fixed cart shopping issues

merge-update-with-lab-changes
Fatimah Alshammari 4 years ago
parent d8db5ad590
commit e2763a5bd5

@ -215,6 +215,17 @@ class OrderPreviewViewModel extends BaseViewModel {
setState(ViewState.Idle); setState(ViewState.Idle);
} }
} }
// bool outOfStock = false;
bool checkCardQuantity(){
bool outOfStock = false;
for (int i = 0; i <cartResponse.shoppingCarts.length; i++) {
if(cartResponse.shoppingCarts[i].product.stockQuantity == 0){
outOfStock = true;
break;
} return outOfStock;
}
}
} }
enum PaymentOption { meda, sadad, visa, mastercard, installments } enum PaymentOption { meda, sadad, visa, mastercard, installments }

@ -1,6 +1,10 @@
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart';
import 'package:diplomaticquarterapp/locator.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
@ -17,6 +21,8 @@ dynamic languageID;
class FinalProductsPage extends StatefulWidget { class FinalProductsPage extends StatefulWidget {
final String id; final String id;
final int productType; // 1 : default, 2 : manufacturer , 3 : recently viewed final int productType; // 1 : default, 2 : manufacturer , 3 : recently viewed
AuthenticatedUserObject authenticatedUserObject =
locator<AuthenticatedUserObject>();
FinalProductsPage({this.id, this.productType = 1}); FinalProductsPage({this.id, this.productType = 1});
@ -606,19 +612,24 @@ class _FinalProductsPageState extends State<FinalProductsPage> {
], ],
), ),
), ),
widget.authenticatedUserObject.isLogin?
Container( Container(
child: IconButton( child: IconButton(
icon: Icon(Icons.shopping_cart, icon: Icon(Icons.shopping_cart,
size: 15, size: 15,
color: Colors.blue,), color: Colors.blue,),
onPressed: () async { onPressed: () async {
GifLoaderDialogUtils.showMyDialog(context);
await addToCartFunction(1, model.finalProducts[index].id);
GifLoaderDialogUtils.hideDialog(context);
Navigator.push( Navigator.push(
context, context,
FadePage(page: CartOrderPage()), FadePage(page: CartOrderPage()),
); );
}, },
), ),
), ):Container(),
], ],
), ),
), ),
@ -665,4 +676,9 @@ class _FinalProductsPageState extends State<FinalProductsPage> {
), ),
)); ));
} }
addToCartFunction(quantity, itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel();
await x.addToCartData(quantity, itemID);
}
} }

@ -1,8 +1,11 @@
import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart';
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/locator.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart';
import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart'; import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart';
@ -22,10 +25,14 @@ import 'package:provider/provider.dart';
import 'package:diplomaticquarterapp/pages/sub_categories_modalsheet.dart'; import 'package:diplomaticquarterapp/pages/sub_categories_modalsheet.dart';
import 'base/base_view.dart'; import 'base/base_view.dart';
class ParentCategorisePage extends StatefulWidget { class ParentCategorisePage extends StatefulWidget {
String id; String id;
String titleName; String titleName;
AuthenticatedUserObject authenticatedUserObject =
locator<AuthenticatedUserObject>();
ParentCategorisePage({this.id, this.titleName}); ParentCategorisePage({this.id, this.titleName});
@override @override
@ -38,7 +45,9 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
String titleName; String titleName;
final dynamic productID; final dynamic productID;
_ParentCategorisePageState({this.id, this.titleName, this.productID});
_ParentCategorisePageState({this.id, this.titleName, this.productID,});
Map<String, bool> values = {'huusam': false, 'ali': false, 'noor': false}; Map<String, bool> values = {'huusam': false, 'ali': false, 'noor': false};
bool checkedBrands = false; bool checkedBrands = false;
@ -1157,6 +1166,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
], ],
), ),
), ),
widget.authenticatedUserObject.isLogin ?
Container( Container(
child: IconButton( child: IconButton(
icon: Icon(Icons.shopping_cart, icon: Icon(Icons.shopping_cart,
@ -1164,15 +1175,15 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
color: Colors.blue,), color: Colors.blue,),
onPressed: () async { onPressed: () async {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
await addToCartFunction(1, productID); await addToCartFunction(1, model.parentProducts[index].id);
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
Navigator.push( Navigator.push(
context, context,
FadePage(page: CartOrderPage()), FadePage(page: CartOrderPage()),
); );
}, },
), )
), ): Container(),
], ],
), ),
), ),
@ -1220,6 +1231,13 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
), ),
), ),
)); ));
}
addToCartFunction(quantity, itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel();
await x.addToCartData(quantity, itemID);
} }
bool isEntityListSelected(CategoriseParentModel masterKey) { bool isEntityListSelected(CategoriseParentModel masterKey) {
@ -1240,8 +1258,6 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
return false; return false;
} }
addToCartFunction(quantity, itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel();
await x.addToCartData(quantity, itemID);
}
} }

