From 7b6622ee4cfca05939a1e07b21de4e96168cee57 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Sun, 14 Nov 2021 10:13:53 +0200 Subject: [PATCH 1/7] fix cart order page --- .../screens/cart-page/cart-order-page.dart | 2 +- .../pharmacies/widgets/ProductOrderItem.dart | 83 +++++++++++-------- 2 files changed, 51 insertions(+), 34 deletions(-) diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart index 70858fa9..593a8660 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -128,7 +128,7 @@ class _CartOrderPageState extends State { GifLoaderDialogUtils.hideDialog( context); }); - })) + },model: model,),) ], ), ), diff --git a/lib/pages/pharmacies/widgets/ProductOrderItem.dart b/lib/pages/pharmacies/widgets/ProductOrderItem.dart index 11976175..4301f3cf 100644 --- a/lib/pages/pharmacies/widgets/ProductOrderItem.dart +++ b/lib/pages/pharmacies/widgets/ProductOrderItem.dart @@ -1,4 +1,6 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCart.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; @@ -11,8 +13,10 @@ class ProductOrderItem extends StatefulWidget { final ShoppingCart item; final VoidCallback changeCartItems; final VoidCallback deleteCartItems; + final OrderPreviewViewModel model; - ProductOrderItem(this.item, this.changeCartItems, this.deleteCartItems); + ProductOrderItem(this.item, this.changeCartItems, this.deleteCartItems, + {this.model}); @override _ProductOrderItemState createState() => _ProductOrderItemState(); @@ -40,7 +44,8 @@ class _ProductOrderItemState extends State { leading: InkWell( onTap: () => {widget.deleteCartItems()}, child: Icon( - FontAwesomeIcons.trashAlt,size: 15, + FontAwesomeIcons.trashAlt, + size: 15, color: Colors.grey.shade700, ), ), @@ -50,17 +55,18 @@ class _ProductOrderItemState extends State { crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ - (widget.item.product.images != null && widget.item.product.images.length > 0) + (widget.item.product.images != null && + widget.item.product.images.length > 0) ? Image.network( - widget.item.product.images[0].src, - fit: BoxFit.cover, - height: 80, - ) + widget.item.product.images[0].src, + fit: BoxFit.cover, + height: 80, + ) : Image.asset( - "assets/images/no_image.png", - fit: BoxFit.cover, - height: 80, - ), + "assets/images/no_image.png", + fit: BoxFit.cover, + height: 80, + ), Expanded( child: Container( margin: @@ -101,7 +107,9 @@ class _ProductOrderItemState extends State { width: 25, height: 25, child: Icon( - Icons.remove, color: Colors.grey.shade400, size: 20, + Icons.remove, + color: Colors.grey.shade400, + size: 20, ), decoration: BoxDecoration( border: Border.all( @@ -129,7 +137,8 @@ class _ProductOrderItemState extends State { if (value == null) { widget.item.quantity = 0; } else { - widget.item.quantity = int.parse(text); + widget.item.quantity = + int.parse(text); } _totalPrice = "${(widget.item.product.price * widget.item.quantity).toStringAsFixed(2)}"; @@ -144,7 +153,9 @@ class _ProductOrderItemState extends State { width: 25, height: 25, child: Icon( - Icons.add, color: Colors.grey.shade400, size: 20, + Icons.add, + color: Colors.grey.shade400, + size: 20, ), decoration: BoxDecoration( border: Border.all( @@ -169,21 +180,21 @@ class _ProductOrderItemState extends State { fontSize: 12, 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(""), + 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(""), ], ), ), - - ], ), ) @@ -209,7 +220,7 @@ class _ProductOrderItemState extends State { _quantityOnChangeClick(Operation operation) { int newValue = 0; - setState(() { + setState(() async { switch (operation) { case Operation.inc: { @@ -230,14 +241,20 @@ class _ProductOrderItemState extends State { } if (newValue > 0) { widget.item.quantity = newValue; - _quantityController.text = "${widget.item.quantity}"; - _totalPrice = - "${(widget.item.product.price * widget.item.quantity).toStringAsFixed(2)}"; + await widget.changeCartItems(); + if (widget.model.state == ViewState.ErrorLocal) { + if (operation == Operation.dec) { + newValue = widget.item.quantity + 1; + } else { + newValue = widget.item.quantity - 1; + } + } else { + _quantityController.text = "${widget.item.quantity}"; + _totalPrice = + "${(widget.item.product.price * widget.item.quantity).toStringAsFixed(2)}"; + } } }); - if (newValue > 0) { - widget.changeCartItems(); - } } @override From ff86dcbdc09e9d41de992f093b5a7722f7b7dcfa Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Sun, 14 Nov 2021 10:34:46 +0200 Subject: [PATCH 2/7] sub categories pagnation --- .../service/pharmacy_categorise_service.dart | 9 +- .../pharmacy_categorise_view_model.dart | 30 +- lib/pages/parent_categorise_page.dart | 962 +++++++++--------- .../screens/cart-page/cart-order-page.dart | 2 +- .../pharmacies/widgets/ProductOrderItem.dart | 77 +- lib/pages/sub_categorise_page.dart | 32 +- 6 files changed, 601 insertions(+), 511 deletions(-) diff --git a/lib/core/service/pharmacy_categorise_service.dart b/lib/core/service/pharmacy_categorise_service.dart index 3cc45680..be376c91 100644 --- a/lib/core/service/pharmacy_categorise_service.dart +++ b/lib/core/service/pharmacy_categorise_service.dart @@ -187,11 +187,14 @@ class PharmacyCategoriseService extends BaseService { ); } - Future getSubProducts({String id}) async { + Future getSubProducts( + {String id, int pageIndex, bool isLoading = false}) async { hasError = false; - _subProductsList.clear(); + if (isLoading == false) { + _subProductsList.clear(); + } String endPoint = id != null - ? GET_SUB_PRODUCTS + "$id" + '&page=1&limit=50' + ? GET_SUB_PRODUCTS + "$id" + '&page=' + '$pageIndex' + '&limit=24' : GET_SUB_PRODUCTS + ""; await baseAppClient.getPharmacy( endPoint, diff --git a/lib/core/viewModels/pharmacy_categorise_view_model.dart b/lib/core/viewModels/pharmacy_categorise_view_model.dart index fcae18d2..2be2f14c 100644 --- a/lib/core/viewModels/pharmacy_categorise_view_model.dart +++ b/lib/core/viewModels/pharmacy_categorise_view_model.dart @@ -121,7 +121,7 @@ class PharmacyCategoriseViewModel extends BaseViewModel { hasError = false; // _insuranceCardService.clearInsuranceCard(); setState(ViewState.BusyLocal); - //GifLoaderDialogUtils.showMyDialog(context); + GifLoaderDialogUtils.showMyDialog(context); await _pharmacyCategoriseService.getParentProducts( id: i, pageNumber: pageIndex, isLoading: isLoading); if (_pharmacyCategoriseService.hasError) { @@ -129,31 +129,45 @@ class PharmacyCategoriseViewModel extends BaseViewModel { setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); - //GifLoaderDialogUtils.hideDialog(context); + GifLoaderDialogUtils.hideDialog(context); } - Future getSubCategorise({String i}) async { + Future getSubCategorise( + {String i, + int pageIndex, + bool isLoading = false, + BuildContext context}) async { hasError = false; // _insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); - await _pharmacyCategoriseService.getSubCategorise(id: i); + await _pharmacyCategoriseService.getSubCategorise( + id: i, + ); if (_pharmacyCategoriseService.hasError) { error = _pharmacyCategoriseService.error; setState(ViewState.ErrorLocal); } else - getSubProducts(i: i); + getSubProducts( + i: i, pageIndex: pageIndex, isLoading: isLoading, context: context); } - Future getSubProducts({String i}) async { + Future getSubProducts( + {String i, + int pageIndex, + bool isLoading = false, + BuildContext context}) async { hasError = false; // _insuranceCardService.clearInsuranceCard(); - setState(ViewState.Busy); - await _pharmacyCategoriseService.getSubProducts(id: i); + setState(ViewState.BusyLocal); + GifLoaderDialogUtils.showMyDialog(context); + await _pharmacyCategoriseService.getSubProducts( + id: i, pageIndex: pageIndex, isLoading: isLoading); if (_pharmacyCategoriseService.hasError) { error = _pharmacyCategoriseService.error; setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); + GifLoaderDialogUtils.hideDialog(context); } Future getFinalProducts({String i}) async { diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 461e837c..5a917897 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -689,150 +689,159 @@ class _ParentCategorisePageState extends State { ), model.parentProducts.isNotEmpty ? styleOne == true - ? model.state != ViewState.BusyLocal - ? Container( - height: - model.parentProducts.length * - MediaQuery.of(context) - .size - .height * - 0.15, - child: GridView.builder( - physics: - NeverScrollableScrollPhysics(), - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 0.5, - mainAxisSpacing: 2.0, - childAspectRatio: 0.9, - ), - itemCount: - model.parentProducts.length, - itemBuilder: - (BuildContext context, - int index) { - return NetworkBaseView( - baseViewModel: model, - child: InkWell( - child: Card( - color: model - .parentProducts[ - index] - .discountName != - null - ? Color( - 0xffFFFF00) - : Colors.white, - elevation: 0, - shape: Border( - right: BorderSide( - color: Colors.grey - .shade300, - width: 1, - ), - left: BorderSide( - color: Colors.grey - .shade300, - width: 1, - ), - bottom: BorderSide( - color: Colors.grey - .shade300, - width: 1, - ), - top: BorderSide( - color: Colors.grey - .shade300, - width: 1, - ), - ), - margin: EdgeInsets - .symmetric( - horizontal: 8, - vertical: 4, + ? Container( + height: model.parentProducts.length * + MediaQuery.of(context) + .size + .height * + 0.15, + child: GridView.builder( + physics: + NeverScrollableScrollPhysics(), + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + crossAxisSpacing: 0.5, + mainAxisSpacing: 2.0, + childAspectRatio: 0.9, + ), + itemCount: + model.parentProducts.length, + itemBuilder: (BuildContext context, + int index) { + return NetworkBaseView( + baseViewModel: model, + child: InkWell( + child: Card( + color: model + .parentProducts[ + index] + .discountName != + null + ? Color(0xffFFFF00) + : Colors.white, + elevation: 0, + shape: Border( + right: BorderSide( + color: Colors + .grey.shade300, + width: 1, + ), + left: BorderSide( + color: Colors + .grey.shade300, + width: 1, + ), + bottom: BorderSide( + color: Colors + .grey.shade300, + width: 1, + ), + top: BorderSide( + color: Colors + .grey.shade300, + width: 1, + ), + ), + margin: + EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + child: Container( + decoration: + BoxDecoration( + borderRadius: + BorderRadius.only( + topLeft: + Radius.circular( + 110.0), ), - child: Container( - decoration: - BoxDecoration( - borderRadius: - BorderRadius - .only( - topLeft: Radius - .circular( - 110.0), - ), - color: - Colors.white, - ), - padding: EdgeInsets - .symmetric( - horizontal: - 0), - width: MediaQuery.of( - context) - .size - .width / - 3, - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + color: Colors.white, + ), + padding: EdgeInsets + .symmetric( + horizontal: 0), + width: MediaQuery.of( + context) + .size + .width / + 3, + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Stack( children: [ - Stack( - children: [ - if (model - .parentProducts[index] - .discountName != - null) - RotatedBox( - quarterTurns: - 4, + if (model + .parentProducts[ + index] + .discountName != + null) + RotatedBox( + quarterTurns: + 4, + child: + Container( + decoration: + BoxDecoration(), + child: + Padding( + padding: + EdgeInsets.only( + right: + 5.0, + top: + 20.0, + bottom: + 5.0, + ), child: - Container( - decoration: - BoxDecoration(), - child: - Padding( - padding: - EdgeInsets.only( - right: 5.0, - top: 20.0, - bottom: 5.0, - ), - child: - Texts( - TranslationBase.of(context).offers.toUpperCase(), - color: Colors.red, - fontSize: 13.0, - fontWeight: FontWeight.w900, - ), - ), - transform: - new Matrix4.rotationZ(5.837200), + Texts( + TranslationBase.of(context) + .offers + .toUpperCase(), + color: + Colors.red, + fontSize: + 13.0, + fontWeight: + FontWeight.w900, ), ), - Container( - margin: EdgeInsets - .fromLTRB( - 0, - 16, - 0, - 0), - alignment: - Alignment - .center, - child: Image - .network( - model.parentProducts[index].images.isNotEmpty - ? model.parentProducts[index].images[0].thumb - : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', - fit: BoxFit - .cover, - height: - 80, - ), + transform: + new Matrix4.rotationZ( + 5.837200), ), + ), + Container( + margin: EdgeInsets + .fromLTRB( + 0, + 16, + 0, + 0), + alignment: + Alignment + .center, + child: Image + .network( + model + .parentProducts[ + index] + .images + .isNotEmpty + ? model + .parentProducts[index] + .images[0] + .thumb + : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', + fit: BoxFit + .cover, + height: 80, + ), + ), // Container( // width: model.parentProducts[index].rxMessage != // null @@ -882,280 +891,67 @@ class _ParentCategorisePageState extends State { // .w400, // // ), // ), - ], - ), - Container( - margin: EdgeInsets - .symmetric( - horizontal: - 6, - vertical: 0, - ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - if (model - .parentProducts[index] - .discountName != - null) - Container( - width: - double.infinity, - height: - 13.0, - decoration: - BoxDecoration( - color: - Color(0xff5AB145), - ), - child: - Center( - child: - Texts( - model.parentProducts[index].discountName, - regular: true, - color: Colors.white, - fontSize: 10.4, - ), - ), - ), - Texts( - projectViewModel.isArabic - ? model.parentProducts[index].namen - : model.parentProducts[index].name, - regular: - true, - fontSize: - 12, - fontWeight: - FontWeight.w700, - ), - Padding( - padding: const EdgeInsets.only( - top: - 4, - bottom: - 4), - child: - Texts( - "SAR ${model.parentProducts[index].price}", - bold: - true, - fontSize: - 14, - ), - ), - Row( - children: [ -// StarRating( -// totalAverage: model.parentProducts[index].approvedRatingSum > 0 -// ? (model.parentProducts[index].approvedRatingSum.toDouble() / model.parentProducts[index].approvedRatingSum.toDouble()).toDouble() -// : 0, -// forceStars: true), - RatingBar - .readOnly( - initialRating: - model.parentProducts[index].approvedRatingSum.toDouble(), - size: - 15.0, - filledColor: - Colors.yellow[700], - emptyColor: - Colors.grey[500], - isHalfAllowed: - true, - halfFilledIcon: - Icons.star_half, - filledIcon: - Icons.star, - emptyIcon: - Icons.star, - ), - Texts( - "(${model.parentProducts[index].approvedTotalReviews})", - regular: - true, - fontSize: - 10, - fontWeight: - FontWeight.w400, - ) - ], - ), - ], - ), - ), - ], - ), - ), - ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage( - model.parentProducts[ - index]), - )), - }, - )); - }, - ), - ) - : Container( - height: - model.parentProducts.length * - MediaQuery.of(context) - .size - .height * - 0.122, - child: ListView.builder( - physics: - NeverScrollableScrollPhysics(), - itemCount: model - .parentProducts.length, - itemBuilder: - (BuildContext context, - int index) { - return InkWell( - child: Card( - child: Row( - children: [ - Stack( - children: [ - Column( - children: [ - Container( - decoration: - BoxDecoration(), - child: - Padding( - padding: - EdgeInsets.only( - left: - 9.0, - top: - 8.0, - right: - 10.0, - ), - ), - ), - Container( - margin: EdgeInsets - .fromLTRB( - 0, - 0, - 0, - 0), - alignment: - Alignment - .center, - child: model - .parentProducts[ - index] - .images - .isNotEmpty - ? Image - .network( - model.parentProducts[index].images[0].thumb, - fit: BoxFit.contain, - height: 70, - ) - : Text( - TranslationBase.of(context).noImage), - ), - ], - ), - Column( - children: [ - Container( - width: model.parentProducts[index].rxMessage != - null - ? MediaQuery.of(context).size.width / - 5.3 - : 0, - padding: - EdgeInsets.all( - 4), - decoration: - BoxDecoration( - color: Color( - 0xffb23838), - borderRadius: - BorderRadius.only(topLeft: Radius.circular(6)), - ), - child: model.parentProducts[index].rxMessage != - null - ? Texts( - projectProvider.isArabic ? model.parentProducts[index].rxMessagen : model.parentProducts[index].rxMessage, - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ) - : Texts( - ""), -// Texts( -// model.parentProducts[index].rxMessage != null ? model.parentProducts[index].rxMessage : "", -// color: Colors.white, -// regular: true, -// fontSize: 10, -// fontWeight: FontWeight.w400, -// ), - ), - ], - ), ], ), Container( margin: EdgeInsets .symmetric( - horizontal: 0, + horizontal: 6, vertical: 0, ), child: Column( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, crossAxisAlignment: CrossAxisAlignment .start, children: [ - SizedBox( - height: 4.0, - ), - Container( - width: MediaQuery.of(context) - .size - .width * - 0.635, - child: - Texts( - projectViewModel - .isArabic - ? model - .parentProducts[ - index] - .namen - : model + if (model + .parentProducts[ + index] + .discountName != + null) + Container( + width: double + .infinity, + height: + 13.0, + decoration: + BoxDecoration( + color: Color( + 0xff5AB145), + ), + child: + Center( + child: + Texts( + model .parentProducts[index] - .name, - regular: - true, - fontSize: - 13.2, - fontWeight: - FontWeight - .w500, - maxLines: - 5, + .discountName, + regular: + true, + color: + Colors.white, + fontSize: + 10.4, + ), + ), ), - ), - SizedBox( - height: 8.0, + Texts( + projectViewModel + .isArabic + ? model + .parentProducts[ + index] + .namen + : model + .parentProducts[index] + .name, + regular: + true, + fontSize: + 12, + fontWeight: + FontWeight + .w700, ), Padding( padding: const EdgeInsets @@ -1174,11 +970,11 @@ class _ParentCategorisePageState extends State { ), Row( children: [ -// StarRating( -// totalAverage: model.parentProducts[index].approvedRatingSum > 0 -// ? (model.parentProducts[index].approvedRatingSum.toDouble() / model.parentProducts[index].approvedRatingSum.toDouble()).toDouble() -// : 0, -// forceStars: true), +// StarRating( +// totalAverage: model.parentProducts[index].approvedRatingSum > 0 +// ? (model.parentProducts[index].approvedRatingSum.toDouble() / model.parentProducts[index].approvedRatingSum.toDouble()).toDouble() +// : 0, +// forceStars: true), RatingBar .readOnly( initialRating: model @@ -1214,11 +1010,258 @@ class _ParentCategorisePageState extends State { ], ), ), - widget.authenticatedUserObject - .isLogin - ? Container( - child: IconButton( - icon: Icon( + ], + ), + ), + ), + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage( + model.parentProducts[ + index]), + )), + }, + )); + }, + ), + ) + : Container( + height: model.parentProducts.length * + MediaQuery.of(context) + .size + .height * + 0.122, + child: ListView.builder( + physics: + NeverScrollableScrollPhysics(), + itemCount: + model.parentProducts.length, + itemBuilder: + (BuildContext context, + int index) { + return InkWell( + child: Card( + child: Row( + children: [ + Stack( + children: [ + Column( + children: [ + Container( + decoration: + BoxDecoration(), + child: + Padding( + padding: + EdgeInsets + .only( + left: 9.0, + top: 8.0, + right: + 10.0, + ), + ), + ), + Container( + margin: EdgeInsets + .fromLTRB( + 0, + 0, + 0, + 0), + alignment: + Alignment + .center, + child: model + .parentProducts[ + index] + .images + .isNotEmpty + ? Image + .network( + model + .parentProducts[index] + .images[0] + .thumb, + fit: BoxFit + .contain, + height: + 70, + ) + : Text(TranslationBase.of( + context) + .noImage), + ), + ], + ), + Column( + children: [ + Container( + width: model.parentProducts[index].rxMessage != + null + ? MediaQuery.of(context) + .size + .width / + 5.3 + : 0, + padding: + EdgeInsets + .all( + 4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), + borderRadius: + BorderRadius.only( + topLeft: + Radius.circular(6)), + ), + child: model.parentProducts[index] + .rxMessage != + null + ? Texts( + projectProvider.isArabic + ? model.parentProducts[index].rxMessagen + : model.parentProducts[index].rxMessage, + color: + Colors.white, + regular: + true, + fontSize: + 10, + fontWeight: + FontWeight.w400, + ) + : Texts(""), +// Texts( +// model.parentProducts[index].rxMessage != null ? model.parentProducts[index].rxMessage : "", +// color: Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: FontWeight.w400, +// ), + ), + ], + ), + ], + ), + Container( + margin: EdgeInsets + .symmetric( + horizontal: 0, + vertical: 0, + ), + child: Column( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + SizedBox( + height: 4.0, + ), + Container( + width: MediaQuery.of( + context) + .size + .width * + 0.635, + child: Texts( + projectViewModel + .isArabic + ? model + .parentProducts[ + index] + .namen + : model + .parentProducts[ + index] + .name, + regular: true, + fontSize: + 13.2, + fontWeight: + FontWeight + .w500, + maxLines: 5, + ), + ), + SizedBox( + height: 8.0, + ), + Padding( + padding: + const EdgeInsets + .only( + top: 4, + bottom: + 4), + child: Texts( + "SAR ${model.parentProducts[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ +// StarRating( +// totalAverage: model.parentProducts[index].approvedRatingSum > 0 +// ? (model.parentProducts[index].approvedRatingSum.toDouble() / model.parentProducts[index].approvedRatingSum.toDouble()).toDouble() +// : 0, +// forceStars: true), + RatingBar + .readOnly( + initialRating: model + .parentProducts[ + index] + .approvedRatingSum + .toDouble(), + size: 15.0, + filledColor: + Colors.yellow[ + 700], + emptyColor: + Colors.grey[ + 500], + isHalfAllowed: + true, + halfFilledIcon: + Icons + .star_half, + filledIcon: + Icons + .star, + emptyIcon: + Icons + .star, + ), + Texts( + "(${model.parentProducts[index].approvedTotalReviews})", + regular: + true, + fontSize: + 10, + fontWeight: + FontWeight + .w400, + ) + ], + ), + ], + ), + ), + widget.authenticatedUserObject + .isLogin + ? Container( + child: + IconButton( + icon: + Icon( Icons .shopping_cart, size: @@ -1226,7 +1269,8 @@ class _ParentCategorisePageState extends State { color: CustomColors.green, ), - onPressed: () async { + onPressed: + () async { if (model.parentProducts[index].rxMessage == null) { GifLoaderDialogUtils.showMyDialog(context); @@ -1238,66 +1282,54 @@ class _ParentCategorisePageState extends State { AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); } }), - ) - : Container(), - ], - ), - ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage( - model.parentProducts[ - index]), - )), - }, - ); - }), - ) - : Padding( - padding: const EdgeInsets.all(12.0), - child: Container( - child: Center( - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Padding( - padding: - const EdgeInsets.all( - 8.0), - child: Image.asset( - 'assets/images/new-design/empty_box.png', - width: 100, - height: 100, - fit: BoxFit.cover, + ) + : Container(), + ], ), ), - Padding( - padding: - const EdgeInsets.all( - 8.0), - child: Text( - TranslationBase.of( - context) - .noData, - // 'There is no data', - style: TextStyle( - fontSize: 30), - ), - ) - ], + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage( + model.parentProducts[ + index]), + )), + }, + ); + }), + ) + : Padding( + padding: const EdgeInsets.all(12.0), + child: Container( + child: Center( + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Padding( + padding: + const EdgeInsets.all(8.0), + child: Image.asset( + 'assets/images/new-design/empty_box.png', + width: 100, + height: 100, + fit: BoxFit.cover, + ), ), - ), + Padding( + padding: + const EdgeInsets.all(8.0), + child: Text( + TranslationBase.of(context) + .noData, + // 'There is no data', + style: + TextStyle(fontSize: 30), + ), + ) + ], ), - ) - : Center( - child: CircularProgressIndicator( - backgroundColor: Colors.white, - valueColor: - AlwaysStoppedAnimation( - Colors.grey[500], ), ), ) diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart index 524501e1..0e5f1731 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -121,7 +121,7 @@ class _CartOrderPageState extends State { // '${value.quantityCount ?? 0}'); } }); - })) + }, model)) ], ), ), diff --git a/lib/pages/pharmacies/widgets/ProductOrderItem.dart b/lib/pages/pharmacies/widgets/ProductOrderItem.dart index 11976175..e6441fe2 100644 --- a/lib/pages/pharmacies/widgets/ProductOrderItem.dart +++ b/lib/pages/pharmacies/widgets/ProductOrderItem.dart @@ -1,6 +1,9 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCart.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -11,8 +14,10 @@ class ProductOrderItem extends StatefulWidget { final ShoppingCart item; final VoidCallback changeCartItems; final VoidCallback deleteCartItems; + final OrderPreviewViewModel model; - ProductOrderItem(this.item, this.changeCartItems, this.deleteCartItems); + ProductOrderItem( + this.item, this.changeCartItems, this.deleteCartItems, this.model); @override _ProductOrderItemState createState() => _ProductOrderItemState(); @@ -40,7 +45,8 @@ class _ProductOrderItemState extends State { leading: InkWell( onTap: () => {widget.deleteCartItems()}, child: Icon( - FontAwesomeIcons.trashAlt,size: 15, + FontAwesomeIcons.trashAlt, + size: 15, color: Colors.grey.shade700, ), ), @@ -50,17 +56,18 @@ class _ProductOrderItemState extends State { crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ - (widget.item.product.images != null && widget.item.product.images.length > 0) + (widget.item.product.images != null && + widget.item.product.images.length > 0) ? Image.network( - widget.item.product.images[0].src, - fit: BoxFit.cover, - height: 80, - ) + widget.item.product.images[0].src, + fit: BoxFit.cover, + height: 80, + ) : Image.asset( - "assets/images/no_image.png", - fit: BoxFit.cover, - height: 80, - ), + "assets/images/no_image.png", + fit: BoxFit.cover, + height: 80, + ), Expanded( child: Container( margin: @@ -95,13 +102,17 @@ class _ProductOrderItemState extends State { child: Row( children: [ InkWell( - onTap: () => - {_quantityOnChangeClick(Operation.dec)}, + onTap: () => widget.model.error.isEmpty + ? {_quantityOnChangeClick(Operation.dec)} + : Utils.showErrorToast( + widget.model.error), child: Container( width: 25, height: 25, child: Icon( - Icons.remove, color: Colors.grey.shade400, size: 20, + Icons.remove, + color: Colors.grey.shade400, + size: 20, ), decoration: BoxDecoration( border: Border.all( @@ -129,7 +140,8 @@ class _ProductOrderItemState extends State { if (value == null) { widget.item.quantity = 0; } else { - widget.item.quantity = int.parse(text); + widget.item.quantity = + int.parse(text); } _totalPrice = "${(widget.item.product.price * widget.item.quantity).toStringAsFixed(2)}"; @@ -138,13 +150,17 @@ class _ProductOrderItemState extends State { )), ), InkWell( - onTap: () => - {_quantityOnChangeClick(Operation.inc)}, + onTap: () => widget.model.error == null + ? {_quantityOnChangeClick(Operation.inc)} + : Utils.showErrorToast( + widget.model.error), child: Container( width: 25, height: 25, child: Icon( - Icons.add, color: Colors.grey.shade400, size: 20, + Icons.add, + color: Colors.grey.shade400, + size: 20, ), decoration: BoxDecoration( border: Border.all( @@ -169,21 +185,21 @@ class _ProductOrderItemState extends State { fontSize: 12, 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(""), + 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(""), ], ), ), - - ], ), ) @@ -209,6 +225,7 @@ class _ProductOrderItemState extends State { _quantityOnChangeClick(Operation operation) { int newValue = 0; + setState(() { switch (operation) { case Operation.inc: diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index b7c5d244..4bc069dc 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.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'; @@ -18,6 +19,7 @@ import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; @@ -55,6 +57,10 @@ class _SubCategorisePageState extends State { color: Colors.blue, size: 29.0, ); + + int pageIndex = 1; + + RefreshController controller = RefreshController(); List entityList = List(); List entityListBrands = List(); @@ -65,7 +71,8 @@ class _SubCategorisePageState extends State { ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectProvider = Provider.of(context); return BaseView( - onModelReady: (model) => model.getSubCategorise(i: id), + onModelReady: (model) => model.getSubCategorise( + i: id, pageIndex: pageIndex, isLoading: false, context: context), allowAny: true, builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => @@ -75,9 +82,26 @@ class _SubCategorisePageState extends State { isShowAppBar: true, backgroundColor: Colors.white, isShowDecPage: false, - //baseViewModel: model, - body: NetworkBaseView( - baseViewModel: model, + baseViewModel: model, + body: SmartRefresher( + controller: controller, + enablePullDown: false, + enablePullUp: true, + onLoading: () async { + setState(() { + ++pageIndex; + }); + await model.getSubProducts( + pageIndex: pageIndex, + i: id, + isLoading: true, + context: context); + if (model.state != ViewState.BusyLocal && pageIndex < 5) { + controller.loadComplete(); + } else { + controller.loadFailed(); + } + }, child: SingleChildScrollView( child: Container( child: Column( From 258e107e1b3d97c976cc2357fa8dac9bb0fc2fb6 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Sun, 14 Nov 2021 10:40:44 +0200 Subject: [PATCH 3/7] fix cart order page --- .../screens/cart-page/cart-order-page.dart | 81 ++++++++++--------- .../pharmacies/widgets/ProductOrderItem.dart | 11 +-- 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart index 593a8660..c50399f8 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -91,46 +91,47 @@ class _CartOrderPageState extends State { endIndent: 0, ), Container( - child: Column( - children: [ - ...List.generate( - model.cartResponse.shoppingCarts != null - ? model.cartResponse.shoppingCarts.length - : 0, - (index) => ProductOrderItem( - model.cartResponse - .shoppingCarts[index], () async { - GifLoaderDialogUtils.showMyDialog( - context); - await model.changeProductQuantity(model - .cartResponse.shoppingCarts[index]); - if (model.state != ViewState.Error) { - // appScaffold.appBar.badgeUpdater( - // '${value.quantityCount ?? 0}'); - } - if (model.state == - ViewState.ErrorLocal) { - Utils.showErrorToast(model.error); - } - GifLoaderDialogUtils.hideDialog( - context); - }, () async { - GifLoaderDialogUtils.showMyDialog( - context); - await model - .deleteProduct(model.cartResponse - .shoppingCarts[index]) - .then((value) { - if (model.state == - ViewState.ErrorLocal) { - Utils.showErrorToast(model.error); - } - GifLoaderDialogUtils.hideDialog( - context); - }); - },model: model,),) - ], - ), + child: ListView.builder( + itemCount: + model.cartResponse.shoppingCarts.length, + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: const AlwaysScrollableScrollPhysics (), + itemBuilder: (context, index) { + return ProductOrderItem( + item:model.cartResponse + .shoppingCarts[index], + changeCartItems:() async { + GifLoaderDialogUtils.showMyDialog( + context); + await model.changeProductQuantity(model + .cartResponse.shoppingCarts[index]); + if (model.state != ViewState.Error) { + } + if (model.state == + ViewState.ErrorLocal) { + Utils.showErrorToast(model.error); + } + GifLoaderDialogUtils.hideDialog( + context); + }, + + deleteCartItems:() async { + GifLoaderDialogUtils.showMyDialog( + context); + await model + .deleteProduct(model.cartResponse + .shoppingCarts[index]) + .then((value) { + if (model.state == + ViewState.ErrorLocal) { + Utils.showErrorToast(model.error); + } + GifLoaderDialogUtils.hideDialog( + context); + }); + },model: model,); + }), ), const Divider( color: Color(0xFFD6D6D6), diff --git a/lib/pages/pharmacies/widgets/ProductOrderItem.dart b/lib/pages/pharmacies/widgets/ProductOrderItem.dart index 4301f3cf..a49c1273 100644 --- a/lib/pages/pharmacies/widgets/ProductOrderItem.dart +++ b/lib/pages/pharmacies/widgets/ProductOrderItem.dart @@ -15,8 +15,8 @@ class ProductOrderItem extends StatefulWidget { final VoidCallback deleteCartItems; final OrderPreviewViewModel model; - ProductOrderItem(this.item, this.changeCartItems, this.deleteCartItems, - {this.model}); + ProductOrderItem({this.item, this.changeCartItems, this.deleteCartItems, + this.model}); @override _ProductOrderItemState createState() => _ProductOrderItemState(); @@ -28,14 +28,15 @@ class _ProductOrderItemState extends State { @override void initState() { - _quantityController.text = "${widget.item.quantity}"; - _totalPrice = - "${(widget.item.product.price * widget.item.quantity).toStringAsFixed(2)}"; + super.initState(); } @override Widget build(BuildContext context) { + _quantityController.text = "${widget.item.quantity}"; + _totalPrice = + "${(widget.item.product.price * widget.item.quantity).toStringAsFixed(2)}"; ProjectViewModel projectProvider = Provider.of(context); return Column( From 3bfca80ab9a859e78b300f067027ce16d8c1c564 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Sun, 14 Nov 2021 12:04:18 +0300 Subject: [PATCH 4/7] fixed issue --- lib/pages/pharmacy/order/Order.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pages/pharmacy/order/Order.dart b/lib/pages/pharmacy/order/Order.dart index 8b3f8502..8d6a55b0 100644 --- a/lib/pages/pharmacy/order/Order.dart +++ b/lib/pages/pharmacy/order/Order.dart @@ -51,6 +51,8 @@ class _OrderPageState extends State _tabController = new TabController( length: 4, vsync: this, + + // initialIndex: 1 ); } @@ -379,6 +381,7 @@ class _OrderPageState extends State processingOrderList.add(model.orders[i]); } } + _tabController.index = 1; return Container( width: MediaQuery.of(context).size.width, child: processingOrderList.length != 0 From 79d99dd48aede28d2730f22853c9e3f186273cd7 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 14 Nov 2021 12:22:02 +0300 Subject: [PATCH 5/7] Pharmacy security updates applied --- lib/config/shared_pref_kay.dart | 1 + .../customer_addresses_service.dart | 3 +- .../parmacyModule/order-preview-service.dart | 7 +- .../parmacyModule/parmacy_module_service.dart | 50 +-- .../order_model_view_model.dart | 4 +- .../NewCMC/new_cmc_step_tow_page.dart | 1 - .../cart-page/payment_bottom_widget.dart | 97 ++--- lib/pages/pharmacy/order/Order.dart | 372 ++++++------------ lib/pages/pharmacy/order/OrderDetails.dart | 20 +- lib/pages/pharmacy/profile/profile.dart | 10 +- .../orderDetails_service.dart | 3 +- .../pharmacy_services/order_service.dart | 39 +- .../pharmacyAddress_service.dart | 3 +- 13 files changed, 213 insertions(+), 397 deletions(-) diff --git a/lib/config/shared_pref_kay.dart b/lib/config/shared_pref_kay.dart index c256d0c1..723e17a0 100644 --- a/lib/config/shared_pref_kay.dart +++ b/lib/config/shared_pref_kay.dart @@ -21,6 +21,7 @@ const THEME_VALUE = 'is_vibration'; const MAIN_USER = 'main-user'; const PHARMACY_LAST_VISITED_PRODUCTS = 'last-visited'; const PHARMACY_CUSTOMER_ID = 'costumer-id'; +const PHARMACY_CUSTOMER_GUID = 'customer-guid'; const PHARMACY_CUSTOMER_OBJECT = 'pharmacy-customer-object'; const IS_ROBOT_VISIBLE = 'robot-visible'; const IS_ROBOT_INIT = 'robot-init'; diff --git a/lib/core/service/AlHabibMedicalService/customer_addresses_service.dart b/lib/core/service/AlHabibMedicalService/customer_addresses_service.dart index bd2e94e4..6b6112bb 100644 --- a/lib/core/service/AlHabibMedicalService/customer_addresses_service.dart +++ b/lib/core/service/AlHabibMedicalService/customer_addresses_service.dart @@ -39,7 +39,8 @@ class CustomerAddressesService extends BaseService { Map queryParams = {'fields': 'addresses'}; hasError = false; var customerID = await sharedPref.getObject(PHARMACY_CUSTOMER_ID); - await baseAppClient.getPharmacy("$BASE_PHARMACY_URL$GET_CUSTOMER_ADDRESSES$customerID", onSuccess: (dynamic response, int statusCode) { + var customerGUID = await sharedPref.getObject(PHARMACY_CUSTOMER_GUID); + await baseAppClient.getPharmacy("$BASE_PHARMACY_URL$GET_CUSTOMER_ADDRESSES$customerID/$customerGUID", onSuccess: (dynamic response, int statusCode) { addressesList.clear(); response["customers"][0]["addresses"].forEach((data) { addressesList.add(AddressInfo.fromJson(data)); diff --git a/lib/core/service/parmacyModule/order-preview-service.dart b/lib/core/service/parmacyModule/order-preview-service.dart index 899cc66b..8b56b739 100644 --- a/lib/core/service/parmacyModule/order-preview-service.dart +++ b/lib/core/service/parmacyModule/order-preview-service.dart @@ -21,10 +21,11 @@ class OrderPreviewService extends BaseService { Future getAddresses() async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); + var customerGUID = await sharedPref.getString(PHARMACY_CUSTOMER_GUID); Map queryParams = {'fields': 'addresses'}; hasError = false; try { - await baseAppClient.getPharmacy("$GET_CUSTOMERS_ADDRESSES$customerId", onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy("$GET_CUSTOMERS_ADDRESSES$customerId/$customerGUID", onSuccess: (dynamic response, int statusCode) { addresses.clear(); response['customers'][0]['addresses'].forEach((item) { addresses.add(Addresses.fromJson(item)); @@ -58,13 +59,15 @@ class OrderPreviewService extends BaseService { Future getShoppingCart() async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); + var customerGUID = await sharedPref.getObject(PHARMACY_CUSTOMER_GUID); + if (customerId == null) return null; Map queryParams = {'shopping_cart_type': '1'}; dynamic localRes; hasError = false; try { - await baseAppClient.getPharmacy("$GET_SHOPPING_CART$customerId", onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy("$GET_SHOPPING_CART$customerId/$customerGUID", onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { hasError = true; diff --git a/lib/core/service/parmacyModule/parmacy_module_service.dart b/lib/core/service/parmacyModule/parmacy_module_service.dart index cc330ed7..7c7afa30 100644 --- a/lib/core/service/parmacyModule/parmacy_module_service.dart +++ b/lib/core/service/parmacyModule/parmacy_module_service.dart @@ -22,16 +22,12 @@ class PharmacyModuleService extends BaseService { List mostViewedProducts = List(); Future makeVerifyCustomer(dynamic data) async { - Map queryParams = { - 'FileNumber': data['PatientID'].toString() - }; + Map queryParams = {'FileNumber': data['PatientID'].toString()}; hasError = false; try { - await baseAppClient.getPharmacy(PHARMACY_VERIFY_CUSTOMER, - onSuccess: (dynamic response, int statusCode) async { + await baseAppClient.getPharmacy(PHARMACY_VERIFY_CUSTOMER, onSuccess: (dynamic response, int statusCode) async { if (response['UserName'] != null) { - sharedPref.setString( - PHARMACY_CUSTOMER_ID, response['CustomerId'].toString()); + sharedPref.setString(PHARMACY_CUSTOMER_ID, response['CustomerId'].toString()); print(response); } else { await createUser(); @@ -57,13 +53,14 @@ class PharmacyModuleService extends BaseService { }; hasError = false; try { - await baseAppClient.getPharmacy(PHARMACY_CREATE_CUSTOMER, - onSuccess: (dynamic response, int statusCode) async { + await baseAppClient.getPharmacy(PHARMACY_CREATE_CUSTOMER, onSuccess: (dynamic response, int statusCode) async { if (!response['IsRegistered']) { } else { customerInfo = CustomerInfo.fromJson(response); - await sharedPref.setObject( - PHARMACY_CUSTOMER_ID, customerInfo.customerId); + print(response['customerDto']); + print(response['customerDto']['customerGuid']); + await sharedPref.setObject(PHARMACY_CUSTOMER_ID, customerInfo.customerId); + await sharedPref.setObject(PHARMACY_CUSTOMER_GUID, response['customerDto']['customerGuid']); } // await generatePharmacyToken(); }, onFailure: (String error, int statusCode) { @@ -83,11 +80,9 @@ class PharmacyModuleService extends BaseService { }; hasError = false; try { - await baseAppClient.getPharmacy(PHARMACY_AUTORZIE_CUSTOMER, - onSuccess: (dynamic response, int statusCode) async { + await baseAppClient.getPharmacy(PHARMACY_AUTORZIE_CUSTOMER, onSuccess: (dynamic response, int statusCode) async { if (response['Status'] == 200) { - await sharedPref.setString( - PHARMACY_AUTORZIE_TOKEN, response['token'].toString()); + await sharedPref.setString(PHARMACY_AUTORZIE_TOKEN, response['token'].toString()); } }, onFailure: (String error, int statusCode) { hasError = true; @@ -101,8 +96,7 @@ class PharmacyModuleService extends BaseService { Future getBannerListList() async { hasError = false; try { - await baseAppClient.getPharmacy(GET_PHARMACY_BANNER, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy(GET_PHARMACY_BANNER, onSuccess: (dynamic response, int statusCode) { bannerItems.clear(); response['images'].forEach((item) { bannerItems.add(PharmacyImageObject.fromJson(item)); @@ -120,8 +114,7 @@ class PharmacyModuleService extends BaseService { if (manufacturerList.isNotEmpty) return; Map queryParams = {'page': '1', 'limit': '8'}; try { - await baseAppClient.getPharmacy(GET_PHARMACY_TOP_MANUFACTURER, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy(GET_PHARMACY_TOP_MANUFACTURER, onSuccess: (dynamic response, int statusCode) { manufacturerList.clear(); response['manufacturer'].forEach((item) { Manufacturer manufacturer = Manufacturer.fromJson(item); @@ -147,8 +140,7 @@ class PharmacyModuleService extends BaseService { 'id,discount_ids,name,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage,reviews', }; try { - await baseAppClient.getPharmacy(GET_PHARMACY_BEST_SELLER_PRODUCT, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy(GET_PHARMACY_BEST_SELLER_PRODUCT, onSuccess: (dynamic response, int statusCode) { bestSellerProducts.clear(); response['products'].forEach((item) { bestSellerProducts.add(PharmacyProduct.fromJson(item)); @@ -165,23 +157,18 @@ class PharmacyModuleService extends BaseService { Future getLastVisitedProducts() async { String lastVisited = ""; - if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != - null) { - lastVisited = - await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS); + if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != null) { + lastVisited = await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS); // lastVisited = "2458,4561"; try { - await baseAppClient - .getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited", - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited", onSuccess: (dynamic response, int statusCode) { lastVisitedProducts.clear(); response['products'].forEach((item) { lastVisitedProducts.add(PharmacyProduct.fromJson(item)); }); hasError = false; }, onFailure: (String error, int statusCode) { - hasError = - true; // sharedPref.setString(PHARMACY_LAST_VISITED_PRODUCTS, ""); + hasError = true; // sharedPref.setString(PHARMACY_LAST_VISITED_PRODUCTS, ""); super.error = error; }); } catch (error) { @@ -197,8 +184,7 @@ class PharmacyModuleService extends BaseService { 'id,discount_ids,name,reviews,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage', }; try { - await baseAppClient.getPharmacy(GET_MOST_VIEWED_PRODUCTS, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy(GET_MOST_VIEWED_PRODUCTS, onSuccess: (dynamic response, int statusCode) { mostViewedProducts.clear(); response['products'].forEach((item) { mostViewedProducts.add(PharmacyProduct.fromJson(item)); diff --git a/lib/core/viewModels/pharmacyModule/order_model_view_model.dart b/lib/core/viewModels/pharmacyModule/order_model_view_model.dart index fe5be016..7d6979cc 100644 --- a/lib/core/viewModels/pharmacyModule/order_model_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/order_model_view_model.dart @@ -37,9 +37,9 @@ class OrderModelViewModel extends BaseViewModel { - Future getOrder(customerId, pageID) async { + Future getOrder(customerId, customerGUID, pageID) async { setState(ViewState.Busy); - await _orderService.getOrder(customerId, pageID); + await _orderService.getOrder(customerId, customerGUID, pageID); if (_orderService.hasError) { error = _orderService.error; setState(ViewState.Error); diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart index 89d58317..4a3f8447 100644 --- a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/NewCMC/new_cmc_step_tow_page.dart @@ -146,7 +146,6 @@ class _NewCMCStepTowPageState extends State { @override Widget build(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); return AppScaffold( isShowAppBar: true, description: TranslationBase.of(context).infoCMC, diff --git a/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart b/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart index 6eee6528..1931f3fa 100644 --- a/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart @@ -1,9 +1,13 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; +import 'package:diplomaticquarterapp/pages/landing/landing_page_pharmcy.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; @@ -35,8 +39,7 @@ class PaymentBottomWidget extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container( - margin: - EdgeInsets.symmetric(horizontal: 0, vertical: 4), + margin: EdgeInsets.symmetric(horizontal: 0, vertical: 4), child: Row( children: [ Texts( @@ -46,8 +49,7 @@ class PaymentBottomWidget extends StatelessWidget { color: Color(0xff929295), ), Padding( - padding: - const EdgeInsets.symmetric(horizontal: 4), + padding: const EdgeInsets.symmetric(horizontal: 4), child: Texts( "${TranslationBase.of(context).inclusiveVat}", fontSize: 8, @@ -76,26 +78,22 @@ class PaymentBottomWidget extends StatelessWidget { width: 1, ), ), - onPressed: (orderPreviewViewModel - .paymentCheckoutData.address != - null && - orderPreviewViewModel - .paymentCheckoutData.paymentOption != - null) + onPressed: (orderPreviewViewModel.paymentCheckoutData.address != null && orderPreviewViewModel.paymentCheckoutData.paymentOption != null) ? () async { + GifLoaderDialogUtils.showMyDialog(context); await model.makeOrder(); if (model.state == ViewState.Idle) { - AppToast.showSuccessToast( - message: TranslationBase.of(context).compeleteOrderMsg - // "Order has been placed successfully!!" - ); - openPayment( - model.orderListModel[0], model.authenticatedUserObject.user); + AppToast.showSuccessToast(message: TranslationBase.of(context).compeleteOrderMsg); + GifLoaderDialogUtils.hideDialog(context); + openPayment(model.orderListModel[0], model.authenticatedUserObject.user); } else { AppToast.showErrorToast(message: model.error); } - Navigator.pop(context); - Navigator.pop(context); + navigateToCartPage(); + // Navigator.pop(context); + // Navigator.pop(context); + // Navigator.pop(context); + // Navigator.pop(context); } : null, child: Padding( @@ -103,34 +101,14 @@ class PaymentBottomWidget extends StatelessWidget { child: new Text( "${TranslationBase.of(context).proceedPay}", style: new TextStyle( - color: (orderPreviewViewModel - .paymentCheckoutData.address != - null && - orderPreviewViewModel.paymentCheckoutData - .paymentOption != - null) - ? Colors.white - : Colors.grey.shade400, + color: + (orderPreviewViewModel.paymentCheckoutData.address != null && orderPreviewViewModel.paymentCheckoutData.paymentOption != null) ? Colors.white : Colors.grey.shade400, fontWeight: FontWeight.bold, fontSize: 12), ), ), - color: - (orderPreviewViewModel.paymentCheckoutData.address != - null && - orderPreviewViewModel - .paymentCheckoutData.paymentOption != - null) - ? Colors.green - : Color(0xff929295), - disabledColor: - (orderPreviewViewModel.paymentCheckoutData.address != - null && - orderPreviewViewModel - .paymentCheckoutData.paymentOption != - null) - ? Colors.green - : Color(0xff929295), + color: (orderPreviewViewModel.paymentCheckoutData.address != null && orderPreviewViewModel.paymentCheckoutData.paymentOption != null) ? Colors.green : Color(0xff929295), + disabledColor: (orderPreviewViewModel.paymentCheckoutData.address != null && orderPreviewViewModel.paymentCheckoutData.paymentOption != null) ? Colors.green : Color(0xff929295), ), ), ], @@ -144,20 +122,10 @@ class PaymentBottomWidget extends StatelessWidget { OrderDetailModel order, AuthenticatedUser authenticatedUser, ) { - browser = new MyInAppBrowser( - onExitCallback: onBrowserExit, onLoadStartCallback: onBrowserLoadStart); + browser = new MyInAppBrowser(onExitCallback: onBrowserExit, onLoadStartCallback: onBrowserLoadStart); - browser.openPharmacyPaymentBrowser( - order, - order.orderTotal, - 'ePharmacy Order', - order.id, - order.billingAddress.email, - order.customValuesXml, - "${authenticatedUser.firstName} ${authenticatedUser.middleName} ${authenticatedUser.lastName}", - authenticatedUser.patientID, - authenticatedUser, - browser); + browser.openPharmacyPaymentBrowser(order, order.orderTotal, 'ePharmacy Order', order.id, order.billingAddress.email, order.customValuesXml, + "${authenticatedUser.firstName} ${authenticatedUser.middleName} ${authenticatedUser.lastName}", authenticatedUser.patientID, authenticatedUser, browser); } onBrowserLoadStart(String url) { @@ -181,19 +149,20 @@ class PaymentBottomWidget extends StatelessWidget { }); } + navigateToCartPage() { + Navigator.pushAndRemoveUntil(locator().navigatorKey.currentContext, MaterialPageRoute(builder: (context) => LandingPagePharmacy(currentTab: 0)), (Route r) => false); + } + onBrowserExit(AppoitmentAllHistoryResultList appo, bool isPaymentMade) { print("onBrowserExit Called!!!!"); if (isPaymentMade) { - AppToast.showSuccessToast( - message: "شكراً\nPayment status for your order is Paid"); - Navigator.pop(context); - Navigator.pop(context); + AppToast.showSuccessToast(message: "شكراً\nPayment status for your order is Paid"); + // Navigator.pop(context); + // Navigator.pop(context); } else { - AppToast.showErrorToast( - message: - "Transaction Failed!\Your transaction is field to some reason please try again or contact to the administration"); - Navigator.pop(context); - Navigator.pop(context); + AppToast.showErrorToast(message: "Transaction Failed!\Your transaction is field to some reason please try again or contact to the administration"); + // Navigator.pop(context); + // Navigator.pop(context); } } } diff --git a/lib/pages/pharmacy/order/Order.dart b/lib/pages/pharmacy/order/Order.dart index 8b3f8502..4a5e92f5 100644 --- a/lib/pages/pharmacy/order/Order.dart +++ b/lib/pages/pharmacy/order/Order.dart @@ -15,15 +15,15 @@ class OrderPage extends StatefulWidget { // orderList({this.customerId, this.pageId}); String customerID; + String customerGUID; - OrderPage({@required this.customerID}); + OrderPage({@required this.customerID, this.customerGUID}); @override _OrderPageState createState() => _OrderPageState(); } -class _OrderPageState extends State - with SingleTickerProviderStateMixin { +class _OrderPageState extends State with SingleTickerProviderStateMixin { String pageID = "1"; String customerId = ""; String order = ""; @@ -57,7 +57,7 @@ class _OrderPageState extends State @override Widget build(BuildContext context) { return BaseView( - onModelReady: (model) => model.getOrder(widget.customerID, pageID), + onModelReady: (model) => model.getOrder(widget.customerID, widget.customerGUID, pageID), builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).order, baseViewModel: model, @@ -105,10 +105,9 @@ class _OrderPageState extends State } Widget getDeliveredOrder(OrderModelViewModel model) { + deliveredOrderList.clear(); for (int i = 0; i < model.orders.length; i++) { - if (model.orders[i].orderStatusId == 30 || - model.orders[i].orderStatusId == 997 || - model.orders[i].orderStatusId == 994) { + if (model.orders[i].orderStatusId == 30 || model.orders[i].orderStatusId == 997 || model.orders[i].orderStatusId == 994) { deliveredOrderList.add(model.orders[i]); } } @@ -132,29 +131,26 @@ class _OrderPageState extends State Navigator.push( context, FadePage( - page: OrderDetailsPage( - orderModel: - deliveredOrderList[ - index]), - )); + page: OrderDetailsPage(orderModel: deliveredOrderList[index]), + )).then((value) { + model.getOrder(widget.customerID, widget.customerGUID, pageID); + getDeliveredOrder(model); + }); }, child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( margin: EdgeInsets.all(8.0), child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Container( margin: EdgeInsets.only(right: 5), child: Text( - TranslationBase.of(context) - .orderNumber, + TranslationBase.of(context).orderNumber, style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -163,9 +159,7 @@ class _OrderPageState extends State ), Container( child: Text( - deliveredOrderList[index] - .id - .toString(), + deliveredOrderList[index].id.toString(), style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -182,8 +176,7 @@ class _OrderPageState extends State Container( margin: EdgeInsets.only(right: 5), child: Text( - TranslationBase.of(context) - .orderDate, + TranslationBase.of(context).orderDate, style: TextStyle( fontSize: 14.0, ), @@ -191,10 +184,7 @@ class _OrderPageState extends State ), Container( child: Text( - deliveredOrderList[index] - .createdOnUtc - .toString() - .substring(0, 10), + deliveredOrderList[index].createdOnUtc.toString().substring(0, 10), style: TextStyle( fontSize: 14.0, ), @@ -208,9 +198,7 @@ class _OrderPageState extends State Container( margin: EdgeInsets.all(8.0), child: SvgPicture.asset( - languageID == "ar" - ? 'assets/images/pharmacy/arrow_left.svg' - : 'assets/images/pharmacy/arrow_right.svg', + languageID == "ar" ? 'assets/images/pharmacy/arrow_left.svg' : 'assets/images/pharmacy/arrow_right.svg', height: 20, width: 20, ), @@ -226,14 +214,11 @@ class _OrderPageState extends State endIndent: 0, ), Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( - margin: EdgeInsets.only( - left: 8, right: 8, top: 1, bottom: 8), - padding: EdgeInsets.only( - left: 13.0, right: 13.0), + margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), + padding: EdgeInsets.only(left: 13.0, right: 13.0), decoration: BoxDecoration( border: Border.all( color: Colors.blue[700], @@ -241,16 +226,12 @@ class _OrderPageState extends State width: 5.0, ), color: Colors.blue[700], - borderRadius: - BorderRadius.circular(30.0)), - child: deliveredOrderList[index].orderStatusId == 30 || - deliveredOrderList[index].orderStatusId == 997 || - deliveredOrderList[index].orderStatusId == 994 + borderRadius: BorderRadius.circular(30.0)), + child: deliveredOrderList[index].orderStatusId == 30 || deliveredOrderList[index].orderStatusId == 997 || deliveredOrderList[index].orderStatusId == 994 // deliveredOrderList[index].orderStatusId == 30 ? Text( // deliveredOrderList[0].orderStatus.toString().substring(12), - TranslationBase.of(context) - .deliveredOrder, + TranslationBase.of(context).deliveredOrder, style: TextStyle( color: Colors.white, fontSize: 15.0, @@ -258,13 +239,7 @@ class _OrderPageState extends State ), ) : Text( - languageID == "ar" - ? deliveredOrderList[index] - .orderStatusn - .toString() - : deliveredOrderList[index] - .orderStatus - .toString(), + languageID == "ar" ? deliveredOrderList[index].orderStatusn.toString() : deliveredOrderList[index].orderStatus.toString(), style: TextStyle( color: Colors.white, fontSize: 15.0, @@ -272,8 +247,7 @@ class _OrderPageState extends State ), )), Container( - margin: EdgeInsets.only( - left: 8, right: 8, top: 1, bottom: 8), + margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), child: Column( // crossAxisAlignment: CrossAxisAlignment.end, children: [ @@ -282,9 +256,7 @@ class _OrderPageState extends State Container( margin: EdgeInsets.only(left: 5), child: Text( - deliveredOrderList[index] - .orderTotal - .toString(), + deliveredOrderList[index].orderTotal.toString(), style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -310,9 +282,7 @@ class _OrderPageState extends State children: [ Container( child: Text( - deliveredOrderList[index] - .productCount - .toString(), + deliveredOrderList[index].productCount.toString(), style: TextStyle( fontSize: 14.0, ), @@ -321,8 +291,7 @@ class _OrderPageState extends State Container( margin: EdgeInsets.only(left: 5), child: Text( - TranslationBase.of(context) - .itemsNo, + TranslationBase.of(context).itemsNo, style: TextStyle( fontSize: 14.0, ), @@ -371,11 +340,9 @@ class _OrderPageState extends State } Widget getProcessingOrder(OrderModelViewModel model) { + processingOrderList.clear(); for (int i = 0; i < model.orders.length; i++) { - if (model.orders[i].orderStatusId == 20 || - model.orders[i].orderStatusId == 995 || - model.orders[i].orderStatusId == 998 || - model.orders[i].orderStatusId == 999) { + if (model.orders[i].orderStatusId == 20 || model.orders[i].orderStatusId == 995 || model.orders[i].orderStatusId == 998 || model.orders[i].orderStatusId == 999) { processingOrderList.add(model.orders[i]); } } @@ -396,31 +363,26 @@ class _OrderPageState extends State children: [ InkWell( onTap: () { - Navigator.push( - context, - FadePage( - page: OrderDetailsPage( - orderModel: - processingOrderList[ - index]))); + Navigator.push(context, FadePage(page: OrderDetailsPage(orderModel: processingOrderList[index]))).then((value) { + model.getOrder(widget.customerID, widget.customerGUID, pageID).then((value) { + getProcessingOrder(model); + }); + }); }, child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( margin: EdgeInsets.all(8.0), child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Container( margin: EdgeInsets.only(right: 5), child: Text( - TranslationBase.of(context) - .orderNumber, + TranslationBase.of(context).orderNumber, style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -429,9 +391,7 @@ class _OrderPageState extends State ), Container( child: Text( - processingOrderList[index] - .id - .toString(), + processingOrderList[index].id.toString(), style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -448,8 +408,7 @@ class _OrderPageState extends State Container( margin: EdgeInsets.only(right: 5), child: Text( - TranslationBase.of(context) - .orderDate, + TranslationBase.of(context).orderDate, style: TextStyle( fontSize: 14.0, ), @@ -457,10 +416,7 @@ class _OrderPageState extends State ), Container( child: Text( - processingOrderList[index] - .createdOnUtc - .toString() - .substring(0, 10), + processingOrderList[index].createdOnUtc.toString().substring(0, 10), style: TextStyle( fontSize: 14.0, ), @@ -474,9 +430,7 @@ class _OrderPageState extends State Container( margin: EdgeInsets.all(8.0), child: SvgPicture.asset( - languageID == "ar" - ? 'assets/images/pharmacy/arrow_left.svg' - : 'assets/images/pharmacy/arrow_right.svg', + languageID == "ar" ? 'assets/images/pharmacy/arrow_left.svg' : 'assets/images/pharmacy/arrow_right.svg', height: 20, width: 20, ), @@ -492,14 +446,11 @@ class _OrderPageState extends State endIndent: 0, ), Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( - margin: EdgeInsets.only( - left: 8, right: 8, top: 1, bottom: 8), - padding: EdgeInsets.only( - left: 13.0, right: 13.0), + margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), + padding: EdgeInsets.only(left: 13.0, right: 13.0), decoration: BoxDecoration( border: Border.all( color: Colors.green, @@ -507,17 +458,15 @@ class _OrderPageState extends State width: 5.0, ), color: Colors.green, - borderRadius: - BorderRadius.circular(30.0)), - child: processingOrderList[index].orderStatusId == 20 || - processingOrderList[index].orderStatusId == 995 || - processingOrderList[index].orderStatusId == 998 || - processingOrderList[index].orderStatusId == 999 + borderRadius: BorderRadius.circular(30.0)), + child: processingOrderList[index].orderStatusId == 20 || + processingOrderList[index].orderStatusId == 995 || + processingOrderList[index].orderStatusId == 998 || + processingOrderList[index].orderStatusId == 999 // processingOrderList[index].orderStatusId == 20 ? Text( // deliveredOrderList[0].orderStatus.toString().substring(12), - TranslationBase.of(context) - .processingOrder, + TranslationBase.of(context).processingOrder, style: TextStyle( color: Colors.white, fontSize: 15.0, @@ -525,13 +474,7 @@ class _OrderPageState extends State ), ) : Text( - languageID == "ar" - ? processingOrderList[index] - .orderStatusn - .toString() - : processingOrderList[index] - .orderStatus - .toString(), + languageID == "ar" ? processingOrderList[index].orderStatusn.toString() : processingOrderList[index].orderStatus.toString(), style: TextStyle( color: Colors.white, fontSize: 15.0, @@ -539,8 +482,7 @@ class _OrderPageState extends State ), )), Container( - margin: EdgeInsets.only( - left: 8, right: 8, top: 1, bottom: 8), + margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), child: Column( // crossAxisAlignment: CrossAxisAlignment.end, children: [ @@ -549,9 +491,7 @@ class _OrderPageState extends State Container( margin: EdgeInsets.only(left: 5), child: Text( - processingOrderList[index] - .orderTotal - .toString(), + processingOrderList[index].orderTotal.toString(), style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -577,9 +517,7 @@ class _OrderPageState extends State children: [ Container( child: Text( - processingOrderList[index] - .productCount - .toString(), + processingOrderList[index].productCount.toString(), style: TextStyle( fontSize: 14.0, ), @@ -588,8 +526,7 @@ class _OrderPageState extends State Container( margin: EdgeInsets.only(left: 5), child: Text( - TranslationBase.of(context) - .itemsNo, + TranslationBase.of(context).itemsNo, style: TextStyle( fontSize: 14.0, ), @@ -817,6 +754,7 @@ class _OrderPageState extends State } Widget getPendingOrder(OrderModelViewModel model) { + pendingOrderList.clear(); for (int i = 0; i < model.orders.length; i++) { if (model.orders[i].orderStatusId == 10) { pendingOrderList.add(model.orders[i]); @@ -839,32 +777,26 @@ class _OrderPageState extends State children: [ InkWell( onTap: () { - Navigator.push( - context, - FadePage( - page: OrderDetailsPage( - orderModel: - pendingOrderList[ - index]))); + Navigator.push(context, FadePage(page: OrderDetailsPage(orderModel: pendingOrderList[index]))).then((value) { + model.getOrder(widget.customerID, widget.customerGUID, pageID).then((value) { + getPendingOrder(model); + }); + }); }, child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( margin: EdgeInsets.all(8.0), child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Container( - margin: - EdgeInsets.only(right: 5), + margin: EdgeInsets.only(right: 5), child: Text( - TranslationBase.of(context) - .orderNumber, + TranslationBase.of(context).orderNumber, style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -873,9 +805,7 @@ class _OrderPageState extends State ), Container( child: Text( - pendingOrderList[index] - .id - .toString(), + pendingOrderList[index].id.toString(), style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -890,11 +820,9 @@ class _OrderPageState extends State Row( children: [ Container( - margin: - EdgeInsets.only(right: 5), + margin: EdgeInsets.only(right: 5), child: Text( - TranslationBase.of(context) - .orderDate, + TranslationBase.of(context).orderDate, style: TextStyle( fontSize: 14.0, ), @@ -902,10 +830,7 @@ class _OrderPageState extends State ), Container( child: Text( - pendingOrderList[index] - .createdOnUtc - .toString() - .substring(0, 10), + pendingOrderList[index].createdOnUtc.toString().substring(0, 10), style: TextStyle( fontSize: 14.0, ), @@ -919,9 +844,7 @@ class _OrderPageState extends State Container( margin: EdgeInsets.all(8.0), child: SvgPicture.asset( - languageID == "ar" - ? 'assets/images/pharmacy/arrow_left.svg' - : 'assets/images/pharmacy/arrow_right.svg', + languageID == "ar" ? 'assets/images/pharmacy/arrow_left.svg' : 'assets/images/pharmacy/arrow_right.svg', height: 20, width: 20, ), @@ -937,13 +860,11 @@ class _OrderPageState extends State endIndent: 0, ), Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( margin: EdgeInsets.all(8.0), - padding: EdgeInsets.only( - left: 13.0, right: 13.0), + padding: EdgeInsets.only(left: 13.0, right: 13.0), decoration: BoxDecoration( border: Border.all( color: Colors.orange[300], @@ -951,15 +872,11 @@ class _OrderPageState extends State width: 5.0, ), color: Colors.orange[300], - borderRadius: - BorderRadius.circular(30.0)), - child: pendingOrderList[index] - .orderStatusId == - 10 + borderRadius: BorderRadius.circular(30.0)), + child: pendingOrderList[index].orderStatusId == 10 ? Text( // deliveredOrderList[0].orderStatus.toString().substring(12), - TranslationBase.of(context) - .pendingOrder, + TranslationBase.of(context).pendingOrder, style: TextStyle( color: Colors.white, fontSize: 15.0, @@ -967,13 +884,7 @@ class _OrderPageState extends State ), ) : Text( - languageID == "ar" - ? pendingOrderList[index] - .orderStatusn - .toString() - : pendingOrderList[index] - .orderStatus - .toString(), + languageID == "ar" ? pendingOrderList[index].orderStatusn.toString() : pendingOrderList[index].orderStatus.toString(), style: TextStyle( color: Colors.white, fontSize: 15.0, @@ -988,12 +899,9 @@ class _OrderPageState extends State Row( children: [ Container( - margin: - EdgeInsets.only(left: 5), + margin: EdgeInsets.only(left: 5), child: Text( - pendingOrderList[index] - .orderTotal - .toString(), + pendingOrderList[index].orderTotal.toString(), style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -1001,11 +909,9 @@ class _OrderPageState extends State ), ), Container( - margin: - EdgeInsets.only(left: 5), + margin: EdgeInsets.only(left: 5), child: Text( - TranslationBase.of(context) - .sar, + TranslationBase.of(context).sar, style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -1021,20 +927,16 @@ class _OrderPageState extends State children: [ Container( child: Text( - pendingOrderList[index] - .productCount - .toString(), + pendingOrderList[index].productCount.toString(), style: TextStyle( fontSize: 14.0, ), ), ), Container( - margin: - EdgeInsets.only(left: 5), + margin: EdgeInsets.only(left: 5), child: Text( - TranslationBase.of(context) - .itemsNo, + TranslationBase.of(context).itemsNo, style: TextStyle( fontSize: 14.0, ), @@ -1084,10 +986,9 @@ class _OrderPageState extends State } Widget getCancelledOrder(OrderModelViewModel model) { + cancelledOrderList.clear(); for (int i = 0; i < model.orders.length; i++) { - if (model.orders[i].orderStatusId == 40 || - model.orders[i].orderStatus == 996 || - model.orders[i].orderStatusId == 200) { + if (model.orders[i].orderStatusId == 40 || model.orders[i].orderStatus == 996 || model.orders[i].orderStatusId == 200) { cancelledOrderList.add(model.orders[i]); } } @@ -1108,32 +1009,26 @@ class _OrderPageState extends State children: [ InkWell( onTap: () { - Navigator.push( - context, - FadePage( - page: OrderDetailsPage( - orderModel: - cancelledOrderList[ - index]))); + Navigator.push(context, FadePage(page: OrderDetailsPage(orderModel: cancelledOrderList[index]))).then((value) { + model.getOrder(widget.customerID, widget.customerGUID, pageID).then((value) { + getCancelledOrder(model); + }); + }); }, child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( margin: EdgeInsets.all(8.0), child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Container( - margin: - EdgeInsets.only(right: 5), + margin: EdgeInsets.only(right: 5), child: Text( - TranslationBase.of(context) - .orderNumber, + TranslationBase.of(context).orderNumber, style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -1142,9 +1037,7 @@ class _OrderPageState extends State ), Container( child: Text( - cancelledOrderList[index] - .id - .toString(), + cancelledOrderList[index].id.toString(), style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -1159,11 +1052,9 @@ class _OrderPageState extends State Row( children: [ Container( - margin: - EdgeInsets.only(right: 5), + margin: EdgeInsets.only(right: 5), child: Text( - TranslationBase.of(context) - .orderDate, + TranslationBase.of(context).orderDate, style: TextStyle( fontSize: 14.0, ), @@ -1171,10 +1062,7 @@ class _OrderPageState extends State ), Container( child: Text( - cancelledOrderList[index] - .createdOnUtc - .toString() - .substring(0, 10), + cancelledOrderList[index].createdOnUtc.toString().substring(0, 10), style: TextStyle( fontSize: 14.0, ), @@ -1188,9 +1076,7 @@ class _OrderPageState extends State Container( margin: EdgeInsets.all(8.0), child: SvgPicture.asset( - languageID == "ar" - ? 'assets/images/pharmacy/arrow_left.svg' - : 'assets/images/pharmacy/arrow_right.svg', + languageID == "ar" ? 'assets/images/pharmacy/arrow_left.svg' : 'assets/images/pharmacy/arrow_right.svg', height: 20, width: 20, ), @@ -1206,17 +1092,11 @@ class _OrderPageState extends State endIndent: 0, ), Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( - margin: EdgeInsets.only( - left: 8, - right: 8, - top: 1, - bottom: 8), - padding: EdgeInsets.only( - left: 10.0, right: 10.0), + margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), + padding: EdgeInsets.only(left: 10.0, right: 10.0), decoration: BoxDecoration( border: Border.all( color: Colors.red[900], @@ -1224,15 +1104,11 @@ class _OrderPageState extends State width: 5.0, ), color: Colors.red[900], - borderRadius: - BorderRadius.circular(30.0)), - child: cancelledOrderList[index] - .orderStatusId == - 40 + borderRadius: BorderRadius.circular(30.0)), + child: cancelledOrderList[index].orderStatusId == 40 ? Text( // deliveredOrderList[0].orderStatus.toString().substring(12), - TranslationBase.of(context) - .cancelledOrder, + TranslationBase.of(context).cancelledOrder, style: TextStyle( color: Colors.white, fontSize: 15.0, @@ -1240,13 +1116,7 @@ class _OrderPageState extends State ), ) : Text( - languageID == "ar" - ? cancelledOrderList[index] - .orderStatusn - .toString() - : cancelledOrderList[index] - .orderStatus - .toString(), + languageID == "ar" ? cancelledOrderList[index].orderStatusn.toString() : cancelledOrderList[index].orderStatus.toString(), style: TextStyle( color: Colors.white, fontSize: 15.0, @@ -1254,20 +1124,16 @@ class _OrderPageState extends State ), )), Container( - margin: EdgeInsets.only( - left: 8, right: 8, top: 1, bottom: 8), + margin: EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 8), child: Column( // crossAxisAlignment: CrossAxisAlignment.end, children: [ Row( children: [ Container( - margin: - EdgeInsets.only(left: 5), + margin: EdgeInsets.only(left: 5), child: Text( - cancelledOrderList[index] - .orderTotal - .toString(), + cancelledOrderList[index].orderTotal.toString(), style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -1275,11 +1141,9 @@ class _OrderPageState extends State ), ), Container( - margin: - EdgeInsets.only(left: 5), + margin: EdgeInsets.only(left: 5), child: Text( - TranslationBase.of(context) - .sar, + TranslationBase.of(context).sar, style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.bold, @@ -1295,20 +1159,16 @@ class _OrderPageState extends State children: [ Container( child: Text( - cancelledOrderList[index] - .productCount - .toString(), + cancelledOrderList[index].productCount.toString(), style: TextStyle( fontSize: 14.0, ), ), ), Container( - margin: - EdgeInsets.only(left: 5), + margin: EdgeInsets.only(left: 5), child: Text( - TranslationBase.of(context) - .itemsNo, + TranslationBase.of(context).itemsNo, style: TextStyle( fontSize: 14.0, ), diff --git a/lib/pages/pharmacy/order/OrderDetails.dart b/lib/pages/pharmacy/order/OrderDetails.dart index ee360bb1..eb08584a 100644 --- a/lib/pages/pharmacy/order/OrderDetails.dart +++ b/lib/pages/pharmacy/order/OrderDetails.dart @@ -557,8 +557,6 @@ class _OrderDetailsPageState extends State { ? InkWell( onTap: () { presentConfirmDialog(model, widget.orderModel.id); - // model.orderListModel[0].id//(widget.orderModel.id)); -// }, child: Container( // padding: EdgeInsets.only(left: 13.0, right: 13.0, top: 5.0), @@ -645,18 +643,12 @@ class _OrderDetailsPageState extends State { confirmMessage: TranslationBase.of(context).confirmCancellation, okText: TranslationBase.of(context).confirm, cancelText: TranslationBase.of(context).cancel_nocaps, - okFunction: () => cancelFunction.getCanceledOrder(id, context).then((value) { - print(":D"); - print(value); -// Navigator.pop(context); - Navigator.push( - context, - FadePage( - page: OrderPage( -// customerID: model.ordersList[0].customerId.toString() - customerID: widget.orderModel.customerId.toString())), - ); - }), + okFunction: () { + Navigator.pop(context); + cancelFunction.getCanceledOrder(id, context).then((value) { + Navigator.pop(context); + }); + }, cancelFunction: () => {}); dialog.showAlertDialog(context); } diff --git a/lib/pages/pharmacy/profile/profile.dart b/lib/pages/pharmacy/profile/profile.dart index 8362b2c8..ad3014e6 100644 --- a/lib/pages/pharmacy/profile/profile.dart +++ b/lib/pages/pharmacy/profile/profile.dart @@ -41,6 +41,7 @@ class _ProfilePageState extends State { bool isLogin = false; String firstName; String customerId; + String customerGUID; String lastName, mobileNo, identificationNo; int languageId; @@ -50,11 +51,15 @@ class _ProfilePageState extends State { getCustomer() async { String custID; + String custGUID; custID = await sharedPref.getString(PHARMACY_CUSTOMER_ID); + custGUID = await sharedPref.getObject(PHARMACY_CUSTOMER_GUID); setState(() { customerId = custID; + customerGUID = custGUID; }); print("customer Id is" + customerId); + print("customer GUID is" + customerGUID); return customerId; } @@ -91,8 +96,9 @@ class _ProfilePageState extends State { return BaseView( onModelReady: (model) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); + var customerGUID = await sharedPref.getObject(PHARMACY_CUSTOMER_GUID); GifLoaderDialogUtils.showMyDialog(context); - model.getOrder(customerId, page_id); + model.getOrder(customerId, customerGUID, page_id); GifLoaderDialogUtils.hideDialog(context); }, builder: (_, model, wi) => AppScaffold( @@ -170,7 +176,7 @@ class _ProfilePageState extends State { AppToast.showErrorToast(message: "Customer not found"); return; } - Navigator.push(context, FadePage(page: OrderPage(customerID: customerId))); + Navigator.push(context, FadePage(page: OrderPage(customerID: customerId, customerGUID: customerGUID))); }, child: Column( children: [ diff --git a/lib/services/pharmacy_services/orderDetails_service.dart b/lib/services/pharmacy_services/orderDetails_service.dart index a897955a..2f4a1d56 100644 --- a/lib/services/pharmacy_services/orderDetails_service.dart +++ b/lib/services/pharmacy_services/orderDetails_service.dart @@ -21,8 +21,9 @@ class OrderDetailsService extends BaseService{ Future getOrderDetails(OrderId) async { + var customerGUID = await sharedPref.getObject(PHARMACY_CUSTOMER_GUID); hasError = false; - await baseAppClient.getPharmacy(GET_ORDER_DETAILS+OrderId, + await baseAppClient.getPharmacy(GET_ORDER_DETAILS+OrderId + "/$customerGUID", onSuccess: (dynamic response, int statusCode) { _orderList.clear(); response['orders'].forEach((item) { diff --git a/lib/services/pharmacy_services/order_service.dart b/lib/services/pharmacy_services/order_service.dart index b5632076..373f2819 100644 --- a/lib/services/pharmacy_services/order_service.dart +++ b/lib/services/pharmacy_services/order_service.dart @@ -5,40 +5,38 @@ import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.da import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; - -class OrderService extends BaseService{ +class OrderService extends BaseService { AppSharedPreferences sharedPref = AppSharedPreferences(); AppGlobal appGlobal = new AppGlobal(); AuthenticatedUser authUser = new AuthenticatedUser(); AuthProvider authProvider = new AuthProvider(); List _orderList = List(); + List get orderList => _orderList; - String url =""; + String url = ""; - Future getOrder(customerId, pageId) async { + Future getOrder(customerId, customerGUID, pageId) async { hasError = false; // url =GET_ORDER+"customer=1,fields=id,order_total,order_status,order_statusn,order_status_id,created_on_utc&page=1&limit=200&customer_id=1367368"; - // url =GET_ORDER+"customer=1,fields=id,order_total,order_status,order_statusn,order_status_id,created_on_utc&page=$pageId&limit=200&customer_id=$customerId"; - url =GET_ORDER+"customer=1&fields=id,order_total,order_status,order_statusn,order_status_id,created_on_utc,product_count,can_cancel,can_refund&page=$pageId&limit=200&customer_id=$customerId"; + // url =GET_ORDER+"customer=1,fields=id,order_total,order_status,order_statusn,order_status_id,created_on_utc&page=$pageId&limit=200&customer_id=$customerId"; + url = GET_ORDER + "customer=1&fields=id,order_total,order_status,order_statusn,order_status_id,created_on_utc,product_count,can_cancel,can_refund&page=$pageId&limit=200&customer_id=$customerId&CustomerguId=$customerGUID"; print(url); - await baseAppClient.getPharmacy(url, - onSuccess: (dynamic response, int statusCode) { - _orderList.clear(); + await baseAppClient.getPharmacy(url, onSuccess: (dynamic response, int statusCode) { + _orderList.clear(); - response['orders'].forEach((item) { - _orderList.add(Orders.fromJson(item)); - }); - print(_orderList.length); - print(response); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }); + response['orders'].forEach((item) { + _orderList.add(Orders.fromJson(item)); + }); + print(_orderList.length); + print(response); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }); } - // Future getProductReview(orderId) async { // print("step 1"); // hasError = false; @@ -59,7 +57,6 @@ class OrderService extends BaseService{ // }); // } - // Future getOrder(BuildContext context ) async { // // if (await this.sharedPref.getObject(USER_PROFILE) != null) { @@ -80,4 +77,4 @@ class OrderService extends BaseService{ // }); // return Future.value(localRes); // } -} \ No newline at end of file +} diff --git a/lib/services/pharmacy_services/pharmacyAddress_service.dart b/lib/services/pharmacy_services/pharmacyAddress_service.dart index 40d906f3..aada50da 100644 --- a/lib/services/pharmacy_services/pharmacyAddress_service.dart +++ b/lib/services/pharmacy_services/pharmacyAddress_service.dart @@ -15,13 +15,14 @@ class PharmacyAddressService extends BaseService { Future> getAddresses() async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); + var customerGUID = await sharedPref.getObject(PHARMACY_CUSTOMER_GUID); Map queryParams = {'fields': 'addresses'}; hasError = false; Addresses selectedAddress; try { var completer = Completer(); - await baseAppClient.getPharmacy("$GET_CUSTOMERS_ADDRESSES$customerId", onSuccess: (dynamic response, int statusCode) async { + await baseAppClient.getPharmacy("$GET_CUSTOMERS_ADDRESSES$customerId/$customerGUID", onSuccess: (dynamic response, int statusCode) async { addresses.clear(); var savedAddress = await sharedPref.getObject(PHARMACY_SELECTED_ADDRESS); if (savedAddress != null) { From 7607631052c6a36f32253d26679bcb07f5a1b617 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Sun, 14 Nov 2021 12:00:09 +0200 Subject: [PATCH 6/7] sub categories pagnation --- .../screens/cart-page/cart-order-page.dart | 46 ++++++++----------- .../pharmacies/widgets/ProductOrderItem.dart | 7 ++- 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart index c50399f8..d217e3da 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -93,44 +93,37 @@ class _CartOrderPageState extends State { Container( child: ListView.builder( itemCount: - model.cartResponse.shoppingCarts.length, + model.cartResponse.shoppingCarts.length, scrollDirection: Axis.vertical, shrinkWrap: true, - physics: const AlwaysScrollableScrollPhysics (), + physics: const AlwaysScrollableScrollPhysics(), itemBuilder: (context, index) { return ProductOrderItem( - item:model.cartResponse - .shoppingCarts[index], - changeCartItems:() async { - GifLoaderDialogUtils.showMyDialog( - context); + item: model.cartResponse.shoppingCarts[index], + changeCartItems: () async { + GifLoaderDialogUtils.showMyDialog(context); await model.changeProductQuantity(model .cartResponse.shoppingCarts[index]); - if (model.state != ViewState.Error) { - } - if (model.state == - ViewState.ErrorLocal) { + if (model.state != ViewState.Error) {} + if (model.state == ViewState.ErrorLocal) { Utils.showErrorToast(model.error); } - GifLoaderDialogUtils.hideDialog( - context); + GifLoaderDialogUtils.hideDialog(context); }, - - deleteCartItems:() async { - GifLoaderDialogUtils.showMyDialog( - context); + deleteCartItems: () async { + GifLoaderDialogUtils.showMyDialog(context); await model - .deleteProduct(model.cartResponse - .shoppingCarts[index]) + .deleteProduct(model + .cartResponse.shoppingCarts[index]) .then((value) { - if (model.state == - ViewState.ErrorLocal) { + if (model.state == ViewState.ErrorLocal) { Utils.showErrorToast(model.error); } - GifLoaderDialogUtils.hideDialog( - context); + GifLoaderDialogUtils.hideDialog(context); }); - },model: model,); + }, + model: model, + ); }), ), const Divider( @@ -290,8 +283,9 @@ class _OrderBottomWidgetState extends State { Widget build(BuildContext context) { ProjectViewModel projectProvider = Provider.of(context); - return ! widget.isLoading && !(widget.model.cartResponse.shoppingCarts == null || - widget.model.cartResponse.shoppingCarts.length == 0) + return !widget.isLoading && + !(widget.model.cartResponse.shoppingCarts == null || + widget.model.cartResponse.shoppingCarts.length == 0) ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/pages/pharmacies/widgets/ProductOrderItem.dart b/lib/pages/pharmacies/widgets/ProductOrderItem.dart index a49c1273..fa0ead15 100644 --- a/lib/pages/pharmacies/widgets/ProductOrderItem.dart +++ b/lib/pages/pharmacies/widgets/ProductOrderItem.dart @@ -15,8 +15,8 @@ class ProductOrderItem extends StatefulWidget { final VoidCallback deleteCartItems; final OrderPreviewViewModel model; - ProductOrderItem({this.item, this.changeCartItems, this.deleteCartItems, - this.model}); + ProductOrderItem( + {this.item, this.changeCartItems, this.deleteCartItems, this.model}); @override _ProductOrderItemState createState() => _ProductOrderItemState(); @@ -28,7 +28,6 @@ class _ProductOrderItemState extends State { @override void initState() { - super.initState(); } @@ -36,7 +35,7 @@ class _ProductOrderItemState extends State { Widget build(BuildContext context) { _quantityController.text = "${widget.item.quantity}"; _totalPrice = - "${(widget.item.product.price * widget.item.quantity).toStringAsFixed(2)}"; + "${(widget.item.product.price * widget.item.quantity).toStringAsFixed(2)}"; ProjectViewModel projectProvider = Provider.of(context); return Column( From 54ff9931cbb8433a0fa83ee03d2cbb5de77674ff Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Sun, 14 Nov 2021 15:11:29 +0300 Subject: [PATCH 7/7] fixed arrow issue order page --- lib/pages/pharmacy/order/Order.dart | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/pages/pharmacy/order/Order.dart b/lib/pages/pharmacy/order/Order.dart index 8d6a55b0..817cf72a 100644 --- a/lib/pages/pharmacy/order/Order.dart +++ b/lib/pages/pharmacy/order/Order.dart @@ -1,6 +1,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/orders_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/order/OrderDetails.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -8,6 +9,7 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:provider/provider.dart'; dynamic languageID; @@ -107,6 +109,7 @@ class _OrderPageState extends State } Widget getDeliveredOrder(OrderModelViewModel model) { + ProjectViewModel projectViewModel = Provider.of(context); for (int i = 0; i < model.orders.length; i++) { if (model.orders[i].orderStatusId == 30 || model.orders[i].orderStatusId == 997 || @@ -210,7 +213,7 @@ class _OrderPageState extends State Container( margin: EdgeInsets.all(8.0), child: SvgPicture.asset( - languageID == "ar" + projectViewModel.isArabic ? 'assets/images/pharmacy/arrow_left.svg' : 'assets/images/pharmacy/arrow_right.svg', height: 20, @@ -373,6 +376,7 @@ class _OrderPageState extends State } Widget getProcessingOrder(OrderModelViewModel model) { + ProjectViewModel projectViewModel = Provider.of(context); for (int i = 0; i < model.orders.length; i++) { if (model.orders[i].orderStatusId == 20 || model.orders[i].orderStatusId == 995 || @@ -477,7 +481,7 @@ class _OrderPageState extends State Container( margin: EdgeInsets.all(8.0), child: SvgPicture.asset( - languageID == "ar" + projectViewModel.isArabic ? 'assets/images/pharmacy/arrow_left.svg' : 'assets/images/pharmacy/arrow_right.svg', height: 20, @@ -820,6 +824,7 @@ class _OrderPageState extends State } Widget getPendingOrder(OrderModelViewModel model) { + ProjectViewModel projectViewModel = Provider.of(context); for (int i = 0; i < model.orders.length; i++) { if (model.orders[i].orderStatusId == 10) { pendingOrderList.add(model.orders[i]); @@ -922,7 +927,7 @@ class _OrderPageState extends State Container( margin: EdgeInsets.all(8.0), child: SvgPicture.asset( - languageID == "ar" + projectViewModel.isArabic ? 'assets/images/pharmacy/arrow_left.svg' : 'assets/images/pharmacy/arrow_right.svg', height: 20, @@ -1087,6 +1092,7 @@ class _OrderPageState extends State } Widget getCancelledOrder(OrderModelViewModel model) { + ProjectViewModel projectViewModel = Provider.of(context); for (int i = 0; i < model.orders.length; i++) { if (model.orders[i].orderStatusId == 40 || model.orders[i].orderStatus == 996 || @@ -1191,7 +1197,7 @@ class _OrderPageState extends State Container( margin: EdgeInsets.all(8.0), child: SvgPicture.asset( - languageID == "ar" + projectViewModel.isArabic ? 'assets/images/pharmacy/arrow_left.svg' : 'assets/images/pharmacy/arrow_right.svg', height: 20,