diff --git a/lib/config/config.dart b/lib/config/config.dart index 7aea6857..9e17af68 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -16,9 +16,7 @@ const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; const PACKAGES_ORDERS = '/api/orders'; const PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara'; // const BASE_URL = 'https://uat.hmgwebservices.com/'; -// const BASE_URL = 'https://hmgwebservices.com/'; -const BASE_URL = 'https://uat.hmgwebservices.com/'; -// const BASE_URL = 'https://hmgwebservices.com/'; +const BASE_URL = 'https://hmgwebservices.com/'; // Pharmacy UAT URLs // const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; diff --git a/lib/core/service/parmacyModule/order-preview-service.dart b/lib/core/service/parmacyModule/order-preview-service.dart index 0364d64f..0fc6f79a 100644 --- a/lib/core/service/parmacyModule/order-preview-service.dart +++ b/lib/core/service/parmacyModule/order-preview-service.dart @@ -144,12 +144,12 @@ class OrderPreviewService extends BaseService { return Future.value(localRes); } - Future getLacumAccountInformation() async { + Future getLacumAccountInformation(String identificationNo) async { hasError = false; super.error = ""; Map body = Map(); - body['IdentificationNo'] = user.patientIdentificationNo; + body['IdentificationNo'] = identificationNo; try { await baseAppClient.post(GET_LACUM_ACCOUNT_INFORMATION, @@ -164,12 +164,12 @@ class OrderPreviewService extends BaseService { } } - Future getLacumGroupInformation() async { + Future getLacumGroupInformation(String identificationNo) async { hasError = false; super.error = ""; Map body = Map(); - body['IdentificationNo'] = user.patientIdentificationNo; + body['IdentificationNo'] = identificationNo; body['AccountNumber'] = "${lacumInformation.yahalaAccountNo}"; try { diff --git a/lib/core/viewModels/PharmacyPagesViewModel.dart b/lib/core/viewModels/PharmacyPagesViewModel.dart new file mode 100644 index 00000000..41c43066 --- /dev/null +++ b/lib/core/viewModels/PharmacyPagesViewModel.dart @@ -0,0 +1,17 @@ +import 'package:flutter/cupertino.dart'; + +class PharmacyPagesViewModel with ChangeNotifier { + int currentTab = 0; + PageController pageController; + + PharmacyPagesViewModel() { + pageController = PageController(keepPage: true); + } + changeCurrentTab(int tab) { + if (pageController.hasClients) { + currentTab = tab; + pageController.jumpToPage(tab); + notifyListeners(); + } + } +} diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index e64ab20c..d3f09119 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -31,6 +31,11 @@ class OrderPreviewViewModel extends BaseViewModel { PaymentCheckoutData paymentCheckoutData = PaymentCheckoutData(); double totalAdditionalShippingCharge = 0; + setShoppingCartResponse(ShoppingCartResponse cart){ + cartResponse = cart; + notifyListeners(); + } + Future getOrderPreviewData() async { setState(ViewState.Busy); await _orderService.getAddresses(); @@ -156,25 +161,25 @@ class OrderPreviewViewModel extends BaseViewModel { return _orderService.getPaymentOptionName(paymentOption); } - getInformationsByAddress() async { - await getLacumAccountInformation(); + getInformationsByAddress(String identificationNo) async { await getShippingOption(); + await getLacumAccountInformation(identificationNo); } - getLacumAccountInformation() async { + getLacumAccountInformation(String identificationNo) async { setState(ViewState.Busy); - await _orderService.getLacumAccountInformation(); + await _orderService.getLacumAccountInformation(identificationNo); if (_orderService.hasError) { error = _orderService.error; setState(ViewState.Error); } else { - getLacumGroupData(); + getLacumGroupData(identificationNo); } } - Future getLacumGroupData() async { + Future getLacumGroupData(String identificationNo) async { setState(ViewState.Busy); - await _orderService.getLacumGroupInformation(); + await _orderService.getLacumGroupInformation(identificationNo); paymentCheckoutData.lacumInformation = _orderService.lacumGroupInformation; paymentCheckoutData.usedLakumPoints = paymentCheckoutData .lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount; diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index 828aa8e4..98596ee0 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -1,13 +1,17 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/Wishlist.dart'; import 'package:diplomaticquarterapp/models/pharmacy/locationModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart'; +import 'package:diplomaticquarterapp/services/pharmacy_services/product_detail_service.dart'; import 'package:diplomaticquarterapp/models/pharmacy/specification.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; - -import 'package:diplomaticquarterapp/services/pharmacy_services/product_detail_service.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCart.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCartResponse.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import '../../../locator.dart'; @@ -61,12 +65,39 @@ class ProductDetailViewModel extends BaseViewModel{ Future addToCartData(quantity, itemID) async { hasError = false; setState(ViewState.BusyLocal); - await _productDetailService.addToCart(quantity, itemID); + var resp = await _productDetailService.addToCart(quantity, itemID); + ShoppingCartResponse object = _handleGetShoppingCartResponse(resp); if (_productDetailService.hasError) { error = _productDetailService.error; setState(ViewState.ErrorLocal); - } else + } else { setState(ViewState.Idle); + Provider.of(locator().navigatorKey.currentContext, listen: false) + .setShoppingCartResponse( object); + } + } + + ShoppingCartResponse _handleGetShoppingCartResponse(Map res) { + ShoppingCartResponse cartResponse = ShoppingCartResponse(); + + if (res == null) { + error = "response is null"; + setState(ViewState.Error); + return null; + } + print(res); + cartResponse.itemCount = res["item_count"]; + cartResponse.quantityCount = res["quantity_count"]; + cartResponse.subtotal = res["subtotal"]; + cartResponse.subtotalWithVat = res["subtotal_with_vat"]; + cartResponse.subtotalVatAmount = res["subtotal_vat_amount"]; + cartResponse.subtotalVatRate = res["subtotal_vat_rate"]; + cartResponse.shoppingCarts = List(); + res["shopping_carts"].forEach((item) { + ShoppingCart shoppingCart = ShoppingCart.fromJson(item); + cartResponse.shoppingCarts.add(shoppingCart); + }); + return cartResponse; } Future addToWishlistData(itemID) async { diff --git a/lib/main.dart b/lib/main.dart index 99b7cefe..0dd18a2d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,4 @@ -import 'dart:io'; - +import 'package:diplomaticquarterapp/core/viewModels/PharmacyPagesViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/routes.dart'; @@ -84,6 +83,9 @@ class _MyApp extends State { SizeConfig().init(constraints, orientation); return MultiProvider( providers: [ + ChangeNotifierProvider( + create: (context) => PharmacyPagesViewModel(), + ), ChangeNotifierProvider( create: (context) => ProjectViewModel(), ), diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 65adf282..51f8c8db 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -4,17 +4,17 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_deta import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; -import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/src/widgets/image.dart' as flutterImage; + import 'base/base_view.dart'; dynamic languageID; @@ -22,8 +22,7 @@ dynamic languageID; class FinalProductsPage extends StatefulWidget { final String id; final int productType; // 1 : default, 2 : manufacturer , 3 : recently viewed - AuthenticatedUserObject authenticatedUserObject = - locator(); + AuthenticatedUserObject authenticatedUserObject = locator(); FinalProductsPage({this.id, this.productType = 1}); @@ -33,7 +32,9 @@ class FinalProductsPage extends StatefulWidget { class _FinalProductsPageState extends State { String id; + _FinalProductsPageState({this.id}); + String categoriseName = "Personal Care"; String appBarTitle = ""; bool styleOne = true; @@ -77,11 +78,10 @@ class _FinalProductsPageState extends State { } }, allowAny: true, - builder: (BuildContext context, PharmacyCategoriseViewModel model, - Widget child) => - PharmacyAppScaffold( + builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => AppScaffold( + isPharmacy: true, appBarTitle: appBarTitle, - isBottomBar: false, + isBottomBar: true, isShowAppBar: true, backgroundColor: Colors.white, isShowDecPage: false, @@ -91,16 +91,13 @@ class _FinalProductsPageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ -//Expanded widget heree if nassery - Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: EdgeInsets.all(8.0), child: Texts( - "$appBarTitle " + - TranslationBase.of(context).products, + "$appBarTitle " + TranslationBase.of(context).products, fontWeight: FontWeight.w600, ), ), @@ -154,29 +151,21 @@ class _FinalProductsPageState extends State { ? Expanded( child: model.finalProducts.length > 0 ? Container( - height: MediaQuery.of(context).size.height * - 3.90, + height: MediaQuery.of(context).size.height * 3.90, child: GridView.builder( - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 0.5, mainAxisSpacing: 2.0, childAspectRatio: 1.0, ), itemCount: model.finalProducts.length, - itemBuilder: - (BuildContext context, int index) { + itemBuilder: (BuildContext context, int index) { return NetworkBaseView( baseViewModel: model, child: InkWell( child: Card( - color: - model.finalProducts[index] - .discountName != - null - ? Color(0xffFFFF00) - : Colors.white, + color: model.finalProducts[index].discountName != null ? Color(0xffFFFF00) : Colors.white, elevation: 0, shape: Border( right: BorderSide( @@ -198,226 +187,84 @@ class _FinalProductsPageState extends State { ), margin: EdgeInsets.symmetric( horizontal: 8, - vertical: 1, -// vertical: 2, + vertical: 4, ), child: Container( decoration: BoxDecoration( - borderRadius: - BorderRadius.only( - topLeft: Radius.circular( - 110.0), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(110.0), ), color: Colors.white, ), - padding: EdgeInsets.symmetric( - horizontal: 4, - ), + padding: EdgeInsets.symmetric(horizontal: 0), width: MediaQuery.of(context).size.width / 3, -// width: MediaQuery.of(context) -// .size -// .width / -// 1, -// height: MediaQuery.of(context) -// .size -// .width / -// 1, child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ Container( - margin: EdgeInsets - .fromLTRB(0, 1, - 0, 0), - alignment: Alignment - .center, - child: - Image.network( - model - .finalProducts[ - index] - .images - .isNotEmpty - ? model - .finalProducts[ - index] - .images[0] - .thumb + margin: EdgeInsets.fromLTRB(0, 16, 0, 0), + alignment: Alignment.center, + child: Image.network( + model.finalProducts[index].images.isNotEmpty + ? model.finalProducts[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: 70, + height: 80, ), ), -// Container( -// width: model -// .finalProducts[ -// index] -// .rxMessage != -// null -// ? MediaQuery.of( -// context) -// .size -// .width / -// 2.8 -// : 0, -// padding: -// EdgeInsets.all( -// 4), -// decoration: -// BoxDecoration( -// color: Color( -// 0xffb23838), -// borderRadius: BorderRadius.only( -// topLeft: Radius -// .circular( -// 6)), -// ), -// child: model -// .finalProducts[ -// index] -// .rxMessage != -// null -// ? Texts( -// languageID == -// 'ar' -// ? model -// .finalProducts[ -// index] -// .rxMessagen -// : model -// .finalProducts[index] -// .rxMessage, -// color: Colors -// .white, -// regular: -// true, -// fontSize: -// 10, -// fontWeight: -// FontWeight -// .w600, -// ) -// : Texts(""), -// ), - ], - ), - Container( - margin: EdgeInsets - .symmetric( - horizontal: 0, - vertical: 2, - ), - width: model - .finalProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 2.0 - : 0, - padding: - EdgeInsets.fromLTRB(8,4,8,4), - decoration: - BoxDecoration( - color: Color( - 0xffb23838), -// borderRadius: BorderRadius.only( -// topLeft: Radius -// .circular( -// 6)), + Container( + width: model.finalProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 2.8 : 0, + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + color: Color(0xffb23838), + borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: model - .finalProducts[ - index] - .rxMessage != - null + child: model.finalProducts[index].rxMessage != null ? Texts( - languageID == - 'ar' - ? model - .finalProducts[ - index] - .rxMessagen - : model - .finalProducts[index] - .rxMessage, - color: Colors - .white, - regular: - true, - fontSize: - 10, - fontWeight: - FontWeight - .w600, + languageID == 'ar' ? model.finalProducts[index].rxMessagen : model.finalProducts[index].rxMessage, + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w600, ) : Texts(""), ), + ], + ), Container( - margin: EdgeInsets - .symmetric( + margin: EdgeInsets.symmetric( horizontal: 6, vertical: 0, ), child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (model - .finalProducts[ - index] - .discountName != - null) + if (model.finalProducts[index].discountName != null) Container( - width: double - .infinity, + width: double.infinity, height: 13.0, - decoration: - BoxDecoration( - color: Color( - 0xff5AB145), + decoration: BoxDecoration( + color: Color(0xff5AB145), ), child: Center( child: Texts( - model - .finalProducts[ - index] - .discountName, - regular: - true, - color: Colors - .white, - fontSize: - 10.4, + model.finalProducts[index].discountName, + regular: true, + color: Colors.white, + fontSize: 10.4, ), ), ), Texts( - model - .finalProducts[ - index] - .name, + model.finalProducts[index].name, regular: true, fontSize: 12, - fontWeight: - FontWeight - .w400, + fontWeight: FontWeight.w400, ), Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: - 4), + padding: const EdgeInsets.only(top: 4, bottom: 4), child: Texts( "SAR ${model.finalProducts[index].price}", bold: true, @@ -427,20 +274,15 @@ class _FinalProductsPageState extends State { Row( children: [ StarRating( - totalAverage: model.finalProducts[index].approvedRatingSum > - 0 - ? (model.finalProducts[index].approvedRatingSum.toDouble() / model.finalProducts[index].approvedRatingSum.toDouble()) - .toDouble() + totalAverage: model.finalProducts[index].approvedRatingSum > 0 + ? (model.finalProducts[index].approvedRatingSum.toDouble() / model.finalProducts[index].approvedRatingSum.toDouble()).toDouble() : 0, - forceStars: - true), + forceStars: true), Texts( "(${model.finalProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: - FontWeight - .w400, + fontWeight: FontWeight.w400, ) ], ), @@ -455,9 +297,7 @@ class _FinalProductsPageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage( - model.finalProducts[ - index]), + page: ProductDetailPage(model.finalProducts[index]), )), }, )); @@ -466,10 +306,8 @@ class _FinalProductsPageState extends State { ) : Container( child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ Align( alignment: Alignment.center, @@ -493,285 +331,143 @@ class _FinalProductsPageState extends State { : Expanded( child: model.finalProducts.length > 0 ? Container( - height: MediaQuery.of(context).size.height * - 5.0, + height: MediaQuery.of(context).size.height * 5.0, child: ListView.builder( itemCount: model.finalProducts.length, - itemBuilder: - (BuildContext context, int index) { + itemBuilder: (BuildContext context, int index) { return InkWell( child: Card( - child: Padding( - padding: const EdgeInsets.all(4.0), - child: Row( - children: [ - Stack( - children: [ - Column( - children: [ - Container( - decoration: - BoxDecoration(), - child: Padding( - padding: - EdgeInsets - .only( - left: 2.0, - top: 2.0, - right: 2.0, - ), + 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( -// 8, 0, 8, 0), - alignment: Alignment - .center, - child: - Image.network( - model - .finalProducts[ - index] - .images - .isNotEmpty - ? model - .finalProducts[ - 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 - .contain, - height: 70, - ), + ), + Container( + margin: EdgeInsets.fromLTRB(0, 0, 0, 0), + alignment: Alignment.center, + child: Image.network( + model.finalProducts[index].images.isNotEmpty + ? model.finalProducts[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.contain, + height: 80, ), - ], - ), -// Column( -// children: [ -// Container( -// width: model -// .finalProducts[ -// 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: Texts( -// model -// .finalProducts[ -// index] -// .rxMessage != -// null -// ? model -// .finalProducts[ -// index] -// .rxMessage -// : "", -// color: -// Colors.white, -// regular: true, -// fontSize: 10, -// fontWeight: -// FontWeight -// .w600, -// ), -// ), -// ], -// ), - - - - ], - ), - Container( - height: 130.0, - margin: - EdgeInsets.symmetric( - horizontal: 0, - vertical: 6, + ), + ], ), - child: Column( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - crossAxisAlignment: - CrossAxisAlignment - .start, + Column( children: [ - Container( - margin: EdgeInsets - .symmetric( - horizontal: 4, - vertical: 0, - ), - width: model - .finalProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 2.0 - : 0, - padding: - EdgeInsets.all( - 4), - decoration: - BoxDecoration( - color: Color( - 0xffb23838), -// borderRadius: BorderRadius.only( -// topLeft: Radius -// .circular( -// 6)), + width: model.finalProducts[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 - .finalProducts[ - index] - .rxMessage != - null - ? Texts( - languageID == - 'ar' - ? model - .finalProducts[ - index] - .rxMessagen - : model - .finalProducts[index] - .rxMessage, - color: Colors - .white, - regular: - true, - fontSize: - 10, - fontWeight: - FontWeight - .w600, - ) - : Texts(""), - ), - SizedBox( - height: 4.0, - ), - Container( - width: MediaQuery.of( - context) - .size - .width * - 0.65, child: Texts( - model - .finalProducts[ - index] - .name, + model.finalProducts[index].rxMessage != null ? model.finalProducts[index].rxMessage : "", + color: Colors.white, regular: true, - fontSize: 13.2, - fontWeight: - FontWeight.w500, - maxLines: 5, + fontSize: 10, + fontWeight: FontWeight.w600, ), ), - SizedBox( - height: 8.0, - ), - Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), - child: Texts( - "SAR ${model.finalProducts[index].price}", - bold: true, - fontSize: 14, - ), - ), - Row( - children: [ - StarRating( - totalAverage: model - .finalProducts[ - index] - .approvedRatingSum > - 0 - ? (model.finalProducts[index].approvedRatingSum.toDouble() / - model.finalProducts[index].approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: - true), - Texts( - "(${model.finalProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: - FontWeight - .w400, - ) - ], - ), ], ), + ], + ), + Container( + height: 100.0, + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, ), - - widget.authenticatedUserObject.isLogin - ? Container( - child: IconButton( - icon: Icon(Icons.shopping_cart, - size: 18, - color: Colors.blue,), - onPressed: () async { - if(model.finalProducts[index].rxMessage == null){ - GifLoaderDialogUtils.showMyDialog(context); - await addToCartFunction(1, model.finalProducts[index].id); - GifLoaderDialogUtils.hideDialog(context); - Navigator.push( - context, - FadePage(page: CartOrderPage())); - } - else{ - AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); - } + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 4.0, + ), + Container( + width: MediaQuery.of(context).size.width * 0.65, + child: Texts( + model.finalProducts[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.finalProducts[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ + StarRating( + totalAverage: model.finalProducts[index].approvedRatingSum > 0 + ? (model.finalProducts[index].approvedRatingSum.toDouble() / model.finalProducts[index].approvedRatingSum.toDouble()).toDouble() + : 0, + forceStars: true), + Texts( + "(${model.finalProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ) + ], + ), + ], + ), + ), + widget.authenticatedUserObject.isLogin + ? Container( + child: IconButton( + icon: Icon( + Icons.shopping_cart, + size: 18, + color: Colors.blue, + ), + onPressed: () async { + if (model.finalProducts[index].rxMessage == null) { + GifLoaderDialogUtils.showMyDialog(context); + await addToCartFunction(1, model.finalProducts[index].id); + GifLoaderDialogUtils.hideDialog(context); + Navigator.push(context, FadePage(page: CartOrderPage())); + } else { + AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); + } // - } - - ), - ):Container(), - ], - ), + }), + ) + : Container(), + ], ), ), onTap: () => { Navigator.push( context, FadePage( - page: ProductDetailPage( - model.finalProducts[ - index]), + page: ProductDetailPage(model.finalProducts[index]), )), }, ); @@ -779,10 +475,8 @@ class _FinalProductsPageState extends State { ) : Container( child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ Align( alignment: Alignment.center, diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 2e251f3b..9e650966 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/PharmacyPagesViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_page.dart'; @@ -14,36 +15,46 @@ import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/pharmacy/bottom_nav_pharmacy_bar.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import '../../locator.dart'; class LandingPagePharmacy extends StatefulWidget { + final int currentTab; + + const LandingPagePharmacy({Key key, this.currentTab = 0}) : super(key: key); @override _LandingPagePharmacyState createState() => _LandingPagePharmacyState(); } class _LandingPagePharmacyState extends State { + ProjectViewModel projectProvider; int currentTab = 0; PageController pageController; - ProjectViewModel projectProvider; - - _changeCurrentTab(int tab) { - setState(() { - currentTab = tab; - pageController.jumpToPage(tab); - }); - } void initState() { super.initState(); locator().manufacturerList = []; locator().bestSellerProducts = []; locator().lastVisitedProducts = []; + pageController = + PageController(keepPage: true, initialPage: widget.currentTab); + setState(() { + currentTab = widget.currentTab; + }); + } - pageController = PageController(keepPage: true); + changeCurrentTab(int tab) { + if (pageController.hasClients) { + setState(() { + currentTab = tab; + pageController.jumpToPage(tab); + }); + } } @override @@ -52,75 +63,13 @@ class _LandingPagePharmacyState extends State { onWillPop: () async { return false; }, - child: Scaffold( - appBar: currentTab != 4 && currentTab != 3 - ? AppBar( - backgroundColor: Color(0xff5AB145), - elevation: 0, - title: Container( - height: MediaQuery.of(context).size.height * 0.056, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - color: Colors.white, - ), - child: InkWell( - child: Padding( - padding: EdgeInsets.all(5.0), - child: Row( - //crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Icon(Icons.search, size: 25.0), - SizedBox( - width: 15.0, - ), - Texts( - TranslationBase.of(context).searchProductHere, - fontSize: 13, - ) - ], - ), - ), - onTap: () { - Navigator.push( - context, - FadePage(page: SearchProductsPage()), - ); - }, - ), - ), - leading: Builder( - builder: (BuildContext context) { - return InkWell( - onTap: () { - setState(() { - currentTab = 0; - pageController.jumpToPage(0); - }); - }, - child: Container( - height: 2.0, - width: 10.0, - child: Image.asset( - 'assets/images/pharmacy_logo.png', - ), - ), - ); - }, - ), - actions: [ - IconButton( - // iconSize: 70, - icon: Image.asset( - 'assets/images/new-design/qr-code.png', - ), - onPressed: _scanQrAndGetProduct //do something, - ) - ], - centerTitle: true, - ) - : null, + child: AppScaffold( + isBottomBar: true, extendBody: false, + isShowDecPage: false, + isMainPharmacyPages: true, + currentTab: currentTab, + changeCurrentTab: changeCurrentTab, body: PageView( physics: NeverScrollableScrollPhysics(), controller: pageController, @@ -128,13 +77,9 @@ class _LandingPagePharmacyState extends State { PharmacyPage(), PharmacyCategorisePage(), PharmacyProfilePage(), - CartOrderPage(changeTab: _changeCurrentTab), + CartOrderPage(changeTab: changeCurrentTab), ], ), - bottomNavigationBar: BottomNavPharmacyBar( - changeIndex: _changeCurrentTab, - index: currentTab, - ), ), ); } diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index 86acac5c..49c8d0d6 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -384,6 +384,7 @@ class _Login extends State { getRegisterData() async { var registerData = await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN); + await sharedPref.remove(REGISTER_DATA_FOR_LOGIIN); if (registerData != null) { setState(() { diff --git a/lib/pages/login/register.dart b/lib/pages/login/register.dart index 540174c7..11ed7c79 100644 --- a/lib/pages/login/register.dart +++ b/lib/pages/login/register.dart @@ -329,15 +329,17 @@ class _Register extends State { nRequest['LogInTokenID'] = response['LogInTokenID']; if (response['hasFile'] == true) { ConfirmDialog dialog = new ConfirmDialog( - context: context, - confirmMessage: response['ErrorEndUserMessage'], - okText: TranslationBase.of(context).ok, - okFunction: () { - AlertDialogBox.closeAlertDialog(context); - - sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, nRequest); - Navigator.of(context).push(FadePage(page: Login())); - }).showAlertDialog(context); + context: context, + confirmMessage: response['ErrorEndUserMessage'], + okText: TranslationBase.of(context).ok, + cancelText: TranslationBase.of(context).cancel, + okFunction: () { + AlertDialogBox.closeAlertDialog(context); + sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, nRequest); + Navigator.of(context).push(FadePage(page: Login())); + }, + cancelFunction: () {}) + .showAlertDialog(context); } else { nRequest['forRegister'] = true; nRequest['isRegister'] = true; diff --git a/lib/pages/packages_offers/ClinicOfferAndPackagesPage.dart b/lib/pages/packages_offers/ClinicOfferAndPackagesPage.dart index d522d81e..97daf27f 100644 --- a/lib/pages/packages_offers/ClinicOfferAndPackagesPage.dart +++ b/lib/pages/packages_offers/ClinicOfferAndPackagesPage.dart @@ -40,7 +40,7 @@ class _ClinicPackagesPageState extends State with AfterLayo if(viewModel.service.customer != null) { var request = AddProductToCartRequestModel(product_id: product.id, customer_id: viewModel.service.customer.id); await viewModel.service.addProductToCart(request, context: context).then((response){ - appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount); + // appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount); }).catchError((error) { utils.Utils.showErrorToast(error); }); @@ -50,7 +50,7 @@ class _ClinicPackagesPageState extends State with AfterLayo @override void afterFirstLayout(BuildContext context) async{ - appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount); + // appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount); } @override diff --git a/lib/pages/packages_offers/OfferAndPackagesPage.dart b/lib/pages/packages_offers/OfferAndPackagesPage.dart index dc5b6584..056e23e1 100644 --- a/lib/pages/packages_offers/OfferAndPackagesPage.dart +++ b/lib/pages/packages_offers/OfferAndPackagesPage.dart @@ -96,7 +96,7 @@ class _PackagesHomePageState extends State with AfterLayoutMix if(viewModel.service.customer != null) { var request = AddProductToCartRequestModel(product_id: product.id, customer_id: viewModel.service.customer.id); await viewModel.service.addProductToCart(request, context: context).then((response){ - appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount); + // appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount); }).catchError((error) { utils.Utils.showErrorToast(error.toString()); }); diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index b63319f5..31bf7243 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -16,6 +16,7 @@ import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/entity_checkbox_list.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; @@ -26,13 +27,12 @@ import 'package:provider/provider.dart'; import 'package:diplomaticquarterapp/pages/sub_categories_modalsheet.dart'; import 'base/base_view.dart'; - class ParentCategorisePage extends StatefulWidget { String id; String titleName; AuthenticatedUserObject authenticatedUserObject = - locator(); + locator(); ParentCategorisePage({this.id, this.titleName}); @@ -46,9 +46,11 @@ class _ParentCategorisePageState extends State { String titleName; final dynamic productID; - - - _ParentCategorisePageState({this.id, this.titleName, this.productID,}); + _ParentCategorisePageState({ + this.id, + this.titleName, + this.productID, + }); Map values = {'huusam': false, 'ali': false, 'noor': false}; bool checkedBrands = false; @@ -75,9 +77,10 @@ class _ParentCategorisePageState extends State { allowAny: true, builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => - PharmacyAppScaffold( + AppScaffold( + isPharmacy: true, appBarTitle: titleName, - isBottomBar: false, + isBottomBar: true, isShowAppBar: true, backgroundColor: Colors.white, isShowDecPage: false, @@ -139,8 +142,7 @@ class _ParentCategorisePageState extends State { page: SubCategoriseModalsheet( // id: model.categorise[0].id, // titleName: model.categorise[0].name, - ) - ), + )), ); // showModalBottomSheet( // isScrollControlled: true, @@ -348,13 +350,13 @@ class _ParentCategorisePageState extends State { width: 10.0, ), Texts( - - TranslationBase.of(context).refine, + TranslationBase.of( + context) + .refine, // 'Refine', fontWeight: FontWeight.w600, - ), SizedBox( width: 250.0, @@ -362,7 +364,9 @@ class _ParentCategorisePageState extends State { InkWell( child: Texts( // 'Close', - TranslationBase.of(context).closeIt, + TranslationBase.of( + context) + .closeIt, color: Colors.red, fontWeight: FontWeight.w600, @@ -383,10 +387,10 @@ class _ParentCategorisePageState extends State { Column( children: [ ExpansionTile( - - title: Texts( TranslationBase.of( - context) - .categorise), + title: Texts( + TranslationBase.of( + context) + .categorise), children: [ ProcedureListWidget( model: model, @@ -424,9 +428,10 @@ class _ParentCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts( TranslationBase.of( - context) - .brands), + title: Texts( + TranslationBase.of( + context) + .brands), children: [ ProcedureListWidget( model: model, @@ -465,9 +470,10 @@ class _ParentCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts( TranslationBase.of( - context) - .price), + title: Texts( + TranslationBase.of( + context) + .price), children: [ Container( color: Color( @@ -558,14 +564,11 @@ class _ParentCategorisePageState extends State { Container( width: 100, child: Button( - - label: TranslationBase.of( - context) + label: TranslationBase.of( + context) .reset, - backgroundColor: Colors.red, - - - + backgroundColor: + Colors.red, ), ), SizedBox( @@ -629,13 +632,12 @@ class _ParentCategorisePageState extends State { Navigator.pop( context); }, - - label: TranslationBase.of( - context) + label: TranslationBase.of( + context) .apply, - backgroundColor: Colors.green, - - + backgroundColor: + Colors + .green, ), ), ], @@ -1131,7 +1133,8 @@ class _ParentCategorisePageState extends State { padding: const EdgeInsets .only( - top: 4, bottom: 4), + top: 4, + bottom: 4), child: Texts( "SAR ${model.parentProducts[index].price}", bold: true, @@ -1167,30 +1170,50 @@ class _ParentCategorisePageState extends State { ], ), ), - - widget.authenticatedUserObject.isLogin ? - Container( - child: IconButton( - icon: Icon(Icons.shopping_cart, - size: 18, - color: Colors.blue,), - onPressed: () async { - if(model.parentProducts[index].rxMessage == null){ - GifLoaderDialogUtils.showMyDialog(context); - await addToCartFunction(1, model.parentProducts[index].id); - GifLoaderDialogUtils.hideDialog(context); - Navigator.push( - context, - FadePage(page: CartOrderPage())); - } - else{ - AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); - } - - } - - ), - ): Container(), + widget.authenticatedUserObject + .isLogin + ? Container( + child: IconButton( + icon: Icon( + Icons + .shopping_cart, + size: 18, + color: + Colors.blue, + ), + onPressed: + () async { + if (model + .parentProducts[ + index] + .rxMessage == + null) { + GifLoaderDialogUtils + .showMyDialog( + context); + await addToCartFunction( + 1, + model + .parentProducts[ + index] + .id); + GifLoaderDialogUtils + .hideDialog( + context); + Navigator.push( + context, + FadePage( + page: + CartOrderPage())); + } else { + AppToast.showErrorToast( + message: TranslationBase.of( + context) + .needPrescription); + } + }), + ) + : Container(), ], ), ), @@ -1238,8 +1261,6 @@ class _ParentCategorisePageState extends State { ), ), )); - - } addToCartFunction(quantity, itemID) async { @@ -1264,7 +1285,4 @@ class _ParentCategorisePageState extends State { } return false; } - - - } diff --git a/lib/pages/pharmacies/product-brands.dart b/lib/pages/pharmacies/product-brands.dart index 4ff90706..eed79869 100644 --- a/lib/pages/pharmacies/product-brands.dart +++ b/lib/pages/pharmacies/product-brands.dart @@ -33,105 +33,108 @@ class _ProductBrandsPageState extends State { isShowAppBar: true, isPharmacy: true, isShowDecPage: false, - body: Container( - child: Column( - children: [ - Container( - color: Colors.white, - alignment: - languageID == 'ar' ? Alignment.topRight : Alignment.topLeft, - padding: languageID == 'ar' - ? EdgeInsets.only(right: 10.0, top: 10.0) - : EdgeInsets.only(left: 10.0, top: 10.0), - child: Text( - TranslationBase.of(context).topBrands, - style: TextStyle( - fontWeight: FontWeight.bold, + body: SingleChildScrollView( + child: Container( + child: Column( + children: [ + Container( + color: Colors.white, + alignment: languageID == 'ar' + ? Alignment.topRight + : Alignment.topLeft, + padding: languageID == 'ar' + ? EdgeInsets.only(right: 10.0, top: 10.0) + : EdgeInsets.only(left: 10.0, top: 10.0), + child: Text( + TranslationBase.of(context).topBrands, + style: TextStyle( + fontWeight: FontWeight.bold, + ), ), ), - ), - Container( - height: 220, - width: double.infinity, - color: Colors.white, - child: topBrand(context), - ), - SizedBox( - height: 10, - ), - Container( - height: MediaQuery.of(context).size.height * 0.056, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), + Container( + height: 220, + width: double.infinity, color: Colors.white, + child: topBrand(context), ), - child: InkWell( - child: Padding( - padding: EdgeInsets.all(8.0), - child: Row( - //crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Icon(Icons.search, size: 25.0), - SizedBox( - width: 15.0, - ), - Texts( - TranslationBase.of(context).searchProductHere, - fontSize: 13, - ) - ], + SizedBox( + height: 10, + ), + Container( + height: MediaQuery.of(context).size.height * 0.056, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.0), + color: Colors.white, + ), + child: InkWell( + child: Padding( + padding: EdgeInsets.all(8.0), + child: Row( + //crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Icon(Icons.search, size: 25.0), + SizedBox( + width: 15.0, + ), + Texts( + TranslationBase.of(context).searchProductHere, + fontSize: 13, + ) + ], + ), ), + onTap: () { + Navigator.push( + context, + FadePage(page: SearchBrandsPage()), + ); + }, ), - onTap: () { - Navigator.push( - context, - FadePage(page: SearchBrandsPage()), - ); - }, ), - ), - SizedBox( - height: 10, - ), - Container( - height: 420, - width: double.infinity, - color: Colors.white, - child: ListView.builder( - itemCount: model.brandsListList.length, - itemBuilder: (BuildContext context, int index) { - return InkWell( - child: Container( - margin: EdgeInsets.only(top: 50, left: 10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - languageID == 'ar' - ? Text(model.brandsListList[index].namen) - : Text(model.brandsListList[index].name), - SizedBox( - height: 3, - ), - Divider(height: 1, color: Colors.grey) - ], + SizedBox( + height: 10, + ), + Container( + height: 420, + width: double.infinity, + color: Colors.white, + child: ListView.builder( + itemCount: model.brandsListList.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + child: Container( + margin: EdgeInsets.only(top: 50, left: 10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + languageID == 'ar' + ? Text(model.brandsListList[index].namen) + : Text(model.brandsListList[index].name), + SizedBox( + height: 3, + ), + Divider(height: 1, color: Colors.grey) + ], + ), ), - ), - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => FinalProductsPage( - id: model.brandsListList[index].id - .toString(), - )), - ); - }, - ); - }), - ), - ], + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => FinalProductsPage( + id: model.brandsListList[index].id + .toString(), + )), + ); + }, + ); + }), + ), + ], + ), ), ), ), 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 79165766..6bfe4fbc 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -55,8 +55,10 @@ class _CartOrderPageState extends State { appBarTitle: TranslationBase.of(context).shoppingCart, isShowAppBar: true, isPharmacy: true, + //isBottomBar: true, showHomeAppBarIcon: false, - isShowDecPage: true, + isShowDecPage: false, + isMainPharmacyPages: true, baseViewModel: model, backgroundColor: Colors.white, body: !(model.cartResponse.shoppingCarts == null || @@ -103,8 +105,8 @@ class _CartOrderPageState extends State { .shoppingCarts[index]) .then((value) { if (model.state != ViewState.Error) { - appScaffold.appBar.badgeUpdater( - '${value.quantityCount ?? 0}'); + // appScaffold.appBar.badgeUpdater( + // '${value.quantityCount ?? 0}'); } if (model.state == ViewState.ErrorLocal) { @@ -117,8 +119,8 @@ class _CartOrderPageState extends State { .shoppingCarts[index]) .then((value) { if (model.state != ViewState.Error) { - appScaffold.appBar.badgeUpdater( - '${value.quantityCount ?? 0}'); + // appScaffold.appBar.badgeUpdater( + // '${value.quantityCount ?? 0}'); } }); })) 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 44ebd882..389b4331 100644 --- a/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart @@ -89,7 +89,7 @@ class PaymentBottomWidget extends StatelessWidget { message: "Order has been placed successfully!!"); openPayment( - model.orderListModel[0], model.user); + model.orderListModel[0], model.authenticatedUserObject.user); } else { AppToast.showErrorToast(message: model.error); } diff --git a/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart index d6182b9a..ab55002f 100644 --- a/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart @@ -37,14 +37,14 @@ class SelectAddressWidget extends StatefulWidget { class _SelectAddressWidgetState extends State { AddressInfo address; - _navigateToAddressPage() { + _navigateToAddressPage(String identificationNo) { Navigator.push(context, FadePage(page: PharmacyAddressesPage())) .then((result) { if (result != null) { address = result; widget.model.paymentCheckoutData.address = Addresses.fromJson(address.toJson()); - widget.model.getInformationsByAddress(); + widget.model.getInformationsByAddress(identificationNo); widget.changeMainState(); } }); @@ -66,7 +66,7 @@ class _SelectAddressWidgetState extends State { color: Colors.white, child: address == null ? InkWell( - onTap: () => {_navigateToAddressPage()}, + onTap: () => {_navigateToAddressPage(model.user.patientIdentificationNo)}, child: Container( margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), child: Row( @@ -125,7 +125,7 @@ class _SelectAddressWidgetState extends State { ), ), InkWell( - onTap: () => {_navigateToAddressPage()}, + onTap: () => {_navigateToAddressPage(model.authenticatedUserObject.user.patientIdentificationNo)}, child: Texts( TranslationBase.of(context).changeAddress, fontSize: 12, diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 7656922a..4da64235 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -42,21 +42,24 @@ class _PharmacyPageState extends State { allowAny: true, builder: (_, model, wi) => AppScaffold( title: "", - isShowAppBar: false, isShowDecPage: false, baseViewModel: model, + isMainPharmacyPages: true, + isPharmacy: true, + isShowPharmacyAppbar: true, backgroundColor: Colors.white, body: Container( width: double.infinity, child: SingleChildScrollView( child: Column( + //crossAxisAlignment: CrossAxisAlignment.start, children: [ BannerPager(model), + // GridViewButtons(model), PrescriptionsWidget(), -// ShopByBrandWidget(), + ShopByBrandWidget(), RecentlyViewedWidget(), BestSellerWidget(), - ShopByBrandWidget(), ], ), ), diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index cb38ca4f..e34a5dbc 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -1,10 +1,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; -import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-name-and-price.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/recommended_products.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/reviews_info.dart'; @@ -14,7 +11,6 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'availability_info.dart'; @@ -106,8 +102,8 @@ class __ProductDetailPageState extends State { deleteFromWishlistFunction: () async { await deleteFromWishlistFunction(itemID: itemID, model: model); }, - isInWishList:isInWishList, - addToCartFunction:addToCartFunction , + isInWishList: isInWishList, + addToCartFunction: addToCartFunction, ), body: SingleChildScrollView( child: Column( @@ -125,8 +121,7 @@ class __ProductDetailPageState extends State { fit: BoxFit.contain, ), ), - if (widget.product.discountDescription != null) - DiscountDescription(product: widget.product) + if (widget.product.discountDescription != null) DiscountDescription(product: widget.product) ], ), ), @@ -144,15 +139,11 @@ class __ProductDetailPageState extends State { setState(() {}); }, deleteFromWishlistFunction: (item) { - deleteFromWishlistFunction( - itemID: item, model: model); + deleteFromWishlistFunction(itemID: item, model: model); setState(() {}); }, notifyMeWhenAvailable: (context, itemId) { - notifyMeWhenAvailable( - itemId: itemId, - customerId: customerId, - model: model); + notifyMeWhenAvailable(itemId: itemId, customerId: customerId, model: model); }, isInWishList: isInWishList, ), @@ -167,8 +158,7 @@ class __ProductDetailPageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - padding: EdgeInsets.symmetric( - vertical: 15, horizontal: 10), + padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10), child: Texts( TranslationBase.of(context).specification, fontSize: 15, @@ -205,16 +195,12 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).details, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), CustomDivider( - color: isDetails - ? Colors.green - : Colors.transparent, + color: isDetails ? Colors.green : Colors.transparent, ) ], ), @@ -225,14 +211,10 @@ class __ProductDetailPageState extends State { children: [ FlatButton( onPressed: () async { - if (widget.product.approvedTotalReviews > - 0) { - GifLoaderDialogUtils.showMyDialog( - context); - await model.getProductReviewsData( - widget.product.id); - GifLoaderDialogUtils.hideDialog( - context); + if (widget.product.approvedTotalReviews > 0) { + GifLoaderDialogUtils.showMyDialog(context); + await model.getProductReviewsData(widget.product.id); + GifLoaderDialogUtils.hideDialog(context); } else { model.clearReview(); } @@ -244,16 +226,12 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).reviews, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), CustomDivider( - color: isReviews - ? Colors.green - : Colors.transparent, + color: isReviews ? Colors.green : Colors.transparent, ), ], ), @@ -264,8 +242,7 @@ class __ProductDetailPageState extends State { children: [ FlatButton( onPressed: () async { - GifLoaderDialogUtils.showMyDialog( - context); + GifLoaderDialogUtils.showMyDialog(context); await model.getProductLocationData(); GifLoaderDialogUtils.hideDialog(context); @@ -277,16 +254,12 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).availability, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), CustomDivider( - color: isAvailability - ? Colors.green - : Colors.transparent, + color: isAvailability ? Colors.green : Colors.transparent, ), ], ), @@ -315,12 +288,16 @@ class __ProductDetailPageState extends State { SizedBox( height: 10, ), - RecommendedProducts(product: widget.product,productDetailViewModel: model, + RecommendedProducts( + product: widget.product, + productDetailViewModel: model, addToWishlistFunction: (itemID) async { - await addToWishlistFunction(itemID: itemID, model: model); - }, deleteFromWishlistFunction: (itemID) async { + await addToWishlistFunction(itemID: itemID, model: model); + }, + deleteFromWishlistFunction: (itemID) async { await deleteFromWishlistFunction(itemID: itemID, model: model); - },) + }, + ) ], ), ), @@ -339,6 +316,10 @@ class __ProductDetailPageState extends State { )); } + addToShoppingCartFunction({quantity, itemID, ProductDetailViewModel model}) async { + await model.addToCartData(quantity, itemID); + } + addToWishlistFunction({itemID, ProductDetailViewModel model}) async { isInWishList = true; await model.addToWishlistData(itemID); @@ -350,31 +331,18 @@ class __ProductDetailPageState extends State { await model.deleteWishlistData(itemID); setState(() {}); } - addToCartFunction( - {quantity, - itemID, - ProductDetailViewModel model}) async { - GifLoaderDialogUtils.showMyDialog(context); - await model.addToCartData(quantity, itemID); - GifLoaderDialogUtils.hideDialog(context); - } - addToShoppingCartFunction( - {quantity, - itemID, - ProductDetailViewModel model}) async { + addToCartFunction({ + quantity, + itemID, + ProductDetailViewModel model, + }) async { GifLoaderDialogUtils.showMyDialog(context); await model.addToCartData(quantity, itemID); GifLoaderDialogUtils.hideDialog(context); - Navigator.push( - context, - FadePage(page: CartOrderPage())); } } - - -notifyMeWhenAvailable( - {itemId, customerId, ProductDetailViewModel model}) async { +notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model}) async { await model.notifyMe(customerId, itemId); } diff --git a/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart index 25be1775..1626e24f 100644 --- a/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart +++ b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart @@ -25,9 +25,19 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { final bool isInWishList; final Function addToCartFunction; - ProductAppBar({Key key, this.product, this.model, this.addToWishlistFunction, this.quantity, this.deleteFromWishlistFunction, this.isInWishList, this.addToCartFunction}) : super(key: key); + ProductAppBar( + {Key key, + this.product, + this.model, + this.addToWishlistFunction, + this.quantity, + this.deleteFromWishlistFunction, + this.isInWishList, + this.addToCartFunction}) + : super(key: key); - AuthenticatedUserObject authenticatedUserObject = locator(); + AuthenticatedUserObject authenticatedUserObject = + locator(); @override Widget build(BuildContext context) { @@ -69,7 +79,11 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { MaterialPageRoute(builder: (context) => CartOrderPage()), ); }), - if (Provider.of(context, listen: false).cartResponse.quantityCount != 0) + if (Provider.of(context, + listen: false) + .cartResponse + .quantityCount != + 0) Positioned( top: 0, right: -1.0, @@ -79,10 +93,14 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { borderRadius: BorderRadius.circular(15), ), padding: EdgeInsets.only(left: 5, right: 4.5), - height: 19, + height: 18, child: Center( child: Texts( - orderPreviewViewModel.cartResponse.quantityCount.toString(), + Provider.of(context, + listen: false) + .cartResponse + .quantityCount + .toString(), style: "caption", medium: true, color: Colors.white, @@ -130,7 +148,11 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { onTap: () async { if (quantity > 0) { { - await addToCartFunction(quantity: quantity, itemID: itemID, model: model); + await addToCartFunction( + quantity: quantity, + itemID: itemID, + model: model, + context: context); Navigator.of(context).pop(); } @@ -144,7 +166,9 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { color: !isInWishList ? Colors.white : Colors.red[800], ), title: Text( - isInWishList ? TranslationBase.of(context).removeFromWishlist : TranslationBase.of(context).addToWishlist, + isInWishList + ? TranslationBase.of(context).removeFromWishlist + : TranslationBase.of(context).addToWishlist, ), onTap: () async { if (isInWishList) @@ -159,7 +183,8 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { TranslationBase.of(context).compare, ), onTap: () { - Provider.of(context, listen: false).addItem(specificationData); + Provider.of(context, listen: false) + .addItem(specificationData); Navigator.of(context).pop(); }, ), diff --git a/lib/pages/pharmacies/search_brands_page.dart b/lib/pages/pharmacies/search_brands_page.dart index cb1281ff..ad592134 100644 --- a/lib/pages/pharmacies/search_brands_page.dart +++ b/lib/pages/pharmacies/search_brands_page.dart @@ -118,22 +118,23 @@ class _SearchBrandsPageState extends State { itemCount: model.searchList.length, itemBuilder: (BuildContext ctx, index) { return Padding( - padding:EdgeInsets.all(8.0), + padding: EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Text( - model.searchList[index].name, - style: TextStyle(fontSize: 20), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Text( + model.searchList[index].name, + style: TextStyle(fontSize: 20), + ), ), ), - ), - Divider(height: 1, color: Colors.grey) - ],), + Divider(height: 1, color: Colors.grey) + ], + ), ); }, ), diff --git a/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart index 261f4e99..fabab916 100644 --- a/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart +++ b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart @@ -36,7 +36,7 @@ class PrescriptionsWidget extends StatelessWidget { ViewAllHomeWidget(TranslationBase.of(context).myPrescription, HomePrescriptionsPage()), Container( margin: EdgeInsets.only(right: 10.0, left: 10.0), - height: MediaQuery.of(context).size.height * 0.28, + height: MediaQuery.of(context).size.height * 0.18, child: ListView.builder( scrollDirection: Axis.horizontal, shrinkWrap: true, diff --git a/lib/pages/pharmacy/profile/profile.dart b/lib/pages/pharmacy/profile/profile.dart index 2b11887d..f4534a01 100644 --- a/lib/pages/pharmacy/profile/profile.dart +++ b/lib/pages/pharmacy/profile/profile.dart @@ -94,9 +94,12 @@ class _ProfilePageState extends State { }, builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).myAccount, - isShowAppBar: false, - isShowDecPage: false, + isShowAppBar: true, + isShowDecPage: true, isPharmacy: true, + + //isBottomBar: true, + isMainPharmacyPages: true, body: user != null ? Container( color: Colors.white, @@ -208,7 +211,9 @@ class _ProfilePageState extends State { ), Text( TranslationBase.of(context).lakum, - style: TextStyle(fontSize: 13.0, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 13.0, + fontWeight: FontWeight.bold), ), ], ), @@ -217,7 +222,8 @@ class _ProfilePageState extends State { Expanded( child: InkWell( onTap: () { - Navigator.push(context, FadePage(page: WishlistPage())); + Navigator.push(context, + FadePage(page: WishlistPage())); }, child: Column( children: [ @@ -243,7 +249,8 @@ class _ProfilePageState extends State { Expanded( child: InkWell( onTap: () { - Navigator.push(context, FadePage(page: MyReviewsPage())); + Navigator.push(context, + FadePage(page: MyReviewsPage())); }, child: Column( children: [ @@ -288,7 +295,9 @@ class _ProfilePageState extends State { children: [ Text( TranslationBase.of(context).myAccount, - style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.bold), ), SizedBox( height: 10, @@ -299,7 +308,10 @@ class _ProfilePageState extends State { ), InkWell( onTap: () { - Navigator.push(context, FadePage(page: HomePrescriptionsPage())); + Navigator.push( + context, + FadePage( + page: HomePrescriptionsPage())); }, child: Row( children: [ @@ -312,7 +324,8 @@ class _ProfilePageState extends State { width: 15, ), Text( - TranslationBase.of(context).myPrescription, + TranslationBase.of(context) + .myPrescription, style: TextStyle( fontSize: 13.0, ), @@ -329,11 +342,15 @@ class _ProfilePageState extends State { ), InkWell( onTap: () { - Navigator.push(context, FadePage(page: ComparePage())); + Navigator.push(context, + FadePage(page: ComparePage())); }, child: Row( children: [ - Image.asset('assets/images/pharmacy/compare.png', width: 35, height: 35), + Image.asset( + 'assets/images/pharmacy/compare.png', + width: 35, + height: 35), SizedBox( width: 15, ), @@ -355,7 +372,10 @@ class _ProfilePageState extends State { ), InkWell( onTap: () { - Navigator.push(context, FadePage(page: HomePrescriptionsPage())); + Navigator.push( + context, + FadePage( + page: HomePrescriptionsPage())); }, child: Row( children: [ @@ -368,7 +388,8 @@ class _ProfilePageState extends State { width: 20, ), Text( - TranslationBase.of(context).medicationsRefill, + TranslationBase.of(context) + .medicationsRefill, style: TextStyle( fontSize: 13.0, ), @@ -385,7 +406,8 @@ class _ProfilePageState extends State { ), InkWell( onTap: () { - Navigator.push(context, FadePage(page: MyFamily())); + Navigator.push( + context, FadePage(page: MyFamily())); }, child: Row( children: [ @@ -415,7 +437,10 @@ class _ProfilePageState extends State { ), InkWell( onTap: () { - Navigator.push(context, FadePage(page: PharmacyAddressesPage())); + Navigator.push( + context, + FadePage( + page: PharmacyAddressesPage())); }, child: Row( children: [ @@ -428,7 +453,8 @@ class _ProfilePageState extends State { width: 20, ), Text( - TranslationBase.of(context).shippingAddresses, + TranslationBase.of(context) + .shippingAddresses, style: TextStyle( fontSize: 13.0, ), @@ -445,7 +471,10 @@ class _ProfilePageState extends State { ), InkWell( onTap: () { - Navigator.push(context, FadePage(page: PharmacyTermsConditions())); + Navigator.push( + context, + FadePage( + page: PharmacyTermsConditions())); }, child: Row( children: [ @@ -458,7 +487,8 @@ class _ProfilePageState extends State { width: 10, ), Text( - TranslationBase.of(context).conditionsHMG, + TranslationBase.of(context) + .conditionsHMG, style: TextStyle( fontSize: 13.0, ), @@ -475,7 +505,15 @@ class _ProfilePageState extends State { ), InkWell( onTap: () { - Navigator.push(context, FadePage(page: LakumTermsConditions(this.identificationNo, this.firstName, this.lastName, this.mobileNo, this.languageId))); + Navigator.push( + context, + FadePage( + page: LakumTermsConditions( + this.identificationNo, + this.firstName, + this.lastName, + this.mobileNo, + this.languageId))); }, child: Row( children: [ @@ -490,7 +528,8 @@ class _ProfilePageState extends State { width: 10, ), Text( - TranslationBase.of(context).conditions, + TranslationBase.of(context) + .conditions, style: TextStyle( fontSize: 13.0, ), @@ -521,7 +560,9 @@ class _ProfilePageState extends State { children: [ Text( TranslationBase.of(context).reachUs, - style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.bold), ), SizedBox( height: 5, @@ -532,7 +573,8 @@ class _ProfilePageState extends State { ), InkWell( onTap: () { - Navigator.push(context, FadePage(page: LiveChatPage())); + Navigator.push(context, + FadePage(page: LiveChatPage())); }, child: Row( children: [ @@ -560,7 +602,8 @@ class _ProfilePageState extends State { ), InkWell( onTap: () { - Navigator.push(context, FadePage(page: FindUsPage())); + Navigator.push(context, + FadePage(page: FindUsPage())); }, child: Row( children: [ @@ -573,7 +616,8 @@ class _ProfilePageState extends State { width: 20, ), Text( - TranslationBase.of(context).ourLocations, + TranslationBase.of(context) + .ourLocations, style: TextStyle(fontSize: 13.0), ), ], diff --git a/lib/pages/pharmacy_categorise.dart b/lib/pages/pharmacy_categorise.dart index b71c28ce..8a965b6e 100644 --- a/lib/pages/pharmacy_categorise.dart +++ b/lib/pages/pharmacy_categorise.dart @@ -35,6 +35,10 @@ class _PharmacyCategorisePageState extends State { Widget child) => AppScaffold( isShowDecPage: false, + isShowAppBar: false, + isMainPharmacyPages: true, + isPharmacy: true, + isShowPharmacyAppbar: true, baseViewModel: model, body: Column( children: [ diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 31a06fea..47673eab 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -2,10 +2,14 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/models/pharmacy/Wishlist.dart'; +import 'package:diplomaticquarterapp/models/pharmacy/addToCartModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/locationModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart'; +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/models/pharmacy/specification.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCart.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; class ProductDetailService extends BaseService { @@ -73,7 +77,7 @@ class ProductDetailService extends BaseService { }, body: request); } - Future addToCart(quantity, itemID) async { + Future addToCart(quantity, itemID) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; Map request; @@ -88,9 +92,8 @@ class ProductDetailService extends BaseService { "language_id": 1 } }; - - - + dynamic localRes; + await baseAppClient.pharmacyPost(GET_SHOPPING_CART, isExternal: false, onSuccess: (dynamic response, int statusCode) { _addToCartModel.clear(); @@ -98,11 +101,14 @@ class ProductDetailService extends BaseService { _addToCartModel.add(Wishlist.fromJson(item)); }); AppToast.showSuccessToast(message: 'You have added a product to the cart'); + localRes = response; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage()); }, body: request); + + return Future.value(localRes); } Future notifyMe(customerId, itemID) async { @@ -142,7 +148,7 @@ class ProductDetailService extends BaseService { Future getWishlistItems() async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; - await baseAppClient.getPharmacy(GET_WISHLIST.toString()+customerId.toString()+"?shopping_cart_type=2", + await baseAppClient.getPharmacy(GET_WISHLIST+customerId+"?shopping_cart_type=2", onSuccess: (dynamic response, int statusCode) { _wishListProducts.clear(); response['shopping_carts'].forEach((item) { diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index c93ac267..d071d4d2 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -1,17 +1,30 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:badges/badges.dart'; +import 'package:barcode_scan_fix/barcode_scan.dart'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; +import 'package:diplomaticquarterapp/core/viewModels/PharmacyPagesViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; +import 'package:diplomaticquarterapp/pages/landing/landing_page_pharmcy.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; +import 'package:diplomaticquarterapp/pages/search_products_page.dart'; import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; import 'package:diplomaticquarterapp/theme/colors.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/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/pharmacy/bottom_nav_pharmacy_bar.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_loader_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; @@ -25,7 +38,7 @@ import 'not_auh_page.dart'; VoidCallback _onCartClick; -class AppScaffold extends StatelessWidget { +class AppScaffold extends StatefulWidget { final String appBarTitle; final Widget body; final Widget bottomSheet; @@ -60,12 +73,18 @@ class AppScaffold extends StatelessWidget { List dropDownList; final Function(int) dropDownIndexChange; Function onTap; - - AuthenticatedUserObject authenticatedUserObject = locator(); - - AppBarWidget appBar; + final bool isMainPharmacyPages; + final bool extendBody; + final ValueChanged changeCurrentTab; + final int currentTab; + final bool isShowPharmacyAppbar; final Widget customAppBar; + AppScaffold setOnAppBarCartClick(VoidCallback onClick) { + _onCartClick = onClick; + return this; + } + AppScaffold( {@required this.body, this.appBarTitle = '', @@ -73,6 +92,8 @@ class AppScaffold extends StatelessWidget { this.isShowAppBar = false, this.showNewAppBar = false, this.showNewAppBarTitle = false, + this.isMainPharmacyPages = false, + this.extendBody = false, this.hasAppBarParam, this.bottomSheet, this.bottomNavigationBar, @@ -85,7 +106,7 @@ class AppScaffold extends StatelessWidget { this.title, this.description, this.isShowDecPage = true, - this.isBottomBar, + this.isBottomBar = false, this.backgroundColor, this.preferredSize = 0.0, this.appBarIcons, @@ -102,78 +123,200 @@ class AppScaffold extends StatelessWidget { appBar, this.customAppBar, this.isLocalLoader = false, - this.backButtonTab}); + this.backButtonTab, + this.changeCurrentTab, + this.currentTab, + this.isShowPharmacyAppbar = false}); - AppScaffold setOnAppBarCartClick(VoidCallback onClick) { - _onCartClick = onClick; - return this; + @override + _AppScaffoldState createState() => _AppScaffoldState(); +} + +class _AppScaffoldState extends State { + AuthenticatedUserObject authenticatedUserObject = locator(); + AppBarWidget appBar; + + @override + void initState() { + // TODO: implement initState + super.initState(); + } + + AppBar pharmacyAppbar() { + return AppBar( + backgroundColor: Color(0xff5AB145), + elevation: 0, + title: Container( + height: MediaQuery.of(context).size.height * 0.056, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.0), + color: Colors.white, + ), + child: InkWell( + child: Padding( + padding: EdgeInsets.all(5.0), + child: Row( + //crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Icon(Icons.search, size: 25.0), + SizedBox( + width: 15.0, + ), + Texts( + TranslationBase.of(context).searchProductHere, + fontSize: 13, + ) + ], + ), + ), + onTap: () { + Navigator.push( + context, + FadePage(page: SearchProductsPage()), + ); + }, + ), + ), + leading: Builder( + builder: (BuildContext context) { + return InkWell( + onTap: () { + Provider.of(context, listen: false).changeCurrentTab(0); + }, + child: Container( + height: 2.0, + width: 10.0, + child: Image.asset( + 'assets/images/pharmacy_logo.png', + ), + ), + ); + }, + ), + actions: [ + IconButton( + // iconSize: 70, + icon: Image.asset( + 'assets/images/new-design/qr-code.png', + ), + onPressed: _scanQrAndGetProduct //do something, + ) + ], + centerTitle: true, + ); } @override Widget build(BuildContext context) { AppGlobal.context = context; + PharmacyPagesViewModel pagesViewModel = Provider.of(context); - bool isUserNotLogin = (!Provider.of(context, listen: false).isLogin && isShowDecPage); + bool isUserNotLogin = (!Provider.of(context, listen: false).isLogin && widget.isShowDecPage); return Scaffold( - backgroundColor: backgroundColor ?? CustomColors.appBackgroudGrey2Color, + backgroundColor: widget.backgroundColor ?? CustomColors.appBackgroudGrey2Color, + + // appBar: widget.isShowPharmacyAppbar + // ? pharmacyAppbar() + // : widget.isShowAppBar + // ? widget.customAppBar != null + // ? widget.customAppBar + appBar: isUserNotLogin ? null - : (showNewAppBar - ? NewAppBarWidget( - title: appBarTitle, - showTitle: showNewAppBarTitle, - showDropDown: showDropDown, - dropdownIndexValue: dropdownIndexValue, - dropDownList: dropDownList ?? [], - dropDownIndexChange: dropDownIndexChange, - appBarIcons: appBarIcons, - onTap: onTap, - ) - : (isShowAppBar - ? customAppBar != null - ? customAppBar - : appBar = AppBarWidget( - appBarTitle: appBarTitle, - appBarIcons: appBarIcons, - showHomeAppBarIcon: showHomeAppBarIcon, - isPharmacy: isPharmacy, - showPharmacyCart: showPharmacyCart, - isOfferPackages: isOfferPackages, - showOfferPackagesCart: showOfferPackagesCart, - isShowDecPage: isShowDecPage, - backButtonTab: backButtonTab, - ) - : null)), - bottomSheet: bottomSheet, + : widget.isShowPharmacyAppbar + ? pharmacyAppbar() + : (widget.showNewAppBar + ? NewAppBarWidget( + title: widget.appBarTitle, + showTitle: widget.showNewAppBarTitle, + showDropDown: widget.showDropDown, + dropdownIndexValue: widget.dropdownIndexValue, + dropDownList: widget.dropDownList ?? [], + dropDownIndexChange: widget.dropDownIndexChange, + appBarIcons: widget.appBarIcons, + onTap: widget.onTap, + ) + : (widget.isShowAppBar + ? widget.customAppBar != null + ? widget.customAppBar + : appBar = AppBarWidget( + appBarTitle: widget.appBarTitle, + appBarIcons: widget.appBarIcons, + showHomeAppBarIcon: widget.showHomeAppBarIcon, + isPharmacy: widget.isPharmacy, + showPharmacyCart: widget.showPharmacyCart, + isOfferPackages: widget.isOfferPackages, + showOfferPackagesCart: widget.showOfferPackagesCart, + isShowDecPage: widget.isShowDecPage, + backButtonTab: widget.backButtonTab, + ) + : null)), + bottomSheet: widget.bottomSheet, body: SafeArea( top: true, bottom: true, child: isUserNotLogin ? NotAutPage( - title: title ?? appBarTitle, - description: description, - infoList: infoList, - imagesInfo: imagesInfo, - icon: icon, + title: widget.title ?? widget.appBarTitle, + description: widget.description, + infoList: widget.infoList, + imagesInfo: widget.imagesInfo, + icon: widget.icon, ) - : baseViewModel != null + : widget.baseViewModel != null ? NetworkBaseView( child: buildBodyWidget(context), - baseViewModel: baseViewModel, + baseViewModel: widget.baseViewModel, ) : buildBodyWidget(context), ), - bottomNavigationBar: bottomNavigationBar, - floatingActionButton: floatingActionButton, + bottomNavigationBar: widget.isBottomBar + ? BottomNavPharmacyBar( + changeIndex: changeCurrentTab, + index: widget.currentTab, + ) + : null, + floatingActionButton: widget.floatingActionButton, ); } + void changeCurrentTab(int value) { + if (widget.isMainPharmacyPages) { + widget.changeCurrentTab(value); + } else { + Navigator.pushAndRemoveUntil( + locator().navigatorKey.currentContext, MaterialPageRoute(builder: (context) => LandingPagePharmacy(currentTab: value)), (Route r) => false); + } + } + + void _scanQrAndGetProduct() async { + try { + String result = await BarcodeScanner.scan(); + try { + String barcode = result; + GifLoaderDialogUtils.showMyDialog(context); + await BaseAppClient().getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode", onSuccess: (dynamic response, int statusCode) { + print(response); + var product = PharmacyProduct.fromJson(response["products"][0]); + GifLoaderDialogUtils.hideDialog(context); + Navigator.push(context, FadePage(page: ProductDetailPage(product))); + }, onFailure: (String error, int statusCode) { + GifLoaderDialogUtils.hideDialog(context); + AppToast.showErrorToast(message: "Product not found"); + }); + } catch (apiEx) { + AppToast.showErrorToast(message: "Something went wrong, please try again"); + } + } catch (barcodeEx) {} + } + buildAppLoaderWidget(bool isLoading) { return isLoading ? AppLoaderWidget() : Container(); } buildBodyWidget(context) { - return Stack(children: [body, isHelp == true ? RobotIcon() : Container()]); + return Stack(children: [widget.body, widget.isHelp == true ? RobotIcon() : Container()]); } } @@ -206,7 +349,6 @@ class NewAppBarWidget extends StatelessWidget with PreferredSizeWidget { // centerTitle: false, title: Row( children: [ - if (showTitle) Expanded( child: Text( @@ -256,17 +398,19 @@ class NewAppBarWidget extends StatelessWidget with PreferredSizeWidget { ], ), actions: [ - if (appBarIcons != null) ...appBarIcons else - IconButton( - onPressed: () { - Navigator.pushAndRemoveUntil( - context, - MaterialPageRoute(builder: (context) => LandingPage()), - (Route route) => false, - ); - }, - icon: Icon(Icons.home), - ), + if (appBarIcons != null) + ...appBarIcons + else + IconButton( + onPressed: () { + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute(builder: (context) => LandingPage()), + (Route route) => false, + ); + }, + icon: Icon(Icons.home), + ), ], ); } diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart index d84a8b4f..105d7503 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart @@ -7,9 +7,9 @@ import 'bottom_nav_pharmacy_item.dart'; class BottomNavPharmacyBar extends StatefulWidget { final ValueChanged changeIndex; - final int index; BottomNavPharmacyBar({Key key, this.changeIndex, this.index}) : super(key: key); + int index = 0; @override _BottomNavPharmacyBarState createState() => _BottomNavPharmacyBarState(); diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart index 4c5b9d96..28217b8b 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart @@ -9,7 +9,7 @@ class BottomNavHomeItem extends StatelessWidget { final Image image; final String title; - final ValueChanged changeIndex; + final Function changeIndex; final int index; final int currentIndex; final Function onTap; @@ -62,7 +62,6 @@ class BottomNavHomeItem extends StatelessWidget { 'assets/images/habib-logo.png', ), height: 22.0, - ), SizedBox( height: 5, diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index af1e75ec..3b89c49c 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -163,7 +163,7 @@ class productTile extends StatelessWidget { ), onPressed: () async { GifLoaderDialogUtils.showMyDialog(context); - await addToCartFunction(1, productID); + await addToCartFunction(1, productID, context); GifLoaderDialogUtils.hideDialog(context); Navigator.push( context, @@ -292,7 +292,7 @@ class productTile extends StatelessWidget { // await x.deletWishlistData(itemID); // } - addToCartFunction(quantity, itemID) async { + addToCartFunction(quantity, itemID, BuildContext context) async { ProductDetailViewModel x = new ProductDetailViewModel(); await x.addToCartData(quantity, itemID); }