BASE: Update Icons & Name Of The App.
This commit is contained in:
@@ -5,12 +5,12 @@ import 'package:customer/models/cart_product_model.dart';
|
||||
import 'package:customer/themes/custom_dialog_box.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'package:get/get.dart' hide Trans;
|
||||
import 'database_helper.dart';
|
||||
|
||||
class CartProvider with ChangeNotifier {
|
||||
final _cartStreamController = StreamController<List<CartProductModel>>.broadcast();
|
||||
final _cartStreamController =
|
||||
StreamController<List<CartProductModel>>.broadcast();
|
||||
List<CartProductModel> _cartItems = [];
|
||||
|
||||
Stream<List<CartProductModel>> get cartStream => _cartStreamController.stream;
|
||||
@@ -24,7 +24,11 @@ class CartProvider with ChangeNotifier {
|
||||
_cartStreamController.sink.add(_cartItems);
|
||||
}
|
||||
|
||||
Future<void> addToCart(BuildContext context, CartProductModel product, int quantity) async {
|
||||
Future<void> addToCart(
|
||||
BuildContext context,
|
||||
CartProductModel product,
|
||||
int quantity,
|
||||
) async {
|
||||
_cartItems = await DatabaseHelper.instance.fetchCartProducts();
|
||||
if ((_cartItems.where((item) => item.id == product.id)).isNotEmpty) {
|
||||
var index = _cartItems.indexWhere((item) => item.id == product.id);
|
||||
@@ -38,7 +42,10 @@ class CartProvider with ChangeNotifier {
|
||||
}
|
||||
await DatabaseHelper.instance.updateCartProduct(_cartItems[index]);
|
||||
} else {
|
||||
if (_cartItems.isEmpty || _cartItems.where((item) => item.vendorID == product.vendorID).isNotEmpty) {
|
||||
if (_cartItems.isEmpty ||
|
||||
_cartItems
|
||||
.where((item) => item.vendorID == product.vendorID)
|
||||
.isNotEmpty) {
|
||||
product.quantity = quantity;
|
||||
_cartItems.add(product);
|
||||
cartItem.add(product);
|
||||
@@ -50,7 +57,9 @@ class CartProvider with ChangeNotifier {
|
||||
builder: (BuildContext context) {
|
||||
return CustomDialogBox(
|
||||
title: "Alert".tr(),
|
||||
descriptions: "Your cart already contains items from another restaurant. Would you like to replace them with items from this restaurant instead?".tr(),
|
||||
descriptions:
|
||||
"Your cart already contains items from another restaurant. Would you like to replace them with items from this restaurant instead?"
|
||||
.tr(),
|
||||
positiveString: "Add".tr(),
|
||||
negativeString: "Cancel".tr(),
|
||||
positiveClick: () async {
|
||||
|
||||
Reference in New Issue
Block a user