@ -21,17 +21,24 @@ import 'package:provider/provider.dart';
import 'cart-page/cart-order-preview.dart'; import 'cart-page/cart-order-preview.dart';
class CartOrderPage extends StatefulWidget { class CartOrderPage extends StatefulWidget {
const CartOrderPage({Key key}) : super(key: key);
const CartOrderPage({ Key key})
: super(key: key);
@override @override
_CartOrderPageState createState() => _CartOrderPageState(); _CartOrderPageState createState() => _CartOrderPageState();
} }
class _CartOrderPageState extends State<CartOrderPage> { class _CartOrderPageState extends State<CartOrderPage> {
bool isLoading = true; bool isLoading = true;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
getData(); getData();
} }
@override @override
@ -269,7 +276,7 @@ class OrderBottomWidget extends StatefulWidget {
class _OrderBottomWidgetState extends State<OrderBottomWidget> { class _OrderBottomWidgetState extends State<OrderBottomWidget> {
bool isAgree = false; bool isAgree = false;
bool outOfStock = false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectProvider = Provider.of(context); ProjectViewModel projectProvider = Provider.of(context);
@ -391,6 +398,7 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
), ),
RaisedButton( RaisedButton(
onPressed: isAgree onPressed: isAgree
// && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0
? () => { ? () => {
Navigator.push( Navigator.push(
context, context,
@ -398,7 +406,7 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
page: page:
OrderPreviewPage(widget.addresses))) OrderPreviewPage(widget.addresses)))
} }
: null, : Text("remove item " ),
child: new Text( child: new Text(
"${TranslationBase.of(context).checkOut}", "${TranslationBase.of(context).checkOut}",
style: new TextStyle( style: new TextStyle(

@ -45,6 +45,7 @@ class _ProductOrderItemState extends State<ProductOrderItem> {
), ),
title: Container( title: Container(
child: Row( child: Row(
// widget.item.product.stock_quantity===0
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
children: [ children: [
@ -166,10 +167,22 @@ class _ProductOrderItemState extends State<ProductOrderItem> {
"$_totalPrice ${projectProvider.isArabic ? widget.item.currencyn : widget.item.currency}", "$_totalPrice ${projectProvider.isArabic ? widget.item.currencyn : widget.item.currency}",
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
) ),
widget.item.product.stockQuantity == 0 ?
Texts(
projectProvider.isArabic
? widget.item.product.stockAvailabilityn
: widget.item.product.stockAvailability,
fontWeight: FontWeight.normal,
fontSize: 13,
color:Colors.red,
): Texts(""),
], ],
), ),
) ),
], ],
), ),
) )

@ -1,5 +1,8 @@
import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart';
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart';
import 'package:diplomaticquarterapp/locator.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -21,6 +24,9 @@ class SubCategorisePage extends StatefulWidget {
String title; String title;
String parentId; String parentId;
AuthenticatedUserObject authenticatedUserObject =
locator<AuthenticatedUserObject>();
SubCategorisePage({this.id, this.parentId, this.title}); SubCategorisePage({this.id, this.parentId, this.title});
@override @override
@ -861,19 +867,24 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
], ],
), ),
), ),
widget.authenticatedUserObject.isLogin?
Container( Container(
child: IconButton( child: IconButton(
icon: Icon(Icons.shopping_cart, icon: Icon(Icons.shopping_cart,
size: 15, size: 15,
color: Colors.blue,), color: Colors.blue,),
onPressed: () async { onPressed: () async {
GifLoaderDialogUtils.showMyDialog(context);
await addToCartFunction(1, model.subProducts[index].id);
GifLoaderDialogUtils.hideDialog(context);
Navigator.push( Navigator.push(
context, context,
FadePage(page: CartOrderPage()), FadePage(page: CartOrderPage()),
); );
}, },
), ),
), ):Container(),
], ],
), ),
), ),
@ -1137,4 +1148,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
} }
return false; return false;
} }
addToCartFunction(quantity, itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel();
await x.addToCartData(quantity, itemID);
}
} }

Loading…
Cancel
Save