Dorixona qidiruv mobil ilovasini ishlab chiqish


Dorilarni ochirish,taxrirlash,korish


Download 212.18 Kb.
bet5/9
Sana03.06.2024
Hajmi212.18 Kb.
#1899112
1   2   3   4   5   6   7   8   9
Bog'liq
Rajabova Gulshira

2.2.Dorilarni ochirish,taxrirlash,korish

Tugma bosilganda


class CartController extends BaseController {
TextEditingController controller;
void Function(void Function())? updater;
bool isLoading = false;

CartController({this.updater})


: controller = TextEditingController();

@override


void close() {
controller.dispose();
super.close();
}

void decrement(


int index,
) {
if (cartManager.cart.carts[index].quantity > 1) {
cartManager.cart.carts[index].quantity--;
cartManager.cart.carts[index].total -= cartManager.cart.carts[index].product.price;
updater!(() {});
}
}

void increment(int index) {


cartManager.cart.carts[index].quantity++;
cartManager.cart.carts[index].total += cartManager.cart.carts[index].product.price;

updater!(() {});


}

void getBack(BuildContext context) {


Navigator.pop(context);
}

void buttomCardItemDelate(int index, BuildContext context) {


showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text("You want to remove from Cart?",
style: AppTextStyles.nunitoSansBold20),
actions: [
TextButton(
onPressed: () {
cartManager.cart.carts.removeAt(index);
Navigator.pop(context);
updater!(() {});
},
child: const Text("Yes",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: AppColors.cEB5757)),
),
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text(
"No",
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
)
],
);
},
);
}
}
SHU KODGA ASOSAN maxsulot savatga qoshiladi

Va sonini oshirish kamaytirish mumkin boladi va puli ham shunga mutanosib tarzda oshib boradi yoki kamayib

Savatni korishimiz ham mumkin boladi
import 'package:flutter/cupertino.dart';
import 'package:furniture_app/controllers/base_controller.dart';
import 'package:furniture_app/models/product_model.dart';
import 'package:furniture_app/screens/cart_screen.dart';
import 'package:furniture_app/services/data/database/products.dart';

import '../screens/product_screen.dart';

class FavoriteController extends BaseController{
void Function(void Function())? updater;
void goToCongrats(BuildContext context) {
Navigator.pushNamed(context, CartScreen.id);
}

void buttonProduct(BuildContext context, Product product) {
Navigator.of(context).pushNamed(ProductScreen.id, arguments: product);
}

FavoriteController({this.updater});


void productDelete(int index){
products.removeAt(index);
updater!((){});
}
}



import 'package:flutter/material.dart';
import 'package:furniture_app/screens/order_internal/detail_screen.dart';
import 'package:furniture_app/screens/order_screen.dart';
import 'package:furniture_app/screens/profile_screen.dart';
import 'base_controller.dart';

class OrderController extends BaseController{


void goToProfile(BuildContext context){
Navigator.of(context).pushReplacementNamed(ProfileScreen.id);
}

void goToDetail(BuildContext context){
Navigator.of(context).pushNamed(DetailScreen.id);
}
void goToOrder(BuildContext context){
Navigator.of(context).popAndPushNamed(OrderScreen.id);
}

}
Kodi shu tarzda yoziladi


import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:furniture_app/controllers/base_controller.dart';
import 'package:furniture_app/models/address_model.dart';
import 'package:furniture_app/models/user_model.dart';
import 'package:furniture_app/services/app_routes.dart';
import 'package:furniture_app/services/config/checker.dart';
import 'package:furniture_app/services/data/database/users.dart';
import 'package:furniture_app/views/utils/message_components.dart';

class SignUpController extends BaseController {
TextEditingController nameController;
TextEditingController emailController;
TextEditingController passwordController;
TextEditingController rePasswordController;

void Function(void Function())? updater;
bool isLoading = false;

SignUpController({this.updater})


: nameController = TextEditingController(),
emailController = TextEditingController(),
passwordController = TextEditingController(),
rePasswordController = TextEditingController();

@override


void close() {
nameController.dispose();
emailController.dispose();
passwordController.dispose();
rePasswordController.dispose();
super.close();
}

void signUp(BuildContext context) async {
isLoading = true;
updater!(() {});

String name = nameController.text.trim();


String email = emailController.text.trim();
String password = passwordController.text.trim();
String rePassword = rePasswordController.text.trim();

debugPrint(name);


debugPrint(email);
debugPrint(password);
debugPrint(rePassword);

isLoading = false;


updater!(() {});

bool existUser = _isExist(email);


bool validate = _validate(name, email, password, rePassword);

if (validate && !existUser) {
int userId = int.parse(usersList.last.userId) + 1;

final newUser = User(
userId: userId.toString(),
name: name,
email: email,
password: password,
createdAt: DateTime.now().toString(),
modifyAt: DateTime.now().toString(),
devices: [],
cards: [],
favourites: [],
addresses: [Address(id: "1", usedid: "1", createdAt: DateTime.now().toString(), modifyAt: DateTime.now().toString(), title: "Address", address: "Address", lat: 0.1, Ing: 0.1, zipCode: "zipCode", street: "", city: "", region: "", country: "")],
);

usersList.add(newUser);


AppRoutes.pushReplaceSignIn(context);
} else {
_wrongCase(context, name, email, password, rePassword);
}
}

void _wrongCase(BuildContext context, String name, String email,
String password, String rePassword) {
if (!Checker.checkName(name) || name.isEmpty) {
AppMessage.customSnackBar(context: context, content: "Invalid name");
} else if (!Checker.checkEmail(email) || email.isEmpty) {
AppMessage.customSnackBar(context: context, content: "Invalid email");
} else if (!Checker.checkPassword(password) || password.isEmpty) {
AppMessage.customSnackBar(context: context, content: "Invalid password");
} else if (!(password == rePassword) || rePassword.isEmpty) {
AppMessage.customSnackBar(
context: context, content: "Password must match");
}
}

bool _isExist(String email) {


for (int i = 0; i < usersList.length; i++) {
if (usersList[i].email == email) {
return true;
}
}
return false;
}

bool _validate(


String name, String email, String password, String rePassword) =>
Checker.checkName(name) &&
Checker.checkEmail(email) &&
Checker.checkPassword(password) &&
password == rePassword;
}
Login tizimga kirish kodi

Profil bolimi orqali email,zakaslarni korish mumkin

Bu yerda yangi malumotlarni korish mumkin boladi yani yangi qoshilgan maxsulot haqida tizim yangiliklari haqida bilish mumkin boladi
import 'package:flutter/cupertino.dart';
import 'package:furniture_app/controllers/base_controller.dart';
import 'package:furniture_app/controllers/data_controller/cart_manager.dart';
import 'package:furniture_app/models/category_model.dart';
import 'package:furniture_app/models/product_model.dart';
import 'package:furniture_app/screens/cart_screen.dart';
import 'package:furniture_app/screens/product_screen.dart';
import 'package:furniture_app/services/data/database/categories.dart';
import 'package:furniture_app/services/data/database/products.dart';

class HomeController extends BaseController {
int initialCategoryPage = 0;
List categoryList = [];
List
productList = [];
void Function(void Function())? updater;
bool isLoading = false;

HomeController({this.updater});

@override
void initial() {
super.initial();
getAllCategory();
}


void buttonTabBar(int index) {
initialCategoryPage = index;
getProduct(index);
updater!(() {});
}


void getAllCategory() {


Download 212.18 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling