From 4939fe63d15eee907d011abd8525fb9daadc37cd Mon Sep 17 00:00:00 2001 From: mosazaid Date: Sun, 31 Oct 2021 15:45:01 +0200 Subject: [PATCH 01/70] pharmacy cart fixe counter --- .../pharmacyModule/OrderPreviewViewModel.dart | 5 ++ .../product_detail_view_model.dart | 42 ++++++++++++++-- lib/pages/login/login.dart | 5 +- .../product-details/product-detail.dart | 7 +-- .../shared/product_details_app_bar.dart | 48 ++++++++++++------- .../product_detail_service.dart | 11 +++-- lib/widgets/pharmacy/product_tile.dart | 6 +-- 7 files changed, 90 insertions(+), 34 deletions(-) diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index 801f6fb7..e27b0e03 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -32,6 +32,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(); diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index 014ba7fb..01c95b04 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -1,5 +1,6 @@ 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'; @@ -7,7 +8,10 @@ import 'package:diplomaticquarterapp/services/pharmacy_services/product_detail_s 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/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'; @@ -58,15 +62,45 @@ class ProductDetailViewModel extends BaseViewModel{ setState(ViewState.Idle); } - Future addToCartData(quantity, itemID) async { + Future addToCartData(quantity, itemID, BuildContext context) 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); + + // OrderPreviewViewModel orderPreviewViewModel = Provider.of(context); + Provider.of(locator().navigatorKey.currentContext, listen: false) + .setShoppingCartResponse( object); + // orderPreviewViewModel.cartResponse = 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/pages/login/login.dart b/lib/pages/login/login.dart index a77aaa1c..1f3fb133 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -68,10 +68,11 @@ class _Login extends State { if(BASE_URL.contains("uat.")){ nationalIDorFile.text = "2001273"; mobileNumberController.text = mobileNo = "0555416043"; - }/* else { + } else { nationalIDorFile.text = "3376044"; mobileNumberController.text = mobileNo = "0555416575"; - }*/ + } + } getDeviceToken() async { diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index ef3b7d8a..229fec19 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -3,7 +3,7 @@ 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/core/enum/viewstate.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'; @@ -345,9 +345,10 @@ class __ProductDetailPageState extends State { addToCartFunction( {quantity, itemID, - ProductDetailViewModel model}) async { + ProductDetailViewModel model, + }) async { GifLoaderDialogUtils.showMyDialog(context); - await model.addToCartData(quantity, itemID); + await model.addToCartData(quantity, itemID, context); GifLoaderDialogUtils.hideDialog(context); } } 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 ee1bcd60..82c1b5cf 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,7 +25,6 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { final bool isInWishList; final Function addToCartFunction; - ProductAppBar( {Key key, this.product, @@ -33,7 +32,8 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { this.addToWishlistFunction, this.quantity, this.deleteFromWishlistFunction, - this.isInWishList, this.addToCartFunction}) + this.isInWishList, + this.addToCartFunction}) : super(key: key); AuthenticatedUserObject authenticatedUserObject = @@ -79,21 +79,34 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { builder: (context) => CartOrderPage()), ); }), - - if(Provider.of(context, listen: false).cartResponse.quantityCount !=0) - Positioned( - top:0, right: -1.0, - child: Container( - decoration: BoxDecoration( - color: Colors.red[800], - borderRadius: BorderRadius.circular(15), - + if (Provider.of(context, + listen: false) + .cartResponse + .quantityCount != + 0) + Positioned( + top: 0, + right: -1.0, + child: Container( + decoration: BoxDecoration( + color: Colors.red[800], + borderRadius: BorderRadius.circular(15), + ), + padding: EdgeInsets.only(left: 5, right: 4.5), + height: 18, + child: Center( + child: Texts( + Provider.of(context, + listen: false) + .cartResponse + .quantityCount + .toString(), + style: "caption", + medium: true, + color: Colors.white, + )), ), - padding: EdgeInsets.only(left: 5, right: 4.5), - height: 18, - child: Center(child: Texts(Provider.of(context, listen: false).cartResponse.quantityCount.toString(), style: "caption", medium: true, color: Colors.white,)), - ), - ) + ) ], ), SizedBox( @@ -138,7 +151,8 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { await addToCartFunction( quantity: quantity, itemID: itemID, - model: model); + model: model, + context: context); Navigator.of(context).pop(); } diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 8bad3e69..b7b67b50 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -1,13 +1,13 @@ import 'package:diplomaticquarterapp/config/config.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'; class ProductDetailService extends BaseService { bool isLogin = false; @@ -28,7 +28,6 @@ class ProductDetailService extends BaseService { List get productSpecification => _productSpecification; - Future getProductReviews(productID) async { hasError = false; await baseAppClient.getPharmacy(GET_PRODUCT_DETAIL+productID+"?fields=reviews", @@ -74,7 +73,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; @@ -89,8 +88,7 @@ class ProductDetailService extends BaseService { "language_id": 1 } }; - - + dynamic localRes; await baseAppClient.pharmacyPost(GET_SHOPPING_CART, isExternal: false, onSuccess: (dynamic response, int statusCode) { @@ -99,11 +97,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 { diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index b6f73823..6d942c53 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -153,7 +153,7 @@ class productTile extends StatelessWidget { icon: Icon(FontAwesomeIcons.shoppingCart, size: 15), onPressed: () async { GifLoaderDialogUtils.showMyDialog(context); - await addToCartFunction(1, productID); + await addToCartFunction(1, productID, context); GifLoaderDialogUtils.hideDialog(context); Navigator.push( context, @@ -301,8 +301,8 @@ 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); + await x.addToCartData(quantity, itemID, context); } } From bc91b9ad88c462099f279c59880477d5789968ff Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Sun, 31 Oct 2021 17:15:17 +0200 Subject: [PATCH 02/70] bottom nav pharmacy --- .../viewModels/PharmacyPagesViewModel.dart | 17 ++ lib/main.dart | 11 +- lib/pages/final_products_page.dart | 75 ++++-- lib/pages/landing/landing_page_pharmcy.dart | 122 +-------- lib/pages/parent_categorise_page.dart | 150 ++++++----- lib/pages/pharmacies/product-brands.dart | 185 ++++++------- .../screens/cart-page/cart-order-page.dart | 4 +- .../screens/pharmacy_module_page.dart | 58 ++-- lib/pages/pharmacies/search_brands_page.dart | 21 +- lib/pages/pharmacy/profile/profile.dart | 9 +- lib/pages/pharmacy_categorise.dart | 4 + lib/widgets/others/app_scaffold_widget.dart | 247 ++++++++++++++---- .../pharmacy/bottom_nav_pharmacy_bar.dart | 2 +- .../bottom_nav_pharmacy_home_item.dart | 3 +- 14 files changed, 506 insertions(+), 402 deletions(-) create mode 100644 lib/core/viewModels/PharmacyPagesViewModel.dart 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/main.dart b/lib/main.dart index 87120231..12deb064 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/analytics/google-analytics.dart'; +import 'package:diplomaticquarterapp/core/viewModels/PharmacyPagesViewModel.dart'; import 'package:diplomaticquarterapp/theme/theme_notifier.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/routes.dart'; @@ -19,7 +20,6 @@ import 'locator.dart'; import 'pages/pharmacies/compare-list.dart'; import 'package:firebase_core/firebase_core.dart'; - void main() async { WidgetsFlutterBinding.ensureInitialized(); FirebaseApp defaultApp = await Firebase.initializeApp(); @@ -34,7 +34,6 @@ class MyApp extends StatefulWidget { } class _MyApp extends State { - @override void initState() { // ProjectViewModel projectProvider; @@ -52,7 +51,6 @@ class _MyApp extends State { .showNow(title: "Payload", subtitle: payload, payload: payload); }); - // final themeNotifier = Provider.of(context); precacheImage(AssetImage('assets/images/powerd-by.jpg'), context); return LayoutBuilder( @@ -62,6 +60,9 @@ class _MyApp extends State { SizeConfig().init(constraints, orientation); return MultiProvider( providers: [ + ChangeNotifierProvider( + create: (context) => PharmacyPagesViewModel(), + ), ChangeNotifierProvider( create: (context) => ProjectViewModel(), ), @@ -85,9 +86,7 @@ class _MyApp extends State { ], child: Consumer( builder: (context, projectProvider, child) => MaterialApp( - navigatorObservers: [ - GAnalytics.shared.navObserver() - ], + navigatorObservers: [GAnalytics.shared.navObserver()], navigatorKey: locator().navigatorKey, showSemanticsDebugger: false, title: 'Diplomatic Quarter App', diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 854b66a6..3e8f35ed 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -11,6 +11,7 @@ import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/pr 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'; @@ -23,7 +24,7 @@ class FinalProductsPage extends StatefulWidget { final String id; final int productType; // 1 : default, 2 : manufacturer , 3 : recently viewed AuthenticatedUserObject authenticatedUserObject = - locator(); + locator(); FinalProductsPage({this.id, this.productType = 1}); @@ -79,9 +80,10 @@ class _FinalProductsPageState extends State { allowAny: true, builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => - PharmacyAppScaffold( + AppScaffold( + isPharmacy: true, appBarTitle: appBarTitle, - isBottomBar: false, + isBottomBar: true, isShowAppBar: true, backgroundColor: Colors.white, isShowDecPage: false, @@ -91,8 +93,6 @@ class _FinalProductsPageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ -//Expanded widget heree if nassery - Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -613,30 +613,51 @@ class _FinalProductsPageState extends State { ], ), ), - - widget.authenticatedUserObject.isLogin + 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: 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(), ], ), ), diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 6ae272e2..a71038e0 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -15,6 +15,7 @@ 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'; @@ -27,24 +28,13 @@ class LandingPagePharmacy extends StatefulWidget { } class _LandingPagePharmacyState extends State { - 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); } @override @@ -53,117 +43,15 @@ 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, - body: PageView( - physics: NeverScrollableScrollPhysics(), - controller: pageController, - children: [ - PharmacyPage(), - PharmacyCategorisePage(), - PharmacyProfilePage(), - CartOrderPage(changeTab: _changeCurrentTab), - ], - ), - bottomNavigationBar: BottomNavPharmacyBar( - changeIndex: _changeCurrentTab, - index: currentTab, - ), + // isMainPharmacyPages: true, + body: null, ), ); } - 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) {} - } - getText(currentTab) { switch (currentTab) { case 2: diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 18133bb2..1a93a7b1 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 fb3e38e4..fe04784b 100644 --- a/lib/pages/pharmacies/product-brands.dart +++ b/lib/pages/pharmacies/product-brands.dart @@ -35,105 +35,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 ef4904b2..5043b527 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -48,8 +48,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, backButtonTab: widget.changeTab != null ? () => widget.changeTab(0) : null, diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 5ffe875c..0c88e473 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -21,36 +21,38 @@ class _PharmacyPageState extends State { Widget build(BuildContext context) { OrderPreviewViewModel orderPreviewViewModel = Provider.of(context); return WillPopScope( - onWillPop: ()async{ + onWillPop: () async { return false; }, - child:BaseView( - onModelReady: (model) async { - await model.getSavedLanguage(); - await model.getBannerList(); - if(model.isLogin) - await orderPreviewViewModel.getShoppingCart(); - }, - allowAny: true, - builder: (_, model, wi) => AppScaffold( - title: "", - isShowAppBar: false, - isShowDecPage: false, - baseViewModel: model, - backgroundColor: Colors.white, - body: Container( - width: double.infinity, - child: SingleChildScrollView( - child: Column( - //crossAxisAlignment: CrossAxisAlignment.start, - children: [ - BannerPager(model), - GridViewButtons(model), - PrescriptionsWidget(), - ShopByBrandWidget(), - RecentlyViewedWidget(), - BestSellerWidget(), - ],), + child: BaseView( + onModelReady: (model) async { + await model.getSavedLanguage(); + await model.getBannerList(); + if (model.isLogin) await orderPreviewViewModel.getShoppingCart(); + }, + allowAny: true, + builder: (_, model, wi) => AppScaffold( + title: "", + isShowDecPage: false, + baseViewModel: model, + isMainPharmacyPages: true, + isPharmacy: true, + isBottomBar: true, + backgroundColor: Colors.white, + body: Container( + width: double.infinity, + child: SingleChildScrollView( + child: Column( + //crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BannerPager(model), + GridViewButtons(model), + PrescriptionsWidget(), + ShopByBrandWidget(), + RecentlyViewedWidget(), + BestSellerWidget(), + ], + ), ), ), ), diff --git a/lib/pages/pharmacies/search_brands_page.dart b/lib/pages/pharmacies/search_brands_page.dart index 8f771490..f053dee1 100644 --- a/lib/pages/pharmacies/search_brands_page.dart +++ b/lib/pages/pharmacies/search_brands_page.dart @@ -108,22 +108,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/pharmacy/profile/profile.dart b/lib/pages/pharmacy/profile/profile.dart index a82a74eb..93c26844 100644 --- a/lib/pages/pharmacy/profile/profile.dart +++ b/lib/pages/pharmacy/profile/profile.dart @@ -94,11 +94,13 @@ class _ProfilePageState extends State { builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).myAccount, isShowAppBar: false, - isShowDecPage: false, + isShowDecPage: true, isPharmacy: true, + isBottomBar: true, + isMainPharmacyPages: true, body: user != null ? Container( - color: Colors.white, + color: Colors.white, child: SingleChildScrollView( child: Column( children: [ @@ -233,8 +235,7 @@ class _ProfilePageState extends State { Expanded( child: InkWell( onTap: () { - Navigator.push( - context, + Navigator.push(context, FadePage(page: WishlistPage())); }, child: Column( diff --git a/lib/pages/pharmacy_categorise.dart b/lib/pages/pharmacy_categorise.dart index b71c28ce..8dc357cb 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, + isBottomBar: true, baseViewModel: model, body: Column( children: [ diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index f80acf75..3d9d88b6 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -1,20 +1,32 @@ import 'package:badges/badges.dart'; +import 'package:barcode_scan_fix/barcode_scan.dart'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/config/size_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/insurance/insurance_update_screen.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacy/profile/profile.dart'; +import 'package:diplomaticquarterapp/pages/pharmacy_categorise.dart'; +import 'package:diplomaticquarterapp/pages/search_products_page.dart'; import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/robo_search/event_provider.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/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/bottom_bar.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:diplomaticquarterapp/widgets/typewriter/typewiter.dart'; @@ -33,7 +45,9 @@ import 'not_auh_page.dart'; VoidCallback _onCartClick; -class AppScaffold extends StatelessWidget { +class AppScaffold extends StatefulWidget { + AppBarWidget appBar; + final String appBarTitle; final Widget body; final Widget bottomSheet; @@ -44,9 +58,11 @@ class AppScaffold extends StatelessWidget { final bool isBottomBar; final Widget floatingActionButton; final bool isPharmacy; + final bool isMainPharmacyPages; final bool isOfferPackages; final bool showPharmacyCart; final bool showOfferPackagesCart; + final bool extendBody; final String title; final String description; final bool isShowDecPage; @@ -60,12 +76,13 @@ class AppScaffold extends StatelessWidget { final bool isLocalLoader; final Function backButtonTab; - AuthenticatedUserObject authenticatedUserObject = - locator(); - - AppBarWidget appBar; final Widget customAppBar; + AppScaffold setOnAppBarCartClick(VoidCallback onClick) { + _onCartClick = onClick; + return this; + } + AppScaffold( {@required this.body, this.appBarTitle = '', @@ -76,13 +93,15 @@ class AppScaffold extends StatelessWidget { this.baseViewModel, this.floatingActionButton, this.isPharmacy = false, + this.isMainPharmacyPages = false, this.showPharmacyCart = true, this.isOfferPackages = false, this.showOfferPackagesCart = false, + this.extendBody = false, this.title, this.description, this.isShowDecPage = true, - this.isBottomBar, + this.isBottomBar = false, this.backgroundColor, this.preferredSize = 0.0, this.appBarIcons, @@ -95,56 +114,185 @@ class AppScaffold extends StatelessWidget { this.isLocalLoader = false, this.backButtonTab}); - AppScaffold setOnAppBarCartClick(VoidCallback onClick) { - _onCartClick = onClick; - return this; + @override + _AppScaffoldState createState() => _AppScaffoldState(); +} + +class _AppScaffoldState extends State { + AuthenticatedUserObject authenticatedUserObject = + locator(); + + @override + void initState() { + super.initState(); + } + + AppBar pharmacyAppbar() { + return Provider.of(context, listen: false) + .currentTab != + 4 && + Provider.of(context, listen: false) + .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: () { + 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, + ) + : null; } @override Widget build(BuildContext context) { + PharmacyPagesViewModel pagesViewModel = Provider.of(context); AppGlobal.context = context; return Scaffold( backgroundColor: - backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, - appBar: isShowAppBar - ? customAppBar != null - ? customAppBar - : appBar = AppBarWidget( - appBarTitle: appBarTitle, - appBarIcons: appBarIcons, - showHomeAppBarIcon: showHomeAppBarIcon, - isPharmacy: isPharmacy, - showPharmacyCart: showPharmacyCart, - isOfferPackages: isOfferPackages, - showOfferPackagesCart: showOfferPackagesCart, - isShowDecPage: isShowDecPage, - backButtonTab: backButtonTab, - ) + widget.backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, + extendBody: widget.extendBody, + appBar: widget.isMainPharmacyPages + ? pharmacyAppbar() + : widget.isShowAppBar + ? widget.customAppBar != null + ? widget.customAppBar + : widget.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: (widget.isBottomBar && widget.isPharmacy) + ? PageView( + physics: NeverScrollableScrollPhysics(), + controller: pagesViewModel.pageController, + children: [ + PharmacyPage(), + PharmacyCategorisePage(), + PharmacyProfilePage(), + CartOrderPage(changeTab: pagesViewModel.changeCurrentTab), + ], + ) + : mainBody(), + floatingActionButton: widget.floatingActionButton, + bottomNavigationBar: widget.isBottomBar + ? BottomNavPharmacyBar( + changeIndex: pagesViewModel.changeCurrentTab, + index: pagesViewModel.currentTab, + ) : null, - bottomSheet: bottomSheet, - body: SafeArea( - top: true, - bottom: true, - child: - (!Provider.of(context, listen: false).isLogin && - isShowDecPage) - ? NotAutPage( - title: title ?? appBarTitle, - description: description, - infoList: infoList, - imagesInfo: imagesInfo, - ) - : baseViewModel != null - ? NetworkBaseView( - child: buildBodyWidget(context), - baseViewModel: baseViewModel, - ) - : buildBodyWidget(context), - ), - floatingActionButton: floatingActionButton, ); } + Widget mainBody() { + return SafeArea( + top: true, + bottom: true, + child: (!Provider.of(context, listen: false).isLogin && + widget.isShowDecPage) + ? NotAutPage( + title: widget.title ?? widget.appBarTitle, + description: widget.description, + infoList: widget.infoList, + imagesInfo: widget.imagesInfo, + ) + : widget.baseViewModel != null + ? NetworkBaseView( + child: buildBodyWidget(context), + baseViewModel: widget.baseViewModel, + ) + : buildBodyWidget(context), + ); + } + + 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(); } @@ -152,15 +300,15 @@ class AppScaffold extends StatelessWidget { buildBodyWidget(context) { return Stack(children: [ Center( - child: isLoading + child: widget.isLoading ? CircularProgressIndicator( backgroundColor: Colors.white, valueColor: AlwaysStoppedAnimation( Colors.grey[500], ), ) - : body), - isHelp == true ? RobotIcon() : Container() + : widget.body), + widget.isHelp == true ? RobotIcon() : Container() ]); } } @@ -263,7 +411,8 @@ class AppBarWidgetState extends State { icon: Badge( position: BadgePosition.topStart(top: -15, start: -10), badgeContent: Text( - orderPreviewViewModel.cartResponse.quantityCount.toString() /*_badgeText*/, + orderPreviewViewModel.cartResponse.quantityCount + .toString() /*_badgeText*/, style: TextStyle( fontSize: 9, color: Colors.white, diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart index d1490d74..83ee640a 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart @@ -8,7 +8,7 @@ import 'bottom_nav_pharmacy_home_item.dart'; import 'bottom_nav_pharmacy_item.dart'; class BottomNavPharmacyBar extends StatefulWidget { - final ValueChanged changeIndex; + final Function changeIndex; final int index; BottomNavPharmacyBar({Key key, this.changeIndex, this.index}) : super(key: key); diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart index 24986c74..6a930617 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, From 044f74865e37247257e40deb7477ccb258848032 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Mon, 1 Nov 2021 10:26:59 +0300 Subject: [PATCH 03/70] fixed issues --- lib/config/localized_values.dart | 1 + lib/pages/offers_categorise_page.dart | 2 +- lib/pages/pharmacies/product-brands.dart | 4 ++-- .../screens/product-details/footor/footer-widget.dart | 2 +- lib/pages/pharmacies/search_brands_page.dart | 6 ++++-- lib/pages/pharmacies/widgets/ProductTileItem.dart | 10 +++++----- lib/pages/search_products_page.dart | 6 +++--- lib/uitl/translations_delegate_base.dart | 2 ++ 8 files changed, 19 insertions(+), 14 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index aa786e77..ba89e77a 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -585,6 +585,7 @@ const Map localizedValues = { "remeberthat": {"en": "Remember that", "ar": "تذكر ذلك:"}, "loginToUseService": {"en": "You need to login to use this service", "ar": "هذة الخدمة تتطلب تسجيل الدخول"}, "offersAndPromotions": {"en": "OFFERS & SPECIAL PROMOTIONS", "ar": "العروض والترقيات الخاصة"}, + "offers": {"en": "OFFERS", "ar": "العروض"}, "myPrescriptions": {"en": "MY PRESCRIPTIONS", "ar": "وصفاتي"}, "searchAndScanMedication": {"en": "SEARCH & SCAN FOR MEDICATION", "ar": "البحث والمسح للأدوية"}, "shopByBrands": {"en": "Shop by Brands", "ar": "تسوق حسب الماركات"}, diff --git a/lib/pages/offers_categorise_page.dart b/lib/pages/offers_categorise_page.dart index 2715b2b0..15c3b070 100644 --- a/lib/pages/offers_categorise_page.dart +++ b/lib/pages/offers_categorise_page.dart @@ -33,7 +33,7 @@ class _OffersCategorisePageState extends State { builder: (BuildContext context, OffersCategoriseViewModel model, Widget child) => PharmacyAppScaffold( - appBarTitle: 'Offers', + appBarTitle: TranslationBase.of(context).offers, isShowAppBar: true, backgroundColor: Colors.white, isShowDecPage: false, diff --git a/lib/pages/pharmacies/product-brands.dart b/lib/pages/pharmacies/product-brands.dart index 4ff90706..29146381 100644 --- a/lib/pages/pharmacies/product-brands.dart +++ b/lib/pages/pharmacies/product-brands.dart @@ -60,7 +60,7 @@ class _ProductBrandsPageState extends State { height: 10, ), Container( - height: MediaQuery.of(context).size.height * 0.056, + height: MediaQuery.of(context).size.height * 0.076, decoration: BoxDecoration( borderRadius: BorderRadius.circular(5.0), color: Colors.white, @@ -95,7 +95,7 @@ class _ProductBrandsPageState extends State { height: 10, ), Container( - height: 420, + height: 250, width: double.infinity, color: Colors.white, child: ListView.builder( diff --git a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart index b8bc5808..977e3e39 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -86,7 +86,7 @@ class _FooterWidgetState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, ), Container( - height: 50.0, + height: 35.0, child: ListView( scrollDirection: Axis.horizontal, children: [ diff --git a/lib/pages/pharmacies/search_brands_page.dart b/lib/pages/pharmacies/search_brands_page.dart index cb1281ff..5794ac55 100644 --- a/lib/pages/pharmacies/search_brands_page.dart +++ b/lib/pages/pharmacies/search_brands_page.dart @@ -52,10 +52,12 @@ class _SearchBrandsPageState extends State { prefixIcon: Icon(Icons.search), inputAction: TextInputAction.search, inputFormatters: [ - FilteringTextInputFormatter.deny(RegExp("[\u0621-\u064a-\ ]")) + FilteringTextInputFormatter.allow(RegExp(r'([A-Za-z0-9 a space])') +// ("[\u0621-\u064a-\ ]") + ) ], validator: (value) { - RegExp regExp = RegExp('[\u0621-\u064a-\ ]'); + RegExp regExp = RegExp(r'([A-Za-z0-9 a space])'); if (value.isEmpty) { TranslationBase.of(context).pleaseEnterProductName; }else if (regExp.hasMatch(value)){ diff --git a/lib/pages/pharmacies/widgets/ProductTileItem.dart b/lib/pages/pharmacies/widgets/ProductTileItem.dart index a24531a5..278fc6aa 100644 --- a/lib/pages/pharmacies/widgets/ProductTileItem.dart +++ b/lib/pages/pharmacies/widgets/ProductTileItem.dart @@ -125,12 +125,12 @@ class ProductTileItem extends StatelessWidget { ], ), Padding( - padding: EdgeInsets.fromLTRB(4,2,4,2), + padding: EdgeInsets.fromLTRB(1,1,1,1), child: Container( -// width: item.rxMessage != null -// ? MediaQuery.of(context).size.width / 5 -// : 0, - // padding: EdgeInsets.fromLTRB(6,4,6,4), + width: item.rxMessage != null + ? MediaQuery.of(context).size.width / 1.0 + : 0, + padding: EdgeInsets.fromLTRB(8,2,8,2), decoration: BoxDecoration( color: Color(0xffb23838), diff --git a/lib/pages/search_products_page.dart b/lib/pages/search_products_page.dart index 954546d7..b7f08378 100644 --- a/lib/pages/search_products_page.dart +++ b/lib/pages/search_products_page.dart @@ -59,11 +59,11 @@ class _SearchProductsPageState extends State { prefixIcon: Icon(Icons.search), inputAction: TextInputAction.search, inputFormatters: [ - FilteringTextInputFormatter.deny( - RegExp("[\u0621-\u064a-\ ]")) + FilteringTextInputFormatter.allow( + RegExp(r'([A-Za-z0-9 a space])')) ], validator: (value) { - RegExp regExp = RegExp('[\u0621-\u064a-\ ]'); + RegExp regExp = RegExp(r'([A-Za-z0-9 a space])'); if (value.isEmpty) { TranslationBase.of(context) .pleaseEnterProductName; diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 134da8bf..6efa2283 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1072,6 +1072,8 @@ class TranslationBase { String get offersAndPromotions => localizedValues['offersAndPromotions'][locale.languageCode]; + String get offers => localizedValues['offers'][locale.languageCode]; + String get review => localizedValues['review'][locale.languageCode]; String get deliveredOrder => localizedValues['deliveredOrder'][locale.languageCode]; From d4283c011627949192af0695b4ea1b964c7d66de Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Mon, 1 Nov 2021 09:44:44 +0200 Subject: [PATCH 04/70] fix merge issue --- .../viewModels/pharmacyModule/product_detail_view_model.dart | 5 +---- .../pharmacies/screens/product-details/product-detail.dart | 5 ++++- lib/widgets/pharmacy/product_tile.dart | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index 01c95b04..98596ee0 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -62,7 +62,7 @@ class ProductDetailViewModel extends BaseViewModel{ setState(ViewState.Idle); } - Future addToCartData(quantity, itemID, BuildContext context) async { + Future addToCartData(quantity, itemID) async { hasError = false; setState(ViewState.BusyLocal); var resp = await _productDetailService.addToCart(quantity, itemID); @@ -72,11 +72,8 @@ class ProductDetailViewModel extends BaseViewModel{ setState(ViewState.ErrorLocal); } else { setState(ViewState.Idle); - - // OrderPreviewViewModel orderPreviewViewModel = Provider.of(context); Provider.of(locator().navigatorKey.currentContext, listen: false) .setShoppingCartResponse( object); - // orderPreviewViewModel.cartResponse = object; } } diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 07c5d0e8..9367ceb9 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -338,6 +338,9 @@ class __ProductDetailPageState extends State { ), )); } + addToShoppingCartFunction({quantity,itemID,ProductDetailViewModel model})async{ + await model.addToCartData(quantity,itemID); + } addToWishlistFunction({itemID, ProductDetailViewModel model}) async { isInWishList = true; @@ -356,7 +359,7 @@ class __ProductDetailPageState extends State { ProductDetailViewModel model, }) async { GifLoaderDialogUtils.showMyDialog(context); - await model.addToCartData(quantity, itemID, context); + await model.addToCartData(quantity, itemID); GifLoaderDialogUtils.hideDialog(context); } } diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index 15eab3ed..de449eaf 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -319,6 +319,6 @@ class productTile extends StatelessWidget { addToCartFunction(quantity, itemID, BuildContext context) async { ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID, context); + await x.addToCartData(quantity, itemID); } } From f424315a1977eaa41ca3879ca9f1b27e450a134f Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Mon, 1 Nov 2021 09:52:15 +0200 Subject: [PATCH 05/70] =?UTF-8?q?last=20commit=20=F0=9F=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/pharmacies/screens/product-details/product-detail.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 9367ceb9..237c1ed8 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -340,6 +340,7 @@ class __ProductDetailPageState extends State { } addToShoppingCartFunction({quantity,itemID,ProductDetailViewModel model})async{ await model.addToCartData(quantity,itemID); + } addToWishlistFunction({itemID, ProductDetailViewModel model}) async { From 46d7e7ee14d4136225cce30268099b045e33a3d4 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 1 Nov 2021 16:02:40 +0200 Subject: [PATCH 06/70] show bottom nav in pharmacy all pages --- lib/pages/landing/landing_page_pharmcy.dart | 37 +++- .../screens/cart-page/cart-order-page.dart | 2 +- .../screens/pharmacy_module_page.dart | 2 +- lib/pages/pharmacy/profile/profile.dart | 2 +- lib/pages/pharmacy_categorise.dart | 2 +- lib/widgets/others/app_scaffold_widget.dart | 179 ++++++++++-------- .../pharmacy/bottom_nav_pharmacy_bar.dart | 5 +- 7 files changed, 138 insertions(+), 91 deletions(-) diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index a71038e0..7a290383 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/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; @@ -19,22 +20,42 @@ 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; void initState() { super.initState(); locator().manufacturerList = []; locator().bestSellerProducts = []; locator().lastVisitedProducts = []; + pageController = + PageController(keepPage: true, initialPage: widget.currentTab); + setState(() { + currentTab = widget.currentTab; + }); + } + + changeCurrentTab(int tab) { + if (pageController.hasClients) { + setState(() { + currentTab = tab; + pageController.jumpToPage(tab); + }); + } } @override @@ -46,8 +67,20 @@ class _LandingPagePharmacyState extends State { child: AppScaffold( isBottomBar: true, extendBody: false, - // isMainPharmacyPages: true, - body: null, + isShowDecPage: false, + isMainPharmacyPages: true, + currentTab: currentTab, + changeCurrentTab: changeCurrentTab, + body: PageView( + physics: NeverScrollableScrollPhysics(), + controller: pageController, + children: [ + PharmacyPage(), + PharmacyCategorisePage(), + PharmacyProfilePage(), + CartOrderPage(changeTab: changeCurrentTab), + ], + ), ), ); } 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 5043b527..31cfa666 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -48,7 +48,7 @@ class _CartOrderPageState extends State { appBarTitle: TranslationBase.of(context).shoppingCart, isShowAppBar: true, isPharmacy: true, - isBottomBar: true, + //isBottomBar: true, showHomeAppBarIcon: false, isShowDecPage: false, isMainPharmacyPages: true, diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 0c88e473..77eca9c6 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -37,7 +37,7 @@ class _PharmacyPageState extends State { baseViewModel: model, isMainPharmacyPages: true, isPharmacy: true, - isBottomBar: true, + isShowPharmacyAppbar: true, backgroundColor: Colors.white, body: Container( width: double.infinity, diff --git a/lib/pages/pharmacy/profile/profile.dart b/lib/pages/pharmacy/profile/profile.dart index 93c26844..b9db9f29 100644 --- a/lib/pages/pharmacy/profile/profile.dart +++ b/lib/pages/pharmacy/profile/profile.dart @@ -96,7 +96,7 @@ class _ProfilePageState extends State { isShowAppBar: false, isShowDecPage: true, isPharmacy: true, - isBottomBar: true, + //isBottomBar: true, isMainPharmacyPages: true, body: user != null ? Container( diff --git a/lib/pages/pharmacy_categorise.dart b/lib/pages/pharmacy_categorise.dart index 8dc357cb..8a965b6e 100644 --- a/lib/pages/pharmacy_categorise.dart +++ b/lib/pages/pharmacy_categorise.dart @@ -38,7 +38,7 @@ class _PharmacyCategorisePageState extends State { isShowAppBar: false, isMainPharmacyPages: true, isPharmacy: true, - isBottomBar: true, + isShowPharmacyAppbar: true, baseViewModel: model, body: Column( children: [ diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 3d9d88b6..6b8f42a3 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -13,6 +13,7 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreview import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; +import 'package:diplomaticquarterapp/pages/landing/landing_page_pharmcy.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; @@ -23,6 +24,7 @@ import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/robo_search/event_provider.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/others/bottom_bar.dart'; @@ -75,9 +77,10 @@ class AppScaffold extends StatefulWidget { final bool isHelp; final bool isLocalLoader; final Function backButtonTab; - + final ValueChanged changeCurrentTab; final Widget customAppBar; - + final int currentTab; + final bool isShowPharmacyAppbar; AppScaffold setOnAppBarCartClick(VoidCallback onClick) { _onCartClick = onClick; return this; @@ -112,7 +115,10 @@ class AppScaffold extends StatefulWidget { appBar, this.customAppBar, this.isLocalLoader = false, - this.backButtonTab}); + this.backButtonTab, + this.changeCurrentTab, + this.currentTab, + this.isShowPharmacyAppbar = false}); @override _AppScaffoldState createState() => _AppScaffoldState(); @@ -128,76 +134,69 @@ class _AppScaffoldState extends State { } AppBar pharmacyAppbar() { - return Provider.of(context, listen: false) - .currentTab != - 4 && - Provider.of(context, listen: false) - .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, - ) - ], - ), + 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, ), - onTap: () { - Navigator.push( - context, - FadePage(page: SearchProductsPage()), - ); - }, + 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', ), ), - 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', ), - actions: [ - IconButton( - // iconSize: 70, - icon: Image.asset( - 'assets/images/new-design/qr-code.png', - ), - onPressed: _scanQrAndGetProduct //do something, - ) - ], - centerTitle: true, - ) - : null; + onPressed: _scanQrAndGetProduct //do something, + ) + ], + centerTitle: true, + ); } @override @@ -208,7 +207,7 @@ class _AppScaffoldState extends State { backgroundColor: widget.backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, extendBody: widget.extendBody, - appBar: widget.isMainPharmacyPages + appBar: widget.isShowPharmacyAppbar ? pharmacyAppbar() : widget.isShowAppBar ? widget.customAppBar != null @@ -226,28 +225,42 @@ class _AppScaffoldState extends State { ) : null, bottomSheet: widget.bottomSheet, - body: (widget.isBottomBar && widget.isPharmacy) - ? PageView( - physics: NeverScrollableScrollPhysics(), - controller: pagesViewModel.pageController, - children: [ - PharmacyPage(), - PharmacyCategorisePage(), - PharmacyProfilePage(), - CartOrderPage(changeTab: pagesViewModel.changeCurrentTab), - ], + body: (!Provider.of(context, listen: false).isLogin && + widget.isShowDecPage) + ? NotAutPage( + title: widget.title ?? widget.appBarTitle, + description: widget.description, + infoList: widget.infoList, + imagesInfo: widget.imagesInfo, ) - : mainBody(), + : widget.baseViewModel != null + ? NetworkBaseView( + child: buildBodyWidget(context), + baseViewModel: widget.baseViewModel, + ) + : buildBodyWidget(context), floatingActionButton: widget.floatingActionButton, bottomNavigationBar: widget.isBottomBar ? BottomNavPharmacyBar( - changeIndex: pagesViewModel.changeCurrentTab, - index: pagesViewModel.currentTab, + changeIndex: changeCurrentTab, + index: widget.currentTab, ) : null, ); } + 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); + } + } + Widget mainBody() { return SafeArea( top: true, diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart index 83ee640a..19c90da7 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart @@ -8,8 +8,9 @@ import 'bottom_nav_pharmacy_home_item.dart'; import 'bottom_nav_pharmacy_item.dart'; class BottomNavPharmacyBar extends StatefulWidget { - final Function changeIndex; - final int index; + final ValueChanged changeIndex; + int index = 0; + BottomNavPharmacyBar({Key key, this.changeIndex, this.index}) : super(key: key); From cb8508596940ecb3e99af8c265deddea0620fc67 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 1 Nov 2021 16:08:36 +0200 Subject: [PATCH 07/70] show bottom nav in pharmacy all pages --- lib/pages/pharmacy/profile/profile.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pages/pharmacy/profile/profile.dart b/lib/pages/pharmacy/profile/profile.dart index b9db9f29..dd4b908d 100644 --- a/lib/pages/pharmacy/profile/profile.dart +++ b/lib/pages/pharmacy/profile/profile.dart @@ -93,9 +93,10 @@ class _ProfilePageState extends State { }, builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).myAccount, - isShowAppBar: false, + isShowAppBar: true, isShowDecPage: true, isPharmacy: true, + //isBottomBar: true, isMainPharmacyPages: true, body: user != null From 585e26b091495a233fcec1ee5e8e9b9fff4046f8 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 1 Nov 2021 17:18:34 +0300 Subject: [PATCH 08/70] Registration fix --- lib/config/config.dart | 4 +--- lib/pages/login/login.dart | 1 + lib/pages/login/register.dart | 20 +++++++++++--------- 3 files changed, 13 insertions(+), 12 deletions(-) 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/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; From 8d6278a59be2f1f6bc1ac0b40c8b61b03bf3d0b5 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 1 Nov 2021 18:38:23 +0300 Subject: [PATCH 09/70] Pharmacy fixes --- .../parmacyModule/order-preview-service.dart | 8 +- .../pharmacyModule/OrderPreviewViewModel.dart | 14 +-- .../ClinicOfferAndPackagesPage.dart | 4 +- .../packages_offers/OfferAndPackagesPage.dart | 2 +- .../screens/cart-page/cart-order-page.dart | 8 +- .../cart-page/payment_bottom_widget.dart | 2 +- .../cart-page/select_address_widget.dart | 8 +- .../screens/pharmacy_module_page.dart | 2 +- .../product-details/product-detail.dart | 95 +++++--------- .../widgets/home/PrescriptionsWidget.dart | 2 +- lib/widgets/others/app_scaffold_widget.dart | 116 ++++++++++-------- .../pharmacy/bottom_nav_pharmacy_bar.dart | 4 - 12 files changed, 123 insertions(+), 142 deletions(-) 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/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index e9c32f2b..d3f09119 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -161,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/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/pharmacies/screens/cart-page/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart index 4fc5067e..6bfe4fbc 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -105,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) { @@ -119,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 77cdaed6..4da64235 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -55,7 +55,7 @@ class _PharmacyPageState extends State { //crossAxisAlignment: CrossAxisAlignment.start, children: [ BannerPager(model), - GridViewButtons(model), + // GridViewButtons(model), PrescriptionsWidget(), ShopByBrandWidget(), RecentlyViewedWidget(), diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 2056c7ab..e34a5dbc 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -1,12 +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/core/enum/viewstate.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.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'; @@ -16,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'; @@ -108,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( @@ -127,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) ], ), ), @@ -146,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, ), @@ -169,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, @@ -207,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, ) ], ), @@ -227,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(); } @@ -246,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, ), ], ), @@ -266,8 +242,7 @@ class __ProductDetailPageState extends State { children: [ FlatButton( onPressed: () async { - GifLoaderDialogUtils.showMyDialog( - context); + GifLoaderDialogUtils.showMyDialog(context); await model.getProductLocationData(); GifLoaderDialogUtils.hideDialog(context); @@ -279,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, ), ], ), @@ -317,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); - },) + }, + ) ], ), ), @@ -340,9 +315,9 @@ class __ProductDetailPageState extends State { ), )); } - addToShoppingCartFunction({quantity,itemID,ProductDetailViewModel model})async{ - await model.addToCartData(quantity,itemID); + addToShoppingCartFunction({quantity, itemID, ProductDetailViewModel model}) async { + await model.addToCartData(quantity, itemID); } addToWishlistFunction({itemID, ProductDetailViewModel model}) async { @@ -356,20 +331,18 @@ class __ProductDetailPageState extends State { await model.deleteWishlistData(itemID); setState(() {}); } - addToCartFunction( - {quantity, - itemID, - ProductDetailViewModel model, - }) async { + + addToCartFunction({ + quantity, + itemID, + ProductDetailViewModel model, + }) async { GifLoaderDialogUtils.showMyDialog(context); await model.addToCartData(quantity, itemID); GifLoaderDialogUtils.hideDialog(context); } } - - -notifyMeWhenAvailable( - {itemId, customerId, ProductDetailViewModel model}) async { +notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model}) async { await model.notifyMe(customerId, itemId); } 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/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 75e0a8f9..d071d4d2 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -12,13 +12,8 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreview 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/cart-page/cart-order-page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; -import 'package:diplomaticquarterapp/pages/pharmacy/profile/profile.dart'; -import 'package:diplomaticquarterapp/pages/pharmacy_categorise.dart'; import 'package:diplomaticquarterapp/pages/search_products_page.dart'; -import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; @@ -27,7 +22,6 @@ 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/others/bottom_bar.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'; @@ -45,8 +39,6 @@ import 'not_auh_page.dart'; VoidCallback _onCartClick; class AppScaffold extends StatefulWidget { - AppBarWidget appBar; - final String appBarTitle; final Widget body; final Widget bottomSheet; @@ -60,11 +52,9 @@ class AppScaffold extends StatefulWidget { final bool isBottomBar; final Widget floatingActionButton; final bool isPharmacy; - final bool isMainPharmacyPages; final bool isOfferPackages; final bool showPharmacyCart; final bool showOfferPackagesCart; - final bool extendBody; final String title; final String description; final bool isShowDecPage; @@ -83,13 +73,12 @@ class AppScaffold extends StatefulWidget { List dropDownList; final Function(int) dropDownIndexChange; Function onTap; + final bool isMainPharmacyPages; + final bool extendBody; final ValueChanged changeCurrentTab; - - AuthenticatedUserObject authenticatedUserObject = locator(); - - final Widget customAppBar; final int currentTab; final bool isShowPharmacyAppbar; + final Widget customAppBar; AppScaffold setOnAppBarCartClick(VoidCallback onClick) { _onCartClick = onClick; @@ -103,17 +92,17 @@ class AppScaffold extends StatefulWidget { this.isShowAppBar = false, this.showNewAppBar = false, this.showNewAppBarTitle = false, + this.isMainPharmacyPages = false, + this.extendBody = false, this.hasAppBarParam, this.bottomSheet, this.bottomNavigationBar, this.baseViewModel, this.floatingActionButton, this.isPharmacy = false, - this.isMainPharmacyPages = false, this.showPharmacyCart = true, this.isOfferPackages = false, this.showOfferPackagesCart = false, - this.extendBody = false, this.title, this.description, this.isShowDecPage = true, @@ -145,9 +134,11 @@ class AppScaffold extends StatefulWidget { class _AppScaffoldState extends State { AuthenticatedUserObject authenticatedUserObject = locator(); + AppBarWidget appBar; @override void initState() { + // TODO: implement initState super.initState(); } @@ -218,66 +209,87 @@ class _AppScaffoldState extends State { @override Widget build(BuildContext context) { - PharmacyPagesViewModel pagesViewModel = Provider.of(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 - : (widget.isShowPharmacyAppbar + : widget.isShowPharmacyAppbar ? pharmacyAppbar() - : showNewAppBar + : (widget.showNewAppBar ? NewAppBarWidget( - title: appBarTitle, - showTitle: showNewAppBarTitle, - showDropDown: showDropDown, - dropdownIndexValue: dropdownIndexValue, - dropDownList: dropDownList ?? [], - dropDownIndexChange: dropDownIndexChange, - appBarIcons: appBarIcons, - onTap: onTap, + title: widget.appBarTitle, + showTitle: widget.showNewAppBarTitle, + showDropDown: widget.showDropDown, + dropdownIndexValue: widget.dropdownIndexValue, + dropDownList: widget.dropDownList ?? [], + dropDownIndexChange: widget.dropDownIndexChange, + appBarIcons: widget.appBarIcons, + onTap: widget.onTap, ) - : (isShowAppBar - ? customAppBar != null - ? customAppBar + : (widget.isShowAppBar + ? widget.customAppBar != null + ? widget.customAppBar : appBar = AppBarWidget( - appBarTitle: appBarTitle, - appBarIcons: appBarIcons, - showHomeAppBarIcon: showHomeAppBarIcon, - isPharmacy: isPharmacy, - showPharmacyCart: showPharmacyCart, - isOfferPackages: isOfferPackages, - showOfferPackagesCart: showOfferPackagesCart, - isShowDecPage: isShowDecPage, - backButtonTab: backButtonTab, + 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: bottomSheet, + 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(); @@ -304,7 +316,7 @@ class _AppScaffoldState extends State { } buildBodyWidget(context) { - return Stack(children: [body, isHelp == true ? RobotIcon() : Container()]); + return Stack(children: [widget.body, widget.isHelp == true ? RobotIcon() : Container()]); } } diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart index 01896117..105d7503 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart @@ -7,14 +7,10 @@ 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; - BottomNavPharmacyBar({Key key, this.changeIndex, this.index}) - : super(key: key); - @override _BottomNavPharmacyBarState createState() => _BottomNavPharmacyBarState(); } From 78fc77159c2b5fb3ec6d49ddcf2d270e8d4ed969 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Tue, 2 Nov 2021 10:39:06 +0300 Subject: [PATCH 10/70] fix lakum issues --- lib/config/config.dart | 8 ++-- lib/config/localized_values.dart | 13 +++++- .../service/parmacyModule/lacum-service.dart | 4 ++ .../screens/lacum-setting-page.dart | 4 +- .../pharmacies/screens/lakum-main-page.dart | 40 ++++++++++--------- .../screens/lakum-points-month-page.dart | 2 +- .../screens/lakum-points-year-page.dart | 11 ++--- .../screens/order-preview-page.dart | 2 +- .../widgets/lacum-banner-widget.dart | 12 +++--- lib/uitl/translations_delegate_base.dart | 22 ++++++++++ 10 files changed, 80 insertions(+), 38 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index bca5db17..65f602c5 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -19,12 +19,12 @@ const BASE_URL = 'https://uat.hmgwebservices.com/'; // const BASE_URL = 'https://hmgwebservices.com/'; // Pharmacy UAT URLs -// const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; -// const PHARMACY_BASE_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; + const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; + const PHARMACY_BASE_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; // // Pharmacy Production URLs -const BASE_PHARMACY_URL = 'https://mdlaboratories.com/exacartapi/api/'; -const PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapi/api/'; +// const BASE_PHARMACY_URL = 'https://mdlaboratories.com/exacartapi/api/'; +// const PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapi/api/'; const PING_SERVICE = 'Services/Weather.svc/REST/CheckConnectivity'; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index ba89e77a..1e347bf8 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -490,6 +490,8 @@ const Map localizedValues = { "noLocationAvailable": {"en": "No Location Available", "ar": "لا يوجد موقع"}, "orders": {"en": "Orders", "ar": "الطلبات"}, "lakum": {"en": "Lakum", "ar": "برنامج لكم"}, + "lakumMsg": {"en": "No Details of Points Are There", "ar": " لاتوجد تفاصيل عن النقاط"}, + "lakumPoint": {"en": "Point", "ar": "نقطه"}, "wishlist": {"en": "Wishlist", "ar": "المفضلة"}, "products": {"en": "Products", "ar": "المنتجات"}, "reviews": {"en": "Reviews", "ar": "التقيمات"}, @@ -606,10 +608,19 @@ const Map localizedValues = { "gained": {"en": "GAINED", "ar": "المكتسب"}, "consumed": {"en": "Consumed", "ar": "المستهلك"}, "transferred": {"en": "TRANSFERRED", "ar": "المحول"}, + "RIYAL": {"en": "RIYAL", "ar": "ريال"}, + "MEMBERSINCE": {"en": "MEMBER SINCE", "ar": "تاريخ العضوية"}, + "IDENTIFICATION": {"en": "IDENTIFICATION", "ar": "رقم الهوية"}, + "lakumMobile": {"en": "lakum Mobile", "ar": "رقم الجوال"}, + "Waitinggained": {"en": "Waiting gained", "ar": " بأنتظار التفعيل"}, + "Expired": {"en": "Expired", "ar": "منتهية الصلاحيه"}, + "WillBeExpired": {"en": "Will Be Expired", "ar": "ستنتهي صلاحيتها"}, + "LakumPoint": {"en": "Lakum Points", "ar": "نقاط لكم"}, + "ActivateLAKUMAccount": {"en": "Activate LAKUM Account", "ar": "تفعيل لكم"}, "checkBeneficiary": {"en": "CHECK BENEFICIARY", "ar": "تحقق من المستفيد"}, "beneficiaryName": {"en": "Beneficiary Name", "ar": "اسم المستفيد"}, "accountActivation": {"en": "Account Activation", "ar": "تفعيل الحساب"}, - "lakumTransfer": {"en": "Lakum Transfer", "ar": "تفعيل الحساب"}, + "lakumTransfer": {"en": "Lakum Transfer", "ar": "تحويل نقاط لكم"}, "acceptLbl": {"en": "Accept", "ar": "موافقة"}, "select-gender": {"en": "Select Gender", "ar": "اختر الجنس"}, "i-am-a": {"en": "I am a ...", "ar": "أنا ..."}, diff --git a/lib/core/service/parmacyModule/lacum-service.dart b/lib/core/service/parmacyModule/lacum-service.dart index c7117303..122bafd6 100644 --- a/lib/core/service/parmacyModule/lacum-service.dart +++ b/lib/core/service/parmacyModule/lacum-service.dart @@ -23,6 +23,8 @@ class LacumService extends BaseService{ await baseAppClient.post(GET_LACUM_ACCOUNT_INFORMATION, onSuccess: (response, statusCode) async { lacumInformation = LacumAccountInformation.fromJson(response); + print("Test Lacum Account Information"); + print(response); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; @@ -45,6 +47,8 @@ class LacumService extends BaseService{ await baseAppClient.post(GET_LACUM_GROUP_INFORMATION, onSuccess: (response, statusCode) async { lacumGroupInformation = LacumAccountInformation.fromJson(response); + print("Test Lacum Group Information"); + print(response); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; diff --git a/lib/pages/pharmacies/screens/lacum-setting-page.dart b/lib/pages/pharmacies/screens/lacum-setting-page.dart index 4f7f5fd6..7c402402 100644 --- a/lib/pages/pharmacies/screens/lacum-setting-page.dart +++ b/lib/pages/pharmacies/screens/lacum-setting-page.dart @@ -112,8 +112,8 @@ class _LakumSettingPageState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Texts( - "Activate LAKUM Account", + Texts(TranslationBase.of(context).ActivateLAKUMAccount, +// "Activate LAKUM Account", fontSize: 16, fontWeight: FontWeight.normal, color: Colors.black, diff --git a/lib/pages/pharmacies/screens/lakum-main-page.dart b/lib/pages/pharmacies/screens/lakum-main-page.dart index 23adf2f6..c688f319 100644 --- a/lib/pages/pharmacies/screens/lakum-main-page.dart +++ b/lib/pages/pharmacies/screens/lakum-main-page.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/pages/pharmacies/screens/lacum-setting-page import 'package:diplomaticquarterapp/pages/pharmacies/screens/lacum-transfer-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/lakum-points-year-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/lacum-banner-widget.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.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'; @@ -47,7 +48,7 @@ class LakumMainPage extends StatelessWidget { Column( children: [ SizedBox( - height: mediaQuery.size.height * 0.05, + height: mediaQuery.size.height * 0.02, ), Container( width: mediaQuery.size.width * 1, @@ -65,7 +66,7 @@ class LakumMainPage extends StatelessWidget { height: 20, ), Container( - height: 100, + height: 125, margin: EdgeInsets.symmetric(horizontal: 16), child: ListView( scrollDirection: Axis.horizontal, @@ -174,15 +175,15 @@ class LakumMainPage extends StatelessWidget { Padding( padding: EdgeInsets.symmetric(horizontal: 8), - child: Texts( - "Expired", + child: Texts(TranslationBase.of(context).Expired, +// "Expired", fontSize: 14, ), ) ], ), Texts( - "${model.lacumGroupInformation.lakumInquiryInformationObjVersion.expiredPoints} Points", + "${model.lacumGroupInformation.lakumInquiryInformationObjVersion.expiredPoints}${TranslationBase.of(context).lakumPoint} " , fontWeight: FontWeight.bold, fontSize: 14, ), @@ -214,15 +215,15 @@ class LakumMainPage extends StatelessWidget { Padding( padding: EdgeInsets.symmetric(horizontal: 8), - child: Texts( - "Waiting gained", + child: Texts(TranslationBase.of(context).Waitinggained, +// "Waiting gained", fontSize: 14, ), ) ], ), Texts( - "${model.lacumGroupInformation.lakumInquiryInformationObjVersion.waitingPoints} Points", + "${model.lacumGroupInformation.lakumInquiryInformationObjVersion.waitingPoints} ${TranslationBase.of(context).lakumPoint}", fontWeight: FontWeight.bold, fontSize: 14, ), @@ -254,15 +255,15 @@ class LakumMainPage extends StatelessWidget { Padding( padding: EdgeInsets.symmetric(horizontal: 8), - child: Texts( - "Will Be Expired", + child: Texts(TranslationBase.of(context).WillBeExpired, +// "Will Be Expired", fontSize: 14, ), ) ], ), Texts( - "${model.lacumGroupInformation.lakumInquiryInformationObjVersion.pointsWillBeExpired} Points", + "${model.lacumGroupInformation.lakumInquiryInformationObjVersion.pointsWillBeExpired} ${TranslationBase.of(context).lakumPoint}", fontWeight: FontWeight.bold, fontSize: 14, ), @@ -441,13 +442,16 @@ class LacumPointsWidget extends StatelessWidget { Navigator.push(context, FadePage(page: LakumPointsYearPage(pointsAmountPerYear))); } else { + AppToast.showErrorToast( + message: TranslationBase.of(context) + .lakumMsg); // show snackBar No Details Points are there } } }, child: Container( - width: mediaQuery.size.width / 2 - 16, - padding: EdgeInsets.only(top: 12, left: 8, right: 8, bottom: 4), + width: mediaQuery.size.width / 2 - 25, + padding: EdgeInsets.only(top: 12, left: 8, right: 8, bottom: 2), decoration: BoxDecoration( shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(8), @@ -493,8 +497,8 @@ class LacumPointsWidget extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts( - "RIYAL", + Texts(TranslationBase.of(context).RIYAL, +// "RIYAL", fontSize: 13, fontWeight: FontWeight.bold, color: pointType == 1 ? Colors.white : Colors.black, @@ -520,12 +524,12 @@ class LacumPointsWidget extends StatelessWidget { ), Expanded( child: Container( - margin: EdgeInsets.only(left: 4), + margin: EdgeInsets.only(left: 8, right: 8), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts( - "POINT", + Texts(TranslationBase.of(context).point, +// "POINT", fontSize: 12, fontWeight: FontWeight.bold, color: pointType == 1 ? Colors.white : Colors.black, diff --git a/lib/pages/pharmacies/screens/lakum-points-month-page.dart b/lib/pages/pharmacies/screens/lakum-points-month-page.dart index 47270eee..26c88755 100644 --- a/lib/pages/pharmacies/screens/lakum-points-month-page.dart +++ b/lib/pages/pharmacies/screens/lakum-points-month-page.dart @@ -26,7 +26,7 @@ class _LakumPointsMonthPageState extends State { return BaseView( builder: (_, model, wi) => AppScaffold( - title: "Lakum points", + title: TranslationBase.of(context).LakumPoint, isShowAppBar: true, isShowDecPage: false, backgroundColor: Colors.white, diff --git a/lib/pages/pharmacies/screens/lakum-points-year-page.dart b/lib/pages/pharmacies/screens/lakum-points-year-page.dart index f7b6d9e6..323f1a91 100644 --- a/lib/pages/pharmacies/screens/lakum-points-year-page.dart +++ b/lib/pages/pharmacies/screens/lakum-points-year-page.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PointsAmountPerYear.d import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/lacum-viewmodel.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/lakum-point-table-row-widget.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'; @@ -26,7 +27,7 @@ class _LakumPointsYearPageState extends State { return BaseView( builder: (_, model, wi) => AppScaffold( - title: "Lakum points", + title: TranslationBase.of(context).LakumPoint, isShowAppBar: true, isShowDecPage: false, backgroundColor: Colors.white, @@ -143,8 +144,8 @@ class LacumPointsYearWidget extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts( - "POINT", + Texts(TranslationBase.of(context).point, +// "POINT", fontSize: 12, fontWeight: FontWeight.bold, color: isSelected ? Colors.white : Colors.black, @@ -172,8 +173,8 @@ class LacumPointsYearWidget extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Texts( - "RIYAL", + Texts(TranslationBase.of(context).RIYAL, +// "RIYAL", fontSize: 13, fontWeight: FontWeight.bold, color: isSelected ? Colors.white : Colors.black, diff --git a/lib/pages/pharmacies/screens/order-preview-page.dart b/lib/pages/pharmacies/screens/order-preview-page.dart index d9646fcf..6b5f4f51 100644 --- a/lib/pages/pharmacies/screens/order-preview-page.dart +++ b/lib/pages/pharmacies/screens/order-preview-page.dart @@ -10,7 +10,7 @@ class OrderPreviewPage extends StatelessWidget { Widget build(BuildContext context) { return BaseView( builder: (_, model, wi) => AppScaffold( - title: "Shopping Cart", + title: TranslationBase.of(context).shoppingCart, isShowAppBar: true, isShowDecPage: false, baseViewModel: model, diff --git a/lib/pages/pharmacies/widgets/lacum-banner-widget.dart b/lib/pages/pharmacies/widgets/lacum-banner-widget.dart index 14a53e72..a15b385d 100644 --- a/lib/pages/pharmacies/widgets/lacum-banner-widget.dart +++ b/lib/pages/pharmacies/widgets/lacum-banner-widget.dart @@ -125,8 +125,8 @@ class _LakumBannerWidgetState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts( - "IDENTIFICATION #", + Texts(TranslationBase.of(context).IDENTIFICATION, +// "IDENTIFICATION #", fontSize: 14, fontWeight: FontWeight.bold, color: Colors.black, @@ -143,8 +143,8 @@ class _LakumBannerWidgetState extends State { Column( crossAxisAlignment: CrossAxisAlignment.end, children: [ - Texts( - "MEMBER SINCE", + Texts(TranslationBase.of(context).MEMBERSINCE, +// "MEMBER SINCE", fontSize: 14, fontWeight: FontWeight.bold, color: Colors.black, @@ -168,8 +168,8 @@ class _LakumBannerWidgetState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts( - "MOBILE #", + Texts(TranslationBase.of(context).lakumMobile, +// "MOBILE #", fontSize: 14, fontWeight: FontWeight.bold, color: Colors.black, diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 6efa2283..32fa6f66 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -941,6 +941,28 @@ class TranslationBase { String get lakum => localizedValues['lakum'][locale.languageCode]; + String get lakumMsg => localizedValues['lakumMsg'][locale.languageCode]; + + String get lakumPoint => localizedValues['lakumPoint'][locale.languageCode]; + + String get MEMBERSINCE => localizedValues['MEMBERSINCE'][locale.languageCode]; + + String get IDENTIFICATION => localizedValues['IDENTIFICATION'][locale.languageCode]; + + String get lakumMobile => localizedValues['lakumMobile'][locale.languageCode]; + + String get Waitinggained => localizedValues['Waitinggained'][locale.languageCode]; + + String get Expired => localizedValues['Expired'][locale.languageCode]; + + String get WillBeExpired => localizedValues['WillBeExpired'][locale.languageCode]; + + String get RIYAL => localizedValues['RIYAL'][locale.languageCode]; + + String get LakumPoint => localizedValues['LakumPoint'][locale.languageCode]; + + String get ActivateLAKUMAccount => localizedValues['ActivateLAKUMAccount'][locale.languageCode]; + String get wishlist => localizedValues['wishlist'][locale.languageCode]; String get brands => localizedValues['brands'][locale.languageCode]; From 5943522163e2c5f9bd3165b89997299b0d11ed86 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 2 Nov 2021 12:58:54 +0300 Subject: [PATCH 11/70] UI fixes --- lib/pages/Blood/blood_donation.dart | 39 ++- .../widgets/home/PrescriptionsWidget.dart | 248 +++++++++--------- .../pharmacy/bottom_nav_pharmacy_item.dart | 2 +- 3 files changed, 135 insertions(+), 154 deletions(-) diff --git a/lib/pages/Blood/blood_donation.dart b/lib/pages/Blood/blood_donation.dart index e0c6bfe7..db96a5a1 100644 --- a/lib/pages/Blood/blood_donation.dart +++ b/lib/pages/Blood/blood_donation.dart @@ -38,9 +38,6 @@ class _BloodDonationPageState extends State { TextEditingController _notesTextController = TextEditingController(); BeneficiaryType beneficiaryType = BeneficiaryType.NON; - // Gender gender = Gender.Male; //Gender.NON; - // Blood blood = Blood.Aminus; //Blood.NON; - //HospitalsModel _selectedHospital; CitiesModel _selectedHospital; int _selectedHospitalIndex = 0; @@ -80,7 +77,6 @@ class _BloodDonationPageState extends State { cityID = element.iD; } }); - return cityID; } @@ -90,20 +86,22 @@ class _BloodDonationPageState extends State { return BaseView( onModelReady: (model) { - model.getCities().then((value) { - model.getBlood().then((value) { - if (model.bloodModelList.length > 0) { - CitiesModel citiesModel = new CitiesModel(); - citiesModel.iD = getSelectedCityID(model); - _selectedHospitalIndex = (citiesModel.iD - 1); - citiesModel.description = model.CitiesModelList[_selectedHospitalIndex].description; - citiesModel.descriptionN = model.CitiesModelList[_selectedHospitalIndex].descriptionN; - _selectedHospital = citiesModel; - } else { - _selectedHospital = model.CitiesModelList[0]; - } + if (projectProvider.isLogin) { + model.getCities().then((value) { + model.getBlood().then((value) { + if (model.bloodModelList.length > 0) { + CitiesModel citiesModel = new CitiesModel(); + citiesModel.iD = getSelectedCityID(model); + _selectedHospitalIndex = (citiesModel.iD - 1); + citiesModel.description = model.CitiesModelList[_selectedHospitalIndex].description; + citiesModel.descriptionN = model.CitiesModelList[_selectedHospitalIndex].descriptionN; + _selectedHospital = citiesModel; + } else { + _selectedHospital = model.CitiesModelList[0]; + } + }); }); - }); + } }, builder: (_, model, w) => AppScaffold( isShowAppBar: true, @@ -130,12 +128,7 @@ class _BloodDonationPageState extends State { ), SizedBox(height: 12), if (projectProvider.isLogin && model.state != ViewState.Busy) - CommonDropDownView( - TranslationBase.of(context).city, - // (model.bloodModelList.isNotEmpty && model.CitiesModelList.isNotEmpty) - // ? model.bloodModelList[0].city - // : - projectProvider.isArabic ? _selectedHospital.descriptionN : _selectedHospital.description, () { + CommonDropDownView(TranslationBase.of(context).city, projectProvider.isArabic ? _selectedHospital.descriptionN : _selectedHospital.description, () { List list = [ for (int i = 0; i < model.CitiesModelList.length; i++) RadioSelectionDialogModel(projectProvider.isArabic ? model.CitiesModelList[i].descriptionN : model.CitiesModelList[i].description, i), diff --git a/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart index fabab916..ab278984 100644 --- a/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart +++ b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart @@ -13,9 +13,7 @@ import 'package:provider/provider.dart'; import 'package:rating_bar/rating_bar.dart'; class PrescriptionsWidget extends StatelessWidget { - - AuthenticatedUserObject authenticatedUserObject = - locator(); + AuthenticatedUserObject authenticatedUserObject = locator(); @override Widget build(BuildContext context) { @@ -36,157 +34,147 @@ 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.18, + height: MediaQuery.of(context).size.height * 0.2, child: ListView.builder( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - physics: ScrollPhysics(), - itemCount: model.prescriptionsList.length, - itemBuilder: (context, index) { - return Container( - padding: EdgeInsets.only(left: 8.0, right: 8.0), - margin: EdgeInsets.only(right: 5.0, left: 5.0), - decoration: BoxDecoration( - border: Border.all( - color: Colors.grey, - style: BorderStyle.solid, - width: 1.0, + scrollDirection: Axis.horizontal, + shrinkWrap: true, + physics: ScrollPhysics(), + itemCount: model.prescriptionsList.length, + itemBuilder: (context, index) { + return Container( + padding: EdgeInsets.only(left: 8.0, right: 8.0), + margin: EdgeInsets.only(right: 5.0, left: 5.0), + decoration: BoxDecoration( + border: Border.all( + color: Colors.grey, + style: BorderStyle.solid, + width: 1.0, + ), + color: Colors.white, + borderRadius: BorderRadius.circular(10.0)), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Row( + children: [ + Container( + padding: EdgeInsets.only( + top: 10.0, + left: 10.0, + right: 10.0, + bottom: 10.0, + ), + child: CircleAvatar( + radius: 30, + backgroundColor: Colors.transparent, + child: Image.network( + model.prescriptionsList[index].doctorImageURL, + width: 50, + height: 50, + ), + ), ), - color: Colors.white, - borderRadius: BorderRadius.circular(10.0)), - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - children: [ - Column(children: [ + Column( + children: [ Container( - padding: EdgeInsets.only( - top: 10.0, - left: 10.0, - right: 10.0, - bottom: 10.0, - ), - child: CircleAvatar( - radius: 30, - backgroundColor: Colors.transparent, - child: Image.network( - model.prescriptionsList[index].doctorImageURL, - width: 60, - height: 60, - ), - ), - ), - ]), - Column( - children: [ - Container( - margin: EdgeInsets.only(left: 1), - padding: EdgeInsets.only(left: 15.0, right: 15.0), - decoration: BoxDecoration( - border: Border.all( - color: Colors.green, - style: BorderStyle.solid, - width: 3.0, - ), + padding: EdgeInsets.only(left: 15.0, right: 15.0), + decoration: BoxDecoration( + border: Border.all( color: Colors.green, - borderRadius: BorderRadius.circular(30.0)), - child: Text( - model.languageID == "ar" - ? model.prescriptionsList[index].isInOutPatientDescriptionN.toString() - : model.prescriptionsList[index].isInOutPatientDescription.toString(), - style: TextStyle( - color: Colors.white, - fontSize: 15.0, + style: BorderStyle.solid, + width: 3.0, ), - )), - Row(children: [ - Image.asset( - 'assets/images/Icon-awesome-calendar.png', - width: 30, - height: 30, - ), - Text( - DateUtil.convertStringToDate(model.prescriptionsList[index].appointmentDate.toString()).toString().substring(0, 10), + color: Colors.green, + borderRadius: BorderRadius.circular(30.0)), + child: Text( + model.languageID == "ar" + ? model.prescriptionsList[index].isInOutPatientDescriptionN.toString() + : model.prescriptionsList[index].isInOutPatientDescription.toString(), style: TextStyle( - color: Colors.black, + color: Colors.white, fontSize: 15.0, ), - ) - ]), - ], - ), - ], - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(left: 5), - child: Row(children: [ - Text( - model.prescriptionsList[index].doctorTitle.toString(), - style: TextStyle( - color: Colors.black, - fontSize: 15.0, - fontWeight: FontWeight.bold, - ), + )), + Row(children: [ + Image.asset( + 'assets/images/Icon-awesome-calendar.png', + width: 30, + height: 30, ), Text( - model.prescriptionsList[index].doctorName.toString(), + DateUtil.convertStringToDate(model.prescriptionsList[index].appointmentDate.toString()).toString().substring(0, 10), style: TextStyle( color: Colors.black, fontSize: 15.0, - fontWeight: FontWeight.bold, ), - ), + ) ]), + ], + ), + ], + ), + Container( + margin: EdgeInsets.only(left: 5), + child: Row(children: [ + Text( + model.prescriptionsList[index].doctorTitle.toString(), + style: TextStyle( + color: Colors.black, + fontSize: 15.0, + fontWeight: FontWeight.bold, ), - ], - ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(left: 5), - child: Text( - model.prescriptionsList[index].clinicDescription.toString(), - style: TextStyle( - color: Colors.green, - fontSize: 15.0, -// fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - Row(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - margin: EdgeInsets.only(left: 5), - child: Align( - alignment: Alignment.topLeft, - child: RatingBar.readOnly( - initialRating: model.prescriptionsList[index].actualDoctorRate.toDouble(), -// initialRating: productRate, - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, - ), + ), + Text( + model.prescriptionsList[index].doctorName.toString(), + style: TextStyle( + color: Colors.black, + fontSize: 15.0, + fontWeight: FontWeight.bold, ), - ) + ), ]), + ), + Container( + margin: EdgeInsets.only(left: 5), + child: Text( + model.prescriptionsList[index].clinicDescription.toString(), + style: TextStyle( + color: Colors.green, + fontSize: 15.0, + ), + ), + ), + Row(children: [ + Container( + margin: EdgeInsets.only(left: 5), + child: RatingBar.readOnly( + initialRating: model.prescriptionsList[index].actualDoctorRate.toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), + ), + SizedBox( + width: 100.0, + ), + Container( + child: Icon( + Icons.arrow_forward, + color: Theme.of(context).primaryColor, + )), ]), - ); - }), + ]), + ); + }, + ), ), ], ), ), ) - : Container( - ), + : Container(), ); } } diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart index 6e6a5f53..9731f2b1 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart @@ -96,7 +96,7 @@ class BottomNavPharmacyItem extends StatelessWidget { fontWeight: currentIndex == index ? FontWeight.normal : FontWeight.w400, - fontSize: currentIndex == index ? 13 : 11, + fontSize: currentIndex == index ? 11 : 9, ), ], ), From be771917f0971a76355b39e22b2b887866df2863 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 2 Nov 2021 14:41:12 +0300 Subject: [PATCH 12/70] pharmacy fixes --- lib/config/localized_values.dart | 1 + lib/core/model/pharmacies/Prescriptions.dart | 157 ---- .../parmacyModule/prescription_service.dart | 7 +- .../pharmacyModule/OrderPreviewViewModel.dart | 35 +- .../pharmacyModule/PrescriptionViewModel.dart | 3 +- lib/models/pharmacy/locationModel.dart | 6 +- lib/pages/final_products_page.dart | 9 +- lib/pages/parent_categorise_page.dart | 689 +++++------------- .../screens/cart-page/cart-order-page.dart | 2 +- .../screens/cart-page/cart-order-preview.dart | 22 +- .../cart-page/select_address_widget.dart | 45 +- .../pharmacies/screens/lakum-main-page.dart | 208 ++---- .../screens/lakum-points-year-page.dart | 2 +- .../screens/pharmacy_module_page.dart | 4 +- .../product-details/availability_info.dart | 119 ++- .../product-details/footor/footer-widget.dart | 15 +- .../product-details/product-detail.dart | 2 + .../widgets/home/PrescriptionsWidget.dart | 234 +++--- .../widgets/lacum-banner-widget.dart | 2 +- lib/pages/sub_categorise_page.dart | 633 +++++----------- lib/routes.dart | 8 +- lib/uitl/translations_delegate_base.dart | 2 + lib/widgets/others/app_scaffold_widget.dart | 4 +- 23 files changed, 653 insertions(+), 1556 deletions(-) delete mode 100644 lib/core/model/pharmacies/Prescriptions.dart diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 7823bf57..207a65d7 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1625,4 +1625,5 @@ const Map localizedValues = { "bodyFatTitle": {"en": "Body Fat", "ar": " الدهون في الجسم"}, "cholesTitle": {"en": "Blood Cholesterol", "ar": " الكولسترول في الدم"}, "laserClinic": {"en": "Laser Clinic", "ar": "عيادة الليزر"}, + "noImage": {"en": "No Image", "ar": "لا توجد صورة"}, }; diff --git a/lib/core/model/pharmacies/Prescriptions.dart b/lib/core/model/pharmacies/Prescriptions.dart deleted file mode 100644 index 80caff0a..00000000 --- a/lib/core/model/pharmacies/Prescriptions.dart +++ /dev/null @@ -1,157 +0,0 @@ - - -import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; - -class Prescriptions { - String setupID; - int projectID; - int patientID; - int appointmentNo; - String appointmentDate; - String doctorName; - String clinicDescription; - String name; - int episodeID; - int actualDoctorRate; - int admission; - int clinicID; - String companyName; - String despensedStatus; - DateTime dischargeDate; - int dischargeNo; - int doctorID; - String doctorImageURL; - int doctorRate; - String doctorTitle; - int gender; - String genderDescription; - bool isActiveDoctorProfile; - bool isDoctorAllowVedioCall; - bool isExecludeDoctor; - bool isInOutPatient; - String isInOutPatientDescription; - String isInOutPatientDescriptionN; - bool isInsurancePatient; - String nationalityFlagURL; - int noOfPatientsRate; - String qR; - List speciality; - - Prescriptions( - {this.setupID, - this.projectID, - this.patientID, - this.appointmentNo, - this.appointmentDate, - this.doctorName, - this.clinicDescription, - this.name, - this.episodeID, - this.actualDoctorRate, - this.admission, - this.clinicID, - this.companyName, - this.despensedStatus, - this.dischargeDate, - this.dischargeNo, - this.doctorID, - this.doctorImageURL, - this.doctorRate, - this.doctorTitle, - this.gender, - this.genderDescription, - this.isActiveDoctorProfile, - this.isDoctorAllowVedioCall, - this.isExecludeDoctor, - this.isInOutPatient, - this.isInOutPatientDescription, - this.isInOutPatientDescriptionN, - this.isInsurancePatient, - this.nationalityFlagURL, - this.noOfPatientsRate, - this.qR, - this.speciality}); - - Prescriptions.fromJson(Map json) { - setupID = json['SetupID']; - projectID = json['ProjectID']; - patientID = json['PatientID']; - appointmentNo = json['AppointmentNo']; - appointmentDate = json['AppointmentDate']; - doctorName = json['DoctorName']; - clinicDescription = json['ClinicDescription']; - name = json['Name']; - episodeID = json['EpisodeID']; - actualDoctorRate = json['ActualDoctorRate']; - admission = json['Admission']; - clinicID = json['ClinicID']; - companyName = json['CompanyName']; - despensedStatus = json['Despensed_Status']; - dischargeDate = DateUtil.convertStringToDate(json['DischargeDate']); - dischargeNo = json['DischargeNo']; - doctorID = json['DoctorID']; - doctorImageURL = json['DoctorImageURL']; - doctorRate = json['DoctorRate']; - doctorTitle = json['DoctorTitle']; - gender = json['Gender']; - genderDescription = json['GenderDescription']; - isActiveDoctorProfile = json['IsActiveDoctorProfile']; - isDoctorAllowVedioCall = json['IsDoctorAllowVedioCall']; - isExecludeDoctor = json['IsExecludeDoctor']; - isInOutPatient = json['IsInOutPatient']; - isInOutPatientDescription = json['IsInOutPatientDescription']; - isInOutPatientDescriptionN = json['IsInOutPatientDescriptionN']; - isInsurancePatient = json['IsInsurancePatient']; - nationalityFlagURL = json['NationalityFlagURL']; - noOfPatientsRate = json['NoOfPatientsRate']; - qR = json['QR']; - // speciality = json['Speciality'].cast(); - } - - Map toJson() { - final Map data = new Map(); - data['SetupID'] = this.setupID; - data['ProjectID'] = this.projectID; - data['PatientID'] = this.patientID; - data['AppointmentNo'] = this.appointmentNo; - data['AppointmentDate'] = this.appointmentDate; - data['DoctorName'] = this.doctorName; - data['ClinicDescription'] = this.clinicDescription; - data['Name'] = this.name; - data['EpisodeID'] = this.episodeID; - data['ActualDoctorRate'] = this.actualDoctorRate; - data['Admission'] = this.admission; - data['ClinicID'] = this.clinicID; - data['CompanyName'] = this.companyName; - data['Despensed_Status'] = this.despensedStatus; - data['DischargeDate'] = this.dischargeDate; - data['DischargeNo'] = this.dischargeNo; - data['DoctorID'] = this.doctorID; - data['DoctorImageURL'] = this.doctorImageURL; - data['DoctorRate'] = this.doctorRate; - data['DoctorTitle'] = this.doctorTitle; - data['Gender'] = this.gender; - data['GenderDescription'] = this.genderDescription; - data['IsActiveDoctorProfile'] = this.isActiveDoctorProfile; - data['IsDoctorAllowVedioCall'] = this.isDoctorAllowVedioCall; - data['IsExecludeDoctor'] = this.isExecludeDoctor; - data['IsInOutPatient'] = this.isInOutPatient; - data['IsInOutPatientDescription'] = this.isInOutPatientDescription; - data['IsInOutPatientDescriptionN'] = this.isInOutPatientDescriptionN; - data['IsInsurancePatient'] = this.isInsurancePatient; - data['NationalityFlagURL'] = this.nationalityFlagURL; - data['NoOfPatientsRate'] = this.noOfPatientsRate; - data['QR'] = this.qR; - data['Speciality'] = this.speciality; - return data; - } -} - -//class PrescriptionsList { -// String filterName = ""; -// List prescriptionsList = List(); -// -// PrescriptionsList({this.filterName, Prescriptions prescriptions}) { -// prescriptionsList.add(prescriptions); -// } -//} diff --git a/lib/core/service/parmacyModule/prescription_service.dart b/lib/core/service/parmacyModule/prescription_service.dart index 9011496c..9a77b7bc 100644 --- a/lib/core/service/parmacyModule/prescription_service.dart +++ b/lib/core/service/parmacyModule/prescription_service.dart @@ -1,8 +1,7 @@ import 'package:diplomaticquarterapp/config/config.dart'; -import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/core/model/prescriptions/Prescriptions.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/Prescriptions.dart'; class PrescriptionService extends BaseService { final AppSharedPreferences sharedPref = AppSharedPreferences(); @@ -11,14 +10,14 @@ class PrescriptionService extends BaseService { String errorMsg = ''; List _prescriptionsList = List(); + List get prescriptionsList => _prescriptionsList; Future getPrescription() async { hasError = false; Map body = Map(); body['isDentalAllowedBackend'] = false; - await baseAppClient.post(PRESCRIPTION, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(PRESCRIPTION, onSuccess: (dynamic response, int statusCode) { _prescriptionsList.clear(); response['PatientPrescriptionList'].forEach((prescriptions) { _prescriptionsList.add(Prescriptions.fromJson(prescriptions)); diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index d3f09119..d498d095 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -8,8 +8,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; import 'package:diplomaticquarterapp/core/service/parmacyModule/order-preview-service.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; -import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; -import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import '../../../locator.dart'; import '../base_view_model.dart'; @@ -19,19 +17,17 @@ class OrderPreviewViewModel extends BaseViewModel { List get addresses => _orderService.addresses; - LacumAccountInformation get lacumInformation => - _orderService.lacumInformation; + LacumAccountInformation get lacumInformation => _orderService.lacumInformation; List get orderListModel => _orderService.orderList; - PharmacyModuleViewModel pharmacyModuleViewModel = - locator(); + PharmacyModuleViewModel pharmacyModuleViewModel = locator(); ShoppingCartResponse cartResponse = ShoppingCartResponse(); PaymentCheckoutData paymentCheckoutData = PaymentCheckoutData(); double totalAdditionalShippingCharge = 0; - setShoppingCartResponse(ShoppingCartResponse cart){ + setShoppingCartResponse(ShoppingCartResponse cart) { cartResponse = cart; notifyListeners(); } @@ -71,8 +67,7 @@ class OrderPreviewViewModel extends BaseViewModel { } } - Future changeProductQuantity( - ShoppingCart product) async { + Future changeProductQuantity(ShoppingCart product) async { setState(ViewState.Busy); var resp = await _orderService.changeProductQuantity(product.id, product); var object = _handleGetShoppingCartResponse(resp); @@ -125,11 +120,17 @@ class OrderPreviewViewModel extends BaseViewModel { cartResponse.subtotalVatAmount = res["subtotal_vat_amount"]; cartResponse.subtotalVatRate = res["subtotal_vat_rate"]; cartResponse.shoppingCarts = List(); + + if (paymentCheckoutData.shippingOption != null) { + totalAdditionalShippingCharge = paymentCheckoutData.shippingOption.rate; + cartResponse.subtotalVatAmount += paymentCheckoutData.shippingOption.rateVat; + cartResponse.subtotal += paymentCheckoutData.shippingOption.rate + paymentCheckoutData.shippingOption.rateVat; + } + res["shopping_carts"].forEach((item) { ShoppingCart shoppingCart = ShoppingCart.fromJson(item); cartResponse.shoppingCarts.add(shoppingCart); - totalAdditionalShippingCharge += - shoppingCart.product.additionalShippingCharge; + totalAdditionalShippingCharge += shoppingCart.product.additionalShippingCharge; }); return cartResponse; } @@ -173,7 +174,7 @@ class OrderPreviewViewModel extends BaseViewModel { error = _orderService.error; setState(ViewState.Error); } else { - getLacumGroupData(identificationNo); + if (_orderService.lacumInformation.yahalaAccountNo != 0) getLacumGroupData(identificationNo); } } @@ -181,8 +182,7 @@ class OrderPreviewViewModel extends BaseViewModel { setState(ViewState.Busy); await _orderService.getLacumGroupInformation(identificationNo); paymentCheckoutData.lacumInformation = _orderService.lacumGroupInformation; - paymentCheckoutData.usedLakumPoints = paymentCheckoutData - .lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount; + paymentCheckoutData.usedLakumPoints = paymentCheckoutData.lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount; if (_orderService.hasError) { error = _orderService.error; setState(ViewState.Error); @@ -193,9 +193,7 @@ class OrderPreviewViewModel extends BaseViewModel { getShippingOption() async { setState(ViewState.Busy); - await _orderService - .getShippingOption(paymentCheckoutData.address) - .then((res) { + await _orderService.getShippingOption(paymentCheckoutData.address).then((res) { paymentCheckoutData.shippingOption = ShippingOption.fromJson(res); setState(ViewState.Idle); }); @@ -211,8 +209,7 @@ class OrderPreviewViewModel extends BaseViewModel { setState(ViewState.Busy); await pharmacyModuleViewModel.generatePharmacyToken(); - await _orderService.makeOrder( - paymentCheckoutData, cartResponse.shoppingCarts); + await _orderService.makeOrder(paymentCheckoutData, cartResponse.shoppingCarts); if (_orderService.hasError) { error = _orderService.error; setState(ViewState.ErrorLocal); diff --git a/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart b/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart index 420ec1fa..ba71781f 100644 --- a/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart @@ -1,5 +1,5 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/Prescriptions.dart'; +import 'package:diplomaticquarterapp/core/model/prescriptions/Prescriptions.dart'; import 'package:diplomaticquarterapp/core/service/parmacyModule/prescription_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; @@ -14,6 +14,7 @@ class PrescriptionViewModel extends BaseViewModel { getPrescription() async { await getSavedLanguage(); + prescriptionsList.clear(); if(prescriptionsList.isEmpty){ setState(ViewState.Busy); await _prescriptionService.getPrescription(); diff --git a/lib/models/pharmacy/locationModel.dart b/lib/models/pharmacy/locationModel.dart index 36ee7350..02d67a09 100644 --- a/lib/models/pharmacy/locationModel.dart +++ b/lib/models/pharmacy/locationModel.dart @@ -52,7 +52,7 @@ class LocationModel { int barcode; dynamic companybarcode; int cityId; - CityName cityName; + String cityName; int distanceInKilometers; String latitude; int locationType; @@ -78,7 +78,7 @@ class LocationModel { barcode: json["Barcode"], companybarcode: json["Companybarcode"], cityId: json["CityID"], - cityName: cityNameValues.map[json["CityName"]], + cityName: json["CityName"], distanceInKilometers: json["DistanceInKilometers"], latitude: json["Latitude"], locationType: json["LocationType"], @@ -105,7 +105,7 @@ class LocationModel { "Barcode": barcode, "Companybarcode": companybarcode, "CityID": cityId, - "CityName": cityNameValues.reverse[cityName], + "CityName": cityName, "DistanceInKilometers": distanceInKilometers, "Latitude": latitude, "LocationType": locationType, diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 51f8c8db..5705f726 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_mo 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/theme/colors.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'; @@ -123,7 +124,7 @@ class _FinalProductsPageState extends State { styleTwo = true; styleIcon = Icon( Icons.auto_awesome_mosaic, - color: Colors.blue, + color: CustomColors.green, size: 29.0, ); } else { @@ -131,7 +132,7 @@ class _FinalProductsPageState extends State { styleTwo = false; styleIcon = Icon( Icons.widgets_sharp, - color: Colors.blue, + color: CustomColors.green, size: 29.0, ); } @@ -401,7 +402,7 @@ class _FinalProductsPageState extends State { height: 4.0, ), Container( - width: MediaQuery.of(context).size.width * 0.65, + width: MediaQuery.of(context).size.width * 0.64, child: Texts( model.finalProducts[index].name, regular: true, @@ -445,7 +446,7 @@ class _FinalProductsPageState extends State { icon: Icon( Icons.shopping_cart, size: 18, - color: Colors.blue, + color: CustomColors.green, ), onPressed: () async { if (model.finalProducts[index].rxMessage == null) { diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 31bf7243..ec37cff5 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -1,5 +1,3 @@ -import 'package:diplomaticquarterapp/config/size_config.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; @@ -8,37 +6,35 @@ import 'package:diplomaticquarterapp/core/viewModels/project_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/pages/sub_categories_modalsheet.dart'; import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; 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'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; 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(); + AuthenticatedUserObject authenticatedUserObject = locator(); ParentCategorisePage({this.id, this.titleName}); @override - _ParentCategorisePageState createState() => - _ParentCategorisePageState(id: id, titleName: titleName); + _ParentCategorisePageState createState() => _ParentCategorisePageState(id: id, titleName: titleName); } class _ParentCategorisePageState extends State { @@ -75,9 +71,7 @@ class _ParentCategorisePageState extends State { return BaseView( onModelReady: (model) => model.getCategoriseParent(i: id), allowAny: true, - builder: (BuildContext context, PharmacyCategoriseViewModel model, - Widget child) => - AppScaffold( + builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => AppScaffold( isPharmacy: true, appBarTitle: titleName, isBottomBar: true, @@ -129,8 +123,7 @@ class _ParentCategorisePageState extends State { child: InkWell( child: Container( child: Texts( - TranslationBase.of(context) - .viewCategorise, + TranslationBase.of(context).viewCategorise, // 'View All Categories', fontWeight: FontWeight.w300, ), @@ -215,28 +208,22 @@ class _ParentCategorisePageState extends State { child: Center( child: ListView.builder( scrollDirection: Axis.horizontal, - itemCount: model.categoriseParent.length > 8 - ? 8 - : model.categoriseParent.length, + itemCount: model.categoriseParent.length > 8 ? 8 : model.categoriseParent.length, itemBuilder: (BuildContext context, int index) { return Padding( - padding: - EdgeInsets.symmetric(horizontal: 8.0), + padding: EdgeInsets.symmetric(horizontal: 8.0), child: InkWell( child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ Padding( - padding: EdgeInsets.symmetric( - horizontal: 13.0), + padding: EdgeInsets.symmetric(horizontal: 13.0), child: Container( height: 60.0, width: 65.0, decoration: BoxDecoration( shape: BoxShape.circle, - color: Colors.orange.shade200 - .withOpacity(0.45), + color: Colors.orange.shade200.withOpacity(0.45), ), child: Center( child: Icon( @@ -247,23 +234,14 @@ class _ParentCategorisePageState extends State { ), ), Container( - width: MediaQuery.of(context) - .size - .width * - 0.197, + width: MediaQuery.of(context).size.width * 0.197, // height: MediaQuery.of(context) // .size // .height * // 0.08, child: Center( child: Texts( - projectViewModel.isArabic - ? model - .categoriseParent[index] - .namen - : model - .categoriseParent[index] - .name, + projectViewModel.isArabic ? model.categoriseParent[index].namen : model.categoriseParent[index].name, fontSize: 13.4, fontWeight: FontWeight.w600, maxLines: 3, @@ -277,10 +255,8 @@ class _ParentCategorisePageState extends State { context, FadePage( page: SubCategorisePage( - title: model - .categoriseParent[index].name, - id: model - .categoriseParent[index].id, + title: model.categoriseParent[index].name, + id: model.categoriseParent[index].id, parentId: id, )), ); @@ -326,21 +302,16 @@ class _ParentCategorisePageState extends State { initialChildSize: 0.95, maxChildSize: 0.95, minChildSize: 0.9, - builder: (BuildContext context, - ScrollController scrollController) { + builder: (BuildContext context, ScrollController scrollController) { return SingleChildScrollView( controller: scrollController, child: Container( color: Colors.white, - height: MediaQuery.of(context) - .size - .height * - 1.95, + height: MediaQuery.of(context).size.height * 1.95, child: Column( children: [ Padding( - padding: - EdgeInsets.all(8.0), + padding: EdgeInsets.all(8.0), child: Row( children: [ Icon( @@ -350,13 +321,10 @@ class _ParentCategorisePageState extends State { width: 10.0, ), Texts( - TranslationBase.of( - context) - .refine, + TranslationBase.of(context).refine, // 'Refine', - fontWeight: - FontWeight.w600, + fontWeight: FontWeight.w600, ), SizedBox( width: 250.0, @@ -364,17 +332,13 @@ class _ParentCategorisePageState extends State { InkWell( child: Texts( // 'Close', - TranslationBase.of( - context) - .closeIt, + TranslationBase.of(context).closeIt, color: Colors.red, - fontWeight: - FontWeight.w600, + fontWeight: FontWeight.w600, fontSize: 15.0, ), onTap: () { - Navigator.pop( - context); + Navigator.pop(context); }, ), ], @@ -387,39 +351,26 @@ class _ParentCategorisePageState extends State { Column( children: [ ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .categorise), + title: Texts(TranslationBase.of(context).categorise), children: [ ProcedureListWidget( model: model, - masterList: model - .categoriseParent, - removeHistory: - (item) { + masterList: model.categoriseParent, + removeHistory: (item) { setState(() { - entityList - .remove( - item); + entityList.remove(item); }); }, - addHistory: - (history) { + addHistory: (history) { setState(() { - entityList.add( - history); + entityList.add(history); }); }, - addSelectedHistories: - () { + addSelectedHistories: () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: - (master) => - isEntityListSelected( - master), + isEntityListSelected: (master) => isEntityListSelected(master), ) ], ), @@ -428,40 +379,26 @@ class _ParentCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .brands), + title: Texts(TranslationBase.of(context).brands), children: [ ProcedureListWidget( model: model, - masterList: model - .brandsList, - removeHistory: - (item) { + masterList: model.brandsList, + removeHistory: (item) { setState(() { - entityListBrands - .remove( - item); + entityListBrands.remove(item); }); }, - addHistory: - (history) { + addHistory: (history) { setState(() { - entityListBrands - .add( - history); + entityListBrands.add(history); }); }, - addSelectedHistories: - () { + addSelectedHistories: () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: - (master) => - isEntityListSelectedBrands( - master), + isEntityListSelected: (master) => isEntityListSelectedBrands(master), ) ], ), @@ -470,69 +407,43 @@ class _ParentCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .price), + title: Texts(TranslationBase.of(context).price), children: [ Container( - color: Color( - 0xffEEEEEE), + color: Color(0xffEEEEEE), child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column( - mainAxisAlignment: - MainAxisAlignment - .start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts( - 'Min'), + Texts('Min'), Container( - color: Colors - .white, - width: - 200, - height: - 40, - child: - TextFormField( - decoration: - InputDecoration( - border: - OutlineInputBorder(), + color: Colors.white, + width: 200, + height: 40, + child: TextFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), ), - controller: - minField, + controller: minField, ), ), ], ), Column( - mainAxisAlignment: - MainAxisAlignment - .start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts( - 'Max'), + Texts('Max'), Container( - color: Colors - .white, - width: - 200, - height: - 40, - child: - TextFormField( - decoration: - InputDecoration( - border: - OutlineInputBorder(), + color: Colors.white, + width: 200, + height: 40, + child: TextFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), ), - controller: - maxField, + controller: maxField, ), ), ], @@ -547,28 +458,18 @@ class _ParentCategorisePageState extends State { color: Colors.black12, ), SizedBox( - height: MediaQuery.of( - context) - .size - .height * - 0.4, + height: MediaQuery.of(context).size.height * 0.4, ), Padding( - padding: - EdgeInsets.all(8.0), + padding: EdgeInsets.all(8.0), child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceEvenly, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container( width: 100, child: Button( - label: TranslationBase.of( - context) - .reset, - backgroundColor: - Colors.red, + label: TranslationBase.of(context).reset, + backgroundColor: Colors.red, ), ), SizedBox( @@ -577,67 +478,34 @@ class _ParentCategorisePageState extends State { Container( width: 200, child: Button( - onTap: - () async { - String - categoriesId = - ""; - for (CategoriseParentModel category - in entityList) { - if (categoriesId == - "") { - categoriesId = - category - .id; + onTap: () async { + String categoriesId = ""; + for (CategoriseParentModel category in entityList) { + if (categoriesId == "") { + categoriesId = category.id; } else { - categoriesId = - "$categoriesId,${category.id}"; + categoriesId = "$categoriesId,${category.id}"; } } - String - brandIds = - ""; - for (CategoriseParentModel brand - in entityListBrands) { - if (brandIds == - "") { - brandIds = - brand - .id; + String brandIds = ""; + for (CategoriseParentModel brand in entityListBrands) { + if (brandIds == "") { + brandIds = brand.id; } else { - brandIds = - "$brandIds,${brand.id}"; + brandIds = "$brandIds,${brand.id}"; } } - GifLoaderDialogUtils - .showMyDialog( - context); + GifLoaderDialogUtils.showMyDialog(context); await model.getFilteredProducts( - min: minField - .text - .toString(), - max: maxField - .text - .toString(), - categoryId: - categoriesId, - brandId: - brandIds); - GifLoaderDialogUtils - .hideDialog( - context); + min: minField.text.toString(), max: maxField.text.toString(), categoryId: categoriesId, brandId: brandIds); + GifLoaderDialogUtils.hideDialog(context); - Navigator.pop( - context); + Navigator.pop(context); }, - label: TranslationBase.of( - context) - .apply, - backgroundColor: - Colors - .green, + label: TranslationBase.of(context).apply, + backgroundColor: Colors.green, ), ), ], @@ -676,7 +544,7 @@ class _ParentCategorisePageState extends State { styleTwo = true; styleIcon = Icon( Icons.auto_awesome_mosaic, - color: Colors.blue, + color: CustomColors.green, size: 29.0, ); } else { @@ -684,7 +552,7 @@ class _ParentCategorisePageState extends State { styleTwo = false; styleIcon = Icon( Icons.widgets_sharp, - color: Colors.blue, + color: CustomColors.green, size: 29.0, ); } @@ -704,30 +572,22 @@ class _ParentCategorisePageState extends State { model.parentProducts.isNotEmpty ? styleOne == true ? Container( - height: model.parentProducts.length * - MediaQuery.of(context).size.height * - 0.15, + height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.15, child: GridView.builder( physics: NeverScrollableScrollPhysics(), - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 0.5, mainAxisSpacing: 2.0, childAspectRatio: 0.9, ), itemCount: model.parentProducts.length, - itemBuilder: - (BuildContext context, int index) { + itemBuilder: (BuildContext context, int index) { return NetworkBaseView( baseViewModel: model, child: InkWell( child: Card( - color: model.parentProducts[index] - .discountName != - null - ? Color(0xffFFFF00) - : Colors.white, + color: model.parentProducts[index].discountName != null ? Color(0xffFFFF00) : Colors.white, elevation: 0, shape: Border( right: BorderSide( @@ -753,187 +613,99 @@ class _ParentCategorisePageState extends State { ), 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: 0), - width: MediaQuery.of(context) - .size - .width / - 3, + padding: EdgeInsets.symmetric(horizontal: 0), + width: MediaQuery.of(context).size.width / 3, child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ - if (model - .parentProducts[ - index] - .discountName != - null) + if (model.parentProducts[index].discountName != null) RotatedBox( quarterTurns: 4, child: Container( - decoration: - BoxDecoration(), + decoration: BoxDecoration(), child: Padding( - padding: - EdgeInsets - .only( + padding: EdgeInsets.only( right: 5.0, top: 20.0, bottom: 5.0, ), child: Texts( - 'offer' - .toUpperCase(), - color: Colors - .red, - fontSize: - 13.0, - fontWeight: - FontWeight - .w900, + 'offer'.toUpperCase(), + color: Colors.red, + fontSize: 13.0, + fontWeight: FontWeight.w900, ), ), - transform: new Matrix4 - .rotationZ( - 5.837200), + transform: new Matrix4.rotationZ(5.837200), ), ), Container( - margin: EdgeInsets - .fromLTRB( - 0, 16, 0, 0), - alignment: - Alignment.center, + margin: EdgeInsets.fromLTRB(0, 16, 0, 0), + alignment: Alignment.center, child: Image.network( - model - .parentProducts[ - index] - .images - .isNotEmpty - ? model - .parentProducts[ - index] - .images[0] - .thumb + 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 - ? MediaQuery.of( - context) - .size - .width / - 5 - : 0, - padding: - EdgeInsets.all(4), - decoration: - BoxDecoration( - color: Color( - 0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), + width: model.parentProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 5 : 0, + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + color: Color(0xffb23838), + borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), child: Texts( - model - .parentProducts[ - index] - .rxMessage != - null - ? model - .parentProducts[ - index] - .rxMessage - : "", + model.parentProducts[index].rxMessage != null ? model.parentProducts[index].rxMessage : "", color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ), ), ], ), Container( - margin: - EdgeInsets.symmetric( + margin: EdgeInsets.symmetric( horizontal: 6, vertical: 0, ), child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (model - .parentProducts[ - index] - .discountName != - null) + if (model.parentProducts[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 - .parentProducts[ - index] - .discountName, + model.parentProducts[index].discountName, regular: true, - color: Colors - .white, - fontSize: - 10.4, + color: Colors.white, + fontSize: 10.4, ), ), ), Texts( - projectViewModel - .isArabic - ? model - .parentProducts[ - index] - .namen - : model - .parentProducts[ - index] - .name, + projectViewModel.isArabic ? model.parentProducts[index].namen : model.parentProducts[index].name, regular: true, fontSize: 12, - fontWeight: - FontWeight.w700, + fontWeight: FontWeight.w700, ), Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), + padding: const EdgeInsets.only(top: 4, bottom: 4), child: Texts( "SAR ${model.parentProducts[index].price}", bold: true, @@ -943,25 +715,15 @@ class _ParentCategorisePageState extends State { Row( children: [ StarRating( - totalAverage: model - .parentProducts[ - index] - .approvedRatingSum > - 0 - ? (model.parentProducts[index].approvedRatingSum.toDouble() / - model.parentProducts[index].approvedRatingSum - .toDouble()) - .toDouble() + totalAverage: model.parentProducts[index].approvedRatingSum > 0 + ? (model.parentProducts[index].approvedRatingSum.toDouble() / model.parentProducts[index].approvedRatingSum.toDouble()).toDouble() : 0, - forceStars: - true), + forceStars: true), Texts( "(${model.parentProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: - FontWeight - .w400, + fontWeight: FontWeight.w400, ) ], ), @@ -976,9 +738,7 @@ class _ParentCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage( - model.parentProducts[ - index]), + page: ProductDetailPage(model.parentProducts[index]), )), }, )); @@ -986,14 +746,11 @@ class _ParentCategorisePageState extends State { ), ) : Container( - height: model.parentProducts.length * - MediaQuery.of(context).size.height * - 0.122, + 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) { + itemBuilder: (BuildContext context, int index) { return InkWell( child: Card( child: Row( @@ -1003,11 +760,9 @@ class _ParentCategorisePageState extends State { Column( children: [ Container( - decoration: - BoxDecoration(), + decoration: BoxDecoration(), child: Padding( - padding: - EdgeInsets.only( + padding: EdgeInsets.only( left: 9.0, top: 8.0, right: 10.0, @@ -1015,71 +770,33 @@ class _ParentCategorisePageState extends State { ), ), Container( - margin: EdgeInsets - .fromLTRB( - 0, 0, 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.contain, - height: 70, - ), + 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)), + 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: Texts( - model - .parentProducts[ - index] - .rxMessage != - null - ? model - .parentProducts[ - index] - .rxMessage - : "", + model.parentProducts[index].rxMessage != null ? model.parentProducts[index].rxMessage : "", color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ), ), ], @@ -1092,37 +809,19 @@ class _ParentCategorisePageState extends State { vertical: 0, ), child: Column( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - crossAxisAlignment: - CrossAxisAlignment - .start, + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: 4.0, ), Container( - width: MediaQuery.of( - context) - .size - .width * - 0.65, + width: MediaQuery.of(context).size.width * 0.635, child: Texts( - projectViewModel - .isArabic - ? model - .parentProducts[ - index] - .namen - : model - .parentProducts[ - index] - .name, + projectViewModel.isArabic ? model.parentProducts[index].namen : model.parentProducts[index].name, regular: true, fontSize: 13.2, - fontWeight: - FontWeight.w500, + fontWeight: FontWeight.w500, maxLines: 5, ), ), @@ -1130,11 +829,7 @@ class _ParentCategorisePageState extends State { height: 8.0, ), Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), + padding: const EdgeInsets.only(top: 4, bottom: 4), child: Texts( "SAR ${model.parentProducts[index].price}", bold: true, @@ -1144,72 +839,37 @@ class _ParentCategorisePageState extends State { Row( children: [ StarRating( - totalAverage: model - .parentProducts[ - index] - .approvedRatingSum > - 0 - ? (model.parentProducts[index].approvedRatingSum - .toDouble() / - model - .parentProducts[index] - .approvedRatingSum - .toDouble()) - .toDouble() + totalAverage: model.parentProducts[index].approvedRatingSum > 0 + ? (model.parentProducts[index].approvedRatingSum.toDouble() / model.parentProducts[index].approvedRatingSum.toDouble()).toDouble() : 0, forceStars: true), Texts( "(${model.parentProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ) ], ), ], ), ), - widget.authenticatedUserObject - .isLogin + widget.authenticatedUserObject.isLogin ? Container( child: IconButton( icon: Icon( - Icons - .shopping_cart, + Icons.shopping_cart, size: 18, - color: - Colors.blue, + color: CustomColors.green, ), - 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())); + 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); + AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); } }), ) @@ -1221,8 +881,7 @@ class _ParentCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage(model - .parentProducts[index]), + page: ProductDetailPage(model.parentProducts[index]), )), }, ); @@ -1269,8 +928,7 @@ class _ParentCategorisePageState extends State { } bool isEntityListSelected(CategoriseParentModel masterKey) { - Iterable history = - entityList.where((element) => masterKey.id == element.id); + Iterable history = entityList.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } @@ -1278,8 +936,7 @@ class _ParentCategorisePageState extends State { } bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { - Iterable history = - entityListBrands.where((element) => masterKey.id == element.id); + Iterable history = entityListBrands.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } 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 6bfe4fbc..69aaa04e 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -55,10 +55,10 @@ class _CartOrderPageState extends State { appBarTitle: TranslationBase.of(context).shoppingCart, isShowAppBar: true, isPharmacy: true, - //isBottomBar: true, showHomeAppBarIcon: false, isShowDecPage: false, isMainPharmacyPages: true, + showPharmacyCart: false, baseViewModel: model, backgroundColor: Colors.white, body: !(model.cartResponse.shoppingCarts == null || diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart index 4f5ab14e..50cee7c3 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart @@ -33,9 +33,7 @@ class _OrderPreviewPageState extends State { } void getData() async { - if (isLoading) - await Provider.of(context, listen: false) - .getShoppingCart(); + if (isLoading) await Provider.of(context, listen: false).getShoppingCart(); setState(() { isLoading = false; }); @@ -63,7 +61,7 @@ class _OrderPreviewPageState extends State { color: Color(0xFFF1F1F1), child: Column( children: [ - SelectAddressWidget(model, widget.addresses,changeMainState), + SelectAddressWidget(model, widget.addresses, changeMainState), SizedBox( height: 10, ), @@ -97,11 +95,8 @@ class _OrderPreviewPageState extends State { color: Colors.black, ), ...List.generate( - model.cartResponse.shoppingCarts != null - ? model.cartResponse.shoppingCarts.length - : 0, - (index) => ProductOrderPreviewItem( - model.cartResponse.shoppingCarts[index]), + model.cartResponse.shoppingCarts != null ? model.cartResponse.shoppingCarts.length : 0, + (index) => ProductOrderPreviewItem(model.cartResponse.shoppingCarts[index]), ), ], ), @@ -219,9 +214,7 @@ class _OrderPreviewPageState extends State { : Container(), ), SizedBox( - height: model.cartResponse.shoppingCarts != null - ? height * 0.10 - : 0, + height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, ) ], ), @@ -235,9 +228,8 @@ class _OrderPreviewPageState extends State { ), ); } - changeMainState(){ - setState(() { - }); + changeMainState() { + setState(() {}); } } 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 ab55002f..e03a4b35 100644 --- a/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart @@ -1,24 +1,10 @@ -import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer_addresses_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; -import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; -import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; -import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.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/widgets/data_display/text.dart'; -import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.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:provider/provider.dart'; @@ -38,14 +24,15 @@ class _SelectAddressWidgetState extends State { AddressInfo address; _navigateToAddressPage(String identificationNo) { - Navigator.push(context, FadePage(page: PharmacyAddressesPage())) - .then((result) { + Navigator.push(context, FadePage(page: PharmacyAddressesPage())).then((result) async { if (result != null) { + GifLoaderDialogUtils.showMyDialog(context); address = result; - widget.model.paymentCheckoutData.address = - Addresses.fromJson(address.toJson()); - widget.model.getInformationsByAddress(identificationNo); - widget.changeMainState(); + widget.model.paymentCheckoutData.address = Addresses.fromJson(address.toJson()); + await widget.model.getInformationsByAddress(identificationNo); + await widget.model.getShoppingCart(); + widget.changeMainState(); + GifLoaderDialogUtils.hideDialog(context); } }); } @@ -53,8 +40,7 @@ class _SelectAddressWidgetState extends State { @override void initState() { if (widget.model.paymentCheckoutData.address != null) { - address = AddressInfo.fromJson( - widget.model.paymentCheckoutData.address.toJson()); + address = AddressInfo.fromJson(widget.model.paymentCheckoutData.address.toJson()); } super.initState(); } @@ -79,8 +65,7 @@ class _SelectAddressWidgetState extends State { ), Expanded( child: Container( - padding: - EdgeInsets.symmetric(vertical: 0, horizontal: 6), + padding: EdgeInsets.symmetric(vertical: 0, horizontal: 6), child: Texts( TranslationBase.of(context).selectAddress, fontSize: 14, @@ -114,8 +99,7 @@ class _SelectAddressWidgetState extends State { ), Expanded( child: Container( - padding: EdgeInsets.symmetric( - vertical: 0, horizontal: 6), + padding: EdgeInsets.symmetric(vertical: 0, horizontal: 6), child: Texts( TranslationBase.of(context).shippingAddress, fontSize: 14, @@ -190,8 +174,7 @@ class _SelectAddressWidgetState extends State { fit: BoxFit.scaleDown, ), Container( - padding: - EdgeInsets.symmetric(vertical: 0, horizontal: 6), + padding: EdgeInsets.symmetric(vertical: 0, horizontal: 6), child: Texts( "${TranslationBase.of(context).shipBy}", fontSize: 12, @@ -203,9 +186,7 @@ class _SelectAddressWidgetState extends State { child: Image.asset( model.paymentCheckoutData.shippingOption == null ? "" - : model.paymentCheckoutData.shippingOption - .shippingRateComputationMethodSystemName == - "Shipping.FixedOrByWeight" + : model.paymentCheckoutData.shippingOption.shippingRateComputationMethodSystemName == "Shipping.FixedOrByWeight" ? "assets/images/pharmacy_module/payment/hmg_shipping_logo.png" : "assets/images/pharmacy_module/payment/aramex_shipping_logo.png", fit: BoxFit.contain, diff --git a/lib/pages/pharmacies/screens/lakum-main-page.dart b/lib/pages/pharmacies/screens/lakum-main-page.dart index 18981cc9..1547b929 100644 --- a/lib/pages/pharmacies/screens/lakum-main-page.dart +++ b/lib/pages/pharmacies/screens/lakum-main-page.dart @@ -39,10 +39,7 @@ class LakumMainPage extends StatelessWidget { body: Container( width: double.infinity, child: SingleChildScrollView( - child: (model.lacumGroupInformation != null && - model.lacumGroupInformation - .lakumInquiryInformationObjVersion != - null) + child: (model.lacumGroupInformation != null && model.lacumGroupInformation.lakumInquiryInformationObjVersion != null) ? Column( children: [ Stack( @@ -56,10 +53,7 @@ class LakumMainPage extends StatelessWidget { SizedBox( height: mediaQuery.size.height * 0.02, ), - Container( - width: mediaQuery.size.width * 1, - child: LakumBannerWidget( - model, mediaQuery, true)), + Container(width: mediaQuery.size.width * 1, child: LakumBannerWidget(model, mediaQuery, true)), ], ) ], @@ -67,20 +61,8 @@ class LakumMainPage extends StatelessWidget { SizedBox( width: 8, ), - LacumPointsWidget( - mediaQuery, - 2, - TranslationBase.of(context).gained, - model - .lacumGroupInformation - .lakumInquiryInformationObjVersion - .pointsBalanceAmount, - model.lacumGroupInformation - .lakumInquiryInformationObjVersion.gainedPoints, - model - .lacumGroupInformation - .lakumInquiryInformationObjVersion - .gainedPointsAmountPerYear), + LacumPointsWidget(mediaQuery, 2, TranslationBase.of(context).gained, model.lacumGroupInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount, + model.lacumGroupInformation.lakumInquiryInformationObjVersion.gainedPoints, model.lacumGroupInformation.lakumInquiryInformationObjVersion.gainedPointsAmountPerYear), SizedBox( height: 20, ), @@ -90,38 +72,13 @@ class LakumMainPage extends StatelessWidget { child: ListView( scrollDirection: Axis.horizontal, children: [ - LacumPointsWidget( - mediaQuery, - 1, - TranslationBase.of(context).balance, - model - .lacumGroupInformation - .lakumInquiryInformationObjVersion - .pointsBalanceAmount, - model - .lacumGroupInformation - .lakumInquiryInformationObjVersion - .pointsBalance, - null), + LacumPointsWidget(mediaQuery, 1, TranslationBase.of(context).balance, model.lacumGroupInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount, + model.lacumGroupInformation.lakumInquiryInformationObjVersion.pointsBalance, null), SizedBox( width: 8, ), - LacumPointsWidget( - mediaQuery, - 2, - TranslationBase.of(context).gained, - model - .lacumGroupInformation - .lakumInquiryInformationObjVersion - .pointsBalanceAmount, - model - .lacumGroupInformation - .lakumInquiryInformationObjVersion - .gainedPoints, - model - .lacumGroupInformation - .lakumInquiryInformationObjVersion - .gainedPointsAmountPerYear), + LacumPointsWidget(mediaQuery, 2, TranslationBase.of(context).gained, model.lacumGroupInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount, + model.lacumGroupInformation.lakumInquiryInformationObjVersion.gainedPoints, model.lacumGroupInformation.lakumInquiryInformationObjVersion.gainedPointsAmountPerYear), SizedBox( width: 8, ), @@ -129,40 +86,16 @@ class LakumMainPage extends StatelessWidget { mediaQuery, 3, TranslationBase.of(context).consumed, - model - .lacumGroupInformation - .lakumInquiryInformationObjVersion - .consumedPointsAmount != - null - ? int.parse(model - .lacumGroupInformation - .lakumInquiryInformationObjVersion - .consumedPointsAmount) + model.lacumGroupInformation.lakumInquiryInformationObjVersion.consumedPointsAmount != null + ? int.parse(model.lacumGroupInformation.lakumInquiryInformationObjVersion.consumedPointsAmount) : 0, - model - .lacumGroupInformation - .lakumInquiryInformationObjVersion - .consumedPoints, - model - .lacumGroupInformation - .lakumInquiryInformationObjVersion - .consumedPointsAmountPerYear), + model.lacumGroupInformation.lakumInquiryInformationObjVersion.consumedPoints, + model.lacumGroupInformation.lakumInquiryInformationObjVersion.consumedPointsAmountPerYear), SizedBox( width: 8, ), - LacumPointsWidget( - mediaQuery, - 4, - TranslationBase.of(context).transferred, - 0, - model - .lacumGroupInformation - .lakumInquiryInformationObjVersion - .transferPoints, - model - .lacumGroupInformation - .lakumInquiryInformationObjVersion - .transferPointsAmountPerYear), + LacumPointsWidget(mediaQuery, 4, TranslationBase.of(context).transferred, 0, model.lacumGroupInformation.lakumInquiryInformationObjVersion.transferPoints, + model.lacumGroupInformation.lakumInquiryInformationObjVersion.transferPointsAmountPerYear), ], ), ), @@ -170,22 +103,11 @@ class LakumMainPage extends StatelessWidget { mediaQuery, 3, TranslationBase.of(context).consumed, - model - .lacumGroupInformation - .lakumInquiryInformationObjVersion - .consumedPointsAmount != - null - ? int.parse(model - .lacumGroupInformation - .lakumInquiryInformationObjVersion - .consumedPointsAmount) + model.lacumGroupInformation.lakumInquiryInformationObjVersion.consumedPointsAmount != null + ? int.parse(model.lacumGroupInformation.lakumInquiryInformationObjVersion.consumedPointsAmount) : 0, - model.lacumGroupInformation - .lakumInquiryInformationObjVersion.consumedPoints, - model - .lacumGroupInformation - .lakumInquiryInformationObjVersion - .consumedPointsAmountPerYear), + model.lacumGroupInformation.lakumInquiryInformationObjVersion.consumedPoints, + model.lacumGroupInformation.lakumInquiryInformationObjVersion.consumedPointsAmountPerYear), SizedBox( width: 8, ), @@ -197,8 +119,7 @@ class LakumMainPage extends StatelessWidget { ), ), Container( - margin: - EdgeInsets.symmetric(vertical: 16, horizontal: 8), + margin: EdgeInsets.symmetric(vertical: 16, horizontal: 8), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -213,7 +134,7 @@ class LakumMainPage extends StatelessWidget { Padding( padding: EdgeInsets.symmetric(horizontal: 8), child: Texts( - TranslationBase.of(context).Expired, + TranslationBase.of(context).expiryDate, // "Expired", fontSize: 14, ), @@ -234,45 +155,39 @@ class LakumMainPage extends StatelessWidget { // fontSize: 14, // ), Container( - margin: - EdgeInsets.symmetric(vertical: 16, horizontal: 8), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + margin: EdgeInsets.symmetric(vertical: 16, horizontal: 8), + child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Row( children: [ - Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/lakum/waiting_gained_icon.png", - fit: BoxFit.fill, - width: 20, - height: 25, - ), - Padding( - padding: - EdgeInsets.symmetric(horizontal: 8), - child: Texts( - TranslationBase.of(context) - .Waitinggained, -// "Waiting gained", - fontSize: 14, - ), - ) - ], - ), - Texts( - "${model.lacumGroupInformation.lakumInquiryInformationObjVersion.waitingPoints} ${TranslationBase.of(context).lakumPoint}", - fontWeight: FontWeight.bold, - fontSize: 14, + Image.asset( + "assets/images/pharmacy_module/lakum/waiting_gained_icon.png", + fit: BoxFit.fill, + width: 20, + height: 25, ), - ])), + Padding( + padding: EdgeInsets.symmetric(horizontal: 8), + child: Texts( + TranslationBase.of(context).Waitinggained, +// "Waiting gained", + fontSize: 14, + ), + ) + ], + ), + Texts( + "${model.lacumGroupInformation.lakumInquiryInformationObjVersion.waitingPoints} ${TranslationBase.of(context).lakumPoint}", + fontWeight: FontWeight.bold, + fontSize: 14, + ), + ])), // Texts( // "${model.lacumGroupInformation.lakumInquiryInformationObjVersion.waitingPoints} Points", // fontWeight: FontWeight.bold, // fontSize: 14, // ), Container( - margin: - EdgeInsets.symmetric(vertical: 16, horizontal: 8), + margin: EdgeInsets.symmetric(vertical: 16, horizontal: 8), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -325,11 +240,7 @@ class LakumMainPage extends StatelessWidget { } navigateToLakumRegister(BuildContext context) { - Navigator.pushReplacement( - context, - FadePage( - page: LakumRegistrationPage( - projectViewModel.user.patientIdentificationNo))); + Navigator.pushReplacement(context, FadePage(page: LakumRegistrationPage(projectViewModel.user.patientIdentificationNo))); } } @@ -339,12 +250,7 @@ List _buildAppBarICons(BuildContext context, LacumViewModel model) { icon: Icon(Icons.settings), color: Colors.white, onPressed: () { - Navigator.push( - context, - FadePage( - page: LakumSettingPage( - model.lacumInformation, model.lacumGroupInformation))) - .then((result) => {model.getLacumGroupData()}); + Navigator.push(context, FadePage(page: LakumSettingPage(model.lacumInformation, model.lacumGroupInformation))).then((result) => {model.getLacumGroupData()}); }, ), ]; @@ -366,9 +272,7 @@ class LakumHomeButtons extends StatelessWidget { child: InkWell( onTap: () { print("Account activate click"); - Navigator.push( - context, FadePage(page: LakumActivationVidaPage())) - .then((result) => {model.getLacumGroupData()}); + Navigator.push(context, FadePage(page: LakumActivationVidaPage())).then((result) => {model.getLacumGroupData()}); }, child: Container( padding: EdgeInsets.symmetric(horizontal: 8), @@ -411,12 +315,7 @@ class LakumHomeButtons extends StatelessWidget { child: InkWell( onTap: () { print("Lacum transfer click"); - Navigator.push( - context, - FadePage( - page: LacumTransferPage(model.lacumInformation, - model.lacumGroupInformation))) - .then((result) => {model.getLacumGroupData()}); + Navigator.push(context, FadePage(page: LacumTransferPage(model.lacumInformation, model.lacumGroupInformation))).then((result) => {model.getLacumGroupData()}); }, child: Container( padding: EdgeInsets.symmetric(horizontal: 8), @@ -467,8 +366,7 @@ class LacumPointsWidget extends StatelessWidget { Color titleColor; final List pointsAmountPerYear; - LacumPointsWidget(this.mediaQuery, this.pointType, this.title, this.riyal, - this.point, this.pointsAmountPerYear) { + LacumPointsWidget(this.mediaQuery, this.pointType, this.title, this.riyal, this.point, this.pointsAmountPerYear) { if (pointType == 1) { titleColor = Color(0xffefefef); } else if (pointType == 2) { @@ -486,11 +384,9 @@ class LacumPointsWidget extends StatelessWidget { onTap: () { if (pointType != 1) { if (pointsAmountPerYear != null && pointsAmountPerYear.length > 0) { - Navigator.push(context, - FadePage(page: LakumPointsYearPage(pointsAmountPerYear))); + Navigator.push(context, FadePage(page: LakumPointsYearPage(pointsAmountPerYear))); } else { - AppToast.showErrorToast( - message: TranslationBase.of(context).lakumMsg); + AppToast.showErrorToast(message: TranslationBase.of(context).lakumMsg); // show snackBar No Details Points are there } } diff --git a/lib/pages/pharmacies/screens/lakum-points-year-page.dart b/lib/pages/pharmacies/screens/lakum-points-year-page.dart index 323f1a91..df333cdf 100644 --- a/lib/pages/pharmacies/screens/lakum-points-year-page.dart +++ b/lib/pages/pharmacies/screens/lakum-points-year-page.dart @@ -173,7 +173,7 @@ class LacumPointsYearWidget extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Texts(TranslationBase.of(context).RIYAL, + Texts(TranslationBase.of(context).sar, // "RIYAL", fontSize: 13, fontWeight: FontWeight.bold, diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 4da64235..0d0716cc 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -55,11 +55,11 @@ class _PharmacyPageState extends State { //crossAxisAlignment: CrossAxisAlignment.start, children: [ BannerPager(model), - // GridViewButtons(model), PrescriptionsWidget(), - ShopByBrandWidget(), +// ShopByBrandWidget(), RecentlyViewedWidget(), BestSellerWidget(), + ShopByBrandWidget(), ], ), ), diff --git a/lib/pages/pharmacies/screens/product-details/availability_info.dart b/lib/pages/pharmacies/screens/product-details/availability_info.dart index 9e717de6..13e94c87 100644 --- a/lib/pages/pharmacies/screens/product-details/availability_info.dart +++ b/lib/pages/pharmacies/screens/product-details/availability_info.dart @@ -1,82 +1,73 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; -import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:flutter/material.dart'; class AvailabilityInfo extends StatelessWidget { final ProductDetailViewModel previousModel; const AvailabilityInfo({Key key, this.previousModel}) : super(key: key); + @override Widget build(BuildContext context) { return previousModel.productLocationService.length == 0 ? Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text( - TranslationBase.of(context).noLocationAvailable, - ), - ) + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text( + TranslationBase.of(context).noLocationAvailable, + ), + ) : ListView.builder( - physics: ScrollPhysics(), - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemCount: previousModel.productLocationService.length, - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - flex: 1, - child: Image.network(previousModel - .productLocationService[index].projectImageUrl), - ), - SizedBox( - width: 10, - ), - Expanded( - flex: 4, - child: Text( - previousModel.productLocationService[index] - .locationDescription + - "\n" + - convertCityName( - previousModel.productLocationService[0].cityName - .toString(), + physics: ScrollPhysics(), + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: previousModel.productLocationService.length, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: EdgeInsets.all(8.0), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + flex: 1, + child: Image.network(previousModel.productLocationService[index].projectImageUrl), + ), + SizedBox( + width: 10, + ), + Expanded( + flex: 4, + child: Text( + previousModel.productLocationService[index].locationDescription + "\n" + previousModel.productLocationService[index].cityName.toString(), + style: TextStyle(fontSize: 12), ), - style: TextStyle(fontSize: 12), - ), - ), - Expanded( - flex: 1, - child: IconButton( - icon: Icon(Icons.location_on), - color: Colors.red, - onPressed: () {}, - ), - ), - Expanded( - flex: 1, - child: IconButton( - icon: Icon(Icons.phone), - color: Colors.red, - onPressed: () {}, + ), + Expanded( + flex: 1, + child: IconButton( + icon: Icon(Icons.location_on), + color: Colors.red, + onPressed: () {}, + ), + ), + Expanded( + flex: 1, + child: IconButton( + icon: Icon(Icons.phone), + color: Colors.red, + onPressed: () {}, + ), + ), + ], ), - ), - ], - ), - Divider(height: 1.2, color: Colors.grey) - ], - ), - ); - }, - ); + Divider(height: 1.2, color: Colors.grey) + ], + ), + ); + }, + ); } convertCityName(txt) { diff --git a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart index bf45c539..14dab3e5 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -206,11 +206,15 @@ class _FooterWidgetState extends State { WELCOME_LOGIN, ); } else { - await widget.addToShoppingCartFunction(quantity: widget.quantity, itemID: widget.item.id, model: widget.model); - Navigator.push( - context, - FadePage(page: CartOrderPage()), - );} + await widget.addToShoppingCartFunction(quantity: widget.quantity, itemID: widget.item.id, model: widget.model); + Navigator.of(context).pushNamed( + CART_ORDER_PAGE, + ); + // Navigator.push( + // context, + // FadePage(page: CartOrderPage()), + // ); + } }, fontWeight: FontWeight.w600, borderColor: Colors.grey[800], @@ -224,7 +228,6 @@ class _FooterWidgetState extends State { ), ], ), - ); } diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index e34a5dbc..d33e3178 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -317,7 +317,9 @@ class __ProductDetailPageState extends State { } addToShoppingCartFunction({quantity, itemID, ProductDetailViewModel model}) async { + GifLoaderDialogUtils.showMyDialog(context); await model.addToCartData(quantity, itemID); + GifLoaderDialogUtils.hideDialog(context); } addToWishlistFunction({itemID, ProductDetailViewModel model}) async { diff --git a/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart index ab278984..61177d1f 100644 --- a/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart +++ b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart @@ -3,11 +3,13 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/Prescription import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescription_items_page.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.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:provider/provider.dart'; import 'package:rating_bar/rating_bar.dart'; @@ -34,138 +36,150 @@ 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.2, + height: MediaQuery.of(context).size.height * 0.19, child: ListView.builder( scrollDirection: Axis.horizontal, shrinkWrap: true, physics: ScrollPhysics(), itemCount: model.prescriptionsList.length, itemBuilder: (context, index) { - return Container( - padding: EdgeInsets.only(left: 8.0, right: 8.0), - margin: EdgeInsets.only(right: 5.0, left: 5.0), - decoration: BoxDecoration( - border: Border.all( - color: Colors.grey, - style: BorderStyle.solid, - width: 1.0, + return InkWell( + onTap: () { + Navigator.push( + context, + FadePage( + page: PrescriptionItemsPage( + prescriptions: model.prescriptionsList[index], + ), ), - color: Colors.white, - borderRadius: BorderRadius.circular(10.0)), - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - children: [ - Container( - padding: EdgeInsets.only( - top: 10.0, - left: 10.0, - right: 10.0, - bottom: 10.0, - ), - child: CircleAvatar( - radius: 30, - backgroundColor: Colors.transparent, - child: Image.network( - model.prescriptionsList[index].doctorImageURL, - width: 50, - height: 50, + ); + }, + child: Container( + padding: EdgeInsets.only(left: 8.0, right: 8.0), + margin: EdgeInsets.only(right: 5.0, left: 5.0), + decoration: BoxDecoration( + border: Border.all( + color: Colors.grey, + style: BorderStyle.solid, + width: 1.0, + ), + color: Colors.white, + borderRadius: BorderRadius.circular(10.0)), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Row( + children: [ + Container( + padding: EdgeInsets.only( + top: 10.0, + left: 10.0, + right: 10.0, + bottom: 10.0, + ), + child: CircleAvatar( + radius: 30, + backgroundColor: Colors.transparent, + child: Image.network( + model.prescriptionsList[index].doctorImageURL, + width: 50, + height: 50, + ), ), ), - ), - Column( - children: [ - Container( - padding: EdgeInsets.only(left: 15.0, right: 15.0), - decoration: BoxDecoration( - border: Border.all( + Column( + children: [ + Container( + padding: EdgeInsets.only(left: 15.0, right: 15.0), + decoration: BoxDecoration( + border: Border.all( + color: Colors.green, + style: BorderStyle.solid, + width: 3.0, + ), color: Colors.green, - style: BorderStyle.solid, - width: 3.0, + borderRadius: BorderRadius.circular(30.0)), + child: Text( + model.languageID == "ar" + ? model.prescriptionsList[index].isInOutPatientDescriptionN.toString() + : model.prescriptionsList[index].isInOutPatientDescription.toString(), + style: TextStyle( + color: Colors.white, + fontSize: 15.0, ), - color: Colors.green, - borderRadius: BorderRadius.circular(30.0)), - child: Text( - model.languageID == "ar" - ? model.prescriptionsList[index].isInOutPatientDescriptionN.toString() - : model.prescriptionsList[index].isInOutPatientDescription.toString(), + )), + Row(children: [ + Image.asset( + 'assets/images/Icon-awesome-calendar.png', + width: 30, + height: 30, + ), + Text( + DateUtil.convertStringToDate(model.prescriptionsList[index].appointmentDate.toString()).toString().substring(0, 10), style: TextStyle( - color: Colors.white, + color: Colors.black, fontSize: 15.0, ), - )), - Row(children: [ - Image.asset( - 'assets/images/Icon-awesome-calendar.png', - width: 30, - height: 30, - ), - Text( - DateUtil.convertStringToDate(model.prescriptionsList[index].appointmentDate.toString()).toString().substring(0, 10), - style: TextStyle( - color: Colors.black, - fontSize: 15.0, - ), - ) - ]), - ], - ), - ], - ), - Container( - margin: EdgeInsets.only(left: 5), - child: Row(children: [ - Text( - model.prescriptionsList[index].doctorTitle.toString(), - style: TextStyle( - color: Colors.black, - fontSize: 15.0, - fontWeight: FontWeight.bold, + ) + ]), + ], ), - ), - Text( - model.prescriptionsList[index].doctorName.toString(), - style: TextStyle( - color: Colors.black, - fontSize: 15.0, - fontWeight: FontWeight.bold, + ], + ), + Container( + margin: EdgeInsets.only(left: 5), + child: Row(children: [ + Text( + model.prescriptionsList[index].doctorTitle.toString(), + style: TextStyle( + color: Colors.black, + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), ), - ), - ]), - ), - Container( - margin: EdgeInsets.only(left: 5), - child: Text( - model.prescriptionsList[index].clinicDescription.toString(), - style: TextStyle( - color: Colors.green, - fontSize: 15.0, - ), + Text( + model.prescriptionsList[index].doctorName.toString(), + style: TextStyle( + color: Colors.black, + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ), + ]), ), - ), - Row(children: [ Container( margin: EdgeInsets.only(left: 5), - child: RatingBar.readOnly( - initialRating: model.prescriptionsList[index].actualDoctorRate.toDouble(), - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + child: Text( + model.prescriptionsList[index].clinicDescription.toString(), + style: TextStyle( + color: Colors.green, + fontSize: 15.0, + ), ), ), - SizedBox( - width: 100.0, - ), - Container( - child: Icon( - Icons.arrow_forward, - color: Theme.of(context).primaryColor, - )), + Row(children: [ + Container( + margin: EdgeInsets.only(left: 5), + child: RatingBar.readOnly( + initialRating: model.prescriptionsList[index].actualDoctorRate.toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), + ), + SizedBox( + width: 130.0, + ), + Container( + child: Icon( + Icons.arrow_forward, + color: Theme.of(context).primaryColor, + )), + ]), ]), - ]), + ), ); }, ), diff --git a/lib/pages/pharmacies/widgets/lacum-banner-widget.dart b/lib/pages/pharmacies/widgets/lacum-banner-widget.dart index a15b385d..7d10b886 100644 --- a/lib/pages/pharmacies/widgets/lacum-banner-widget.dart +++ b/lib/pages/pharmacies/widgets/lacum-banner-widget.dart @@ -125,7 +125,7 @@ class _LakumBannerWidgetState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts(TranslationBase.of(context).IDENTIFICATION, + Texts(TranslationBase.of(context).identificationNumber, // "IDENTIFICATION #", fontSize: 14, fontWeight: FontWeight.bold, diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 49ebf48d..e5a8b097 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -5,9 +5,10 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_mo 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/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; @@ -25,14 +26,12 @@ class SubCategorisePage extends StatefulWidget { String title; String parentId; - AuthenticatedUserObject authenticatedUserObject = - locator(); + AuthenticatedUserObject authenticatedUserObject = locator(); SubCategorisePage({this.id, this.parentId, this.title}); @override - _SubCategorisePageState createState() => - _SubCategorisePageState(id: id, title: title, parentId: parentId); + _SubCategorisePageState createState() => _SubCategorisePageState(id: id, title: title, parentId: parentId); } class _SubCategorisePageState extends State { @@ -54,15 +53,14 @@ class _SubCategorisePageState extends State { ); List entityList = List(); List entityListBrands = List(); + @override Widget build(BuildContext context) { TextEditingController minField = TextEditingController(); TextEditingController maxField = TextEditingController(); return BaseView( onModelReady: (model) => model.getSubCategorise(i: id), - builder: (BuildContext context, PharmacyCategoriseViewModel model, - Widget child) => - PharmacyAppScaffold( + builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( appBarTitle: title, isBottomBar: false, isShowAppBar: true, @@ -94,8 +92,7 @@ class _SubCategorisePageState extends State { ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' : parentId == '9' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' - : parentId == - '10' + : parentId == '10' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' : '', fit: BoxFit.fill, @@ -107,14 +104,12 @@ class _SubCategorisePageState extends State { children: [ InkWell( child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: EdgeInsets.all(10.0), child: Container( - child: Texts(TranslationBase.of(context) - .viewCategorise), + child: Texts(TranslationBase.of(context).viewCategorise), ), ), Icon(Icons.arrow_forward) @@ -126,30 +121,21 @@ class _SubCategorisePageState extends State { context: context, builder: (BuildContext context) { return Container( - height: - MediaQuery.of(context).size.height * - 0.89, + height: MediaQuery.of(context).size.height * 0.89, color: Colors.white, child: Center( child: ListView.builder( scrollDirection: Axis.vertical, - itemCount: - model.subCategorise.length, - itemBuilder: (BuildContext context, - int index) { + itemCount: model.subCategorise.length, + itemBuilder: (BuildContext context, int index) { return Container( child: Padding( padding: EdgeInsets.all(8.0), child: InkWell( child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts(model - .subCategorise[ - index] - .name), + Texts(model.subCategorise[index].name), Divider( thickness: 0.6, color: Colors.black12, @@ -160,12 +146,8 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: - FinalProductsPage( - id: model - .subCategorise[ - index] - .id, + page: FinalProductsPage( + id: model.subCategorise[index].id, ), ), ); @@ -198,23 +180,19 @@ class _SubCategorisePageState extends State { itemCount: model.subCategorise.length, itemBuilder: (BuildContext context, int index) { return Padding( - padding: - EdgeInsets.symmetric(horizontal: 8.0), + padding: EdgeInsets.symmetric(horizontal: 8.0), child: InkWell( child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ Padding( - padding: EdgeInsets.symmetric( - horizontal: 13.0), + padding: EdgeInsets.symmetric(horizontal: 13.0), child: Container( height: 60.0, width: 65.0, decoration: BoxDecoration( shape: BoxShape.circle, - color: Colors.orange.shade200 - .withOpacity(0.45), + color: Colors.orange.shade200.withOpacity(0.45), ), child: Center( child: Icon( @@ -225,14 +203,8 @@ class _SubCategorisePageState extends State { ), ), Container( - width: MediaQuery.of(context) - .size - .width * - 0.17, - height: MediaQuery.of(context) - .size - .height * - 0.10, + width: MediaQuery.of(context).size.width * 0.17, + height: MediaQuery.of(context).size.height * 0.10, child: Center( child: Texts( model.subCategorise[index].name, @@ -293,21 +265,16 @@ class _SubCategorisePageState extends State { initialChildSize: 0.95, maxChildSize: 0.95, minChildSize: 0.9, - builder: (BuildContext context, - ScrollController scrollController) { + builder: (BuildContext context, ScrollController scrollController) { return SingleChildScrollView( controller: scrollController, child: Container( color: Colors.white, - height: MediaQuery.of(context) - .size - .height * - 1.95, + height: MediaQuery.of(context).size.height * 1.95, child: Column( children: [ Padding( - padding: - EdgeInsets.all(8.0), + padding: EdgeInsets.all(8.0), child: Row( children: [ Icon( @@ -317,30 +284,23 @@ class _SubCategorisePageState extends State { width: 10.0, ), Texts( - TranslationBase.of( - context) - .refine, + TranslationBase.of(context).refine, // 'Refine', - fontWeight: - FontWeight.w600, + fontWeight: FontWeight.w600, ), SizedBox( width: 250.0, ), InkWell( child: Texts( - TranslationBase.of( - context) - .closeIt, + TranslationBase.of(context).closeIt, // 'Close', color: Colors.red, - fontWeight: - FontWeight.w600, + fontWeight: FontWeight.w600, fontSize: 15.0, ), onTap: () { - Navigator.pop( - context); + Navigator.pop(context); }, ), ], @@ -353,39 +313,26 @@ class _SubCategorisePageState extends State { Column( children: [ ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .categorise), + title: Texts(TranslationBase.of(context).categorise), children: [ ProcedureListWidget( model: model, - masterList: model - .subCategorise, - removeHistory: - (item) { + masterList: model.subCategorise, + removeHistory: (item) { setState(() { - entityList - .remove( - item); + entityList.remove(item); }); }, - addHistory: - (history) { + addHistory: (history) { setState(() { - entityList.add( - history); + entityList.add(history); }); }, - addSelectedHistories: - () { + addSelectedHistories: () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: - (master) => - isEntityListSelected( - master), + isEntityListSelected: (master) => isEntityListSelected(master), ) ], ), @@ -394,40 +341,26 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .brands), + title: Texts(TranslationBase.of(context).brands), children: [ ProcedureListWidget( model: model, - masterList: model - .brandsList, - removeHistory: - (item) { + masterList: model.brandsList, + removeHistory: (item) { setState(() { - entityListBrands - .remove( - item); + entityListBrands.remove(item); }); }, - addHistory: - (history) { + addHistory: (history) { setState(() { - entityListBrands - .add( - history); + entityListBrands.add(history); }); }, - addSelectedHistories: - () { + addSelectedHistories: () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: - (master) => - isEntityListSelectedBrands( - master), + isEntityListSelected: (master) => isEntityListSelectedBrands(master), ) ], ), @@ -436,69 +369,43 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .price), + title: Texts(TranslationBase.of(context).price), children: [ Container( - color: Color( - 0xffEEEEEE), + color: Color(0xffEEEEEE), child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column( - mainAxisAlignment: - MainAxisAlignment - .start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts( - 'Min'), + Texts('Min'), Container( - color: Colors - .white, - width: - 200, - height: - 40, - child: - TextFormField( - decoration: - InputDecoration( - border: - OutlineInputBorder(), + color: Colors.white, + width: 200, + height: 40, + child: TextFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), ), - controller: - minField, + controller: minField, ), ), ], ), Column( - mainAxisAlignment: - MainAxisAlignment - .start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts( - 'Max'), + Texts('Max'), Container( - color: Colors - .white, - width: - 200, - height: - 40, - child: - TextFormField( - decoration: - InputDecoration( - border: - OutlineInputBorder(), + color: Colors.white, + width: 200, + height: 40, + child: TextFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), ), - controller: - maxField, + controller: maxField, ), ), ], @@ -513,31 +420,20 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), SizedBox( - height: MediaQuery.of( - context) - .size - .height * - 0.4, + height: MediaQuery.of(context).size.height * 0.4, ), Padding( - padding: - EdgeInsets.all(8.0), + padding: EdgeInsets.all(8.0), child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceEvenly, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Expanded( child: Container( width: 100, child: Button( - label: TranslationBase.of( - context) - .reset, + label: TranslationBase.of(context).reset, // 'Reset', - backgroundColor: - Colors - .red, + backgroundColor: Colors.red, ), ), ), @@ -547,66 +443,33 @@ class _SubCategorisePageState extends State { Container( width: 200, child: Button( - onTap: - () async { - String - categoriesId = - ""; - for (CategoriseParentModel category - in entityList) { - if (categoriesId == - "") { - categoriesId = - category - .id; + onTap: () async { + String categoriesId = ""; + for (CategoriseParentModel category in entityList) { + if (categoriesId == "") { + categoriesId = category.id; } else { - categoriesId = - "$categoriesId,${category.id}"; + categoriesId = "$categoriesId,${category.id}"; } } - String - brandIds = - ""; - for (CategoriseParentModel brand - in entityListBrands) { - if (brandIds == - "") { - brandIds = - brand - .id; + String brandIds = ""; + for (CategoriseParentModel brand in entityListBrands) { + if (brandIds == "") { + brandIds = brand.id; } else { - brandIds = - "$brandIds,${brand.id}"; + brandIds = "$brandIds,${brand.id}"; } } - GifLoaderDialogUtils - .showMyDialog( - context); + GifLoaderDialogUtils.showMyDialog(context); await model.getFilteredSubProducts( - min: minField - .text - .toString(), - max: maxField - .text - .toString(), - categoryId: - categoriesId, - brandId: - brandIds); - GifLoaderDialogUtils - .hideDialog( - context); - Navigator.pop( - context); + min: minField.text.toString(), max: maxField.text.toString(), categoryId: categoriesId, brandId: brandIds); + GifLoaderDialogUtils.hideDialog(context); + Navigator.pop(context); }, - label: TranslationBase.of( - context) - .apply, + label: TranslationBase.of(context).apply, // 'Apply', - backgroundColor: - Colors - .green, + backgroundColor: Colors.green, ), ), ], @@ -645,7 +508,7 @@ class _SubCategorisePageState extends State { styleTwo = true; styleIcon = Icon( Icons.auto_awesome_mosaic, - color: Colors.blue, + color: CustomColors.green, size: 29.0, ); } else { @@ -653,7 +516,7 @@ class _SubCategorisePageState extends State { styleTwo = false; styleIcon = Icon( Icons.widgets_sharp, - color: Colors.blue, + color: CustomColors.green, size: 29.0, ); } @@ -673,30 +536,22 @@ class _SubCategorisePageState extends State { model.subProducts.isNotEmpty ? styleOne == true ? Container( - height: model.subProducts.length * - MediaQuery.of(context).size.height * - 0.15, + height: model.subProducts.length * MediaQuery.of(context).size.height * 0.15, child: GridView.builder( physics: NeverScrollableScrollPhysics(), - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 0.5, mainAxisSpacing: 2.0, childAspectRatio: 0.9, ), itemCount: model.subProducts.length, - itemBuilder: - (BuildContext context, int index) { + itemBuilder: (BuildContext context, int index) { return NetworkBaseView( baseViewModel: model, child: InkWell( child: Card( - color: model.subProducts[index] - .discountName != - null - ? Color(0xffFFFF00) - : Colors.white, + color: model.subProducts[index].discountName != null ? Color(0xffFFFF00) : Colors.white, elevation: 0, shape: Border( right: BorderSide( @@ -722,118 +577,62 @@ class _SubCategorisePageState extends State { ), 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: 0), - width: MediaQuery.of(context) - .size - .width / - 3, + padding: EdgeInsets.symmetric(horizontal: 0), + width: MediaQuery.of(context).size.width / 3, child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ Container( - margin: EdgeInsets - .fromLTRB( - 0, 16, 0, 0), - alignment: - Alignment.center, + margin: EdgeInsets.fromLTRB(0, 16, 0, 0), + alignment: Alignment.center, child: Image.network( - model - .subProducts[ - index] - .images - .isNotEmpty - ? model - .subProducts[ - index] - .images[0] - .thumb + model.subProducts[index].images.isNotEmpty + ? model.subProducts[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 - .subProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 5 - : 0, - padding: - EdgeInsets.all(4), - decoration: - BoxDecoration( - color: Color( - 0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), + width: model.subProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 5 : 0, + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + color: Color(0xffb23838), + borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), child: Texts( - model - .subProducts[ - index] - .rxMessage != - null - ? model - .subProducts[ - index] - .rxMessage - : "", + model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ), ), ], ), Container( - margin: - EdgeInsets.symmetric( + margin: EdgeInsets.symmetric( horizontal: 6, vertical: 0, ), child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - model - .subProducts[ - index] - .name, + model.subProducts[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.subProducts[index].price}", bold: true, @@ -843,25 +642,15 @@ class _SubCategorisePageState extends State { Row( children: [ StarRating( - totalAverage: model - .subProducts[ - index] - .approvedRatingSum > - 0 - ? (model.subProducts[index].approvedRatingSum.toDouble() / - model.subProducts[index].approvedRatingSum - .toDouble()) - .toDouble() + totalAverage: model.subProducts[index].approvedRatingSum > 0 + ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() : 0, - forceStars: - true), + forceStars: true), Texts( "(${model.subProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: - FontWeight - .w400, + fontWeight: FontWeight.w400, ) ], ), @@ -876,9 +665,7 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage( - model.subProducts[ - index]), + page: ProductDetailPage(model.subProducts[index]), )), }, )); @@ -886,14 +673,11 @@ class _SubCategorisePageState extends State { ), ) : Container( - height: model.subProducts.length * - MediaQuery.of(context).size.height * - 0.122, + height: model.subProducts.length * MediaQuery.of(context).size.height * 0.122, child: ListView.builder( physics: NeverScrollableScrollPhysics(), itemCount: model.subProducts.length, - itemBuilder: - (BuildContext context, int index) { + itemBuilder: (BuildContext context, int index) { return InkWell( child: Card( child: Row( @@ -903,11 +687,9 @@ class _SubCategorisePageState extends State { Column( children: [ Container( - decoration: - BoxDecoration(), + decoration: BoxDecoration(), child: Padding( - padding: - EdgeInsets.only( + padding: EdgeInsets.only( left: 9.0, top: 8.0, right: 10.0, @@ -915,71 +697,33 @@ class _SubCategorisePageState extends State { ), ), Container( - margin: EdgeInsets - .fromLTRB( - 0, 0, 0, 0), - alignment: - Alignment.center, - child: Image.network( - model - .subProducts[ - index] - .images - .isNotEmpty - ? model - .subProducts[ - index] - .images[0] - .thumb - : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', + margin: EdgeInsets.fromLTRB(0, 0, 0, 0), + alignment: Alignment.center, + child: model.subProducts[index].images.isNotEmpty + ? Image.network( + model.subProducts[index].images[0].thumb, fit: BoxFit.contain, - height: 80, - ), + height: 70, + ) + : Text(TranslationBase.of(context).noImage), ), ], ), Column( children: [ Container( - width: model - .subProducts[ - 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)), + width: model.subProducts[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 - .subProducts[ - index] - .rxMessage != - null - ? model - .subProducts[ - index] - .rxMessage - : "", + model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ), ), ], @@ -993,31 +737,19 @@ class _SubCategorisePageState extends State { vertical: 0, ), child: Column( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - crossAxisAlignment: - CrossAxisAlignment - .start, + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: 4.0, ), Container( - width: MediaQuery.of( - context) - .size - .width * - 0.65, + width: MediaQuery.of(context).size.width * 0.65, child: Texts( - model - .subProducts[ - index] - .name, + model.subProducts[index].name, regular: true, fontSize: 13.2, - fontWeight: - FontWeight.w500, + fontWeight: FontWeight.w500, maxLines: 5, ), ), @@ -1025,11 +757,7 @@ class _SubCategorisePageState extends State { height: 8.0, ), Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), + padding: const EdgeInsets.only(top: 4, bottom: 4), child: Texts( "SAR ${model.subProducts[index].price}", bold: true, @@ -1039,54 +767,41 @@ class _SubCategorisePageState extends State { Row( children: [ StarRating( - totalAverage: model - .subProducts[ - index] - .approvedRatingSum > - 0 - ? (model.subProducts[index].approvedRatingSum - .toDouble() / - model - .subProducts[index] - .approvedRatingSum - .toDouble()) - .toDouble() + totalAverage: model.subProducts[index].approvedRatingSum > 0 + ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() : 0, forceStars: true), Texts( "(${model.subProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ) ], ), ], ), ), - widget.authenticatedUserObject.isLogin? - Container( - child: IconButton( - icon: Icon(Icons.shopping_cart, - size: 18, - color: Colors.blue,), - onPressed: () async { - if(model.subProducts[index].rxMessage == null){ - GifLoaderDialogUtils.showMyDialog(context); - await addToCartFunction(1, model.subProducts[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: CustomColors.green, + ), + onPressed: () async { + if (model.subProducts[index].rxMessage == null) { + GifLoaderDialogUtils.showMyDialog(context); + await addToCartFunction(1, model.subProducts[index].id); + GifLoaderDialogUtils.hideDialog(context); + Navigator.push(context, FadePage(page: CartOrderPage())); + } else { + AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); + } + }), + ) + : Container(), ], ), ), @@ -1094,8 +809,7 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage( - model.subProducts[index]), + page: ProductDetailPage(model.subProducts[index]), )), }, ); @@ -1137,8 +851,7 @@ class _SubCategorisePageState extends State { } bool isEntityListSelected(CategoriseParentModel masterKey) { - Iterable history = - entityList.where((element) => masterKey.id == element.id); + Iterable history = entityList.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } @@ -1146,13 +859,13 @@ class _SubCategorisePageState extends State { } bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { - Iterable history = - entityListBrands.where((element) => masterKey.id == element.id); + Iterable history = entityListBrands.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } return false; } + addToCartFunction(quantity, itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); await x.addToCartData(quantity, itemID); diff --git a/lib/routes.dart b/lib/routes.dart index a8d850e1..72599bb2 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -14,8 +14,8 @@ import 'package:diplomaticquarterapp/pages/login/register-info.dart'; import 'package:diplomaticquarterapp/pages/login/register.dart'; import 'package:diplomaticquarterapp/pages/login/welcome.dart'; import 'package:diplomaticquarterapp/pages/packages_offers/OfferAndPackagesCartPage.dart'; -import 'package:diplomaticquarterapp/pages/packages_offers/OfferAndPackagesPage.dart'; import 'package:diplomaticquarterapp/pages/packages_offers/PackageOrderCompletedPage.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/settings/settings.dart'; import 'package:diplomaticquarterapp/pages/symptom-checker/info.dart'; import 'package:diplomaticquarterapp/pages/symptom-checker/select-gender.dart'; @@ -47,6 +47,7 @@ const String PACKAGES_OFFERS_CART = 'packages-offers-cart'; const String PACKAGES_ORDER_COMPLETED = 'packages-offers-cart'; const String TEST_PAGE = 'test-page'; const String OPENTOK_CALL_PAGE = 'OPENTOK_CALL_PAGE'; +const String CART_ORDER_PAGE = 'cart-order-page'; const String HEALTH_WEATHER = 'health-weather'; const APP_UPDATE = 'app-update'; @@ -74,9 +75,10 @@ var routes = { HEALTH_WEATHER: (_) => HealthWeatherIndicator(), APP_UPDATE: (_) => AppUpdatePage(), SETTINGS: (_) => Settings(), + CART_ORDER_PAGE: (_) => CartOrderPage(), OPENTOK_CALL_PAGE: (_) => OpenTokConnectCallPage( apiKey: '46209962', sessionId: '1_MX40NjIwOTk2Mn5-MTYzNDY0ODM3NDY2Nn5PcnpnNGM0R1Q3ODZ6UXlFQ01lMDF5YWJ-fg', - token: 'T1==cGFydG5lcl9pZD00NjIwOTk2MiZzaWc9Y2ZhZjMzZjA3MWFkMjkxN2JmYjEwZDkxYTRkOTdhN2NmNWE4YjMyYTpzZXNzaW9uX2lkPTFfTVg0ME5qSXdPVGsyTW41LU1UWXpORFkwT0RNM05EWTJObjVQY25wbk5HTTBSMVEzT0RaNlVYbEZRMDFsTURGNVlXSi1mZyZjcmVhdGVfdGltZT0xNjM0NjQ4Mzc1Jm5vbmNlPTAuNzczMzcxNDUxMDgzMjQyMyZyb2xlPW1vZGVyYXRvciZleHBpcmVfdGltZT0xNjM0NzM0Nzc1JmluaXRpYWxfbGF5b3V0X2NsYXNzX2xpc3Q9' - ), + token: + 'T1==cGFydG5lcl9pZD00NjIwOTk2MiZzaWc9Y2ZhZjMzZjA3MWFkMjkxN2JmYjEwZDkxYTRkOTdhN2NmNWE4YjMyYTpzZXNzaW9uX2lkPTFfTVg0ME5qSXdPVGsyTW41LU1UWXpORFkwT0RNM05EWTJObjVQY25wbk5HTTBSMVEzT0RaNlVYbEZRMDFsTURGNVlXSi1mZyZjcmVhdGVfdGltZT0xNjM0NjQ4Mzc1Jm5vbmNlPTAuNzczMzcxNDUxMDgzMjQyMyZyb2xlPW1vZGVyYXRvciZleHBpcmVfdGltZT0xNjM0NzM0Nzc1JmluaXRpYWxfbGF5b3V0X2NsYXNzX2xpc3Q9'), }; diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 8db305d7..0bdfb6f7 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1421,6 +1421,7 @@ class TranslationBase { String get enablingWifi => localizedValues['enablingWifi'][locale.languageCode]; String get offerAndPackages => localizedValues['offerAndPackages'][locale.languageCode]; + String get offerAndPackagesDetails => localizedValues['offerAndPackagesDetails'][locale.languageCode]; String get invoiceNo => localizedValues['InvoiceNo'][locale.languageCode]; @@ -2608,6 +2609,7 @@ class TranslationBase { String get laserClinic => localizedValues["laserClinic"][locale.languageCode]; + String get noImage => localizedValues["noImage"][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index d071d4d2..8772a60e 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -14,6 +14,7 @@ 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/routes.dart'; import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; @@ -493,7 +494,8 @@ class AppBarWidgetState extends State { icon: Badge(badgeContent: Text(orderPreviewViewModel.cartResponse.quantityCount.toString()), child: Icon(Icons.shopping_cart)), color: Colors.white, onPressed: () { - Navigator.of(context).popUntil(ModalRoute.withName('/')); + // Navigator.of(context).popUntil(ModalRoute.withName('/')); + Navigator.of(context).popAndPushNamed(CART_ORDER_PAGE); }) : Container(), (widget.isOfferPackages && widget.showOfferPackagesCart) From 72784f68b971eea13116faab308123dabf0963c4 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 2 Nov 2021 17:29:27 +0300 Subject: [PATCH 13/70] Fixes & updates --- lib/config/config.dart | 16 +- .../model/er/AmbulanceRequestOrdersModel.dart | 483 +++++++++--------- lib/core/model/er/PatientER_RC.dart | 2 +- ..._all_transportation_method_list_model.dart | 48 +- .../prescription_info_rc_model.dart | 52 ++ .../AlHabibMedicalService/cmc_service.dart | 8 +- .../home_health_care_service.dart | 8 +- lib/core/service/client/base_app_client.dart | 24 +- lib/core/service/er/am_service.dart | 20 +- .../medical/prescriptions_service.dart | 32 +- .../viewModels/er/am_request_view_model.dart | 2 +- lib/core/viewModels/er/rrt-view-model.dart | 6 +- .../medical/prescriptions_view_model.dart | 21 +- .../orders_log_details_page.dart | 4 +- lib/pages/Blood/blood_donation.dart | 46 +- .../DrawerPages/family/add-family-member.dart | 5 +- .../AmbulanceRequestIndex.dart | 35 +- .../PickupLocation.dart | 2 +- .../SelectTransportationMethod.dart | 2 +- lib/pages/ErService/OrderLogPage.dart | 4 +- .../rapid-response-team/rrt-logs-page.dart | 28 +- .../prescriptions_history_details_page.dart | 38 +- .../prescriptions_history_page.dart | 24 +- 23 files changed, 537 insertions(+), 373 deletions(-) create mode 100644 lib/core/model/prescriptions/prescription_info_rc_model.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 49b33063..f3444d3a 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -15,16 +15,19 @@ const PACKAGES_CUSTOMER = '/api/customers'; 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/'; // Pharmacy UAT URLs - const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; - const PHARMACY_BASE_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; +// const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; +// const PHARMACY_BASE_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; // // Pharmacy Production URLs -// const BASE_PHARMACY_URL = 'https://mdlaboratories.com/exacartapi/api/'; -// const PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapi/api/'; +const BASE_PHARMACY_URL = 'https://mdlaboratories.com/exacartapi/api/'; +const PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapi/api/'; + +// RC API URLs +const RC_BASE_URL = 'https://livecare.hmg.com/'; const PING_SERVICE = 'Services/Weather.svc/REST/CheckConnectivity'; @@ -462,6 +465,7 @@ const UPDATE_RRT_ORDER_RC = 'rc/api/rrt/update'; // PRESCRIPTION RC SERVICES const ADD_PRESCRIPTION_ORDER_RC = "rc/api/prescription/add"; const GET_ALL_PRESCRIPTION_ORDERS_RC = "rc/api/prescription/list"; +const GET_ALL_PRESCRIPTION_INFO_RC = "rc/api/Prescription/info"; const UPDATE_PRESCRIPTION_ORDER_RC = 'rc/api/prescription/update'; diff --git a/lib/core/model/er/AmbulanceRequestOrdersModel.dart b/lib/core/model/er/AmbulanceRequestOrdersModel.dart index 6bcc02b0..72a3fd5f 100644 --- a/lib/core/model/er/AmbulanceRequestOrdersModel.dart +++ b/lib/core/model/er/AmbulanceRequestOrdersModel.dart @@ -1,26 +1,27 @@ class AmbulanceRequestOrdersModel { String statusText; - int paymentStatus; + num paymentStatus; dynamic clientRequestid; dynamic paymentStatusText; dynamic projectName; String nearestProjectName; - double paymentAmount; + num paymentAmount; WFOrder wFOrder; String serviceText; bool isSentForApproval; - int exaCartOrderId; + num exaCartOrderId; + String exaCartGUID; bool isTimer; - int timeSeconds; - int totalPendingSeconds; - int timeMinute; - int timeHour; - int timeTotalSeconds; - int timeTotalMinute; - int timeTotalHour; + num timeSeconds; + num totalPendingSeconds; + num timeMinute; + num timeHour; + num timeTotalSeconds; + num timeTotalMinute; + num timeTotalHour; dynamic approvalStatus; bool isActive; - int clickButton; + num clickButton; dynamic orderHistory; String pickupLocation; String dropOffLocation; @@ -28,22 +29,21 @@ class AmbulanceRequestOrdersModel { String doctorName; String branch; String time; - dynamic notes; - int id; - String patientId; - int patientOutSa; + String notes; + num iD; + num patientId; + num patientOutSa; bool isOutPatient; - int projectId; - int nearestProjectId; + num projectId; + num nearestProjectId; dynamic longitude; dynamic latitude; dynamic appointmentNo; dynamic dischargeId; - int statusId; - int serviceId; - int channel; + num statusId; + num serviceId; + num channel; Orderpayment orderpayment; - dynamic orderselectedservice; dynamic wforder; dynamic orderapprovalobj; String created; @@ -54,266 +54,293 @@ class AmbulanceRequestOrdersModel { AmbulanceRequestOrdersModel( {this.statusText, - this.paymentStatus, - this.clientRequestid, - this.paymentStatusText, - this.projectName, - this.nearestProjectName, - this.paymentAmount, - this.wFOrder, - this.serviceText, - this.isSentForApproval, - this.exaCartOrderId, - this.isTimer, - this.timeSeconds, - this.totalPendingSeconds, - this.timeMinute, - this.timeHour, - this.timeTotalSeconds, - this.timeTotalMinute, - this.timeTotalHour, - this.approvalStatus, - this.isActive, - this.clickButton, - this.orderHistory, - this.pickupLocation, - this.dropOffLocation, - this.clinicName, - this.doctorName, - this.branch, - this.time, - this.notes, - this.id, - this.patientId, - this.patientOutSa, - this.isOutPatient, - this.projectId, - this.nearestProjectId, - this.longitude, - this.latitude, - this.appointmentNo, - this.dischargeId, - this.statusId, - this.serviceId, - this.channel, - this.orderpayment, - this.orderselectedservice, - this.wforder, - this.orderapprovalobj, - this.created, - this.createdBy, - this.modified, - this.modifiedBy, - this.isDeleted}); + this.paymentStatus, + this.clientRequestid, + this.paymentStatusText, + this.projectName, + this.nearestProjectName, + this.paymentAmount, + this.wFOrder, + this.serviceText, + this.isSentForApproval, + this.exaCartOrderId, + this.exaCartGUID, + this.isTimer, + this.timeSeconds, + this.totalPendingSeconds, + this.timeMinute, + this.timeHour, + this.timeTotalSeconds, + this.timeTotalMinute, + this.timeTotalHour, + this.approvalStatus, + this.isActive, + this.clickButton, + this.orderHistory, + this.pickupLocation, + this.dropOffLocation, + this.clinicName, + this.doctorName, + this.branch, + this.time, + this.notes, + this.iD, + this.patientId, + this.patientOutSa, + this.isOutPatient, + this.projectId, + this.nearestProjectId, + this.longitude, + this.latitude, + this.appointmentNo, + this.dischargeId, + this.statusId, + this.serviceId, + this.channel, + this.orderpayment, + this.wforder, + this.orderapprovalobj, + this.created, + this.createdBy, + this.modified, + this.modifiedBy, + this.isDeleted}); AmbulanceRequestOrdersModel.fromJson(Map json) { - statusText = json['statusText']; - paymentStatus = json['paymentStatus']; - clientRequestid = json['clientRequestid']; - paymentStatusText = json['paymentStatusText']; - projectName = json['projectName']; - nearestProjectName = json['nearestProjectName']; - paymentAmount = json['paymentAmount']; - wFOrder = json['wF_order'] != null ? new WFOrder.fromJson(json['wF_order']) : null; - serviceText = json['serviceText']; + statusText = json['StatusText']; + paymentStatus = json['PaymentStatus']; + clientRequestid = json['ClientRequestid']; + paymentStatusText = json['PaymentStatusText']; + projectName = json['ProjectName']; + nearestProjectName = json['NearestProjectName']; + paymentAmount = json['PaymentAmount']; + wFOrder = json['WF_order'] != null + ? new WFOrder.fromJson(json['WF_order']) + : null; + serviceText = json['ServiceText']; isSentForApproval = json['isSentForApproval']; - exaCartOrderId = json['exaCart_OrderId']; + exaCartOrderId = json['ExaCart_OrderId']; + exaCartGUID = json['ExaCart_GUID']; isTimer = json['isTimer']; - timeSeconds = json['timeSeconds']; - totalPendingSeconds = json['totalPendingSeconds']; - timeMinute = json['timeMinute']; - timeHour = json['timeHour']; - timeTotalSeconds = json['timeTotalSeconds']; - timeTotalMinute = json['timeTotalMinute']; - timeTotalHour = json['timeTotalHour']; - approvalStatus = json['approvalStatus']; + timeSeconds = json['TimeSeconds']; + totalPendingSeconds = json['TotalPendingSeconds']; + timeMinute = json['TimeMinute']; + timeHour = json['TimeHour']; + timeTotalSeconds = json['TimeTotalSeconds']; + timeTotalMinute = json['TimeTotalMinute']; + timeTotalHour = json['TimeTotalHour']; + approvalStatus = json['ApprovalStatus']; isActive = json['isActive']; - clickButton = json['clickButton']; - orderHistory = json['orderHistory']; - pickupLocation = json['pickupLocation']; - dropOffLocation = json['dropOffLocation']; + clickButton = json['ClickButton']; + orderHistory = json['OrderHistory']; + pickupLocation = json['PickupLocation']; + dropOffLocation = json['DropOffLocation']; clinicName = json['clinicName']; - doctorName = json['doctorName']; - branch = json['branch']; - time = json['time']; - notes = json['notes']; - id = json['id']; - patientId = json['patientId']; - patientOutSa = json['patientOutSa']; - isOutPatient = json['isOutPatient']; - projectId = json['projectId']; - nearestProjectId = json['nearestProjectId']; - longitude = json['longitude']; - latitude = json['latitude']; - appointmentNo = json['appointmentNo']; - dischargeId = json['dischargeId']; - statusId = json['statusId']; - serviceId = json['serviceId']; - channel = json['channel']; - orderpayment = json['orderpayment'] != null ? new Orderpayment.fromJson(json['orderpayment']) : null; - orderselectedservice = json['orderselectedservice']; + doctorName = json['DoctorName']; + branch = json['Branch']; + time = json['Time']; + notes = json['Notes']; + iD = json['ID']; + patientId = json['PatientId']; + patientOutSa = json['PatientOutSa']; + isOutPatient = json['IsOutPatient']; + projectId = json['ProjectId']; + nearestProjectId = json['NearestProjectId']; + longitude = json['Longitude']; + latitude = json['Latitude']; + appointmentNo = json['AppointmentNo']; + dischargeId = json['DischargeId']; + statusId = json['StatusId']; + serviceId = json['ServiceId']; + channel = json['Channel']; + orderpayment = json['orderpayment'] != null + ? new Orderpayment.fromJson(json['orderpayment']) + : null; wforder = json['wforder']; orderapprovalobj = json['orderapprovalobj']; - created = json['created']; - createdBy = json['createdBy']; - modified = json['modified']; - modifiedBy = json['modifiedBy']; - isDeleted = json['isDeleted']; + created = json['Created']; + createdBy = json['CreatedBy']; + modified = json['Modified']; + modifiedBy = json['ModifiedBy']; + isDeleted = json['IsDeleted']; } Map toJson() { final Map data = new Map(); - data['statusText'] = this.statusText; - data['paymentStatus'] = this.paymentStatus; - data['clientRequestid'] = this.clientRequestid; - data['paymentStatusText'] = this.paymentStatusText; - data['projectName'] = this.projectName; - data['nearestProjectName'] = this.nearestProjectName; - data['paymentAmount'] = this.paymentAmount; + data['StatusText'] = this.statusText; + data['PaymentStatus'] = this.paymentStatus; + data['ClientRequestid'] = this.clientRequestid; + data['PaymentStatusText'] = this.paymentStatusText; + data['ProjectName'] = this.projectName; + data['NearestProjectName'] = this.nearestProjectName; + data['PaymentAmount'] = this.paymentAmount; if (this.wFOrder != null) { - data['wF_order'] = this.wFOrder.toJson(); + data['WF_order'] = this.wFOrder.toJson(); } - data['serviceText'] = this.serviceText; + data['ServiceText'] = this.serviceText; data['isSentForApproval'] = this.isSentForApproval; - data['exaCart_OrderId'] = this.exaCartOrderId; + data['ExaCart_OrderId'] = this.exaCartOrderId; + data['ExaCart_GUID'] = this.exaCartGUID; data['isTimer'] = this.isTimer; - data['timeSeconds'] = this.timeSeconds; - data['totalPendingSeconds'] = this.totalPendingSeconds; - data['timeMinute'] = this.timeMinute; - data['timeHour'] = this.timeHour; - data['timeTotalSeconds'] = this.timeTotalSeconds; - data['timeTotalMinute'] = this.timeTotalMinute; - data['timeTotalHour'] = this.timeTotalHour; - data['approvalStatus'] = this.approvalStatus; + data['TimeSeconds'] = this.timeSeconds; + data['TotalPendingSeconds'] = this.totalPendingSeconds; + data['TimeMinute'] = this.timeMinute; + data['TimeHour'] = this.timeHour; + data['TimeTotalSeconds'] = this.timeTotalSeconds; + data['TimeTotalMinute'] = this.timeTotalMinute; + data['TimeTotalHour'] = this.timeTotalHour; + data['ApprovalStatus'] = this.approvalStatus; data['isActive'] = this.isActive; - data['clickButton'] = this.clickButton; - data['orderHistory'] = this.orderHistory; - data['pickupLocation'] = this.pickupLocation; - data['dropOffLocation'] = this.dropOffLocation; + data['ClickButton'] = this.clickButton; + data['OrderHistory'] = this.orderHistory; + data['PickupLocation'] = this.pickupLocation; + data['DropOffLocation'] = this.dropOffLocation; data['clinicName'] = this.clinicName; - data['doctorName'] = this.doctorName; - data['branch'] = this.branch; - data['time'] = this.time; - data['notes'] = this.notes; - data['id'] = this.id; - data['patientId'] = this.patientId; - data['patientOutSa'] = this.patientOutSa; - data['isOutPatient'] = this.isOutPatient; - data['projectId'] = this.projectId; - data['nearestProjectId'] = this.nearestProjectId; - data['longitude'] = this.longitude; - data['latitude'] = this.latitude; - data['appointmentNo'] = this.appointmentNo; - data['dischargeId'] = this.dischargeId; - data['statusId'] = this.statusId; - data['serviceId'] = this.serviceId; - data['channel'] = this.channel; + data['DoctorName'] = this.doctorName; + data['Branch'] = this.branch; + data['Time'] = this.time; + data['Notes'] = this.notes; + data['ID'] = this.iD; + data['PatientId'] = this.patientId; + data['PatientOutSa'] = this.patientOutSa; + data['IsOutPatient'] = this.isOutPatient; + data['ProjectId'] = this.projectId; + data['NearestProjectId'] = this.nearestProjectId; + data['Longitude'] = this.longitude; + data['Latitude'] = this.latitude; + data['AppointmentNo'] = this.appointmentNo; + data['DischargeId'] = this.dischargeId; + data['StatusId'] = this.statusId; + data['ServiceId'] = this.serviceId; + data['Channel'] = this.channel; if (this.orderpayment != null) { data['orderpayment'] = this.orderpayment.toJson(); } - data['orderselectedservice'] = this.orderselectedservice; data['wforder'] = this.wforder; data['orderapprovalobj'] = this.orderapprovalobj; - data['created'] = this.created; - data['createdBy'] = this.createdBy; - data['modified'] = this.modified; - data['modifiedBy'] = this.modifiedBy; - data['isDeleted'] = this.isDeleted; + data['Created'] = this.created; + data['CreatedBy'] = this.createdBy; + data['Modified'] = this.modified; + data['ModifiedBy'] = this.modifiedBy; + data['IsDeleted'] = this.isDeleted; return data; } } class WFOrder { - dynamic wfButtonsDTO; - int id; - int orderId; - int previousStep; - int nextStep; - int serviceId; - dynamic order; + Null wfButtonsDTO; + num iD; + num orderId; + num previousStep; + num nextStep; + num serviceId; + Null order; String created; - dynamic createdBy; - dynamic modified; - dynamic modifiedBy; + Null createdBy; + Null modified; + Null modifiedBy; bool isDeleted; - WFOrder({this.wfButtonsDTO, this.id, this.orderId, this.previousStep, this.nextStep, this.serviceId, this.order, this.created, this.createdBy, this.modified, this.modifiedBy, this.isDeleted}); + WFOrder( + {this.wfButtonsDTO, + this.iD, + this.orderId, + this.previousStep, + this.nextStep, + this.serviceId, + this.order, + this.created, + this.createdBy, + this.modified, + this.modifiedBy, + this.isDeleted}); WFOrder.fromJson(Map json) { wfButtonsDTO = json['wf_ButtonsDTO']; - id = json['id']; - orderId = json['orderId']; - previousStep = json['previousStep']; - nextStep = json['nextStep']; - serviceId = json['serviceId']; - order = json['order']; - created = json['created']; - createdBy = json['createdBy']; - modified = json['modified']; - modifiedBy = json['modifiedBy']; - isDeleted = json['isDeleted']; + iD = json['ID']; + orderId = json['OrderId']; + previousStep = json['PreviousStep']; + nextStep = json['NextStep']; + serviceId = json['ServiceId']; + order = json['Order']; + created = json['Created']; + createdBy = json['CreatedBy']; + modified = json['Modified']; + modifiedBy = json['ModifiedBy']; + isDeleted = json['IsDeleted']; } Map toJson() { final Map data = new Map(); data['wf_ButtonsDTO'] = this.wfButtonsDTO; - data['id'] = this.id; - data['orderId'] = this.orderId; - data['previousStep'] = this.previousStep; - data['nextStep'] = this.nextStep; - data['serviceId'] = this.serviceId; - data['order'] = this.order; - data['created'] = this.created; - data['createdBy'] = this.createdBy; - data['modified'] = this.modified; - data['modifiedBy'] = this.modifiedBy; - data['isDeleted'] = this.isDeleted; + data['ID'] = this.iD; + data['OrderId'] = this.orderId; + data['PreviousStep'] = this.previousStep; + data['NextStep'] = this.nextStep; + data['ServiceId'] = this.serviceId; + data['Order'] = this.order; + data['Created'] = this.created; + data['CreatedBy'] = this.createdBy; + data['Modified'] = this.modified; + data['ModifiedBy'] = this.modifiedBy; + data['IsDeleted'] = this.isDeleted; return data; } } class Orderpayment { - int id; - int orderId; - dynamic clientRequestId; - double totalAmount; - int paymentStatus; - dynamic order; + num iD; + num orderId; + Null clientRequestId; + num totalAmount; + num paymentStatus; + Null order; String created; - dynamic createdBy; - dynamic modified; - dynamic modifiedBy; + Null createdBy; + Null modified; + Null modifiedBy; bool isDeleted; - Orderpayment({this.id, this.orderId, this.clientRequestId, this.totalAmount, this.paymentStatus, this.order, this.created, this.createdBy, this.modified, this.modifiedBy, this.isDeleted}); + Orderpayment( + {this.iD, + this.orderId, + this.clientRequestId, + this.totalAmount, + this.paymentStatus, + this.order, + this.created, + this.createdBy, + this.modified, + this.modifiedBy, + this.isDeleted}); Orderpayment.fromJson(Map json) { - id = json['id']; - orderId = json['orderId']; - clientRequestId = json['clientRequestId']; - totalAmount = json['totalAmount']; - paymentStatus = json['paymentStatus']; - order = json['order']; - created = json['created']; - createdBy = json['createdBy']; - modified = json['modified']; - modifiedBy = json['modifiedBy']; - isDeleted = json['isDeleted']; + iD = json['ID']; + orderId = json['OrderId']; + clientRequestId = json['ClientRequestId']; + totalAmount = json['TotalAmount']; + paymentStatus = json['PaymentStatus']; + order = json['Order']; + created = json['Created']; + createdBy = json['CreatedBy']; + modified = json['Modified']; + modifiedBy = json['ModifiedBy']; + isDeleted = json['IsDeleted']; } Map toJson() { final Map data = new Map(); - data['id'] = this.id; - data['orderId'] = this.orderId; - data['clientRequestId'] = this.clientRequestId; - data['totalAmount'] = this.totalAmount; - data['paymentStatus'] = this.paymentStatus; - data['order'] = this.order; - data['created'] = this.created; - data['createdBy'] = this.createdBy; - data['modified'] = this.modified; - data['modifiedBy'] = this.modifiedBy; - data['isDeleted'] = this.isDeleted; + data['ID'] = this.iD; + data['OrderId'] = this.orderId; + data['ClientRequestId'] = this.clientRequestId; + data['TotalAmount'] = this.totalAmount; + data['PaymentStatus'] = this.paymentStatus; + data['Order'] = this.order; + data['Created'] = this.created; + data['CreatedBy'] = this.createdBy; + data['Modified'] = this.modified; + data['ModifiedBy'] = this.modifiedBy; + data['IsDeleted'] = this.isDeleted; return data; } } diff --git a/lib/core/model/er/PatientER_RC.dart b/lib/core/model/er/PatientER_RC.dart index ec564128..6abec2d6 100644 --- a/lib/core/model/er/PatientER_RC.dart +++ b/lib/core/model/er/PatientER_RC.dart @@ -10,7 +10,7 @@ class PatientER_RC { String sessionID; bool isDentalAllowedBackend; int deviceTypeID; - String patientID; + int patientID; String tokenID; int patientTypeID; int patientType; diff --git a/lib/core/model/er/get_all_transportation_method_list_model.dart b/lib/core/model/er/get_all_transportation_method_list_model.dart index 1f0a91c3..530b4f25 100644 --- a/lib/core/model/er/get_all_transportation_method_list_model.dart +++ b/lib/core/model/er/get_all_transportation_method_list_model.dart @@ -1,5 +1,5 @@ class PatientERTransportationMethod { - int id; + int iD; String serviceID; int orderServiceID; String text; @@ -12,7 +12,7 @@ class PatientERTransportationMethod { int quantity; PatientERTransportationMethod( - {this.id, + {this.iD, this.serviceID, this.orderServiceID, this.text, @@ -25,32 +25,32 @@ class PatientERTransportationMethod { this.quantity}); PatientERTransportationMethod.fromJson(Map json) { - id = json['id']; - serviceID = json['serviceID']; - orderServiceID = json['orderServiceID']; - text = json['text']; - textN = json['textN']; - price = json['price']; - priceVAT = json['priceVAT']; - priceTotal = json['priceTotal']; - isEnabled = json['isEnabled']; - orderId = json['orderId']; - quantity = json['quantity']; + iD = json['ID']; + serviceID = json['ServiceID']; + orderServiceID = json['OrderServiceID']; + text = json['Text']; + textN = json['TextN']; + price = json['Price']; + priceVAT = json['PriceVAT']; + priceTotal = json['PriceTotal']; + isEnabled = json['IsEnabled']; + orderId = json['OrderId']; + quantity = json['Quantity']; } Map toJson() { final Map data = new Map(); - data['id'] = this.id; - data['serviceID'] = this.serviceID; - data['orderServiceID'] = this.orderServiceID; - data['text'] = this.text; - data['textN'] = this.textN; - data['price'] = this.price; - data['priceVAT'] = this.priceVAT; - data['priceTotal'] = this.priceTotal; - data['isEnabled'] = this.isEnabled; - data['orderId'] = this.orderId; - data['quantity'] = this.quantity; + data['ID'] = this.iD; + data['ServiceID'] = this.serviceID; + data['OrderServiceID'] = this.orderServiceID; + data['Text'] = this.text; + data['TextN'] = this.textN; + data['Price'] = this.price; + data['PriceVAT'] = this.priceVAT; + data['PriceTotal'] = this.priceTotal; + data['IsEnabled'] = this.isEnabled; + data['OrderId'] = this.orderId; + data['Quantity'] = this.quantity; return data; } } diff --git a/lib/core/model/prescriptions/prescription_info_rc_model.dart b/lib/core/model/prescriptions/prescription_info_rc_model.dart new file mode 100644 index 00000000..23c4ad55 --- /dev/null +++ b/lib/core/model/prescriptions/prescription_info_rc_model.dart @@ -0,0 +1,52 @@ +class PrescriptionInfoRCModel { + String itemDescription; + String image; + String sKU; + dynamic productId; + dynamic productName; + int quantity; + int orderId; + int totalPrice; + int dispenseQuantity; + dynamic itemhand; + + PrescriptionInfoRCModel( + {this.itemDescription, + this.image, + this.sKU, + this.productId, + this.productName, + this.quantity, + this.orderId, + this.totalPrice, + this.dispenseQuantity, + this.itemhand}); + + PrescriptionInfoRCModel.fromJson(Map json) { + itemDescription = json['ItemDescription']; + image = json['image']; + sKU = json['SKU']; + productId = json['ProductId']; + productName = json['ProductName']; + quantity = json['Quantity']; + orderId = json['OrderId']; + totalPrice = json['TotalPrice']; + dispenseQuantity = json['DispenseQuantity']; + itemhand = json['itemhand']; + } + + Map toJson() { + final Map data = new Map(); + data['ItemDescription'] = this.itemDescription; + data['image'] = this.image; + data['SKU'] = this.sKU; + data['ProductId'] = this.productId; + data['ProductName'] = this.productName; + data['Quantity'] = this.quantity; + data['OrderId'] = this.orderId; + data['TotalPrice'] = this.totalPrice; + data['DispenseQuantity'] = this.dispenseQuantity; + data['itemhand'] = this.itemhand; + return data; + } +} diff --git a/lib/core/service/AlHabibMedicalService/cmc_service.dart b/lib/core/service/AlHabibMedicalService/cmc_service.dart index 7fc23cc9..c6c2d82f 100644 --- a/lib/core/service/AlHabibMedicalService/cmc_service.dart +++ b/lib/core/service/AlHabibMedicalService/cmc_service.dart @@ -28,7 +28,7 @@ class CMCService extends BaseService { hasError = false; // RC IMPLEMENTATION - await baseAppClient.post(GET_ALL_CMC_SERVICES_RC + "?patientID=" + user.patientID.toString(), isAllowAny: true, onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(GET_ALL_CMC_SERVICES_RC + "?patientID=" + user.patientID.toString(), isRCService: true, isAllowAny: true, onSuccess: (dynamic response, int statusCode) { cmcAllServicesList.clear(); response['response'].forEach((data) { cmcAllServicesList.add(GetCMCServicesResponseModel.fromJson(data)); @@ -67,7 +67,7 @@ class CMCService extends BaseService { Future getCmcAllPresOrdersRC() async { GetHHCAllPresOrdersRequestModel getHHCAllPresOrdersRequestModel = GetHHCAllPresOrdersRequestModel(); hasError = false; - await baseAppClient.post(GET_ALL_CMC_ORDERS_RC, onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(GET_ALL_CMC_ORDERS_RC, isRCService: true, onSuccess: (dynamic response, int statusCode) { cmcAllPresOrdersList.clear(); cmcAllOrderDetail.clear(); @@ -122,7 +122,7 @@ class CMCService extends BaseService { Future updateCmcPresOrderRC(UpdatePresOrderRequestModel updatePresOrderRequestModel) async { hasError = false; - await baseAppClient.post(UPDATE_CMC_ORDER_RC, onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(UPDATE_CMC_ORDER_RC, isRCService: true, onSuccess: (dynamic response, int statusCode) { isOrderUpdated = true; }, onFailure: (String error, int statusCode) { hasError = true; @@ -133,7 +133,7 @@ class CMCService extends BaseService { Future insertCMCOrderRC({CMCInsertPresOrderRequestModel order}) async { hasError = false; String reqId = ""; - await baseAppClient.post(ADD_CMC_ORDER_RC, onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(ADD_CMC_ORDER_RC, isRCService: true, onSuccess: (dynamic response, int statusCode) { isOrderUpdated = true; reqId = response['response'].toString(); }, onFailure: (String error, int statusCode) { diff --git a/lib/core/service/AlHabibMedicalService/home_health_care_service.dart b/lib/core/service/AlHabibMedicalService/home_health_care_service.dart index cd90dae5..99220b07 100644 --- a/lib/core/service/AlHabibMedicalService/home_health_care_service.dart +++ b/lib/core/service/AlHabibMedicalService/home_health_care_service.dart @@ -38,7 +38,7 @@ class HomeHealthCareService extends BaseService { Future getHHCAllServicesRC(HHCGetAllServicesRequestModel hHCGetAllServicesRequestModel) async { hasError = false; - await baseAppClient.post(HHC_GET_ALL_SERVICES_RC + "?PatientID=" + user.patientID.toString(), onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(HHC_GET_ALL_SERVICES_RC + "?PatientID=" + user.patientID.toString(), isRCService: true, onSuccess: (dynamic response, int statusCode) { hhcAllServicesList.clear(); response['response'].forEach((data) { hhcAllServicesList.add(HHCGetAllServicesResponseModel.fromJson(data)); @@ -52,7 +52,7 @@ class HomeHealthCareService extends BaseService { Future getHHCAllPresOrdersRC() async { GetHHCAllPresOrdersRequestModel getHHCAllPresOrdersRequestModel = GetHHCAllPresOrdersRequestModel(); hasError = false; - await baseAppClient.post(GET_ALL_HHC_ORDERS_RC, onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(GET_ALL_HHC_ORDERS_RC, isRCService: true, onSuccess: (dynamic response, int statusCode) { hhcAllPresOrdersList.clear(); hhcAllOrderDetail.clear(); response['response'].forEach((data) { @@ -106,7 +106,7 @@ class HomeHealthCareService extends BaseService { Future updateHHCPresOrderRC(UpdatePresOrderRequestModel updatePresOrderRequestModel) async { hasError = false; - await baseAppClient.post(UPDATE_HHC_ORDER_RC, onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(UPDATE_HHC_ORDER_RC, isRCService: true, onSuccess: (dynamic response, int statusCode) { isOrderUpdated = true; }, onFailure: (String error, int statusCode) { hasError = true; @@ -127,7 +127,7 @@ class HomeHealthCareService extends BaseService { Future insertHHCOrderRC({PatientERInsertPresOrderRequestModel order}) async { hasError = false; - await baseAppClient.post(ADD_HHC_ORDER_RC, onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(ADD_HHC_ORDER_RC, isRCService: true, onSuccess: (dynamic response, int statusCode) { hhcResponse = response; requestNo = response["response"]; }, onFailure: (String error, int statusCode) { diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 19c8eac2..696cda28 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -35,12 +35,20 @@ VitalSignService _vitalSignService = locator(); class BaseAppClient { post(String endPoint, - {Map body, Function(dynamic response, int statusCode) onSuccess, Function(String error, int statusCode) onFailure, bool isAllowAny = false, bool isExternal = false}) async { + {Map body, + Function(dynamic response, int statusCode) onSuccess, + Function(String error, int statusCode) onFailure, + bool isAllowAny = false, + bool isExternal = false, + bool isRCService = false}) async { String url; if (isExternal) { url = endPoint; } else { - url = BASE_URL + endPoint; + if (isRCService) + url = RC_BASE_URL + endPoint; + else + url = BASE_URL + endPoint; } try { //Map profile = await sharedPref.getObj(DOCTOR_PROFILE); @@ -376,12 +384,20 @@ class BaseAppClient { Navigator.pushReplacement(context, FadePage(page: AppUpdatePage(appUpdateText: text))); } - get(String endPoint, {Function(dynamic response, int statusCode) onSuccess, Function(String error, int statusCode) onFailure, Map queryParams, bool isExternal = false}) async { + get(String endPoint, + {Function(dynamic response, int statusCode) onSuccess, + Function(String error, int statusCode) onFailure, + Map queryParams, + bool isExternal = false, + bool isRCService = false}) async { String url; if (isExternal) { url = endPoint; } else { - url = BASE_URL + endPoint; + if (isRCService) + url = RC_BASE_URL + endPoint; + else + url = BASE_URL + endPoint; } if (queryParams != null) { String queryString = Uri(queryParameters: queryParams).query; diff --git a/lib/core/service/er/am_service.dart b/lib/core/service/er/am_service.dart index 9c66d373..a76ae73a 100644 --- a/lib/core/service/er/am_service.dart +++ b/lib/core/service/er/am_service.dart @@ -28,9 +28,9 @@ class AmService extends BaseService { Map body = Map(); body['isDentalAllowedBackend'] = false; body['IdentificationNo'] = user.patientIdentificationNo; - await baseAppClient.get(GET_ALL_TRANSPORTATIONS_RC + "?patientID=" + user.patientID.toString(), isExternal: false, onSuccess: (dynamic response, int statusCode) { + await baseAppClient.get(GET_ALL_TRANSPORTATIONS_RC + "?patientID=" + user.patientID.toString(), isRCService: true, isExternal: false, onSuccess: (dynamic response, int statusCode) { amModelList.clear(); - response['data']['transportationservices'].forEach((item) { + response['response']['transportationservices'].forEach((item) { amModelList.add(PatientERTransportationMethod.fromJson(item)); }); }, onFailure: (String error, int statusCode) { @@ -69,18 +69,18 @@ class AmService extends BaseService { pickUpRequestPresOrder = null; Map body = Map(); - body['patientId'] = patientID.toString(); - body['PatientID'] = patientID.toString(); + body['patientId'] = patientID; + body['PatientID'] = patientID; - await baseAppClient.post(GET_ALL_TRANSPORTATIONS_ORDERS, onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(GET_ALL_TRANSPORTATIONS_ORDERS, isRCService: true, onSuccess: (dynamic response, int statusCode) { patientAmbulanceRequestOrdersList.clear(); hasPendingOrder = false; pendingOrderID = 0; pendingAmbulanceRequestOrder = null; - response['data'].forEach((item) { + response['response'].forEach((item) { patientAmbulanceRequestOrdersList.add(AmbulanceRequestOrdersModel.fromJson(item)); - if (item['statusId'] == 1) { + if (item['StatusId'] == 1) { hasPendingOrder = true; pendingOrderID = item['orderpayment']['id']; pendingOrderStatus = item['statusText']; @@ -127,14 +127,14 @@ class AmService extends BaseService { }, body: body); } - Future updatePressOrderRC({@required int presOrderID, @required String patientID}) async { + Future updatePressOrderRC({@required int presOrderID, @required int patientID}) async { hasError = false; Map body = Map(); body['Id'] = presOrderID; body['StatusId'] = 6; body['ClickButton'] = 14; body['PatientID'] = patientID; - await baseAppClient.post(CANCEL_AMBULANCE_REQUEST, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { + await baseAppClient.post(CANCEL_AMBULANCE_REQUEST, isRCService: true, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); @@ -146,7 +146,7 @@ class AmService extends BaseService { var body = patientER.toJson(); print(body); - await baseAppClient.post(INSERT_TRANSPORTATION_ORDER_RC, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { + await baseAppClient.post(INSERT_TRANSPORTATION_ORDER_RC, isRCService: true, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); diff --git a/lib/core/service/medical/prescriptions_service.dart b/lib/core/service/medical/prescriptions_service.dart index 48c4f1bf..4349f218 100644 --- a/lib/core/service/medical/prescriptions_service.dart +++ b/lib/core/service/medical/prescriptions_service.dart @@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/GetCMCAllOrdersResponseModel.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/Prescriptions.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/perscription_pharmacy.dart'; +import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_info_rc_model.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report_enh.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report_inp.dart'; @@ -18,6 +19,7 @@ class PrescriptionsService extends BaseService { List prescriptionsList = List(); List prescriptionReportListINP = List(); List prescriptionsOrderList = List(); + List prescriptionsOrderListRC = List(); var isMedDeliveryAllowed; Future getPrescriptions() async { @@ -49,6 +51,20 @@ class PrescriptionsService extends BaseService { }, body: body); } + Future getPrescriptionsInfoRC(int orderID, dynamic patientID) async { + prescriptionsOrderListRC.clear(); + Map body = Map(); + body['ID'] = orderID; + await baseAppClient.post(GET_ALL_PRESCRIPTION_INFO_RC + "?PatientId=" + patientID.toString(), onSuccess: (dynamic response, int statusCode) { + response['response']['report'].forEach((prescriptionsOrder) { + prescriptionsOrderListRC.add(PrescriptionInfoRCModel.fromJson(prescriptionsOrder)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } + Future getPrescriptionsOrdersRC() async { prescriptionsOrderList.clear(); Map body = Map(); @@ -162,7 +178,6 @@ class PrescriptionsService extends BaseService { List prescriptionReportEnhList = List(); Future getPrescriptionReportEnh({PrescriptionsOrder prescriptionsOrder}) async { - ///This logic copy from the old app from class [order-history.component.ts] in line 45 bool isInPatient = false; prescriptionsList.forEach((element) { if (prescriptionsOrder.appointmentNo == "0") { @@ -184,8 +199,6 @@ class PrescriptionsService extends BaseService { _requestPrescriptionReportEnh.setupID = element.setupID; _requestPrescriptionReportEnh.dischargeNo = element.dischargeNo; isInPatient = element.isInOutPatient; - - ///call inpGetPrescriptionReport } } }); @@ -212,6 +225,19 @@ class PrescriptionsService extends BaseService { }, body: _requestPrescriptionReportEnh.toJson()); } + Future updatePressOrderRC({@required int presOrderID, @required String patientID}) async { + hasError = false; + Map body = Map(); + body['Id'] = presOrderID; + body['StatusId'] = 6; + body['ClickButton'] = 14; + body['PatientID'] = patientID; + await baseAppClient.post(UPDATE_PRESCRIPTION_ORDER_RC, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } + Future updatePressOrder({@required int presOrderID}) async { hasError = false; Map body = Map(); diff --git a/lib/core/viewModels/er/am_request_view_model.dart b/lib/core/viewModels/er/am_request_view_model.dart index ac1b934e..aff532d7 100644 --- a/lib/core/viewModels/er/am_request_view_model.dart +++ b/lib/core/viewModels/er/am_request_view_model.dart @@ -106,7 +106,7 @@ class AmRequestViewModel extends BaseViewModel { Future updatePressOrder({@required int presOrderID}) async { setState(ViewState.Busy); // await _amService.updatePressOrder(presOrderID: presOrderID); - await _amService.updatePressOrderRC(presOrderID: presOrderID, patientID: authenticatedUserObject.user.patientID.toString()); + await _amService.updatePressOrderRC(presOrderID: presOrderID, patientID: authenticatedUserObject.user.patientID); if (_amService.hasError) { error = _amService.error; setState(ViewState.Error); diff --git a/lib/core/viewModels/er/rrt-view-model.dart b/lib/core/viewModels/er/rrt-view-model.dart index 60411fab..093c29b6 100644 --- a/lib/core/viewModels/er/rrt-view-model.dart +++ b/lib/core/viewModels/er/rrt-view-model.dart @@ -62,7 +62,7 @@ class RRTViewModel extends BaseViewModel { // body['OrderServiceID'] = 5; var localRes; int requestNo; - await _service.baseAppClient.post(ADD_RRT_ORDER_RC, body: body, onSuccess: (response, statusCode) { + await _service.baseAppClient.post(ADD_RRT_ORDER_RC, isRCService: true, body: body, onSuccess: (response, statusCode) { requestNo = response['response']; }, onFailure: (error, statusCode) { AppToast.showErrorToast(message: error); @@ -94,7 +94,7 @@ class RRTViewModel extends BaseViewModel { } Future<_RRTServiceData> getAllOrdersRC() async { - await _service.baseAppClient.post(GET_ALL_RRT_ORDERS_RC, body: {}, onSuccess: (response, statusCode) { + await _service.baseAppClient.post(GET_ALL_RRT_ORDERS_RC, isRCService: true, body: {}, onSuccess: (response, statusCode) { var data = response["response"]; rrtServiceData.completedOrders.clear(); rrtServiceData.pendingOrders.clear(); @@ -161,7 +161,7 @@ class RRTViewModel extends BaseViewModel { Future cancelOrderRC(GetCMCAllOrdersResponseModel order, {String reason = ""}) async { Map body = {"Id": order.iD, "ClickButton": 16}; var success = false; - await _service.baseAppClient.post(UPDATE_RRT_ORDER_RC, body: body, onSuccess: (response, statusCode) { + await _service.baseAppClient.post(UPDATE_RRT_ORDER_RC, isRCService: true, body: body, onSuccess: (response, statusCode) { success = true; rrtServiceData.pendingOrders.remove(order); }, onFailure: (error, statusCode) { diff --git a/lib/core/viewModels/medical/prescriptions_view_model.dart b/lib/core/viewModels/medical/prescriptions_view_model.dart index be6153bd..f480fb56 100644 --- a/lib/core/viewModels/medical/prescriptions_view_model.dart +++ b/lib/core/viewModels/medical/prescriptions_view_model.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/GetCMCAllOrdersResponseModel.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/perscription_pharmacy.dart'; +import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_info_rc_model.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report_enh.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report_inp.dart'; @@ -31,6 +32,10 @@ class PrescriptionsViewModel extends BaseViewModel { List get pharmacyPrescriptionsList => _prescriptionsService.pharmacyPrescriptionsList; + List get prescriptionReportEnhList => _prescriptionsService.prescriptionReportEnhList; + + List get prescriptionsOrderListRC => _prescriptionsService.prescriptionsOrderListRC; + List get prescriptionsOrderList => filterType == FilterType.Clinic ? _prescriptionsOrderListClinic : _prescriptionsOrderListHospital; List prescriptionsOrderListByValue(filterValue) { @@ -131,8 +136,6 @@ class PrescriptionsViewModel extends BaseViewModel { } } - List get prescriptionReportEnhList => _prescriptionsService.prescriptionReportEnhList; - getPrescriptionReportEnh({PrescriptionsOrder prescriptionsOrder}) async { setState(ViewState.Busy); await _prescriptionsService.getPrescriptionReportEnh(prescriptionsOrder: prescriptionsOrder); @@ -144,9 +147,21 @@ class PrescriptionsViewModel extends BaseViewModel { } } + getPrescriptionReportDetailsRC() async { + setState(ViewState.Busy); + await _prescriptionsService.getPrescriptionsInfoRC(4, 2001273); + if (_prescriptionsService.hasError) { + error = _prescriptionsService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } + Future updatePressOrder({@required int presOrderID}) async { setState(ViewState.Busy); - await _prescriptionsService.updatePressOrder(presOrderID: presOrderID); + // await _prescriptionsService.updatePressOrder(presOrderID: presOrderID); + await _prescriptionsService.updatePressOrderRC(presOrderID: presOrderID); if (_prescriptionsService.hasError) { error = _prescriptionsService.error; setState(ViewState.Error); diff --git a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/orders_log_details_page.dart b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/orders_log_details_page.dart index d3c7f970..48b904aa 100644 --- a/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/orders_log_details_page.dart +++ b/lib/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/orders_log_details_page.dart @@ -56,7 +56,7 @@ class OrdersLogDetailsPage extends StatelessWidget { return AppScaffold( isShowAppBar: false, baseViewModel: model, - body: ListView.separated( + body: model.cmcAllPresOrders.length > 0 ? ListView.separated( padding: EdgeInsets.all(21), physics: BouncingScrollPhysics(), itemBuilder: (context, index) { @@ -178,7 +178,7 @@ class OrdersLogDetailsPage extends StatelessWidget { ); }, separatorBuilder: (context, index) => SizedBox(height: 12), - itemCount: model.cmcAllPresOrders.length), + itemCount: model.cmcAllPresOrders.length) : getNoDataWidget(context), ); } } diff --git a/lib/pages/Blood/blood_donation.dart b/lib/pages/Blood/blood_donation.dart index db96a5a1..d9dbcf4b 100644 --- a/lib/pages/Blood/blood_donation.dart +++ b/lib/pages/Blood/blood_donation.dart @@ -3,7 +3,6 @@ import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart'; import 'package:diplomaticquarterapp/core/model/blooddonation/blood_groub_details.dart'; import 'package:diplomaticquarterapp/core/model/blooddonation/get_all_cities.dart'; import 'package:diplomaticquarterapp/core/model/my_balance/AdvanceModel.dart'; -import 'package:diplomaticquarterapp/core/model/my_balance/patient_info.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/my_balance_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; @@ -34,8 +33,6 @@ class BloodDonationPage extends StatefulWidget { } class _BloodDonationPageState extends State { - TextEditingController _fileTextController = TextEditingController(); - TextEditingController _notesTextController = TextEditingController(); BeneficiaryType beneficiaryType = BeneficiaryType.NON; CitiesModel _selectedHospital; @@ -43,10 +40,10 @@ class _BloodDonationPageState extends State { int _selectedHospitalIndex = 0; int _selectedGenderIndex = 1; int _selectedBloodTypeIndex = 0; + String _selectedBloodType = "O+"; String amount = ""; String email; - PatientInfo _selectedPatientInfo; AuthenticatedUser authenticatedUser; GetAllSharedRecordsByStatusList selectedPatientFamily; AdvanceModel advanceModel = AdvanceModel(); @@ -71,7 +68,6 @@ class _BloodDonationPageState extends State { int getSelectedCityID(MyBalanceViewModel model) { int cityID = 1; - model.CitiesModelList.forEach((element) { if (element.description == model.bloodModelList[0].city) { cityID = element.iD; @@ -96,6 +92,8 @@ class _BloodDonationPageState extends State { citiesModel.description = model.CitiesModelList[_selectedHospitalIndex].description; citiesModel.descriptionN = model.CitiesModelList[_selectedHospitalIndex].descriptionN; _selectedHospital = citiesModel; + _selectedBloodType = model.bloodModelList[0].bloodGroup; + _selectedBloodTypeIndex = getBloodIndex(_selectedBloodType); } else { _selectedHospital = model.CitiesModelList[0]; } @@ -168,7 +166,7 @@ class _BloodDonationPageState extends State { ); }).withBorderedContainer, SizedBox(height: 12), - CommonDropDownView(TranslationBase.of(context).bloodType, model.bloodModelList.isNotEmpty ? model.bloodModelList[0].bloodGroup : getBlood(_selectedBloodTypeIndex), () { + CommonDropDownView(TranslationBase.of(context).bloodType, _selectedBloodType, () { List list = [ RadioSelectionDialogModel("O+", 0), RadioSelectionDialogModel("O-", 1), @@ -188,6 +186,7 @@ class _BloodDonationPageState extends State { isScrollable: true, onValueSelected: (index) { _selectedBloodTypeIndex = index; + _selectedBloodType = getBlood(index); setState(() {}); }, ), @@ -321,6 +320,41 @@ class _BloodDonationPageState extends State { } } + int getBloodIndex(String type) { + switch (type) { + case "O+": + return 0; + break; + case "O-": + return 1; + break; + case "AB+": + return 2; + break; + case "AB-": + return 3; + break; + case "A+": + return 4; + break; + case "A-": + return 5; + break; + case "B-": + return 6; + break; + case "B-": + return 7; + break; + case "B+": + return 8; + break; + + default: + return 0; + } + } + String getHospitalName(ProjectViewModel projectProvider, BuildContext context) { if (_selectedHospital != null) return projectProvider.isArabic ? _selectedHospital.descriptionN : _selectedHospital.description; diff --git a/lib/pages/DrawerPages/family/add-family-member.dart b/lib/pages/DrawerPages/family/add-family-member.dart index 320ca8d1..9fb20630 100644 --- a/lib/pages/DrawerPages/family/add-family-member.dart +++ b/lib/pages/DrawerPages/family/add-family-member.dart @@ -168,7 +168,10 @@ class _AddMember extends State { request.regionID = 1; } loading(true); - familyFileProvider.insertNewMember(request).then((value) => sendActivationCode(value)); + familyFileProvider.insertNewMember(request).then((value) => sendActivationCode(value)).catchError((err){ + loading(false); + AppToast.showErrorToast(message: err); + }); } sendActivationCode(result) { diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart index bf8cc676..bbae70a5 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/core/model/er/PatientER.dart'; import 'package:diplomaticquarterapp/core/model/er/PatientER_RC.dart'; import 'package:diplomaticquarterapp/core/viewModels/er/am_request_view_model.dart'; import 'package:diplomaticquarterapp/pages/ErService/widgets/StepsWidget.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/others/OrderLogItem.dart'; @@ -20,8 +21,7 @@ class AmbulanceRequestIndexPage extends StatefulWidget { AmbulanceRequestIndexPage({Key key, this.amRequestViewModel}); @override - _AmbulanceRequestIndexPageState createState() => - _AmbulanceRequestIndexPageState(); + _AmbulanceRequestIndexPageState createState() => _AmbulanceRequestIndexPageState(); } class _AmbulanceRequestIndexPageState extends State { @@ -37,8 +37,7 @@ class _AmbulanceRequestIndexPageState extends State { setState(() { currentIndex = tab; }); - pageController.animateToPage(tab, - duration: Duration(milliseconds: 800), curve: Curves.easeOutQuart); + pageController.animateToPage(tab, duration: Duration(milliseconds: 800), curve: Curves.easeOutQuart); } @override @@ -53,7 +52,7 @@ class _AmbulanceRequestIndexPageState extends State { return AppScaffold( body: widget.amRequestViewModel.pendingAmbulanceRequestOrder != null ? SingleChildScrollView( - child: Column( + child: Column( children: [ SizedBox( height: 10, @@ -69,9 +68,7 @@ class _AmbulanceRequestIndexPageState extends State { children: [ OrderLogItem( title: TranslationBase.of(context).reqId, - value: widget.amRequestViewModel.pendingAmbulanceRequestOrder - .id - .toString(), + value: widget.amRequestViewModel.pendingAmbulanceRequestOrder.iD.toString(), ), OrderLogItem( title: TranslationBase.of(context).status, @@ -79,22 +76,19 @@ class _AmbulanceRequestIndexPageState extends State { ), OrderLogItem( title: TranslationBase.of(context).pickupDate, - value: getDate(widget.amRequestViewModel.pendingAmbulanceRequestOrder.created), + value: DateUtil.getDayMonthYearDateFormatted(DateTime.tryParse(widget.amRequestViewModel.pendingAmbulanceRequestOrder.created)), ), OrderLogItem( title: TranslationBase.of(context).pickupLocation, - value: widget.amRequestViewModel.pendingAmbulanceRequestOrder - .pickupLocation, + value: widget.amRequestViewModel.pendingAmbulanceRequestOrder.pickupLocation, ), OrderLogItem( title: TranslationBase.of(context).dropoffLocation, - value: widget.amRequestViewModel.pendingAmbulanceRequestOrder - .dropOffLocation, + value: widget.amRequestViewModel.pendingAmbulanceRequestOrder.dropOffLocation, ), OrderLogItem( title: TranslationBase.of(context).transportMethod, - value: widget - .amRequestViewModel.pendingAmbulanceRequestOrder.serviceText, + value: widget.amRequestViewModel.pendingAmbulanceRequestOrder.serviceText, ), Container( padding: EdgeInsets.all(10), @@ -111,9 +105,7 @@ class _AmbulanceRequestIndexPageState extends State { textColor: Colors.white, label: TranslationBase.of(context).cancel, onTap: () { - widget.amRequestViewModel.updatePressOrder( - presOrderID: widget.amRequestViewModel - .pendingAmbulanceRequestOrder.id); + widget.amRequestViewModel.updatePressOrder(presOrderID: widget.amRequestViewModel.pendingAmbulanceRequestOrder.iD); }, ), ) @@ -122,7 +114,7 @@ class _AmbulanceRequestIndexPageState extends State { ), ], ), - ) + ) : Column( children: [ SizedBox( @@ -172,9 +164,4 @@ class _AmbulanceRequestIndexPageState extends State { ), ); } - - String getDate(String date) { - return date.split("T")[0]; - } - } diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart index d05fae2f..850d308a 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart @@ -411,7 +411,7 @@ class _PickupLocationState extends State { widget.patientER_RC.transportationDetails.pickupDateTime = DateUtil.convertDateToStringLocation(DateTime.now()); widget.patientER_RC.transportationDetails.pickupLocationName = widget.patientER.direction == 0 ? _selectedHospital.name : _result.formattedAddress; widget.patientER_RC.projectID = widget.amRequestViewModel.user.projectID; - widget.patientER_RC.patientID = widget.amRequestViewModel.user.patientID.toString(); + widget.patientER_RC.patientID = widget.amRequestViewModel.user.patientID; widget.patientER_RC.transportationDetails.requesterIsOutSA = false; // widget.patientER.lineItemNo = 0; widget.patientER_RC.transportationDetails.requesterMobileNo = widget.amRequestViewModel.user.mobileNumber; diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/SelectTransportationMethod.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/SelectTransportationMethod.dart index d2a74505..0a187918 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/SelectTransportationMethod.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/SelectTransportationMethod.dart @@ -302,7 +302,7 @@ class _SelectTransportationMethodState extends State widget.patientER_RC.transportationDetails.direction = _direction == Direction.ToHospital ? 1 : 0; widget.patientER_RC.transportationDetails.tripType = _way == Way.TwoWays ? 0 : 1; widget.patientER_RC.transportationDetails.ambulate = (widget.amRequestViewModel.amRequestModeList.indexOf(_erTransportationMethod) + 1); - widget.patientER_RC.transportationDetails.transportationType = _erTransportationMethod.id.toString(); + widget.patientER_RC.transportationDetails.transportationType = _erTransportationMethod.iD.toString(); widget.patientER_RC.patientERTransportationMethod = _erTransportationMethod; widget.patientER_RC.transportationDetails.pickupUrgency = 1; // widget.patientER.orderServiceID = _orderService.getIdOrderService(); diff --git a/lib/pages/ErService/OrderLogPage.dart b/lib/pages/ErService/OrderLogPage.dart index 3d492c83..4ecde680 100644 --- a/lib/pages/ErService/OrderLogPage.dart +++ b/lib/pages/ErService/OrderLogPage.dart @@ -28,7 +28,7 @@ class OrderLogPage extends StatelessWidget { children: [ OrderLogItem( title: TranslationBase.of(context).reqId, - value: amRequestViewModel.patientAmbulanceRequestOrdersList[index].id.toString(), + value: amRequestViewModel.patientAmbulanceRequestOrdersList[index].iD.toString(), ), OrderLogItem( title: TranslationBase.of(context).orderStatus, @@ -62,7 +62,7 @@ class OrderLogPage extends StatelessWidget { textColor: Colors.white, label: TranslationBase.of(context).cancel, onTap: () { - amRequestViewModel.updatePressOrder(presOrderID: amRequestViewModel.pendingAmbulanceRequestOrder.id); + amRequestViewModel.updatePressOrder(presOrderID: amRequestViewModel.pendingAmbulanceRequestOrder.iD); }, ), ) diff --git a/lib/pages/ErService/rapid-response-team/rrt-logs-page.dart b/lib/pages/ErService/rapid-response-team/rrt-logs-page.dart index 2a1dd3c9..5f0506f3 100644 --- a/lib/pages/ErService/rapid-response-team/rrt-logs-page.dart +++ b/lib/pages/ErService/rapid-response-team/rrt-logs-page.dart @@ -1,15 +1,15 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/GetCMCAllOrdersResponseModel.dart'; -import 'package:diplomaticquarterapp/core/model/prescriptions/prescriptions_order.dart'; import 'package:diplomaticquarterapp/core/viewModels/er/rrt-view-model.dart'; +import 'package:diplomaticquarterapp/pages/ErService/rapid-response-team/rrt-main-screen.dart'; import 'package:diplomaticquarterapp/pages/ErService/rapid-response-team/rrt-order-list-item.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; -import 'package:diplomaticquarterapp/pages/ErService/rapid-response-team/rrt-main-screen.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; -import 'package:diplomaticquarterapp/uitl/utils.dart'; class RRTLogPage extends StatefulWidget { final List orders; @@ -36,13 +36,15 @@ class RRTLogPageState extends State { viewModel = vm, }, builder: (ctx, vm, widgetState) { - return ListView.builder( - itemCount: widget.orders.length, - padding: EdgeInsets.all(21), - itemBuilder: (ctx, idx) { - var order = widget.orders[idx]; - return RRTLogListItem(order, onCancel: deleteOrder); - }); + return widget.orders.length > 0 + ? ListView.builder( + itemCount: widget.orders.length, + padding: EdgeInsets.all(21), + itemBuilder: (ctx, idx) { + var order = widget.orders[idx]; + return RRTLogListItem(order, onCancel: deleteOrder); + }) + : getNoDataWidget(context); }); } @@ -58,4 +60,4 @@ class RRTLogPageState extends State { Navigator.push(context, FadePage(page: RRTMainScreen())); } } -} +} \ No newline at end of file diff --git a/lib/pages/medical/prescriptions/prescriptions_history_details_page.dart b/lib/pages/medical/prescriptions/prescriptions_history_details_page.dart index c024b575..e9b1dfb6 100644 --- a/lib/pages/medical/prescriptions/prescriptions_history_details_page.dart +++ b/lib/pages/medical/prescriptions/prescriptions_history_details_page.dart @@ -1,12 +1,11 @@ -import 'package:diplomaticquarterapp/core/model/prescriptions/prescriptions_order.dart'; +import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/ComprehensiveMedicalCheckup/GetCMCAllOrdersResponseModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/extensions/string_extensions.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/extensions/string_extensions.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; @@ -14,7 +13,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class PrescriptionsHistoryDetailsPage extends StatelessWidget { - final PrescriptionsOrder prescriptionsOrder; + final GetCMCAllOrdersResponseModel prescriptionsOrder; PrescriptionsHistoryDetailsPage({Key key, this.prescriptionsOrder}); @@ -22,10 +21,10 @@ class PrescriptionsHistoryDetailsPage extends StatelessWidget { Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( - onModelReady: (model) => model.getPrescriptionReportEnh(prescriptionsOrder: prescriptionsOrder), + onModelReady: (model) => model.getPrescriptionReportDetailsRC(), builder: (_, model, widget) { - int status = prescriptionsOrder.status; - String _statusDisp = projectViewModel.isArabic ? prescriptionsOrder.descriptionN : prescriptionsOrder.description; + int status = prescriptionsOrder.statusId; + String _statusDisp = prescriptionsOrder.statusText; Color _color; if (status == 1) { //pending @@ -36,7 +35,7 @@ class PrescriptionsHistoryDetailsPage extends StatelessWidget { } else if (status == 3) { //completed _color = Color(0xff359846); - } else if (status == 4) { + } else if (status == 4 || status == 6 || status == 7) { //cancel // Rejected _color = Color(0xffD02127); } @@ -109,13 +108,9 @@ class PrescriptionsHistoryDetailsPage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( - DateUtil.getDayMonthYearDateFormatted(prescriptionsOrder.createdOn), + DateUtil.getDayMonthYearDateFormatted(DateTime.tryParse(prescriptionsOrder.created)), style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.4, height: 16 / 10), ), - Text( - DateUtil.formatDateToTimeLang(prescriptionsOrder.createdOn, false), - style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), - ), ], ) ], @@ -134,7 +129,7 @@ class PrescriptionsHistoryDetailsPage extends StatelessWidget { child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(30)), child: Image.network( - model.prescriptionReportEnhList[index].imageSRCUrl, + model.prescriptionsOrderListRC[index].image, fit: BoxFit.cover, width: 48, height: 48, @@ -144,9 +139,9 @@ class PrescriptionsHistoryDetailsPage extends StatelessWidget { SizedBox(width: 14), Expanded( child: Text( - (model.prescriptionReportEnhList[index].itemDescription.isNotEmpty - ? model.prescriptionReportEnhList[index].itemDescription - : model.prescriptionReportEnhList[index].itemDescriptionN ?? '') + (model.prescriptionsOrderListRC[index].itemDescription.isNotEmpty + ? model.prescriptionsOrderListRC[index].itemDescription + : model.prescriptionsOrderListRC[index].itemDescription ?? '') .toLowerCase() .capitalizeFirstofEach, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64), @@ -155,7 +150,7 @@ class PrescriptionsHistoryDetailsPage extends StatelessWidget { ], ), separatorBuilder: (context, index) => SizedBox(height: 12), - itemCount: model.prescriptionReportEnhList.length) + itemCount: model.prescriptionsOrderListRC.length) ], ), ), @@ -168,9 +163,10 @@ class PrescriptionsHistoryDetailsPage extends StatelessWidget { padding: EdgeInsets.only(top: 16, bottom: 16, right: 21, left: 21), child: DefaultButton( TranslationBase.of(context).cancelOrder, - prescriptionsOrder.status != 1 - ? null - : () { + // prescriptionsOrder.statusId != 1 + // ? null + // : + () { showCDialog(model, context); }, disabledColor: Color(0xff575757), diff --git a/lib/pages/medical/prescriptions/prescriptions_history_page.dart b/lib/pages/medical/prescriptions/prescriptions_history_page.dart index adce13bb..1de0ae1d 100644 --- a/lib/pages/medical/prescriptions/prescriptions_history_page.dart +++ b/lib/pages/medical/prescriptions/prescriptions_history_page.dart @@ -2,10 +2,12 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_history_details_page.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -52,17 +54,17 @@ class PrescriptionsHistoryPage extends StatelessWidget { return InkWell( onTap: () async { - // final result = await Navigator.push( - // context, - // FadePage( - // page: PrescriptionsHistoryDetailsPage( - // prescriptionsOrder: prescriptionsViewModel.prescriptionsHistory[index], - // ), - // ), - // ); - // if (result != null) { - // showOrderLog(); - // } + final result = await Navigator.push( + context, + FadePage( + page: PrescriptionsHistoryDetailsPage( + prescriptionsOrder: prescriptionsViewModel.prescriptionsHistory[index], + ), + ), + ); + if (result != null) { + showOrderLog(); + } }, child: Container( height: 65, From e1e31de8182571431ddfdedbc7ad044b21870543 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 2 Nov 2021 17:55:53 +0300 Subject: [PATCH 14/70] Lakum fixes --- lib/config/config.dart | 6 +++--- lib/pages/pharmacies/screens/lakum-main-page.dart | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index f3444d3a..53588ac1 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -15,8 +15,8 @@ const PACKAGES_CUSTOMER = '/api/customers'; 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/'; // Pharmacy UAT URLs // const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; @@ -26,7 +26,7 @@ const BASE_URL = 'https://uat.hmgwebservices.com/'; const BASE_PHARMACY_URL = 'https://mdlaboratories.com/exacartapi/api/'; const PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapi/api/'; -// RC API URLs +// RC API URL const RC_BASE_URL = 'https://livecare.hmg.com/'; const PING_SERVICE = 'Services/Weather.svc/REST/CheckConnectivity'; diff --git a/lib/pages/pharmacies/screens/lakum-main-page.dart b/lib/pages/pharmacies/screens/lakum-main-page.dart index 1547b929..c4415852 100644 --- a/lib/pages/pharmacies/screens/lakum-main-page.dart +++ b/lib/pages/pharmacies/screens/lakum-main-page.dart @@ -26,11 +26,21 @@ class LakumMainPage extends StatelessWidget { projectViewModel = Provider.of(context); return BaseView( - onModelReady: (model) => model.getLacumData(), + onModelReady: (model) async { + await model.getLacumData(); + if (model.lacumInformation.yahalaAccountNo == 0 || model.lacumInformation.yahalaAccountNo == null) { + navigateToLakumRegister(context); + } else { + if (model.lacumInformation.status == "Hold") { + Navigator.pushReplacement(context, FadePage(page: LakumActivationVidaPage())); + } + } + }, builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).lakum, isShowAppBar: true, isPharmacy: true, + showPharmacyCart: false, isShowDecPage: false, backgroundColor: Colors.white, baseViewModel: model, From 6f632502527373572f8aac83079be21fafdeac73 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Wed, 3 Nov 2021 11:44:28 +0300 Subject: [PATCH 15/70] fix issues --- .../viewModels/pharmacyModule/brand_view_model.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/core/viewModels/pharmacyModule/brand_view_model.dart b/lib/core/viewModels/pharmacyModule/brand_view_model.dart index 158d9cdb..71e68a0a 100644 --- a/lib/core/viewModels/pharmacyModule/brand_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/brand_view_model.dart @@ -1,8 +1,11 @@ +import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:diplomaticquarterapp/models/pharmacy/brandModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/topBrandsModel.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/brands_service.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import '../../../locator.dart'; @@ -22,18 +25,28 @@ class BrandsViewModel extends BaseViewModel{ Future getBrandsData() async { hasError = false; setState(ViewState.Busy); +// GifLoaderDialogUtils.showMyDialog( +// AppGlobal.context); await _brandsService.getBrands(); +// GifLoaderDialogUtils.hideDialog( +// AppGlobal.context); if (_brandsService.hasError) { error = _brandsService.error; setState(ViewState.ErrorLocal); } else +// GifLoaderDialogUtils.hideDialog( +// locator().navigatorKey.currentContext); setState(ViewState.Idle); } Future getTopBrandsData() async { hasError = false; setState(ViewState.Busy); + GifLoaderDialogUtils.showMyDialog( + AppGlobal.context); await _topBrandsService.getTopBrands(); + GifLoaderDialogUtils.hideDialog( + AppGlobal.context); if (_topBrandsService.hasError) { error = _topBrandsService.error; setState(ViewState.ErrorLocal); From 894cc0e3367611c5499eecd619f15fe0326422db Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 3 Nov 2021 18:11:36 +0300 Subject: [PATCH 16/70] Updates & fixes --- lib/config/config.dart | 11 +- lib/config/localized_values.dart | 6 +- lib/core/service/client/base_app_client.dart | 2 +- lib/core/service/hospital_service.dart | 5 +- .../NewCMC/new_cmc_step_tow_page.dart | 1 - .../new_home_health_care_page.dart | 22 +- lib/pages/Blood/blood_donation.dart | 14 +- .../covid-drivethru-location.dart | 1 - .../covid-payment-details.dart | 68 --- lib/pages/ErService/AmbulanceReq.dart | 2 +- .../BillAmount.dart | 442 ++++++++------- .../PickupLocation.dart | 437 +++++++++------ .../SelectTransportationMethod.dart | 245 +++++---- .../AmbulanceRequestIndexPages/Summary.dart | 101 ++-- lib/pages/ErService/ErOptions.dart | 15 +- lib/pages/ErService/OrderLogPage.dart | 5 +- .../rrt-order-list-item.dart | 30 +- .../rrt-pickup-address-page.dart | 7 +- .../rapid-response-team/rrt-place-order.dart | 2 +- .../rapid-response-team/rrt-request-page.dart | 4 +- lib/pages/ErService/widgets/StepsWidget.dart | 507 +++++++++++------- lib/pages/ToDoList/payment_method_select.dart | 88 +-- .../medical/balance/advance_payment_page.dart | 8 +- lib/uitl/translations_delegate_base.dart | 8 + lib/widgets/drawer/app_drawer_widget.dart | 37 +- .../pickupLocation/PickupLocationFromMap.dart | 31 +- 26 files changed, 1150 insertions(+), 949 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 53588ac1..694cb602 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -85,8 +85,11 @@ const SEND_RAD_REPORT_EMAIL = 'Services/Notifications.svc/REST/SendRadReportEmai ///Feedback const SEND_FEEDBACK = 'Services/COCWS.svc/REST/InsertCOCItemInSPList'; const GET_STATUS_FOR_COCO = 'Services/COCWS.svc/REST/GetStatusforCOC'; +// const GET_PATIENT_AppointmentHistory = 'Services' +// '/Doctors.svc/REST/PateintHasAppoimentHistory'; + const GET_PATIENT_AppointmentHistory = 'Services' - '/Doctors.svc/REST/PateintHasAppoimentHistory'; + '/Doctors.svc/REST/PateintHasAppoimentHistory_Async'; ///VITAL SIGN const GET_PATIENT_VITAL_SIGN = 'Services/Doctors.svc/REST/Doctor_GetPatientVitalSign'; @@ -166,7 +169,8 @@ const INSERT_REQUEST_FOR_MEDICAL_REPORT = 'Services/Doctors.svc/REST/InsertReque const SEND_MEDICAL_REPORT_EMAIL = 'Services/Notifications.svc/REST/SendMedicalReportEmail'; ///Rate -const IS_LAST_APPOITMENT_RATED = 'Services/Doctors.svc/REST/IsLastAppoitmentRated'; +// const IS_LAST_APPOITMENT_RATED = 'Services/Doctors.svc/REST/IsLastAppoitmentRated'; +const IS_LAST_APPOITMENT_RATED = 'Services/Doctors.svc/REST/IsLastAppoitmentRated_Async'; const GET_APPOINTMENT_DETAILS_BY_NO = 'Services/MobileNotifications.svc/REST/GetAppointmentDetailsByApptNo'; const NEW_RATE_APPOINTMENT_URL = "Services/Doctors.svc/REST/AppointmentsRating_InsertAppointmentRate"; const NEW_RATE_DOCTOR_URL = "Services/Doctors.svc/REST/DoctorsRating_InsertDoctorRate"; @@ -207,7 +211,8 @@ const SEND_REPORT_EYE_EMAIL = "Services/Notifications.svc/REST/SendGlassesPrescr const SEND_CONTACT_LENS_PRESCRIPTION_EMAIL = "Services/Notifications.svc/REST/SendContactLensPrescriptionEmail"; //URL to get patient appointment curfew history -const GET_PATIENT_APPOINTMENT_CURFEW_HISTORY = "Services/Doctors.svc/REST/AppoimentHistoryForCurfew"; +// const GET_PATIENT_APPOINTMENT_CURFEW_HISTORY = "Services/Doctors.svc/REST/AppoimentHistoryForCurfew"; +const GET_PATIENT_APPOINTMENT_CURFEW_HISTORY = "Services/Doctors.svc/REST/AppoimentHistoryForCurfew_Async"; //URL to confirm appointment const CONFIRM_APPOINTMENT = "Services/MobileNotifications.svc/REST/ConfirmAppointment"; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 207a65d7..8a80f0ea 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -625,7 +625,7 @@ const Map localizedValues = { "select-gender": {"en": "Select Gender", "ar": "اختر الجنس"}, "i-am-a": {"en": "I am a ...", "ar": "أنا ..."}, "select-age": {"en": "Select Your Age", "ar": "حدد العمر"}, - "select": {"en": "Select", "ar": "يختار"}, + "select": {"en": "Select", "ar": "اختر"}, "i-am": {"en": "I am", "ar": "أنا"}, "years-old": {"en": "years old", "ar": "سنة"}, "drag-point": {"en": "Drag point to change your age", "ar": "اسحب لتغيير عمرك"}, @@ -1626,4 +1626,8 @@ const Map localizedValues = { "cholesTitle": {"en": "Blood Cholesterol", "ar": " الكولسترول في الدم"}, "laserClinic": {"en": "Laser Clinic", "ar": "عيادة الليزر"}, "noImage": {"en": "No Image", "ar": "لا توجد صورة"}, + "signoutMessage": {"en": "Are you sure you want to logout?", "ar": "هل أنت متأكد أنك تريد تسجيل الخروج؟"}, + "RRTTitle": {"en": "RRT", "ar": "خدمة فريق"}, + "RRTSubTitle": {"en": "Service", "ar": "الاستجابة السريع"}, + "transportation": {"en": "Transportation", "ar": "النقل"}, }; diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 696cda28..322ec08b 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -124,7 +124,7 @@ class BaseAppClient { // body['IdentificationNo'] = 1009199553; // body['MobileNo'] = "966545156035"; - // body['PatientID'] = 1018977; + // body['PatientID'] = 1018977; //3844083 // body['TokenID'] = "@dm!n"; body.removeWhere((key, value) => key == null || value == null); diff --git a/lib/core/service/hospital_service.dart b/lib/core/service/hospital_service.dart index b9e970e1..46bc95f9 100644 --- a/lib/core/service/hospital_service.dart +++ b/lib/core/service/hospital_service.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:geolocator/geolocator.dart'; @@ -25,8 +26,8 @@ class HospitalService extends BaseService { if(isResBasedOnLoc) await _getCurrentLocation(); Map body = Map(); - body['Latitude'] = isResBasedOnLoc?_latitude:0; - body['Longitude'] = isResBasedOnLoc?_longitude:0; + body['Latitude'] = await this.sharedPref.getDouble(USER_LAT); + body['Longitude'] = await this.sharedPref.getDouble(USER_LONG); body['IsOnlineCheckIn'] = isResBasedOnLoc; body['PatientOutSA'] = 0; 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 0d859690..89d58317 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 @@ -170,7 +170,6 @@ class _NewCMCStepTowPageState extends State { child: Container( padding: EdgeInsets.all(8), width: double.infinity, - // height: 65, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.white, diff --git a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_home_health_care_page.dart b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_home_health_care_page.dart index 75c68127..82f91cff 100644 --- a/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_home_health_care_page.dart +++ b/lib/pages/AlHabibMedicalService/HomeHealthCare/NewHomeHealthCare/new_home_health_care_page.dart @@ -149,23 +149,15 @@ class _NewHomeHealthCarePageState extends State with Tick crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - TranslationBase.of(context).serviceName + ": ", + TranslationBase.of(context).hospital + ": ", style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), ), - Column( - children: [ - ...List.generate( - widget.model.hhcAllOrderDetail.length, - (index) => Container( - child: Texts( - projectViewModel.isArabic ? widget.model.hhcAllOrderDetail[index].descriptionN : widget.model.hhcAllOrderDetail[index].description.capitalize(), - fontSize: 13, - bold: false, - ), - ), - ) - ], - ) + Expanded( + child: Text( + widget.model.pendingOrder.nearestProjectName.toString(), + style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.56), + ), + ), ], ) ], diff --git a/lib/pages/Blood/blood_donation.dart b/lib/pages/Blood/blood_donation.dart index d9dbcf4b..3a702d32 100644 --- a/lib/pages/Blood/blood_donation.dart +++ b/lib/pages/Blood/blood_donation.dart @@ -2,11 +2,8 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart'; import 'package:diplomaticquarterapp/core/model/blooddonation/blood_groub_details.dart'; import 'package:diplomaticquarterapp/core/model/blooddonation/get_all_cities.dart'; -import 'package:diplomaticquarterapp/core/model/my_balance/AdvanceModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/my_balance_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; -import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/h2o/h20_setting.dart'; import 'package:diplomaticquarterapp/pages/Blood/user_agreement_page.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; @@ -44,12 +41,9 @@ class _BloodDonationPageState extends State { String amount = ""; String email; - AuthenticatedUser authenticatedUser; - GetAllSharedRecordsByStatusList selectedPatientFamily; - AdvanceModel advanceModel = AdvanceModel(); + List_BloodGroupDetailsModel bloodDetails = List_BloodGroupDetailsModel(bloodGroup: "A-"); AppSharedPreferences sharedPref = AppSharedPreferences(); - AuthenticatedUser authUser; var checkedValue = false; List imagesInfo = List(); @@ -60,9 +54,7 @@ class _BloodDonationPageState extends State { imagesInfo.add( ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/images-info-home/blood/en/0.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/images-info-home/blood/ar/0.png'), ); - WidgetsBinding.instance.addPostFrameCallback((_) { - if (projectProvider.isLogin) authUser = projectProvider.user; - }); + WidgetsBinding.instance.addPostFrameCallback((_) {}); super.initState(); } @@ -82,7 +74,7 @@ class _BloodDonationPageState extends State { return BaseView( onModelReady: (model) { - if (projectProvider.isLogin) { + if (projectProvider.isLogin && projectProvider.user != null) { model.getCities().then((value) { model.getBlood().then((value) { if (model.bloodModelList.length > 0) { diff --git a/lib/pages/Covid-DriveThru/covid-drivethru-location.dart b/lib/pages/Covid-DriveThru/covid-drivethru-location.dart index 0d169ef8..a0842a73 100644 --- a/lib/pages/Covid-DriveThru/covid-drivethru-location.dart +++ b/lib/pages/Covid-DriveThru/covid-drivethru-location.dart @@ -58,7 +58,6 @@ class _CovidDrivethruLocationState extends State { @override Widget build(BuildContext context) { projectViewModel = Provider.of(context); - imagesInfo.add(ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/covid/en/0.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/covid/ar/0.png')); return AppScaffold( appBarTitle: TranslationBase.of(context).covidTest, isShowAppBar: true, diff --git a/lib/pages/Covid-DriveThru/covid-payment-details.dart b/lib/pages/Covid-DriveThru/covid-payment-details.dart index e567dbe7..2301de51 100644 --- a/lib/pages/Covid-DriveThru/covid-payment-details.dart +++ b/lib/pages/Covid-DriveThru/covid-payment-details.dart @@ -55,51 +55,6 @@ class _CovidPaymentDetailsState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Container( - // height: 150.0, - // decoration: BoxDecoration( - // image: DecorationImage( - // image: AssetImage( - // "assets/images/new-design/covid-19-big-banner-bg.png"), - // fit: BoxFit.fill, - // ), - // color: Colors.white.withOpacity(0.3), - // borderRadius: BorderRadius.all(Radius.circular(10))), - // child: Row( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // Container( - // margin: - // EdgeInsets.only(left: 15.0, right: 15.0, top: 30.0), - // child: SvgPicture.asset( - // 'assets/images/new-design/covid-19-car.svg', - // width: 90.0, - // height: 90.0), - // ), - // Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // Container( - // margin: EdgeInsets.only( - // left: 20.0, right: 20.0, top: 20.0), - // child: Text(TranslationBase.of(context).covidTest, - // style: TextStyle( - // color: Colors.white, - // fontWeight: FontWeight.bold, - // fontSize: 24.0)), - // ), - // Container( - // margin: EdgeInsets.only( - // left: 20.0, right: 20.0, top: 10.0), - // child: Text(TranslationBase.of(context).driveThru, - // style: TextStyle( - // color: Colors.white, fontSize: 24.0)), - // ), - // ], - // ), - // ], - // ), - // ), Text(TranslationBase.of(context).covidSelectProcedure, style: TextStyle(color: Colors.black, fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.bold)), ...List.generate( widget.proceduresList.length, @@ -144,29 +99,6 @@ class _CovidPaymentDetailsState extends State { fontWeight: FontWeight.w600, ), ), - // ListTile( - // title: Text( - // projectViewModel.isArabic ? widget.proceduresList[index].procedureNameN : widget.proceduresList[index].procedureName, - // style: TextStyle( - // fontSize: 12.0, - // letterSpacing: -0.48, - // fontWeight: FontWeight.w600, - // ), - // ), - // leading: Radio( - // value: widget.proceduresList[index], - // groupValue: widget.selectedProcedure, - // activeColor: Colors.red[800], - // toggleable: true, - // onChanged: (value) { - // setState(() { - // widget.selectedProcedure = value; - // print(widget.selectedProcedure.procedureName); - // getPaymentInfo(context, widget.projectID.toString(), widget.selectedProcedure.procedureID); - // }); - // }, - // ), - // ), ], ), ), diff --git a/lib/pages/ErService/AmbulanceReq.dart b/lib/pages/ErService/AmbulanceReq.dart index 939c138c..3803bcd4 100644 --- a/lib/pages/ErService/AmbulanceReq.dart +++ b/lib/pages/ErService/AmbulanceReq.dart @@ -78,7 +78,7 @@ class _AmbulanceReqState extends State with SingleTickerProviderSt ), Expanded( child: TabBarView( - physics: BouncingScrollPhysics(), + physics: NeverScrollableScrollPhysics(), controller: _tabController, children: [ AmbulanceRequestIndexPage( diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/BillAmount.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/BillAmount.dart index 11950cef..e571e4e8 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/BillAmount.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/BillAmount.dart @@ -2,10 +2,9 @@ import 'package:diplomaticquarterapp/core/enum/Ambulate.dart'; import 'package:diplomaticquarterapp/core/model/er/PatientER.dart'; import 'package:diplomaticquarterapp/core/model/er/PatientER_RC.dart'; import 'package:diplomaticquarterapp/core/viewModels/er/am_request_view_model.dart'; -import 'package:diplomaticquarterapp/pages/Blood/new_text_Field.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -45,269 +44,229 @@ class _BillAmountState extends State { body: SingleChildScrollView( physics: BouncingScrollPhysics(), child: Container( - margin: EdgeInsets.only(left: 12, right: 12), + margin: EdgeInsets.only(left: 12, right: 12, top: 12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts(TranslationBase.of(context).billAmount), + Text(TranslationBase.of(context).billAmount, style: TextStyle(fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.w600)), SizedBox( height: 10, ), - Table( - border: TableBorder.symmetric(inside: BorderSide(width: 1.0, color: Colors.grey[300]), outside: BorderSide(width: 1.0, color: Colors.grey[300])), - children: [ - TableRow( + Container( + decoration: cardRadius(12), + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ + // Text(TranslationBase.of(context).testFee, + // style: TextStyle( + // color: Colors.black, + // fontSize: 16.0, + // fontWeight: FontWeight.w600, + // letterSpacing: -0.64, + // )), Container( - height: MediaQuery.of(context).size.height * 0.09, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(10.0), - ), - ), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Texts( - TranslationBase.of(context).patientShareB, - textAlign: TextAlign.start, - color: Colors.black, - fontSize: 15, - ), + width: double.infinity, + padding: EdgeInsets.only(top: 10, bottom: 3), + child: Row( + children: [ + Expanded( + child: _getNormalText(TranslationBase.of(context).patientShareToDo), + ), + Expanded( + child: _getNormalText(TranslationBase.of(context).sar + ' ${widget.patientER_RC.patientERTransportationMethod.price}', isBold: true), + ) + ], ), ), + mDivider(Colors.grey[200]), Container( - height: MediaQuery.of(context).size.height * 0.09, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - topRight: Radius.circular(10.0), - ), - ), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Texts( - TranslationBase.of(context).sar + ' ${widget.patientER_RC.patientERTransportationMethod.price}', - color: Colors.black, - textAlign: TextAlign.start, - fontSize: 15, - ), + width: double.infinity, + padding: EdgeInsets.only(top: 3, bottom: 3), + child: Row( + children: [ + Expanded( + child: _getNormalText(TranslationBase.of(context).patientTaxToDo), + ), + Expanded( + child: _getNormalText(TranslationBase.of(context).sar + ' ${widget.patientER_RC.patientERTransportationMethod.priceVAT}', isBold: true), + ) + ], ), ), - ], - ), - TableRow( - children: [ + mDivider(Colors.grey[200]), Container( - color: Colors.white, - height: MediaQuery.of(context).size.height * 0.09, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Texts( - TranslationBase.of(context).patientShareTax, - color: Colors.black, - fontSize: 15, - textAlign: TextAlign.start, - ), - ), - ), - Container( - height: MediaQuery.of(context).size.height * 0.09, - color: Colors.white, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Texts( - TranslationBase.of(context).sar + ' ${widget.patientER_RC.patientERTransportationMethod.priceVAT}', - color: Colors.black, - fontSize: 15, - textAlign: TextAlign.start, - ), + width: double.infinity, + padding: EdgeInsets.only(top: 3, bottom: 3), + child: Row( + children: [ + Expanded( + child: _getNormalText(TranslationBase.of(context).patientShareTotalToDo), + ), + Expanded( + child: _getNormalText(TranslationBase.of(context).sar + ' ${widget.patientER_RC.patientERTransportationMethod.priceTotal}', isBold: true, isTotal: true), + ) + ], ), ), ], ), - TableRow( - children: [ - Container( - height: MediaQuery.of(context).size.height * 0.09, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(10.0), - ), - ), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Texts( - TranslationBase.of(context).patientShareTotal, - color: Colors.black, - fontSize: 15, - textAlign: TextAlign.start, - bold: true, - ), - ), - ), - Container( - height: MediaQuery.of(context).size.height * 0.09, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(10.0), - ), - ), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Texts( - TranslationBase.of(context).sar + ' ${widget.patientER_RC.patientERTransportationMethod.priceTotal}', - color: Colors.black, - fontSize: 15, - textAlign: TextAlign.start, - ), - ), - ), - ], - ), - ], + ), ), SizedBox( height: 10, ), - Texts( - TranslationBase.of(context).selectAmbulate, - bold: false, - ), + Text(TranslationBase.of(context).selectAmbulate, style: TextStyle(fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.w600)), SizedBox( height: 5, ), Row( children: [ - Expanded( - child: InkWell( - onTap: () { - setState(() { - _ambulate = Ambulate.Wheelchair; - }); - }, - child: Container( - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey, width: 0.5), - color: Colors.white, - ), - child: ListTile( - title: Text(TranslationBase.of(context).wheelchair, style: TextStyle( - fontSize: 14.0 - )), - leading: Radio( - value: Ambulate.Wheelchair, - groupValue: _ambulate, - onChanged: (value) { - setState(() { - _ambulate = value; - }); - }, - ), + InkWell( + onTap: () { + setState(() { + _ambulate = Ambulate.Wheelchair; + }); + }, + child: Container( + width: MediaQuery.of(context).size.width * 0.9, + child: ListTile( + contentPadding: EdgeInsets.only(left: 0.0, right: 0.0), + title: Row( + children: [ + Radio( + value: Ambulate.Wheelchair, + groupValue: _ambulate, + onChanged: (value) { + setState(() { + _ambulate = value; + }); + }, + ), + Text( + TranslationBase.of(context).wheelchair, + style: TextStyle( + fontSize: 12.0, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ), + ], ), ), ), ), - Expanded( - child: InkWell( - onTap: () { - setState(() { - _ambulate = Ambulate.Walker; - }); - }, - child: Container( - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey, width: 0.5), - color: Colors.white, - ), - child: ListTile( - title: Text(TranslationBase.of(context).walker, style: TextStyle( - fontSize: 14.0 - )), - leading: Radio( - value: Ambulate.Walker, - groupValue: _ambulate, - onChanged: (value) { - setState(() { - _ambulate = value; - }); - }, - ), + ], + ), + Row( + children: [ + InkWell( + onTap: () { + setState(() { + _ambulate = Ambulate.Walker; + }); + }, + child: Container( + width: MediaQuery.of(context).size.width * 0.9, + child: ListTile( + contentPadding: EdgeInsets.only(left: 0.0, right: 0.0), + title: Row( + children: [ + Radio( + value: Ambulate.Walker, + groupValue: _ambulate, + onChanged: (value) { + setState(() { + _ambulate = value; + }); + }, + ), + Text( + TranslationBase.of(context).walker, + style: TextStyle( + fontSize: 12.0, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ), + ], ), ), ), ), ], ), - SizedBox( - height: 5, - ), Row( children: [ - Expanded( - child: InkWell( - onTap: () { - setState(() { - _ambulate = Ambulate.Stretcher; - }); - }, - child: Container( - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey, width: 0.5), - color: Colors.white, - ), - child: ListTile( - title: Text(TranslationBase.of(context).stretcher, style: TextStyle( - fontSize: 14.0 - )), - leading: Radio( - value: Ambulate.Stretcher, - groupValue: _ambulate, - onChanged: (value) { - setState(() { - _ambulate = value; - }); - }, - ), + InkWell( + onTap: () { + setState(() { + _ambulate = Ambulate.Stretcher; + }); + }, + child: Container( + width: MediaQuery.of(context).size.width * 0.9, + child: ListTile( + contentPadding: EdgeInsets.only(left: 0.0, right: 0.0), + title: Row( + children: [ + Radio( + value: Ambulate.Stretcher, + groupValue: _ambulate, + onChanged: (value) { + setState(() { + _ambulate = value; + }); + }, + ), + Text( + TranslationBase.of(context).stretcher, + style: TextStyle( + fontSize: 12.0, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ), + ], ), ), ), ), - Expanded( - child: InkWell( - onTap: () { - setState(() { - _ambulate = Ambulate.None; - }); - }, - child: Container( - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey, width: 0.5), - color: Colors.white, - ), - child: ListTile( - title: Text(TranslationBase.of(context).none, style: TextStyle( - fontSize: 14.0 - )), - leading: Radio( - value: Ambulate.None, - groupValue: _ambulate, - onChanged: (value) { - setState(() { - _ambulate = value; - }); - }, - ), + ], + ), + Row( + children: [ + InkWell( + onTap: () { + setState(() { + _ambulate = Ambulate.None; + }); + }, + child: Container( + width: MediaQuery.of(context).size.width * 0.9, + child: ListTile( + contentPadding: EdgeInsets.only(left: 0.0, right: 0.0), + title: Row( + children: [ + Radio( + value: Ambulate.None, + groupValue: _ambulate, + onChanged: (value) { + setState(() { + _ambulate = value; + }); + }, + ), + Text( + TranslationBase.of(context).none, + style: TextStyle( + fontSize: 12.0, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ), + ], ), ), ), @@ -317,14 +276,21 @@ class _BillAmountState extends State { SizedBox( height: 12, ), - NewTextFields( - hintText: TranslationBase.of(context).notes, - initialValue: note, - onChanged: (value) { - setState(() { - note = value; - }); - }, + Container( + decoration: cardRadius(10), + child: Padding( + padding: EdgeInsets.all(8.0), + child: TextField( + maxLines: 5, + decoration: InputDecoration.collapsed( + hintText: TranslationBase.of(context).notes, hintStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16)), + onChanged: (value) { + setState(() { + note = value; + }); + }, + ), + ), ), SizedBox( height: 100, @@ -352,4 +318,20 @@ class _BillAmountState extends State { ), ); } + + _getNormalText(text, {bool isBold = false, bool isTotal = false}) { + return Text( + text, + style: TextStyle( + fontSize: isBold + ? isTotal + ? 16 + : 12 + : 10, + letterSpacing: -0.5, + color: isBold ? Colors.black : Colors.grey[700], + fontWeight: FontWeight.w600, + ), + ); + } } diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart index 850d308a..0e63bf76 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart @@ -4,7 +4,6 @@ import 'package:diplomaticquarterapp/core/model/er/PatientER_RC.dart'; import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/er/am_request_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; -import 'package:diplomaticquarterapp/pages/Blood/dialogs/SelectHospitalDialog.dart'; import 'package:diplomaticquarterapp/pages/ErService/widgets/AppointmentCard.dart'; import 'package:diplomaticquarterapp/uitl/ProgressDialog.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; @@ -13,12 +12,12 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/pickupLocation/PickupLocationFromMap.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:geolocator/geolocator.dart'; import 'package:google_maps_place_picker/google_maps_place_picker.dart'; @@ -51,9 +50,7 @@ class _PickupLocationState extends State { void initState() { super.initState(); _getCurrentLocation(); - setState(() { - - }); + setState(() {}); } _getCurrentLocation() async { @@ -64,7 +61,6 @@ class _PickupLocationState extends State { _longitude = 0; _latitude = 0; }); - } @override @@ -75,7 +71,7 @@ class _PickupLocationState extends State { body: SingleChildScrollView( physics: BouncingScrollPhysics(), child: Container( - margin: EdgeInsets.only(left: 12, right: 12), + margin: EdgeInsets.only(left: 12, right: 12, top: 12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -83,43 +79,66 @@ class _PickupLocationState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts(TranslationBase.of(context).pickupLocation), + Text(TranslationBase.of(context).pickupLocation, style: TextStyle(fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.w600)), SizedBox( height: 15, ), - InkWell( - onTap: () { - Navigator.push( - context, - FadePage( - page: PickupLocationFromMap( - latitude: _latitude??0, - longitude: _longitude??0, - onPick: (value) { - setState(() { - _result = value; - }); - }, - )), - ); - }, - child: Container( - padding: EdgeInsets.all(12), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey, width: 0.5), - color: Colors.white, + Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, ), + ), + child: InkWell( + onTap: () { + Navigator.push( + context, + FadePage( + page: PickupLocationFromMap( + latitude: _latitude ?? 0, + longitude: _longitude ?? 0, + onPick: (value) { + setState(() { + _result = value; + }); + }, + )), + ); + }, child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Expanded(child: Texts(getSelectFromMapName(context))), - Icon( - FontAwesomeIcons.mapMarkerAlt, - size: 24, - color: Colors.black, - ) + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).selectMap, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + Text( + getSelectFromMapName(context), + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + ], + ), + ), + Icon(Icons.arrow_drop_down), ], ), ), @@ -127,7 +146,7 @@ class _PickupLocationState extends State { SizedBox( height: 12, ), - Texts(TranslationBase.of(context).pickupSpot), + Text(TranslationBase.of(context).pickupSpot, style: TextStyle(fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.w600)), SizedBox( height: 5, ), @@ -138,21 +157,27 @@ class _PickupLocationState extends State { }); }, child: Container( - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey, width: 0.5), - color: Colors.white, - ), child: ListTile( - title: Texts(TranslationBase.of(context).insideHome), - leading: Checkbox( - value: _isInsideHome, - onChanged: (value) { - setState(() { - _isInsideHome = value; - }); - }, + contentPadding: EdgeInsets.only(left: 0.0, right: 0.0), + title: Row( + children: [ + Checkbox( + value: _isInsideHome, + onChanged: (value) { + setState(() { + _isInsideHome = value; + }); + }, + ), + Text( + TranslationBase.of(context).insideHome, + style: TextStyle( + fontSize: 12.0, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ), + ], ), ), ), @@ -160,7 +185,7 @@ class _PickupLocationState extends State { SizedBox( height: 12, ), - Texts(TranslationBase.of(context).haveAppo), + Text(TranslationBase.of(context).haveAppo, style: TextStyle(fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.w600)), SizedBox( height: 5, ), @@ -177,25 +202,31 @@ class _PickupLocationState extends State { } }, child: Container( - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey, width: 0.5), - color: Colors.white, - ), child: ListTile( - title: Texts(TranslationBase.of(context).yes), - leading: Radio( - value: HaveAppointment.YES, - groupValue: _haveAppointment, - onChanged: (value) { - if (myAppointment == null) { - getAppointment(); - setState(() { - _haveAppointment = value; - }); - } - }, + contentPadding: EdgeInsets.only(left: 0.0, right: 0.0), + title: Row( + children: [ + Radio( + value: HaveAppointment.YES, + groupValue: _haveAppointment, + onChanged: (value) { + if (myAppointment == null) { + getAppointment(); + setState(() { + _haveAppointment = value; + }); + } + }, + ), + Text( + TranslationBase.of(context).yes, + style: TextStyle( + fontSize: 12.0, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ), + ], ), ), ), @@ -210,23 +241,29 @@ class _PickupLocationState extends State { }); }, child: Container( - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey, width: 0.5), - color: Colors.white, - ), child: ListTile( - title: Texts(TranslationBase.of(context).no), - leading: Radio( - value: HaveAppointment.NO, - groupValue: _haveAppointment, - onChanged: (value) { - setState(() { - _haveAppointment = value; - myAppointment = null; - }); - }, + contentPadding: EdgeInsets.only(left: 0.0, right: 0.0), + title: Row( + children: [ + Radio( + value: HaveAppointment.NO, + groupValue: _haveAppointment, + onChanged: (value) { + setState(() { + _haveAppointment = value; + myAppointment = null; + }); + }, + ), + Text( + TranslationBase.of(context).no, + style: TextStyle( + fontSize: 12.0, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ), + ], ), ), ), @@ -249,31 +286,54 @@ class _PickupLocationState extends State { SizedBox( height: 12, ), - Texts(TranslationBase.of(context).dropoffLocation), + Text(TranslationBase.of(context).dropoffLocation, style: TextStyle(fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.w600)), SizedBox( height: 8, ), - InkWell( - onTap: () { - confirmSelectHospitalDialog(widget.amRequestViewModel.hospitals); - }, - child: Container( - padding: EdgeInsets.all(12), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey, width: 0.5), - color: Colors.white, + Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, ), + ), + child: InkWell( + onTap: () { + confirmSelectHospitalDialog(widget.amRequestViewModel.hospitals); + }, child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Texts(getHospitalName(TranslationBase.of(context).selectHospital)), - Icon( - Icons.arrow_drop_down, - size: 24, - color: Colors.black, - ) + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).selectHospital, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + Text( + getHospitalName(""), + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + ], + ), + ), + Icon(Icons.arrow_drop_down), ], ), ), @@ -284,26 +344,54 @@ class _PickupLocationState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts(TranslationBase.of(context).pickupLocation), + Text(TranslationBase.of(context).pickupLocation, style: TextStyle(fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.w600)), SizedBox( height: 15, ), - InkWell( - onTap: () { - confirmSelectHospitalDialog(widget.amRequestViewModel.hospitals); - }, - child: Container( - padding: EdgeInsets.all(12), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey, width: 0.5), - color: Colors.white, + Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, ), + ), + child: InkWell( + onTap: () { + confirmSelectHospitalDialog(widget.amRequestViewModel.hospitals); + }, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Texts(getHospitalName(TranslationBase.of(context).pickupLocation)), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).selectHospital, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + Text( + getHospitalName(""), + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + ], + ), + ), Icon( Icons.arrow_drop_down, size: 24, @@ -316,44 +404,67 @@ class _PickupLocationState extends State { SizedBox( height: 12, ), - Texts(TranslationBase.of(context).dropoffLocation), + Text(TranslationBase.of(context).dropoffLocation, style: TextStyle(fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.w600)), SizedBox( height: 8, ), - InkWell( - onTap: () { - Navigator.push( - context, - FadePage( - page: PickupLocationFromMap( - latitude: _latitude, - longitude: _longitude, - onPick: (value) { - setState(() { - _result = value; - }); - }, - ), - ), - ); - }, - child: Container( - padding: EdgeInsets.all(12), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey, width: 0.5), - color: Colors.white, + Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, ), + ), + child: InkWell( + onTap: () { + Navigator.push( + context, + FadePage( + page: PickupLocationFromMap( + latitude: _latitude, + longitude: _longitude, + onPick: (value) { + setState(() { + _result = value; + }); + }, + ), + ), + ); + }, child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Expanded(child: Texts(getSelectFromMapName(context))), - Icon( - FontAwesomeIcons.mapMarkerAlt, - size: 24, - color: Colors.black, - ) + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).selectMap, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + Text( + getSelectFromMapName(context), + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + ], + ), + ), + Icon(Icons.arrow_drop_down), ], ), ), @@ -442,16 +553,22 @@ class _PickupLocationState extends State { ); } + int _selectedHospitalIndex = -1; + void confirmSelectHospitalDialog(List hospitals) { + List list = [ + for (int i = 0; i < hospitals.length; i++) RadioSelectionDialogModel(hospitals[i].name + ' ${hospitals[i].distanceInKilometers} ' + TranslationBase.of(context).km, i), + ]; showDialog( context: context, - child: SelectHospitalDialog( - hospitals: hospitals, - selectedHospital: _selectedHospital, - onValueSelected: (value) { - setState(() { - _selectedHospital = value; - }); + child: RadioSelectionDialog( + listData: list, + selectedIndex: _selectedHospitalIndex, + isScrollable: true, + onValueSelected: (index) { + _selectedHospitalIndex = index; + _selectedHospital = hospitals[index]; + setState(() {}); }, ), ); @@ -462,7 +579,7 @@ class _PickupLocationState extends State { } String getSelectFromMapName(context) { - return _result != null ? _result.formattedAddress : TranslationBase.of(context).selectMap; + return _result != null ? _result.formattedAddress : ""; } getAppointment() { diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/SelectTransportationMethod.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/SelectTransportationMethod.dart index 0a187918..e3c8ccf2 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/SelectTransportationMethod.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/SelectTransportationMethod.dart @@ -5,8 +5,8 @@ import 'package:diplomaticquarterapp/core/model/er/get_all_transportation_method import 'package:diplomaticquarterapp/core/viewModels/er/am_request_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -71,56 +71,77 @@ class _SelectTransportationMethodState extends State SizedBox( height: 12, ), - Texts(TranslationBase.of(context).transportHeading), - ...List.generate( - widget.amRequestViewModel.amRequestModeList.length, - (index) => InkWell( - onTap: () { - setState(() { - _erTransportationMethod = widget.amRequestViewModel.amRequestModeList[index]; - }); - }, - child: Container( - margin: EdgeInsets.all(5), - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey, width: 0.5), - color: Colors.white, - ), - child: Row( - children: [ - Expanded( - flex: 3, - child: ListTile( - title: Texts(projectViewModel.isArabic ? widget.amRequestViewModel.amRequestModeList[index].textN : widget.amRequestViewModel.amRequestModeList[index].text), - leading: Radio( - value: widget.amRequestViewModel.amRequestModeList[index], - groupValue: _erTransportationMethod, - onChanged: (value) { - setState(() { - _erTransportationMethod = value; - }); - }, - ), + Text(TranslationBase.of(context).transportHeading, style: TextStyle(fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.w600)), + Container( + margin: EdgeInsets.only(top: 12), + decoration: cardRadius(12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ...List.generate( + widget.amRequestViewModel.amRequestModeList.length, + (index) => InkWell( + onTap: () { + setState(() { + _erTransportationMethod = widget.amRequestViewModel.amRequestModeList[index]; + }); + }, + child: Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + flex: 4, + child: ListTile( + contentPadding: EdgeInsets.only(left: 0.0, right: 0.0), + title: Row( + children: [ + Radio( + value: widget.amRequestViewModel.amRequestModeList[index], + groupValue: _erTransportationMethod, + onChanged: (value) { + setState(() { + _erTransportationMethod = value; + }); + }, + ), + Flexible( + child: Text( + projectViewModel.isArabic ? widget.amRequestViewModel.amRequestModeList[index].textN : widget.amRequestViewModel.amRequestModeList[index].text, + style: TextStyle( + fontSize: 12.0, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ), + ), + ], + ), + ), + ), + Expanded( + flex: 1, + child: Text( + TranslationBase.of(context).sar + ' ${widget.amRequestViewModel.amRequestModeList[index].price}', + style: TextStyle( + fontSize: 12.0, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + ), + ), + ) + ], ), ), - Expanded( - flex: 1, - child: Texts(TranslationBase.of(context).sar + ' ${widget.amRequestViewModel.amRequestModeList[index].price}'), - ) - ], + ), ), - ), + ], ), ), SizedBox( height: 12, ), - Texts(TranslationBase.of(context).directionHeading), - SizedBox( - height: 5, - ), + Text(TranslationBase.of(context).directionHeading, style: TextStyle(fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.w600)), Container( width: double.maxFinite, child: Row( @@ -136,22 +157,26 @@ class _SelectTransportationMethodState extends State }, child: Container( width: double.maxFinite, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey, width: 0.5), - color: Colors.white, - ), child: ListTile( - title: Texts(TranslationBase.of(context).toHospital), - leading: Radio( - value: Direction.ToHospital, - groupValue: _direction, - onChanged: (value) { - setState(() { - _direction = value; - }); - }, + contentPadding: EdgeInsets.only(left: 0.0, right: 0.0), + title: Row( + children: [ + Radio( + value: Direction.ToHospital, + groupValue: _direction, + onChanged: (value) { + setState(() { + _direction = value; + }); + }, + ), + Text(TranslationBase.of(context).toHospital, + style: TextStyle( + fontSize: 12.0, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + )), + ], ), ), ), @@ -166,22 +191,26 @@ class _SelectTransportationMethodState extends State }, child: Container( width: double.maxFinite, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey, width: 0.5), - color: Colors.white, - ), child: ListTile( - title: Texts(TranslationBase.of(context).fromHospital), - leading: Radio( - value: Direction.FromHospital, - groupValue: _direction, - onChanged: (value) { - setState(() { - _direction = value; - }); - }, + contentPadding: EdgeInsets.only(left: 0.0, right: 0.0), + title: Row( + children: [ + Radio( + value: Direction.FromHospital, + groupValue: _direction, + onChanged: (value) { + setState(() { + _direction = value; + }); + }, + ), + Text(TranslationBase.of(context).fromHospital, + style: TextStyle( + fontSize: 12.0, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + )), + ], ), ), ), @@ -197,7 +226,7 @@ class _SelectTransportationMethodState extends State SizedBox( height: 8, ), - Texts(TranslationBase.of(context).wayHeading), + Text(TranslationBase.of(context).wayHeading, style: TextStyle(fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.w600)), SizedBox( height: 5, ), @@ -213,22 +242,26 @@ class _SelectTransportationMethodState extends State }); }, child: Container( - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey, width: 0.5), - color: Colors.white, - ), child: ListTile( - title: Texts(TranslationBase.of(context).oneDirec), - leading: Radio( - value: Way.OneWay, - groupValue: _way, - onChanged: (value) { - setState(() { - _way = value; - }); - }, + contentPadding: EdgeInsets.only(left: 0.0, right: 0.0), + title: Row( + children: [ + Radio( + value: Way.OneWay, + groupValue: _way, + onChanged: (value) { + setState(() { + _way = value; + }); + }, + ), + Text(TranslationBase.of(context).oneDirec, + style: TextStyle( + fontSize: 12.0, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + )), + ], ), ), ), @@ -242,22 +275,26 @@ class _SelectTransportationMethodState extends State }); }, child: Container( - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.grey, width: 0.5), - color: Colors.white, - ), child: ListTile( - title: Texts(TranslationBase.of(context).twoDirec), - leading: Radio( - value: Way.TwoWays, - groupValue: _way, - onChanged: (value) { - setState(() { - _way = value; - }); - }, + contentPadding: EdgeInsets.only(left: 0.0, right: 0.0), + title: Row( + children: [ + Radio( + value: Way.TwoWays, + groupValue: _way, + onChanged: (value) { + setState(() { + _way = value; + }); + }, + ), + Text(TranslationBase.of(context).twoDirec, + style: TextStyle( + fontSize: 12.0, + letterSpacing: -0.48, + fontWeight: FontWeight.w600, + )), + ], ), ), ), diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/Summary.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/Summary.dart index 21bb5e89..4b59a8fa 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/Summary.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/Summary.dart @@ -3,8 +3,8 @@ import 'package:diplomaticquarterapp/core/model/er/PatientER_RC.dart'; import 'package:diplomaticquarterapp/core/viewModels/er/am_request_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -31,91 +31,73 @@ class _SummaryState extends State { isShowAppBar: false, body: SingleChildScrollView( child: Container( - margin: EdgeInsets.only(left: 12, right: 12), + margin: EdgeInsets.only(left: 12, right: 12, top: 12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts(TranslationBase.of(context).RRTSummary), + Text(TranslationBase.of(context).RRTSummary, style: TextStyle(fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.w600)), SizedBox( height: 5, ), Container( width: double.infinity, padding: EdgeInsets.all(10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(12), - ), + // margin: EdgeInsets.only(top: 12), + decoration: cardRadius(12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts( - TranslationBase.of(context).transportMethod, - color: Colors.grey, - ), + _getNormalText(TranslationBase.of(context).transportMethod), projectViewModel.isArabic - ? Texts( + ? _getNormalText( '${widget.patientER_RC.patientERTransportationMethod.textN}', - bold: true, + isBold: true, ) - : Texts( + : _getNormalText( '${widget.patientER_RC.patientERTransportationMethod.text}', - bold: true, + isBold: true, ), SizedBox( height: 8, ), - Texts( - TranslationBase.of(context).directions, - color: Colors.grey, - ), - Texts( + _getNormalText(TranslationBase.of(context).directions), + _getNormalText( widget.patientER_RC.transportationDetails.direction == 0 ? TranslationBase.of(context).toHospital : TranslationBase.of(context).fromHospital, - bold: true, + isBold: true, ), SizedBox( height: 8, ), - Texts( + _getNormalText( TranslationBase.of(context).pickupLocation, - color: Colors.grey, ), - Texts( + _getNormalText( '${widget.patientER_RC.transportationDetails.pickupLocationName}', - bold: true, + isBold: true, ), SizedBox( height: 8, ), - Texts( - TranslationBase.of(context).dropoffLocation, - color: Colors.grey, - ), - Texts( + _getNormalText(TranslationBase.of(context).dropoffLocation), + _getNormalText( '${widget.patientER_RC.transportationDetails.dropoffLocationName}', - bold: true, + isBold: true, ), SizedBox( height: 8, ), - Texts( - TranslationBase.of(context).selectAmbulate, - color: Colors.grey, - ), - Texts( + _getNormalText(TranslationBase.of(context).selectAmbulate), + _getNormalText( '${widget.patientER_RC.transportationDetails.ambulateTitle}', - bold: true, + isBold: true, ), SizedBox( height: 8, ), - Texts( - TranslationBase.of(context).notes, - color: Colors.grey, - ), - Texts( + _getNormalText(TranslationBase.of(context).notes), + _getNormalText( '${widget.patientER_RC.transportationDetails.notes ?? '---'}', - bold: true, + isBold: true, ), SizedBox( height: 8, @@ -126,23 +108,26 @@ class _SummaryState extends State { SizedBox( height: 20, ), - Texts( - TranslationBase.of(context).billAmount, - textAlign: TextAlign.start, - ), + Text(TranslationBase.of(context).billAmount, style: TextStyle(fontSize: 16.0, letterSpacing: -0.64, fontWeight: FontWeight.w600)), SizedBox( height: 5, ), Container( height: 55, padding: EdgeInsets.all(10), - decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)), + decoration: cardRadius(12), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [Texts(TranslationBase.of(context).patientShareTotal + ':'), Texts(TranslationBase.of(context).sar + ' ${widget.patientER_RC.patientERTransportationMethod.priceTotal}')], + children: [ + _getNormalText(TranslationBase.of(context).patientShareTotal + ':'), + Container( + padding: EdgeInsets.only(left: 20.0, right: 20.0), + child: _getNormalText(TranslationBase.of(context).sar + ' ${widget.patientER_RC.patientERTransportationMethod.priceTotal}', isBold: true, isTotal: true) + ), + ], ), ), - SizedBox(height: 130), + SizedBox(height: 50), ], ), ), @@ -156,4 +141,20 @@ class _SummaryState extends State { ), ); } + + _getNormalText(text, {bool isBold = false, bool isTotal = false}) { + return Text( + text, + style: TextStyle( + fontSize: isBold + ? isTotal + ? 16 + : 12 + : 10, + letterSpacing: -0.5, + color: isBold ? Colors.black : Colors.grey[700], + fontWeight: FontWeight.w600, + ), + ); + } } diff --git a/lib/pages/ErService/ErOptions.dart b/lib/pages/ErService/ErOptions.dart index 095ad884..88b21b11 100644 --- a/lib/pages/ErService/ErOptions.dart +++ b/lib/pages/ErService/ErOptions.dart @@ -9,7 +9,6 @@ import 'package:provider/provider.dart'; import '../../uitl/translations_delegate_base.dart'; import 'AmbulanceReq.dart'; -import 'EdOnline/DdServicesPage.dart'; import 'NearestEr.dart'; class ErOptions extends StatefulWidget { @@ -75,26 +74,26 @@ class _ErOptionsState extends State { ), InkWell( onTap: () { - // Navigator.push(context, FadePage(page: DdServicesPage())); + if (rrtLocked) Navigator.push(context, FadePage(page: RRTMainScreen())); }, child: MedicalProfileItem( - title: "ED", + title: TranslationBase.of(context).RRTTitle, imagePath: 'assets/images/new-design/AM.PNG', - subTitle: TranslationBase.of(context).service, + subTitle: TranslationBase.of(context).RRTSubTitle, isPngImage: true, - isEnable: false, + isEnable: rrtLocked, ), ), InkWell( onTap: () { - if(rrtLocked) Navigator.push(context, FadePage(page: RRTMainScreen())); + // Navigator.push(context, FadePage(page: DdServicesPage())); }, child: MedicalProfileItem( - title: TranslationBase.of(context).rrtService, + title: "ED", imagePath: 'assets/images/new-design/AM.PNG', subTitle: TranslationBase.of(context).service, isPngImage: true, - isEnable: rrtLocked, + isEnable: false, ), ), ], diff --git a/lib/pages/ErService/OrderLogPage.dart b/lib/pages/ErService/OrderLogPage.dart index 4ecde680..9bb56b9c 100644 --- a/lib/pages/ErService/OrderLogPage.dart +++ b/lib/pages/ErService/OrderLogPage.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/viewModels/er/am_request_view_model.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/others/OrderLogItem.dart'; import 'package:flutter/cupertino.dart'; @@ -15,7 +16,7 @@ class OrderLogPage extends StatelessWidget { return Container( margin: EdgeInsets.all(10), padding: EdgeInsets.all(8), - child: ListView.builder( + child: amRequestViewModel.patientAmbulanceRequestOrdersList.length > 0 ? ListView.builder( itemCount: amRequestViewModel.patientAmbulanceRequestOrdersList.length, itemBuilder: (context, index) => Container( margin: EdgeInsets.all(8), @@ -69,7 +70,7 @@ class OrderLogPage extends StatelessWidget { ], ), ), - ), + ) : getNoDataWidget(context), ); } diff --git a/lib/pages/ErService/rapid-response-team/rrt-order-list-item.dart b/lib/pages/ErService/rapid-response-team/rrt-order-list-item.dart index 8a4f1e18..dfb7cdaa 100644 --- a/lib/pages/ErService/rapid-response-team/rrt-order-list-item.dart +++ b/lib/pages/ErService/rapid-response-team/rrt-order-list-item.dart @@ -103,21 +103,21 @@ class RRTLogListItemState extends State { '${TranslationBase.of(context).requestID}: ${widget.order.iD}', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64, height: 25 / 16), ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).locationa + ": ", - style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), - ), - Expanded( - child: Text( - widget.order.projectName.toString(), - style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.56), - ), - ), - ], - ), + // Row( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text( + // TranslationBase.of(context).locationa + ": ", + // style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), + // ), + // Expanded( + // child: Text( + // widget.order.projectName.toString(), + // style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.56), + // ), + // ), + // ], + // ), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ diff --git a/lib/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart b/lib/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart index 0a25ca7a..9d9ca428 100644 --- a/lib/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart +++ b/lib/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart @@ -43,7 +43,7 @@ class RRTRequestPickupAddressPageState extends State { child: Text(TranslationBase.of(context).youCanPayByTheFollowingOptions, style: TextStyle(fontSize: 13, color: Theme.of(context).appBarTheme.color, fontWeight: FontWeight.w500), maxLines: 2)), - paymentOptions(), + Container(margin: EdgeInsets.only(left: 15.0, right: 15.0, top: 10.0), child: getPaymentMethods()) ], ), ), diff --git a/lib/pages/ErService/widgets/StepsWidget.dart b/lib/pages/ErService/widgets/StepsWidget.dart index 56b3de6b..219cfd60 100644 --- a/lib/pages/ErService/widgets/StepsWidget.dart +++ b/lib/pages/ErService/widgets/StepsWidget.dart @@ -1,5 +1,7 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -12,216 +14,331 @@ class StepsWidget extends StatelessWidget { @override Widget build(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); - return projectViewModel.isArabic? - Stack( - children: [ - Container( - height: 50, - width: MediaQuery.of(context).size.width, - color: Colors.transparent, - child: Center( - child: Divider( - color: Colors.grey, - height: 0.75, - thickness: 0.75, + return Container( + width: double.infinity, + padding: EdgeInsets.only(left: 12, right: 12, bottom: 12), + child: Row( + children: [ + Expanded( + child: showProgress( + title: TranslationBase.of(context).transportation, + status: index == 0 + ? TranslationBase.of(context).inPrgress + : index > 0 + ? TranslationBase.of(context).completed + : TranslationBase.of(context).locked, + color: index == 0 ? CustomColors.orange : CustomColors.green, ), ), - ), - Positioned( - top: 10, - right: 0, - child: InkWell( - onTap: () => changeCurrentTab(0), - child: Container( - width: 35, - height: 35, - decoration: BoxDecoration( - border: index > 0 ? null:Border.all(color: Colors.black,width: 0.75), - shape: BoxShape.circle, - color: index == 0 ? Colors.grey[800] : index > 0 ?Colors.green: Colors.white, - ), - child: Center( - child: Texts( - '1', - color: index == 0 ? Colors.white : index > 0 ?Colors.white: Colors.grey[800], - ), - ), + Expanded( + child: showProgress( + title: TranslationBase.of(context).locationa, + status: index == 1 + ? TranslationBase.of(context).inPrgress + : index > 1 + ? TranslationBase.of(context).completed + : TranslationBase.of(context).locked, + color: index == 1 + ? CustomColors.orange + : index > 1 + ? CustomColors.green + : CustomColors.grey2, ), ), - ), - Positioned( - top: 10, - right: MediaQuery.of(context).size.width * 0.3, - child: InkWell( - onTap: () => index >= 2 ? changeCurrentTab(1) : null, - child: Container( - width: 35, - height: 35, - decoration: BoxDecoration( - border: index > 1 ? null:Border.all(color: Colors.black,width: 0.75), - shape: BoxShape.circle, - color: index == 1 ? Colors.grey[800] : index > 1 ?Colors.green: Colors.white, - ), - child: Center( - child: Texts( - '2', - color: index == 1? Colors.white : index > 1 ?Colors.white: Colors.grey[800], - ), - ), + Expanded( + child: showProgress( + title: TranslationBase.of(context).otherInfo, + status: index == 2 + ? TranslationBase.of(context).inPrgress + : index > 2 + ? TranslationBase.of(context).completed + : TranslationBase.of(context).locked, + color: index == 2 + ? CustomColors.orange + : index > 2 + ? CustomColors.green + : CustomColors.grey2, ), ), - ), - Positioned( - top: 10, - right: MediaQuery.of(context).size.width * 0.6, - child: InkWell( - onTap: () => index >= 3 ? changeCurrentTab(2) : null, - child: Container( - width: 35, - height: 35, - decoration: BoxDecoration( - shape: BoxShape.circle, - border: index > 2 ? null:Border.all(color: Colors.black,width: 0.75), - color: index == 2 ? Colors.grey[800] : index > 1 ?Colors.green: Colors.white, - ), - child: Center( - child: Texts( - '3', - color: index == 2? Colors.white : index > 1 ?Colors.white: Colors.grey[800], - ), - ), - ), + showProgress( + title: TranslationBase.of(context).RRTSummary, + status: index == 3 ? TranslationBase.of(context).inPrgress : TranslationBase.of(context).locked, + color: index == 3 + ? CustomColors.orange + : index > 4 + ? CustomColors.green + : CustomColors.grey2, + isNeedBorder: false, ), - ), - Positioned( - top: 10, - left: 0, - child: InkWell( - onTap: () => index == 2 ?changeCurrentTab(3):null, - child: Container( - width: 35, - height: 35, - decoration: BoxDecoration( - border: Border.all(color: Colors.black,width: 0.75), + ], + ), + ); - shape: BoxShape.circle, - color: index == 3 ? Colors.grey[800] : Colors.white, - ), - child: Center( - child: Texts( - '4', - color: index == 3 ? Colors.white : Colors.grey[800], - ), - ), - ), - ), - ), - ], - ): - Stack( + // return projectViewModel.isArabic? + // Stack( + // children: [ + // Container( + // height: 50, + // width: MediaQuery.of(context).size.width, + // color: Colors.transparent, + // child: Center( + // child: Divider( + // color: Colors.grey, + // height: 0.75, + // thickness: 0.75, + // ), + // ), + // ), + // Positioned( + // top: 10, + // right: 0, + // child: InkWell( + // onTap: () => changeCurrentTab(0), + // child: Container( + // width: 35, + // height: 35, + // decoration: BoxDecoration( + // border: index > 0 ? null:Border.all(color: Colors.black,width: 0.75), + // shape: BoxShape.circle, + // color: index == 0 ? Colors.grey[800] : index > 0 ?Colors.green: Colors.white, + // ), + // child: Center( + // child: Texts( + // '1', + // color: index == 0 ? Colors.white : index > 0 ?Colors.white: Colors.grey[800], + // ), + // ), + // ), + // ), + // ), + // Positioned( + // top: 10, + // right: MediaQuery.of(context).size.width * 0.3, + // child: InkWell( + // onTap: () => index >= 2 ? changeCurrentTab(1) : null, + // child: Container( + // width: 35, + // height: 35, + // decoration: BoxDecoration( + // border: index > 1 ? null:Border.all(color: Colors.black,width: 0.75), + // shape: BoxShape.circle, + // color: index == 1 ? Colors.grey[800] : index > 1 ?Colors.green: Colors.white, + // ), + // child: Center( + // child: Texts( + // '2', + // color: index == 1? Colors.white : index > 1 ?Colors.white: Colors.grey[800], + // ), + // ), + // ), + // ), + // ), + // Positioned( + // top: 10, + // right: MediaQuery.of(context).size.width * 0.6, + // child: InkWell( + // onTap: () => index >= 3 ? changeCurrentTab(2) : null, + // child: Container( + // width: 35, + // height: 35, + // decoration: BoxDecoration( + // shape: BoxShape.circle, + // border: index > 2 ? null:Border.all(color: Colors.black,width: 0.75), + // color: index == 2 ? Colors.grey[800] : index > 1 ?Colors.green: Colors.white, + // ), + // child: Center( + // child: Texts( + // '3', + // color: index == 2? Colors.white : index > 1 ?Colors.white: Colors.grey[800], + // ), + // ), + // ), + // ), + // ), + // Positioned( + // top: 10, + // left: 0, + // child: InkWell( + // onTap: () => index == 2 ?changeCurrentTab(3):null, + // child: Container( + // width: 35, + // height: 35, + // decoration: BoxDecoration( + // border: Border.all(color: Colors.black,width: 0.75), + // + // shape: BoxShape.circle, + // color: index == 3 ? Colors.grey[800] : Colors.white, + // ), + // child: Center( + // child: Texts( + // '4', + // color: index == 3 ? Colors.white : Colors.grey[800], + // ), + // ), + // ), + // ), + // ), + // ], + // ): + // Stack( + // children: [ + // Container( + // height: 50, + // width: MediaQuery.of(context).size.width, + // color: Colors.transparent, + // child: Center( + // child: Divider( + // color: Colors.grey, + // height: 0.75, + // thickness: 0.75, + // ), + // ), + // ), + // Positioned( + // top: 10, + // left: 0, + // child: InkWell( + // onTap: () => changeCurrentTab(0), + // child: Container( + // width: 35, + // height: 35, + // decoration: BoxDecoration( + // border: index > 0 ? null:Border.all(color: Colors.black,width: 0.75), + // shape: BoxShape.circle, + // color: index == 0 ? Colors.grey[800] : index > 0 ?Colors.green: Colors.white, + // ), + // child: Center( + // child: Texts( + // '1', + // color: index == 0 ? Colors.white : index > 0 ?Colors.white: Colors.grey[800], + // ), + // ), + // ), + // ), + // ), + // Positioned( + // top: 10, + // left: MediaQuery.of(context).size.width * 0.3, + // child: InkWell( + // onTap: () => index >= 2 ? changeCurrentTab(1) : null, + // child: Container( + // width: 35, + // height: 35, + // decoration: BoxDecoration( + // border: index > 1 ? null:Border.all(color: Colors.black,width: 0.75), + // shape: BoxShape.circle, + // color: index == 1 ? Colors.grey[800] : index > 1 ?Colors.green: Colors.white, + // ), + // child: Center( + // child: Texts( + // '2', + // color: index == 1? Colors.white : index > 1 ?Colors.white: Colors.grey[800], + // ), + // ), + // ), + // ), + // ), + // Positioned( + // top: 10, + // left: MediaQuery.of(context).size.width * 0.6, + // child: InkWell( + // onTap: () => index >= 3 ? changeCurrentTab(2) : null, + // child: Container( + // width: 35, + // height: 35, + // decoration: BoxDecoration( + // shape: BoxShape.circle, + // border: index > 2 ? null:Border.all(color: Colors.black,width: 0.75), + // color: index == 2 ? Colors.grey[800] : index > 1 ?Colors.green: Colors.white, + // ), + // child: Center( + // child: Texts( + // '3', + // color: index == 2? Colors.white : index > 1 ?Colors.white: Colors.grey[800], + // ), + // ), + // ), + // ), + // ), + // Positioned( + // top: 10, + // right: 0, + // child: InkWell( + // onTap: () => index == 2 ?changeCurrentTab(3):null, + // child: Container( + // width: 35, + // height: 35, + // decoration: BoxDecoration( + // border: Border.all(color: Colors.black,width: 0.75), + // + // shape: BoxShape.circle, + // color: index == 3 ? Colors.grey[800] : Colors.white, + // ), + // child: Center( + // child: Texts( + // '4', + // color: index == 3 ? Colors.white : Colors.grey[800], + // ), + // ), + // ), + // ), + // ), + // ], + // ); + } + + Widget showProgress({String title, String status, Color color, bool isNeedBorder = true}) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - height: 50, - width: MediaQuery.of(context).size.width, - color: Colors.transparent, - child: Center( - child: Divider( - color: Colors.grey, - height: 0.75, - thickness: 0.75, - ), - ), - ), - Positioned( - top: 10, - left: 0, - child: InkWell( - onTap: () => changeCurrentTab(0), - child: Container( - width: 35, - height: 35, - decoration: BoxDecoration( - border: index > 0 ? null:Border.all(color: Colors.black,width: 0.75), - shape: BoxShape.circle, - color: index == 0 ? Colors.grey[800] : index > 0 ?Colors.green: Colors.white, - ), - child: Center( - child: Texts( - '1', - color: index == 0 ? Colors.white : index > 0 ?Colors.white: Colors.grey[800], - ), - ), - ), - ), - ), - Positioned( - top: 10, - left: MediaQuery.of(context).size.width * 0.3, - child: InkWell( - onTap: () => index >= 2 ? changeCurrentTab(1) : null, - child: Container( - width: 35, - height: 35, - decoration: BoxDecoration( - border: index > 1 ? null:Border.all(color: Colors.black,width: 0.75), - shape: BoxShape.circle, - color: index == 1 ? Colors.grey[800] : index > 1 ?Colors.green: Colors.white, - ), - child: Center( - child: Texts( - '2', - color: index == 1? Colors.white : index > 1 ?Colors.white: Colors.grey[800], + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + width: 26, + height: 26, + decoration: containerRadius(color, 200), + child: Icon( + Icons.done, + color: Colors.white, + size: 16, + ), ), - ), + if (isNeedBorder) + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: mDivider(Colors.grey), + )), + ], ), - ), - ), - Positioned( - top: 10, - left: MediaQuery.of(context).size.width * 0.6, - child: InkWell( - onTap: () => index >= 3 ? changeCurrentTab(2) : null, - child: Container( - width: 35, - height: 35, - decoration: BoxDecoration( - shape: BoxShape.circle, - border: index > 2 ? null:Border.all(color: Colors.black,width: 0.75), - color: index == 2 ? Colors.grey[800] : index > 1 ?Colors.green: Colors.white, - ), - child: Center( - child: Texts( - '3', - color: index == 2? Colors.white : index > 1 ?Colors.white: Colors.grey[800], - ), + mHeight(8), + Text( + title, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + letterSpacing: -0.44, ), ), - ), - ), - Positioned( - top: 10, - right: 0, - child: InkWell( - onTap: () => index == 2 ?changeCurrentTab(3):null, - child: Container( - width: 35, - height: 35, - decoration: BoxDecoration( - border: Border.all(color: Colors.black,width: 0.75), - - shape: BoxShape.circle, - color: index == 3 ? Colors.grey[800] : Colors.white, - ), - child: Center( - child: Texts( - '4', - color: index == 3 ? Colors.white : Colors.grey[800], + mHeight(2), + Container( + padding: EdgeInsets.all(5), + decoration: containerRadius(color.withOpacity(0.2), 4), + child: Text( + status, + style: TextStyle( + fontSize: 8, + fontWeight: FontWeight.w600, + letterSpacing: -0.32, + color: color, ), ), ), - ), - ), + ], + ) ], ); } diff --git a/lib/pages/ToDoList/payment_method_select.dart b/lib/pages/ToDoList/payment_method_select.dart index 1cccf517..21b08fc3 100644 --- a/lib/pages/ToDoList/payment_method_select.dart +++ b/lib/pages/ToDoList/payment_method_select.dart @@ -8,8 +8,9 @@ import 'package:flutter/material.dart'; class PaymentMethod extends StatefulWidget { Function onSelectedMethod; + bool isShowInstallments; - PaymentMethod({this.onSelectedMethod}); + PaymentMethod({this.onSelectedMethod, this.isShowInstallments = false}); @override _PaymentMethodState createState() => _PaymentMethodState(); @@ -185,55 +186,56 @@ class _PaymentMethodState extends State { ), ), ), - Container( - width: double.infinity, - child: InkWell( - onTap: () { - updateSelectedPaymentMethod("Installment"); - }, - child: Card( - elevation: 0.0, - margin: EdgeInsets.fromLTRB(8.0, 16.0, 8.0, 8.0), - color: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - side: selectedPaymentMethod == "Installment" ? BorderSide(color: Colors.green, width: 2.0) : BorderSide(color: Colors.transparent, width: 0.0), - ), - child: Padding( - padding: const EdgeInsets.all(12.0), - child: Row( - children: [ - Container( - width: 24, - height: 24, - decoration: containerColorRadiusBorderWidth(selectedPaymentMethod == "Installment" ? CustomColors.accentColor : Colors.transparent, 100, Colors.grey, 0.5), - ), - mWidth(12), - Container( - height: 60.0, - padding: EdgeInsets.all(7.0), - width: 60, - child: Image.asset("assets/images/new/payment/installments.png"), - ), - mFlex(1), - if (selectedPaymentMethod == "Installment") + if (widget.isShowInstallments) + Container( + width: double.infinity, + child: InkWell( + onTap: () { + updateSelectedPaymentMethod("Installment"); + }, + child: Card( + elevation: 0.0, + margin: EdgeInsets.fromLTRB(8.0, 16.0, 8.0, 8.0), + color: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + side: selectedPaymentMethod == "Installment" ? BorderSide(color: Colors.green, width: 2.0) : BorderSide(color: Colors.transparent, width: 0.0), + ), + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Row( + children: [ Container( - decoration: containerRadius(CustomColors.green, 200), - padding: EdgeInsets.only(top: 6, bottom: 6, left: 12, right: 12), - child: Text( - TranslationBase.of(context).paymentSelected, - style: TextStyle( - color: Colors.white, - fontSize: 11, + width: 24, + height: 24, + decoration: containerColorRadiusBorderWidth(selectedPaymentMethod == "Installment" ? CustomColors.accentColor : Colors.transparent, 100, Colors.grey, 0.5), + ), + mWidth(12), + Container( + height: 60.0, + padding: EdgeInsets.all(7.0), + width: 60, + child: Image.asset("assets/images/new/payment/installments.png"), + ), + mFlex(1), + if (selectedPaymentMethod == "Installment") + Container( + decoration: containerRadius(CustomColors.green, 200), + padding: EdgeInsets.only(top: 6, bottom: 6, left: 12, right: 12), + child: Text( + TranslationBase.of(context).paymentSelected, + style: TextStyle( + color: Colors.white, + fontSize: 11, + ), ), ), - ), - ], + ], + ), ), ), ), ), - ), Platform.isIOS ? Container( width: double.infinity, diff --git a/lib/pages/medical/balance/advance_payment_page.dart b/lib/pages/medical/balance/advance_payment_page.dart index 6ade52bd..a7f308af 100644 --- a/lib/pages/medical/balance/advance_payment_page.dart +++ b/lib/pages/medical/balance/advance_payment_page.dart @@ -313,9 +313,11 @@ class _AdvancePaymentPageState extends State { Navigator.push( context, FadePage( - page: PaymentMethod(onSelectedMethod: (String metohd) { - setState(() {}); - }), + page: PaymentMethod( + onSelectedMethod: (String metohd) { + setState(() {}); + }, + isShowInstallments: num.tryParse(amount) >= 1000 ? true : false), ), ).then( (value) { diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 0bdfb6f7..b15f7adb 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2610,6 +2610,14 @@ class TranslationBase { String get laserClinic => localizedValues["laserClinic"][locale.languageCode]; String get noImage => localizedValues["noImage"][locale.languageCode]; + + String get signoutMessage => localizedValues["signoutMessage"][locale.languageCode]; + + String get RRTTitle => localizedValues["RRTTitle"][locale.languageCode]; + + String get RRTSubTitle => localizedValues["RRTSubTitle"][locale.languageCode]; + + String get transportation => localizedValues["transportation"][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index affcb02a..9e5a88d4 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -28,6 +28,7 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -475,20 +476,28 @@ class _AppDrawerState extends State { } logout() async { - authenticatedUserObject.logout(); - projectProvider.isLogin = false; - await authenticatedUserObject.getUser(); - _vitalSignService.heightCm = ""; - _vitalSignService.weightKg = ""; - await _privilegeService.getPrivilege(); - projectProvider.setPrivilegeModelList(privilege: _privilegeService.privilegeModelList); - var appLanguage = await sharedPref.getString(APP_LANGUAGE); - await sharedPref.clear(); - await sharedPref.setString(APP_LANGUAGE, appLanguage); - await sharedPref.remove(APPOINTMENT_HISTORY_MEDICAL); - this.user = null; - Navigator.of(context).pushNamed(HOME); - // projectProvider.platformBridge().unRegisterHmgGeofences(); + ConfirmDialog dialog = new ConfirmDialog( + context: context, + confirmMessage: TranslationBase.of(context).signoutMessage, + okText: TranslationBase.of(context).confirm, + cancelText: TranslationBase.of(context).cancel_nocaps, + okFunction: () async { + authenticatedUserObject.logout(); + projectProvider.isLogin = false; + await authenticatedUserObject.getUser(); + _vitalSignService.heightCm = ""; + _vitalSignService.weightKg = ""; + await _privilegeService.getPrivilege(); + projectProvider.setPrivilegeModelList(privilege: _privilegeService.privilegeModelList); + var appLanguage = await sharedPref.getString(APP_LANGUAGE); + await sharedPref.clear(); + await sharedPref.setString(APP_LANGUAGE, appLanguage); + await sharedPref.remove(APPOINTMENT_HISTORY_MEDICAL); + this.user = null; + Navigator.of(context).pushNamed(HOME); + }, + cancelFunction: () => {}); + dialog.showAlertDialog(context); } login() async { diff --git a/lib/widgets/pickupLocation/PickupLocationFromMap.dart b/lib/widgets/pickupLocation/PickupLocationFromMap.dart index d1efeef6..b0a67980 100644 --- a/lib/widgets/pickupLocation/PickupLocationFromMap.dart +++ b/lib/widgets/pickupLocation/PickupLocationFromMap.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/close_back.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -30,19 +31,23 @@ class PickupLocationFromMap extends StatelessWidget { @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); - return Scaffold( - appBar: isWithAppBar - ? AppBar( - elevation: 0, - textTheme: TextTheme( - headline6: - TextStyle(color: Colors.white, fontWeight: FontWeight.bold), - ), - title: Text('Location'), - leading: CloseBack(), - centerTitle: true, - ) - : null, + return AppScaffold( + isShowAppBar: true, + showNewAppBarTitle: true, + showNewAppBar: true, + appBarTitle: TranslationBase.of(context).selectLocation, + // appBar: isWithAppBar + // ? AppBar( + // elevation: 0, + // textTheme: TextTheme( + // headline6: + // TextStyle(color: Colors.white, fontWeight: FontWeight.bold), + // ), + // title: Text('Location'), + // leading: CloseBack(), + // centerTitle: true, + // ) + // : null, body: PlacePicker( apiKey: GOOGLE_API_KEY, enableMyLocationButton: true, From 23acdfd494aeeef991314f2d61f04c395f7c6305 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Thu, 4 Nov 2021 09:53:11 +0300 Subject: [PATCH 17/70] fix loader issue and design --- lib/config/localized_values.dart | 2 +- .../pharmacyModule/brand_view_model.dart | 14 +- lib/pages/pharmacies/product-brands.dart | 209 +++++++++--------- .../screens/cart-page/cart-order-page.dart | 2 +- lib/pages/pharmacy/profile/profile.dart | 3 + lib/widgets/pharmacy/product_tile.dart | 7 +- 6 files changed, 118 insertions(+), 119 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 207a65d7..dd0de321 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -494,7 +494,7 @@ const Map localizedValues = { "lakumPoint": {"en": "Point", "ar": "نقطه"}, "wishlist": {"en": "Wishlist", "ar": "المفضلة"}, "products": {"en": "Products", "ar": "المنتجات"}, - "reviews": {"en": "Reviews", "ar": "التقيمات"}, + "reviews": {"en": "Reviews", "ar": "التقييمات"}, "brands": {"en": "Brands", "ar": "العلامات التجارية"}, "productDetails": {"en": "Product Details", "ar": "تفاصيل المنتج"}, "medicationRefill": {"en": "Medication Refill", "ar": "تعبئة الأدوية"}, diff --git a/lib/core/viewModels/pharmacyModule/brand_view_model.dart b/lib/core/viewModels/pharmacyModule/brand_view_model.dart index 71e68a0a..6c2a00fc 100644 --- a/lib/core/viewModels/pharmacyModule/brand_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/brand_view_model.dart @@ -4,8 +4,7 @@ import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:diplomaticquarterapp/models/pharmacy/brandModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/topBrandsModel.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/brands_service.dart'; -import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; -import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; + import '../../../locator.dart'; @@ -25,28 +24,19 @@ class BrandsViewModel extends BaseViewModel{ Future getBrandsData() async { hasError = false; setState(ViewState.Busy); -// GifLoaderDialogUtils.showMyDialog( -// AppGlobal.context); + await _brandsService.getBrands(); -// GifLoaderDialogUtils.hideDialog( -// AppGlobal.context); if (_brandsService.hasError) { error = _brandsService.error; setState(ViewState.ErrorLocal); } else -// GifLoaderDialogUtils.hideDialog( -// locator().navigatorKey.currentContext); setState(ViewState.Idle); } Future getTopBrandsData() async { hasError = false; setState(ViewState.Busy); - GifLoaderDialogUtils.showMyDialog( - AppGlobal.context); await _topBrandsService.getTopBrands(); - GifLoaderDialogUtils.hideDialog( - AppGlobal.context); if (_topBrandsService.hasError) { error = _topBrandsService.error; setState(ViewState.ErrorLocal); diff --git a/lib/pages/pharmacies/product-brands.dart b/lib/pages/pharmacies/product-brands.dart index 7b6c6fd6..15960b30 100644 --- a/lib/pages/pharmacies/product-brands.dart +++ b/lib/pages/pharmacies/product-brands.dart @@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/pages/pharmacies/search_brands_page.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/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -34,117 +35,121 @@ class _ProductBrandsPageState extends State { isPharmacy: true, isShowDecPage: false, 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, + child: NetworkBaseView( + baseViewModel: model, + isLocalLoader:true, + 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.076, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), + Container( + height: 220, + width: double.infinity, color: Colors.white, + child: topBrand(context), ), - child: topBrand(context), - ), - SizedBox( - height: 10, - ), - Container( - height: MediaQuery.of(context).size.height * 0.056, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - color: Colors.white, + SizedBox( + height: 10, ), - 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, - ) - ], - ), + Container( + height: MediaQuery.of(context).size.height * 0.076, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.0), + color: Colors.white, ), - onTap: () { - Navigator.push( - context, - FadePage(page: SearchBrandsPage()), - ); - }, + child: topBrand(context), ), - ), - SizedBox( - height: 10, - ), - Container( - height: 250, - 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: MediaQuery.of(context).size.height * 0.066, + 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, ), - ), - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => FinalProductsPage( - id: model.brandsListList[index].id - .toString(), - )), - ); - }, + Texts( + TranslationBase.of(context).searchProductHere, + fontSize: 13, + ) + ], + ), + ), + onTap: () { + Navigator.push( + context, + FadePage(page: SearchBrandsPage()), ); - }), - ), - ], + }, + ), + ), + SizedBox( + height: 10, + ), + Container( + height: 250, + 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(), + )), + ); + }, + ); + }), + ), + ], + ), ), ), ), 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 69aaa04e..9c6fa42e 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -347,7 +347,7 @@ class _OrderBottomWidgetState extends State { child: Icon( Icons.info, size: 25, - color: Color(0xff005aff), + color: Color(0xFF4CAF50), // color: Color(0xff005aff), ), ), diff --git a/lib/pages/pharmacy/profile/profile.dart b/lib/pages/pharmacy/profile/profile.dart index f4534a01..8362b2c8 100644 --- a/lib/pages/pharmacy/profile/profile.dart +++ b/lib/pages/pharmacy/profile/profile.dart @@ -18,6 +18,7 @@ import 'package:diplomaticquarterapp/pages/pharmacy/order/Order.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.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/widgets/avatar/large_avatar.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -90,7 +91,9 @@ class _ProfilePageState extends State { return BaseView( onModelReady: (model) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); + GifLoaderDialogUtils.showMyDialog(context); model.getOrder(customerId, page_id); + GifLoaderDialogUtils.hideDialog(context); }, builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).myAccount, diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index 3b89c49c..c63410ba 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -129,7 +129,7 @@ class productTile extends StatelessWidget { ), ), Text( - '$approvedTotalReviews', + '${approvedTotalReviews} ${TranslationBase.of(context).reviews}', style: TextStyle(fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 13), ), ], @@ -159,7 +159,7 @@ class productTile extends StatelessWidget { icon: Icon( Icons.shopping_cart, size: 18, - color: Colors.blue, + color: Colors.green, ), onPressed: () async { GifLoaderDialogUtils.showMyDialog(context); @@ -253,7 +253,8 @@ class productTile extends StatelessWidget { // alignment: Alignment.topLeft, child: RichText( text: TextSpan( - text: '($productReviews reviews)', + text: '${productReviews} ${TranslationBase.of(context).reviews}', +// text: '($productReviews reviews)', style: TextStyle(fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 13), ), ), From f995a9fa8e9e84d63f8e72b095d8ad7a99b42173 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Thu, 4 Nov 2021 13:19:14 +0300 Subject: [PATCH 18/70] Ambulance request UI revamped --- .../notification_details_page.dart | 110 +++--- .../notifications/notifications_page.dart | 2 + .../AmbulanceRequestIndex.dart | 331 +++++++++++++++--- lib/pages/ErService/OrderLogPage.dart | 283 ++++++++++++--- lib/widgets/drawer/app_drawer_widget.dart | 2 +- .../pickupLocation/PickupLocationFromMap.dart | 35 +- 6 files changed, 573 insertions(+), 190 deletions(-) diff --git a/lib/pages/DrawerPages/notifications/notification_details_page.dart b/lib/pages/DrawerPages/notifications/notification_details_page.dart index 7633ab9c..6a24a52f 100644 --- a/lib/pages/DrawerPages/notifications/notification_details_page.dart +++ b/lib/pages/DrawerPages/notifications/notification_details_page.dart @@ -34,70 +34,68 @@ class NotificationsDetailsPage extends StatelessWidget { @override Widget build(BuildContext context) { - return BaseView( - builder: (_, model, widget) => AppScaffold( - isShowAppBar: true, - showNewAppBar: true, - showNewAppBarTitle: true, - appBarTitle: TranslationBase.of(context).notificationDetails, - body: SingleChildScrollView( - child: Center( - child: FractionallySizedBox( - widthFactor: 0.9, - child: Column( - children: [ - SizedBox( - height: 25, - ), - Container( - width: double.infinity, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(notification.createdOn)) + " " + DateUtil.formatDateToTimeLang(DateUtil.convertStringToDate(notification.createdOn), false), - style: TextStyle( + return AppScaffold( + isShowAppBar: true, + showNewAppBar: true, + showNewAppBarTitle: true, + appBarTitle: TranslationBase.of(context).notificationDetails, + body: SingleChildScrollView( + child: Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Column( + children: [ + SizedBox( + height: 25, + ), + Container( + width: double.infinity, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(notification.createdOn)) + " " + DateUtil.formatDateToTimeLang(DateUtil.convertStringToDate(notification.createdOn), false), + style: TextStyle( fontSize: 18.0, color: Colors.black, fontWeight: FontWeight.w600 - ), ), ), ), - SizedBox( - height: 15, - ), - if (notification.messageTypeData.length != 0) - FractionallySizedBox( - widthFactor: 0.9, - child: Image.network(notification.messageTypeData, - loadingBuilder: (BuildContext context, Widget child, - ImageChunkEvent loadingProgress) { - if (loadingProgress == null) return child; - return Center( - child: SizedBox( - width: 40.0, - height: 40.0, - child: AppCircularProgressIndicator(), - ), - ); - }, - fit: BoxFit - .fill) //Image.network(notification.messageTypeData), - ), - SizedBox( - height: 15, + ), + SizedBox( + height: 15, + ), + if (notification.messageTypeData.length != 0) + FractionallySizedBox( + widthFactor: 0.9, + child: Image.network(notification.messageTypeData, + loadingBuilder: (BuildContext context, Widget child, + ImageChunkEvent loadingProgress) { + if (loadingProgress == null) return child; + return Center( + child: SizedBox( + width: 40.0, + height: 40.0, + child: AppCircularProgressIndicator(), + ), + ); + }, + fit: BoxFit + .fill) //Image.network(notification.messageTypeData), ), - Row( - children: [ - Expanded( - child: Center( - child: Text(notification.message), - ), + SizedBox( + height: 15, + ), + Row( + children: [ + Expanded( + child: Center( + child: Text(notification.message), ), - ], - ), - ], - ), + ), + ], + ), + ], ), ), ), diff --git a/lib/pages/DrawerPages/notifications/notifications_page.dart b/lib/pages/DrawerPages/notifications/notifications_page.dart index 6ae318c3..498afde8 100644 --- a/lib/pages/DrawerPages/notifications/notifications_page.dart +++ b/lib/pages/DrawerPages/notifications/notifications_page.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/notifications/get_notifications_request_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/notifications_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; @@ -21,6 +22,7 @@ class NotificationsPage extends StatelessWidget { @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); + AppGlobal.context = context; return BaseView( onModelReady: (model) { GetNotificationsRequestModel getNotificationsRequestModel = diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart index bbae70a5..806c0738 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart @@ -1,14 +1,22 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/er/AmbulanceRequestOrdersModel.dart'; import 'package:diplomaticquarterapp/core/model/er/PatientER.dart'; import 'package:diplomaticquarterapp/core/model/er/PatientER_RC.dart'; import 'package:diplomaticquarterapp/core/viewModels/er/am_request_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/ErService/widgets/StepsWidget.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; -import 'package:diplomaticquarterapp/widgets/others/OrderLogItem.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/ConfirmWithMessageDialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'BillAmount.dart'; import 'PickupLocation.dart'; @@ -33,6 +41,10 @@ class _AmbulanceRequestIndexPageState extends State { TransportationDetails transportationDetails = new TransportationDetails(); + int status; + String _statusDisp; + Color _color; + _changeCurrentTab(int tab) { setState(() { currentIndex = tab; @@ -49,8 +61,31 @@ class _AmbulanceRequestIndexPageState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + + AmbulanceRequestOrdersModel order = widget.amRequestViewModel.pendingAmbulanceRequestOrder; + + if(widget.amRequestViewModel.pendingAmbulanceRequestOrder != null) { + int status = order.statusId; + String _statusDisp = order.statusText; + Color _color; + if (status == 1) { + //pending + _color = Color(0xffCC9B14); + } else if (status == 2) { + //processing + _color = Color(0xff2E303A); + } else if (status == 3) { + //completed + _color = Color(0xff359846); + } else if (status == 4 || status == 6 || status == 7) { + //cancel // Rejected + _color = Color(0xffD02127); + } + } + return AppScaffold( - body: widget.amRequestViewModel.pendingAmbulanceRequestOrder != null + body: widget.amRequestViewModel.pendingAmbulanceRequestOrder != null && order != null ? SingleChildScrollView( child: Column( children: [ @@ -58,60 +93,234 @@ class _AmbulanceRequestIndexPageState extends State { height: 10, ), Container( - margin: EdgeInsets.only(left: 18, right: 18), + margin: EdgeInsets.all(21), decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(2), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - OrderLogItem( - title: TranslationBase.of(context).reqId, - value: widget.amRequestViewModel.pendingAmbulanceRequestOrder.iD.toString(), - ), - OrderLogItem( - title: TranslationBase.of(context).status, - value: widget.amRequestViewModel.pendingAmbulanceRequestOrder.statusText, - ), - OrderLogItem( - title: TranslationBase.of(context).pickupDate, - value: DateUtil.getDayMonthYearDateFormatted(DateTime.tryParse(widget.amRequestViewModel.pendingAmbulanceRequestOrder.created)), - ), - OrderLogItem( - title: TranslationBase.of(context).pickupLocation, - value: widget.amRequestViewModel.pendingAmbulanceRequestOrder.pickupLocation, - ), - OrderLogItem( - title: TranslationBase.of(context).dropoffLocation, - value: widget.amRequestViewModel.pendingAmbulanceRequestOrder.dropOffLocation, + color: _color, + borderRadius: BorderRadius.all( + Radius.circular(10.0), + ), + boxShadow: [ + BoxShadow( + color: Color(0xff000000).withOpacity(.05), + blurRadius: 27, + offset: Offset(0, -3), ), - OrderLogItem( - title: TranslationBase.of(context).transportMethod, - value: widget.amRequestViewModel.pendingAmbulanceRequestOrder.serviceText, + ], + ), + child: Container( + margin: EdgeInsets.only(left: projectViewModel.isArabic ? 0 : 6, right: projectViewModel.isArabic ? 6 : 0), + padding: EdgeInsets.symmetric(vertical: 14, horizontal: 12), + decoration: BoxDecoration( + color: Colors.white, + border: Border.all(color: Colors.white, width: 1), + borderRadius: BorderRadius.only( + bottomRight: projectViewModel.isArabic ? Radius.circular(0) : Radius.circular(10.0), + topRight: projectViewModel.isArabic ? Radius.circular(0) : Radius.circular(10.0), + bottomLeft: projectViewModel.isArabic ? Radius.circular(10.0) : Radius.circular(0), + topLeft: projectViewModel.isArabic ? Radius.circular(10.0) : Radius.circular(0), ), - Container( - padding: EdgeInsets.all(10), - width: double.maxFinite, - margin: EdgeInsets.only(bottom: 4, left: 4, right: 4), - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(12), - bottomLeft: Radius.circular(12), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _statusDisp, + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: _color, letterSpacing: -0.4, height: 16 / 10), + ), + SizedBox(height: 6), + Text( + '${TranslationBase.of(context).requestID}: ${order.iD}', + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64, height: 25 / 16), + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).pickupDate + ": ", + style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), + ), + Expanded( + child: Text( + DateUtil.getDayMonthYearDateFormatted(DateTime.tryParse(order.created)), + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48, height: 16 / 10), + ), + ), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).transportMethod + ": ", + style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), + ), + Expanded( + child: Text( + order.serviceText, + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48, height: 16 / 10), + ), + ), + ], + ), + SizedBox( + height: 20.0, + ), + ], + ), ), - color: Colors.white), - child: SecondaryButton( - color: Colors.red[900], - textColor: Colors.white, - label: TranslationBase.of(context).cancel, - onTap: () { - widget.amRequestViewModel.updatePressOrder(presOrderID: widget.amRequestViewModel.pendingAmbulanceRequestOrder.iD); - }, + Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + SizedBox(height: 12), + if (order.statusId == 1 || order.statusId == 2) + InkWell( + onTap: () { + showConfirmMessage(widget.amRequestViewModel, order.iD); + }, + child: Container( + padding: EdgeInsets.symmetric(vertical: 8, horizontal: 14), + decoration: BoxDecoration( + color: Color(0xffD02127), + border: Border.all(color: Colors.white, width: 1), + borderRadius: BorderRadius.circular(10), + ), + child: Text( + TranslationBase.of(context).cancel_nocaps, + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.4), + ), + ), + ), + ], + ), + ], ), - ) - ], + Row( + children: [ + Container( + margin: projectViewModel.isArabic ? EdgeInsets.only(left: 10.0) : EdgeInsets.only(right: 10.0), + width: 8, + height: 8, + decoration: containerRadius( + CustomColors.textColor, + 100, + ), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).pickupLocation + ": ", + style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), + ), + Text( + order.pickupLocation.trim().toString(), + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48), + ), + ], + ), + ], + ), + Container( + height: 20.0, + width: 1.0, + color: CustomColors.grey2, + margin: const EdgeInsets.only(left: 3.0, right: 3.0), + ), + Row( + children: [ + Container( + margin: projectViewModel.isArabic ? EdgeInsets.only(left: 10.0) : EdgeInsets.only(right: 10.0), + width: 8, + height: 8, + decoration: containerRadius( + CustomColors.accentColor, + 100, + ), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).dropoffLocation + ": ", + style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), + ), + Text( + order.dropOffLocation.trim().toString(), + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48), + ), + ], + ), + ], + ), + ], + ), ), ), + + // Container( + // margin: EdgeInsets.only(left: 18, right: 18), + // decoration: BoxDecoration( + // color: Colors.white, + // borderRadius: BorderRadius.circular(2), + // ), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // OrderLogItem( + // title: TranslationBase.of(context).reqId, + // value: widget.amRequestViewModel.pendingAmbulanceRequestOrder.iD.toString(), + // ), + // OrderLogItem( + // title: TranslationBase.of(context).status, + // value: widget.amRequestViewModel.pendingAmbulanceRequestOrder.statusText, + // ), + // OrderLogItem( + // title: TranslationBase.of(context).pickupDate, + // value: DateUtil.getDayMonthYearDateFormatted(DateTime.tryParse(widget.amRequestViewModel.pendingAmbulanceRequestOrder.created)), + // ), + // OrderLogItem( + // title: TranslationBase.of(context).pickupLocation, + // value: widget.amRequestViewModel.pendingAmbulanceRequestOrder.pickupLocation, + // ), + // OrderLogItem( + // title: TranslationBase.of(context).dropoffLocation, + // value: widget.amRequestViewModel.pendingAmbulanceRequestOrder.dropOffLocation, + // ), + // OrderLogItem( + // title: TranslationBase.of(context).transportMethod, + // value: widget.amRequestViewModel.pendingAmbulanceRequestOrder.serviceText, + // ), + // Container( + // padding: EdgeInsets.all(10), + // width: double.maxFinite, + // margin: EdgeInsets.only(bottom: 4, left: 4, right: 4), + // decoration: BoxDecoration( + // borderRadius: BorderRadius.only( + // bottomRight: Radius.circular(12), + // bottomLeft: Radius.circular(12), + // ), + // color: Colors.white), + // child: SecondaryButton( + // color: Colors.red[900], + // textColor: Colors.white, + // label: TranslationBase.of(context).cancel, + // onTap: () { + // widget.amRequestViewModel.updatePressOrder(presOrderID: widget.amRequestViewModel.pendingAmbulanceRequestOrder.iD); + // }, + // ), + // ) + // ], + // ), + // ), ], ), ) @@ -164,4 +373,26 @@ class _AmbulanceRequestIndexPageState extends State { ), ); } + + void showConfirmMessage(AmRequestViewModel model, int presOrderID) { + showDialog( + context: context, + child: ConfirmWithMessageDialog( + message: TranslationBase.of(context).cancelOrderMsg, + onTap: () { + Future.delayed(new Duration(milliseconds: 300)).then((value) async { + GifLoaderDialogUtils.showMyDialog(context); + await model.updatePressOrder(presOrderID: presOrderID); + if (model.state == ViewState.ErrorLocal) { + Utils.showErrorToast(model.error); + GifLoaderDialogUtils.hideDialog(context); + } else { + AppToast.showSuccessToast(message: TranslationBase.of(context).processDoneSuccessfully); + GifLoaderDialogUtils.hideDialog(context); + } + }); + }, + )); + return; + } } diff --git a/lib/pages/ErService/OrderLogPage.dart b/lib/pages/ErService/OrderLogPage.dart index 9bb56b9c..644f3164 100644 --- a/lib/pages/ErService/OrderLogPage.dart +++ b/lib/pages/ErService/OrderLogPage.dart @@ -1,10 +1,18 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/er/AmbulanceRequestOrdersModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/er/am_request_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; -import 'package:diplomaticquarterapp/widgets/others/OrderLogItem.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/ConfirmWithMessageDialog.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; class OrderLogPage extends StatelessWidget { final AmRequestViewModel amRequestViewModel; @@ -13,64 +21,231 @@ class OrderLogPage extends StatelessWidget { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + + void showConfirmMessage(AmRequestViewModel model, int presOrderID) { + showDialog( + context: context, + child: ConfirmWithMessageDialog( + message: TranslationBase.of(context).cancelOrderMsg, + onTap: () { + Future.delayed(new Duration(milliseconds: 300)).then((value) async { + GifLoaderDialogUtils.showMyDialog(context); + await model.updatePressOrder(presOrderID: presOrderID); + if (model.state == ViewState.ErrorLocal) { + Utils.showErrorToast(model.error); + GifLoaderDialogUtils.hideDialog(context); + } else { + AppToast.showSuccessToast(message: TranslationBase.of(context).processDoneSuccessfully); + GifLoaderDialogUtils.hideDialog(context); + } + }); + }, + )); + return; + } + return Container( - margin: EdgeInsets.all(10), + // margin: EdgeInsets.all(10), padding: EdgeInsets.all(8), - child: amRequestViewModel.patientAmbulanceRequestOrdersList.length > 0 ? ListView.builder( - itemCount: amRequestViewModel.patientAmbulanceRequestOrdersList.length, - itemBuilder: (context, index) => Container( - margin: EdgeInsets.all(8), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(2), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - OrderLogItem( - title: TranslationBase.of(context).reqId, - value: amRequestViewModel.patientAmbulanceRequestOrdersList[index].iD.toString(), - ), - OrderLogItem( - title: TranslationBase.of(context).orderStatus, - value: amRequestViewModel.patientAmbulanceRequestOrdersList[index].statusText, - ), - OrderLogItem( - title: TranslationBase.of(context).pickupDate, - value: getDate(amRequestViewModel.patientAmbulanceRequestOrdersList[index].created), - ), - OrderLogItem( - title: TranslationBase.of(context).pickupLocation, - value: amRequestViewModel.patientAmbulanceRequestOrdersList[index].pickupLocation, - ), - OrderLogItem( - title: TranslationBase.of(context).dropoffLocation, - value: amRequestViewModel.patientAmbulanceRequestOrdersList[index].dropOffLocation, - ), - if (amRequestViewModel.patientAmbulanceRequestOrdersList[index].statusId == 1) - Container( - padding: EdgeInsets.all(10), - width: double.maxFinite, - margin: EdgeInsets.only(bottom: 4, left: 4, right: 4), + child: amRequestViewModel.patientAmbulanceRequestOrdersList.length > 0 + ? ListView.builder( + padding: EdgeInsets.all(21), + itemCount: amRequestViewModel.patientAmbulanceRequestOrdersList.length, + itemBuilder: (context, index) { + AmbulanceRequestOrdersModel order = amRequestViewModel.patientAmbulanceRequestOrdersList[index]; + + int status = order.statusId; + String _statusDisp = order.statusText; + Color _color; + if (status == 1) { + //pending + _color = Color(0xffCC9B14); + } else if (status == 2) { + //processing + _color = Color(0xff2E303A); + } else if (status == 3) { + //completed + _color = Color(0xff359846); + } else if (status == 4 || status == 6 || status == 7) { + //cancel // Rejected + _color = Color(0xffD02127); + } + + return Container( decoration: BoxDecoration( + color: _color, + borderRadius: BorderRadius.all( + Radius.circular(10.0), + ), + boxShadow: [ + BoxShadow( + color: Color(0xff000000).withOpacity(.05), + blurRadius: 27, + offset: Offset(0, -3), + ), + ], + ), + child: Container( + margin: EdgeInsets.only(left: projectViewModel.isArabic ? 0 : 6, right: projectViewModel.isArabic ? 6 : 0), + padding: EdgeInsets.symmetric(vertical: 14, horizontal: 12), + decoration: BoxDecoration( + color: Colors.white, + border: Border.all(color: Colors.white, width: 1), borderRadius: BorderRadius.only( - bottomRight: Radius.circular(12), - bottomLeft: Radius.circular(12), + bottomRight: projectViewModel.isArabic ? Radius.circular(0) : Radius.circular(10.0), + topRight: projectViewModel.isArabic ? Radius.circular(0) : Radius.circular(10.0), + bottomLeft: projectViewModel.isArabic ? Radius.circular(10.0) : Radius.circular(0), + topLeft: projectViewModel.isArabic ? Radius.circular(10.0) : Radius.circular(0), ), - color: Colors.white), - child: SecondaryButton( - color: Colors.red[900], - textColor: Colors.white, - label: TranslationBase.of(context).cancel, - onTap: () { - amRequestViewModel.updatePressOrder(presOrderID: amRequestViewModel.pendingAmbulanceRequestOrder.iD); - }, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _statusDisp, + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: _color, letterSpacing: -0.4, height: 16 / 10), + ), + SizedBox(height: 6), + Text( + '${TranslationBase.of(context).requestID}: ${order.iD}', + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64, height: 25 / 16), + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).pickupDate + ": ", + style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), + ), + Expanded( + child: Text( + DateUtil.getDayMonthYearDateFormatted(DateTime.tryParse(order.created)), + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48, height: 16 / 10), + ), + ), + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).transportMethod + ": ", + style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), + ), + Expanded( + child: Text( + order.serviceText, + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48, height: 16 / 10), + ), + ), + ], + ), + SizedBox( + height: 20.0, + ), + ], + ), + ), + Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + SizedBox(height: 12), + if (order.statusId == 1 || order.statusId == 2) + InkWell( + onTap: () { + showConfirmMessage(amRequestViewModel, order.iD); + }, + child: Container( + padding: EdgeInsets.symmetric(vertical: 8, horizontal: 14), + decoration: BoxDecoration( + color: Color(0xffD02127), + border: Border.all(color: Colors.white, width: 1), + borderRadius: BorderRadius.circular(10), + ), + child: Text( + TranslationBase.of(context).cancel_nocaps, + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.4), + ), + ), + ), + ], + ), + ], + ), + Row( + children: [ + Container( + margin: projectViewModel.isArabic ? EdgeInsets.only(left: 10.0) : EdgeInsets.only(right: 10.0), + width: 8, + height: 8, + decoration: containerRadius( + CustomColors.textColor, + 100, + ), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).pickupLocation + ": ", + style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), + ), + Text( + order.pickupLocation.trim().toString(), + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48), + ), + ], + ), + ], + ), + Container( + height: 20.0, + width: 1.0, + color: CustomColors.grey2, + margin: const EdgeInsets.only(left: 3.0, right: 3.0), + ), + Row( + children: [ + Container( + margin: projectViewModel.isArabic ? EdgeInsets.only(left: 10.0) : EdgeInsets.only(right: 10.0), + width: 8, + height: 8, + decoration: containerRadius( + CustomColors.accentColor, + 100, + ), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).dropoffLocation + ": ", + style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), + ), + Text( + order.dropOffLocation.trim().toString(), + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48), + ), + ], + ), + ], + ), + ], + ), ), - ) - ], - ), - ), - ) : getNoDataWidget(context), + ); + }) + : getNoDataWidget(context), ); } diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index 9e5a88d4..8b3819f1 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -361,7 +361,7 @@ class _AppDrawerState extends State { onTap: () { //NotificationsPage // Navigator.of(context).pop(); - if (!projectProvider.isLoginChild) Navigator.push(AppGlobal.context, FadePage(page: NotificationsPage())); + if (!projectProvider.isLoginChild) Navigator.push(context, FadePage(page: NotificationsPage())); }, ), if (projectProvider.havePrivilege(3)) diff --git a/lib/widgets/pickupLocation/PickupLocationFromMap.dart b/lib/widgets/pickupLocation/PickupLocationFromMap.dart index b0a67980..73edbe08 100644 --- a/lib/widgets/pickupLocation/PickupLocationFromMap.dart +++ b/lib/widgets/pickupLocation/PickupLocationFromMap.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/close_back.dart'; import 'package:flutter/cupertino.dart'; @@ -18,15 +19,7 @@ class PickupLocationFromMap extends StatelessWidget { final String buttonLabel; final Color buttonColor; - const PickupLocationFromMap( - {Key key, - this.onPick, - this.latitude, - this.longitude, - this.isWithAppBar = true, - this.buttonLabel, - this.buttonColor}) - : super(key: key); + const PickupLocationFromMap({Key key, this.onPick, this.latitude, this.longitude, this.isWithAppBar = true, this.buttonLabel, this.buttonColor}) : super(key: key); @override Widget build(BuildContext context) { @@ -60,8 +53,7 @@ class PickupLocationFromMap extends StatelessWidget { onPick(result); Navigator.of(context).pop(); }, - selectedPlaceWidgetBuilder: - (_, selectedPlace, state, isSearchBarFocused) { + selectedPlaceWidgetBuilder: (_, selectedPlace, state, isSearchBarFocused) { print("state: $state, isSearchBarFocused: $isSearchBarFocused"); return isSearchBarFocused ? Container() @@ -75,28 +67,13 @@ class PickupLocationFromMap extends StatelessWidget { ? Center(child: CircularProgressIndicator()) : Container( margin: EdgeInsets.all(12), - child: BorderedButton( - buttonLabel != null ? buttonLabel : TranslationBase.of(context).next, - textColor: Colors.white, - fontWeight: FontWeight.bold, - backgroundColor: buttonColor != null ? buttonColor : Colors.grey[800], - fontSize: 14, - vPadding: 12, - radius: 10, - handler: () { + child: DefaultButton( + TranslationBase.of(context).next, + () { onPick(selectedPlace); Navigator.of(context).pop(); }, ), - /* SecondaryButton( - color: Colors.grey[800], - textColor: Colors.white, - onTap: () { - onPick(selectedPlace); - Navigator.of(context).pop(); - }, - label: TranslationBase.of(context).next, - ),*/ ), ); }, From c253ec311023910142a44d3ac69e99aacbfdd619 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Thu, 4 Nov 2021 17:07:12 +0300 Subject: [PATCH 19/70] LiveCare UI revamped --- lib/models/Appointments/DoctorProfile.dart | 48 +- lib/pages/BookAppointment/BookConfirm.dart | 11 +- .../components/DocAvailableAppointments.dart | 8 +- lib/pages/ToDoList/ToDo.dart | 600 ++++++++++++------ lib/pages/ToDoList/widgets/paymentDialog.dart | 2 +- lib/pages/ToDoList/widgets/upcomingCard.dart | 420 ++++-------- lib/pages/livecare/widgets/clinic_list.dart | 2 +- lib/widgets/my_rich_text.dart | 4 +- 8 files changed, 539 insertions(+), 556 deletions(-) diff --git a/lib/models/Appointments/DoctorProfile.dart b/lib/models/Appointments/DoctorProfile.dart index df6031a7..f96eb4d6 100644 --- a/lib/models/Appointments/DoctorProfile.dart +++ b/lib/models/Appointments/DoctorProfile.dart @@ -1,47 +1,47 @@ class DoctorProfileList { - int doctorID; + num doctorID; String doctorName; - Null doctorNameN; - int clinicID; + dynamic doctorNameN; + num clinicID; String clinicDescription; - Null clinicDescriptionN; - Null licenseExpiry; - int employmentType; - Null setupID; - int projectID; + dynamic clinicDescriptionN; + dynamic licenseExpiry; + num employmentType; + dynamic setupID; + num projectID; String projectName; String nationalityID; String nationalityName; - Null nationalityNameN; - int gender; + dynamic nationalityNameN; + num gender; String genderDescription; - Null genderDescriptionN; - Null doctorTitle; - Null projectNameN; + dynamic genderDescriptionN; + dynamic doctorTitle; + dynamic projectNameN; bool isAllowWaitList; String titleDescription; - Null titleDescriptionN; - Null isRegistered; - Null isDoctorDummy; + dynamic titleDescriptionN; + dynamic isRegistered; + dynamic isDoctorDummy; bool isActive; bool isDoctorHasPrePostImages; - Null isDoctorAppointmentDisplayed; + dynamic isDoctorAppointmentDisplayed; bool doctorClinicActive; - Null isbookingAllowed; + dynamic isbookingAllowed; String doctorCases; - Null doctorPicture; + dynamic doctorPicture; String doctorProfileInfo; List specialty; - int actualDoctorRate; + num actualDoctorRate; String doctorImageURL; - int doctorRate; - double decimalDoctorRate; + num doctorRate; + num decimalDoctorRate; String doctorTitleForProfile; bool isAppointmentAllowed; String nationalityFlagURL; - int noOfPatientsRate; + num noOfPatientsRate; String qR; - int serviceID; + num serviceID; DoctorProfileList( {this.doctorID, diff --git a/lib/pages/BookAppointment/BookConfirm.dart b/lib/pages/BookAppointment/BookConfirm.dart index 323567b7..585e862d 100644 --- a/lib/pages/BookAppointment/BookConfirm.dart +++ b/lib/pages/BookAppointment/BookConfirm.dart @@ -47,6 +47,8 @@ class BookConfirm extends StatefulWidget { class _BookConfirmState extends State { ToDoCountProviderModel toDoProvider; + AppSharedPreferences sharedPref = new AppSharedPreferences(); + @override void initState() { widget.authUser = new AuthenticatedUser(); @@ -195,8 +197,8 @@ class _BookConfirmState extends State { elevation: 0, disabledTextColor: Colors.white, disabledColor: new Color(0xFFbcc2c4), - onPressed: () { - if (!widget.isLiveCareAppointment) { + onPressed: () async { + if (!await this.sharedPref.getBool(IS_LIVECARE_APPOINTMENT)) { insertAppointment(context, widget.doctor); } else { insertLiveCareScheduledAppointment(context, widget.doctor); @@ -244,8 +246,8 @@ class _BookConfirmState extends State { service.cancelAppointment(appo, context).then((res) { GifLoaderDialogUtils.hideDialog(context); if (res['MessageStatus'] == 1) { - Future.delayed(new Duration(milliseconds: 1500), () { - if (!widget.isLiveCareAppointment) { + Future.delayed(new Duration(milliseconds: 1500), () async { + if (!await this.sharedPref.getBool(IS_LIVECARE_APPOINTMENT)) { insertAppointment(context, widget.doctor); } else { insertLiveCareScheduledAppointment(context, widget.doctor); @@ -441,6 +443,7 @@ class _BookConfirmState extends State { Future navigateToBookSuccess(context, DoctorList docObject, PatientShareResponse patientShareResponse) async { GifLoaderDialogUtils.hideDialog(context); + this.sharedPref.remove(IS_LIVECARE_APPOINTMENT); Navigator.push( context, FadePage( diff --git a/lib/pages/BookAppointment/components/DocAvailableAppointments.dart b/lib/pages/BookAppointment/components/DocAvailableAppointments.dart index 959816af..8e576c99 100644 --- a/lib/pages/BookAppointment/components/DocAvailableAppointments.dart +++ b/lib/pages/BookAppointment/components/DocAvailableAppointments.dart @@ -12,7 +12,6 @@ import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; - import 'package:syncfusion_flutter_calendar/calendar.dart'; import '../../../uitl/date_uitl.dart'; @@ -79,7 +78,7 @@ class _DocAvailableAppointmentsState extends State wit WidgetsBinding.instance.addPostFrameCallback((_) async { getCurrentLanguage(); - if (widget.isLiveCareAppointment) + if (await this.sharedPref.getBool(IS_LIVECARE_APPOINTMENT)) getDoctorScheduledFreeSlots(context, widget.doctor); else { getDoctorFreeSlots(context, widget.doctor); @@ -351,22 +350,27 @@ class MeetingDataSource extends CalendarDataSource { DateTime getStartTime(int index) { return _getMeetingData(index).from; } + @override DateTime getEndTime(int index) { return _getMeetingData(index).to; } + @override String getSubject(int index) { return _getMeetingData(index).eventName; } + @override Color getColor(int index) { return _getMeetingData(index).background; } + @override bool isAllDay(int index) { return _getMeetingData(index).isAllDay; } + Meeting _getMeetingData(int index) { final dynamic meeting = appointments[index]; Meeting meetingData; diff --git a/lib/pages/ToDoList/ToDo.dart b/lib/pages/ToDoList/ToDo.dart index 1a0ec103..b46e1958 100644 --- a/lib/pages/ToDoList/ToDo.dart +++ b/lib/pages/ToDoList/ToDo.dart @@ -1,8 +1,6 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart'; -import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/models/Appointments/PatientShareResposne.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; @@ -20,7 +18,10 @@ import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart'; import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; +import 'package:diplomaticquarterapp/widgets/my_rich_text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -40,7 +41,7 @@ class ToDo extends StatefulWidget { bool isShowAppBar = true; Function onBackClick; - ToDo({@required this.isShowAppBar,this.onBackClick}); + ToDo({@required this.isShowAppBar, this.onBackClick}); @override _ToDoState createState() => _ToDoState(); @@ -49,11 +50,7 @@ class ToDo extends StatefulWidget { class _ToDoState extends State { AppSharedPreferences sharedPref = AppSharedPreferences(); - AuthenticatedUser authUser; - AuthenticatedUserObject authenticatedUserObject = locator(); - List imagesInfo = List(); - ToDoCountProviderModel toDoProvider; CountdownTimerController controller; @@ -63,7 +60,7 @@ class _ToDoState extends State { void initState() { widget.patientShareResponse = new PatientShareResponse(); WidgetsBinding.instance.addPostFrameCallback((_) { - if (authenticatedUserObject.isLogin) getPatientData(); + getPatientAppointmentHistory(); }); super.initState(); imagesInfo @@ -85,7 +82,7 @@ class _ToDoState extends State { showNewAppBarTitle: true, icon: "assets/images/new/bottom_nav/todo.svg", description: TranslationBase.of(context).infoTodo, - onTap:widget.onBackClick, + onTap: widget.onBackClick, backgroundColor: CustomColors.appBackgroudGrey2Color, body: SingleChildScrollView( child: Column( @@ -98,207 +95,353 @@ class _ToDoState extends State { padding: EdgeInsets.all(0.0), itemCount: widget.appoList.length, itemBuilder: (context, index) { - print("ttt " + getNextActionImage(widget.appoList[index].nextAction)); - print("ttt " + widget.appoList[index].nextAction.toString()); return Container( - margin: EdgeInsets.all(10.0), + width: double.infinity, + margin: EdgeInsets.only(left: 12.0, right: 12.0, top: 12.0), + decoration: cardRadius(12), + padding: EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - child: Card( - margin: EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 8.0), - color: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(top: 4.0), + child: widget.appoList[index].clinicID == 265 + ? Container( + margin: EdgeInsets.only(left: 5.0, right: 5.0), + child: SvgPicture.asset("assets/images/new/drive-thru.svg"), + ) + : widget.appoList[index].isLiveCareAppointment + ? SvgPicture.asset("assets/images/new/virtual.svg") + : SvgPicture.asset("assets/images/new/hospital-visit.svg"), + + // SvgPicture.asset("assets/images/new/virtual.svg"), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(left: 8.0, right: 8.0), + child: Text( + widget.appoList[index].clinicID == 265 + ? TranslationBase.of(context).drivethruAppo + : widget.appoList[index].isLiveCareAppointment + ? TranslationBase.of(context).liveCareAppo + : TranslationBase.of(context).walkinAppo, + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48)), + ), + Padding( + padding: const EdgeInsets.only(left: 8.0, right: 8.0), + child: CountdownTimer( + controller: new CountdownTimerController(endTime: DateTime.now().millisecondsSinceEpoch + (widget.appoList[index].remaniningHoursTocanPay * 1000) * 60), + widgetBuilder: (_, CurrentRemainingTime time) { + return time != null + ? Text( + '${time.days != null ? time.days : "0"}:${time.hours != null ? time.hours.toString().length == 1 ? "0" + time.hours.toString() : time.hours : "00"}:${time.min}:${time.sec} ' + + TranslationBase.of(context).upcomingTimeLeft, + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: CustomColors.accentColor, letterSpacing: -0.48)) + : Container(); + }, + ), + ), + ], + ), + ], + ), + Container( + child: InkWell( + onTap: () { + performNextAction(widget.appoList[index]); + }, + child: Container( + padding: EdgeInsets.symmetric(vertical: 8, horizontal: 14), + decoration: BoxDecoration( + color: getNextActionButtonColor(widget.appoList[index].nextAction), + border: Border.all(color: Colors.white, width: 1), + borderRadius: BorderRadius.circular(6), + ), + child: Text( + getNextActionText(widget.appoList[index].nextAction), + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.4), + ), + ), + ), + ), + ], + ), + Padding( + padding: const EdgeInsets.only(top: 8.0), + child: Text( + widget.appoList[index].doctorTitle + " " + widget.appoList[index].doctorNameObj, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64, height: 25 / 16), + ), + ), + Row( + mainAxisSize: MainAxisSize.min, + children: [ + LargeAvatar( + name: widget.appoList[index].doctorTitle + " " + widget.appoList[index].doctorNameObj, + url: widget.appoList[index].doctorImageURL, + width: 52, + height: 52, ), - child: Container( - width: MediaQuery.of(context).size.width, - padding: EdgeInsets.all(10.0), + SizedBox(width: 11), + Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.max, + mainAxisSize: MainAxisSize.min, children: [ + MyRichText(TranslationBase.of(context).clinic + ": ", widget.appoList[index].clinicName, projectViewModel.isArabic), + MyRichText(TranslationBase.of(context).appointmentDate + ": ", + DateUtil.getDayMonthYearHourMinuteDateFormatted(DateUtil.convertStringToDate(widget.appoList[index].appointmentDate)), projectViewModel.isArabic), + MyRichText(TranslationBase.of(context).branch, widget.appoList[index].projectName, projectViewModel.isArabic), Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.max, children: [ - Image.asset("assets/images/new-design/time_icon.png", width: 20.0, height: 20.0), - Container( - width: MediaQuery.of(context).size.width * 0.4, - margin: EdgeInsets.only(left: 10.0, right: 10.0), - child: Text( - DateUtil.getWeekDayMonthDayYearDateFormatted( - DateUtil.convertStringToDate(widget.appoList[index].appointmentDate), projectViewModel.isArabic ? "ar" : "en") + - " " + - widget.appoList[index].startTime.substring(0, 5), - overflow: TextOverflow.clip, - style: TextStyle(fontSize: 10.0)), - ), - !widget.appoList[index].isLiveCareAppointment ? Image.asset("assets/images/new-design/hospital_address_icon.png", width: 20.0, height: 20.0) : Container(), - Container( - margin: EdgeInsets.only(left: 5.0, right: 5.0), - child: widget.appoList[index].isLiveCareAppointment - ? Container() - : Text(widget.appoList[index].projectName != null ? widget.appoList[index].projectName : "-", - overflow: TextOverflow.clip, maxLines: 2, style: TextStyle(fontSize: 10.0)), + RatingBar.readOnly( + initialRating: widget.appoList[index].actualDoctorRate.toDouble(), + size: 16.0, + filledColor: Color(0XFFD02127), + emptyColor: Color(0XFFD02127), + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star_border, ), ], ), - Container( - margin: EdgeInsets.only(top: 5.0), - child: Divider( - color: Colors.grey[500], - ), - ), - Flex( - direction: Axis.horizontal, - children: [ - Expanded( - flex: 1, - child: Container( - height: MediaQuery.of(context).size.height * 0.1, - margin: EdgeInsets.only(top: 5.0), - child: ClipRRect( - borderRadius: BorderRadius.circular(100.0), - child: Image.network(widget.appoList[index].doctorImageURL, fit: BoxFit.fill), - ), - ), - ), - Expanded( - flex: 3, - child: Container( - margin: EdgeInsets.only(top: 10.0, left: 20.0, right: 20.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(widget.appoList[index].doctorTitle + " " + widget.appoList[index].doctorNameObj, - style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.bold, letterSpacing: -0.64)), - if (getDoctorSpeciality(widget.appoList[index].doctorSpeciality) != "null\n") - Container( - margin: EdgeInsets.only(top: 3.0, bottom: 3.0), - child: Text(getDoctorSpeciality(widget.appoList[index].doctorSpeciality).trim(), - style: TextStyle(fontSize: 12.0, color: Colors.grey[600], letterSpacing: -0.64)), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - mainAxisSize: MainAxisSize.max, - children: [ - RatingBar.readOnly( - initialRating: widget.appoList[index].actualDoctorRate.toDouble(), - size: 20.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, - ), - ], - ), - Container( - child: CountdownTimer( - controller: - new CountdownTimerController(endTime: DateTime.now().millisecondsSinceEpoch + (widget.appoList[index].remaniningHoursTocanPay * 1000) * 60), - widgetBuilder: (_, CurrentRemainingTime time) { - return time != null - ? Text( - '${time.days != null ? time.days : "0"}:${time.hours != null ? time.hours.toString().length == 1 ? "0" + time.hours.toString() : time.hours : "00"}:${time.min}:${time.sec} ' + - TranslationBase.of(context).upcomingTimeLeft, - style: TextStyle(fontSize: 12.0, color: Color(0xffC5272D))) - : Container(); - }, - ), - ), - ], - ), - ), - ), - Expanded( - flex: 1, - child: InkWell( - onTap: () => performNextAction(widget.appoList[index]), - child: Container( - margin: EdgeInsets.only(top: 20.0), - child: Column( - children: [ - Image.asset(getNextActionImage(widget.appoList[index].nextAction), width: 50.0, height: 50.0), - Container( - margin: EdgeInsets.only(top: 5.0), - child: Text(getNextActionText(widget.appoList[index].nextAction), textAlign: TextAlign.center, style: TextStyle(fontSize: 12.0)), - ) - ], - ), - ), - ), - ) - ], - ), - Divider( - color: Colors.grey[500], - ), - Flex( - direction: Axis.horizontal, - children: [ - Expanded( - flex: 2, - child: Container( - child: Text(getNextActionDescription(widget.appoList[index].nextAction), style: TextStyle(fontSize: 11.0, color: Colors.grey[700])), - ), - ), - Expanded( - flex: 1, - child: GestureDetector( - onTap: () { - navigateToAppointmentDetails(context, widget.appoList[index]); - }, - child: Container( - child: Text(TranslationBase.of(context).upcomingDetails, - textAlign: TextAlign.end, style: TextStyle(fontSize: 11.0, color: new Color(0xffC5272D), decoration: TextDecoration.underline)), - ), - ), - ) - ], - ), ], ), ), - ), + ], ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.only(bottomLeft: Radius.circular(10.0), bottomRight: Radius.circular(10.0)), - color: Color(0xff20bc44), + Padding( + padding: const EdgeInsets.only(top: 12.0), + child: Text( + getNextActionDescription(widget.appoList[index].nextAction), + style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.48, height: 25 / 16), ), - height: 30.0, - padding: EdgeInsets.only(right: 10, left: 10), - margin: EdgeInsets.symmetric(horizontal: 20), - transform: Matrix4.translationValues(0.0, -8.0, 0.0), - child: Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - widget.appoList[index].clinicID == 265 - ? Container( - margin: EdgeInsets.only(left: 5.0, right: 5.0), - child: SvgPicture.asset( - "assets/images/new/car_icon.svg", - height: 15, - width: 15, - ), - ) - : widget.appoList[index].isLiveCareAppointment - ? Image.asset("assets/images/new-design/video.png") - : Image.asset("assets/images/new-design/walkin.png"), - widget.appoList[index].clinicID == 265 - ? Text(TranslationBase.of(context).drivethruAppo, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 11.0)) - : widget.appoList[index].isLiveCareAppointment - ? Text(TranslationBase.of(context).videoAppo, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 11.0)) - : Text(TranslationBase.of(context).walkinAppo, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 11.0)) - ], + ), + InkWell( + onTap: () { + navigateToAppointmentDetails(context, widget.appoList[index]); + }, + child: Padding( + padding: const EdgeInsets.only(top: 0.0), + child: Text( + TranslationBase.of(context).moreDetails, + style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: CustomColors.accentColor, letterSpacing: -0.48, height: 25 / 16, decoration: TextDecoration.underline), + ), ), ), ], ), ); + // return Container( + // margin: EdgeInsets.all(10.0), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Container( + // child: Card( + // margin: EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 8.0), + // color: Colors.white, + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(10), + // ), + // child: Container( + // width: MediaQuery.of(context).size.width, + // padding: EdgeInsets.all(10.0), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // mainAxisSize: MainAxisSize.max, + // children: [ + // Row( + // children: [ + // Image.asset("assets/images/new-design/time_icon.png", width: 20.0, height: 20.0), + // Container( + // width: MediaQuery.of(context).size.width * 0.4, + // margin: EdgeInsets.only(left: 10.0, right: 10.0), + // child: Text( + // DateUtil.getWeekDayMonthDayYearDateFormatted( + // DateUtil.convertStringToDate(widget.appoList[index].appointmentDate), projectViewModel.isArabic ? "ar" : "en") + + // " " + + // widget.appoList[index].startTime.substring(0, 5), + // overflow: TextOverflow.clip, + // style: TextStyle(fontSize: 10.0)), + // ), + // !widget.appoList[index].isLiveCareAppointment ? Image.asset("assets/images/new-design/hospital_address_icon.png", width: 20.0, height: 20.0) : Container(), + // Container( + // margin: EdgeInsets.only(left: 5.0, right: 5.0), + // child: widget.appoList[index].isLiveCareAppointment + // ? Container() + // : Text(widget.appoList[index].projectName != null ? widget.appoList[index].projectName : "-", + // overflow: TextOverflow.clip, maxLines: 2, style: TextStyle(fontSize: 10.0)), + // ), + // ], + // ), + // Container( + // margin: EdgeInsets.only(top: 5.0), + // child: Divider( + // color: Colors.grey[500], + // ), + // ), + // Flex( + // direction: Axis.horizontal, + // children: [ + // Expanded( + // flex: 1, + // child: Container( + // height: MediaQuery.of(context).size.height * 0.1, + // margin: EdgeInsets.only(top: 5.0), + // child: ClipRRect( + // borderRadius: BorderRadius.circular(100.0), + // child: Image.network(widget.appoList[index].doctorImageURL, fit: BoxFit.fill), + // ), + // ), + // ), + // Expanded( + // flex: 3, + // child: Container( + // margin: EdgeInsets.only(top: 10.0, left: 20.0, right: 20.0), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Text(widget.appoList[index].doctorTitle + " " + widget.appoList[index].doctorNameObj, + // style: TextStyle(fontSize: 14.0, color: Colors.black, fontWeight: FontWeight.bold, letterSpacing: -0.64)), + // if (getDoctorSpeciality(widget.appoList[index].doctorSpeciality) != "null\n") + // Container( + // margin: EdgeInsets.only(top: 3.0, bottom: 3.0), + // child: Text(getDoctorSpeciality(widget.appoList[index].doctorSpeciality).trim(), + // style: TextStyle(fontSize: 12.0, color: Colors.grey[600], letterSpacing: -0.64)), + // ), + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // mainAxisSize: MainAxisSize.max, + // children: [ + // RatingBar.readOnly( + // initialRating: widget.appoList[index].actualDoctorRate.toDouble(), + // size: 20.0, + // filledColor: Colors.yellow[700], + // emptyColor: Colors.grey[500], + // isHalfAllowed: true, + // halfFilledIcon: Icons.star_half, + // filledIcon: Icons.star, + // emptyIcon: Icons.star, + // ), + // ], + // ), + // Container( + // child: CountdownTimer( + // controller: + // new CountdownTimerController(endTime: DateTime.now().millisecondsSinceEpoch + (widget.appoList[index].remaniningHoursTocanPay * 1000) * 60), + // widgetBuilder: (_, CurrentRemainingTime time) { + // return time != null + // ? Text( + // '${time.days != null ? time.days : "0"}:${time.hours != null ? time.hours.toString().length == 1 ? "0" + time.hours.toString() : time.hours : "00"}:${time.min}:${time.sec} ' + + // TranslationBase.of(context).upcomingTimeLeft, + // style: TextStyle(fontSize: 12.0, color: Color(0xffC5272D))) + // : Container(); + // }, + // ), + // ), + // ], + // ), + // ), + // ), + // Expanded( + // flex: 1, + // child: InkWell( + // onTap: () => performNextAction(widget.appoList[index]), + // child: Container( + // margin: EdgeInsets.only(top: 20.0), + // child: Column( + // children: [ + // Image.asset(getNextActionImage(widget.appoList[index].nextAction), width: 50.0, height: 50.0), + // Container( + // margin: EdgeInsets.only(top: 5.0), + // child: Text(getNextActionText(widget.appoList[index].nextAction), textAlign: TextAlign.center, style: TextStyle(fontSize: 12.0)), + // ) + // ], + // ), + // ), + // ), + // ) + // ], + // ), + // Divider( + // color: Colors.grey[500], + // ), + // Flex( + // direction: Axis.horizontal, + // children: [ + // Expanded( + // flex: 2, + // child: Container( + // child: Text(getNextActionDescription(widget.appoList[index].nextAction), style: TextStyle(fontSize: 11.0, color: Colors.grey[700])), + // ), + // ), + // Expanded( + // flex: 1, + // child: GestureDetector( + // onTap: () { + // navigateToAppointmentDetails(context, widget.appoList[index]); + // }, + // child: Container( + // child: Text(TranslationBase.of(context).upcomingDetails, + // textAlign: TextAlign.end, style: TextStyle(fontSize: 11.0, color: new Color(0xffC5272D), decoration: TextDecoration.underline)), + // ), + // ), + // ) + // ], + // ), + // ], + // ), + // ), + // ), + // ), + // Container( + // decoration: BoxDecoration( + // borderRadius: BorderRadius.only(bottomLeft: Radius.circular(10.0), bottomRight: Radius.circular(10.0)), + // color: Color(0xff20bc44), + // ), + // height: 30.0, + // padding: EdgeInsets.only(right: 10, left: 10), + // margin: EdgeInsets.symmetric(horizontal: 20), + // transform: Matrix4.translationValues(0.0, -8.0, 0.0), + // child: Row( + // mainAxisSize: MainAxisSize.min, + // mainAxisAlignment: MainAxisAlignment.start, + // children: [ + // widget.appoList[index].clinicID == 265 + // ? Container( + // margin: EdgeInsets.only(left: 5.0, right: 5.0), + // child: SvgPicture.asset( + // "assets/images/new/car_icon.svg", + // height: 15, + // width: 15, + // ), + // ) + // : widget.appoList[index].isLiveCareAppointment + // ? Image.asset("assets/images/new-design/video.png") + // : Image.asset("assets/images/new-design/walkin.png"), + // widget.appoList[index].clinicID == 265 + // ? Text(TranslationBase.of(context).drivethruAppo, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 11.0)) + // : widget.appoList[index].isLiveCareAppointment + // ? Text(TranslationBase.of(context).videoAppo, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 11.0)) + // : Text(TranslationBase.of(context).walkinAppo, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 11.0)) + // ], + // ), + // ), + // ], + // ), + // ); }, ), ), @@ -375,6 +518,48 @@ class _ToDoState extends State { } } + Color getNextActionButtonColor(nextAction) { + switch (nextAction) { + case 0: + return CustomColors.accentColor; + break; + case 10: + return CustomColors.green; + break; + + case 15: + return CustomColors.grey2; + break; + + case 20: + return CustomColors.green; + break; + + case 30: + return CustomColors.accentColor; + break; + + case 40: + return CustomColors.green; + break; + + case 50: + return CustomColors.green; + break; + + case 60: + return CustomColors.orange; + break; + + case 90: + return CustomColors.accentColor; + break; + + default: + return CustomColors.green; + } + } + String getNextActionText(nextAction) { switch (nextAction) { case 0: @@ -732,35 +917,34 @@ class _ToDoState extends State { }); } - getPatientData() async { - AppSharedPreferences sharedPref = AppSharedPreferences(); - if (await sharedPref.getObject(USER_PROFILE) != null) { - var data = AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE)); - setState(() { - print(data); - authUser = data; - }); - getPatientAppointmentHistory(); - } - } + // getPatientData() async { + // AppSharedPreferences sharedPref = AppSharedPreferences(); + // if (await sharedPref.getObject(USER_PROFILE) != null) { + // var data = AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE)); + // setState(() { + // print(data); + // authUser = data; + // }); + // getPatientAppointmentHistory(); + // } + // } Future navigateToPaymentMethod(context, PatientShareResponse patientShareResponse, AppoitmentAllHistoryResultList appo) async { - if (await this.sharedPref.getObject(USER_PROFILE) != null) { - var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE)); - setState(() { - authUser = data; - }); - } - - Navigator.push(context, FadePage(page: PaymentMethod( - onSelectedMethod: (String metohd) { + // if (await this.sharedPref.getObject(USER_PROFILE) != null) { + // var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE)); + // setState(() { + // authUser = data; + // }); + // } + + Navigator.push(context, FadePage(page: PaymentMethod(onSelectedMethod: (String metohd) { setState(() {}); }))).then((value) { print(value); getPatientAppointmentHistory(); if (value != null) { - openPayment(value, authUser, double.parse(patientShareResponse.patientShareWithTax.toString()), patientShareResponse, appo); + openPayment(value, projectViewModel.user, double.parse(patientShareResponse.patientShareWithTax.toString()), patientShareResponse, appo); } }); } diff --git a/lib/pages/ToDoList/widgets/paymentDialog.dart b/lib/pages/ToDoList/widgets/paymentDialog.dart index eedbb874..7a0bdc2e 100644 --- a/lib/pages/ToDoList/widgets/paymentDialog.dart +++ b/lib/pages/ToDoList/widgets/paymentDialog.dart @@ -89,7 +89,7 @@ class _PaymentDialogState extends State { children: [ Expanded( child: DefaultButton( - TranslationBase.of(context).cancel, + TranslationBase.of(context).cancel_nocaps, () { Navigator.pop(context, null); }, diff --git a/lib/pages/ToDoList/widgets/upcomingCard.dart b/lib/pages/ToDoList/widgets/upcomingCard.dart index 6610ed33..863947ea 100644 --- a/lib/pages/ToDoList/widgets/upcomingCard.dart +++ b/lib/pages/ToDoList/widgets/upcomingCard.dart @@ -1,20 +1,17 @@ -import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; -import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; -import 'package:diplomaticquarterapp/pages/MyAppointments/AppointmentDetails.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; -import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart'; +import 'package:diplomaticquarterapp/widgets/my_rich_text.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:provider/provider.dart'; import 'package:rating_bar/rating_bar.dart'; class TodoListCard extends StatefulWidget { - AppoitmentAllHistoryResultList appo; - var languageID; - final VoidCallback onListUpdated; - - TodoListCard({@required this.appo, this.onListUpdated}); + TodoListCard(); @override _TodoListCardState createState() => _TodoListCardState(); @@ -25,333 +22,128 @@ class _TodoListCardState extends State { @override void initState() { -// widget.onListUpdated(); super.initState(); } @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); return Container( + width: double.infinity, margin: EdgeInsets.all(10.0), - child: Card( - margin: EdgeInsets.fromLTRB(8.0, 0.0, 8.0, 8.0), - color: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - ), - child: Container( - width: MediaQuery.of(context).size.width, - padding: EdgeInsets.all(10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ + decoration: cardRadius(12), + padding: EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ Row( - children: [ - Image.asset("assets/images/new-design/time_icon.png", - width: 20.0, height: 20.0), - Container( - margin: EdgeInsets.only(left: 10.0, right: 30.0), - child: Text(getDate(widget.appo.appointmentDate), - style: TextStyle(fontSize: 12.0)), + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(top: 4.0), + child: SvgPicture.asset("assets/images/new/virtual.svg"), ), - widget.appo.isLiveCareAppointment - ? SvgPicture.asset( - "assets/images/new-design/liveCare_logo_icon.svg", - width: 20.0, - height: 20.0) - : Image.asset( - "assets/images/new-design/hospital_address_icon.png", - width: 20.0, - height: 20.0), - Container( - margin: EdgeInsets.only(left: 10.0, right: 10.0), - child: widget.appo.isLiveCareAppointment - ? Text(TranslationBase.of(context).upcomingLivecare, - style: TextStyle(fontSize: 12.0)) - : Text(widget.appo.projectName, - style: TextStyle(fontSize: 12.0)), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(left: 8.0, right: 8.0), + child: Text(TranslationBase.of(context).videoAppo, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48)), + ), + Padding( + padding: const EdgeInsets.only(left: 8.0, right: 8.0), + child: Text("01:23:22 " + TranslationBase.of(context).upcomingTimeLeft, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: CustomColors.accentColor, letterSpacing: -0.48)), + ), + ], ), ], ), Container( - margin: EdgeInsets.only(top: 5.0), - child: Divider( - color: Colors.grey[500], - ), - ), - Flex( - direction: Axis.horizontal, - children: [ - Expanded( - flex: 1, - child: Container( - height: MediaQuery.of(context).size.height * 0.1, - margin: EdgeInsets.only(top: 5.0), - child: ClipRRect( - borderRadius: BorderRadius.circular(100.0), - child: Image.network(widget.appo.doctorImageURL, - fit: BoxFit.fill), - ), + child: InkWell( + onTap: () { + // showConfirmMessage(model, order); + }, + child: Container( + padding: EdgeInsets.symmetric(vertical: 8, horizontal: 14), + decoration: BoxDecoration( + color: CustomColors.green, + border: Border.all(color: Colors.white, width: 1), + borderRadius: BorderRadius.circular(6), ), - ), - Expanded( - flex: 3, - child: Container( - margin: - EdgeInsets.only(top: 20.0, left: 20.0, right: 20.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - widget.appo.doctorTitle + - " " + - widget.appo.doctorNameObj, - style: TextStyle( - fontSize: 14.0, - color: Colors.black, - fontWeight: FontWeight.bold, - letterSpacing: 1.0)), - Container( - margin: EdgeInsets.only(top: 3.0, bottom: 3.0), - child: Text( - getDoctorSpeciality( - widget.appo.doctorSpeciality) - .trim(), - style: TextStyle( - fontSize: 12.0, - color: Colors.grey[600], - letterSpacing: 1.0)), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - mainAxisSize: MainAxisSize.max, - children: [ - RatingBar.readOnly( - initialRating: 4.0, - size: 20.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, - ), - ], - ), - ], - ), + child: Text( + TranslationBase.of(context).confirm, + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.4), ), ), - Expanded( - flex: 1, - child: Container( - margin: EdgeInsets.only(top: 20.0), - child: Column( - children: [ - Image.asset( - getNextActionImage(widget.appo.nextAction), - width: 50.0, - height: 50.0), - Container( - margin: EdgeInsets.only(top: 5.0), - child: Text( - getNextActionText(widget.appo.nextAction), - textAlign: TextAlign.center, - style: TextStyle(fontSize: 12.0)), - ) - ], - ), - ), - ) - ], + ), ), - Divider( - color: Colors.grey[500], + ], + ), + Padding( + padding: const EdgeInsets.only(top: 8.0), + child: Text( + "Raed Mubarak Bin Ghanem", + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64, height: 25 / 16), + ), + ), + Row( + mainAxisSize: MainAxisSize.min, + children: [ + LargeAvatar( + name: "Raed Mubarak Bin Ghanem", + url: "https://hmgwebservices.com/Images/MobileImages/TAKHSUSI/158210.png", + width: 52, + height: 52, ), - Flex( - direction: Axis.horizontal, - children: [ - Expanded( - flex: 2, - child: Container( - child: Text( - getNextActionDescription(widget.appo.nextAction), - style: TextStyle( - fontSize: 12.0, color: Colors.grey[700])), + SizedBox(width: 11), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + MyRichText(TranslationBase.of(context).clinic + ": ", "Cardiology", projectViewModel.isArabic), + MyRichText(TranslationBase.of(context).appointmentDate + ": ", "11/04/2021 15:30", projectViewModel.isArabic), + MyRichText(TranslationBase.of(context).branch, "Olaya Hospital", projectViewModel.isArabic), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.max, + children: [ + RatingBar.readOnly( + initialRating: 4.5, + size: 16.0, + filledColor: Color(0XFFD02127), + emptyColor: Color(0XFFD02127), + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star_border, + ), + ], ), - ), - Expanded( - flex: 1, - child: GestureDetector( - onTap: () { - navigateToAppointmentDetails(context); - }, - child: Container( - child: Text(TranslationBase.of(context).upcomingDetails, - textAlign: TextAlign.end, - style: TextStyle( - fontSize: 12.0, - color: new Color(0xFF40ACC9), - decoration: TextDecoration.underline)), - ), - ), - ) - ], + ], + ), ), ], ), - ), + Padding( + padding: const EdgeInsets.only(top: 12.0), + child: Text( + "Please confirm the appointment to avoid cancellation", + style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.48, height: 25 / 16), + ), + ), + Padding( + padding: const EdgeInsets.only(top: 0.0), + child: Text( + "More Details", + style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: CustomColors.accentColor, letterSpacing: -0.48, height: 25 / 16, decoration: TextDecoration.underline), + ), + ), + ], ), ); } - - String getNextActionImage(nextAction) { - switch (nextAction) { - case 0: - return "No Action"; - break; - case 10: - return "assets/images/new-design/confirm_button.png"; - break; - - case 15: - return widget.languageID == 'ar' - ? "assets/images/new-design/pay_online_button_arabic_disabled.png" - : "assets/images/new-design/pay_online_button_disabled.png"; - break; - - case 20: - return widget.languageID == 'ar' - ? "assets/images/new-design/pay_online_button_arabic.png" - : "assets/images/new-design/pay_online_button.png"; - break; - - case 30: - return "assets/images/new-design/qr_code_button.png"; - break; - - case 40: - return "assets/images/new-design/video_call_instruction.png"; - break; - - case 50: - return "assets/images/new-design/liveCare_logo_icon.png"; - break; - - default: - return ""; - } - } - - String getNextActionText(nextAction) { - switch (nextAction) { - case 0: - return "No Action"; - break; - case 10: - return TranslationBase.of(context).confirm; - break; - - case 15: - return TranslationBase.of(context).pendingPayment; - break; - - case 20: - return TranslationBase.of(context).payNow; - break; - - case 30: - return TranslationBase.of(context).viewQR; - break; - - case 40: - return TranslationBase.of(context).instruction; - break; - - case 50: - return TranslationBase.of(context).livecare; - break; - - default: - return ""; - } - } - - String getNextActionDescription(nextAction) { - switch (nextAction) { - case 0: - return "No Action"; - break; - case 10: - return TranslationBase.of(context).upcomingConfirm; - break; - - case 15: - return TranslationBase.of(context).upcomingPaymentPending; - break; - - case 20: - return TranslationBase.of(context).upcomingPaymentNow; - break; - - case 30: - return TranslationBase.of(context).upcomingQR; - break; - - case 40: - return TranslationBase.of(context).upcomingVirtual; - break; - - case 50: - return TranslationBase.of(context).upcomingLivecare; - break; - - default: - return ""; - } - } - - getLanguageID() async { - var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); - setState(() { - widget.languageID = languageID; - }); - } - - String getDate(String date) { - DateTime dateObj = DateUtil.convertStringToDate(date); - return DateUtil.getWeekDay(dateObj.weekday) + - ", " + - dateObj.day.toString() + - " " + - DateUtil.getMonth(dateObj.month) + - " " + - dateObj.year.toString() + - " " + - dateObj.hour.toString() + - ":" + - getMinute(dateObj); - } - - String getMinute(DateTime dateObj) { - if (dateObj.minute == 0) { - return dateObj.minute.toString() + "0"; - } else { - return dateObj.minute.toString(); - } - } - - String getDoctorSpeciality(List docSpecial) { - String docSpeciality = ""; - docSpecial.forEach((v) { - docSpeciality = docSpeciality + v + "\n"; - }); - return docSpeciality; - } - - Future navigateToAppointmentDetails(context) async { - Navigator.push( - context, FadePage(page: AppointmentDetails())); - } } diff --git a/lib/pages/livecare/widgets/clinic_list.dart b/lib/pages/livecare/widgets/clinic_list.dart index 988d102c..bf4d33c7 100644 --- a/lib/pages/livecare/widgets/clinic_list.dart +++ b/lib/pages/livecare/widgets/clinic_list.dart @@ -626,7 +626,7 @@ class _clinic_listState extends State { } Future navigateToSearchResults(context, List docList, List patientDoctorAppointmentListHospital) async { - Navigator.push(context, FadePage(page: SearchResults(doctorsList: docList, isLiveCareAppointment: true, patientDoctorAppointmentListHospital: patientDoctorAppointmentListHospital))); + Navigator.push(context, FadePage(page: SearchResults(doctorsList: docList, isLiveCareAppointment: false, patientDoctorAppointmentListHospital: patientDoctorAppointmentListHospital))); } updateSelectedIndex(PatientERGetClinicsList patientERGetClinicsList) { diff --git a/lib/widgets/my_rich_text.dart b/lib/widgets/my_rich_text.dart index 92100f48..c3d108c5 100644 --- a/lib/widgets/my_rich_text.dart +++ b/lib/widgets/my_rich_text.dart @@ -12,11 +12,11 @@ class MyRichText extends StatelessWidget { maxLines: 1, text: TextSpan( text: title, - style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, fontFamily: isArabic ? 'Cairo' : 'Poppins', color: Color(0xff575757), letterSpacing: -0.4, height: 18 / 10), + style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, fontFamily: isArabic ? 'Cairo' : 'Poppins', color: Color(0xff575757), letterSpacing: -0.4, height: 18 / 10), children: [ TextSpan( text: " $value", - style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, fontFamily: isArabic ? 'Cairo' : 'Poppins', color: Color(0xff2B353E), letterSpacing: -0.48, height: 18 / 12), + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, fontFamily: isArabic ? 'Cairo' : 'Poppins', color: Color(0xff2B353E), letterSpacing: -0.48, height: 18 / 12), ) ]), ); From 30e67bbe3e11db3f2970ddd1cc265f9269695670 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Thu, 4 Nov 2021 17:26:32 +0300 Subject: [PATCH 20/70] updates --- .../service/blood/blood_donation_service.dart | 47 ++++++++-------- .../medical/my_balance_view_model.dart | 16 +++--- lib/pages/Blood/blood_donation.dart | 56 ++++++++++++------- 3 files changed, 67 insertions(+), 52 deletions(-) diff --git a/lib/core/service/blood/blood_donation_service.dart b/lib/core/service/blood/blood_donation_service.dart index 0128d0d1..a59a2169 100644 --- a/lib/core/service/blood/blood_donation_service.dart +++ b/lib/core/service/blood/blood_donation_service.dart @@ -10,13 +10,13 @@ class BloodDonationService extends BaseService { List CitiesModelList = List(); Map body = Map(); + Future getAllCitiesOrders() async { hasError = false; body['ListCities'] = false; - await baseAppClient.post(GET_CITIES_REQUEST, - onSuccess: (dynamic response, int statusCode) { + body["IsPublicRequest"] = true; + await baseAppClient.post(GET_CITIES_REQUEST, onSuccess: (dynamic response, int statusCode) { CitiesModelList.clear(); - response['ListCities'].forEach((vital) { CitiesModelList.add(CitiesModel.fromJson(vital)); }); @@ -25,16 +25,16 @@ class BloodDonationService extends BaseService { super.error = error; }, body: body); } + Future bloodDonationSave(request) async { var localRes; try { - await baseAppClient.post(SAVE_BLOOD_REQUEST, - onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - localRes = error; - return Future.value(error); - }, body: request); + await baseAppClient.post(SAVE_BLOOD_REQUEST, onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + localRes = error; + return Future.value(error); + }, body: request); return Future.value(localRes); } catch (error) { throw error; @@ -44,30 +44,27 @@ class BloodDonationService extends BaseService { Future getAgreement() async { var localRes; try { - await baseAppClient.post(GET_BLOOD_AGREEMENT, - onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - localRes = error; - return Future.value(error); - }, body: {}); + await baseAppClient.post(GET_BLOOD_AGREEMENT, onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + localRes = error; + return Future.value(error); + }, body: {}); return Future.value(localRes); } catch (error) { throw error; } } - Future saveAgreement(request) async { var localRes; try { - await baseAppClient.post(SAVE_BLOOD_AGREEMENT, - onSuccess: (dynamic response, int statusCode) { - localRes = response; - }, onFailure: (String error, int statusCode) { - localRes = error; - return Future.value(error); - }, body: request); + await baseAppClient.post(SAVE_BLOOD_AGREEMENT, onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + localRes = error; + return Future.value(error); + }, body: request); return Future.value(localRes); } catch (error) { throw error; diff --git a/lib/core/viewModels/medical/my_balance_view_model.dart b/lib/core/viewModels/medical/my_balance_view_model.dart index a92b6e16..e12e2b07 100644 --- a/lib/core/viewModels/medical/my_balance_view_model.dart +++ b/lib/core/viewModels/medical/my_balance_view_model.dart @@ -81,13 +81,15 @@ class MyBalanceViewModel extends BaseViewModel { } Future getCities() async { - setState(ViewState.Busy); - await _bloodDonationService.getAllCitiesOrders(); - if (_bloodDonationService.hasError) { - error = _bloodDonationService.error; - setState(ViewState.Error); - } else - setState(ViewState.Idle); + if(isLogin) { + setState(ViewState.Busy); + await _bloodDonationService.getAllCitiesOrders(); + if (_bloodDonationService.hasError) { + error = _bloodDonationService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } } Future getBlood() async { diff --git a/lib/pages/Blood/blood_donation.dart b/lib/pages/Blood/blood_donation.dart index 3a702d32..c5e0f714 100644 --- a/lib/pages/Blood/blood_donation.dart +++ b/lib/pages/Blood/blood_donation.dart @@ -73,26 +73,42 @@ class _BloodDonationPageState extends State { projectProvider = Provider.of(context); return BaseView( - onModelReady: (model) { - if (projectProvider.isLogin && projectProvider.user != null) { - model.getCities().then((value) { - model.getBlood().then((value) { - if (model.bloodModelList.length > 0) { - CitiesModel citiesModel = new CitiesModel(); - citiesModel.iD = getSelectedCityID(model); - _selectedHospitalIndex = (citiesModel.iD - 1); - citiesModel.description = model.CitiesModelList[_selectedHospitalIndex].description; - citiesModel.descriptionN = model.CitiesModelList[_selectedHospitalIndex].descriptionN; - _selectedHospital = citiesModel; - _selectedBloodType = model.bloodModelList[0].bloodGroup; - _selectedBloodTypeIndex = getBloodIndex(_selectedBloodType); - } else { - _selectedHospital = model.CitiesModelList[0]; - } - }); - }); - } - }, + onModelReady: (model) => model.getCities().then((value) { + model.getBlood().then((value) { + if (model.bloodModelList.length > 0) { + CitiesModel citiesModel = new CitiesModel(); + citiesModel.iD = getSelectedCityID(model); + _selectedHospitalIndex = (citiesModel.iD - 1); + citiesModel.description = model.CitiesModelList[_selectedHospitalIndex].description; + citiesModel.descriptionN = model.CitiesModelList[_selectedHospitalIndex].descriptionN; + _selectedHospital = citiesModel; + _selectedBloodType = model.bloodModelList[0].bloodGroup; + _selectedBloodTypeIndex = getBloodIndex(_selectedBloodType); + } else { + _selectedHospital = model.CitiesModelList[0]; + } + }); + }), + // { + // if (projectProvider.isLogin && projectProvider.user != null) { + // model.getCities().then((value) { + // model.getBlood().then((value) { + // if (model.bloodModelList.length > 0) { + // CitiesModel citiesModel = new CitiesModel(); + // citiesModel.iD = getSelectedCityID(model); + // _selectedHospitalIndex = (citiesModel.iD - 1); + // citiesModel.description = model.CitiesModelList[_selectedHospitalIndex].description; + // citiesModel.descriptionN = model.CitiesModelList[_selectedHospitalIndex].descriptionN; + // _selectedHospital = citiesModel; + // _selectedBloodType = model.bloodModelList[0].bloodGroup; + // _selectedBloodTypeIndex = getBloodIndex(_selectedBloodType); + // } else { + // _selectedHospital = model.CitiesModelList[0]; + // } + // }); + // }); + // } + // }, builder: (_, model, w) => AppScaffold( isShowAppBar: true, showNewAppBar: true, From ca11fe313458be4ad71beff0a83233d849354389 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Sun, 7 Nov 2021 09:27:19 +0300 Subject: [PATCH 21/70] fix issues --- lib/config/localized_values.dart | 1 + .../pharmacyModule/order_model_view_model.dart | 11 +++++++---- lib/pages/pharmacy/order/ProductReview.dart | 2 +- lib/uitl/translations_delegate_base.dart | 2 ++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index a61f86c4..69e412bb 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1037,6 +1037,7 @@ const Map localizedValues = { "no-data": {"en": "No data found", "ar": "لاتوجد بيانات"}, "insurance-details": {"en": "Insurance Details", "ar": "تفاصيل التأمين"}, "nearest-hospital": {"en": "Nearest Hospital", "ar": "أقرب مستشفى"}, + "submitReview": {"en": "Your review has been Submitted successfully", "ar": "تم إرسال التقييم بنجاح"}, "request-sent": {"en": "Request sent successfully", "ar": "تم إرسال الطلب بنجاح"}, "message-sent": {"en": "Message sent successfully", "ar": "تم إرسال الرسالة بنجاح"}, "sent-on": {"en": "Sent on", "ar": "أرسلت في"}, diff --git a/lib/core/viewModels/pharmacyModule/order_model_view_model.dart b/lib/core/viewModels/pharmacyModule/order_model_view_model.dart index 232e10c4..fe5be016 100644 --- a/lib/core/viewModels/pharmacyModule/order_model_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/order_model_view_model.dart @@ -11,6 +11,7 @@ import 'package:diplomaticquarterapp/services/pharmacy_services/cancelOrder_serv import 'package:diplomaticquarterapp/services/pharmacy_services/orderDetails_service.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/order_service.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import '../../../locator.dart'; import '../base_view_model.dart'; @@ -77,7 +78,8 @@ class OrderModelViewModel extends BaseViewModel { dynamic res; await _cancelOrderService.getCanceledOrder(order).then((value) { res = value['success']['SuccessEndUserMsg']; - AppToast.showSuccessToast(message: "Request Sent Successfully"); + // AppToast.showSuccessToast(message: "Request Sent Successfully"); + AppToast.showSuccessToast(message: TranslationBase.of(context).requestSent); // Navigator.pop(context); }); if (_cancelOrderService.hasError) { @@ -95,7 +97,7 @@ class OrderModelViewModel extends BaseViewModel { return res; } - Future makeReview(PharmacyProduct product, double rating, String reviewText) async { + Future makeReview(PharmacyProduct product, double rating, String reviewText, context) async { setState(ViewState.Busy); await _orderDetailsService.makeReview(product, rating, reviewText); if (_orderDetailsService.hasError) { @@ -104,8 +106,9 @@ class OrderModelViewModel extends BaseViewModel { AppToast.showErrorToast(message: error); } else { setState(ViewState.Idle); - AppToast.showSuccessToast( - message: "Your review has been Submitted successfully"); + AppToast.showSuccessToast(message: TranslationBase.of(context).submitReview); + // AppToast.showSuccessToast( + // message: "Your review has been Submitted successfully"); } } diff --git a/lib/pages/pharmacy/order/ProductReview.dart b/lib/pages/pharmacy/order/ProductReview.dart index 12ab939a..bb680864 100644 --- a/lib/pages/pharmacy/order/ProductReview.dart +++ b/lib/pages/pharmacy/order/ProductReview.dart @@ -201,7 +201,7 @@ class _ProductReviewPageState extends State { ? () { model .makeReview( - widget.product, ratingValue, reviewText) + widget.product, ratingValue, reviewText, context) .then((value) { setState(() { finishReview = true; diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index b15f7adb..12e01337 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1770,6 +1770,8 @@ class TranslationBase { String get requestSent => localizedValues['request-sent'][locale.languageCode]; + String get submitReview => localizedValues['submitReview'][locale.languageCode]; + String get attachInsuraceImage => localizedValues['attach-insurace-image'][locale.languageCode]; String get infoInsurCards => localizedValues['info-insur-cards'][locale.languageCode]; From 0b8600605b7f11618543a90e3a970a2e05ff933f Mon Sep 17 00:00:00 2001 From: devmirza121 Date: Sun, 7 Nov 2021 10:41:03 +0300 Subject: [PATCH 22/70] Health Calculator 1.0 --- assets/images/new/services/bmi.svg | 8 + assets/images/new/services/bmr_calc.svg | 7 + assets/images/new/services/body_fat_calc.svg | 5 + assets/images/new/services/calories_calc.svg | 15 + .../new/services/carbs_proteitn_fat.svg | 8 + assets/images/new/services/delivery.svg | 9 + .../images/new/services/ideal_weight_calc.svg | 3 + assets/images/new/services/ovulation.svg | 8 + lib/config/config.dart | 4 +- lib/config/localized_values.dart | 4 +- .../bmi_calculator/bmi_calculator.dart | 877 +++++++++++------- .../​ health_calculators.dart | 34 +- 12 files changed, 605 insertions(+), 377 deletions(-) create mode 100644 assets/images/new/services/bmi.svg create mode 100644 assets/images/new/services/bmr_calc.svg create mode 100644 assets/images/new/services/body_fat_calc.svg create mode 100644 assets/images/new/services/calories_calc.svg create mode 100644 assets/images/new/services/carbs_proteitn_fat.svg create mode 100644 assets/images/new/services/delivery.svg create mode 100644 assets/images/new/services/ideal_weight_calc.svg create mode 100644 assets/images/new/services/ovulation.svg diff --git a/assets/images/new/services/bmi.svg b/assets/images/new/services/bmi.svg new file mode 100644 index 00000000..ce3be188 --- /dev/null +++ b/assets/images/new/services/bmi.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/assets/images/new/services/bmr_calc.svg b/assets/images/new/services/bmr_calc.svg new file mode 100644 index 00000000..991cdd08 --- /dev/null +++ b/assets/images/new/services/bmr_calc.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/assets/images/new/services/body_fat_calc.svg b/assets/images/new/services/body_fat_calc.svg new file mode 100644 index 00000000..552715b9 --- /dev/null +++ b/assets/images/new/services/body_fat_calc.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/images/new/services/calories_calc.svg b/assets/images/new/services/calories_calc.svg new file mode 100644 index 00000000..2d4de2fa --- /dev/null +++ b/assets/images/new/services/calories_calc.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/assets/images/new/services/carbs_proteitn_fat.svg b/assets/images/new/services/carbs_proteitn_fat.svg new file mode 100644 index 00000000..ba1c7005 --- /dev/null +++ b/assets/images/new/services/carbs_proteitn_fat.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/assets/images/new/services/delivery.svg b/assets/images/new/services/delivery.svg new file mode 100644 index 00000000..2b350b8b --- /dev/null +++ b/assets/images/new/services/delivery.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/assets/images/new/services/ideal_weight_calc.svg b/assets/images/new/services/ideal_weight_calc.svg new file mode 100644 index 00000000..60d7ecbe --- /dev/null +++ b/assets/images/new/services/ideal_weight_calc.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/images/new/services/ovulation.svg b/assets/images/new/services/ovulation.svg new file mode 100644 index 00000000..29650a70 --- /dev/null +++ b/assets/images/new/services/ovulation.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/lib/config/config.dart b/lib/config/config.dart index 49b33063..16beb792 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -15,8 +15,8 @@ const PACKAGES_CUSTOMER = '/api/customers'; 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/'; // Pharmacy UAT URLs const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 207a65d7..0b059d96 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1195,8 +1195,8 @@ const Map localizedValues = { "ovulation": {"en": "Ovulation", "ar": "الإباضة"}, "delivery": {"en": "Delivery", "ar": "الولادة"}, "bmiCalcDesc": { - "en": "'Calculate the BMI value and weight\n status to identify the healthy weight.\n Not appropriate for children and women\n who are pregnant or breastfeeding'", - "ar": "حساب قيمة مؤشر كتلة الجسم وحالة الوزن لتحديد الوزن الصحي. \n وغير مناسب للأطفال والنساء الحوامل أو المرضعات" + "en": "Calculate the BMI value and weight status to identify the healthy weight. Not appropriate for children and women who are pregnant or breastfeeding", + "ar": "احسب قيمة مؤشر كتلة الجسم وحالة الوزن لتحديد الوزن الصحي. غير مناسب للأطفال والنساء الحوامل أو المرضعات" }, "selectUnit": {"en": "Select Unit", "ar": "اختر الوحدة"}, "feet": {"en": "Feet", "ar": "قدم"}, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart index e90acc24..a6f8131b 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart @@ -6,6 +6,7 @@ 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 'package:flutter/services.dart'; import '../health_calc_desc.dart'; import 'result_page.dart'; @@ -30,6 +31,19 @@ class _BMICalculatorState extends State { Color lbCard = inactiveCardColor; Color kgCard = activeCardColor; + TextEditingController _heightController = TextEditingController(); + TextEditingController _weightController = TextEditingController(); + + List _weightPopupList = List(); + List _heightPopupList = List(); + + bool _isUnitML = true; + bool _isGenderMale = false; + bool _isHeightCM = false; + bool _isWeightKG = false; + double _heightValue = 150; + double _weightValue = 40; + void updateColor(int type) { //MG/DLT card if (type == 1) { @@ -115,432 +129,585 @@ class _BMICalculatorState extends State { void initState() { super.initState(); textController.text = '0'; // Setting the initial value for the field. + _heightValue = 100; + _weightValue = 50; + _heightController.text = _heightValue.toStringAsFixed(0); + _weightController.text = _weightValue.toStringAsFixed(0); + + _isWeightKG = true; + _isHeightCM = true; } Widget build(BuildContext context) { + _weightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).kg), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).lb), value: false)]; + _heightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).cm), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).ft), value: false)]; + return AppScaffold( isShowAppBar: true, isShowDecPage: false, showHomeAppBarIcon: false, + showNewAppBar: true, + showNewAppBarTitle: true, appBarIcons: [ IconButton( icon: Icon(Icons.info_outline), - color: Colors.white, + color: Colors.black, onPressed: () { Navigator.push( context, MaterialPageRoute( - builder: (context) => HealthDescPage( - "${TranslationBase.of(context).bmi} ${TranslationBase.of(context).calcHealth}", - TranslationBase.of(context).bmiCalcDesc, + builder: (context) => HealthDescPage("${TranslationBase.of(context).bmi} ${TranslationBase.of(context).calcHealth}", TranslationBase.of(context).bmiCalcDesc, "assets/images/AlHabibMedicalService/health_calculator/bmi.png")), ); }, ) ], - appBarTitle: - "${TranslationBase.of(context).bmi} ${TranslationBase.of(context).calcHealth}", + appBarTitle: "${TranslationBase.of(context).bmi} ${TranslationBase.of(context).calcHealth}", body: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Center( - child: Container( - margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16), - child: Padding( - padding: EdgeInsets.symmetric(vertical: 15.0), - child: Text( - TranslationBase.of(context).bmiCalcDesc, - style: TextStyle(fontSize: 18.0), - ), + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).bmiCalcDesc, + style: TextStyle( + fontSize: 14.0, + letterSpacing: -0.56, + fontWeight: FontWeight.w600, ), ), - ), - Container( - margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16), - padding: EdgeInsets.only(bottom: 16), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(12.0), - ), - child: Column( - children: [ - Row( - children: [ - Padding( - padding: EdgeInsets.all(8.0), - child: Texts(TranslationBase.of(context).height), - ), - ], - ), - Row( - children: [ - Padding( - padding: EdgeInsets.symmetric( - vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, + + _commonInputAndUnitRow( + TranslationBase.of(context).height, + _heightController, + 1, + 270, + _heightValue, + (text) { + _heightController.text = text; + }, + (value) { + _heightValue = value; + }, + _isHeightCM ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, + (value) { + if (_isHeightCM != value) { + setState(() { + _isHeightCM = value; + }); + } + }, + _heightPopupList), + Container( + margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16), + padding: EdgeInsets.only(bottom: 16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12.0), + ), + child: Column( + children: [ + Row( + children: [ + Padding( + padding: EdgeInsets.all(8.0), + child: Texts(TranslationBase.of(context).height), + ), + ], + ), + Row( + children: [ + Padding( + padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0), + child: Center( + child: Container( + width: 60.0, + foregroundDecoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.0), + border: Border.all( + color: Colors.blueGrey, + width: 2.0, + ), ), - ), - child: Row( - children: [ - Expanded( - child: Center( - child: Text(height.toString()), + child: Row( + children: [ + Expanded( + child: Center( + child: Text(height.toString()), + ), ), - ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, + Container( + height: 38.0, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + width: 0.5, + ), ), ), + child: InkWell( + child: Icon( + Icons.arrow_drop_up, + size: 18.0, + ), + onTap: () { + setState(() { + if (height < 250) height++; + }); + }, + ), ), - child: InkWell( + InkWell( child: Icon( - Icons.arrow_drop_up, + Icons.arrow_drop_down, size: 18.0, ), onTap: () { setState(() { - if (height < 250) height++; + if (height > 120) height--; }); }, ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (height > 120) height--; - }); - }, - ), - ], + ], + ), ), - ), - ], + ], + ), ), ), ), - ), - Slider( - value: height.toDouble(), - min: 120, - max: 250, - onChanged: (double newValue) { - setState(() { - height = newValue.round(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), - ], - ), - Row( - children: [ - Padding( - padding: EdgeInsets.all(8.0), - child: Texts(TranslationBase.of(context).selectUnit), - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - GestureDetector( - onTap: () { - setState(() { - updateColor(1); - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: - Offset(0, 3), // changes position of shadow - ), - ], - color: cmCard, - borderRadius: BorderRadius.circular(3.0), - ), - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 0.0, horizontal: 18.0), - child: Center( - child: Texts(TranslationBase.of(context).cm)), - ), + Slider( + value: height.toDouble(), + min: 120, + max: 250, + onChanged: (double newValue) { + setState(() { + height = newValue.round(); + }); + }, + activeColor: Color(0xffC5272D), + inactiveColor: Color(0xffF3C5C6), ), - ), - GestureDetector( - onTap: () { - setState(() { - updateColor(2); - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - color: ftCard, - borderRadius: BorderRadius.circular(3.0), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: - Offset(0, 3), // changes position of shadow - ), - ], + ], + ), + Row( + children: [ + Padding( + padding: EdgeInsets.all(8.0), + child: Texts(TranslationBase.of(context).selectUnit), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + GestureDetector( + onTap: () { + setState(() { + updateColor(1); + }); + }, + child: Container( + height: 55.0, + width: 150.0, + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 3, + blurRadius: 7, + offset: Offset(0, 3), // changes position of shadow + ), + ], + color: cmCard, + borderRadius: BorderRadius.circular(3.0), + ), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 0.0, horizontal: 18.0), + child: Center(child: Texts(TranslationBase.of(context).cm)), + ), ), - child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 16.0), - child: Center( - child: Texts(TranslationBase.of(context).feet)), + ), + GestureDetector( + onTap: () { + setState(() { + updateColor(2); + }); + }, + child: Container( + height: 55.0, + width: 150.0, + decoration: BoxDecoration( + color: ftCard, + borderRadius: BorderRadius.circular(3.0), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 3, + blurRadius: 7, + offset: Offset(0, 3), // changes position of shadow + ), + ], + ), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: Center(child: Texts(TranslationBase.of(context).feet)), + ), ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), - ), - SizedBox( - height: 25.0, - ), - Container( - margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16), - padding: EdgeInsets.only(bottom: 16), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(12.0), + SizedBox( + height: 25.0, ), - child: Column( - children: [ - Row( - children: [ - Padding( - padding: EdgeInsets.all(8.0), - child: Texts(TranslationBase.of(context).weight), - ), - ], - ), - Row( - children: [ - Padding( - padding: EdgeInsets.symmetric( - vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, + Container( + margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16), + padding: EdgeInsets.only(bottom: 16), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12.0), + ), + child: Column( + children: [ + Row( + children: [ + Padding( + padding: EdgeInsets.all(8.0), + child: Texts(TranslationBase.of(context).weight), + ), + ], + ), + Row( + children: [ + Padding( + padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0), + child: Center( + child: Container( + width: 60.0, + foregroundDecoration: BoxDecoration( + borderRadius: BorderRadius.circular(5.0), + border: Border.all( + color: Colors.blueGrey, + width: 2.0, + ), ), - ), - child: Row( - children: [ - Expanded( - child: Center( - child: Text(weight.toString()), + child: Row( + children: [ + Expanded( + child: Center( + child: Text(weight.toString()), + ), ), - ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, + Container( + height: 38.0, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + width: 0.5, + ), ), ), + child: InkWell( + child: Icon( + Icons.arrow_drop_up, + size: 18.0, + ), + onTap: () { + setState(() { + if (weight < 250) weight++; + }); + }, + ), ), - child: InkWell( + InkWell( child: Icon( - Icons.arrow_drop_up, + Icons.arrow_drop_down, size: 18.0, ), onTap: () { setState(() { - if (weight < 250) weight++; + if (weight > 40) weight--; }); }, ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (weight > 40) weight--; - }); - }, - ), - ], + ], + ), ), - ), - ], + ], + ), ), ), ), - ), - Slider( - value: weight.toDouble(), - min: 40, - max: 250, - onChanged: (double newValue) { - setState(() { - weight = newValue.round(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), - ], - ), - Row( - children: [ - Padding( - padding: EdgeInsets.all(8.0), - child: Texts(TranslationBase.of(context).selectUnit), - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - GestureDetector( - onTap: () { - setState(() { - updateColorWeight(1); - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: - Offset(0, 3), // changes position of shadow - ), - ], - color: kgCard, - borderRadius: BorderRadius.circular(3.0), - ), - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 0.0, horizontal: 18.0), - child: Center( - child: Texts(TranslationBase.of(context).kg)), - ), + Slider( + value: weight.toDouble(), + min: 40, + max: 250, + onChanged: (double newValue) { + setState(() { + weight = newValue.round(); + }); + }, + activeColor: Color(0xffC5272D), + inactiveColor: Color(0xffF3C5C6), ), - ), - GestureDetector( - onTap: () { - setState(() { - updateColorWeight(2); - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - color: lbCard, - borderRadius: BorderRadius.circular(3.0), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: - Offset(0, 3), // changes position of shadow - ), - ], + ], + ), + Row( + children: [ + Padding( + padding: EdgeInsets.all(8.0), + child: Texts(TranslationBase.of(context).selectUnit), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + GestureDetector( + onTap: () { + setState(() { + updateColorWeight(1); + }); + }, + child: Container( + height: 55.0, + width: 150.0, + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 3, + blurRadius: 7, + offset: Offset(0, 3), // changes position of shadow + ), + ], + color: kgCard, + borderRadius: BorderRadius.circular(3.0), + ), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 0.0, horizontal: 18.0), + child: Center(child: Texts(TranslationBase.of(context).kg)), + ), ), - child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 16.0), - child: Center( - child: - Texts(TranslationBase.of(context).pound)), + ), + GestureDetector( + onTap: () { + setState(() { + updateColorWeight(2); + }); + }, + child: Container( + height: 55.0, + width: 150.0, + decoration: BoxDecoration( + color: lbCard, + borderRadius: BorderRadius.circular(3.0), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.5), + spreadRadius: 3, + blurRadius: 7, + offset: Offset(0, 3), // changes position of shadow + ), + ], + ), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: Center(child: Texts(TranslationBase.of(context).pound)), + ), ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), - ), - SizedBox( - height: 25.0, - ), - Container( - margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16), - padding: EdgeInsets.symmetric(vertical: 8), - child: SecondaryButton( - label: TranslationBase.of(context).calculate, - onTap: () => { - setState(() { - calculateBMI(); - showTextResult(context); - showMsg(context); - { - Navigator.push( - context, - FadePage( - page: ResultPage( - finalResult: bmiResult, - textResult: textResult, - msg: msg, - )), - ); - } - }) + SizedBox( + height: 25.0, + ), + Container( + margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16), + padding: EdgeInsets.symmetric(vertical: 8), + child: SecondaryButton( + label: TranslationBase.of(context).calculate, + onTap: () => { + setState(() { + calculateBMI(); + showTextResult(context); + showMsg(context); + { + Navigator.push( + context, + FadePage( + page: ResultPage( + finalResult: bmiResult, + textResult: textResult, + msg: msg, + )), + ); + } + }) + }, + ), + ), + ], + ), + ), + ), + ); + } + + Widget _commonInputAndUnitRow(_title, _controller, double _minValue, double _maxValue, double _valueOrg, Function(String) onTextValueChange, Function(double) onValueChange, String unitTitle, + Function(bool) onUnitTap, _list) { + return Row( + children: [ + Expanded( + flex: 3, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _title, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff2E303A), + letterSpacing: -0.44, + ), + ), + TextField( + controller: _controller, + keyboardType: TextInputType.number, + onChanged: (value) { + double _value = double.parse(value); + if (_value > _maxValue) { + onTextValueChange(_maxValue.toStringAsFixed(0)); + onValueChange(_maxValue); + return; + } else if (_value < _minValue) { + onTextValueChange(_minValue.toStringAsFixed(0)); + onValueChange(_minValue); + return; + } else if (_value >= _minValue && _value <= _maxValue) { + onValueChange(_value); + return; + } }, + inputFormatters: [ + FilteringTextInputFormatter.allow(RegExp(r'[0-9]')), + ], + style: TextStyle( + color: Color(0xff575757), + letterSpacing: -0.56, + ), + decoration: InputDecoration( + isDense: true, + hintText: "0", + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), ), - ), - ], + ], + ), ), + Container(height: 34, width: 1, color: Color(0xffE0E0E0), margin: EdgeInsets.only(left: 12, right: 12)), + Expanded( + flex: 1, + child: PopupMenuButton( + child: CommonDropDownView(TranslationBase.of(context).unit, unitTitle, null), + onSelected: (value) { + onUnitTap(value); + }, + itemBuilder: (context) => _list), + ) + ], + ).withBorderedContainer; + } +} + +// todo 'sikander' move these to separate file once usability known +class CommonDropDownView extends StatelessWidget { + final String title; + final String value; + final VoidCallback callback; + final IconData iconData; + + CommonDropDownView(this.title, this.value, this.callback, {Key key, this.iconData}) : super(key: key); + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: callback, + child: Row( + children: [ + Expanded( + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text( + title, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff2E303A), + letterSpacing: -0.44, + ), + ), + Text( + value, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + ), + ]), + ), + Icon( + iconData ?? Icons.keyboard_arrow_down_sharp, + color: Color(0xff2E303A), + ) + ], ), ); } } + +extension BorderedContainer on Widget { + Widget get withBorderedContainer => Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: this, + ); +} diff --git a/lib/pages/AlHabibMedicalService/​ health_calculators.dart b/lib/pages/AlHabibMedicalService/​ health_calculators.dart index 341a298d..67f27337 100644 --- a/lib/pages/AlHabibMedicalService/​ health_calculators.dart +++ b/lib/pages/AlHabibMedicalService/​ health_calculators.dart @@ -109,11 +109,11 @@ class _HealthCalculatorsState extends State with SingleTicker ), ), Container( - margin: EdgeInsets.all(20.0), + // margin: EdgeInsets.all(20.0), child: Column( children: [ Padding( - padding: EdgeInsets.only(left: 12, right: 12), + padding: EdgeInsets.only(left: 12, right: 12, top: 20.0), child: GridView.builder( shrinkWrap: true, primary: false, @@ -147,9 +147,9 @@ class _HealthCalculatorsState extends State with SingleTicker ), child: MedicalProfileItem( title: TranslationBase.of(context).bmi, - imagePath: 'assets/images/new-design/bmi_health_calculator.png', + imagePath: 'bmi.svg', subTitle: TranslationBase.of(context).calcHealth, - isPngImage: true, + ), )); @@ -160,9 +160,9 @@ class _HealthCalculatorsState extends State with SingleTicker ), child: MedicalProfileItem( title: TranslationBase.of(context).calories, - imagePath: 'assets/images/new-design/calories-calculator.png', + imagePath: 'calories_calc.svg', subTitle: TranslationBase.of(context).calcHealth, - isPngImage: true, + ), )); @@ -173,9 +173,9 @@ class _HealthCalculatorsState extends State with SingleTicker ), child: MedicalProfileItem( title: TranslationBase.of(context).bmr, - imagePath: 'assets/images/new-design/BMR_calculator.png', + imagePath: 'bmr_calc.svg', subTitle: TranslationBase.of(context).calcHealth, - isPngImage: true, + ), )); @@ -186,9 +186,9 @@ class _HealthCalculatorsState extends State with SingleTicker ), child: MedicalProfileItem( title: TranslationBase.of(context).idealBody, - imagePath: 'assets/images/new-design/body_weight.png', + imagePath: 'ideal_weight_calc.svg', subTitle: TranslationBase.of(context).weight, - isPngImage: true, + ), )); @@ -199,9 +199,9 @@ class _HealthCalculatorsState extends State with SingleTicker ), child: MedicalProfileItem( title: TranslationBase.of(context).bodyWord, - imagePath: 'assets/images/new-design/body_fat.png', + imagePath: 'bmr_calc.svg', subTitle: TranslationBase.of(context).fat, - isPngImage: true, + ), )); @@ -212,9 +212,9 @@ class _HealthCalculatorsState extends State with SingleTicker ), child: MedicalProfileItem( title: TranslationBase.of(context).carbohydrate, - imagePath: 'assets/images/new-design/carb_protein.png', + imagePath: 'carbs_proteitn_fat.svg', subTitle: TranslationBase.of(context).proteinFat, - isPngImage: true, + ), )); @@ -231,9 +231,8 @@ class _HealthCalculatorsState extends State with SingleTicker ), child: MedicalProfileItem( title: TranslationBase.of(context).ovulation, - imagePath: 'assets/images/new-design/ovulation_period_icon.png', + imagePath: 'ovulation.svg', subTitle: TranslationBase.of(context).period, - isPngImage: true, ), )); @@ -244,9 +243,8 @@ class _HealthCalculatorsState extends State with SingleTicker ), child: MedicalProfileItem( title: TranslationBase.of(context).delivery, - imagePath: 'assets/images/new-design/delivery_date_icon.png', + imagePath: 'delivery.svg', subTitle: TranslationBase.of(context).dueDate, - isPngImage: true, ), )); From d4eab13982b773161f1d64ceead8cfc244e0664d Mon Sep 17 00:00:00 2001 From: devmirza121 Date: Sun, 7 Nov 2021 16:05:16 +0300 Subject: [PATCH 23/70] Health Calculator 2.0 --- lib/config/localized_values.dart | 2 +- .../bmi_calculator/bmi_calculator.dart | 556 ++-------- .../bmi_calculator/result_page.dart | 157 ++- .../bmr_calculator/bmr_calculator.dart | 342 ++++++- .../calorie_calculator.dart | 968 ++++++++---------- .../calorie_result_page.dart | 111 +- 6 files changed, 1018 insertions(+), 1118 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 343bd2f5..65b05d37 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1149,7 +1149,7 @@ const Map localizedValues = { "triglycerides": {"en": "Triglycerides", "ar": "الدهون الثلاثية"}, "fatInBlood": {"en": "Fat in Blood", "ar": ""}, "convertFrom": {"en": "Convert from", "ar": "تحويل من"}, - "calculate": {"en": "calculate", "ar": "احسب"}, + "calculate": {"en": "Calculate", "ar": "احسب"}, "enterReadingValue": {"en": "Enter the reading value", "ar": "ادخل القيمة"}, "result": {"en": "Result", "ar": "النتيجة"}, "sort": {"en": "Sort", "ar": "فرز"}, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart index a6f8131b..c06d77db 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart @@ -1,6 +1,8 @@ import 'dart:math'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -24,12 +26,6 @@ class _BMICalculatorState extends State { String textResult; String msg; double bmiResult; - int height = 150; - int weight = 40; - Color cmCard = activeCardColor; - Color ftCard = inactiveCardColor; - Color lbCard = inactiveCardColor; - Color kgCard = activeCardColor; TextEditingController _heightController = TextEditingController(); TextEditingController _weightController = TextEditingController(); @@ -37,53 +33,11 @@ class _BMICalculatorState extends State { List _weightPopupList = List(); List _heightPopupList = List(); - bool _isUnitML = true; - bool _isGenderMale = false; - bool _isHeightCM = false; - bool _isWeightKG = false; + bool _isHeightCM = true; + bool _isWeightKG = true; double _heightValue = 150; double _weightValue = 40; - void updateColor(int type) { - //MG/DLT card - if (type == 1) { - if (cmCard == inactiveCardColor) { - cmCard = activeCardColor; - ftCard = inactiveCardColor; - } else { - cmCard = inactiveCardColor; - } - } - if (type == 2) { - if (ftCard == inactiveCardColor) { - ftCard = activeCardColor; - cmCard = inactiveCardColor; - } else { - ftCard = inactiveCardColor; - } - } - } - - void updateColorWeight(int type) { - //MG/DLT card - if (type == 1) { - if (kgCard == inactiveCardColor) { - kgCard = activeCardColor; - lbCard = inactiveCardColor; - } else { - kgCard = inactiveCardColor; - } - } - if (type == 2) { - if (lbCard == inactiveCardColor) { - lbCard = activeCardColor; - kgCard = inactiveCardColor; - } else { - lbCard = inactiveCardColor; - } - } - } - double convertToCm(double number) { return number * 30.48; } @@ -93,10 +47,10 @@ class _BMICalculatorState extends State { } double calculateBMI() { - if (ftCard == activeCardColor) { - convertToCm(height.toDouble()); + if (_isHeightCM) { + convertToCm(_heightValue.toDouble()); } - bmiResult = weight / pow(height / 100, 2); + bmiResult = _weightValue / pow(_heightValue / 100, 2); return bmiResult; } @@ -129,13 +83,13 @@ class _BMICalculatorState extends State { void initState() { super.initState(); textController.text = '0'; // Setting the initial value for the field. - _heightValue = 100; - _weightValue = 50; + _heightValue = 100; + _weightValue = 50; _heightController.text = _heightValue.toStringAsFixed(0); _weightController.text = _weightValue.toStringAsFixed(0); _isWeightKG = true; - _isHeightCM = true; + _isHeightCM = true; } Widget build(BuildContext context) { @@ -163,410 +117,100 @@ class _BMICalculatorState extends State { ) ], appBarTitle: "${TranslationBase.of(context).bmi} ${TranslationBase.of(context).calcHealth}", - body: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(12.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).bmiCalcDesc, - style: TextStyle( - fontSize: 14.0, - letterSpacing: -0.56, - fontWeight: FontWeight.w600, - ), - ), - - _commonInputAndUnitRow( - TranslationBase.of(context).height, - _heightController, - 1, - 270, - _heightValue, - (text) { - _heightController.text = text; - }, - (value) { - _heightValue = value; - }, - _isHeightCM ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, - (value) { - if (_isHeightCM != value) { - setState(() { - _isHeightCM = value; - }); - } - }, - _heightPopupList), - Container( - margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16), - padding: EdgeInsets.only(bottom: 16), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(12.0), - ), - child: Column( - children: [ - Row( - children: [ - Padding( - padding: EdgeInsets.all(8.0), - child: Texts(TranslationBase.of(context).height), - ), - ], - ), - Row( - children: [ - Padding( - padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), - child: Row( - children: [ - Expanded( - child: Center( - child: Text(height.toString()), - ), - ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (height < 250) height++; - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (height > 120) height--; - }); - }, - ), - ], - ), - ), - ], - ), - ), - ), - ), - Slider( - value: height.toDouble(), - min: 120, - max: 250, - onChanged: (double newValue) { - setState(() { - height = newValue.round(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), - ], - ), - Row( - children: [ - Padding( - padding: EdgeInsets.all(8.0), - child: Texts(TranslationBase.of(context).selectUnit), - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - GestureDetector( - onTap: () { - setState(() { - updateColor(1); - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow - ), - ], - color: cmCard, - borderRadius: BorderRadius.circular(3.0), - ), - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 0.0, horizontal: 18.0), - child: Center(child: Texts(TranslationBase.of(context).cm)), - ), - ), - ), - GestureDetector( - onTap: () { - setState(() { - updateColor(2); - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - color: ftCard, - borderRadius: BorderRadius.circular(3.0), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow - ), - ], - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: Center(child: Texts(TranslationBase.of(context).feet)), - ), - ), - ), - ], - ), - ], - ), - ), - SizedBox( - height: 25.0, - ), - Container( - margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16), - padding: EdgeInsets.only(bottom: 16), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(12.0), - ), - child: Column( - children: [ - Row( - children: [ - Padding( - padding: EdgeInsets.all(8.0), - child: Texts(TranslationBase.of(context).weight), - ), - ], - ), - Row( - children: [ - Padding( - padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), - child: Row( - children: [ - Expanded( - child: Center( - child: Text(weight.toString()), - ), - ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (weight < 250) weight++; - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (weight > 40) weight--; - }); - }, - ), - ], - ), - ), - ], - ), - ), - ), - ), - Slider( - value: weight.toDouble(), - min: 40, - max: 250, - onChanged: (double newValue) { - setState(() { - weight = newValue.round(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), - ], - ), - Row( - children: [ - Padding( - padding: EdgeInsets.all(8.0), - child: Texts(TranslationBase.of(context).selectUnit), - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - GestureDetector( - onTap: () { - setState(() { - updateColorWeight(1); - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow - ), - ], - color: kgCard, - borderRadius: BorderRadius.circular(3.0), - ), - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 0.0, horizontal: 18.0), - child: Center(child: Texts(TranslationBase.of(context).kg)), - ), - ), - ), - GestureDetector( - onTap: () { - setState(() { - updateColorWeight(2); - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - color: lbCard, - borderRadius: BorderRadius.circular(3.0), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow - ), - ], - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: Center(child: Texts(TranslationBase.of(context).pound)), - ), - ), - ), - ], + body: Column( + children: [ + Expanded( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).bmiCalcDesc, + style: TextStyle( + fontSize: 14.0, + letterSpacing: -0.56, + fontWeight: FontWeight.w600, ), - ], - ), - ), - SizedBox( - height: 25.0, - ), - Container( - margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16), - padding: EdgeInsets.symmetric(vertical: 8), - child: SecondaryButton( - label: TranslationBase.of(context).calculate, - onTap: () => { - setState(() { - calculateBMI(); - showTextResult(context); - showMsg(context); - { - Navigator.push( - context, - FadePage( - page: ResultPage( - finalResult: bmiResult, - textResult: textResult, - msg: msg, - )), - ); + ), + mHeight(24), + _commonInputAndUnitRow( + TranslationBase.of(context).height, + _heightController, + 1, + 270, + _heightValue, + (text) { + _heightController.text = text; + }, + (value) { + _heightValue = value; + }, + _isHeightCM ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, + (value) { + if (_isHeightCM != value) { + setState(() { + _isHeightCM = value; + }); } - }) - }, - ), + }, + _heightPopupList, + ), + mHeight(12), + _commonInputAndUnitRow( + TranslationBase.of(context).weight, + _weightController, + 1, + 270, + _weightValue, + (text) { + _weightController.text = text; + }, + (value) { + _weightValue = value; + }, + _isWeightKG ? TranslationBase.of(context).kg : TranslationBase.of(context).pound, + (value) { + if (_isWeightKG != value) { + setState(() { + _isWeightKG = value; + }); + } + }, + _weightPopupList, + ), + ], ), - ], + ), ), - ), + Container( + color: Colors.white, + padding: EdgeInsets.all(16), + child: SecondaryButton( + label: TranslationBase.of(context).calculate, + color: CustomColors.accentColor, + onTap: () { + setState(() { + calculateBMI(); + showTextResult(context); + showMsg(context); + { + Navigator.push( + context, + FadePage( + page: ResultPage( + finalResult: bmiResult, + textResult: textResult, + msg: msg, + ), + ), + ); + } + }); + }, + ), + ), + ], ), ); } diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/result_page.dart index 91a430ca..68126b4d 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/result_page.dart @@ -1,12 +1,16 @@ - +import 'package:auto_size_text/auto_size_text.dart'; import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bariatrics-screen.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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 'package:flutter_svg/svg.dart'; import 'package:percent_indicator/percent_indicator.dart'; class ResultPage extends StatelessWidget { @@ -50,67 +54,71 @@ class ResultPage extends StatelessWidget { return AppScaffold( isShowDecPage: false, isShowAppBar: true, + showNewAppBarTitle: true, + showNewAppBar: true, appBarTitle: "${TranslationBase.of(context).bmi} ${TranslationBase.of(context).calcHealth}", body: Column( children: [ - Expanded( - child: SingleChildScrollView( + Container( + margin: EdgeInsets.only(left: 20, right: 20, top: 20, bottom: 6), + decoration: cardRadius(12), + child: Padding( + padding: const EdgeInsets.all(12.0), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, children: [ - Container( - margin: EdgeInsets.only(top: 50), - child: Center( - child: CircularPercentIndicator( - radius: 220.0, - lineWidth: 20.0, - percent: percentInductor(), - center: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - finalResult.toStringAsFixed(1), - style: TextStyle( - fontSize: 18.0, - fontWeight: FontWeight.bold, - ), - ), - SizedBox( - height: 5.0, - ), - Text( - textResult, - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.w600, - ), - ), - ], - ), - progressColor: colorInductor(), - backgroundColor: Colors.white, - ), + Text( + TranslationBase.of(context).bodyMassIndex + finalResult.toString(), + style: TextStyle( + fontSize: 16, + letterSpacing: -0.64, + fontWeight: FontWeight.w600, ), ), + mHeight(20), Container( - margin: EdgeInsets.symmetric(horizontal: 16, vertical: 16), - child: Texts(msg), + height: MediaQuery.of(context).size.width / 2.8, + child: Row( + children: [ + showMass(context, TranslationBase.of(context).underWeight, "< 18.5", finalResult <= 18.5 ? Colors.red : Colors.black, 8), + mWidth(12), + showMass(context, TranslationBase.of(context).healthy, "18.5 - 24.9", (finalResult > 18.5 && finalResult < 25) ? Colors.red : Colors.black, 6), + mWidth(12), + showMass(context, TranslationBase.of(context).overWeight, "25 - 29.9", (finalResult >= 25 && finalResult < 30) ? Colors.red : Colors.black, 4), + mWidth(12), + showMass(context, TranslationBase.of(context).obese, "30 - 34.9", (finalResult >= 30 && finalResult < 35) ? Colors.red : Colors.black, 2), + mWidth(12), + showMass(context, TranslationBase.of(context).extremeObese, "> 35", (finalResult >= 35) ? Colors.red : Colors.black, 0), + ], + ), + ), + mHeight(20), + Text( + textResult, + style: TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, + ), + ), + mHeight(4), + Text( + msg, + style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.56, color: CustomColors.textColor), ), ], ), ), ), + mFlex(1), Container( - margin: EdgeInsets.symmetric(horizontal: 16, vertical: 16), - child: BorderedButton( - TranslationBase.of(context).seeListOfDoctor, - fontSize: SizeConfig.textMultiplier * 2.1, - textColor: Colors.white, - vPadding: 8, - hPadding: 8, - backgroundColor: Theme.of(context).primaryColor, - radius: 8, - fontWeight: FontWeight.bold, - handler: () { + color: Colors.white, + padding: EdgeInsets.all(16), + child: SecondaryButton( + label: TranslationBase.of(context).seeListOfDoctor, + color: CustomColors.accentColor, + onTap: () { Navigator.push( context, FadePage(page: BariatricsPage(1, 1, finalResult)), @@ -122,4 +130,57 @@ class ResultPage extends StatelessWidget { ), ); } + + Widget showMass(BuildContext context, String title, String weight, Color color, int f) { + return Expanded( + flex: 1, + child: Container( + height: double.infinity, + width: double.infinity, + child: Column( + children: [ + Flexible( + child: Row( + children: [ + mFlex(f), + Flexible( + flex: 10, + child: SvgPicture.asset( + "assets/images/new/mass/health_BMI.svg", + height: double.infinity, + width: double.infinity, + fit: BoxFit.fill, + color: color, + ), + ), + mFlex(f), + ], + ), + ), + mHeight(20), + AutoSizeText( + title, + maxLines: 1, + minFontSize: 6, + style: TextStyle( + color: color, + fontSize: 10, + letterSpacing: -0.6, + ), + ), + AutoSizeText( + weight, + maxLines: 1, + minFontSize: 6, + style: TextStyle( + color: color, + fontSize: 10, + letterSpacing: -0.6, + ), + ) + ], + ), + ), + ); + } } diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart index ad35c61d..aea4d3b0 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart @@ -1,10 +1,13 @@ +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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 'package:flutter/services.dart'; import 'bmr_result_page.dart'; @@ -145,10 +148,14 @@ class _BmrCalculatorState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: EdgeInsets.all(10.0), - child: Texts( - 'Calculates the amount of energy that the person’s body expends in a day'), + Text( + 'Calculates the amount of energy that the person’s body expends in a day', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, + color: CustomColors.textColor, + ), ), Divider( thickness: 2.0, @@ -159,53 +166,85 @@ class _BmrCalculatorState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts('Gender'), SizedBox( - height: 5.0, + height: 20, + ), + Text( + TranslationBase.of(context).selectGender, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, + color: CustomColors.textColor, + ), + ), + SizedBox( + height: 8.0, ), Container( - width: 350, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(35.0), - color: Colors.white, - border: Border.all( - color: Colors.black45, - )), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - GestureDetector( - onTap: () { - setState(() { - updateColor(1); - isMale = false; - }); - }, - child: Container( - height: 55.0, - width: 170.0, - decoration: BoxDecoration( - color: maleCard, - borderRadius: BorderRadius.circular(35.0), + Expanded( + child: GestureDetector( + onTap: () { + setState(() { + updateColor(1); + isMale = false; + }); + }, + child: Row( + children: [ + Container( + decoration: containerColorRadiusBorderWidth(Colors.white, 1000, CustomColors.darkGreyColor, 1), + width: 24, + height: 24, + padding: EdgeInsets.all(4), + child: Container( + width: double.infinity, + height: double.infinity, + decoration: containerRadius(!isMale?CustomColors.accentColor:Colors.white, 100), + ), + ), + mWidth(12), + Text(TranslationBase.of(context).female, style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, + ),), + ], ), - child: Center(child: Texts('FEMALE')), ), ), - GestureDetector( - onTap: () { - setState(() { - updateColor(2); - isMale = true; - }); - }, - child: Container( - height: 55.0, - width: 170.0, - decoration: BoxDecoration( - color: femaleCard, - borderRadius: BorderRadius.circular(35.0), + Expanded( + child: GestureDetector( + onTap: () { + setState(() { + updateColor(2); + isMale = true; + }); + }, + child: Row( + children: [ + Container( + decoration: containerColorRadiusBorderWidth(Colors.white, 1000, CustomColors.darkGreyColor, 1), + width: 24, + height: 24, + padding: EdgeInsets.all(4), + child: Container( + width: double.infinity, + height: double.infinity, + decoration: containerRadius(isMale?CustomColors.accentColor:Colors.white, 100), + ), + ), + mWidth(12), + Text(TranslationBase.of(context).male, style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, + ),), + ], ), - child: Center(child: Texts('MALE')), ), ), ], @@ -734,4 +773,225 @@ class _BmrCalculatorState extends State { ), ); } + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) { + return Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: InkWell( + onTap: hasSelection ? () {} : null, + child: Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _labelText, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.zero, + keyboardType: TextInputType.number, + controller: _controller, + onChanged: (value) => {}, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + prefixIconConstraints: BoxConstraints(minWidth: 50), + prefixIcon: prefix == null + ? null + : Text( + "+" + prefix, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, + ), + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ], + ), + ), + if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined), + ], + ), + ), + ); + } + + Widget _commonInputAndUnitRow(_title, _controller, double _minValue, double _maxValue, double _valueOrg, Function(String) onTextValueChange, Function(double) onValueChange, String unitTitle, + Function(bool) onUnitTap, _list) { + return Row( + children: [ + Expanded( + flex: 3, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _title, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff2E303A), + letterSpacing: -0.44, + ), + ), + TextField( + controller: _controller, + keyboardType: TextInputType.number, + onChanged: (value) { + double _value = double.parse(value); + if (_value > _maxValue) { + onTextValueChange(_maxValue.toStringAsFixed(0)); + onValueChange(_maxValue); + return; + } else if (_value < _minValue) { + onTextValueChange(_minValue.toStringAsFixed(0)); + onValueChange(_minValue); + return; + } else if (_value >= _minValue && _value <= _maxValue) { + onValueChange(_value); + return; + } + }, + inputFormatters: [ + FilteringTextInputFormatter.allow(RegExp(r'[0-9]')), + ], + style: TextStyle( + color: Color(0xff575757), + letterSpacing: -0.56, + ), + decoration: InputDecoration( + isDense: true, + hintText: "0", + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ], + ), + ), + Container(height: 34, width: 1, color: Color(0xffE0E0E0), margin: EdgeInsets.only(left: 12, right: 12)), + Expanded( + flex: 1, + child: PopupMenuButton( + child: CommonDropDownView(TranslationBase.of(context).unit, unitTitle, null), + onSelected: (value) { + onUnitTap(value); + }, + itemBuilder: (context) => _list), + ) + ], + ).withBorderedContainer; + } +} + +// todo 'sikander' move these to separate file once usability known +class CommonDropDownView extends StatelessWidget { + final String title; + final String value; + final VoidCallback callback; + final IconData iconData; + + CommonDropDownView(this.title, this.value, this.callback, {Key key, this.iconData}) : super(key: key); + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: callback, + child: Row( + children: [ + Expanded( + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text( + title, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff2E303A), + letterSpacing: -0.44, + ), + ), + Text( + value, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + ), + ]), + ), + Icon( + iconData ?? Icons.keyboard_arrow_down_sharp, + color: Color(0xff2E303A), + ) + ], + ), + ); + } } + +extension BorderedContainer on Widget { + Widget get withBorderedContainer => Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: this, + ); +} \ No newline at end of file diff --git a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart index 4e24f64a..6685a2c6 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart @@ -1,9 +1,14 @@ +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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 'package:flutter/services.dart'; +import 'package:provider/provider.dart'; import 'calorie_result_page.dart'; @@ -21,13 +26,23 @@ class _CalorieCalculatorState extends State { bool isMale = false; Color maleCard = activeCardColorGender; Color femaleCard = inactiveCardColorGender; - Color kgCard = activeCardColor; - Color lbCard = inactiveCardColor; - Color cmCard = activeCardColor; - Color ftCard = inactiveCardColor; - int age = 0; - int height = 0; - int weight = 0; + + final GlobalKey clinicDropdownKey = GlobalKey(); + bool _isHeightCM = true; + bool _isWeightKG = true; + double _heightValue = 150; + double _weightValue = 40; + + TextEditingController ageController = new TextEditingController(); + TextEditingController _heightController = new TextEditingController(); + TextEditingController _weightController = TextEditingController(); + + List _heightPopupList = List(); + List _weightPopupList = List(); + + // int age = 0; + // int height = 0; + // int weight = 0; double calories; String dropdownValue; @@ -51,69 +66,32 @@ class _CalorieCalculatorState extends State { } } - void updateColorWeight(int type) { - //MG/DLT card - if (type == 1) { - if (kgCard == inactiveCardColor) { - kgCard = activeCardColor; - lbCard = inactiveCardColor; - } else { - kgCard = inactiveCardColor; - } - } - if (type == 2) { - if (lbCard == inactiveCardColor) { - lbCard = activeCardColor; - kgCard = inactiveCardColor; - } else { - lbCard = inactiveCardColor; - } - } - } - - void updateColorHeight(int type) { - //MG/DLT card - if (type == 1) { - if (cmCard == inactiveCardColor) { - cmCard = activeCardColor; - ftCard = inactiveCardColor; - } else { - cmCard = inactiveCardColor; - } - } - if (type == 2) { - if (ftCard == inactiveCardColor) { - ftCard = activeCardColor; - cmCard = inactiveCardColor; - } else { - ftCard = inactiveCardColor; - } - } - } - void calculateCalories() { if (isMale == true) { - calories = 66.5 + (13.75 * weight) + (5.003 * height) - (6.755 * age); + calories = 66.5 + (13.75 * int.parse(_weightController.text)) + (5.003 * int.parse(_heightController.text)) - (6.755 * int.parse(ageController.text)); } else if (isMale == false) { - calories = - 655.0955 + (9.5634 * weight) + (1.850 * height) - (4.676 * age); + calories = 655.0955 + (9.5634 * int.parse(_weightController.text)) + (1.850 * int.parse(_heightController.text)) - (4.676 * int.parse(ageController.text)); } } @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + _weightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).kg), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).lb), value: false)]; + _heightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).cm), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).ft), value: false)]; + return AppScaffold( isShowAppBar: true, isShowDecPage: false, - appBarTitle: - "${TranslationBase.of(context).calories} ${TranslationBase.of(context).calcHealth}", - showHomeAppBarIcon: false, + showNewAppBar: true, + showNewAppBarTitle: true, + appBarTitle: "${TranslationBase.of(context).calories} ${TranslationBase.of(context).calcHealth}", appBarIcons: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 7.0), child: Icon( Icons.info_outline, - color: Colors.white, + color: Colors.black, ), ) ], @@ -127,23 +105,31 @@ class _CalorieCalculatorState extends State { //mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts( + Text( TranslationBase.of(context).calorieCalcDesc, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, + color: CustomColors.textColor, + ), ), SizedBox( - height: 8.0, + height: 20, + ), + Text( + TranslationBase.of(context).selectGender, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, + color: CustomColors.textColor, + ), ), - Texts(TranslationBase.of(context).gender), SizedBox( height: 8.0, ), Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(30.0), - color: Colors.white, - border: Border.all( - color: Colors.black45, - )), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ @@ -155,15 +141,29 @@ class _CalorieCalculatorState extends State { isMale = false; }); }, - child: Container( - padding: EdgeInsets.symmetric(vertical: 16), - decoration: BoxDecoration( - color: maleCard, - borderRadius: BorderRadius.circular(30.0), - ), - child: Center( - child: Texts( - TranslationBase.of(context).female)), + child: Row( + children: [ + Container( + decoration: containerColorRadiusBorderWidth(Colors.white, 1000, CustomColors.darkGreyColor, 1), + width: 24, + height: 24, + padding: EdgeInsets.all(4), + child: Container( + width: double.infinity, + height: double.infinity, + decoration: containerRadius(!isMale ? CustomColors.accentColor : Colors.white, 100), + ), + ), + mWidth(12), + Text( + TranslationBase.of(context).female, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, + ), + ), + ], ), ), ), @@ -175,506 +175,155 @@ class _CalorieCalculatorState extends State { isMale = true; }); }, - child: Container( - padding: EdgeInsets.symmetric(vertical: 16), - decoration: BoxDecoration( - color: femaleCard, - borderRadius: BorderRadius.circular(30.0), - ), - child: Center( - child: Texts( - TranslationBase.of(context).male)), - ), - ), - ), - ], - ), - ), - SizedBox( - height: 12.0, - ), - Texts( - TranslationBase.of(context).age11_120Years, - ), - Container( - margin: - EdgeInsets.symmetric(horizontal: 4.0, vertical: 12.0), - decoration: BoxDecoration( - color: Colors.white, - ), - child: Row( - children: [ - Padding( - padding: EdgeInsets.symmetric( - vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), - child: Row( - children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.all(4.0), - child: Center( - child: Text(age.toString()), - ), - ), + child: Row( + children: [ + Container( + decoration: containerColorRadiusBorderWidth(Colors.white, 1000, CustomColors.darkGreyColor, 1), + width: 24, + height: 24, + padding: EdgeInsets.all(4), + child: Container( + width: double.infinity, + height: double.infinity, + decoration: containerRadius(isMale ? CustomColors.accentColor : Colors.white, 100), ), - Container( - padding: - EdgeInsets.symmetric(horizontal: 4), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (age < 120) age++; - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (age > 0) age--; - }); - }, - ), - ], - ), - ), - ], - ), - ), - ), - ), - Expanded( - child: Slider( - value: age.toDouble(), - min: 0, - max: 120, - onChanged: (double newValue) { - setState(() { - age = newValue.round(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), - ), - ], - ), - ), - Texts( - TranslationBase.of(context).height, - ), - Container( - margin: - EdgeInsets.symmetric(horizontal: 4.0, vertical: 12.0), - decoration: BoxDecoration( - color: Colors.white, - ), - child: Row( - children: [ - Padding( - padding: EdgeInsets.symmetric( - vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, ), - ), - child: Row( - children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.all(4.0), - child: Center( - child: Text(height.toString()), - ), - ), - ), - Container( - padding: - EdgeInsets.symmetric(horizontal: 4.0), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (height < 250) height++; - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (height > 0) height--; - }); - }, - ), - ], - ), + mWidth(12), + Text( + TranslationBase.of(context).male, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, ), - ], - ), + ), + ], ), ), ), - Expanded( - child: Slider( - value: height.toDouble(), - min: 0, - max: 250, - onChanged: (double newValue) { - setState(() { - height = newValue.round(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), - ), ], ), ), - Texts( - TranslationBase.of(context).selectUnit, + SizedBox( + height: 12.0, ), + inputWidget(TranslationBase.of(context).age11_120Years, "0", ageController), SizedBox( - height: 8.0, + height: 12.0, ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - child: GestureDetector( - onTap: () { - setState(() { - updateColorHeight(1); - }); - }, - child: Container( - padding: EdgeInsets.all(12), - margin: EdgeInsets.symmetric(horizontal: 8), - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset( - 0, 3), // changes position of shadow - ), - ], - color: cmCard, - borderRadius: BorderRadius.circular(3.0), - ), - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 0.0, horizontal: 18.0), - child: Center( - child: - Texts(TranslationBase.of(context).cm)), - ), - ), - ), - ), - Expanded( - child: GestureDetector( - onTap: () { - setState(() { - updateColorHeight(2); - }); - }, - child: Container( - padding: EdgeInsets.all(12), - margin: EdgeInsets.symmetric(horizontal: 8), - decoration: BoxDecoration( - color: ftCard, - borderRadius: BorderRadius.circular(3.0), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset( - 0, 3), // changes position of shadow - ), - ], - ), - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 16.0), - child: Center( - child: Texts( - TranslationBase.of(context).feet))), - ), - ), - ), - ], + _commonInputAndUnitRow( + TranslationBase.of(context).height, + _heightController, + 1, + 270, + _heightValue, + (text) { + _heightController.text = text; + }, + (value) { + _heightValue = value; + }, + _isHeightCM ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, + (value) { + if (_isHeightCM != value) { + setState(() { + _isHeightCM = value; + }); + } + }, + _heightPopupList, ), SizedBox( - height: 8.0, + height: 12.0, ), - Texts( + _commonInputAndUnitRow( TranslationBase.of(context).weight, + _weightController, + 1, + 270, + _weightValue, + (text) { + _weightController.text = text; + }, + (value) { + _weightValue = value; + }, + _isWeightKG ? TranslationBase.of(context).kg : TranslationBase.of(context).pound, + (value) { + if (_isWeightKG != value) { + setState(() { + _isWeightKG = value; + }); + } + }, + _weightPopupList, ), SizedBox( - height: 5.0, + height: 12.0, ), - Container( - margin: - EdgeInsets.symmetric(horizontal: 4.0, vertical: 12.0), - decoration: BoxDecoration( - color: Colors.white, - ), - child: Row( - children: [ - Padding( - padding: EdgeInsets.symmetric( - vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), - child: Row( - children: [ - Expanded( - child: Center( - child: Text(weight.toString()), - ), + InkWell( + onTap: () { + // dropdownKey.currentState; + openDropdown(clinicDropdownKey); + }, + child: Container( + // width: double.infinity, + // decoration: containerRadius(Colors.white, 12), + // padding: EdgeInsets.only(left: 10, right: 10, top: 12, bottom: 12), + child: Row( + children: [ + Flexible( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).activityLevel, + style: TextStyle( + fontSize: 11, + letterSpacing: -0.44, + fontWeight: FontWeight.w600, ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (weight < 250) weight++; - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (weight > 0) weight--; - }); - }, - ), - ], + ), + Container( + height: 18, + child: DropdownButtonHideUnderline( + child: DropdownButton( + value: dropdownValue, + icon: Icon(Icons.arrow_downward), + iconSize: 0, + elevation: 16, + isExpanded: true, + style: TextStyle(color: Colors.black87), + underline: Container( + height: 2, + color: Colors.black54, + ), + onChanged: (String newValue) { + setState(() { + dropdownValue = newValue; + }); + }, + items: [ + 'Almost Inactive(Little or no exercises)', + 'Lighty Active (1-3) days per week', + 'very Active(6-7) days per week', + 'Super Active(very hard exercises)' + ].map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), ), ), - ], - ), - ), - ), - ), - Expanded( - child: Slider( - value: weight.toDouble(), - min: 0, - max: 250, - onChanged: (double newValue) { - setState(() { - weight = newValue.round(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), - ), - ], - ), - ), - Texts(TranslationBase.of(context).selectUnit), - SizedBox( - height: 5.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Expanded( - child: GestureDetector( - onTap: () { - setState(() { - updateColorWeight(1); - }); - }, - child: Container( - padding: EdgeInsets.all(12), - margin: EdgeInsets.symmetric(horizontal: 8), - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset( - 0, 3), // changes position of shadow ), ], - color: kgCard, - borderRadius: BorderRadius.circular(3.0), - ), - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 0.0, horizontal: 18.0), - child: Center( - child: - Texts(TranslationBase.of(context).kg)), ), ), - ), + Icon(Icons.keyboard_arrow_down), + ], ), - Expanded( - child: GestureDetector( - onTap: () { - setState(() { - updateColorWeight(2); - }); - }, - child: Container( - padding: EdgeInsets.all(12), - margin: EdgeInsets.symmetric(horizontal: 8), - decoration: BoxDecoration( - color: lbCard, - borderRadius: BorderRadius.circular(3.0), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset( - 0, 3), // changes position of shadow - ), - ], - ), - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 16.0), - child: Center( - child: Texts( - TranslationBase.of(context).pound)), - ), - ), - ), - ), - ], - ), - SizedBox( - height: 8.0, - ), - Texts(TranslationBase.of(context).activityLevel), - Container( - child: DropdownButton( - value: dropdownValue, - icon: Icon(Icons.arrow_downward), - iconSize: 24, - elevation: 16, - style: TextStyle(color: Colors.black87), - underline: Container( - height: 2, - color: Colors.black54, - ), - onChanged: (String newValue) { - setState(() { - dropdownValue = newValue; - }); - }, - items: [ - 'Almost Inactive(Little or no exercises)', - 'Lighty Active (1-3) days per week', - 'very Active(6-7) days per week', - 'Super Active(very hard exercises)' - ].map>((String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }).toList(), - ), + ).withBorderedContainer, ), SizedBox( height: 25.0, @@ -686,8 +335,10 @@ class _CalorieCalculatorState extends State { ), Container( margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, child: SecondaryButton( label: TranslationBase.of(context).calculate, + color: CustomColors.accentColor, onTap: () { setState(() { calculateCalories(); @@ -709,4 +360,231 @@ class _CalorieCalculatorState extends State { ), ); } + + void openDropdown(GlobalKey key) { + GestureDetector detector; + void searchForGestureDetector(BuildContext element) { + element.visitChildElements((element) { + if (element.widget != null && element.widget is GestureDetector) { + detector = element.widget; + return false; + } else { + searchForGestureDetector(element); + } + + return true; + }); + } + + searchForGestureDetector(key.currentContext); + assert(detector != null); + + detector.onTap(); + } + + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) { + return Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: InkWell( + onTap: hasSelection ? () {} : null, + child: Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _labelText, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.zero, + keyboardType: TextInputType.number, + controller: _controller, + onChanged: (value) => {}, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + prefixIconConstraints: BoxConstraints(minWidth: 50), + prefixIcon: prefix == null + ? null + : Text( + "+" + prefix, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, + ), + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ], + ), + ), + if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined), + ], + ), + ), + ); + } + + Widget _commonInputAndUnitRow(_title, _controller, double _minValue, double _maxValue, double _valueOrg, Function(String) onTextValueChange, Function(double) onValueChange, String unitTitle, + Function(bool) onUnitTap, _list) { + return Row( + children: [ + Expanded( + flex: 3, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _title, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff2E303A), + letterSpacing: -0.44, + ), + ), + TextField( + controller: _controller, + keyboardType: TextInputType.number, + onChanged: (value) { + double _value = double.parse(value); + if (_value > _maxValue) { + onTextValueChange(_maxValue.toStringAsFixed(0)); + onValueChange(_maxValue); + return; + } else if (_value < _minValue) { + onTextValueChange(_minValue.toStringAsFixed(0)); + onValueChange(_minValue); + return; + } else if (_value >= _minValue && _value <= _maxValue) { + onValueChange(_value); + return; + } + }, + inputFormatters: [ + FilteringTextInputFormatter.allow(RegExp(r'[0-9]')), + ], + style: TextStyle( + color: Color(0xff575757), + letterSpacing: -0.56, + ), + decoration: InputDecoration( + isDense: true, + hintText: "0", + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ], + ), + ), + Container(height: 34, width: 1, color: Color(0xffE0E0E0), margin: EdgeInsets.only(left: 12, right: 12)), + Expanded( + flex: 1, + child: PopupMenuButton( + child: CommonDropDownView(TranslationBase.of(context).unit, unitTitle, null), + onSelected: (value) { + onUnitTap(value); + }, + itemBuilder: (context) => _list), + ) + ], + ).withBorderedContainer; + } +} + +// todo 'sikander' move these to separate file once usability known +class CommonDropDownView extends StatelessWidget { + final String title; + final String value; + final VoidCallback callback; + final IconData iconData; + + CommonDropDownView(this.title, this.value, this.callback, {Key key, this.iconData}) : super(key: key); + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: callback, + child: Row( + children: [ + Expanded( + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text( + title, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff2E303A), + letterSpacing: -0.44, + ), + ), + Text( + value, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + ), + ]), + ), + Icon( + iconData ?? Icons.keyboard_arrow_down_sharp, + color: Color(0xff2E303A), + ) + ], + ), + ); + } } diff --git a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart index 749bf241..dc27e051 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart @@ -1,9 +1,12 @@ import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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'; @@ -24,45 +27,83 @@ class CalorieResultPage extends StatelessWidget { showNewAppBarTitle: true, showNewAppBar: true, body: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Center( - child: CircularPercentIndicator( - radius: 220.0, - lineWidth: 20.0, - percent: ((this.calorie > 3500) ? 100 : this.calorie / 3500), - center: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - calorie.toStringAsFixed(1), - style: TextStyle( - fontSize: 18.0, - fontWeight: FontWeight.bold, + Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Calories", + style: TextStyle( + fontSize: 19, + letterSpacing: -1.34, + fontWeight: FontWeight.bold, + ), + ), + mHeight(20), + Center( + child: CircularPercentIndicator( + radius: 220.0, + lineWidth: 3.0, + percent: ((this.calorie > 3500) ? 100 : this.calorie / 3500), + center: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + calorie.toStringAsFixed(1), + style: TextStyle( + fontSize: 17, + letterSpacing: -1.02, + fontWeight: FontWeight.w600, + ), + ), + SizedBox( + height: 5.0, + ), + Text( + 'Calories', + style: TextStyle( + fontSize: 18, + letterSpacing: -1.08, + fontWeight: FontWeight.w600, + ), + ), + ], ), + progressColor: CustomColors.accentColor, + backgroundColor: Colors.white, ), - SizedBox( - height: 5.0, + ), + mHeight(20), + Text( + 'Daily intake is ${calorie.toStringAsFixed(1)} calories', + style: TextStyle( + fontSize: 14, + letterSpacing: -0.56, + fontWeight: FontWeight.w600, + color: CustomColors.textColor ), - Texts('Calories'), - ], - ), - progressColor: Color(0xff3C3939), - backgroundColor: Colors.white, - ), - ), - Container( - child: Texts('Daily intake is ${calorie.toStringAsFixed(1)} calories'), + ), + ], + ).withBorderedContainer, ), + mFlex(1), Container( - width: 350, - child: Button( + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( label: TranslationBase.of(context).viewDocList, + color: CustomColors.accentColor, onTap: () { getDoctorsList(context); }, ), ), + ], ), ); @@ -121,3 +162,19 @@ class CalorieResultPage extends StatelessWidget { }); } } + +extension BorderedContainer on Widget { + Widget get withBorderedContainer => Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: this, + ); +} From b752b42a34905c405cdd84fd0d4f65a9f35acc3f Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Sun, 7 Nov 2021 17:38:49 +0300 Subject: [PATCH 24/70] Updates & fixes --- .../service/medical/my_balance_service.dart | 2 +- lib/core/viewModels/er/rrt-view-model.dart | 2 +- .../BookAppointment/DentalComplaints.dart | 50 +++++++------------ .../components/SearchByClinic.dart | 4 +- .../AmbulanceRequestIndex.dart | 13 +++-- lib/pages/ErService/OrderLogPage.dart | 15 +++--- lib/pages/ToDoList/payment_method_select.dart | 6 ++- .../medical/balance/advance_payment_page.dart | 8 ++- lib/widgets/hospital_location.dart | 1 + 9 files changed, 47 insertions(+), 54 deletions(-) diff --git a/lib/core/service/medical/my_balance_service.dart b/lib/core/service/medical/my_balance_service.dart index fd6b5180..283eac4b 100644 --- a/lib/core/service/medical/my_balance_service.dart +++ b/lib/core/service/medical/my_balance_service.dart @@ -28,7 +28,7 @@ class MyBalanceService extends BaseService { locator(); MyBalanceService() { - getFamilyFiles(); + // getFamilyFiles(); } getPatientAdvanceBalanceAmount() async { diff --git a/lib/core/viewModels/er/rrt-view-model.dart b/lib/core/viewModels/er/rrt-view-model.dart index 093c29b6..3a5846da 100644 --- a/lib/core/viewModels/er/rrt-view-model.dart +++ b/lib/core/viewModels/er/rrt-view-model.dart @@ -159,7 +159,7 @@ class RRTViewModel extends BaseViewModel { } Future cancelOrderRC(GetCMCAllOrdersResponseModel order, {String reason = ""}) async { - Map body = {"Id": order.iD, "ClickButton": 16}; + Map body = {"Id": order.iD, "ClickButton": 14}; var success = false; await _service.baseAppClient.post(UPDATE_RRT_ORDER_RC, isRCService: true, body: body, onSuccess: (response, statusCode) { success = true; diff --git a/lib/pages/BookAppointment/DentalComplaints.dart b/lib/pages/BookAppointment/DentalComplaints.dart index 342bff21..4fb1b581 100644 --- a/lib/pages/BookAppointment/DentalComplaints.dart +++ b/lib/pages/BookAppointment/DentalComplaints.dart @@ -50,7 +50,7 @@ class _DentalComplaintsState extends State { Widget build(BuildContext context) { return AppScaffold( isShowAppBar: true, - appBarTitle: "Symptoms", + appBarTitle: TranslationBase.of(context).chiefComplaints, showNewAppBar: true, showNewAppBarTitle: true, isShowDecPage: false, @@ -77,13 +77,15 @@ class _DentalComplaintsState extends State { : Container( child: SingleChildScrollView( child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - margin: EdgeInsets.only(top: 10.0), - child: Text(TranslationBase.of(context).dentalProcedureList, textAlign: TextAlign.center, style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold, letterSpacing: 0.5)), + margin: EdgeInsets.only(top: 12.0, left: 12.0, right: 12.0), + child: Text(TranslationBase.of(context).dentalProcedureList, style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, letterSpacing: -0.46)), ), Container( - margin: EdgeInsets.only(top: 20.0), + decoration: cardRadius(10), + margin: EdgeInsets.all(12.0), child: Table( children: getProceduresData(), ), @@ -148,17 +150,14 @@ class _DentalComplaintsState extends State { children: [ Container( child: Container( - child: Center( - child: Text(TranslationBase.of(context).procedureName, style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold, fontSize: 14.0)), - ), + margin: EdgeInsets.all(12.0), + child: Text(TranslationBase.of(context).procedureName, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, letterSpacing: -0.46)), ), ), Container( child: Container( - margin: EdgeInsets.only(bottom: 10.0), - child: Center( - child: Text(TranslationBase.of(context).timeNeeded, style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold, fontSize: 14.0)), - ), + margin: EdgeInsets.all(12.0), + child: Text(TranslationBase.of(context).timeNeeded, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, letterSpacing: -0.46)), ), ), ], @@ -167,18 +166,12 @@ class _DentalComplaintsState extends State { dentalProceduresModel.listIsPatientHasOnGoingEstimation.forEach((procedure) { tableRow.add(TableRow(children: [ Container( - child: Container( - child: Center( - child: Text(procedure.procedureName, textAlign: TextAlign.center, style: TextStyle(color: Colors.black, fontSize: 14.0)), - ), - ), + margin: EdgeInsets.all(12.0), + child: Text(procedure.procedureName, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, letterSpacing: -0.46)), ), Container( - child: Container( - child: Center( - child: Text(procedure.neededTime.toString() + " mins", textAlign: TextAlign.center, style: TextStyle(color: Colors.black, fontSize: 14.0)), - ), - ), + margin: EdgeInsets.all(12.0), + child: Text(procedure.neededTime.toString() + " " + TranslationBase.of(context).minute, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, letterSpacing: -0.46)), ), ])); }); @@ -186,19 +179,12 @@ class _DentalComplaintsState extends State { TableRow( children: [ Container( - child: Container( - child: Center( - child: Text(TranslationBase.of(context).totalTimeNeeded, textAlign: TextAlign.center, style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold, fontSize: 14.0)), - ), - ), + margin: EdgeInsets.all(12.0), + child: Text(TranslationBase.of(context).totalTimeNeeded, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, letterSpacing: -0.46)), ), Container( - child: Container( - margin: EdgeInsets.only(bottom: 10.0), - child: Center( - child: Text(totalAppointmentTime.toString() + " mins", textAlign: TextAlign.center, style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold, fontSize: 14.0)), - ), - ), + margin: EdgeInsets.all(12.0), + child: Text(totalAppointmentTime.toString() + " " + TranslationBase.of(context).minute, style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, letterSpacing: -0.46)), ), ], ), diff --git a/lib/pages/BookAppointment/components/SearchByClinic.dart b/lib/pages/BookAppointment/components/SearchByClinic.dart index 9c28310e..c2f667c2 100644 --- a/lib/pages/BookAppointment/components/SearchByClinic.dart +++ b/lib/pages/BookAppointment/components/SearchByClinic.dart @@ -320,7 +320,7 @@ class _SearchByClinicState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Select Project", + TranslationBase.of(context).selectHospital, style: TextStyle( fontSize: 11, letterSpacing: -0.44, @@ -332,7 +332,7 @@ class _SearchByClinicState extends State { child: DropdownButtonHideUnderline( child: DropdownButton( key: projectDropdownKey, - hint: new Text("Select Project"), + hint: new Text(TranslationBase.of(context).selectHospital), value: projectDropdownValue, iconSize: 0, isExpanded: true, diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart index 806c0738..f9b2b190 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/AmbulanceRequestIndex.dart @@ -67,8 +67,7 @@ class _AmbulanceRequestIndexPageState extends State { if(widget.amRequestViewModel.pendingAmbulanceRequestOrder != null) { int status = order.statusId; - String _statusDisp = order.statusText; - Color _color; + _statusDisp = order.statusText; if (status == 1) { //pending _color = Color(0xffCC9B14); @@ -184,7 +183,7 @@ class _AmbulanceRequestIndexPageState extends State { if (order.statusId == 1 || order.statusId == 2) InkWell( onTap: () { - showConfirmMessage(widget.amRequestViewModel, order.iD); + showConfirmMessage(widget.amRequestViewModel, order.iD, context); }, child: Container( padding: EdgeInsets.symmetric(vertical: 8, horizontal: 14), @@ -374,21 +373,21 @@ class _AmbulanceRequestIndexPageState extends State { ); } - void showConfirmMessage(AmRequestViewModel model, int presOrderID) { + void showConfirmMessage(AmRequestViewModel model, int presOrderID, BuildContext context) { showDialog( context: context, child: ConfirmWithMessageDialog( message: TranslationBase.of(context).cancelOrderMsg, onTap: () { Future.delayed(new Duration(milliseconds: 300)).then((value) async { - GifLoaderDialogUtils.showMyDialog(context); + // GifLoaderDialogUtils.showMyDialog(context); await model.updatePressOrder(presOrderID: presOrderID); if (model.state == ViewState.ErrorLocal) { Utils.showErrorToast(model.error); - GifLoaderDialogUtils.hideDialog(context); + // GifLoaderDialogUtils.hideDialog(context); } else { AppToast.showSuccessToast(message: TranslationBase.of(context).processDoneSuccessfully); - GifLoaderDialogUtils.hideDialog(context); + // GifLoaderDialogUtils.hideDialog(context); } }); }, diff --git a/lib/pages/ErService/OrderLogPage.dart b/lib/pages/ErService/OrderLogPage.dart index 644f3164..fb8de6d9 100644 --- a/lib/pages/ErService/OrderLogPage.dart +++ b/lib/pages/ErService/OrderLogPage.dart @@ -23,21 +23,21 @@ class OrderLogPage extends StatelessWidget { Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); - void showConfirmMessage(AmRequestViewModel model, int presOrderID) { + void showConfirmMessage(AmRequestViewModel model, int presOrderID, BuildContext context) { showDialog( context: context, child: ConfirmWithMessageDialog( message: TranslationBase.of(context).cancelOrderMsg, onTap: () { Future.delayed(new Duration(milliseconds: 300)).then((value) async { - GifLoaderDialogUtils.showMyDialog(context); + // GifLoaderDialogUtils.showMyDialog(context); await model.updatePressOrder(presOrderID: presOrderID); if (model.state == ViewState.ErrorLocal) { Utils.showErrorToast(model.error); - GifLoaderDialogUtils.hideDialog(context); + // GifLoaderDialogUtils.hideDialog(context); } else { AppToast.showSuccessToast(message: TranslationBase.of(context).processDoneSuccessfully); - GifLoaderDialogUtils.hideDialog(context); + // GifLoaderDialogUtils.hideDialog(context); } }); }, @@ -73,6 +73,7 @@ class OrderLogPage extends StatelessWidget { } return Container( + margin: EdgeInsets.only(bottom: 12.0), decoration: BoxDecoration( color: _color, borderRadius: BorderRadius.all( @@ -88,7 +89,7 @@ class OrderLogPage extends StatelessWidget { ), child: Container( margin: EdgeInsets.only(left: projectViewModel.isArabic ? 0 : 6, right: projectViewModel.isArabic ? 6 : 0), - padding: EdgeInsets.symmetric(vertical: 14, horizontal: 12), + padding: EdgeInsets.symmetric(vertical: 13, horizontal: 12), decoration: BoxDecoration( color: Colors.white, border: Border.all(color: Colors.white, width: 1), @@ -150,7 +151,7 @@ class OrderLogPage extends StatelessWidget { ], ), SizedBox( - height: 20.0, + height: 13.0, ), ], ), @@ -163,7 +164,7 @@ class OrderLogPage extends StatelessWidget { if (order.statusId == 1 || order.statusId == 2) InkWell( onTap: () { - showConfirmMessage(amRequestViewModel, order.iD); + showConfirmMessage(amRequestViewModel, order.iD, context); }, child: Container( padding: EdgeInsets.symmetric(vertical: 8, horizontal: 14), diff --git a/lib/pages/ToDoList/payment_method_select.dart b/lib/pages/ToDoList/payment_method_select.dart index 21b08fc3..ea583477 100644 --- a/lib/pages/ToDoList/payment_method_select.dart +++ b/lib/pages/ToDoList/payment_method_select.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; class PaymentMethod extends StatefulWidget { Function onSelectedMethod; @@ -214,8 +215,9 @@ class _PaymentMethodState extends State { Container( height: 60.0, padding: EdgeInsets.all(7.0), - width: 60, - child: Image.asset("assets/images/new/payment/installments.png"), + width: 90, + // child: Image.asset("assets/images/new/payment/installments.png"), + child: SvgPicture.asset("assets/images/new/payment/instalmt.svg"), ), mFlex(1), if (selectedPaymentMethod == "Installment") diff --git a/lib/pages/medical/balance/advance_payment_page.dart b/lib/pages/medical/balance/advance_payment_page.dart index a7f308af..051b9b95 100644 --- a/lib/pages/medical/balance/advance_payment_page.dart +++ b/lib/pages/medical/balance/advance_payment_page.dart @@ -61,7 +61,10 @@ class _AdvancePaymentPageState extends State { @override Widget build(BuildContext context) { return BaseView( - onModelReady: (model) => model.getHospitals(), + onModelReady: (model) { + model.getHospitals(); + model.getFamilyFiles(); + }, builder: (_, model, w) => AppScaffold( isShowAppBar: true, imagesInfo: imagesInfo, @@ -396,7 +399,8 @@ class _AdvancePaymentPageState extends State { void confirmSelectFamilyDialog(List getAllSharedRecordsByStatusList) { if (getAllSharedRecordsByStatusList.isNotEmpty) { List list = [ - for (int i = 0; i < getAllSharedRecordsByStatusList.length; i++) RadioSelectionDialogModel(getAllSharedRecordsByStatusList[i].patientName, i), + for (int i = 0; i < getAllSharedRecordsByStatusList.length; i++) + if (getAllSharedRecordsByStatusList[i].status == 3) RadioSelectionDialogModel(getAllSharedRecordsByStatusList[i].patientName, i), ]; showDialog( context: context, diff --git a/lib/widgets/hospital_location.dart b/lib/widgets/hospital_location.dart index 401d62ef..8ba7b4bd 100644 --- a/lib/widgets/hospital_location.dart +++ b/lib/widgets/hospital_location.dart @@ -90,6 +90,7 @@ class HospitalLocation extends StatelessWidget { Widget contactButton(IconData _iconData, String title, VoidCallback callback) { return SizedBox( height: 32, + width: 100.0, child: FlatButton.icon( color: Color(0xffF5F5F5), shape: StadiumBorder(side: BorderSide(color: Color(0xffF0F0F0), width: 1)), From d5c68c503230f82a3fee9787c94728f73dab83bc Mon Sep 17 00:00:00 2001 From: Haroon Amjad Date: Mon, 8 Nov 2021 01:59:01 +0300 Subject: [PATCH 25/70] Packages & offers design --- .../responses/PackagesResponseModel.dart | 8 +- lib/core/service/client/base_app_client.dart | 1 - .../PackagesOffersServices.dart | 257 +++++--- .../OfferAndPackageDetailPage.dart | 5 +- .../packages_offers/OfferAndPackagesPage.dart | 594 +++++++++--------- .../offers_packages/PackagesOfferCard.dart | 245 ++++---- 6 files changed, 569 insertions(+), 541 deletions(-) diff --git a/lib/core/model/packages_offers/responses/PackagesResponseModel.dart b/lib/core/model/packages_offers/responses/PackagesResponseModel.dart index 7297a20a..8d4f619b 100644 --- a/lib/core/model/packages_offers/responses/PackagesResponseModel.dart +++ b/lib/core/model/packages_offers/responses/PackagesResponseModel.dart @@ -207,12 +207,10 @@ class PackagesResponseModel with JsonConvert { String seName; String getName() { - if(localizedNames.length == 2){ - if(localizedNames.first.languageId == 2) + if (localizedNames.length == 2) { + if (localizedNames.first.languageId == 2) return localizedNames.first.localizedName ?? name; - - else if(localizedNames.first.languageId == 1) - return localizedNames.last.localizedName ?? name; + else if (localizedNames.first.languageId == 1) return localizedNames.last.localizedName ?? name; } return name; } diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 322ec08b..206c45c6 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -514,7 +514,6 @@ class BaseAppClient { simpleGet(String fullUrl, {Function(dynamic response, int statusCode) onSuccess, Function(String error, int statusCode) onFailure, Map queryParams, Map headers}) async { String url = fullUrl; - print("URL Query String: $url"); var haveParams = (queryParams != null); if (haveParams) { diff --git a/lib/core/service/packages_offers/PackagesOffersServices.dart b/lib/core/service/packages_offers/PackagesOffersServices.dart index d05bc274..3b34b957 100644 --- a/lib/core/service/packages_offers/PackagesOffersServices.dart +++ b/lib/core/service/packages_offers/PackagesOffersServices.dart @@ -21,7 +21,8 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:flutter/cupertino.dart'; -var packagesAuthHeader = {'Authorization' : ''}; +var packagesAuthHeader = {'Authorization': ''}; + class OffersAndPackagesServices extends BaseService { AuthenticatedUser patientUser; List categoryList = List(); @@ -33,52 +34,62 @@ class OffersAndPackagesServices extends BaseService { List cartItemList = List(); String cartItemCount = ""; - PackagesCustomerResponseModel customer; - Future> getAllCategories(OffersCategoriesRequestModel request) async { + Future> getAllCategories( + OffersCategoriesRequestModel request) async { Future errorThrow; var url = EXA_CART_API_BASE_URL + PACKAGES_CATEGORIES; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, + onSuccess: (dynamic stringResponse, int statusCode) { if (statusCode == 200) { var jsonResponse = json.decode(stringResponse); jsonResponse['categories'].forEach((json) { categoryList.add(PackagesCategoriesResponseModel().fromJson(json)); }); } - }, onFailure: (String error, int statusCode) { - }, queryParams: request.toFlatMap()); + }, + onFailure: (String error, int statusCode) {}, + queryParams: request.toFlatMap()); return categoryList; } - Future> getAllProducts({@required OffersProductsRequestModel request, @required BuildContext context, @required bool showLoading = true}) async { + Future> getAllProducts( + {@required OffersProductsRequestModel request, + @required BuildContext context, + @required bool showLoading = true}) async { Future errorThrow; request.sinceId = (productList.isNotEmpty) ? productList.last.id : 0; - + productList = List(); var url = EXA_CART_API_BASE_URL + PACKAGES_PRODUCTS; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, + onSuccess: (dynamic stringResponse, int statusCode) { if (statusCode == 200) { var jsonResponse = json.decode(stringResponse); jsonResponse['products'].forEach((json) { productList.add(PackagesResponseModel().fromJson(json)); }); } - }, onFailure: (String error, int statusCode) { - }, queryParams: request.toFlatMap()); + }, + onFailure: (String error, int statusCode) {}, + queryParams: request.toFlatMap()); return productList; } - Future> getTamaraOptions({@required BuildContext context, @required bool showLoading = true}) async { - if(tamaraPaymentOptions != null && tamaraPaymentOptions.isNotEmpty) + Future> getTamaraOptions( + {@required BuildContext context, + @required bool showLoading = true}) async { + if (tamaraPaymentOptions != null && tamaraPaymentOptions.isNotEmpty) return tamaraPaymentOptions; var url = EXA_CART_API_BASE_URL + PACKAGES_TAMARA_OPT; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, + onSuccess: (dynamic stringResponse, int statusCode) { if (statusCode == 200) { var jsonResponse = json.decode(stringResponse); jsonResponse['payment_option'].forEach((json) { @@ -92,10 +103,13 @@ class OffersAndPackagesServices extends BaseService { return tamaraPaymentOptions; } - Future> getLatestOffers({@required OffersProductsRequestModel request, @required BuildContext context, @required bool showLoading = true}) async { - + Future> getLatestOffers( + {@required OffersProductsRequestModel request, + @required BuildContext context, + @required bool showLoading = true}) async { var url = EXA_CART_API_BASE_URL + PACKAGES_PRODUCTS; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, + onSuccess: (dynamic stringResponse, int statusCode) { if (statusCode == 200) { var jsonResponse = json.decode(stringResponse); jsonResponse['products'].forEach((json) { @@ -109,10 +123,14 @@ class OffersAndPackagesServices extends BaseService { return latestOffersList; } - Future> getBestSellers({@required OffersProductsRequestModel request, @required BuildContext context, @required bool showLoading = true}) async { - + Future> getBestSellers( + {@required OffersProductsRequestModel request, + @required BuildContext context, + @required bool showLoading = true}) async { var url = EXA_CART_API_BASE_URL + PACKAGES_PRODUCTS; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, + onSuccess: (dynamic stringResponse, int statusCode) { + bestSellerList.clear(); if (statusCode == 200) { var jsonResponse = json.decode(stringResponse); jsonResponse['products'].forEach((json) { @@ -126,10 +144,13 @@ class OffersAndPackagesServices extends BaseService { return bestSellerList; } - - Future> getBanners({@required OffersProductsRequestModel request, @required BuildContext context, @required bool showLoading = true}) async { + Future> getBanners( + {@required OffersProductsRequestModel request, + @required BuildContext context, + @required bool showLoading = true}) async { var url = EXA_CART_API_BASE_URL + PACKAGES_PRODUCTS; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, + onSuccess: (dynamic stringResponse, int statusCode) { if (statusCode == 200) { var jsonResponse = json.decode(stringResponse); jsonResponse['products'].forEach((json) { @@ -143,15 +164,16 @@ class OffersAndPackagesServices extends BaseService { return bannersList; } - Future loadOffersPackagesDataForMainPage({@required BuildContext context, bool showLoading = true, Function completion }) async { + Future loadOffersPackagesDataForMainPage( + {@required BuildContext context, + bool showLoading = true, + Function completion}) async { var finished = 0; - var totalCalls = 3; - - - completedAll(){ + var totalCalls = 2; + completedAll() { finished++; - if(completion != null && finished == totalCalls) { + if (completion != null && finished == totalCalls) { _hideLoading(context, showLoading); completion(); } @@ -160,57 +182,71 @@ class OffersAndPackagesServices extends BaseService { _showLoading(context, showLoading); final auth_token = await baseAppClient.generatePackagesToken(); - if(auth_token == null){ + if (auth_token == null) { throw 'Something went wrong while authentication, Please try again letter'; } packagesAuthHeader["Authorization"] = 'Bearer $auth_token'; - // Check and Create Customer - if(patientUser != null){ - customer = await getCurrentCustomer(context: context, showLoading: showLoading); - if(customer == null){ - createCustomer(PackagesCustomerRequestModel.fromUser(patientUser), context: context); + if (patientUser != null) { + customer = + await getCurrentCustomer(context: context, showLoading: showLoading); + if (customer == null) { + createCustomer(PackagesCustomerRequestModel.fromUser(patientUser), + context: context); } } // Performing Parallel Request on same time // # 1 - getBestSellers(request: OffersProductsRequestModel(), context: context, showLoading: false).then((value){ - completedAll(); + getBestSellers( + request: OffersProductsRequestModel(), + context: context, + showLoading: false) + .then((value) { + completedAll(); }); // # 2 - getLatestOffers(request: OffersProductsRequestModel(), context: context, showLoading: false).then((value){ + getLatestOffers( + request: OffersProductsRequestModel(), + context: context, + showLoading: false) + .then((value) { completedAll(); }); // # 3 - getBanners(request: OffersProductsRequestModel(), context: context, showLoading: false).then((value){ - completedAll(); - }); - + // getBanners( + // request: OffersProductsRequestModel(), + // context: context, + // showLoading: false) + // .then((value) { + // completedAll(); + // }); } // -------------------- // Create Customer // -------------------- - Future createCustomer(PackagesCustomerRequestModel request, {@required BuildContext context, bool showLoading = true, Function(bool) completion }) async{ - if(customer != null) - return Future.value(customer); + Future createCustomer(PackagesCustomerRequestModel request, + {@required BuildContext context, + bool showLoading = true, + Function(bool) completion}) async { + if (customer != null) return Future.value(customer); customer = null; Future errorThrow; _showLoading(context, showLoading); var url = EXA_CART_API_BASE_URL + PACKAGES_CUSTOMER; - await baseAppClient.simplePost(url, headers: packagesAuthHeader, body: request.json(), onSuccess: (dynamic stringResponse, int statusCode){ - + await baseAppClient + .simplePost(url, headers: packagesAuthHeader, body: request.json(), + onSuccess: (dynamic stringResponse, int statusCode) { var jsonResponse = json.decode(stringResponse); var customerJson = jsonResponse['customers'].first; customer = PackagesCustomerResponseModel.fromJson(customerJson); - - }, onFailure: (String error, int statusCode){ + }, onFailure: (String error, int statusCode) { errorThrow = Future.error(error); log(error); }); @@ -221,55 +257,60 @@ class OffersAndPackagesServices extends BaseService { return errorThrow ?? customer; } - Future getCurrentCustomer({@required BuildContext context, bool showLoading = true}) async{ - if(customer != null) - return Future.value(customer); + Future getCurrentCustomer( + {@required BuildContext context, bool showLoading = true}) async { + if (customer != null) return Future.value(customer); _showLoading(context, showLoading); - var url = EXA_CART_API_BASE_URL + PACKAGES_CUSTOMER + "/username/${patientUser.patientID}"; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode){ + var url = EXA_CART_API_BASE_URL + + PACKAGES_CUSTOMER + + "/username/${patientUser.patientID}"; + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, + onSuccess: (dynamic stringResponse, int statusCode) { var jsonResponse = json.decode(stringResponse); var customerJson = jsonResponse['customers'].first; customer = PackagesCustomerResponseModel.fromJson(customerJson); - - }, onFailure: (String error, int statusCode){ + }, onFailure: (String error, int statusCode) { log(error); }); _hideLoading(context, showLoading); - return customer; + return customer; } - - // -------------------- // Shopping Cart // -------------------- - Future> cartItems({@required BuildContext context, bool showLoading = true}) async{ + Future> cartItems( + {@required BuildContext context, bool showLoading = true}) async { Future errorThrow; cartItemList.clear(); _showLoading(context, showLoading); - var url = EXA_CART_API_BASE_URL + PACKAGES_SHOPPING_CART + '/${customer.id}'; - Map jsonResponse; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { + var url = + EXA_CART_API_BASE_URL + PACKAGES_SHOPPING_CART + '/${customer.id}'; + Map jsonResponse; + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, + onSuccess: (dynamic stringResponse, int statusCode) { _hideLoading(context, showLoading); jsonResponse = json.decode(stringResponse); jsonResponse['shopping_carts'].forEach((json) { cartItemList.add(PackagesCartItemsResponseModel.fromJson(json)); }); - }, onFailure: (String error, int statusCode) { _hideLoading(context, showLoading); log(error); - errorThrow = Future.error({"error":error, "statusCode":statusCode}); + errorThrow = Future.error({"error": error, "statusCode": statusCode}); }, queryParams: null); return errorThrow ?? jsonResponse; } - Future> addProductToCart(AddProductToCartRequestModel request, {@required BuildContext context, bool showLoading = true}) async{ + Future> addProductToCart( + AddProductToCartRequestModel request, + {@required BuildContext context, + bool showLoading = true}) async { Future errorThrow; ResponseModel response; @@ -277,55 +318,64 @@ class OffersAndPackagesServices extends BaseService { _showLoading(context, showLoading); var url = EXA_CART_API_BASE_URL + PACKAGES_SHOPPING_CART; - await baseAppClient.simplePost(url, headers: packagesAuthHeader, body: request.json(), onSuccess: (dynamic stringResponse, int statusCode){ + await baseAppClient + .simplePost(url, headers: packagesAuthHeader, body: request.json(), + onSuccess: (dynamic stringResponse, int statusCode) { _hideLoading(context, showLoading); var jsonResponse = json.decode(stringResponse); var jsonCartItem = jsonResponse["shopping_carts"][0]; - response = ResponseModel(status: true, data: PackagesCartItemsResponseModel.fromJson(jsonCartItem), error: null); + response = ResponseModel( + status: true, + data: PackagesCartItemsResponseModel.fromJson(jsonCartItem), + error: null); cartItemCount = (jsonResponse['count'] ?? 0).toString(); - - }, onFailure: (String error, int statusCode){ + }, onFailure: (String error, int statusCode) { _hideLoading(context, showLoading); - errorThrow = Future.error(ResponseModel(status: true, data: null, error: error)); + errorThrow = + Future.error(ResponseModel(status: true, data: null, error: error)); }); return errorThrow ?? response; } - Future updateProductToCart(int cartItemID, {UpdateProductToCartRequestModel request, @required BuildContext context, bool showLoading = true}) async{ + Future updateProductToCart(int cartItemID, + {UpdateProductToCartRequestModel request, + @required BuildContext context, + bool showLoading = true}) async { Future errorThrow; _showLoading(context, showLoading); var url = EXA_CART_API_BASE_URL + PACKAGES_SHOPPING_CART + '/$cartItemID'; - await baseAppClient.simplePut(url, headers: packagesAuthHeader, body: request.json(), onSuccess: (dynamic stringResponse, int statusCode){ + await baseAppClient + .simplePut(url, headers: packagesAuthHeader, body: request.json(), + onSuccess: (dynamic stringResponse, int statusCode) { _hideLoading(context, showLoading); var jsonResponse = json.decode(stringResponse); - - }, onFailure: (String error, int statusCode){ + }, onFailure: (String error, int statusCode) { _hideLoading(context, showLoading); log(error); - errorThrow = Future.error({"error":error, "statusCode":statusCode}); + errorThrow = Future.error({"error": error, "statusCode": statusCode}); }); return errorThrow ?? bannersList; } - - Future deleteProductFromCart(int cartItemID, {@required BuildContext context, bool showLoading = true}) async{ + Future deleteProductFromCart(int cartItemID, + {@required BuildContext context, bool showLoading = true}) async { Future errorThrow; _showLoading(context, showLoading); var url = EXA_CART_API_BASE_URL + PACKAGES_SHOPPING_CART + '/$cartItemID'; - await baseAppClient.simpleDelete(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode){ + await baseAppClient.simpleDelete(url, headers: packagesAuthHeader, + onSuccess: (dynamic stringResponse, int statusCode) { _hideLoading(context, showLoading); // var jsonResponse = json.decode(stringResponse); - - }, onFailure: (String error, int statusCode){ + }, onFailure: (String error, int statusCode) { _hideLoading(context, showLoading); log(error); - errorThrow = Future.error({"error":error, "statusCode":statusCode}); + errorThrow = Future.error({"error": error, "statusCode": statusCode}); }); return errorThrow ?? true; @@ -334,29 +384,33 @@ class OffersAndPackagesServices extends BaseService { // -------------------- // Place Order // -------------------- - Future placeOrder({@required Map paymentParams, @required BuildContext context, bool showLoading = true}) async{ + Future placeOrder( + {@required Map paymentParams, + @required BuildContext context, + bool showLoading = true}) async { Future errorThrow; - Map jsonBody = { - "customer_id" : customer.id, + Map jsonBody = { + "customer_id": customer.id, "billing_address": { "email": patientUser.emailAddress, "phone_number": patientUser.mobileNumber }, }; jsonBody.addAll(paymentParams); - jsonBody = {'order' : jsonBody}; + jsonBody = {'order': jsonBody}; int order_id; _showLoading(context, showLoading); var url = EXA_CART_API_BASE_URL + PACKAGES_ORDERS; - await baseAppClient.simplePost(url, headers: packagesAuthHeader, body: jsonBody, onSuccess: (dynamic stringResponse, int statusCode){ + await baseAppClient.simplePost(url, + headers: packagesAuthHeader, + body: jsonBody, onSuccess: (dynamic stringResponse, int statusCode) { _hideLoading(context, showLoading); var jsonResponse = json.decode(stringResponse); order_id = jsonResponse['orders'][0]['id']; - - }, onFailure: (String error, int statusCode){ + }, onFailure: (String error, int statusCode) { _hideLoading(context, showLoading); log(error); errorThrow = Future.error(error); @@ -365,35 +419,34 @@ class OffersAndPackagesServices extends BaseService { return errorThrow ?? order_id; } - Future> getOrderById(int id, {@required BuildContext context, bool showLoading = true}) async{ + Future> getOrderById(int id, + {@required BuildContext context, bool showLoading = true}) async { Future errorThrow; ResponseModel response; _showLoading(context, showLoading); var url = EXA_CART_API_BASE_URL + PACKAGES_ORDERS + '/$id'; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, + onSuccess: (dynamic stringResponse, int statusCode) { _hideLoading(context, showLoading); var jsonResponse = json.decode(stringResponse); var jsonOrder = jsonResponse['orders'][0]; - response = ResponseModel(status: true, data: PackagesOrderResponseModel.fromJson(jsonOrder)); - + response = ResponseModel( + status: true, data: PackagesOrderResponseModel.fromJson(jsonOrder)); }, onFailure: (String error, int statusCode) { _hideLoading(context, showLoading); - errorThrow = Future.error(ResponseModel(status: false,error: error)); + errorThrow = Future.error(ResponseModel(status: false, error: error)); }, queryParams: null); return errorThrow ?? response; } - } -_showLoading(BuildContext context, bool flag){ - if(flag) - GifLoaderDialogUtils.showMyDialog(context); +_showLoading(BuildContext context, bool flag) { + if (flag) GifLoaderDialogUtils.showMyDialog(context); } -_hideLoading(BuildContext context, bool flag){ - if(flag) - GifLoaderDialogUtils.hideDialog(context); -} \ No newline at end of file +_hideLoading(BuildContext context, bool flag) { + if (flag) GifLoaderDialogUtils.hideDialog(context); +} diff --git a/lib/pages/packages_offers/OfferAndPackageDetailPage.dart b/lib/pages/packages_offers/OfferAndPackageDetailPage.dart index f2ff8f6c..24e75797 100644 --- a/lib/pages/packages_offers/OfferAndPackageDetailPage.dart +++ b/lib/pages/packages_offers/OfferAndPackageDetailPage.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesResponseModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/packages_offers/PackagesOffersViewModel.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/ProductCheckTypeWidget.dart'; @@ -10,9 +11,9 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class OfferAndPackagesDetail extends StatefulWidget{ - final dynamic model; + final PackagesResponseModel itemModel; - const OfferAndPackagesDetail({@required this.model, Key key}) : super(key: key); + const OfferAndPackagesDetail({@required this.itemModel, Key key}) : super(key: key); @override State createState() => OfferAndPackagesDetailState(); diff --git a/lib/pages/packages_offers/OfferAndPackagesPage.dart b/lib/pages/packages_offers/OfferAndPackagesPage.dart index 056e23e1..063cc541 100644 --- a/lib/pages/packages_offers/OfferAndPackagesPage.dart +++ b/lib/pages/packages_offers/OfferAndPackagesPage.dart @@ -1,13 +1,13 @@ -import 'package:after_layout/after_layout.dart'; -import 'package:carousel_slider/carousel_slider.dart'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart'; import 'package:diplomaticquarterapp/core/model/packages_offers/requests/AddProductToCartRequestModel.dart'; import 'package:diplomaticquarterapp/core/model/packages_offers/requests/OffersCategoriesRequestModel.dart'; import 'package:diplomaticquarterapp/core/model/packages_offers/requests/OffersProductsRequestModel.dart'; +import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesCategoriesResponseModel.dart'; import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesResponseModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/packages_offers/PackagesOffersViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; @@ -17,229 +17,261 @@ import 'package:diplomaticquarterapp/pages/packages_offers/OfferAndPackageDetail import 'package:diplomaticquarterapp/pages/packages_offers/OfferAndPackagesCartPage.dart'; import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart' as auth; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart' as utils; -import 'package:diplomaticquarterapp/widgets/carousel_indicator/carousel_indicator.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/offers_packages/PackagesOfferCard.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; -import 'package:flutter_material_pickers/flutter_material_pickers.dart'; - -dynamic languageID; +import 'package:provider/provider.dart'; class PackagesHomePage extends StatefulWidget { final AuthenticatedUser user; + PackagesHomePage(this.user); @override _PackagesHomePageState createState() => _PackagesHomePageState(); - } -class _PackagesHomePageState extends State with AfterLayoutMixin{ - getLanguageID() async { - languageID = await sharedPref.getString(APP_LANGUAGE); - } +class _PackagesHomePageState extends State { + ProjectViewModel projectViewModel; @override void initState() { super.initState(); - getLanguageID(); - } - - @override - void afterFirstLayout(BuildContext context) async{ - viewModel.service.patientUser = widget.user; - viewModel.service.loadOffersPackagesDataForMainPage(context: context, completion: (){ - setState((){}); + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + viewModel.service.loadOffersPackagesDataForMainPage( + context: context, + completion: () { + setState(() {}); + }); }); } // Controllers var _searchTextController = TextEditingController(); - var _filterTextController = TextEditingController(); - var _carouselController = CarouselController(); - - - int carouselIndicatorIndex = 0; - CarouselSlider _bannerCarousel; - TextField _textFieldSearch; - TextField _textFieldFilterSelection; ListView _listViewLatestOffers; ListView _listViewBestSeller; PackagesViewModel viewModel; - onCartClick(){ - if (viewModel.service.customer == null){ + onCartClick() { + if (viewModel.service.customer == null) { utils.Utils.showErrorToast("Cart is empty for your current session"); return; } - Navigator.of(context).push( - MaterialPageRoute( - builder: (BuildContext context) => PackagesCartPage() - ) - ); + Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) => PackagesCartPage())); } onProductCartClick(PackagesResponseModel product) async { - if(viewModel.service.customer == null) { + if (viewModel.service.customer == null) { // viewModel.service.customer = await CreateCustomerDialogPage(context: context).show(); loginCheck(context); } - - if(viewModel.service.customer != null) { + + 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); - }).catchError((error) { + await viewModel.service.addProductToCart(request, context: context).then((response) {}).catchError((error) { utils.Utils.showErrorToast(error.toString()); }); } } AppScaffold appScaffold; + PackagesCategoriesResponseModel selectedClinic; + @override Widget build(BuildContext context) { + projectViewModel = Provider.of(context); return BaseView( - allowAny: true, - onModelReady: (model) => viewModel = model, - builder: (_, model, wi){ - return - appScaffold = - AppScaffold( - description: TranslationBase.of(context).offerAndPackagesDetails, - imagesInfo: [ImagesInfo(imageAr: 'https://hmgwebservices.com/Images/MobileApp/CMC/ar/0.png', imageEn: 'https://hmgwebservices.com/Images/MobileApp/CMC/en/0.png')], - appBarTitle: TranslationBase.of(context).offerAndPackages, - isShowAppBar: true, - isPharmacy: false, - showPharmacyCart: false, - showHomeAppBarIcon: false, - isOfferPackages: true, - showOfferPackagesCart: true, - isShowDecPage: false, - body: ListView( + allowAny: true, + onModelReady: (model) => viewModel = model, + builder: (_, model, wi) { + return appScaffold = AppScaffold( + description: TranslationBase.of(context).offerAndPackagesDetails, + imagesInfo: [ImagesInfo(imageAr: 'https://hmgwebservices.com/Images/MobileApp/CMC/ar/0.png', imageEn: 'https://hmgwebservices.com/Images/MobileApp/CMC/en/0.png')], + appBarTitle: TranslationBase.of(context).offerAndPackages, + isShowAppBar: true, + isPharmacy: false, + showPharmacyCart: false, + isOfferPackages: true, + showOfferPackagesCart: false, + isShowDecPage: false, + showNewAppBar: true, + showNewAppBarTitle: true, + body: SingleChildScrollView( + child: Column( + children: [ + SizedBox( + height: 10, + ), + Padding( + padding: const EdgeInsets.all(21), + child: Column( children: [ - - // Top Banner Carousel - AspectRatio( - aspectRatio: 2.2/1, - child: bannerCarousel() + inputWidget(TranslationBase.of(context).search, "", _searchTextController, isInputTypeNum: false), + SizedBox( + height: 10, ), - - Center( - child: CarouselIndicator( - activeColor: Theme.of(context).appBarTheme.color, - color: Colors.grey[300], - cornerRadius: 15, - width: 15, height: 15, - count: _bannerCarousel.itemCount, - index: carouselIndicatorIndex, - onClick: (index){ - debugPrint('onClick at ${index}'); + InkWell( + onTap: () => showClinicSelectionList(), + child: Container( + padding: EdgeInsets.all(12), + width: double.infinity, + height: 65, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + color: Colors.white), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + selectedClinic != null ? selectedClinic.name : "Browse offers by clinic", + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + letterSpacing: -0.46, + ), + ), + Icon(Icons.arrow_drop_down), + ], + ), + ), + ), + SizedBox( + height: 20, + ), + Container( + width: double.infinity, + height: MediaQuery.of(context).size.width * 0.8, + child: ListView.separated( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + itemCount: viewModel.bestSellerList.length, + separatorBuilder: (context, index) { + return mWidth(9.0); + }, + itemBuilder: (BuildContext context, int index) { + return PackagesItemCard( + itemModel: viewModel.bestSellerList[index], + onCartClick: onProductCartClick, + ); }, ), ), - - SizedBox(height: 10,), - - Padding( - padding: const EdgeInsets.all(15), - child: Column( - children: [ - // Search Textfield - searchTextField(), - - SizedBox(height: 10,), - - // Filter Selection - filterOptionSelection(), - - SizedBox(height: 20,), - - // Horizontal Scrollable Cards - Texts( - "Latest offers", - fontWeight: FontWeight.bold, - color: Colors.black87, - fontSize: 20 - ), - - // Latest Offers Horizontal Scrollable List - AspectRatio( - aspectRatio: 1.3/1, - child: LayoutBuilder(builder: (context, constraints){ - double itemContentPadding = 10; - double itemWidth = (constraints.maxWidth/2) - (itemContentPadding*2); - return latestOfferListView(itemWidth: itemWidth, itemContentPadding: itemContentPadding); - }), - ), - - SizedBox(height: 10,), - - Texts( - "Best sellers", - fontWeight: FontWeight.bold, - color: Colors.black87, - fontSize: 20 - ), - - - // Best Seller Horizontal Scrollable List - AspectRatio( - aspectRatio: 1.3/1, - child: LayoutBuilder(builder: (context, constraints){ - double itemContentPadding = 10; // 10 is content padding in each item - double itemWidth = (constraints.maxWidth/2) - (itemContentPadding*2 /* 2 = LeftRight */); - return bestSellerListView(itemWidth: itemWidth, itemContentPadding: itemContentPadding); - }), - ) - - ],), + SizedBox( + height: 21, + ), + // // Best Seller Horizontal Scrollable List + Container( + width: double.infinity, + height: MediaQuery.of(context).size.width * 0.8, + child: ListView.separated( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + itemCount: viewModel.latestOffersList.length, + separatorBuilder: (context, index) { + return mWidth(9.0); + }, + itemBuilder: (BuildContext context, int index) { + return PackagesItemCard( + itemModel: viewModel.latestOffersList[index], + onCartClick: onProductCartClick, + ); + }, + ), ), ], ), + ), + SizedBox( + height: 50.0, ) - .setOnAppBarCartClick(onCartClick); - } + ], + ), + ), + bottomSheet: Container( + color: Colors.white, + padding: const EdgeInsets.all(12.0), + child: SizedBox( + height: 43, + width: double.infinity, + child: FlatButton( + onPressed: () { + onCartClick(); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(left: 8.0, right: 8.0), + child: Icon( + Icons.add_shopping_cart_rounded, + size: 30.0, + color: Colors.white, + ), + ), + Container( + child: Text( + TranslationBase.of(context).shoppingCart, + textAlign: TextAlign.center, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.48), + ), + ), + ], + ), + color: const Color(0xffD02127), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(6), + ), + ), + ), + ), + ); + }, ); } - - - showClinicSelectionList() async { var clinics = viewModel.service.categoryList; - if(clinics.isEmpty) { + if (clinics.isEmpty) { GifLoaderDialogUtils.showMyDialog(context); clinics = await viewModel.service.getAllCategories(OffersCategoriesRequestModel()); GifLoaderDialogUtils.hideDialog(context); } - List options = clinics.map((e) => e.toString()).toList(); - - showMaterialSelectionPicker( + List list = [ + for (int i = 0; i < clinics.length; i++) RadioSelectionDialogModel(clinics[i].name, i), + ]; + showDialog( context: context, - title: "Select Clinic", - items: options, - selectedItem: options.first, - onChanged: (value) async { - var selectedClinic = clinics.firstWhere((element) => element.toString() == value); - var clinicProducts = await viewModel.service.getAllProducts(request: OffersProductsRequestModel(categoryId: selectedClinic.id), context: context, showLoading: true); - if(clinicProducts.isNotEmpty) - Navigator.of(context).push( - MaterialPageRoute( - builder: (BuildContext context) => ClinicPackagesPage(products: clinicProducts) - ) - ); - else - utils.Utils.showErrorToast("No offers available for this clinic"); - }, + child: RadioSelectionDialog( + listData: list, + selectedIndex: 0, + isScrollable: true, + onValueSelected: (index) async { + selectedClinic = clinics[index]; + var clinicProducts = await viewModel.service.getAllProducts(request: OffersProductsRequestModel(categoryId: selectedClinic.id), context: context, showLoading: true); + if (clinicProducts.isNotEmpty) + Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) => ClinicPackagesPage(products: clinicProducts))); + else + utils.Utils.showErrorToast("No offers available for this clinic"); + setState(() {}); + }, + ), ); } @@ -247,182 +279,46 @@ class _PackagesHomePageState extends State with AfterLayoutMix // Main Widgets of Page //---------------------------------- - CarouselSlider bannerCarousel(){ - _bannerCarousel = CarouselSlider.builder( - carouselController: _carouselController, - itemCount: 10, - itemBuilder: (BuildContext context, int itemIndex) { - return Padding( - padding: const EdgeInsets.only(top: 10, bottom: 10, left: 15, right: 15), - child: FractionallySizedBox( - widthFactor: 1, - heightFactor: 1, - child: utils.applyShadow( - spreadRadius: 1, - blurRadius: 5, - child: InkWell( - child: ClipRRect( - borderRadius: BorderRadius.circular(10), - child: utils.Utils.loadNetworkImage(url: "https://wallpaperaccess.com/full/30103.jpg",) - ), - onTap: (){ - Navigator.of(context).push( - MaterialPageRoute( - builder: (BuildContext context) => OfferAndPackagesDetail(model: "",) - ) - ); - }, - ) - ), - ), + Widget latestOfferListView({@required double itemWidth, @required double itemContentPadding}) { + return _listViewLatestOffers = ListView.separated( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + itemCount: viewModel.bestSellerList.length, + itemBuilder: (BuildContext context, int index) { + return PackagesItemCard( + itemWidth: itemWidth, + itemContentPadding: itemContentPadding, + itemModel: viewModel.bestSellerList[index], + onCartClick: onProductCartClick, ); }, - options: CarouselOptions( - autoPlayInterval: Duration(milliseconds: 3500), - enlargeStrategy: CenterPageEnlargeStrategy.scale, - enlargeCenterPage: true, - autoPlay: false, - autoPlayCurve: Curves.fastOutSlowIn, - enableInfiniteScroll: true, - autoPlayAnimationDuration: Duration(milliseconds: 1500), - viewportFraction: 1, - onPageChanged: (page, reason){ - setState(() { - carouselIndicatorIndex = page; - }); - }, - ), + separatorBuilder: separator, ); - return _bannerCarousel; - } - - TextField searchTextField(){ - return _textFieldSearch = - TextField( - controller: _searchTextController, - decoration: InputDecoration( - contentPadding: EdgeInsets.only(top: 0.0, bottom: 0.0, left: 10, right: 10), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide( width: 0.5, color: Colors.grey), - borderRadius: const BorderRadius.all( - const Radius.circular(10.0), - ), - ), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( width: 1, color: Colors.grey), - borderRadius: const BorderRadius.all( - const Radius.circular(10.0), - ), - ), - filled: true, - fillColor: Colors.white, - hintText: "Search", - hintStyle: TextStyle(color: Colors.grey[350], fontWeight: FontWeight.bold), - suffixIcon: IconButton( - onPressed: (){ - // viewModel.search(text: _searchTextController.text); - }, - icon: Icon(Icons.search_rounded, size: 35,), - ), - ), - ); - } - Widget filterOptionSelection(){ - _textFieldFilterSelection = - TextField( - enabled: false, - controller: _searchTextController, - decoration: InputDecoration( - contentPadding: EdgeInsets.only(top: 0.0, bottom: 0.0, left: 10, right: 10), - border: OutlineInputBorder( - borderSide: BorderSide(color: Colors.grey, width: 1), - borderRadius: const BorderRadius.all( - const Radius.circular(10.0), - ), - ), - disabledBorder: OutlineInputBorder( - borderSide: BorderSide( width: 0.5, color: Colors.grey), - borderRadius: const BorderRadius.all( - const Radius.circular(10.0), - ), - ), - focusedBorder: OutlineInputBorder( - borderRadius: const BorderRadius.all( - const Radius.circular(10.0), - ), - ), - filled: true, - fillColor: Colors.white, - hintText: "Browse offers by Clinic", - hintStyle: TextStyle(color: Colors.grey[350], fontWeight: FontWeight.bold), - suffixIcon: IconButton( - onPressed: (){ - showClinicSelectionList(); - }, - icon: Icon(Icons.keyboard_arrow_down_rounded, size: 35, color: Colors.grey,), - ), - ), + Widget bestSellerListView({@required double itemWidth, @required double itemContentPadding}) { + return _listViewLatestOffers = ListView.separated( + scrollDirection: Axis.horizontal, + itemCount: viewModel.bestSellerList.length, + itemBuilder: (BuildContext context, int index) { + return PackagesItemCard( + itemWidth: itemWidth, + itemContentPadding: itemContentPadding, + itemModel: viewModel.bestSellerList[index], + onCartClick: onProductCartClick, ); - - return InkWell( - child: _textFieldFilterSelection, - onTap: (){ - showClinicSelectionList(); }, + separatorBuilder: separator, ); - } - Widget latestOfferListView({@required double itemWidth, @required double itemContentPadding}){ - return _listViewLatestOffers = - ListView.separated( - scrollDirection: Axis.horizontal, - itemCount: viewModel.bestSellerList.length, - itemBuilder: (BuildContext context, int index) { - return PackagesItemCard(itemWidth: itemWidth, itemContentPadding: itemContentPadding, itemModel: viewModel.bestSellerList[index], onCartClick: onProductCartClick,); - }, - separatorBuilder: separator, - ); - - } - - Widget bestSellerListView({@required double itemWidth, @required double itemContentPadding}){ - return _listViewLatestOffers = - ListView.separated( - scrollDirection: Axis.horizontal, - itemCount: viewModel.bestSellerList.length, - itemBuilder: (BuildContext context, int index) { - return PackagesItemCard(itemWidth: itemWidth, itemContentPadding: itemContentPadding, itemModel: viewModel.bestSellerList[index], onCartClick: onProductCartClick,); - }, - separatorBuilder: separator, - ); - - } - - - Widget separator(BuildContext context, int index){ + Widget separator(BuildContext context, int index) { return Container( width: 1, - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment(-1.0, -2.0), - end: Alignment(1.0, 4.0), - colors: [ - Colors.grey, - Colors.grey[100], - Colors.grey[200], - Colors.grey[300], - Colors.grey[400], - Colors.grey[500] - ] - )), + decoration: BoxDecoration(gradient: LinearGradient(begin: Alignment(-1.0, -2.0), end: Alignment(1.0, 4.0), colors: [Colors.grey, Colors.grey[100], Colors.grey[200], Colors.grey[300], Colors.grey[400], Colors.grey[500]])), ); } - - loginCheck(context) async { var data = await sharedPref.getObject(IMEI_USER_DATA); sharedPref.remove(REGISTER_DATA_FOR_LOGIIN); @@ -449,4 +345,74 @@ class _PackagesHomePageState extends State with AfterLayoutMix }); } } + + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {VoidCallback suffixTap, bool isEnable = true, bool hasSelection = false, int lines, bool isInputTypeNum = false}) { + return Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: InkWell( + onTap: hasSelection ? () {} : null, + child: Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _labelText, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.zero, + keyboardType: isInputTypeNum ? TextInputType.number : TextInputType.text, + controller: _controller, + maxLines: lines, + onChanged: (value) => {setState(() {})}, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ], + ), + ), + Icon(Icons.search_outlined), + ], + ), + ), + ); + } } diff --git a/lib/widgets/offers_packages/PackagesOfferCard.dart b/lib/widgets/offers_packages/PackagesOfferCard.dart index 2242f01d..470550c6 100644 --- a/lib/widgets/offers_packages/PackagesOfferCard.dart +++ b/lib/widgets/offers_packages/PackagesOfferCard.dart @@ -1,10 +1,14 @@ import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesResponseModel.dart'; +import 'package:diplomaticquarterapp/pages/packages_offers/OfferAndPackageDetailPage.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - +import 'package:rating_bar/rating_bar.dart'; bool wide = true; @@ -15,15 +19,7 @@ class PackagesItemCard extends StatefulWidget { final PackagesResponseModel itemModel; final Function(PackagesResponseModel product) onCartClick; - const PackagesItemCard( - { - this.itemWidth, - this.itemHeight, - @required this.itemModel, - @required this.itemContentPadding, - @required this.onCartClick, - Key key}) - : super(key: key); + const PackagesItemCard({this.itemWidth, this.itemHeight, @required this.itemModel, @required this.itemContentPadding, @required this.onCartClick, Key key}) : super(key: key); @override State createState() => PackagesItemCardState(); @@ -35,123 +31,138 @@ class PackagesItemCardState extends State { @override Widget build(BuildContext context) { wide = !wide; - return Directionality( - textDirection: TextDirection.rtl, - child: Stack( - children: [ - Padding( - padding: EdgeInsets.only( - left: widget.itemContentPadding, - right: widget.itemContentPadding, - top: widget.itemContentPadding + 5), - child: Container( - width: widget.itemWidth, - color: Colors.transparent, - child: Stack( + return InkWell( + onTap: () { + Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) => OfferAndPackagesDetail(itemModel: widget.itemModel))); + }, + child: Container( + // width: widget.itemWidth, + // color: Colors.transparent, + decoration: cardRadius(15.0), + width: MediaQuery.of(context).size.width * 0.46, + padding: const EdgeInsets.all(9.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(15.0), + child: Image.network("https://mdlaboratories.com/offersdiscounts/images/thumbs/0000162_dermatology-testing.jpeg", fit: BoxFit.fill, height: 180.0, width: 180.0), + ), + Container(margin: const EdgeInsets.only(top: 8.0), child: Text(widget.itemModel.name, maxLines: 1, style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold, letterSpacing: -0.56))), + Container(width: MediaQuery.of(context).size.width * 0.4, child: Text("Special discount for all HMG Employees and their first…", maxLines: 2, style: TextStyle(fontSize: 10.0, fontWeight: FontWeight.w600, letterSpacing: -0.4, color: CustomColors.textColor), overflow: TextOverflow.clip)), + if (widget.itemModel.hasDiscountsApplied) Container(margin: const EdgeInsets.only(top: 19.0), child: Text(widget.itemModel.oldPrice.toString() + " " + TranslationBase.of(context).sar, style: TextStyle(fontSize: 9.0, fontWeight: FontWeight.w600, letterSpacing: -0.36, decoration: TextDecoration.lineThrough, color: CustomColors.grey2))), + Container( + margin: widget.itemModel.hasDiscountsApplied ? const EdgeInsets.only(top: 0.0) : const EdgeInsets.only(top: 19.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( - mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - AspectRatio( - aspectRatio:1 / 1, - child: applyShadow( - child: ClipRRect( - borderRadius: BorderRadius.circular(10), - child: Utils.loadNetworkImage( - url: imageUrl(), - )), - )), - Texts( - widget.itemModel.getName(), - fontWeight: FontWeight.normal, - color: Colors.black, - fontSize: 15 - ), - Padding( - padding: const EdgeInsets.only(left: 10, right: 10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisSize: MainAxisSize.max, - children: [ - Stack( - children: [ - Texts( - '${widget.itemModel.oldPrice} ${'SAR'}', - fontWeight: FontWeight.normal, - decoration: TextDecoration.lineThrough, - color: Colors.grey, - fontSize: 12 - ), - Padding( - padding: const EdgeInsets.only(top: 8), - child: Texts( - '${widget.itemModel.price} ${'SAR'}', - fontWeight: FontWeight.bold, - color: Colors.green, - fontSize: 18 - ), - ), - Padding( - padding: const EdgeInsets.only(top: 35), - child: StarRating( - size: 15, - totalCount: null, - totalAverage: widget.itemModel.approvedRatingSum.toDouble(), - forceStars: true), - ) - ], - ), - Spacer( - flex: 1, - ), - InkWell( - child: Icon( - Icons.add_shopping_cart_rounded, - size: 30.0, - color: Colors.grey, - ), - onTap: () { - widget.onCartClick(widget.itemModel); - }, - ), - ], - ), + Container(margin: const EdgeInsets.only(top: 0.0), child: Text(widget.itemModel.price.toString().trim() + " " + TranslationBase.of(context).sar, style: TextStyle(fontSize: 12.0, fontWeight: FontWeight.bold, letterSpacing: -0.56))), + RatingBar.readOnly( + initialRating: 4.5, + size: 18.0, + filledColor: Color(0XFFD02127), + emptyColor: Color(0XFFD02127), + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star_border, ), ], ), + InkWell( + child: Icon( + Icons.add_shopping_cart_rounded, + size: 30.0, + color: Colors.black, + ), + onTap: () { + widget.onCartClick(widget.itemModel); + }, + ), ], ), ), - ), - Positioned( - top: 0, - right: 0, - child: Visibility( - visible: false, - child: InkWell( - child: Icon( - Icons.favorite, - size: 40.0, - color: Colors.red, - ), - onTap: () { - - }, - ), - ), - ), - - Positioned( - top: 7, - left: 2, - child: Image.asset( - 'assets/images/discount_${'en'}.png', - height: 60, - width: 60, - ), - ), - ], + ], + ), ), ); + // Stack( + // children: [ + // Column( + // mainAxisSize: MainAxisSize.max, + // children: [ + // AspectRatio( + // aspectRatio:1 / 1, + // child: applyShadow( + // child: ClipRRect( + // borderRadius: BorderRadius.circular(10), + // child: Utils.loadNetworkImage( + // url: imageUrl(), + // )), + // )), + // Texts( + // widget.itemModel.getName(), + // fontWeight: FontWeight.normal, + // color: Colors.black, + // fontSize: 15 + // ), + // Padding( + // padding: const EdgeInsets.only(left: 10, right: 10), + // child: Row( + // crossAxisAlignment: CrossAxisAlignment.end, + // mainAxisSize: MainAxisSize.max, + // children: [ + // Stack( + // children: [ + // Texts( + // '${widget.itemModel.oldPrice} ${'SAR'}', + // fontWeight: FontWeight.normal, + // decoration: TextDecoration.lineThrough, + // color: Colors.grey, + // fontSize: 12 + // ), + // Padding( + // padding: const EdgeInsets.only(top: 8), + // child: Texts( + // '${widget.itemModel.price} ${'SAR'}', + // fontWeight: FontWeight.bold, + // color: Colors.green, + // fontSize: 18 + // ), + // ), + // Padding( + // padding: const EdgeInsets.only(top: 35), + // child: StarRating( + // size: 15, + // totalCount: null, + // totalAverage: widget.itemModel.approvedRatingSum.toDouble(), + // forceStars: true), + // ) + // ], + // ), + // Spacer( + // flex: 1, + // ), + // InkWell( + // child: Icon( + // Icons.add_shopping_cart_rounded, + // size: 30.0, + // color: Colors.grey, + // ), + // onTap: () { + // widget.onCartClick(widget.itemModel); + // }, + // ), + // ], + // ), + // ), + // ], + // ), + // ], + // ), + // ); } } From eb4801c7ee2eea821afef18bf36c64214bb97710 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Mon, 8 Nov 2021 11:16:16 +0300 Subject: [PATCH 26/70] fixed rating issues --- lib/pages/final_products_page.dart | 41 ++++++++++++----- lib/pages/offers_categorise_page.dart | 63 ++++++++++++++++++--------- lib/pages/parent_categorise_page.dart | 41 ++++++++++++----- lib/pages/sub_categorise_page.dart | 41 ++++++++++++----- 4 files changed, 135 insertions(+), 51 deletions(-) diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 5705f726..ea5ee011 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -15,6 +15,7 @@ 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:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; @@ -274,11 +275,21 @@ class _FinalProductsPageState extends State { ), Row( children: [ - StarRating( - totalAverage: model.finalProducts[index].approvedRatingSum > 0 - ? (model.finalProducts[index].approvedRatingSum.toDouble() / model.finalProducts[index].approvedRatingSum.toDouble()).toDouble() - : 0, - forceStars: true), +// StarRating( +// totalAverage: model.finalProducts[index].approvedRatingSum > 0 +// ? (model.finalProducts[index].approvedRatingSum.toDouble() / model.finalProducts[index].approvedRatingSum.toDouble()).toDouble() +// : 0, +// forceStars: true), + RatingBar.readOnly( + initialRating: model.finalProducts[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.finalProducts[index].approvedTotalReviews})", regular: true, @@ -424,11 +435,21 @@ class _FinalProductsPageState extends State { ), Row( children: [ - StarRating( - totalAverage: model.finalProducts[index].approvedRatingSum > 0 - ? (model.finalProducts[index].approvedRatingSum.toDouble() / model.finalProducts[index].approvedRatingSum.toDouble()).toDouble() - : 0, - forceStars: true), +// StarRating( +// totalAverage: model.finalProducts[index].approvedRatingSum > 0 +// ? (model.finalProducts[index].approvedRatingSum.toDouble() / model.finalProducts[index].approvedRatingSum.toDouble()).toDouble() +// : 0, +// forceStars: true), + RatingBar.readOnly( + initialRating: model.finalProducts[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.finalProducts[index].approvedTotalReviews})", regular: true, diff --git a/lib/pages/offers_categorise_page.dart b/lib/pages/offers_categorise_page.dart index 15c3b070..263aef5c 100644 --- a/lib/pages/offers_categorise_page.dart +++ b/lib/pages/offers_categorise_page.dart @@ -7,6 +7,7 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; @@ -428,14 +429,24 @@ class _OffersCategorisePageState extends State { ), Row( children: [ - StarRating( - totalAverage: model.products[index].approvedRatingSum > - 0 - ? (model.products[index].approvedRatingSum.toDouble() / model.products[index].approvedRatingSum.toDouble()) - .toDouble() - : 0, - forceStars: - true), +// StarRating( +// totalAverage: model.products[index].approvedRatingSum > +// 0 +// ? (model.products[index].approvedRatingSum.toDouble() / model.products[index].approvedRatingSum.toDouble()) +// .toDouble() +// : 0, +// forceStars: +// true), + RatingBar.readOnly( + initialRating: model.products[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.products[index].approvedTotalReviews})", regular: true, @@ -663,19 +674,29 @@ class _OffersCategorisePageState extends State { ), Row( children: [ - StarRating( - totalAverage: model - .products[ - index] - .approvedRatingSum > - 0 - ? (model.products[index].approvedRatingSum.toDouble() / - model.products[index].approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: - true), +// StarRating( +// totalAverage: model +// .products[ +// index] +// .approvedRatingSum > +// 0 +// ? (model.products[index].approvedRatingSum.toDouble() / +// model.products[index].approvedRatingSum +// .toDouble()) +// .toDouble() +// : 0, +// forceStars: +// true), + RatingBar.readOnly( + initialRating: model.products[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.products[index].approvedTotalReviews})", regular: true, diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index ec37cff5..d8c2279c 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -22,6 +22,7 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; @@ -714,11 +715,21 @@ 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.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, @@ -838,11 +849,21 @@ 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.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, diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index e5a8b097..9d2a1f6b 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -17,6 +17,7 @@ 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'; import 'package:flutter/material.dart'; +import 'package:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; import 'final_products_page.dart'; @@ -641,11 +642,21 @@ class _SubCategorisePageState extends State { ), Row( children: [ - StarRating( - totalAverage: model.subProducts[index].approvedRatingSum > 0 - ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() - : 0, - forceStars: true), +// StarRating( +// totalAverage: model.subProducts[index].approvedRatingSum > 0 +// ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() +// : 0, +// forceStars: true), + RatingBar.readOnly( + initialRating: model.subProducts[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.subProducts[index].approvedTotalReviews})", regular: true, @@ -766,11 +777,21 @@ class _SubCategorisePageState extends State { ), Row( children: [ - StarRating( - totalAverage: model.subProducts[index].approvedRatingSum > 0 - ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() - : 0, - forceStars: true), +// StarRating( +// totalAverage: model.subProducts[index].approvedRatingSum > 0 +// ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() +// : 0, +// forceStars: true), + RatingBar.readOnly( + initialRating: model.subProducts[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.subProducts[index].approvedTotalReviews})", regular: true, From 6225f2468d8026463f3f812e5a247fb82a636793 Mon Sep 17 00:00:00 2001 From: devmirza121 Date: Mon, 8 Nov 2021 16:05:29 +0300 Subject: [PATCH 27/70] Health Calculator 3.0 --- lib/config/localized_values.dart | 5 + .../bmr_calculator/bmr_calculator.dart | 900 ++++-------- .../bmr_calculator/bmr_result_page.dart | 123 +- .../health_calculator/body_fat/body_fat.dart | 1263 ++++++----------- .../body_fat/body_fat_result_page.dart | 101 +- .../calorie_calculator.dart | 1 + .../health_calculator/carbs/carbs.dart | 498 ++++--- .../carbs/carbs_result_page.dart | 214 ++- .../ideal_body/ideal_body.dart | 859 ++++++----- .../ideal_body/ideal_body_result_page.dart | 292 ++-- lib/uitl/translations_delegate_base.dart | 4 + pubspec.yaml | 1 + 12 files changed, 1811 insertions(+), 2450 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 65b05d37..3985f3fc 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1630,4 +1630,9 @@ const Map localizedValues = { "RRTTitle": {"en": "RRT", "ar": "خدمة فريق"}, "RRTSubTitle": {"en": "Service", "ar": "الاستجابة السريع"}, "transportation": {"en": "Transportation", "ar": "النقل"}, + + "neck": {"en": "Neck", "ar": "رقبه"}, + "waist": {"en": "Waist", "ar": "وسط"}, + "hip": {"en": "Hip", "ar": "ورك او نتوء"}, + "carbsProtin": {"en": "Carbs, Protein and Fat", "ar": "الكربوهيدرات والبروتينات والدهون"}, }; diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart index aea4d3b0..3512b4de 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart @@ -1,4 +1,4 @@ - +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; @@ -8,6 +8,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/services.dart'; +import 'package:provider/provider.dart'; import 'bmr_result_page.dart'; @@ -30,9 +31,23 @@ class _BmrCalculatorState extends State { Color lbCard = inactiveCardColor; Color cmCard = activeCardColor; Color ftCard = inactiveCardColor; - int age = 0; - int height = 0; - int weight = 0; + + final GlobalKey clinicDropdownKey = GlobalKey(); + TextEditingController ageController = new TextEditingController(); + TextEditingController _heightController = new TextEditingController(); + TextEditingController _weightController = TextEditingController(); + + bool _isHeightCM = true; + bool _isWeightKG = true; + double _heightValue = 150; + double _weightValue = 40; + + List _heightPopupList = List(); + List _weightPopupList = List(); + + // int age = 0; + // int height = 0; + // int weight = 0; double bmrResult = 0; String dropdownValue = 'Lighty Active (1-3) days per week'; double calories = 0; @@ -99,10 +114,9 @@ class _BmrCalculatorState extends State { void calculateBmr() { if (isMale == true) { - bmrResult = 66.5 + (13.75 * weight) + (5.003 * height) - (6.755 * age); + bmrResult = 66.5 + (13.75 * int.parse(_weightController.text)) + (5.003 * int.parse(_heightController.text)) - (6.755 * int.parse(ageController.text)); } else if (isMale == false) { - bmrResult = - 655.0955 + (9.5634 * weight) + (1.850 * height) - (4.676 * age); + bmrResult = 655.0955 + (9.5634 * int.parse(_weightController.text)) + (1.850 * int.parse(_heightController.text)) - (4.676 * int.parse(ageController.text)); } bmrResult = bmrResult.roundToDouble(); @@ -124,6 +138,10 @@ class _BmrCalculatorState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + _weightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).kg), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).lb), value: false)]; + _heightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).cm), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).ft), value: false)]; + return AppScaffold( isShowAppBar: true, isShowDecPage: false, @@ -140,639 +158,303 @@ class _BmrCalculatorState extends State { ), ) ], - body: Padding( - padding: EdgeInsets.symmetric(horizontal: 25.0, vertical: 15.0), - child: SingleChildScrollView( - child: Container( - height: 850, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Calculates the amount of energy that the person’s body expends in a day', - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - letterSpacing: -0.56, - color: CustomColors.textColor, - ), - ), - Divider( - thickness: 2.0, - ), - SizedBox( - height: 5.0, - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 20, - ), - Text( - TranslationBase.of(context).selectGender, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - letterSpacing: -0.56, - color: CustomColors.textColor, + body: Container( + height: double.infinity, + width: double.infinity, + child: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(21.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Calculates the amount of energy that the person’s body expends in a day', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, + color: CustomColors.textColor, + ), ), - ), - SizedBox( - height: 8.0, - ), - Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: GestureDetector( - onTap: () { - setState(() { - updateColor(1); - isMale = false; - }); - }, - child: Row( - children: [ - Container( - decoration: containerColorRadiusBorderWidth(Colors.white, 1000, CustomColors.darkGreyColor, 1), - width: 24, - height: 24, - padding: EdgeInsets.all(4), - child: Container( - width: double.infinity, - height: double.infinity, - decoration: containerRadius(!isMale?CustomColors.accentColor:Colors.white, 100), - ), - ), - mWidth(12), - Text(TranslationBase.of(context).female, style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - letterSpacing: -0.56, - ),), - ], - ), - ), + SizedBox( + height: 20, ), - Expanded( - child: GestureDetector( - onTap: () { - setState(() { - updateColor(2); - isMale = true; - }); - }, - child: Row( - children: [ - Container( - decoration: containerColorRadiusBorderWidth(Colors.white, 1000, CustomColors.darkGreyColor, 1), - width: 24, - height: 24, - padding: EdgeInsets.all(4), - child: Container( - width: double.infinity, - height: double.infinity, - decoration: containerRadius(isMale?CustomColors.accentColor:Colors.white, 100), - ), - ), - mWidth(12), - Text(TranslationBase.of(context).male, style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - letterSpacing: -0.56, - ),), - ], - ), + Text( + TranslationBase.of(context).selectGender, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, + color: CustomColors.textColor, ), ), - ], - ), - ), - SizedBox( - height: 5.0, - ), - Texts( - 'The Age ( 11 - 120 ) yrs', - ), - SizedBox( - height: 10.0, - ), - Row( - children: [ - Container( - width: 340.0, - height: 60.0, - decoration: BoxDecoration( - color: Colors.white, + SizedBox( + height: 8.0, ), - child: Row( - children: [ - Padding( - padding: EdgeInsets.symmetric( - vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), + Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Expanded( + child: GestureDetector( + onTap: () { + setState(() { + updateColor(1); + isMale = false; + }); + }, child: Row( - children: [ - Expanded( - child: Center( - child: Text(age.toString()), + children: [ + Container( + decoration: containerColorRadiusBorderWidth(Colors.white, 1000, CustomColors.darkGreyColor, 1), + width: 24, + height: 24, + padding: EdgeInsets.all(4), + child: Container( + width: double.infinity, + height: double.infinity, + decoration: containerRadius(!isMale ? CustomColors.accentColor : Colors.white, 100), ), ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (age < 120) age++; - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (age > 0) age--; - }); - }, - ), - ], + mWidth(12), + Text( + TranslationBase.of(context).female, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, ), ), ], ), ), ), - ), - Expanded( - child: Slider( - value: age.toDouble(), - min: 0, - max: 120, - onChanged: (double newValue) { - setState(() { - age = newValue.round(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), - ), - ], - ), - ), - ], - ), - Texts( - 'Height', - ), - Row( - children: [ - Container( - width: 340.0, - height: 60.0, - decoration: BoxDecoration( - color: Colors.white, - ), - child: Row( - children: [ - Padding( - padding: EdgeInsets.symmetric( - vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), + Expanded( + child: GestureDetector( + onTap: () { + setState(() { + updateColor(2); + isMale = true; + }); + }, child: Row( - children: [ - Expanded( - child: Center( - child: Text(height.toString()), + children: [ + Container( + decoration: containerColorRadiusBorderWidth(Colors.white, 1000, CustomColors.darkGreyColor, 1), + width: 24, + height: 24, + padding: EdgeInsets.all(4), + child: Container( + width: double.infinity, + height: double.infinity, + decoration: containerRadius(isMale ? CustomColors.accentColor : Colors.white, 100), ), ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (height < 250) - height++; - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (height > 0) height--; - }); - }, - ), - ], + mWidth(12), + Text( + TranslationBase.of(context).male, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, ), ), ], ), ), ), - ), - Expanded( - child: Slider( - value: height.toDouble(), - min: 0, - max: 250, - onChanged: (double newValue) { - setState(() { - height = newValue.round(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), - ), - ], - ), - ), - ], - ), - Texts('Select Unit'), - SizedBox( - height: 5.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - GestureDetector( - onTap: () { - setState(() { - updateColorHeight(1); - isHeightCm = true; - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset( - 0, 3), // changes position of shadow - ), ], - color: cmCard, - borderRadius: BorderRadius.circular(3.0), - ), - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 0.0, horizontal: 18.0), - child: Center(child: Texts('CM')), ), ), - ), - GestureDetector( - onTap: () { - setState(() { - updateColorHeight(2); - isHeightCm = false; - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - color: ftCard, - borderRadius: BorderRadius.circular(3.0), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset( - 0, 3), // changes position of shadow - ), - ], - ), - child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 16.0), - child: Center(child: Texts('Ft')), - ), + SizedBox( + height: 12.0, ), - ), - ], - ), - SizedBox( - height: 5.0, - ), - Texts( - 'Weight', - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Container( - width: 340.0, - height: 60.0, - decoration: BoxDecoration( - color: Colors.white, + inputWidget(TranslationBase.of(context).age11_120Years, "0", ageController), + SizedBox( + height: 12.0, ), - child: Row( - children: [ - Padding( - padding: EdgeInsets.symmetric( - vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), - child: Row( - children: [ - Expanded( - child: Center( - child: Text(weight.toString()), + _commonInputAndUnitRow( + TranslationBase.of(context).height, + _heightController, + 1, + 270, + _heightValue, + (text) { + _heightController.text = text; + }, + (value) { + _heightValue = value; + }, + _isHeightCM ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, + (value) { + if (_isHeightCM != value) { + setState(() { + _isHeightCM = value; + }); + } + }, + _heightPopupList, + ), + SizedBox( + height: 12.0, + ), + _commonInputAndUnitRow( + TranslationBase.of(context).weight, + _weightController, + 1, + 270, + _weightValue, + (text) { + _weightController.text = text; + }, + (value) { + _weightValue = value; + }, + _isWeightKG ? TranslationBase.of(context).kg : TranslationBase.of(context).pound, + (value) { + if (_isWeightKG != value) { + setState(() { + _isWeightKG = value; + }); + } + }, + _weightPopupList, + ), + SizedBox( + height: 12.0, + ), + InkWell( + onTap: () { + // dropdownKey.currentState; + openDropdown(clinicDropdownKey); + }, + child: Container( + // width: double.infinity, + // decoration: containerRadius(Colors.white, 12), + // padding: EdgeInsets.only(left: 10, right: 10, top: 12, bottom: 12), + child: Row( + children: [ + Flexible( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).activityLevel, + style: TextStyle( + fontSize: 11, + letterSpacing: -0.44, + fontWeight: FontWeight.w600, ), ), Container( - height: 38.0, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (weight < 250) - weight++; - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (weight > 0) weight--; - }); - }, + height: 18, + child: DropdownButtonHideUnderline( + child: DropdownButton( + value: dropdownValue, + icon: Icon(Icons.arrow_downward), + iconSize: 0, + elevation: 16, + isExpanded: true, + style: TextStyle(color: Colors.black87), + underline: Container( + height: 2, + color: Colors.black54, ), - ], + onChanged: (String newValue) { + setState(() { + dropdownValue = newValue; + }); + }, + items: [ + 'Almost Inactive(Little or no exercises)', + 'Lighty Active (1-3) days per week', + 'very Active(6-7) days per week', + 'Super Active(very hard exercises)' + ].map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + ), ), ), ], ), ), - ), - ), - Expanded( - child: Slider( - value: weight.toDouble(), - min: 0, - max: 250, - onChanged: (double newValue) { - setState(() { - weight = newValue.round(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), + Icon(Icons.keyboard_arrow_down), + ], ), - ], - ), - ), - ], - ), - Texts('Select Unit'), - SizedBox( - height: 5.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - GestureDetector( - onTap: () { - setState(() { - updateColorWeight(1); - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset( - 0, 3), // changes position of shadow - ), - ], - color: kgCard, - borderRadius: BorderRadius.circular(3.0), - ), - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 0.0, horizontal: 18.0), - child: Center(child: Texts('KG')), - ), + ).withBorderedContainer, ), - ), - GestureDetector( - onTap: () { - setState(() { - updateColorWeight(2); - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - color: lbCard, - borderRadius: BorderRadius.circular(3.0), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset( - 0, 3), // changes position of shadow - ), - ], - ), - child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 16.0), - child: Center(child: Texts('LB')), - ), + SizedBox( + height: 25.0, ), - ), - ], - ), - SizedBox( - height: 45.0, - ), - Divider( - thickness: 2.0, - ), - SizedBox( - height: 5.0, - ), - Texts('Activity level'), - Container( - width: 300, - child: DropdownButton( - value: dropdownValue, - icon: Icon(Icons.arrow_downward), - iconSize: 24, - elevation: 16, - style: TextStyle(color: Colors.black87), - underline: Container( - height: 2, - color: Colors.black54, - ), - onChanged: (String newValue) { - setState(() { - dropdownValue = newValue; - }); - }, - items: [ - 'Almost Inactive(Little or no exercises)', - 'Lighty Active (1-3) days per week', - 'very Active(6-7) days per week', - 'Super Active(very hard exercises)' - ].map>((String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }).toList(), - ), - ), - SizedBox( - height: 30.0, - ), - Container( - height: 50.0, - width: 350.0, - child: SecondaryButton( - label: 'CALCULATE', - onTap: () { - setState(() { - calculateBmr(); - calculateCalories(); - - { - Navigator.push( - context, - FadePage( - page: BmrResultPage( - bmrResult: bmrResult, - calories: calories, - )), - ); - } - }); - }, + ], ), - ), - ], + ], + ), ), - ], + ), ), - ), + Container( + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( + label: TranslationBase.of(context).calculate, + color: CustomColors.accentColor, + onTap: () { + setState(() { + calculateBmr(); + calculateCalories(); + + { + Navigator.push( + context, + FadePage( + page: BmrResultPage( + bmrResult: bmrResult, + calories: calories, + )), + ); + } + }); + }, + ), + ), + ], ), ), ); } + + void openDropdown(GlobalKey key) { + GestureDetector detector; + void searchForGestureDetector(BuildContext element) { + element.visitChildElements((element) { + if (element.widget != null && element.widget is GestureDetector) { + detector = element.widget; + return false; + } else { + searchForGestureDetector(element); + } + + return true; + }); + } + + searchForGestureDetector(key.currentContext); + assert(detector != null); + + detector.onTap(); + } + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) { return Container( padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), @@ -830,15 +512,15 @@ class _BmrCalculatorState extends State { prefixIcon: prefix == null ? null : Text( - "+" + prefix, - style: TextStyle( - fontSize: 14, - height: 21 / 14, - fontWeight: FontWeight.w500, - color: Color(0xff2E303A), - letterSpacing: -0.56, - ), - ), + "+" + prefix, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, + ), + ), contentPadding: EdgeInsets.zero, border: InputBorder.none, focusedBorder: InputBorder.none, @@ -980,18 +662,4 @@ class CommonDropDownView extends StatelessWidget { } } -extension BorderedContainer on Widget { - Widget get withBorderedContainer => Container( - padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15), - color: Colors.white, - border: Border.all( - color: Color(0xffefefef), - width: 1, - ), - ), - child: this, - ); -} \ No newline at end of file + diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_result_page.dart index e1409ee5..53426f94 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_result_page.dart @@ -1,9 +1,12 @@ import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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'; @@ -27,50 +30,81 @@ class BmrResultPage extends StatelessWidget { body: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Center( - child: CircularPercentIndicator( - radius: 220.0, - lineWidth: 20.0, - percent: ((this.bmrResult > 3500) ? 100 : this.bmrResult / 3500), - center: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - bmrResult.toStringAsFixed(1), - style: TextStyle( - fontSize: 18.0, - fontWeight: FontWeight.bold, - ), + Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Calories", + style: TextStyle( + fontSize: 19, + letterSpacing: -1.34, + fontWeight: FontWeight.bold, ), - SizedBox( - height: 5.0, + ), + mHeight(20), + Center( + child: CircularPercentIndicator( + radius: 220.0, + lineWidth: 3.0, + percent: ((this.bmrResult > 3500) ? 100 : this.bmrResult / 3500), + center: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + bmrResult.toStringAsFixed(1), + style: TextStyle( + fontSize: 17, + letterSpacing: -1.02, + fontWeight: FontWeight.w600, + ), + ), + SizedBox( + height: 5.0, + ), + Text( + 'Calories', + style: TextStyle( + fontSize: 18, + letterSpacing: -1.08, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + progressColor: CustomColors.accentColor, + backgroundColor: Colors.white, ), - Text( - 'Calories/Day', - style: TextStyle( - fontSize: 16.0, + ), + mHeight(20), + Text( + 'This means the body will burn ( ${bmrResult.toStringAsFixed(1)} ) calories each day, if engaged in no activity for the entire day.. Note: Daily calorie requirement is ( ${calories.toStringAsFixed(1)} ) calories, to maintain the current weight.', + style: TextStyle( + fontSize: 14, + letterSpacing: -0.56, fontWeight: FontWeight.w600, - ), + color: CustomColors.textColor ), - ], - ), - progressColor: Color(0xff3C3939), - ), - ), - Container( - height: 120, - width: 280.0, - child: Texts( - 'This means the body will burn ( ${bmrResult.toStringAsFixed(1)} ) calories each day, if engaged in no activity for the entire day.. Note: Daily calorie requirement is ( ${calories.toStringAsFixed(1)} ) calories, to maintain the current weight.'), + ), + ], + ).withBorderedContainer, ), + mFlex(1), + Container( - width: 350, - child: Button( - label: TranslationBase.of(context).viewDocList, - onTap: () { - getDoctorsList(context); - }), + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( + label: TranslationBase.of(context).viewDocList, + color: CustomColors.accentColor, + onTap: () { + getDoctorsList(context); + }, + ), ), + ], ), ); @@ -129,3 +163,18 @@ class BmrResultPage extends StatelessWidget { }); } } +extension BorderedContainer on Widget { + Widget get withBorderedContainer => Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: this, + ); +} \ No newline at end of file diff --git a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart index 7b32c840..1442afbd 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart @@ -1,11 +1,14 @@ import 'dart:math'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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 'package:flutter/services.dart'; import 'body_fat_result_page.dart'; @@ -20,43 +23,65 @@ class BodyFat extends StatefulWidget { } class _BodyFatState extends State { + + final GlobalKey clinicDropdownKey = GlobalKey(); + bool _isHeightCM = true; + bool _isNeckKG = true; + bool _isWaistKG = true; + bool _isHipKG = true; + double _heightValue = 0; + double _neckValue = 0; + double _waistValue = 0; + double _hipValue = 0; + + + TextEditingController _heightController = new TextEditingController(); + TextEditingController _neckController = TextEditingController(); + TextEditingController _waistController = TextEditingController(); + TextEditingController _hipController = TextEditingController(); + + List _heightPopupList = List(); + List _neckPopupList = List(); + List _waistPopupList = List(); + List _hipPopupList = List(); + + + bool isMale = false; - bool isHeightCm = true; + // bool isHeightCm = true; Color maleCard = activeCardColorGender; Color femaleCard = inactiveCardColorGender; - Color neckCmCard = activeCardColor; - Color neckFtCard = inactiveCardColor; + // Color neckCmCard = activeCardColor; + // Color neckFtCard = inactiveCardColor; Color waistCmCard = activeCardColor; Color waistFtCard = inactiveCardColor; Color hipCmCard = activeCardColor; Color hipFtCard = inactiveCardColor; Color cmCard = activeCardColor; Color ftCard = inactiveCardColor; - int neck = 10; - int heightCm = 0; - int heightFt = 0; - int hip = 5; + // int neck = 10; + // int heightCm = 0; + // int heightFt = 0; + // int hip = 5; double heightInches; double minRange; double maxRange; double overWeightBy; - int waist = 5; + // int waist = 5; double bodyFat = 0; double fat = 0; String dropdownValue; double calories = 0; String textResult = ''; - TextEditingController heightController = TextEditingController(); - TextEditingController neckController = TextEditingController(); - TextEditingController waistController = TextEditingController(); - TextEditingController hipController = TextEditingController(); + + @override void initState() { - neckController.text = neck.toString(); - hipController.text = hip.toString(); - waistController.text = waist.toString(); - heightController.text = heightCm.toString(); + _neckController.text = _neckValue.toString(); + _hipController.text = _hipValue.toString(); + _waistController.text = _waistValue.toString(); + _heightController.text = _heightValue.toString(); super.initState(); } @@ -80,25 +105,7 @@ class _BodyFatState extends State { } } - void updateColorNeck(int type) { - //MG/DLT card - if (type == 1) { - if (neckCmCard == inactiveCardColor) { - neckCmCard = activeCardColor; - neckFtCard = inactiveCardColor; - } else { - neckCmCard = inactiveCardColor; - } - } - if (type == 2) { - if (neckFtCard == inactiveCardColor) { - neckFtCard = activeCardColor; - neckCmCard = inactiveCardColor; - } else { - neckFtCard = inactiveCardColor; - } - } - } + void updateColorWaist(int type) { //MG/DLT card @@ -162,10 +169,10 @@ class _BodyFatState extends State { void calculateBodyFat() { if (isMale == true) { - bodyFat = 495 / (1.0324 - 0.19077 * (log(waist - neck) / ln10) + 0.15456 * (log(heightCm) / ln10)) - 450; + bodyFat = 495 / (1.0324 - 0.19077 * (log(_waistValue - _neckValue) / ln10) + 0.15456 * (log(int.parse(_heightController.text)) / ln10)) - 450; fat = (bodyFat * 10) / 10.round(); } else if (isMale == false) { - bodyFat = 495 / (1.29579 - 0.35004 * (log(waist + hip - neck) / ln10) + 0.22100 * (log(heightCm) / ln10)) - 450; + bodyFat = 495 / (1.29579 - 0.35004 * (log(_waistValue + _hipValue - _neckValue) / ln10) + 0.22100 * (log(int.parse(_heightController.text)) / ln10)) - 450; fat = (bodyFat * 10) / 10.round(); } if (fat <= 0) { @@ -209,6 +216,12 @@ class _BodyFatState extends State { @override Widget build(BuildContext context) { + _neckPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).kg), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).lb), value: false)]; + _heightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).cm), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).ft), value: false)]; + + _waistPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).kg), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).lb), value: false)]; + _hipPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).cm), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).ft), value: false)]; + return AppScaffold( isShowAppBar: true, isShowDecPage: false, @@ -224,815 +237,459 @@ class _BodyFatState extends State { ), ) ], - body: Padding( - padding: EdgeInsets.symmetric(horizontal: 25.0, vertical: 15.0), - child: SingleChildScrollView( - child: Container( - height: 1000.0, - child: Column( - children: [ - Padding( - padding: EdgeInsets.all(10.0), - child: Texts('Estimates the total body fat based on\n the size'), - ), - Divider( - thickness: 2.0, - ), - SizedBox( - height: 5.0, - ), - Column( + body: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Container( + padding: EdgeInsets.all(20), + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts('Gender'), + Text( + 'Estimates the total body fat based on\nthe size', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, + color: CustomColors.textColor, + ), + ), + SizedBox( + height: 20, + ), + Text( + TranslationBase.of(context).selectGender, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, + color: CustomColors.textColor, + ), + ), SizedBox( - height: 5.0, + height: 8.0, ), Container( - width: 350, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(35.0), - color: Colors.white, - border: Border.all( - color: Colors.black45, - )), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - GestureDetector( - onTap: () { - setState(() { - updateColor(1); - isMale = false; - }); - }, - child: Container( - height: 55.0, - width: 170.0, - decoration: BoxDecoration( - color: maleCard, - borderRadius: BorderRadius.circular(35.0), - ), - child: Center(child: Texts('FEMALE')), - ), - ), - GestureDetector( - onTap: () { - setState(() { - updateColor(2); - isMale = true; - }); - }, - child: Container( - height: 55.0, - width: 170.0, - decoration: BoxDecoration( - color: femaleCard, - borderRadius: BorderRadius.circular(35.0), - ), - child: Center(child: Texts('MALE')), - ), - ), - ], - ), - ), - Texts( - 'Height', - ), - Row( - children: [ - Expanded( - child: Container( - width: 340.0, - height: 60.0, - decoration: BoxDecoration( - color: Colors.white, - ), - child: Row( - children: [ - Padding( - padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0), - child: Center( + Expanded( + child: GestureDetector( + onTap: () { + setState(() { + updateColor(1); + isMale = false; + }); + }, + child: Row( + children: [ + Container( + decoration: containerColorRadiusBorderWidth(Colors.white, 1000, CustomColors.darkGreyColor, 1), + width: 24, + height: 24, + padding: EdgeInsets.all(4), child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), - child: Row( - children: [ - Expanded( - child: Center( - child: Padding( - padding: const EdgeInsets.only(left: 10.0), - child: TextFormField( - keyboardType: TextInputType.number, - controller: heightController, - ), - ), - ), - ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (heightCm < 250) heightCm++; - heightController.text = heightCm.toString(); - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (heightCm > 0) heightCm--; - heightController.text = heightCm.toString(); - }); - }, - ), - ], - ), - ), - ], - ), + width: double.infinity, + height: double.infinity, + decoration: containerRadius(!isMale ? CustomColors.accentColor : Colors.white, 100), ), ), - ), - Expanded( - child: Slider( - value: heightCm.toDouble(), - min: 0, - max: 250, - onChanged: (double newValue) { - setState(() { - heightCm = newValue.round(); - heightController.text = heightCm.toString(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), + mWidth(12), + Text( + TranslationBase.of(context).female, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, + ), ), - ), - ], - ), - ), - ), - ], - ), - Texts('Select Unit'), - SizedBox( - height: 5.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - GestureDetector( - onTap: () { - setState(() { - updateColorHeight(1); - isHeightCm = true; - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow - ), - ], - color: cmCard, - borderRadius: BorderRadius.circular(3.0), - ), - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 0.0, horizontal: 18.0), - child: Center(child: Texts('CM')), - ), - ), - ), - GestureDetector( - onTap: () { - setState(() { - updateColorHeight(2); - isHeightCm = false; - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - color: ftCard, - borderRadius: BorderRadius.circular(3.0), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow - ), - ], - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: Center(child: Texts('Ft')), + ], + ), ), ), - ), - ], - ), - SizedBox( - height: 10.0, - ), - Texts( - 'Neck', - ), - Row( - children: [ - Expanded( - child: Container( - width: 340.0, - height: 60.0, - decoration: BoxDecoration( - color: Colors.white, - ), - child: Row( - children: [ - Padding( - padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0), - child: Center( + Expanded( + child: GestureDetector( + onTap: () { + setState(() { + updateColor(2); + isMale = true; + }); + }, + child: Row( + children: [ + Container( + decoration: containerColorRadiusBorderWidth(Colors.white, 1000, CustomColors.darkGreyColor, 1), + width: 24, + height: 24, + padding: EdgeInsets.all(4), child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), - child: Row( - children: [ - Expanded( - child: Center( - child: Padding( - padding: const EdgeInsets.only(left: 15.0, bottom: 0), - child: TextFormField( - keyboardType: TextInputType.number, - controller: neckController, - ), - ), - ), - ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (neck < 60) neck++; - neckController.text = neck.toString(); - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (neck > 5) neck--; - neckController.text = neck.toString(); - }); - }, - ), - ], - ), - ), - ], - ), + width: double.infinity, + height: double.infinity, + decoration: containerRadius(isMale ? CustomColors.accentColor : Colors.white, 100), ), ), - ), - Expanded( - child: Slider( - value: neck.toDouble(), - min: 5, - max: 60, - onChanged: (double newValue) { - setState(() { - neck = newValue.round(); - neckController.text = neck.toString(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), + mWidth(12), + Text( + TranslationBase.of(context).male, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, + ), ), - ), - ], - ), - ), - ), - ], - ), - Texts('Select Unit'), - SizedBox( - height: 5.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - GestureDetector( - onTap: () { - setState(() { - updateColorNeck(1); - isHeightCm = true; - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow - ), - ], - color: neckCmCard, - borderRadius: BorderRadius.circular(3.0), - ), - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 0.0, horizontal: 18.0), - child: Center(child: Texts('CM')), - ), - ), - ), - GestureDetector( - onTap: () { - setState(() { - updateColorNeck(2); - isHeightCm = false; - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - color: neckFtCard, - borderRadius: BorderRadius.circular(3.0), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow - ), - ], - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: Center(child: Texts('Ft')), + ], + ), ), ), - ), - ], + ], + ), ), SizedBox( - height: 10.0, - ), - Texts( - 'Waist', + height: 12.0, ), - Row( - children: [ - Expanded( - child: Container( - width: 340.0, - height: 60.0, - decoration: BoxDecoration( - color: Colors.white, - ), - child: Row( - children: [ - Padding( - padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), - child: Row( - children: [ - Expanded( - child: Center( - child: Padding( - padding: const EdgeInsets.only(left: 10.0), - child: TextFormField( - keyboardType: TextInputType.number, - controller: waistController, - ), - ), - ), - ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (waist < 200) waist++; - waistController.text = waist.toString(); - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (waist > 5) waist--; - waistController.text = waist.toString(); - }); - }, - ), - ], - ), - ), - ], - ), - ), - ), - ), - Expanded( - child: Slider( - value: waist.toDouble(), - min: 5, - max: 200, - onChanged: (double newValue) { - setState(() { - waist = newValue.round(); - waistController.text = waist.toString(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), - ), - ], - ), - ), - ), - ], + _commonInputAndUnitRow( + TranslationBase.of(context).height, + _heightController, + 1, + 270, + _heightValue, + (text) { + _heightController.text = text; + }, + (value) { + _heightValue = value; + }, + _isHeightCM ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, + (value) { + if (_isHeightCM != value) { + setState(() { + _isHeightCM = value; + }); + } + }, + _heightPopupList, ), - Texts('Select Unit'), SizedBox( - height: 5.0, + height: 12.0, ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - GestureDetector( - onTap: () { - setState(() { - updateColorWaist(1); - isHeightCm = true; - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow - ), - ], - color: waistCmCard, - borderRadius: BorderRadius.circular(3.0), - ), - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 0.0, horizontal: 18.0), - child: Center(child: Texts('CM')), - ), - ), - ), - GestureDetector( - onTap: () { - setState(() { - updateColorWaist(2); - isHeightCm = false; - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - color: waistFtCard, - borderRadius: BorderRadius.circular(3.0), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow - ), - ], - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: Center(child: Texts('Ft')), - ), - ), - ), - ], + _commonInputAndUnitRow( + TranslationBase.of(context).neck, + _neckController, + 1, + 270, + _neckValue, + (text) { + _neckController.text = text; + }, + (value) { + _neckValue = value; + }, + _isNeckKG ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, + (value) { + if (_isNeckKG != value) { + setState(() { + _isNeckKG = value; + }); + } + }, + _neckPopupList, ), + SizedBox( - height: 10.0, - ), - Texts( - 'Hip', + height: 12.0, ), - Row( - children: [ - Expanded( - child: Container( - width: 340.0, - height: 60.0, - decoration: BoxDecoration( - color: Colors.white, - ), - child: Row( - children: [ - Padding( - padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), - child: Row( - children: [ - Expanded( - child: Center( - child: Padding( - padding: const EdgeInsets.only(left: 10.0), - child: TextFormField( - keyboardType: TextInputType.number, - controller: hipController, - ), - ), - ), - ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (hip < 140) hip++; - hipController.text = hip.toString(); - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (hip > 5) hip--; - hipController.text = hip.toString(); - }); - }, - ), - ], - ), - ), - ], - ), - ), - ), - ), - Expanded( - child: Slider( - value: hip.toDouble(), - min: 5, - max: 140, - onChanged: (double newValue) { - setState(() { - hip = newValue.round(); - hipController.text = hip.toString(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), - ), - ], - ), - ), - ), - ], + _commonInputAndUnitRow( + TranslationBase.of(context).waist, + _waistController, + 1, + 270, + _waistValue, + (text) { + _waistController.text = text; + }, + (value) { + _waistValue = value; + }, + _isWaistKG ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, + (value) { + if (_isWaistKG != value) { + setState(() { + _isWaistKG = value; + }); + } + }, + _waistPopupList, ), - Texts('Select Unit'), SizedBox( - height: 5.0, + height: 12.0, ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - GestureDetector( - onTap: () { - setState(() { - updateColorHip(1); - isHeightCm = true; - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow - ), - ], - color: hipCmCard, - borderRadius: BorderRadius.circular(3.0), - ), - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 0.0, horizontal: 18.0), - child: Center(child: Texts('CM')), - ), - ), - ), - GestureDetector( - onTap: () { - setState(() { - updateColorHip(2); - isHeightCm = false; - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - color: hipFtCard, - borderRadius: BorderRadius.circular(3.0), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset(0, 3), // changes position of shadow - ), - ], - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: Center(child: Texts('Ft')), - ), - ), - ), - ], + _commonInputAndUnitRow( + TranslationBase.of(context).hip, + _hipController, + 1, + 270, + _hipValue, + (text) { + _hipController.text = text; + }, + (value) { + _hipValue = value; + }, + _isHipKG ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, + (value) { + if (_isHipKG != value) { + setState(() { + _isHipKG = value; + }); + } + }, + _hipPopupList, ), + SizedBox( - height: 35.0, + height: 12.0, ), ], ), - Container( - height: MediaQuery.of(context).size.height * 0.084, - width: 350.0, - child: SecondaryButton( - label: 'CALCULATE', - // onTap: () => { - // setState(() { - // print('hiii'); - // }) - // } - onTap: () { - setState(() { - calculateBodyFat(); - showTextResult(); + ), + ), + ), + Container( + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( + label: TranslationBase.of(context).calculate, + color: CustomColors.accentColor, + onTap: () { + setState(() { + calculateBodyFat(); + showTextResult(); - { - Navigator.push( - context, - FadePage( - page: FatResult( - bodyFat: bodyFat, - fat: fat, - textResult: textResult, - )), - ); - } - }); - }, + { + Navigator.push( + context, + FadePage( + page: FatResult( + bodyFat: bodyFat, + fat: fat, + textResult: textResult, + )), + ); + } + }); + }, + ), + ), + ], + ), + ); + } + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) { + return Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: InkWell( + onTap: hasSelection ? () {} : null, + child: Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _labelText, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), ), - ), - ], + TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.zero, + keyboardType: TextInputType.number, + controller: _controller, + onChanged: (value) => {}, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + prefixIconConstraints: BoxConstraints(minWidth: 50), + prefixIcon: prefix == null + ? null + : Text( + "+" + prefix, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, + ), + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ], + ), ), + if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined), + ], + ), + ), + ); + } + + Widget _commonInputAndUnitRow(_title, _controller, double _minValue, double _maxValue, double _valueOrg, Function(String) onTextValueChange, Function(double) onValueChange, String unitTitle, + Function(bool) onUnitTap, _list) { + return Row( + children: [ + Expanded( + flex: 3, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _title, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff2E303A), + letterSpacing: -0.44, + ), + ), + TextField( + controller: _controller, + keyboardType: TextInputType.number, + onChanged: (value) { + double _value = double.parse(value); + if (_value > _maxValue) { + onTextValueChange(_maxValue.toStringAsFixed(0)); + onValueChange(_maxValue); + return; + } else if (_value < _minValue) { + onTextValueChange(_minValue.toStringAsFixed(0)); + onValueChange(_minValue); + return; + } else if (_value >= _minValue && _value <= _maxValue) { + onValueChange(_value); + return; + } + }, + inputFormatters: [ + FilteringTextInputFormatter.allow(RegExp(r'[0-9]')), + ], + style: TextStyle( + color: Color(0xff575757), + letterSpacing: -0.56, + ), + decoration: InputDecoration( + isDense: true, + hintText: "0", + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ], ), ), + Container(height: 34, width: 1, color: Color(0xffE0E0E0), margin: EdgeInsets.only(left: 12, right: 12)), + Expanded( + flex: 1, + child: PopupMenuButton( + child: CommonDropDownView(TranslationBase.of(context).unit, unitTitle, null), + onSelected: (value) { + onUnitTap(value); + }, + itemBuilder: (context) => _list), + ) + ], + ).withBorderedContainer; + } +} + +// todo 'sikander' move these to separate file once usability known +class CommonDropDownView extends StatelessWidget { + final String title; + final String value; + final VoidCallback callback; + final IconData iconData; + + CommonDropDownView(this.title, this.value, this.callback, {Key key, this.iconData}) : super(key: key); + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: callback, + child: Row( + children: [ + Expanded( + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text( + title, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff2E303A), + letterSpacing: -0.44, + ), + ), + Text( + value, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + ), + ]), + ), + Icon( + iconData ?? Icons.keyboard_arrow_down_sharp, + color: Color(0xff2E303A), + ) + ], ), ); } } + + diff --git a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat_result_page.dart index 9ba23a1e..b8285083 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat_result_page.dart @@ -1,9 +1,12 @@ import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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'; @@ -41,49 +44,70 @@ class FatResult extends StatelessWidget { showNewAppBar: true, appBarTitle: TranslationBase.of(context).bodyFatTitle, body: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - SizedBox( - // height: 40.0, - ), - Center( - child: CircularPercentIndicator( - radius: 220.0, - lineWidth: 20.0, - percent: ((fat > 70) ? 100 : fat / 100), - center: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - fat.toStringAsFixed(1) + '%', - style: TextStyle( - fontSize: 18.0, - fontWeight: FontWeight.bold, + Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).bodyFatTitle, + style: TextStyle( + fontSize: 19, + letterSpacing: -1.34, + fontWeight: FontWeight.bold, + ), + ), + mHeight(20), + Center( + child: CircularPercentIndicator( + radius: 220.0, + lineWidth: 3.0, + percent: ((fat > 70) ? 100 : fat / 100), + center: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + fat.toStringAsFixed(1) + '%', + style: TextStyle( + fontSize: 17, + letterSpacing: -1.02, + fontWeight: FontWeight.w600, + ), + ), + ], ), + progressColor: CustomColors.accentColor, + backgroundColor: Colors.white, ), - SizedBox( - height: 5.0, + ), + mHeight(20), + Text( + textResult, style: TextStyle( + fontSize: 14, + letterSpacing: -0.56, + fontWeight: FontWeight.w600, + color: CustomColors.textColor ), - ], - ), - progressColor: inductorColor, - backgroundColor: Colors.white, - ), - ), - Container( - height: 120, - width: 280.0, - child: Texts(textResult), + ), + ], + ).withBorderedContainer, ), + mFlex(1), + Container( - width: 350, - child: Button( + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( label: TranslationBase.of(context).viewDocList, + color: CustomColors.accentColor, onTap: () { getDoctorsList(context); }, ), ), + ], ), ); @@ -142,3 +166,18 @@ class FatResult extends StatelessWidget { }); } } +extension BorderedContainer on Widget { + Widget get withBorderedContainer => Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: this, + ); +} \ No newline at end of file diff --git a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart index 6685a2c6..74db1a30 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart @@ -261,6 +261,7 @@ class _CalorieCalculatorState extends State { SizedBox( height: 12.0, ), + InkWell( onTap: () { // dropdownKey.currentState; diff --git a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart index 4b68687a..fa8e2bc5 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; @@ -17,6 +18,7 @@ class Carbs extends StatefulWidget { class _CarbsState extends State { TextEditingController textController = new TextEditingController(); + final GlobalKey clinicDropdownKey = GlobalKey(); int calories; String dropdownValue; bool _visible = false; @@ -67,9 +69,9 @@ class _CarbsState extends State { void calculate() { pCal = (protein / 100.0) * int.parse(textController.text).ceil(); cCal = (carbs / 100.0) * int.parse(textController.text); - ; + fCal = (fat / 100) * int.parse(textController.text); - ; + pCalGram = pCal / 4.0; cCalGram = cCal / 4.0; fCalGram = fCal / 9.0; @@ -95,286 +97,274 @@ class _CarbsState extends State { ), ) ], - body: Padding( - padding: EdgeInsets.symmetric(horizontal: 25.0, vertical: 15.0), - child: SingleChildScrollView( - child: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - 'Calculates carbohydrate protein and fat\n ratio in calories and grams according to a\n pre-set ratio', - ), - SizedBox( - height: 15.0, - ), - Column( + body: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Container( + padding: EdgeInsets.all(21), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - width: 340.0, - height: 60.0, - decoration: BoxDecoration( - color: Colors.white, - ), - child: Row( - children: [ - Padding( - padding: EdgeInsets.symmetric( - vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 300.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), - child: Row( - children: [ - Expanded( - child: Center( - child: TextFormField( - controller: textController, - inputFormatters: [ - FilteringTextInputFormatter - .digitsOnly - ], - keyboardType: TextInputType.number, - decoration: InputDecoration( - hintText: " The Calories per day ", - labelStyle: TextStyle( - color: Colors.black87, - ), - ), - ), - ), - ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - int currentValue = int.parse( - textController.text); - currentValue++; - textController.text = - (currentValue).toString(); - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - int currentValue = int.parse( - textController.text); - currentValue--; - textController.text = - (currentValue).toString(); - }); - }, - ), - ], - ), - ), - ], - ), - ), - ), - ), - ], + Text( + 'Calculates carbohydrate protein and fat ratio in calories and grams according to a pre-set ratio', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, + color: CustomColors.textColor, ), ), SizedBox( - height: 20.0, + height: 15.0, ), - Button( - backgroundColor: Color(0xffC5272D), - label: 'NOT SURE? CLICK HERE', - onTap: () { - setState(() { - { + Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + inputWidget("The Calories per day", "0", textController), + InkWell( + onTap: () { Navigator.push( context, FadePage(page: CalorieCalculator()), ); - } - }); - }, + }, + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Text( + 'NOT SURE? CLICK HERE', + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, letterSpacing: -0.56, color: CustomColors.accentColor, decoration: TextDecoration.underline), + ), + ), + ) + ], ), - ], - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts('Select Diet Type'), - Container( - width: 400, - child: DropdownButton( - value: dropdownValue, - icon: Icon(Icons.arrow_downward), - iconSize: 24, - elevation: 16, - style: TextStyle(color: Colors.black87), - underline: Container( - height: 2, - color: Colors.black54, - ), - onChanged: (String newValue) { - setState(() { - dropdownValue = newValue; - calculateDietRatios(); - - dropdownValue == null - ? _visible = false - : _visible = true; - }); - }, - items: [ - 'Very Low Carb', - 'Low Carb', - 'Moderate Carb', - 'USDA Gudilines', - 'Zone Diet', - ].map>((String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }).toList(), - ), + SizedBox( + height: 12.0, ), - Visibility( - visible: _visible, + InkWell( + onTap: () { + // dropdownKey.currentState; + openDropdown(clinicDropdownKey); + }, child: Container( - height: 170.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + // width: double.infinity, + // decoration: containerRadius(Colors.white, 12), + // padding: EdgeInsets.only(left: 10, right: 10, top: 12, bottom: 12), + child: Row( children: [ - Texts( - 'Ratios are divided according to the selected diet'), - RichText( - text: TextSpan( - style: TextStyle(color: Colors.black), - children: [ - TextSpan(text: 'Meals Per Day '), - TextSpan( - text: '$meals', - style: TextStyle(color: Color(0xffC5272D)), - ), - ], - ), - ), - RichText( - text: TextSpan( - style: TextStyle(color: Colors.black), + Flexible( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - TextSpan( - text: 'Protein ', - ), - TextSpan( - text: '$protein%', - style: TextStyle(color: Color(0xffC5272D)), - ) - ], - ), - ), - RichText( - text: TextSpan( - style: TextStyle(color: Colors.black), - children: [ - TextSpan( - text: 'Carbohydrate ', + Text( + "Select Diet Type", + style: TextStyle( + fontSize: 11, + letterSpacing: -0.44, + fontWeight: FontWeight.w600, + ), ), - TextSpan( - text: '$carbs%', - style: TextStyle(color: Color(0xffC5272D)), - ) - ], - ), - ), - RichText( - text: TextSpan( - style: TextStyle(color: Colors.black), - children: [ - TextSpan( - text: 'Fat ', + Container( + height: 18, + child: DropdownButtonHideUnderline( + child: DropdownButton( + value: dropdownValue, + icon: Icon(Icons.arrow_downward), + iconSize: 0, + elevation: 16, + isExpanded: true, + style: TextStyle(color: Colors.black87), + underline: Container( + height: 2, + color: Colors.black54, + ), + onChanged: (String newValue) { + setState(() { + dropdownValue = newValue; + calculateDietRatios(); + }); + }, + items: ['Very Low Carb', 'Low Carb', 'Moderate Carb', 'USDA Gudilines', 'Zone Diet'].map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + ), + ), ), - TextSpan( - text: '$fat%', - style: TextStyle(color: Color(0xffC5272D)), - ) ], ), ), + Icon(Icons.keyboard_arrow_down), ], ), - ), - ) + ).withBorderedContainer, + ), + SizedBox( + height: 25.0, + ), + SizedBox( + height: 55.0, + ), ], ), - SizedBox( - height: 55.0, + ), + ), + ), + Container( + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( + label: TranslationBase.of(context).calculate, + color: CustomColors.accentColor, + onTap: () { + setState(() { + { + calculate(); + Navigator.push( + context, + FadePage( + page: CarbsResult( + cCal: cCal, + pCal: pCal, + fCal: fCal, + pCalGram: pCalGram, + pCalMeal: pCalMeal, + fCalGram: fCalGram, + fCalMeal: fCalMeal, + cCalGram: cCalGram, + cCalMeal: cCalMeal, + )), + ); + } + }); + }, + ), + ), + ], + ), + ); + } + + void openDropdown(GlobalKey key) { + GestureDetector detector; + void searchForGestureDetector(BuildContext element) { + element.visitChildElements((element) { + if (element.widget != null && element.widget is GestureDetector) { + detector = element.widget; + return false; + } else { + searchForGestureDetector(element); + } + + return true; + }); + } + + searchForGestureDetector(key.currentContext); + assert(detector != null); + + detector.onTap(); + } +} + +Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) { + return Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: InkWell( + onTap: hasSelection ? () {} : null, + child: Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _labelText, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), ), - Container( - height: 50.0, - width: 350.0, - child: SecondaryButton( - label: 'CALCULATE', - onTap: () { - setState(() { - { - calculate(); - Navigator.push( - context, - FadePage( - page: CarbsResult( - cCal: cCal, - pCal: pCal, - fCal: fCal, - pCalGram: pCalGram, - pCalMeal: pCalMeal, - fCalGram: fCalGram, - fCalMeal: fCalMeal, - cCalGram: cCalGram, - cCalMeal: cCalMeal, - )), - ); - } - }); - }, + TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.zero, + keyboardType: TextInputType.number, + controller: _controller, + onChanged: (value) => {}, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + prefixIconConstraints: BoxConstraints(minWidth: 50), + prefixIcon: prefix == null + ? null + : Text( + "+" + prefix, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, + ), + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, ), ), ], ), ), - ), + if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined), + ], ), - ); - } + ), + ); +} + +extension BorderedContainer on Widget { + Widget get withBorderedContainer => Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: this, + ); } diff --git a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs_result_page.dart index 46c14ee0..43019deb 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs_result_page.dart @@ -1,15 +1,20 @@ - import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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 'package:flutter/painting.dart'; +import 'package:provider/provider.dart'; class CarbsResult extends StatelessWidget { double pCal; @@ -22,18 +27,11 @@ class CarbsResult extends StatelessWidget { double cCalMeal; double fCalMeal; - CarbsResult( - {this.pCal, - this.cCal, - this.fCal, - this.pCalGram, - this.cCalGram, - this.fCalGram, - this.fCalMeal, - this.cCalMeal, - this.pCalMeal}); + CarbsResult({this.pCal, this.cCal, this.fCal, this.pCalGram, this.cCalGram, this.fCalGram, this.fCalMeal, this.cCalMeal, this.pCalMeal}); + @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); return AppScaffold( isShowAppBar: true, isShowDecPage: false, @@ -43,135 +41,96 @@ class CarbsResult extends StatelessWidget { body: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Padding( - padding: EdgeInsets.symmetric(vertical: 30.0, horizontal: 10.0), - child: Table( - border: TableBorder( - verticalInside: BorderSide(width: 1, color: Colors.black54), - bottom: BorderSide(width: 1, color: Colors.black54), - left: BorderSide(width: 1, color: Colors.black54), - right: BorderSide(width: 1, color: Colors.black54), - top: BorderSide(width: 1, color: Colors.black54), - ), + Container( + decoration: containerRadius(Colors.white, 12), + padding: EdgeInsets.all(12), + margin: EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - TableRow( - decoration: BoxDecoration( - color: Colors.white, - ), - children: [ - TableCell( - child: Center( - child: Texts('Description'), - ), - ), - TableCell( - child: Center( - child: Texts('Protein'), - ), - ), - TableCell( - child: Center( - child: Texts( - 'Carbohydrate', - ), - ), - ), - TableCell( - child: Center( - child: Texts('Fat'), - ), - ), - ]), - TableRow(children: [ - Padding( - padding: EdgeInsets.all(8.0), - child: TableCell( - child: Center( - child: Texts('Calories\n Per Day'), - ), - ), - ), - TableCell( - child: Center( - child: Texts(pCal.ceil().toString() + ' Cals'), - ), - ), - TableCell( - child: Center( - child: Texts(cCal.ceil().toString() + ' Cals'), - ), - ), - TableCell( - child: Center( - child: Texts(fCal.ceil().toString() + ' Cals'), - ), - ), - ]), - TableRow(children: [ - Padding( - padding: EdgeInsets.all(8.0), - child: TableCell( - child: Center( - child: Texts('Grams Per\n Day'), - ), - ), - ), - TableCell( - child: Center( - child: Texts(pCalGram.ceil().toString() + ' gr'), - ), - ), - TableCell( - child: Center( - child: Texts(cCalGram.ceil().toString() + ' gr'), - ), + Text( + TranslationBase.of(context).carbsProtin, + style: TextStyle( + fontSize: 19, + fontWeight: FontWeight.bold, + letterSpacing: -1.34, ), - TableCell( - child: Center( - child: Texts(fCalGram.ceil().toString() + ' gr'), - ), - ), - ]), - TableRow(children: [ - Padding( - padding: EdgeInsets.all(8.0), - child: TableCell( - child: Center( - child: Texts('Grams Per\n Meal'), - ), - ), - ), - TableCell( - child: Center( - child: Texts(pCalMeal.ceil().toString() + ' gr'), - ), - ), - TableCell( - child: Center( - child: Texts(cCalMeal.ceil().toString() + ' gr'), - ), - ), - TableCell( - child: Center( - child: Texts(fCalMeal.ceil().toString() + ' gr'), - ), - ), - ]), + ), + mHeight(12), + Table( + columnWidths: { + 0: FlexColumnWidth(2.4), + 1: FlexColumnWidth(1.8), + 2: FlexColumnWidth(2), + 3: FlexColumnWidth(1), + }, + children: fullData(context, projectViewModel), + ), ], ), ), Container( - width: 350, - child: Button( - label: TranslationBase.of(context).viewDocList, + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( + label: TranslationBase.of(context).seeListOfDoctor, + color: CustomColors.accentColor, onTap: () { getDoctorsList(context); }, ), ), + + ], + ), + ); + } + + List fullData(BuildContext context, ProjectViewModel projectViewModel) { + List tableRow = []; + tableRow.add( + TableRow( + children: [ + Utils.tableColumnTitle("Description"), + Utils.tableColumnTitle("Protein"), + Utils.tableColumnTitle("Carbohydrate"), + Utils.tableColumnTitle("Fat"), + ], + ), + ); + + tableRow.add( + TableRow( + children: [ + Utils.tableColumnValue("Calories Per Day", isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(pCal.ceil().toString() + ' Cals', isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(cCal.ceil().toString() + ' Cals', isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(cCal.ceil().toString() + ' Cals', isCapitable: false, mProjectViewModel: projectViewModel), + ], + ), + ); + + tableRow.add( + TableRow( + children: [ + Utils.tableColumnValue("Grams Per Day", isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(pCalGram.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(cCalGram.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(fCalGram.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), ], ), ); + tableRow.add( + TableRow( + children: [ + Utils.tableColumnValue('Grams Per Meal', isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(pCalMeal.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(cCalMeal.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(fCalMeal.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), + ], + ), + ); + return tableRow; } getDoctorsList(BuildContext context) { @@ -208,7 +167,7 @@ class CarbsResult extends StatelessWidget { List doctorByHospital = _patientDoctorAppointmentListHospital .where( (elementClinic) => elementClinic.filterName == element.projectName, - ) + ) .toList(); if (doctorByHospital.length != 0) { @@ -226,5 +185,4 @@ class CarbsResult extends StatelessWidget { print(err); }); } - } diff --git a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart index e8d89b13..e414f028 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart @@ -1,10 +1,11 @@ - +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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 'package:flutter/services.dart'; import 'ideal_body_result_page.dart'; @@ -24,8 +25,9 @@ class _IdealBodyState extends State { Color lbCard = inactiveCardColor; Color cmCard = activeCardColor; Color ftCard = inactiveCardColor; - int age = 0; - int height = 0; + + // int age = 0; + // int height = 0; double heightInches; double minRange; double maxRange; @@ -38,48 +40,22 @@ class _IdealBodyState extends State { double maxIdealWeight; double heightFeet; - void updateColorHeight(int type) { - //MG/DLT card - if (type == 1) { - if (cmCard == inactiveCardColor) { - cmCard = activeCardColor; - ftCard = inactiveCardColor; - } else { - cmCard = inactiveCardColor; - } - } - if (type == 2) { - if (ftCard == inactiveCardColor) { - ftCard = activeCardColor; - cmCard = inactiveCardColor; - } else { - ftCard = inactiveCardColor; - } - } - } + final GlobalKey clinicDropdownKey = GlobalKey(); + bool _isHeightCM = true; + bool _isWeightKG = true; + double _heightValue = 0; + double _weightValue = 0; + + TextEditingController _heightController = new TextEditingController(); + TextEditingController _weightController = TextEditingController(); + + List _heightPopupList = List(); + List _weightPopupList = List(); + - void updateColorWeight(int type) { - //MG/DLT card - if (type == 1) { - if (kgCard == inactiveCardColor) { - kgCard = activeCardColor; - lbCard = inactiveCardColor; - } else { - kgCard = inactiveCardColor; - } - } - if (type == 2) { - if (lbCard == inactiveCardColor) { - lbCard = activeCardColor; - kgCard = inactiveCardColor; - } else { - lbCard = inactiveCardColor; - } - } - } void calculateIdealWeight() { - heightInches = height * .39370078740157477; + heightInches = int.parse(_heightController.text) * .39370078740157477; heightFeet = heightInches / 12; idealWeight = (50 + 2.3 * (heightInches - 60)); if (dropdownValue == 'Small(fingers overlap)') { @@ -99,6 +75,9 @@ class _IdealBodyState extends State { @override Widget build(BuildContext context) { + _weightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).kg), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).lb), value: false)]; + _heightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).cm), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).ft), value: false)]; + return AppScaffold( isShowAppBar: true, isShowDecPage: false, @@ -115,458 +94,418 @@ class _IdealBodyState extends State { ), ) ], - body: Padding( - padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 25.0), - child: SingleChildScrollView( - child: Container( - height: 800.0, - child: Column( - children: [ - Padding( - padding: EdgeInsets.all(10.0), - child: Texts( - 'Calculates the ideal body weight based on height, Weight, and Body Size', - ), - ), - Divider( - thickness: 2.0, - ), - SizedBox( - height: 5.0, - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, + body: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Container( + padding: EdgeInsets.all(21), + child: Column( children: [ - Texts( - 'Height', - ), - Row( - children: [ - Expanded( - child: Container( - width: 340.0, - height: 60.0, - decoration: BoxDecoration( - color: Colors.white, - ), - child: Row( - children: [ - Padding( - padding: EdgeInsets.symmetric( - vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: - BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), - child: Row( - children: [ - Expanded( - child: Center( - child: Text(height.toString()), - ), - ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (height < 250) - height++; - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (height > 0) height--; - }); - }, - ), - ], - ), - ), - ], - ), - ), - ), - ), - Expanded( - child: Slider( - value: height.toDouble(), - min: 0, - max: 250, - onChanged: (double newValue) { - setState(() { - height = newValue.round(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), - ), - ], - ), - ), - ), - ], + Text( + 'Calculates the ideal body weight based on height, Weight, and Body Size', + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + letterSpacing: -0.56, + color: CustomColors.textColor, + ), ), - Texts('Select Unit'), SizedBox( height: 5.0, ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - GestureDetector( - onTap: () { - setState(() { - updateColorHeight(1); - isHeightCm = true; - }); + SizedBox( + height: 12.0, + ), + _commonInputAndUnitRow( + TranslationBase.of(context).height, + _heightController, + 1, + 270, + _heightValue, + (text) { + _heightController.text = text; }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset( - 0, 3), // changes position of shadow - ), - ], - color: cmCard, - borderRadius: BorderRadius.circular(3.0), - ), - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 0.0, horizontal: 18.0), - child: Center(child: Texts('CM')), - ), - ), + (value) { + _heightValue = value; + }, + _isHeightCM ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, + (value) { + if (_isHeightCM != value) { + setState(() { + _isHeightCM = value; + }); + } + }, + _heightPopupList, ), - GestureDetector( - onTap: () { - setState(() { - updateColorHeight(2); - isHeightCm = false; - }); + SizedBox( + height: 12.0, + ), + _commonInputAndUnitRow( + TranslationBase.of(context).weight, + _weightController, + 1, + 270, + _weightValue, + (text) { + _weightController.text = text; }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - color: ftCard, - borderRadius: BorderRadius.circular(3.0), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset( - 0, 3), // changes position of shadow - ), - ], - ), - child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 16.0), - child: Center(child: Texts('Ft')), - ), - ), + (value) { + _weightValue = value; + }, + _isWeightKG ? TranslationBase.of(context).kg : TranslationBase.of(context).pound, + (value) { + if (_isWeightKG != value) { + setState(() { + _isWeightKG = value; + }); + } + }, + _weightPopupList, ), - ], - ), - SizedBox( - height: 45.0, - ), - Divider( - thickness: 2.0, - ), - Texts( - 'Weight', - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( + SizedBox( + height: 12.0, + ), + InkWell( + onTap: () { + // dropdownKey.currentState; + openDropdown(clinicDropdownKey); + }, child: Container( - width: 340.0, - height: 60.0, - decoration: BoxDecoration( - color: Colors.white, - ), + // width: double.infinity, + // decoration: containerRadius(Colors.white, 12), + // padding: EdgeInsets.only(left: 10, right: 10, top: 12, bottom: 12), child: Row( children: [ - Padding( - padding: EdgeInsets.symmetric( - vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: - BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, + Flexible( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Body Frame Size", + style: TextStyle( + fontSize: 11, + letterSpacing: -0.44, + fontWeight: FontWeight.w600, ), ), - child: Row( - children: [ - Expanded( - child: Center( - child: Text(weight.toString()), - ), - ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (weight < 250) - weight++; - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (weight > 0) weight--; - }); - }, - ), - ], + Container( + height: 18, + child: DropdownButtonHideUnderline( + child: DropdownButton( + value: dropdownValue, + icon: Icon(Icons.arrow_downward), + iconSize: 0, + elevation: 16, + isExpanded: true, + style: TextStyle(color: Colors.black87), + underline: Container( + height: 2, + color: Colors.black54, ), + onChanged: (String newValue) { + setState(() { + dropdownValue = newValue; + }); + }, + items: [ + 'Small(fingers overlap)', + 'Medium(fingers touch)', + 'Large(fingers don\'n touch)', + ].map>((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), ), - ], + ), ), - ), - ), - ), - Expanded( - child: Slider( - value: weight.toDouble(), - min: 0, - max: 250, - onChanged: (double newValue) { - setState(() { - weight = newValue.round(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), + ], ), ), + Icon(Icons.keyboard_arrow_down), ], ), - ), - ), - ], - ), - Texts('Select Unit'), - SizedBox( - height: 5.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - GestureDetector( - onTap: () { - setState(() { - updateColorWeight(1); - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset( - 0, 3), // changes position of shadow - ), - ], - color: kgCard, - borderRadius: BorderRadius.circular(3.0), - ), - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 0.0, horizontal: 18.0), - child: Center(child: Texts('KG')), - ), - ), - ), - GestureDetector( - onTap: () { - setState(() { - updateColorWeight(2); - }); - }, - child: Container( - height: 55.0, - width: 150.0, - decoration: BoxDecoration( - color: lbCard, - borderRadius: BorderRadius.circular(3.0), - boxShadow: [ - BoxShadow( - color: Colors.grey.withOpacity(0.5), - spreadRadius: 3, - blurRadius: 7, - offset: Offset( - 0, 3), // changes position of shadow - ), - ], - ), - child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 16.0), - child: Center(child: Texts('LB')), - ), - ), + ).withBorderedContainer, ), ], ), - SizedBox( - height: 45.0, - ), - Divider( - thickness: 2.0, + ], + ), + ), + ), + ), + Container( + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( + label: TranslationBase.of(context).calculate, + color: CustomColors.accentColor, + onTap: () { + setState(() { + // calculateBmr(); + // calculateCalories(); + calculateIdealWeight(); + + print(idealWeight); + print(minRange); + print(maxRange); + print(overWeightBy); + print(textResult); + //print(overWeightBy); + { + Navigator.push( + context, + FadePage( + page: IdealBodyResult( + idealBodyWeight: idealWeight, + minRange: minRange, + mixRange: maxRange, + overWeightBy: overWeightBy, + textResult: textResult, + )), + ); + } + }); + }, + ), + ), + ], + ), + ); + } + + void openDropdown(GlobalKey key) { + GestureDetector detector; + void searchForGestureDetector(BuildContext element) { + element.visitChildElements((element) { + if (element.widget != null && element.widget is GestureDetector) { + detector = element.widget; + return false; + } else { + searchForGestureDetector(element); + } + + return true; + }); + } + + searchForGestureDetector(key.currentContext); + assert(detector != null); + + detector.onTap(); + } + + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) { + return Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: InkWell( + onTap: hasSelection ? () {} : null, + child: Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _labelText, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, ), - SizedBox( - height: 5.0, + ), + TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.zero, + keyboardType: TextInputType.number, + controller: _controller, + onChanged: (value) => {}, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, ), - Texts('Body Frame Size'), - Container( - width: 300, - child: DropdownButton( - value: dropdownValue, - icon: Icon(Icons.arrow_downward), - iconSize: 24, - elevation: 16, - style: TextStyle(color: Colors.black87), - underline: Container( - height: 2, - color: Colors.black54, - ), - onChanged: (String newValue) { - setState(() { - dropdownValue = newValue; - }); - }, - items: [ - 'Small(fingers overlap)', - 'Medium(fingers touch)', - 'Large(fingers don\'n touch)', - ].map>((String value) { - return DropdownMenuItem( - value: value, - child: Text(value), - ); - }).toList(), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, ), + prefixIconConstraints: BoxConstraints(minWidth: 50), + prefixIcon: prefix == null + ? null + : Text( + "+" + prefix, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, + ), + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, ), - SizedBox( - height: 30.0, - ), - Container( - height: 50.0, - width: 350.0, - child: SecondaryButton( - label: 'CALCULATE', - onTap: () { - setState(() { - // calculateBmr(); - // calculateCalories(); - calculateIdealWeight(); + ), + ], + ), + ), + if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined), + ], + ), + ), + ); + } - print(idealWeight); - //print(overWeightBy); - { - Navigator.push( - context, - FadePage( - page: IdealBodyResult( - idealBodyWeight: idealWeight, - minRange: minRange, - mixRange: maxRange, - overWeightBy: overWeightBy, - textResult: textResult, - )), - ); - } - }); - }, - ), - ), - ], + Widget _commonInputAndUnitRow(_title, _controller, double _minValue, double _maxValue, double _valueOrg, Function(String) onTextValueChange, Function(double) onValueChange, String unitTitle, + Function(bool) onUnitTap, _list) { + return Row( + children: [ + Expanded( + flex: 3, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _title, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff2E303A), + letterSpacing: -0.44, ), - ], - ), + ), + TextField( + controller: _controller, + keyboardType: TextInputType.number, + onChanged: (value) { + double _value = double.parse(value); + if (_value > _maxValue) { + onTextValueChange(_maxValue.toStringAsFixed(0)); + onValueChange(_maxValue); + return; + } else if (_value < _minValue) { + onTextValueChange(_minValue.toStringAsFixed(0)); + onValueChange(_minValue); + return; + } else if (_value >= _minValue && _value <= _maxValue) { + onValueChange(_value); + return; + } + }, + inputFormatters: [ + FilteringTextInputFormatter.allow(RegExp(r'[0-9]')), + ], + style: TextStyle( + color: Color(0xff575757), + letterSpacing: -0.56, + ), + decoration: InputDecoration( + isDense: true, + hintText: "0", + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ], ), ), + Container(height: 34, width: 1, color: Color(0xffE0E0E0), margin: EdgeInsets.only(left: 12, right: 12)), + Expanded( + flex: 1, + child: PopupMenuButton( + child: CommonDropDownView(TranslationBase.of(context).unit, unitTitle, null), + onSelected: (value) { + onUnitTap(value); + }, + itemBuilder: (context) => _list), + ) + ], + ).withBorderedContainer; + } +} + +// todo 'sikander' move these to separate file once usability known +class CommonDropDownView extends StatelessWidget { + final String title; + final String value; + final VoidCallback callback; + final IconData iconData; + + CommonDropDownView(this.title, this.value, this.callback, {Key key, this.iconData}) : super(key: key); + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: callback, + child: Row( + children: [ + Expanded( + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text( + title, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff2E303A), + letterSpacing: -0.44, + ), + ), + Text( + value, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + ), + ]), + ), + Icon( + iconData ?? Icons.keyboard_arrow_down_sharp, + color: Color(0xff2E303A), + ) + ], ), ); } } + + diff --git a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body_result_page.dart index 6a40bee7..6eec6dd8 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body_result_page.dart @@ -1,9 +1,12 @@ import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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'; @@ -28,139 +31,170 @@ class IdealBodyResult extends StatelessWidget { appBarTitle: TranslationBase.of(context).idealBody, body: Column( crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Texts( - 'Ideal weight range is', - fontSize: 23.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Row( - children: [ - Texts( - minRange.toStringAsFixed(1), - fontSize: 30.0, - ), - Padding( - padding: EdgeInsets.only(top: 8.0, left: 4.0), - child: Text( - 'Kg', - style: TextStyle(color: Colors.red), - ), - ), - ], - ), - Icon( - Icons.arrow_forward, - color: Colors.red, - size: 55.0, - ), - Row( - children: [ - Texts( - mixRange.toStringAsFixed(1), - fontSize: 30.0, - ), - Padding( - padding: EdgeInsets.only(top: 8.0, left: 4.0), - child: Text( - 'Kg', - style: TextStyle(color: Colors.red), - ), + + Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Ideal weight range is', + style: TextStyle( + fontSize: 19, + letterSpacing: -1.34, + fontWeight: FontWeight.bold, ), - ], - ), - ], - ), - overWeightBy >= 0 && overWeightBy <= 10 - ? Column( + ), + mHeight(12), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Texts( - 'Congratulations! The current weight is\n perfect and considered healthy', - fontSize: 20.0, + Row( + children: [ + Texts( + minRange.toStringAsFixed(1), + fontSize: 30.0, + ), + Padding( + padding: EdgeInsets.only(top: 8.0, left: 4.0), + child: Text( + 'Kg', + style: TextStyle(color: Colors.red), + ), + ), + ], ), - ], - ) - : overWeightBy > 10 && overWeightBy < 17 - ? Column( + Icon( + Icons.arrow_forward, + color: Colors.red, + size: 55.0, + ), + Row( children: [ - Texts('This means that the weight is a little bit more than ideal weight by'), - Texts(overWeightBy.toStringAsFixed(1)), - Texts('May wish to consult with the doctor for medical help. Click to view our list of Doctors'), + Texts( + mixRange.toStringAsFixed(1), + fontSize: 30.0, + ), + Padding( + padding: EdgeInsets.only(top: 8.0, left: 4.0), + child: Text( + 'Kg', + style: TextStyle(color: Colors.red), + ), + ), ], - ) - : overWeightBy >= 18 - ? Container( - height: 250.0, - width: 350, - child: Column( + ), + ], + ), + mHeight(12), + overWeightBy >= 0 && overWeightBy <= 10 + ? Column( + children: [ + Texts( + 'Congratulations! The current weight is perfect and considered healthy', + fontSize: 20.0, + ), + ], + ) + : overWeightBy > 10 && overWeightBy < 17 + ? Column( children: [ - Texts( - 'Means that you suffer from excessive\n obesity by', - ), - SizedBox( - height: 55.0, - ), - Texts( - overWeightBy.toStringAsFixed(1), - fontSize: 40.0, - ), - SizedBox( - height: 25.0, - ), - Texts('May wish to consult with the doctor for\n medical help. Click to view our list of\n Doctors'), + Texts('This means that the weight is a little bit more than ideal weight by'), + Texts(overWeightBy.toStringAsFixed(1)), + Texts('May wish to consult with the doctor for medical help. Click to view our list of Doctors'), ], - ), - ) - : overWeightBy < -18 - ? Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Texts( - 'Under Weight', - fontSize: 18.0, - ), - ), - SizedBox( - height: 55.0, - ), - Texts( - overWeightBy.toStringAsFixed(1), - fontSize: 20.0, + ) + : overWeightBy >= 18 + ? Container( + + child: Column( + children: [ + Texts( + 'Means that you suffer from excessive obesity by', + ), + SizedBox( + height: 12.0, + ), + Text( + overWeightBy.toStringAsFixed(1), + style: TextStyle( + fontSize: 17, + fontWeight: FontWeight.bold, + letterSpacing: -1.34, + ), + ), + SizedBox( + height: 12.0, + ), + Texts('May wish to consult with the doctor for medical help. Click to view our list of\n Doctors'), + ], ), - ], - ) - : Container( - height: 250.0, - width: 350.0, - child: Column( - children: [ - Texts( - 'under wheight', - fontSize: 20.0, - ), - SizedBox( - height: 55.0, - ), - Texts( - overWeightBy.toStringAsFixed(1), - fontSize: 20.0, - ), - SizedBox( - height: 25.0, + ) + : overWeightBy < -18 + ? Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Texts( + 'Under Weight', + fontSize: 18.0, + ), + ), + SizedBox( + height: 12.0, + ), + Text( + overWeightBy.toStringAsFixed(1), + style: TextStyle( + fontSize: 17, + fontWeight: FontWeight.bold, + letterSpacing: -1.34, + ), + ), + ], + ) + : Container( + + child: Column( + children: [ + Text( + 'under wheight', + style: TextStyle( + fontSize: 17, + fontWeight: FontWeight.bold, + letterSpacing: -1.34, + ), + ), + SizedBox( + height: 12.0, + ), + Text( + overWeightBy.toStringAsFixed(1), + style: TextStyle( + fontSize: 17, + fontWeight: FontWeight.bold, + letterSpacing: -1.34, + ), + ), + SizedBox( + height: 12.0, + ), + Texts('May wish to consult with the doctor for medical help. Click to view our list of Doctors'), + ], + ), ), - Texts('May wish to consult with the doctor for\n medical help. Click to view our list of\n Doctors'), - ], - ), - ), + ], + ).withBorderedContainer, + ), Container( - width: 350, - child: Button( + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( label: TranslationBase.of(context).viewDocList, + color: CustomColors.accentColor, onTap: () { getDoctorsList(context); }, @@ -224,3 +258,19 @@ class IdealBodyResult extends StatelessWidget { }); } } + +extension BorderedContainer on Widget { + Widget get withBorderedContainer => Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: this, + ); +} diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index b15f7adb..6d454d05 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2618,6 +2618,10 @@ class TranslationBase { String get RRTSubTitle => localizedValues["RRTSubTitle"][locale.languageCode]; String get transportation => localizedValues["transportation"][locale.languageCode]; + String get neck => localizedValues["neck"][locale.languageCode]; + String get waist => localizedValues["waist"][locale.languageCode]; + String get hip => localizedValues["hip"][locale.languageCode]; + String get carbsProtin => localizedValues["carbsProtin"][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/pubspec.yaml b/pubspec.yaml index 3bdadc73..da332f80 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -168,6 +168,7 @@ dependencies: in_app_review: ^1.0.4 badges: ^1.1.4 + syncfusion_flutter_sliders: ^18.4.49-beta # Dep by Zohaib shimmer: ^1.1.2 From 502c7fd3dea273c5c4bfc92b70c80a20af273c3f Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 8 Nov 2021 17:54:31 +0300 Subject: [PATCH 28/70] Offers & discounts UI updating --- lib/config/localized_values.dart | 2 + .../responses/PackagesResponseModel.dart | 2 + .../PackagesOffersServices.dart | 1 + .../OfferProductsResponseModel_helper.dart | 6 + .../fragments/home_page_fragment2.dart | 3 +- .../OfferAndPackageDetailPage.dart | 384 ++++++++++-------- .../OfferAndPackagesCartPage.dart | 189 ++++----- .../packages_offers/OfferAndPackagesPage.dart | 36 +- lib/uitl/translations_delegate_base.dart | 6 +- .../offers_packages/PackagesCartItemCard.dart | 269 +++++------- .../offers_packages/PackagesOfferCard.dart | 84 +--- 11 files changed, 416 insertions(+), 566 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index a61f86c4..d35fce51 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1630,4 +1630,6 @@ const Map localizedValues = { "RRTTitle": {"en": "RRT", "ar": "خدمة فريق"}, "RRTSubTitle": {"en": "Service", "ar": "الاستجابة السريع"}, "transportation": {"en": "Transportation", "ar": "النقل"}, + "myCart": {"en": "Cart", "ar": "عربة التسوق"}, + "browseOffers": {"en": "Browse offers by clinic", "ar": "تصفح العروض حسب العيادة"}, }; diff --git a/lib/core/model/packages_offers/responses/PackagesResponseModel.dart b/lib/core/model/packages_offers/responses/PackagesResponseModel.dart index 8d4f619b..23a864f7 100644 --- a/lib/core/model/packages_offers/responses/PackagesResponseModel.dart +++ b/lib/core/model/packages_offers/responses/PackagesResponseModel.dart @@ -192,6 +192,8 @@ class PackagesResponseModel with JsonConvert { List discountIds; @JSONField(name: "store_ids") List storeIds; + @JSONField(name: "store_names") + List storeNames; @JSONField(name: "manufacturer_ids") List manufacturerIds; List reviews; diff --git a/lib/core/service/packages_offers/PackagesOffersServices.dart b/lib/core/service/packages_offers/PackagesOffersServices.dart index 3b34b957..238cb611 100644 --- a/lib/core/service/packages_offers/PackagesOffersServices.dart +++ b/lib/core/service/packages_offers/PackagesOffersServices.dart @@ -110,6 +110,7 @@ class OffersAndPackagesServices extends BaseService { var url = EXA_CART_API_BASE_URL + PACKAGES_PRODUCTS; await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { + latestOffersList.clear(); if (statusCode == 200) { var jsonResponse = json.decode(stringResponse); jsonResponse['products'].forEach((json) { diff --git a/lib/generated/json/OfferProductsResponseModel_helper.dart b/lib/generated/json/OfferProductsResponseModel_helper.dart index d180af67..ca402fc0 100644 --- a/lib/generated/json/OfferProductsResponseModel_helper.dart +++ b/lib/generated/json/OfferProductsResponseModel_helper.dart @@ -313,6 +313,12 @@ offerProductsResponseModelFromJson(PackagesResponseModel data, Map(); data.storeIds.addAll(json['store_ids']); } + + if (json['store_names'] != null) { + data.storeNames = new List(); + data.storeNames.addAll(json['store_names']); + } + if (json['manufacturer_ids'] != null) { data.manufacturerIds = json['manufacturer_ids']?.map((v) => v?.toInt())?.toList()?.cast(); } diff --git a/lib/pages/landing/fragments/home_page_fragment2.dart b/lib/pages/landing/fragments/home_page_fragment2.dart index 4714c208..75b9a473 100644 --- a/lib/pages/landing/fragments/home_page_fragment2.dart +++ b/lib/pages/landing/fragments/home_page_fragment2.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; +import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/gradient_color.dart'; import 'package:diplomaticquarterapp/models/hmg_services.dart'; import 'package:diplomaticquarterapp/models/slider_data.dart'; @@ -282,7 +283,7 @@ class _HomePageFragment2State extends State { flex: 1, child: InkWell( onTap: () { - final user = projectViewModel.user; + AuthenticatedUser user = projectViewModel.user; Navigator.of(context).push(MaterialPageRoute(builder: (context) => PackagesHomePage(user))); }, child: Container( diff --git a/lib/pages/packages_offers/OfferAndPackageDetailPage.dart b/lib/pages/packages_offers/OfferAndPackageDetailPage.dart index 24e75797..17c88cc8 100644 --- a/lib/pages/packages_offers/OfferAndPackageDetailPage.dart +++ b/lib/pages/packages_offers/OfferAndPackageDetailPage.dart @@ -1,214 +1,254 @@ import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesResponseModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/packages_offers/PackagesOffersViewModel.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/ProductCheckTypeWidget.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/uitl/utils.dart' as utils; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; -import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:expandable/expandable.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:html/parser.dart'; +import 'package:rating_bar/rating_bar.dart'; -class OfferAndPackagesDetail extends StatefulWidget{ +class OfferAndPackagesDetail extends StatefulWidget { final PackagesResponseModel itemModel; + final Function(PackagesResponseModel product) onCartClick; - const OfferAndPackagesDetail({@required this.itemModel, Key key}) : super(key: key); + const OfferAndPackagesDetail({@required this.itemModel, @required this.onCartClick, Key key}) : super(key: key); @override State createState() => OfferAndPackagesDetailState(); } - -class OfferAndPackagesDetailState extends State{ - +class OfferAndPackagesDetailState extends State { PackagesViewModel viewModel; + bool expandFlag = false; + var controller = new ExpandableController(); + @override Widget build(BuildContext context) { return BaseView( - onModelReady: (model){ + onModelReady: (model) { viewModel = model; }, builder: (_, model, wi) => AppScaffold( - appBarTitle: TranslationBase.of(context).offerAndPackages, - isShowAppBar: true, - isPharmacy: false, - showPharmacyCart: false, - showHomeAppBarIcon: false, - isOfferPackages: true, - showOfferPackagesCart: true, - isShowDecPage: false, - body: Stack( + appBarTitle: TranslationBase.of(context).offerAndPackages, + isShowAppBar: true, + isPharmacy: false, + showPharmacyCart: false, + showHomeAppBarIcon: false, + isOfferPackages: true, + showOfferPackagesCart: true, + isShowDecPage: false, + showNewAppBar: true, + showNewAppBarTitle: true, + body: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.only(bottom: 60), - child: ListView( - children: [ - Padding( - padding: const EdgeInsets.all(5), - child: Stack( - children: [ - Padding( - padding: const EdgeInsets.all(10), - child: AspectRatio( - aspectRatio: 1/1, - child: utils.applyShadow( - child: ClipRRect( - borderRadius: BorderRadius.circular(10), - child: utils.Utils.loadNetworkImage(url: "https://wallpaperaccess.com/full/30103.jpg",) - ), - ) - ), - ), - Align( - alignment: Alignment.topLeft, - child: Image.asset( - 'assets/images/discount_${'en'}.png', - height: 70, - width: 70, - ), - ), - - ], - - ), + Container( + color: Colors.white, + padding: const EdgeInsets.all(21.0), + child: ClipRRect( + borderRadius: BorderRadius.circular(15.0), + child: Image.network("https://mdlaboratories.com/offersdiscounts/images/thumbs/0000162_dermatology-testing.jpeg", fit: BoxFit.fill), + ), + ), + Container( + padding: const EdgeInsets.only(left: 21.0, right: 21.0, top: 21.0), + child: Text(widget.itemModel.name, maxLines: 1, style: TextStyle(fontSize: 19.0, fontWeight: FontWeight.bold, letterSpacing: -1.14))), + Container( + padding: const EdgeInsets.only(left: 21.0, right: 21.0), + child: Text(widget.itemModel.shortDescription, + maxLines: 2, style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.56, color: CustomColors.textColor), overflow: TextOverflow.clip)), + Row( + children: [ + Container( + padding: const EdgeInsets.only(left: 21.0, right: 21.0, top: 12.0), + child: RatingBar.readOnly( + initialRating: 4.5, + size: 18.0, + filledColor: Color(0XFFD02127), + emptyColor: Color(0XFFD02127), + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star_border, ), - - Padding( - padding: const EdgeInsets.only(left: 20, right: 20, bottom: 20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - "Child Dental Offer", - fontSize: 25, - fontWeight: FontWeight.normal, - color: Colors.black, - ), - - Stack( - children: [ - Texts( - "200 SAR", - fontWeight: FontWeight.normal, - decoration: TextDecoration.lineThrough, - color: Colors.grey, - fontSize: 12 - ), - Padding( - padding: const EdgeInsets.only(top: 15), - child: Texts( - "894.99 SAR", - fontWeight: FontWeight.bold, - color: Colors.green, - fontSize: 18 + ), + ], + ), + Container( + padding: const EdgeInsets.only(left: 21.0, right: 21.0, top: 18.0), + width: double.infinity, + height: 50.0, + child: ListView.separated( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + itemCount: widget.itemModel.storeNames.length, + separatorBuilder: (context, index) { + return mWidth(5.0); + }, + itemBuilder: (BuildContext context, int index) { + return contactButton(widget.itemModel.storeNames[index].toString()); + }, + ), + ), + Container( + padding: const EdgeInsets.only(top: 18.0), + child: ExpandableNotifier( + initialExpanded: true, + child: Container( + color: Colors.white, + child: Column( + children: [ + ScrollOnExpand( + scrollOnExpand: true, + scrollOnCollapse: false, + child: ExpandablePanel( + hasIcon: false, + theme: const ExpandableThemeData( + headerAlignment: ExpandablePanelHeaderAlignment.center, + tapBodyToCollapse: true, + ), + header: Padding( + padding: const EdgeInsets.only(top: 20, bottom: 20, left: 21, right: 21), + child: InkWell( + onTap: () { + setState(() { + expandFlag = !expandFlag; + controller.expanded = expandFlag; + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).description, + maxLines: 1, + style: TextStyle(fontSize: 19.0, fontWeight: FontWeight.bold, letterSpacing: -1.14), + ), + ], + ), + ), + Icon( + expandFlag ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down, + color: Color(0xff2E303A), + ), + ], ), ), - ], - ), - - StarRating( - size: 20, - totalCount: null, - totalAverage: 5, - forceStars: true), - - - SizedBox(height: 20,), - - - Texts( - "Details", - fontWeight: FontWeight.bold, - color: Colors.grey, - fontSize: 20 - ), - - - - AspectRatio( - aspectRatio: 2/1, - child: Container( - color: Colors.grey[300], - child: Padding( - padding: const EdgeInsets.all(10), - child: Texts("Detail of offers written here"), - ) ), + builder: (_, collapsed, expanded) { + return Expandable( + controller: controller, + collapsed: collapsed, + expanded: Container( + padding: const EdgeInsets.only(left: 21.0, right: 21.0, bottom: 21.0), + child: Text(parseHtmlString(widget.itemModel.fullDescription), + style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.56, color: CustomColors.textColor), overflow: TextOverflow.clip)), + theme: const ExpandableThemeData(crossFadePoint: 0), + ); + }, ), - - - SizedBox(height: 10,), - ], - ), + ), + ], ), + ), + ), + ), + ], + ), + ), + bottomSheet: Container( + padding: const EdgeInsets.only(top: 16, bottom: 16, left: 21, right: 21), + color: Colors.white, + child: Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if(widget.itemModel.hasDiscountsApplied) Container( + margin: const EdgeInsets.only(top: 0.0), + child: Text(widget.itemModel.oldPrice.toString() + " " + TranslationBase.of(context).sar, + style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.w600, letterSpacing: -0.6, decoration: TextDecoration.lineThrough, color: CustomColors.grey2))), + Container( + margin: const EdgeInsets.only(top: 0.0), + child: Text(widget.itemModel.price.toString().trim() + " " + TranslationBase.of(context).sar, + style: TextStyle(fontSize: 19.0, fontWeight: FontWeight.bold, letterSpacing: -0.56))), ], ), ), - - Padding( - padding: const EdgeInsets.all(10), - child: Align( - alignment: Alignment.bottomRight, - child: Row( - children: [ - - Expanded( - child: RaisedButton.icon( - padding: EdgeInsets.only(top: 5, bottom: 5, left: 0, right: 0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8.0), - side: BorderSide(color: Colors.red, width: 0.5) - ), - color: Colors.red, - icon: Icon( - Icons.add_shopping_cart_outlined, - size: 25, - color: Colors.white, - ), - label: Texts( - "Add to Cart", - fontSize: 17, color: Colors.white, fontWeight: FontWeight.normal, - ), - onPressed: (){},), - ), - - SizedBox(width: 15,), - - Expanded( - child: OutlineButton.icon( - padding: EdgeInsets.only(top: 5, bottom: 5, left: 0, right: 0), - borderSide: BorderSide(width: 1.0, color: Colors.red), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8.0), + SizedBox(width: 8), + Expanded( + child: SizedBox( + height: 43, + width: double.infinity, + child: FlatButton( + onPressed: () { + // onCartClick(); + widget.onCartClick(widget.itemModel); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.only(left: 8.0, right: 8.0), + child: SvgPicture.asset("assets/images/new/add-to-cart.svg", color: Colors.white), + ), + Container( + child: Text( + TranslationBase.of(context).addToCart, + textAlign: TextAlign.center, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.48), ), - color: Colors.white, - icon: Icon( - Icons.favorite_rounded, - size: 25, - color: Colors.red, - ), - label: Texts( - "Add to Favorites", - fontSize: 17, color: Colors.red, fontWeight: FontWeight.normal - ), - onPressed: (){ - - },), - ), - - ], + ), + ], + ), + color: const Color(0xffD02127), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(6), + ), ), ), - ) - + ), + ], + ), + ), + ), + ); + } + String parseHtmlString(String htmlString) { + var document = parse(htmlString); + String parsedString = parse(document.body.text).documentElement.text; + return parsedString; + } - ], - ) + Widget contactButton(String title) { + return SizedBox( + height: 32, + width: 80.0, + child: FlatButton( + onPressed: () {}, + color: Colors.white, + shape: StadiumBorder(side: BorderSide(color: CustomColors.devider, width: 1)), + child: Text( + title, + style: TextStyle(fontSize: 10, letterSpacing: -0.4, color: CustomColors.textColor), + maxLines: 1, + ), ), ); } } - diff --git a/lib/pages/packages_offers/OfferAndPackagesCartPage.dart b/lib/pages/packages_offers/OfferAndPackagesCartPage.dart index d1219541..e28110a8 100644 --- a/lib/pages/packages_offers/OfferAndPackagesCartPage.dart +++ b/lib/pages/packages_offers/OfferAndPackagesCartPage.dart @@ -32,20 +32,18 @@ class PackagesCartPage extends StatefulWidget { _PackagesCartPageState createState() => _PackagesCartPageState(); } -class _PackagesCartPageState extends State - with AfterLayoutMixin, SingleTickerProviderStateMixin { +class _PackagesCartPageState extends State with AfterLayoutMixin, SingleTickerProviderStateMixin { getLanguageID() async { languageID = await sharedPref.getString(APP_LANGUAGE); } - double subtotal,tax, total; + double subtotal, tax, total; @override void initState() { _agreeTerms = false; _selectedPaymentMethod = null; - _animationController = - AnimationController(vsync: this, duration: Duration(seconds: 500)); + _animationController = AnimationController(vsync: this, duration: Duration(seconds: 500)); super.initState(); } @@ -69,22 +67,13 @@ class _PackagesCartPageState extends State } onPayNowClick() async { - await viewModel.service - .placeOrder( - context: context, - paymentParams: _selectedPaymentParams) - .then((orderId) { + await viewModel.service.placeOrder(context: context, paymentParams: _selectedPaymentParams).then((orderId) { if (orderId.runtimeType == int) { // result == order_id - var browser = MyInAppBrowser( - context: context, - onExitCallback: (data, isDone) => paymentClosed( - orderId: orderId, withStatus: isDone, data: data)); - browser.openPackagesPaymentBrowser( - customer_id: viewModel.service.customer.id, order_id: orderId); + var browser = MyInAppBrowser(context: context, onExitCallback: (data, isDone) => paymentClosed(orderId: orderId, withStatus: isDone, data: data)); + browser.openPackagesPaymentBrowser(customer_id: viewModel.service.customer.id, order_id: orderId); } else { - utils.Utils.showErrorToast( - 'Failed to place order, please try again later'); + utils.Utils.showErrorToast('Failed to place order, please try again later'); } }).catchError((error) { utils.Utils.showErrorToast(error.toString()); @@ -111,56 +100,48 @@ class _PackagesCartPageState extends State isOfferPackages: true, showOfferPackagesCart: false, isShowDecPage: false, + showNewAppBar: true, + showNewAppBarTitle: true, body: Column( children: [ Expanded( - child: Padding( - padding: const EdgeInsets.all(5), - child: StaggeredGridView.countBuilder( - crossAxisCount: (_columnCount * _columnCount), - itemCount: viewModel.cartItemList.length, - itemBuilder: (BuildContext context, int index) { - var item = viewModel.cartItemList[index]; - return Dismissible( - key: Key(index.toString()), - direction: DismissDirection.startToEnd, - background: _cartItemDeleteContainer(), - secondaryBackground: _cartItemDeleteContainer(), - confirmDismiss: (direction) async { - bool status = await viewModel.service - .deleteProductFromCart(item.id, - context: context, showLoading: false); - return status; - }, - onDismissed: (direction) { - debugPrint('Index: $index'); - viewModel.cartItemList.removeAt(index); - }, - child: PackagesCartItemCard( - itemModel: item, - shouldStepperChangeApply: (apply, total) async { - var request = AddProductToCartRequestModel( - product_id: item.productId, - quantity: apply); - ResponseModel response = await viewModel - .service - .addProductToCart(request, - context: context, showLoading: false) - .catchError((error) { - utils.Utils.showErrorToast(error); - }); - if(response.status){ - fetchData(); - } - return response.status ?? false; - }, - )); - }, - staggeredTileBuilder: (int index) => - StaggeredTile.fit(_columnCount), - mainAxisSpacing: 0, - crossAxisSpacing: 10, - )), + child: StaggeredGridView.countBuilder( + crossAxisCount: (_columnCount * _columnCount), + itemCount: viewModel.cartItemList.length, + itemBuilder: (BuildContext context, int index) { + var item = viewModel.cartItemList[index]; + return Dismissible( + key: Key(index.toString()), + direction: DismissDirection.startToEnd, + background: _cartItemDeleteContainer(), + secondaryBackground: _cartItemDeleteContainer(), + confirmDismiss: (direction) async { + bool status = await viewModel.service.deleteProductFromCart(item.id, context: context, showLoading: false); + return status; + }, + onDismissed: (direction) { + viewModel.cartItemList.removeAt(index); + }, + child: PackagesCartItemCard( + itemModel: item, + viewModel: viewModel, + getCartItems: fetchData, + shouldStepperChangeApply: (apply, total) async { + var request = AddProductToCartRequestModel(product_id: item.productId, quantity: apply); + ResponseModel response = await viewModel.service.addProductToCart(request, context: context, showLoading: false).catchError((error) { + utils.Utils.showErrorToast(error); + }); + if (response.status) { + fetchData(); + } + return response.status ?? false; + }, + )); + }, + staggeredTileBuilder: (int index) => StaggeredTile.fit(_columnCount), + mainAxisSpacing: 0, + crossAxisSpacing: 10, + ), ), Container( height: 0.25, @@ -170,8 +151,7 @@ class _PackagesCartPageState extends State color: Colors.white, child: Column( children: [ - Texts(TranslationBase.of(context).selectPaymentOption, - fontSize: 10, fontWeight: FontWeight.bold), + Texts(TranslationBase.of(context).selectPaymentOption, fontSize: 10, fontWeight: FontWeight.bold), Container( height: 0.25, width: 100, @@ -184,11 +164,7 @@ class _PackagesCartPageState extends State height: 0.25, color: Colors.grey[300], ), - Container( - height: 40, - child: _termsAndCondition(context, - onSelected: onTermsClick, - onInfoClick: onTermsInfoClick)), + Container(height: 40, child: _termsAndCondition(context, onSelected: onTermsClick, onInfoClick: onTermsInfoClick)), Container( height: 0.25, color: Colors.grey[300], @@ -204,7 +180,7 @@ class _PackagesCartPageState extends State } fetchData() async { - await viewModel.service.cartItems(context: context).then((value){ + await viewModel.service.cartItems(context: context).then((value) { subtotal = value['subtotal'] ?? 0.0; tax = value['tax'] ?? 0.0; total = value['total'] ?? 0.0; @@ -213,15 +189,12 @@ class _PackagesCartPageState extends State setState(() {}); } - paymentClosed( - {@required int orderId, @required bool withStatus, dynamic data}) async { + paymentClosed({@required int orderId, @required bool withStatus, dynamic data}) async { viewModel.service.getOrderById(orderId, context: context).then((value) { var heading = withStatus ? "Success" : "Failed"; - var title = withStatus ? "Your order has been placed successfully" : "Failed to place your order"; + var title = withStatus ? "Your order has been placed successfully" : "Failed to place your order"; var subTitle = "Order# ${value.data.customOrderNumber}"; - Navigator.of(context).pushReplacement(MaterialPageRoute( - builder: (context) => PackageOrderCompletedPage( - heading: heading, title: title, subTitle: subTitle))); + Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (context) => PackageOrderCompletedPage(heading: heading, title: title, subTitle: subTitle))); }).catchError((error) { debugPrint(error); }); @@ -231,7 +204,8 @@ class _PackagesCartPageState extends State // /* Payment Footer Widgets */ // --------------------------- String _selectedPaymentMethod; -Map _selectedPaymentParams; +Map _selectedPaymentParams; + Widget _paymentOptions(BuildContext context, Function(String) onSelected, {PackagesViewModel viewModel}) { double height = 30; @@ -247,18 +221,17 @@ Widget _paymentOptions(BuildContext context, Function(String) onSelected, {Packa ), ], borderRadius: BorderRadius.all(Radius.circular(5)), - border: Border.all( - color: isSelected ? Colors.green : Colors.grey, - width: isSelected ? 1 : 0.5)), + border: Border.all(color: isSelected ? Colors.green : Colors.grey, width: isSelected ? 1 : 0.5)), child: Padding( padding: const EdgeInsets.all(4), child: Image.asset('assets/images/new-design/$imageName'), )); } - - Future selectTamaraPaymentOption() async{ + + Future selectTamaraPaymentOption() async { final tamara_options = await viewModel.service.getTamaraOptions(context: context, showLoading: true); - final selected = await SingleSelectionDialog(tamara_options, icon: Image.asset('assets/images/new-design/tamara.png'), title: TranslationBase.of(context).tamaraInstPlan).show(context); + final selected = + await SingleSelectionDialog(tamara_options, icon: Image.asset('assets/images/new-design/tamara.png'), title: TranslationBase.of(context).tamaraInstPlan).show(context); return selected.name; } @@ -272,9 +245,9 @@ Widget _paymentOptions(BuildContext context, Function(String) onSelected, {Packa children: [ InkWell( child: buttonContent(_selectedPaymentMethod == "tamara", 'tamara.png'), - onTap: () async{ + onTap: () async { final tamara_option = await selectTamaraPaymentOption(); - _selectedPaymentParams = {"channel" : "Web", "payment_method_system_name" : "Payments.Tamara", "payment_option" : tamara_option}; + _selectedPaymentParams = {"channel": "Web", "payment_method_system_name": "Payments.Tamara", "payment_option": tamara_option}; onSelected("tamara"); }, ), @@ -284,7 +257,7 @@ Widget _paymentOptions(BuildContext context, Function(String) onSelected, {Packa InkWell( child: buttonContent(_selectedPaymentMethod == "mada", 'mada.png'), onTap: () { - _selectedPaymentParams = {"payment_method_system_name" : "Payments.PayFort", "payment_option" : "MADA"}; + _selectedPaymentParams = {"payment_method_system_name": "Payments.PayFort", "payment_option": "MADA"}; onSelected("mada"); }, ), @@ -294,7 +267,7 @@ Widget _paymentOptions(BuildContext context, Function(String) onSelected, {Packa InkWell( child: buttonContent(_selectedPaymentMethod == "visa", 'visa.png'), onTap: () { - _selectedPaymentParams = {"payment_method_system_name" : "Payments.PayFort", "payment_option" : "VISA"}; + _selectedPaymentParams = {"payment_method_system_name": "Payments.PayFort", "payment_option": "VISA"}; onSelected("visa"); }, ), @@ -304,7 +277,7 @@ Widget _paymentOptions(BuildContext context, Function(String) onSelected, {Packa InkWell( child: buttonContent(_selectedPaymentMethod == "mastercard", 'mastercard.png'), onTap: () { - _selectedPaymentParams = {"payment_method_system_name" : "Payments.PayFort", "payment_option" : "MASTERCARD"}; + _selectedPaymentParams = {"payment_method_system_name": "Payments.PayFort", "payment_option": "MASTERCARD"}; onSelected("mastercard"); }, ), @@ -326,17 +299,15 @@ Widget _paymentOptions(BuildContext context, Function(String) onSelected, {Packa } bool _agreeTerms = false; -Widget _termsAndCondition(BuildContext context, - {@required Function(bool) onSelected, @required VoidCallback onInfoClick}) { + +Widget _termsAndCondition(BuildContext context, {@required Function(bool) onSelected, @required VoidCallback onInfoClick}) { return Padding( padding: const EdgeInsets.all(5), child: Row( children: [ InkWell( child: Icon( - _agreeTerms - ? Icons.check_circle - : Icons.radio_button_unchecked_sharp, + _agreeTerms ? Icons.check_circle : Icons.radio_button_unchecked_sharp, size: 20, color: _agreeTerms ? Colors.green[600] : Colors.grey[400], ), @@ -386,18 +357,8 @@ Widget _payNow(BuildContext context, {double subtotal, double tax, double total, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts( - '${TranslationBase.of(context).subtotal}: $_subtotal ${TranslationBase.of(context).sar}', - heightFactor: 1.5, - fontWeight: FontWeight.bold, - color: Colors.grey, - fontSize: 8), - Texts( - '${TranslationBase.of(context).vat}: $_tax ${TranslationBase.of(context).sar}', - heightFactor: 1.5, - fontWeight: FontWeight.bold, - color: Colors.grey, - fontSize: 8), + Texts('${TranslationBase.of(context).subtotal}: $_subtotal ${TranslationBase.of(context).sar}', heightFactor: 1.5, fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 8), + Texts('${TranslationBase.of(context).vat}: $_tax ${TranslationBase.of(context).sar}', heightFactor: 1.5, fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 8), Padding( padding: const EdgeInsets.all(3), child: Container( @@ -406,12 +367,7 @@ Widget _payNow(BuildContext context, {double subtotal, double tax, double total, color: Colors.grey[300], ), ), - Texts( - '${TranslationBase.of(context).total}: $_total ${TranslationBase.of(context).sar}', - heightFactor: 1.5, - fontWeight: FontWeight.bold, - color: Colors.black54, - fontSize: 15) + Texts('${TranslationBase.of(context).total}: $_total ${TranslationBase.of(context).sar}', heightFactor: 1.5, fontWeight: FontWeight.bold, color: Colors.black54, fontSize: 15) ], ), ), @@ -425,10 +381,7 @@ Widget _payNow(BuildContext context, {double subtotal, double tax, double total, fontWeight: FontWeight.bold, ), padding: EdgeInsets.only(top: 5, bottom: 5, left: 0, right: 0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5), - side: BorderSide( - color: Theme.of(context).primaryColor, width: 0.5)), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5), side: BorderSide(color: Theme.of(context).primaryColor, width: 0.5)), color: Theme.of(context).primaryColor, onPressed: isPayNowAQctive ? onPayNowClick : null, ), diff --git a/lib/pages/packages_offers/OfferAndPackagesPage.dart b/lib/pages/packages_offers/OfferAndPackagesPage.dart index 063cc541..d323b36d 100644 --- a/lib/pages/packages_offers/OfferAndPackagesPage.dart +++ b/lib/pages/packages_offers/OfferAndPackagesPage.dart @@ -12,24 +12,20 @@ import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.da import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/packages_offers/ClinicOfferAndPackagesPage.dart'; -import 'package:diplomaticquarterapp/pages/packages_offers/CreateCustomerDailogPage.dart'; -import 'package:diplomaticquarterapp/pages/packages_offers/OfferAndPackageDetailPage.dart'; import 'package:diplomaticquarterapp/pages/packages_offers/OfferAndPackagesCartPage.dart'; import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart' as auth; -import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart' as utils; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/offers_packages/PackagesOfferCard.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; class PackagesHomePage extends StatefulWidget { @@ -48,6 +44,7 @@ class _PackagesHomePageState extends State { void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + viewModel.service.patientUser = widget.user; viewModel.service.loadOffersPackagesDataForMainPage( context: context, completion: () { @@ -111,11 +108,8 @@ class _PackagesHomePageState extends State { body: SingleChildScrollView( child: Column( children: [ - SizedBox( - height: 10, - ), Padding( - padding: const EdgeInsets.all(21), + padding: projectViewModel.isArabic ? const EdgeInsets.only(top: 21, right: 21, bottom: 21) : const EdgeInsets.only(top: 21, left: 21, bottom: 21), child: Column( children: [ inputWidget(TranslationBase.of(context).search, "", _searchTextController, isInputTypeNum: false), @@ -126,6 +120,7 @@ class _PackagesHomePageState extends State { onTap: () => showClinicSelectionList(), child: Container( padding: EdgeInsets.all(12), + margin: projectViewModel.isArabic ? const EdgeInsets.only(left: 21) : const EdgeInsets.only(right: 21), width: double.infinity, height: 65, decoration: BoxDecoration( @@ -139,7 +134,7 @@ class _PackagesHomePageState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - selectedClinic != null ? selectedClinic.name : "Browse offers by clinic", + selectedClinic != null ? selectedClinic.name : TranslationBase.of(context).browseOffers, style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, @@ -218,15 +213,16 @@ class _PackagesHomePageState extends State { children: [ Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0), - child: Icon( - Icons.add_shopping_cart_rounded, - size: 30.0, - color: Colors.white, - ), + child: SvgPicture.asset("assets/images/new/cart.svg"), + // child: Icon( + // Icons.add_shopping_cart_rounded, + // size: 30.0, + // color: Colors.white, + // ), ), Container( child: Text( - TranslationBase.of(context).shoppingCart, + TranslationBase.of(context).myCart, textAlign: TextAlign.center, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.48), ), @@ -315,7 +311,9 @@ class _PackagesHomePageState extends State { Widget separator(BuildContext context, int index) { return Container( width: 1, - decoration: BoxDecoration(gradient: LinearGradient(begin: Alignment(-1.0, -2.0), end: Alignment(1.0, 4.0), colors: [Colors.grey, Colors.grey[100], Colors.grey[200], Colors.grey[300], Colors.grey[400], Colors.grey[500]])), + decoration: BoxDecoration( + gradient: + LinearGradient(begin: Alignment(-1.0, -2.0), end: Alignment(1.0, 4.0), colors: [Colors.grey, Colors.grey[100], Colors.grey[200], Colors.grey[300], Colors.grey[400], Colors.grey[500]])), ); } @@ -346,9 +344,11 @@ class _PackagesHomePageState extends State { } } - Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {VoidCallback suffixTap, bool isEnable = true, bool hasSelection = false, int lines, bool isInputTypeNum = false}) { + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, + {VoidCallback suffixTap, bool isEnable = true, bool hasSelection = false, int lines, bool isInputTypeNum = false}) { return Container( padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + margin: projectViewModel.isArabic ? const EdgeInsets.only(left: 21) : const EdgeInsets.only(right: 21), alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.circular(15), diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index b15f7adb..492eab10 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -509,7 +509,7 @@ class TranslationBase { String get switchUser => localizedValues['switch-login'][locale.languageCode]; - String get removeMember => localizedValues['remove-membe'][locale.languageCode]; + String get removeMember => localizedValues['remove-member'][locale.languageCode]; String get allowView => localizedValues['allow-view'][locale.languageCode]; @@ -2618,6 +2618,10 @@ class TranslationBase { String get RRTSubTitle => localizedValues["RRTSubTitle"][locale.languageCode]; String get transportation => localizedValues["transportation"][locale.languageCode]; + + String get browseOffers => localizedValues["browseOffers"][locale.languageCode]; + + String get myCart => localizedValues["myCart"][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/offers_packages/PackagesCartItemCard.dart b/lib/widgets/offers_packages/PackagesCartItemCard.dart index ddca9d90..10c7e5b1 100644 --- a/lib/widgets/offers_packages/PackagesCartItemCard.dart +++ b/lib/widgets/offers_packages/PackagesCartItemCard.dart @@ -1,217 +1,136 @@ import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesCartItemsResponseModel.dart'; import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesResponseModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/packages_offers/PackagesOffersViewModel.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/CounterView.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - +import 'package:flutter_svg/flutter_svg.dart'; bool wide = true; class PackagesCartItemCard extends StatefulWidget { final PackagesCartItemsResponseModel itemModel; - final StepperCallbackFuture shouldStepperChangeApply ; + final StepperCallbackFuture shouldStepperChangeApply; + final PackagesViewModel viewModel; + final Function getCartItems; - const PackagesCartItemCard( - { - @required this.itemModel, - @required this.shouldStepperChangeApply, - Key key}) - : super(key: key); + const PackagesCartItemCard({@required this.itemModel, @required this.shouldStepperChangeApply, @required this.viewModel, this.getCartItems, Key key}) : super(key: key); @override State createState() => PackagesCartItemCardState(); } class PackagesCartItemCardState extends State { - @override Widget build(BuildContext context) { - wide = !wide; return Container( - color: Colors.transparent, - child: Card( - elevation: 3, - shadowColor: Colors.grey[100], - color: Colors.white, - child: Stack( - children: [ - Container( - height: 100, - child: Row( - children: [ - _image(widget.itemModel.product), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, + decoration: cardRadius(15.0), + margin: EdgeInsets.only(left: 21.0, right: 21.0, top: 12.0), + height: 90, + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + _image(widget.itemModel.product), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _itemName(widget.itemModel.product.getName()), + _itemDescription(widget.itemModel.product.shortDescription), + Container( + padding: const EdgeInsets.only(top: 12.0), + width: MediaQuery.of(context).size.width * 0.65, + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + _itemPrice(widget.itemModel.product.price, context: context), + InkWell( + onTap: () async { + await widget.viewModel.service.deleteProductFromCart(widget.itemModel.id, context: context, showLoading: false); + widget.getCartItems(); + }, + child: Row( children: [ - _itemName(widget.itemModel.product.getName()), - Row( - children: [ - _itemPrice(widget.itemModel.product.price, context: context), - _priceSeperator(), - _itemOldPrice(widget.itemModel.product.oldPrice, context: context), - ], - ), - Row( - children: [ - _itemCounter( - widget.itemModel.quantity, - minQuantity: widget.itemModel.product.orderMinimumQuantity, - maxQuantity: widget.itemModel.product.orderMaximumQuantity, - shouldStepperChangeApply: (apply,total) async{ - bool success = await widget.shouldStepperChangeApply(apply,total); - if(success == true) - setState(() => widget.itemModel.quantity = total); - return success; - } + Padding( + padding: const EdgeInsets.only(left: 5.0, right: 5.0), + child: Text( + TranslationBase.of(context).removeMember, + style: TextStyle( + fontSize: 10, + color: CustomColors.accentColor, + fontWeight: FontWeight.w600, + letterSpacing: -0.36, ), - ], + ), ), + SvgPicture.asset("assets/images/new-design/delete.svg", color: CustomColors.accentColor), ], - ) - ], - ), + ), + ), + ], ), - - // Positioned( - // bottom: 8, - // left: 10, - // child: Row( - // children: [ - // _totalLabel(context: context), - // _totalPrice((widget.itemModel.product.price * widget.itemModel.quantity), context: context), - // ], - // ), - // ) - ], - ) - ) + ), + ], + ) + ], + ), ); } } - -// -------------------- -// Product Image -// -------------------- Widget _image(PackagesResponseModel model) => AspectRatio( - aspectRatio: 1/1, - child: Padding( - padding: const EdgeInsets.all(10), - child: Container( - decoration: BoxDecoration( - border: Border.all(color: Colors.grey[300], width: 0.25), - boxShadow: [ - BoxShadow(color: Colors.grey[200], blurRadius: 2.0, spreadRadius: 1, offset: Offset(1,1.5)) - ], - borderRadius: BorderRadius.circular(8), - color: Colors.white, - shape: BoxShape.rectangle, - ), - child: ClipRRect( - borderRadius: BorderRadius.circular(8), - child: (model.images.isNotEmpty) - ? Utils.loadNetworkImage(url: model.images.first.src, fitting:BoxFit.fill) - : Container(color: Colors.grey[200]) + aspectRatio: 1 / 1, + child: Padding( + padding: const EdgeInsets.all(9), + child: Container( + decoration: BoxDecoration( + border: Border.all(color: Colors.grey[300], width: 0.25), + boxShadow: [BoxShadow(color: Colors.grey[200], blurRadius: 2.0, spreadRadius: 1, offset: Offset(1, 1.5))], + borderRadius: BorderRadius.circular(15), + color: Colors.white, + shape: BoxShape.rectangle, + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(15), + child: (model.images.isNotEmpty) ? Utils.loadNetworkImage(url: model.images.first.src, fitting: BoxFit.fill) : Container(color: Colors.grey[200])), + ), ), - ), - ), -); + ); -// -------------------- -// Product Name -// -------------------- Widget _itemName(String name) => Padding( - padding: const EdgeInsets.all(0), - child: Texts( - name, - fontWeight: FontWeight.normal, - color: Colors.black, - fontSize: 15 - ) -); - + padding: const EdgeInsets.only(top: 9.0), + child: Text(name, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + letterSpacing: -0.56, + ))); + +Widget _itemDescription(String desc) => Padding( + padding: const EdgeInsets.only(top: 0.0), + child: Text(desc, + style: TextStyle( + fontSize: 10, + // fontWeight: FontWeight.bold, + letterSpacing: -0.4, + ))); Widget _itemPrice(double price, {@required BuildContext context}) { final prc = (price ?? 0.0).toStringAsFixed(2); return Padding( padding: const EdgeInsets.all(0), - child: Texts( - '${prc} ${TranslationBase.of(context).sar}', - fontWeight: FontWeight.bold, - color: Colors.green, - fontSize: 15 - ) -); -} - - -// -------------------- -// Price Seperator -// -------------------- -Widget _priceSeperator() => Padding( - padding: const EdgeInsets.only(left: 3, right: 3), - child: Container(height: 0.5, width: 5, color: Colors.grey[100],), -); - - -// -------------------- -// Product Price -// -------------------- -Widget _itemOldPrice(double oldPrice, {@required BuildContext context}) { - final prc = (oldPrice ?? 0.0).toStringAsFixed(2); - return Padding( - padding: const EdgeInsets.all(0), - child: Texts( - '${prc} ${TranslationBase.of(context).sar}', - fontWeight: FontWeight.normal, - decoration: TextDecoration.lineThrough, - color: Colors.grey, - fontSize: 10 - ) -); + child: Text( + '${prc} ${TranslationBase.of(context).sar}', + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + letterSpacing: -0.4, + ), + ), + ); } - -// -------------------- -// Product Price -// -------------------- -Widget _itemCounter(int quantity, {int minQuantity, int maxQuantity, StepperCallbackFuture shouldStepperChangeApply}) => Padding( - padding: const EdgeInsets.all(0), - child: StepperView( - height: 25, - backgroundColor: Colors.grey[300], - foregroundColor: Colors.grey[200], - initialNumber: quantity, - minNumber: minQuantity, - maxNumber: maxQuantity, - counterCallback: shouldStepperChangeApply, - decreaseCallback: (){}, - increaseCallback: (){}, - ) -); - - -Widget _totalLabel({@required BuildContext context}) => Padding( - padding: const EdgeInsets.all(0), - child: Texts( - '${TranslationBase.of(context).totalWithColonRight}', - fontWeight: FontWeight.bold, - color: Colors.grey[600], - fontSize: 13 - ) -); - - -Widget _totalPrice(double totalPrice, {@required BuildContext context}) => Padding( - padding: const EdgeInsets.all(0), - child: Texts( - '${totalPrice.toStringAsFixed(2)} ${TranslationBase.of(context).sar}', - fontWeight: FontWeight.normal, - color: Colors.green, - ) -); - diff --git a/lib/widgets/offers_packages/PackagesOfferCard.dart b/lib/widgets/offers_packages/PackagesOfferCard.dart index 470550c6..be756caf 100644 --- a/lib/widgets/offers_packages/PackagesOfferCard.dart +++ b/lib/widgets/offers_packages/PackagesOfferCard.dart @@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'package:rating_bar/rating_bar.dart'; bool wide = true; @@ -33,7 +34,7 @@ class PackagesItemCardState extends State { wide = !wide; return InkWell( onTap: () { - Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) => OfferAndPackagesDetail(itemModel: widget.itemModel))); + Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) => OfferAndPackagesDetail(itemModel: widget.itemModel, onCartClick: widget.onCartClick))); }, child: Container( // width: widget.itemWidth, @@ -73,11 +74,7 @@ class PackagesItemCardState extends State { ], ), InkWell( - child: Icon( - Icons.add_shopping_cart_rounded, - size: 30.0, - color: Colors.black, - ), + child: SvgPicture.asset("assets/images/new/add-to-cart.svg"), onTap: () { widget.onCartClick(widget.itemModel); }, @@ -89,80 +86,5 @@ class PackagesItemCardState extends State { ), ), ); - // Stack( - // children: [ - // Column( - // mainAxisSize: MainAxisSize.max, - // children: [ - // AspectRatio( - // aspectRatio:1 / 1, - // child: applyShadow( - // child: ClipRRect( - // borderRadius: BorderRadius.circular(10), - // child: Utils.loadNetworkImage( - // url: imageUrl(), - // )), - // )), - // Texts( - // widget.itemModel.getName(), - // fontWeight: FontWeight.normal, - // color: Colors.black, - // fontSize: 15 - // ), - // Padding( - // padding: const EdgeInsets.only(left: 10, right: 10), - // child: Row( - // crossAxisAlignment: CrossAxisAlignment.end, - // mainAxisSize: MainAxisSize.max, - // children: [ - // Stack( - // children: [ - // Texts( - // '${widget.itemModel.oldPrice} ${'SAR'}', - // fontWeight: FontWeight.normal, - // decoration: TextDecoration.lineThrough, - // color: Colors.grey, - // fontSize: 12 - // ), - // Padding( - // padding: const EdgeInsets.only(top: 8), - // child: Texts( - // '${widget.itemModel.price} ${'SAR'}', - // fontWeight: FontWeight.bold, - // color: Colors.green, - // fontSize: 18 - // ), - // ), - // Padding( - // padding: const EdgeInsets.only(top: 35), - // child: StarRating( - // size: 15, - // totalCount: null, - // totalAverage: widget.itemModel.approvedRatingSum.toDouble(), - // forceStars: true), - // ) - // ], - // ), - // Spacer( - // flex: 1, - // ), - // InkWell( - // child: Icon( - // Icons.add_shopping_cart_rounded, - // size: 30.0, - // color: Colors.grey, - // ), - // onTap: () { - // widget.onCartClick(widget.itemModel); - // }, - // ), - // ], - // ), - // ), - // ], - // ), - // ], - // ), - // ); } } From d2834bb3dde06a649b186ff39304b5d221717c0d Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 8 Nov 2021 18:30:05 +0300 Subject: [PATCH 29/70] Health calculator fixes --- .../bmi_calculator/bmi_calculator.dart | 16 +-- .../bmi_calculator/result_page.dart | 124 +++++++++++++----- .../bmr_calculator/bmr_calculator.dart | 30 ++--- .../bmr_calculator/bmr_result_page.dart | 50 +++---- .../health_calculator/body_fat/body_fat.dart | 10 +- .../calorie_calculator.dart | 20 +-- .../calorie_result_page.dart | 21 +-- .../ideal_body/ideal_body.dart | 11 +- 8 files changed, 137 insertions(+), 145 deletions(-) diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart index c06d77db..86382fe7 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart @@ -99,23 +99,9 @@ class _BMICalculatorState extends State { return AppScaffold( isShowAppBar: true, isShowDecPage: false, - showHomeAppBarIcon: false, + showHomeAppBarIcon: true, showNewAppBar: true, showNewAppBarTitle: true, - appBarIcons: [ - IconButton( - icon: Icon(Icons.info_outline), - color: Colors.black, - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => HealthDescPage("${TranslationBase.of(context).bmi} ${TranslationBase.of(context).calcHealth}", TranslationBase.of(context).bmiCalcDesc, - "assets/images/AlHabibMedicalService/health_calculator/bmi.png")), - ); - }, - ) - ], appBarTitle: "${TranslationBase.of(context).bmi} ${TranslationBase.of(context).calcHealth}", body: Column( children: [ diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/result_page.dart index 68126b4d..81fba296 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/result_page.dart @@ -1,49 +1,58 @@ +import 'dart:collection'; + import 'package:auto_size_text/auto_size_text.dart'; -import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bariatrics-screen.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; +import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.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/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; 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/svg.dart'; -import 'package:percent_indicator/percent_indicator.dart'; -class ResultPage extends StatelessWidget { +class ResultPage extends StatefulWidget { final double finalResult; final String textResult; final String msg; ResultPage({this.finalResult, this.textResult, this.msg}); + @override + _ResultPageState createState() => _ResultPageState(); +} + +class _ResultPageState extends State { Color inductorColor; + double percent; Color colorInductor() { - if (finalResult >= 30) { + if (widget.finalResult >= 30) { inductorColor = Color(0xffC70D00); - } else if (finalResult < 30 && finalResult >= 25) { + } else if (widget.finalResult < 30 && widget.finalResult >= 25) { inductorColor = Color(0xffC25400); - } else if (finalResult < 25 && finalResult >= 18.5) { + } else if (widget.finalResult < 25 && widget.finalResult >= 18.5) { inductorColor = Color(0xff36D600); - } else if (finalResult < 18.5) { + } else if (widget.finalResult < 18.5) { inductorColor = Color(0xff1BE0EE); } return inductorColor; } double percentInductor() { - if (finalResult >= 30) { + if (widget.finalResult >= 30) { percent = 1.0; - } else if (finalResult < 30 && finalResult >= 25) { + } else if (widget.finalResult < 30 && widget.finalResult >= 25) { percent = 0.73; - } else if (finalResult < 25 && finalResult >= 18.5) { + } else if (widget.finalResult < 25 && widget.finalResult >= 18.5) { percent = 0.5; - } else if (finalResult < 18.5) { + } else if (widget.finalResult < 18.5) { percent = 0.25; } return percent; @@ -69,7 +78,7 @@ class ResultPage extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Text( - TranslationBase.of(context).bodyMassIndex + finalResult.toString(), + TranslationBase.of(context).bodyMassIndex + widget.finalResult.toString(), style: TextStyle( fontSize: 16, letterSpacing: -0.64, @@ -81,21 +90,21 @@ class ResultPage extends StatelessWidget { height: MediaQuery.of(context).size.width / 2.8, child: Row( children: [ - showMass(context, TranslationBase.of(context).underWeight, "< 18.5", finalResult <= 18.5 ? Colors.red : Colors.black, 8), + showMass(context, TranslationBase.of(context).underWeight, "< 18.5", widget.finalResult <= 18.5 ? Colors.red : Colors.black, 8), mWidth(12), - showMass(context, TranslationBase.of(context).healthy, "18.5 - 24.9", (finalResult > 18.5 && finalResult < 25) ? Colors.red : Colors.black, 6), + showMass(context, TranslationBase.of(context).healthy, "18.5 - 24.9", (widget.finalResult > 18.5 && widget.finalResult < 25) ? Colors.red : Colors.black, 6), mWidth(12), - showMass(context, TranslationBase.of(context).overWeight, "25 - 29.9", (finalResult >= 25 && finalResult < 30) ? Colors.red : Colors.black, 4), + showMass(context, TranslationBase.of(context).overWeight, "25 - 29.9", (widget.finalResult >= 25 && widget.finalResult < 30) ? Colors.red : Colors.black, 4), mWidth(12), - showMass(context, TranslationBase.of(context).obese, "30 - 34.9", (finalResult >= 30 && finalResult < 35) ? Colors.red : Colors.black, 2), + showMass(context, TranslationBase.of(context).obese, "30 - 34.9", (widget.finalResult >= 30 && widget.finalResult < 35) ? Colors.red : Colors.black, 2), mWidth(12), - showMass(context, TranslationBase.of(context).extremeObese, "> 35", (finalResult >= 35) ? Colors.red : Colors.black, 0), + showMass(context, TranslationBase.of(context).extremeObese, "> 35", (widget.finalResult >= 35) ? Colors.red : Colors.black, 0), ], ), ), mHeight(20), Text( - textResult, + widget.textResult, style: TextStyle( fontSize: 16.0, fontWeight: FontWeight.w600, @@ -104,7 +113,7 @@ class ResultPage extends StatelessWidget { ), mHeight(4), Text( - msg, + widget.msg, style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600, letterSpacing: -0.56, color: CustomColors.textColor), ), ], @@ -115,14 +124,10 @@ class ResultPage extends StatelessWidget { Container( color: Colors.white, padding: EdgeInsets.all(16), - child: SecondaryButton( - label: TranslationBase.of(context).seeListOfDoctor, - color: CustomColors.accentColor, - onTap: () { - Navigator.push( - context, - FadePage(page: BariatricsPage(1, 1, finalResult)), - ); + child: DefaultButton( + TranslationBase.of(context).seeListOfDoctor, + () { + callDoctorsSearchAPI(); }, ), ), @@ -131,6 +136,65 @@ class ResultPage extends StatelessWidget { ); } + callDoctorsSearchAPI() { + GifLoaderDialogUtils.showMyDialog(context); + List doctorsList = []; + List arr = []; + List arrDistance = []; + List result; + int numAll; + List _patientDoctorAppointmentListHospital = List(); + + DoctorsListService service = new DoctorsListService(); + service.getDoctorsList(108, 0, false, context).then((res) { + GifLoaderDialogUtils.hideDialog(context); + if (res['MessageStatus'] == 1) { + setState(() { + if (res['DoctorList'].length != 0) { + doctorsList.clear(); + res['DoctorList'].forEach((v) { + doctorsList.add(new DoctorList.fromJson(v)); + }); + doctorsList.forEach((element) { + List doctorByHospital = _patientDoctorAppointmentListHospital + .where( + (elementClinic) => elementClinic.filterName == element.projectName, + ) + .toList(); + + if (doctorByHospital.length != 0) { + _patientDoctorAppointmentListHospital[_patientDoctorAppointmentListHospital.indexOf(doctorByHospital[0])].patientDoctorAppointmentList.add(element); + } else { + _patientDoctorAppointmentListHospital + .add(PatientDoctorAppointmentList(filterName: element.projectName, distanceInKMs: element.projectDistanceInKiloMeters.toString(), patientDoctorAppointment: element)); + } + }); + } else {} + }); + + result = LinkedHashSet.from(arr).toList(); + numAll = result.length; + navigateToSearchResults(context, doctorsList, _patientDoctorAppointmentListHospital); + } else { + AppToast.showErrorToast(message: res['ErrorEndUserMessage']); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + AppToast.showErrorToast(message: err); + }); + } + + Future navigateToSearchResults(context, List docList, List patientDoctorAppointmentListHospital) async { + Navigator.push(context, FadePage(page: SearchResults(isLiveCareAppointment: false, doctorsList: docList, patientDoctorAppointmentListHospital: patientDoctorAppointmentListHospital))) + .then((value) { + setState(() { + // dropdownValue = null; + }); + // getProjectsList(); + }); + } + Widget showMass(BuildContext context, String title, String weight, Color color, int f) { return Expanded( flex: 1, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart index 3512b4de..a2d96d89 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart @@ -2,8 +2,7 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -148,16 +147,7 @@ class _BmrCalculatorState extends State { showNewAppBarTitle: true, showNewAppBar: true, appBarTitle: TranslationBase.of(context).bmr, - showHomeAppBarIcon: false, - appBarIcons: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 7.0), - child: Icon( - Icons.info_outline, - color: Colors.white, - ), - ) - ], + showHomeAppBarIcon: true, body: Container( height: double.infinity, width: double.infinity, @@ -406,22 +396,20 @@ class _BmrCalculatorState extends State { Container( margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), color: Colors.white, - child: SecondaryButton( - label: TranslationBase.of(context).calculate, - color: CustomColors.accentColor, - onTap: () { + child: DefaultButton( + TranslationBase.of(context).calculate, + () { setState(() { calculateBmr(); calculateCalories(); - { Navigator.push( context, FadePage( page: BmrResultPage( - bmrResult: bmrResult, - calories: calories, - )), + bmrResult: bmrResult, + calories: calories, + )), ); } }); @@ -661,5 +649,3 @@ class CommonDropDownView extends StatelessWidget { ); } } - - diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_result_page.dart index 53426f94..aee77829 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_result_page.dart @@ -5,9 +5,7 @@ import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -26,6 +24,7 @@ class BmrResultPage extends StatelessWidget { isShowDecPage: false, showNewAppBarTitle: true, showNewAppBar: true, + showHomeAppBarIcon: true, appBarTitle: TranslationBase.of(context).bmr, body: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, @@ -80,31 +79,23 @@ class BmrResultPage extends StatelessWidget { ), mHeight(20), Text( - 'This means the body will burn ( ${bmrResult.toStringAsFixed(1)} ) calories each day, if engaged in no activity for the entire day.. Note: Daily calorie requirement is ( ${calories.toStringAsFixed(1)} ) calories, to maintain the current weight.', - style: TextStyle( - fontSize: 14, - letterSpacing: -0.56, - fontWeight: FontWeight.w600, - color: CustomColors.textColor - ), + 'This means the body will burn (${bmrResult.toStringAsFixed(1)}) calories each day, if engaged in no activity for the entire day.. Note: Daily calorie requirement is (${calories.toStringAsFixed(1)}) calories, to maintain the current weight.', + style: TextStyle(fontSize: 14, letterSpacing: -0.56, fontWeight: FontWeight.w600, color: CustomColors.textColor), ), ], ).withBorderedContainer, ), mFlex(1), - Container( margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), color: Colors.white, - child: SecondaryButton( - label: TranslationBase.of(context).viewDocList, - color: CustomColors.accentColor, - onTap: () { + child: DefaultButton( + TranslationBase.of(context).viewDocList, + () { getDoctorsList(context); }, ), ), - ], ), ); @@ -163,18 +154,19 @@ class BmrResultPage extends StatelessWidget { }); } } + extension BorderedContainer on Widget { Widget get withBorderedContainer => Container( - padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(15), - color: Colors.white, - border: Border.all( - color: Color(0xffefefef), - width: 1, - ), - ), - child: this, - ); -} \ No newline at end of file + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: this, + ); +} diff --git a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart index 1442afbd..22f915b0 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart @@ -227,16 +227,8 @@ class _BodyFatState extends State { isShowDecPage: false, showNewAppBarTitle: true, showNewAppBar: true, + showHomeAppBarIcon: true, appBarTitle: TranslationBase.of(context).bodyFatTitle, - appBarIcons: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 7.0), - child: Icon( - Icons.info_outline, - color: Colors.white, - ), - ) - ], body: Column( children: [ Expanded( diff --git a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart index 74db1a30..2052e58f 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart @@ -2,8 +2,8 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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'; @@ -85,16 +85,8 @@ class _CalorieCalculatorState extends State { isShowDecPage: false, showNewAppBar: true, showNewAppBarTitle: true, + showHomeAppBarIcon: true, appBarTitle: "${TranslationBase.of(context).calories} ${TranslationBase.of(context).calcHealth}", - appBarIcons: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 7.0), - child: Icon( - Icons.info_outline, - color: Colors.black, - ), - ) - ], body: Column( children: [ Expanded( @@ -261,7 +253,6 @@ class _CalorieCalculatorState extends State { SizedBox( height: 12.0, ), - InkWell( onTap: () { // dropdownKey.currentState; @@ -337,10 +328,9 @@ class _CalorieCalculatorState extends State { Container( margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), color: Colors.white, - child: SecondaryButton( - label: TranslationBase.of(context).calculate, - color: CustomColors.accentColor, - onTap: () { + child: DefaultButton( + TranslationBase.of(context).calculate, + () { setState(() { calculateCalories(); print(calories); diff --git a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart index dc27e051..ec19a91e 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart @@ -5,9 +5,7 @@ import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -75,18 +73,13 @@ class CalorieResultPage extends StatelessWidget { ], ), progressColor: CustomColors.accentColor, - backgroundColor: Colors.white, + backgroundColor: CustomColors.darkGreyColor, ), ), mHeight(20), Text( 'Daily intake is ${calorie.toStringAsFixed(1)} calories', - style: TextStyle( - fontSize: 14, - letterSpacing: -0.56, - fontWeight: FontWeight.w600, - color: CustomColors.textColor - ), + style: TextStyle(fontSize: 14, letterSpacing: -0.56, fontWeight: FontWeight.w600, color: CustomColors.textColor), ), ], ).withBorderedContainer, @@ -95,15 +88,13 @@ class CalorieResultPage extends StatelessWidget { Container( margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), color: Colors.white, - child: SecondaryButton( - label: TranslationBase.of(context).viewDocList, - color: CustomColors.accentColor, - onTap: () { + child: DefaultButton( + TranslationBase.of(context).viewDocList, + () { getDoctorsList(context); }, ), ), - ], ), ); diff --git a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart index e414f028..7e4e3b4f 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart @@ -84,16 +84,7 @@ class _IdealBodyState extends State { showNewAppBarTitle: true, showNewAppBar: true, appBarTitle: TranslationBase.of(context).idealBody, - showHomeAppBarIcon: false, - appBarIcons: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 7.0), - child: Icon( - Icons.info_outline, - color: Colors.white, - ), - ) - ], + showHomeAppBarIcon: true, body: Column( children: [ Expanded( From 90b821a37d14d2fbf9e827851364da5afd625996 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 9 Nov 2021 12:43:36 +0300 Subject: [PATCH 30/70] Offers & packages UI completed --- lib/core/service/client/base_app_client.dart | 3 +- .../PackagesOffersServices.dart | 197 +++--- .../PackagesOffersViewModel.dart | 2 + .../BillAmount.dart | 7 - .../OfferAndPackagesCartPage.dart | 565 +++++++++--------- 5 files changed, 373 insertions(+), 401 deletions(-) diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 206c45c6..23558ed1 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -481,7 +481,7 @@ class BaseAppClient { simplePost( String fullUrl, { - Map body, + Map body, Map headers, Function(dynamic response, int statusCode) onSuccess, Function(String error, int statusCode) onFailure, @@ -496,7 +496,6 @@ class BaseAppClient { body: json.encode(body), headers: headers, ); - final int statusCode = response.statusCode; print("statusCode :$statusCode"); if (await handleUnauthorized(statusCode, forUrl: fullUrl)) simplePost(fullUrl, onFailure: onFailure, onSuccess: onSuccess, body: body, headers: headers); diff --git a/lib/core/service/packages_offers/PackagesOffersServices.dart b/lib/core/service/packages_offers/PackagesOffersServices.dart index 238cb611..ae5396a7 100644 --- a/lib/core/service/packages_offers/PackagesOffersServices.dart +++ b/lib/core/service/packages_offers/PackagesOffersServices.dart @@ -4,6 +4,7 @@ import 'dart:developer'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/ResponseModel.dart'; +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; import 'package:diplomaticquarterapp/core/model/packages_offers/requests/AddProductToCartRequestModel.dart'; import 'package:diplomaticquarterapp/core/model/packages_offers/requests/CreateCustomerRequestModel.dart'; import 'package:diplomaticquarterapp/core/model/packages_offers/requests/OffersCategoriesRequestModel.dart'; @@ -15,13 +16,11 @@ import 'package:diplomaticquarterapp/core/model/packages_offers/responses/Packag import 'package:diplomaticquarterapp/core/model/packages_offers/responses/order_response_model.dart'; import 'package:diplomaticquarterapp/core/model/packages_offers/responses/tamara_payment_option.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; -import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; -import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:flutter/cupertino.dart'; -var packagesAuthHeader = {'Authorization': ''}; +Map packagesAuthHeader = {}; class OffersAndPackagesServices extends BaseService { AuthenticatedUser patientUser; @@ -32,64 +31,52 @@ class OffersAndPackagesServices extends BaseService { List bestSellerList = List(); List bannersList = List(); List cartItemList = List(); + List _hospitals = List(); + List get hospitals => _hospitals; String cartItemCount = ""; PackagesCustomerResponseModel customer; - Future> getAllCategories( - OffersCategoriesRequestModel request) async { + Future> getAllCategories(OffersCategoriesRequestModel request) async { Future errorThrow; var url = EXA_CART_API_BASE_URL + PACKAGES_CATEGORIES; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, - onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { if (statusCode == 200) { var jsonResponse = json.decode(stringResponse); jsonResponse['categories'].forEach((json) { categoryList.add(PackagesCategoriesResponseModel().fromJson(json)); }); } - }, - onFailure: (String error, int statusCode) {}, - queryParams: request.toFlatMap()); + }, onFailure: (String error, int statusCode) {}, queryParams: request.toFlatMap()); return categoryList; } - Future> getAllProducts( - {@required OffersProductsRequestModel request, - @required BuildContext context, - @required bool showLoading = true}) async { + Future> getAllProducts({@required OffersProductsRequestModel request, @required BuildContext context, @required bool showLoading = true}) async { Future errorThrow; request.sinceId = (productList.isNotEmpty) ? productList.last.id : 0; productList = List(); var url = EXA_CART_API_BASE_URL + PACKAGES_PRODUCTS; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, - onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { if (statusCode == 200) { var jsonResponse = json.decode(stringResponse); jsonResponse['products'].forEach((json) { productList.add(PackagesResponseModel().fromJson(json)); }); } - }, - onFailure: (String error, int statusCode) {}, - queryParams: request.toFlatMap()); + }, onFailure: (String error, int statusCode) {}, queryParams: request.toFlatMap()); return productList; } - Future> getTamaraOptions( - {@required BuildContext context, - @required bool showLoading = true}) async { - if (tamaraPaymentOptions != null && tamaraPaymentOptions.isNotEmpty) - return tamaraPaymentOptions; + Future> getTamaraOptions({@required BuildContext context, @required bool showLoading = true}) async { + if (tamaraPaymentOptions != null && tamaraPaymentOptions.isNotEmpty) return tamaraPaymentOptions; var url = EXA_CART_API_BASE_URL + PACKAGES_TAMARA_OPT; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, - onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { if (statusCode == 200) { var jsonResponse = json.decode(stringResponse); jsonResponse['payment_option'].forEach((json) { @@ -103,14 +90,10 @@ class OffersAndPackagesServices extends BaseService { return tamaraPaymentOptions; } - Future> getLatestOffers( - {@required OffersProductsRequestModel request, - @required BuildContext context, - @required bool showLoading = true}) async { + Future> getLatestOffers({@required OffersProductsRequestModel request, @required BuildContext context, @required bool showLoading = true}) async { var url = EXA_CART_API_BASE_URL + PACKAGES_PRODUCTS; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, - onSuccess: (dynamic stringResponse, int statusCode) { - latestOffersList.clear(); + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { + latestOffersList.clear(); if (statusCode == 200) { var jsonResponse = json.decode(stringResponse); jsonResponse['products'].forEach((json) { @@ -124,14 +107,10 @@ class OffersAndPackagesServices extends BaseService { return latestOffersList; } - Future> getBestSellers( - {@required OffersProductsRequestModel request, - @required BuildContext context, - @required bool showLoading = true}) async { + Future> getBestSellers({@required OffersProductsRequestModel request, @required BuildContext context, @required bool showLoading = true}) async { var url = EXA_CART_API_BASE_URL + PACKAGES_PRODUCTS; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, - onSuccess: (dynamic stringResponse, int statusCode) { - bestSellerList.clear(); + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { + bestSellerList.clear(); if (statusCode == 200) { var jsonResponse = json.decode(stringResponse); jsonResponse['products'].forEach((json) { @@ -145,13 +124,9 @@ class OffersAndPackagesServices extends BaseService { return bestSellerList; } - Future> getBanners( - {@required OffersProductsRequestModel request, - @required BuildContext context, - @required bool showLoading = true}) async { + Future> getBanners({@required OffersProductsRequestModel request, @required BuildContext context, @required bool showLoading = true}) async { var url = EXA_CART_API_BASE_URL + PACKAGES_PRODUCTS; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, - onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { if (statusCode == 200) { var jsonResponse = json.decode(stringResponse); jsonResponse['products'].forEach((json) { @@ -165,10 +140,7 @@ class OffersAndPackagesServices extends BaseService { return bannersList; } - Future loadOffersPackagesDataForMainPage( - {@required BuildContext context, - bool showLoading = true, - Function completion}) async { + Future loadOffersPackagesDataForMainPage({@required BuildContext context, bool showLoading = true, Function completion}) async { var finished = 0; var totalCalls = 2; @@ -190,30 +162,20 @@ class OffersAndPackagesServices extends BaseService { // Check and Create Customer if (patientUser != null) { - customer = - await getCurrentCustomer(context: context, showLoading: showLoading); + customer = await getCurrentCustomer(context: context, showLoading: showLoading); if (customer == null) { - createCustomer(PackagesCustomerRequestModel.fromUser(patientUser), - context: context); + createCustomer(PackagesCustomerRequestModel.fromUser(patientUser), context: context); } } // Performing Parallel Request on same time // # 1 - getBestSellers( - request: OffersProductsRequestModel(), - context: context, - showLoading: false) - .then((value) { + getBestSellers(request: OffersProductsRequestModel(), context: context, showLoading: false).then((value) { completedAll(); }); // # 2 - getLatestOffers( - request: OffersProductsRequestModel(), - context: context, - showLoading: false) - .then((value) { + getLatestOffers(request: OffersProductsRequestModel(), context: context, showLoading: false).then((value) { completedAll(); }); @@ -230,10 +192,7 @@ class OffersAndPackagesServices extends BaseService { // -------------------- // Create Customer // -------------------- - Future createCustomer(PackagesCustomerRequestModel request, - {@required BuildContext context, - bool showLoading = true, - Function(bool) completion}) async { + Future createCustomer(PackagesCustomerRequestModel request, {@required BuildContext context, bool showLoading = true, Function(bool) completion}) async { if (customer != null) return Future.value(customer); customer = null; @@ -241,9 +200,7 @@ class OffersAndPackagesServices extends BaseService { _showLoading(context, showLoading); var url = EXA_CART_API_BASE_URL + PACKAGES_CUSTOMER; - await baseAppClient - .simplePost(url, headers: packagesAuthHeader, body: request.json(), - onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simplePost(url, headers: packagesAuthHeader, body: request.json(), onSuccess: (dynamic stringResponse, int statusCode) { var jsonResponse = json.decode(stringResponse); var customerJson = jsonResponse['customers'].first; customer = PackagesCustomerResponseModel.fromJson(customerJson); @@ -258,16 +215,12 @@ class OffersAndPackagesServices extends BaseService { return errorThrow ?? customer; } - Future getCurrentCustomer( - {@required BuildContext context, bool showLoading = true}) async { + Future getCurrentCustomer({@required BuildContext context, bool showLoading = true}) async { if (customer != null) return Future.value(customer); _showLoading(context, showLoading); - var url = EXA_CART_API_BASE_URL + - PACKAGES_CUSTOMER + - "/username/${patientUser.patientID}"; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, - onSuccess: (dynamic stringResponse, int statusCode) { + var url = EXA_CART_API_BASE_URL + PACKAGES_CUSTOMER + "/username/${patientUser.patientID}"; + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { var jsonResponse = json.decode(stringResponse); var customerJson = jsonResponse['customers'].first; customer = PackagesCustomerResponseModel.fromJson(customerJson); @@ -282,17 +235,14 @@ class OffersAndPackagesServices extends BaseService { // -------------------- // Shopping Cart // -------------------- - Future> cartItems( - {@required BuildContext context, bool showLoading = true}) async { + Future> cartItems({@required BuildContext context, bool showLoading = true}) async { Future errorThrow; cartItemList.clear(); _showLoading(context, showLoading); - var url = - EXA_CART_API_BASE_URL + PACKAGES_SHOPPING_CART + '/${customer.id}'; + var url = EXA_CART_API_BASE_URL + PACKAGES_SHOPPING_CART + '/${customer.id}'; Map jsonResponse; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, - onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { _hideLoading(context, showLoading); jsonResponse = json.decode(stringResponse); @@ -308,10 +258,7 @@ class OffersAndPackagesServices extends BaseService { return errorThrow ?? jsonResponse; } - Future> addProductToCart( - AddProductToCartRequestModel request, - {@required BuildContext context, - bool showLoading = true}) async { + Future> addProductToCart(AddProductToCartRequestModel request, {@required BuildContext context, bool showLoading = true}) async { Future errorThrow; ResponseModel response; @@ -319,38 +266,27 @@ class OffersAndPackagesServices extends BaseService { _showLoading(context, showLoading); var url = EXA_CART_API_BASE_URL + PACKAGES_SHOPPING_CART; - await baseAppClient - .simplePost(url, headers: packagesAuthHeader, body: request.json(), - onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simplePost(url, headers: packagesAuthHeader, body: request.json(), onSuccess: (dynamic stringResponse, int statusCode) { _hideLoading(context, showLoading); var jsonResponse = json.decode(stringResponse); var jsonCartItem = jsonResponse["shopping_carts"][0]; - response = ResponseModel( - status: true, - data: PackagesCartItemsResponseModel.fromJson(jsonCartItem), - error: null); + response = ResponseModel(status: true, data: PackagesCartItemsResponseModel.fromJson(jsonCartItem), error: null); cartItemCount = (jsonResponse['count'] ?? 0).toString(); }, onFailure: (String error, int statusCode) { _hideLoading(context, showLoading); - errorThrow = - Future.error(ResponseModel(status: true, data: null, error: error)); + errorThrow = Future.error(ResponseModel(status: true, data: null, error: error)); }); return errorThrow ?? response; } - Future updateProductToCart(int cartItemID, - {UpdateProductToCartRequestModel request, - @required BuildContext context, - bool showLoading = true}) async { + Future updateProductToCart(int cartItemID, {UpdateProductToCartRequestModel request, @required BuildContext context, bool showLoading = true}) async { Future errorThrow; _showLoading(context, showLoading); var url = EXA_CART_API_BASE_URL + PACKAGES_SHOPPING_CART + '/$cartItemID'; - await baseAppClient - .simplePut(url, headers: packagesAuthHeader, body: request.json(), - onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simplePut(url, headers: packagesAuthHeader, body: request.json(), onSuccess: (dynamic stringResponse, int statusCode) { _hideLoading(context, showLoading); var jsonResponse = json.decode(stringResponse); @@ -363,16 +299,13 @@ class OffersAndPackagesServices extends BaseService { return errorThrow ?? bannersList; } - Future deleteProductFromCart(int cartItemID, - {@required BuildContext context, bool showLoading = true}) async { + Future deleteProductFromCart(int cartItemID, {@required BuildContext context, bool showLoading = true}) async { Future errorThrow; _showLoading(context, showLoading); var url = EXA_CART_API_BASE_URL + PACKAGES_SHOPPING_CART + '/$cartItemID'; - await baseAppClient.simpleDelete(url, headers: packagesAuthHeader, - onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simpleDelete(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { _hideLoading(context, showLoading); - // var jsonResponse = json.decode(stringResponse); }, onFailure: (String error, int statusCode) { _hideLoading(context, showLoading); log(error); @@ -385,28 +318,23 @@ class OffersAndPackagesServices extends BaseService { // -------------------- // Place Order // -------------------- - Future placeOrder( - {@required Map paymentParams, - @required BuildContext context, - bool showLoading = true}) async { + Future placeOrder({@required Map paymentParams, @required int projectID, @required BuildContext context, bool showLoading = true}) async { Future errorThrow; Map jsonBody = { "customer_id": customer.id, - "billing_address": { - "email": patientUser.emailAddress, - "phone_number": patientUser.mobileNumber - }, + "project_id": projectID, + "billing_address": {"email": patientUser.emailAddress, "phone_number": patientUser.mobileNumber}, }; jsonBody.addAll(paymentParams); jsonBody = {'order': jsonBody}; + print(jsonBody); + int order_id; _showLoading(context, showLoading); var url = EXA_CART_API_BASE_URL + PACKAGES_ORDERS; - await baseAppClient.simplePost(url, - headers: packagesAuthHeader, - body: jsonBody, onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simplePost(url, headers: packagesAuthHeader, body: jsonBody, onSuccess: (dynamic stringResponse, int statusCode) { _hideLoading(context, showLoading); var jsonResponse = json.decode(stringResponse); @@ -420,21 +348,18 @@ class OffersAndPackagesServices extends BaseService { return errorThrow ?? order_id; } - Future> getOrderById(int id, - {@required BuildContext context, bool showLoading = true}) async { + Future> getOrderById(int id, {@required BuildContext context, bool showLoading = true}) async { Future errorThrow; ResponseModel response; _showLoading(context, showLoading); var url = EXA_CART_API_BASE_URL + PACKAGES_ORDERS + '/$id'; - await baseAppClient.simpleGet(url, headers: packagesAuthHeader, - onSuccess: (dynamic stringResponse, int statusCode) { + await baseAppClient.simpleGet(url, headers: packagesAuthHeader, onSuccess: (dynamic stringResponse, int statusCode) { _hideLoading(context, showLoading); var jsonResponse = json.decode(stringResponse); var jsonOrder = jsonResponse['orders'][0]; - response = ResponseModel( - status: true, data: PackagesOrderResponseModel.fromJson(jsonOrder)); + response = ResponseModel(status: true, data: PackagesOrderResponseModel.fromJson(jsonOrder)); }, onFailure: (String error, int statusCode) { _hideLoading(context, showLoading); errorThrow = Future.error(ResponseModel(status: false, error: error)); @@ -442,6 +367,26 @@ class OffersAndPackagesServices extends BaseService { return errorThrow ?? response; } + + Future getHospitals({bool isResBasedOnLoc = true}) async { + Map body = Map(); + body['Latitude'] = await this.sharedPref.getDouble(USER_LAT); + body['Longitude'] = await this.sharedPref.getDouble(USER_LONG); + body['IsOnlineCheckIn'] = isResBasedOnLoc; + body['PatientOutSA'] = 0; + + await baseAppClient.post(GET_PROJECT, + onSuccess: (dynamic response, int statusCode) { + _hospitals.clear(); + response['ListProject'].forEach((hospital) { + _hospitals.add(HospitalsModel.fromJson(hospital)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } + } _showLoading(BuildContext context, bool flag) { diff --git a/lib/core/viewModels/packages_offers/PackagesOffersViewModel.dart b/lib/core/viewModels/packages_offers/PackagesOffersViewModel.dart index 1b68e9d7..af750eab 100644 --- a/lib/core/viewModels/packages_offers/PackagesOffersViewModel.dart +++ b/lib/core/viewModels/packages_offers/PackagesOffersViewModel.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesCartItemsResponseModel.dart'; import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesCategoriesResponseModel.dart'; import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesResponseModel.dart'; @@ -22,6 +23,7 @@ class PackagesViewModel extends BaseViewModel { List get bestSellerList => service.bestSellerList; List get bannersList => service.bannersList; List get cartItemList => service.cartItemList; + List get hospitals => service.hospitals; String _cartItemCount = ""; diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/BillAmount.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/BillAmount.dart index e571e4e8..bacc9c38 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/BillAmount.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/BillAmount.dart @@ -59,13 +59,6 @@ class _BillAmountState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Text(TranslationBase.of(context).testFee, - // style: TextStyle( - // color: Colors.black, - // fontSize: 16.0, - // fontWeight: FontWeight.w600, - // letterSpacing: -0.64, - // )), Container( width: double.infinity, padding: EdgeInsets.only(top: 10, bottom: 3), diff --git a/lib/pages/packages_offers/OfferAndPackagesCartPage.dart b/lib/pages/packages_offers/OfferAndPackagesCartPage.dart index e28110a8..4b42774b 100644 --- a/lib/pages/packages_offers/OfferAndPackagesCartPage.dart +++ b/lib/pages/packages_offers/OfferAndPackagesCartPage.dart @@ -1,19 +1,23 @@ import 'package:after_layout/after_layout.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/ResponseModel.dart'; +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; import 'package:diplomaticquarterapp/core/model/packages_offers/requests/AddProductToCartRequestModel.dart'; -import 'package:diplomaticquarterapp/core/model/packages_offers/responses/tamara_payment_option.dart'; import 'package:diplomaticquarterapp/core/viewModels/packages_offers/PackagesOffersViewModel.dart'; +import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/packages_offers/PackageOrderCompletedPage.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy-terms-conditions-page.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart' as utils; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; import 'package:diplomaticquarterapp/widgets/offers_packages/PackagesCartItemCard.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:diplomaticquarterapp/widgets/single_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -22,6 +26,9 @@ import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; dynamic languageID; const _columnCount = 1; +bool _agreeTerms = false; +String _selectedPaymentMethod; +Map _selectedPaymentParams; AnimationController _animationController; @@ -38,6 +45,8 @@ class _PackagesCartPageState extends State with AfterLayoutMix } double subtotal, tax, total; + int _selectedHospitalIndex = -1; + HospitalsModel _selectedHospital; @override void initState() { @@ -67,9 +76,8 @@ class _PackagesCartPageState extends State with AfterLayoutMix } onPayNowClick() async { - await viewModel.service.placeOrder(context: context, paymentParams: _selectedPaymentParams).then((orderId) { + await viewModel.service.placeOrder(context: context, projectID: _selectedHospital.iD, paymentParams: _selectedPaymentParams).then((orderId) { if (orderId.runtimeType == int) { - // result == order_id var browser = MyInAppBrowser(context: context, onExitCallback: (data, isDone) => paymentClosed(orderId: orderId, withStatus: isDone, data: data)); browser.openPackagesPaymentBrowser(customer_id: viewModel.service.customer.id, order_id: orderId); } else { @@ -83,100 +91,248 @@ class _PackagesCartPageState extends State with AfterLayoutMix @override void afterFirstLayout(BuildContext context) { fetchData(); + viewModel.service.getHospitals(); } @override Widget build(BuildContext context) { return BaseView( - allowAny: true, - onModelReady: (model) => viewModel = model, - builder: (_, model, wi) { - return AppScaffold( - appBarTitle: TranslationBase.of(context).offerAndPackages, - isShowAppBar: true, - isPharmacy: false, - showPharmacyCart: false, - showHomeAppBarIcon: false, - isOfferPackages: true, - showOfferPackagesCart: false, - isShowDecPage: false, - showNewAppBar: true, - showNewAppBarTitle: true, - body: Column( - children: [ - Expanded( - child: StaggeredGridView.countBuilder( - crossAxisCount: (_columnCount * _columnCount), - itemCount: viewModel.cartItemList.length, - itemBuilder: (BuildContext context, int index) { - var item = viewModel.cartItemList[index]; - return Dismissible( - key: Key(index.toString()), - direction: DismissDirection.startToEnd, - background: _cartItemDeleteContainer(), - secondaryBackground: _cartItemDeleteContainer(), - confirmDismiss: (direction) async { - bool status = await viewModel.service.deleteProductFromCart(item.id, context: context, showLoading: false); - return status; - }, - onDismissed: (direction) { - viewModel.cartItemList.removeAt(index); - }, - child: PackagesCartItemCard( - itemModel: item, - viewModel: viewModel, - getCartItems: fetchData, - shouldStepperChangeApply: (apply, total) async { - var request = AddProductToCartRequestModel(product_id: item.productId, quantity: apply); - ResponseModel response = await viewModel.service.addProductToCart(request, context: context, showLoading: false).catchError((error) { - utils.Utils.showErrorToast(error); - }); - if (response.status) { - fetchData(); - } - return response.status ?? false; - }, - )); - }, - staggeredTileBuilder: (int index) => StaggeredTile.fit(_columnCount), - mainAxisSpacing: 0, - crossAxisSpacing: 10, - ), - ), - Container( - height: 0.25, - color: Theme.of(context).primaryColor, - ), - Container( + allowAny: true, + onModelReady: (model) => viewModel = model, + builder: (_, model, wi) { + return AppScaffold( + appBarTitle: TranslationBase.of(context).offerAndPackages, + isShowAppBar: true, + isPharmacy: false, + showPharmacyCart: false, + showHomeAppBarIcon: false, + isOfferPackages: true, + showOfferPackagesCart: false, + isShowDecPage: false, + showNewAppBar: true, + showNewAppBarTitle: true, + body: viewModel.cartItemList.length > 0 + ? Column( + children: [ + Expanded( + child: StaggeredGridView.countBuilder( + crossAxisCount: (_columnCount * _columnCount), + itemCount: viewModel.cartItemList.length, + itemBuilder: (BuildContext context, int index) { + var item = viewModel.cartItemList[index]; + return Dismissible( + key: Key(index.toString()), + direction: DismissDirection.startToEnd, + background: _cartItemDeleteContainer(), + secondaryBackground: _cartItemDeleteContainer(), + confirmDismiss: (direction) async { + bool status = await viewModel.service.deleteProductFromCart(item.id, context: context, showLoading: false); + return status; + }, + onDismissed: (direction) { + viewModel.cartItemList.removeAt(index); + }, + child: PackagesCartItemCard( + itemModel: item, + viewModel: viewModel, + getCartItems: fetchData, + shouldStepperChangeApply: (apply, total) async { + var request = AddProductToCartRequestModel(product_id: item.productId, quantity: apply); + ResponseModel response = await viewModel.service.addProductToCart(request, context: context, showLoading: false).catchError((error) { + utils.Utils.showErrorToast(error); + }); + if (response.status) { + fetchData(); + } + return response.status ?? false; + }, + )); + }, + staggeredTileBuilder: (int index) => StaggeredTile.fit(_columnCount), + mainAxisSpacing: 0, + crossAxisSpacing: 10, + ), + ), + Container( + height: 0.25, + color: Theme.of(context).primaryColor, + ), + ], + ) + : getNoDataWidget(context), + bottomSheet: viewModel.cartItemList.length > 0 + ? Container( + padding: EdgeInsets.all(21.0), + width: double.infinity, color: Colors.white, child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, children: [ - Texts(TranslationBase.of(context).selectPaymentOption, fontSize: 10, fontWeight: FontWeight.bold), Container( - height: 0.25, - width: 100, - color: Colors.grey[300], + margin: EdgeInsets.only(bottom: 12.0), + child: InkWell( + onTap: () => confirmSelectHospitalDialog(model.hospitals), + child: Container( + padding: EdgeInsets.all(12), + width: double.infinity, + height: 50, + decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), border: Border.all(color: CustomColors.devider), color: Colors.white), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + getHospitalName(), + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + letterSpacing: -0.46, + ), + ), + Icon(Icons.arrow_drop_down), + ], + ), + ), + ), + ), + Container( + margin: EdgeInsets.fromLTRB(0.0, 0.0, 20.0, 0.0), + child: Text(TranslationBase.of(context).YouCanPayByTheFollowingOptions, style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.w600)), + ), + Container( + width: MediaQuery.of(context).size.width * 0.75, + margin: EdgeInsets.fromLTRB(0.0, 8.0, 20.0, 5.0), + child: getPaymentMethods(), + ), + Container( + margin: EdgeInsets.only(top: 14.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + height: 24.0, + width: 24.0, + child: Checkbox( + value: _agreeTerms, + onChanged: (v) { + setState(() => _agreeTerms = v); + }), + ), + Expanded( + child: Text( + TranslationBase.of(context).iAcceptTermsConditions, + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: CustomColors.textColor, letterSpacing: -0.48), + ), + ), + ], + ), ), - _paymentOptions(context, (paymentMethod) { - setState(() => _selectedPaymentMethod = paymentMethod); - }, viewModel: viewModel), Container( - height: 0.25, - color: Colors.grey[300], + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: double.infinity, + padding: EdgeInsets.only(top: 12, bottom: 3), + child: Row( + children: [ + Expanded( + child: _getNormalText(TranslationBase.of(context).patientShareToDo), + ), + Expanded( + child: _getNormalText(TranslationBase.of(context).sar + " " + (subtotal ?? 0.0).toStringAsFixed(2), isBold: true), + ) + ], + ), + ), + mDivider(Colors.grey[200]), + Container( + width: double.infinity, + padding: EdgeInsets.only(top: 3, bottom: 3), + child: Row( + children: [ + Expanded( + child: _getNormalText(TranslationBase.of(context).patientTaxToDo), + ), + Expanded( + child: _getNormalText(TranslationBase.of(context).sar + ' ' + (tax ?? 0.0).toStringAsFixed(2), isBold: true), + ) + ], + ), + ), + mDivider(Colors.grey[200]), + Container( + width: double.infinity, + padding: EdgeInsets.only(top: 3, bottom: 3), + child: Row( + children: [ + Expanded( + child: _getNormalText(TranslationBase.of(context).patientShareTotalToDo), + ), + Expanded( + child: _getNormalText(TranslationBase.of(context).sar + ' ' + (total ?? 0.0).toStringAsFixed(2), isBold: true, isTotal: true), + ) + ], + ), + ), + ], + ), ), - Container(height: 40, child: _termsAndCondition(context, onSelected: onTermsClick, onInfoClick: onTermsInfoClick)), Container( - height: 0.25, - color: Colors.grey[300], + padding: EdgeInsets.only(top: 21, bottom: 21), + child: DefaultButton( + TranslationBase.of(context).payNow, + (_agreeTerms && _selectedHospital != null) + ? () { + Navigator.push(context, FadePage(page: PaymentMethod(onSelectedMethod: (String metohd) { + setState(() {}); + }))).then((value) { + print(value); + if (value != null) { + _selectedPaymentMethod = value; + _selectedPaymentParams = {"payment_method_system_name": "Payments.PayFort", "payment_option": value}; + onPayNowClick(); + } + }); + } + : null, + color: CustomColors.green, + disabledColor: CustomColors.grey2, + ), ), - _payNow(context, subtotal: subtotal, tax: tax, total: total, onPayNowClick: onPayNowClick) ], ), ) - ], - ), - ); - }); + : SizedBox(), + ); + }, + ); + } + + void confirmSelectHospitalDialog(List hospitals) { + List list = [ + for (int i = 0; i < hospitals.length; i++) RadioSelectionDialogModel(hospitals[i].name + ' ${hospitals[i].distanceInKilometers} ' + TranslationBase.of(context).km, i), + ]; + showDialog( + context: context, + child: RadioSelectionDialog( + listData: list, + selectedIndex: _selectedHospitalIndex, + isScrollable: true, + onValueSelected: (index) { + _selectedHospitalIndex = index; + _selectedHospital = hospitals[index]; + setState(() {}); + }, + ), + ); + } + + String getHospitalName() { + if (_selectedHospital != null) + return _selectedHospital.name; + else + return TranslationBase.of(context).selectHospital; } fetchData() async { @@ -201,196 +357,73 @@ class _PackagesCartPageState extends State with AfterLayoutMix } } -// /* Payment Footer Widgets */ -// --------------------------- -String _selectedPaymentMethod; -Map _selectedPaymentParams; +// Widget _payNow(BuildContext context, {double subtotal, double tax, double total, @required VoidCallback onPayNowClick}) { +// bool isPayNowAQctive = (_agreeTerms && (_selectedPaymentMethod != null)); +// +// String _subtotal = (subtotal ?? 0.0).toStringAsFixed(2); +// String _tax = (tax ?? 0.0).toStringAsFixed(2); +// String _total = (total ?? 0).toStringAsFixed(2); +// +// return Padding( +// padding: const EdgeInsets.all(5), +// child: Container( +// child: Row( +// crossAxisAlignment: CrossAxisAlignment.end, +// children: [ +// Padding( +// padding: const EdgeInsets.all(5), +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// Texts('${TranslationBase.of(context).subtotal}: $_subtotal ${TranslationBase.of(context).sar}', heightFactor: 1.5, fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 8), +// Texts('${TranslationBase.of(context).vat}: $_tax ${TranslationBase.of(context).sar}', heightFactor: 1.5, fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 8), +// Padding( +// padding: const EdgeInsets.all(3), +// child: Container( +// height: 0.25, +// width: 120, +// color: Colors.grey[300], +// ), +// ), +// Texts('${TranslationBase.of(context).total}: $_total ${TranslationBase.of(context).sar}', heightFactor: 1.5, fontWeight: FontWeight.bold, color: Colors.black54, fontSize: 15) +// ], +// ), +// ), +// Expanded(child: Container()), +// RaisedButton( +// elevation: 0, +// child: Texts( +// TranslationBase.of(context).payNow, +// fontSize: 15, +// color: Colors.white, +// fontWeight: FontWeight.bold, +// ), +// padding: EdgeInsets.only(top: 5, bottom: 5, left: 0, right: 0), +// shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5), side: BorderSide(color: Theme.of(context).primaryColor, width: 0.5)), +// color: Theme.of(context).primaryColor, +// onPressed: isPayNowAQctive ? onPayNowClick : null, +// ), +// ], +// )), +// ); +// } -Widget _paymentOptions(BuildContext context, Function(String) onSelected, {PackagesViewModel viewModel}) { - double height = 30; - - Widget buttonContent(bool isSelected, String imageName) { - return Container( - decoration: BoxDecoration( - color: Colors.white, - boxShadow: [ - BoxShadow( - color: isSelected ? Colors.green[50] : Colors.grey[200], - blurRadius: 1, - spreadRadius: 2, - ), - ], - borderRadius: BorderRadius.all(Radius.circular(5)), - border: Border.all(color: isSelected ? Colors.green : Colors.grey, width: isSelected ? 1 : 0.5)), - child: Padding( - padding: const EdgeInsets.all(4), - child: Image.asset('assets/images/new-design/$imageName'), - )); - } - - Future selectTamaraPaymentOption() async { - final tamara_options = await viewModel.service.getTamaraOptions(context: context, showLoading: true); - final selected = - await SingleSelectionDialog(tamara_options, icon: Image.asset('assets/images/new-design/tamara.png'), title: TranslationBase.of(context).tamaraInstPlan).show(context); - return selected.name; - } - - return Padding( - padding: const EdgeInsets.all(5), - child: Container( - height: height, - color: Colors.transparent, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - InkWell( - child: buttonContent(_selectedPaymentMethod == "tamara", 'tamara.png'), - onTap: () async { - final tamara_option = await selectTamaraPaymentOption(); - _selectedPaymentParams = {"channel": "Web", "payment_method_system_name": "Payments.Tamara", "payment_option": tamara_option}; - onSelected("tamara"); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: buttonContent(_selectedPaymentMethod == "mada", 'mada.png'), - onTap: () { - _selectedPaymentParams = {"payment_method_system_name": "Payments.PayFort", "payment_option": "MADA"}; - onSelected("mada"); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: buttonContent(_selectedPaymentMethod == "visa", 'visa.png'), - onTap: () { - _selectedPaymentParams = {"payment_method_system_name": "Payments.PayFort", "payment_option": "VISA"}; - onSelected("visa"); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: buttonContent(_selectedPaymentMethod == "mastercard", 'mastercard.png'), - onTap: () { - _selectedPaymentParams = {"payment_method_system_name": "Payments.PayFort", "payment_option": "MASTERCARD"}; - onSelected("mastercard"); - }, - ), - // SizedBox( - // width: 5, - // ), - // InkWell( - // child: buttonContent( - // _selectedPaymentMethod == "installment", 'installment.png'), - // onTap: () { - // _selectedPaymentParams = {"payment_method_system_name" : "Payments.PayFort", "payment_option" : "INSTALLMENT"}; - // onSelected("installment"); - // }, - // ), - ], - ), +_getNormalText(text, {bool isBold = false, bool isTotal = false}) { + return Text( + text, + style: TextStyle( + fontSize: isBold + ? isTotal + ? 16 + : 12 + : 10, + letterSpacing: -0.5, + color: isBold ? Colors.black : Colors.grey[700], + fontWeight: FontWeight.w600, ), ); } -bool _agreeTerms = false; - -Widget _termsAndCondition(BuildContext context, {@required Function(bool) onSelected, @required VoidCallback onInfoClick}) { - return Padding( - padding: const EdgeInsets.all(5), - child: Row( - children: [ - InkWell( - child: Icon( - _agreeTerms ? Icons.check_circle : Icons.radio_button_unchecked_sharp, - size: 20, - color: _agreeTerms ? Colors.green[600] : Colors.grey[400], - ), - onTap: () { - onSelected(!_agreeTerms); - }, - ), - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 8), - child: Texts( - TranslationBase.of(context).pharmacyServiceTermsCondition, - fontWeight: FontWeight.normal, - fontSize: 13, - ), - )), - InkWell( - child: Icon( - Icons.info, - size: 20, - color: Colors.grey[600], - ), - onTap: () { - onInfoClick(); - }, - ), - ], - ), - ); -} - -Widget _payNow(BuildContext context, {double subtotal, double tax, double total, @required VoidCallback onPayNowClick}) { - bool isPayNowAQctive = (_agreeTerms && (_selectedPaymentMethod != null)); - - String _subtotal = (subtotal ?? 0.0).toStringAsFixed(2); - String _tax = (tax ?? 0.0).toStringAsFixed(2); - String _total = (total ?? 0).toStringAsFixed(2); - - return Padding( - padding: const EdgeInsets.all(5), - child: Container( - child: Row( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Padding( - padding: const EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts('${TranslationBase.of(context).subtotal}: $_subtotal ${TranslationBase.of(context).sar}', heightFactor: 1.5, fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 8), - Texts('${TranslationBase.of(context).vat}: $_tax ${TranslationBase.of(context).sar}', heightFactor: 1.5, fontWeight: FontWeight.bold, color: Colors.grey, fontSize: 8), - Padding( - padding: const EdgeInsets.all(3), - child: Container( - height: 0.25, - width: 120, - color: Colors.grey[300], - ), - ), - Texts('${TranslationBase.of(context).total}: $_total ${TranslationBase.of(context).sar}', heightFactor: 1.5, fontWeight: FontWeight.bold, color: Colors.black54, fontSize: 15) - ], - ), - ), - Expanded(child: Container()), - RaisedButton( - elevation: 0, - child: Texts( - TranslationBase.of(context).payNow, - fontSize: 15, - color: Colors.white, - fontWeight: FontWeight.bold, - ), - padding: EdgeInsets.only(top: 5, bottom: 5, left: 0, right: 0), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5), side: BorderSide(color: Theme.of(context).primaryColor, width: 0.5)), - color: Theme.of(context).primaryColor, - onPressed: isPayNowAQctive ? onPayNowClick : null, - ), - ], - )), - ); -} -// ------------------- - Widget _cartItemDeleteContainer() { _animationController.duration = Duration(milliseconds: 500); _animationController.repeat(reverse: true); From 75989bdc0191e76e5bc09f691a9c1032e7364788 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 9 Nov 2021 14:06:44 +0300 Subject: [PATCH 31/70] Health Calculators translations --- lib/config/localized_values.dart | 31 +++++- .../bmi_calculator/bmi_calculator.dart | 9 +- .../bmi_calculator/result_page.dart | 2 +- .../bmr_calculator/bmr_calculator.dart | 23 ++-- .../health_calculator/body_fat/body_fat.dart | 104 ++++++++---------- .../calorie_calculator.dart | 12 +- .../calorie_result_page.dart | 7 +- .../health_calculator/carbs/carbs.dart | 33 +++--- .../ideal_body/ideal_body.dart | 30 ++--- lib/uitl/translations_delegate_base.dart | 64 +++++++++++ 10 files changed, 204 insertions(+), 111 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index ff719027..46f010bd 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1631,11 +1631,40 @@ const Map localizedValues = { "RRTTitle": {"en": "RRT", "ar": "خدمة فريق"}, "RRTSubTitle": {"en": "Service", "ar": "الاستجابة السريع"}, "transportation": {"en": "Transportation", "ar": "النقل"}, - "neck": {"en": "Neck", "ar": "رقبه"}, "waist": {"en": "Waist", "ar": "وسط"}, "hip": {"en": "Hip", "ar": "ورك او نتوء"}, "carbsProtin": {"en": "Carbs, Protein and Fat", "ar": "الكربوهيدرات والبروتينات والدهون"}, "myCart": {"en": "Cart", "ar": "عربة التسوق"}, "browseOffers": {"en": "Browse offers by clinic", "ar": "تصفح العروض حسب العيادة"}, + "inactiveAct":{"en":"Almost inactive (little or no exercise)","ar":"غير نشط تقريبا (ممارسة الرياضة قليلة أو منعدمة)"}, + "light":{"en":"Lightly active (1-3) days per week","ar":"خفيف النشاط (1-3 أيام في الأسبوع)"}, + "moderate":{"en":"Moderately active (3-5) days per week)","ar":"معتدل النشاط (3-5 أيام في الأسبوع)"}, + "very":{"en":"Very active (6-7) days per week)","ar":"نشط جداُ (6-7 أيام في الأسبوع)"}, + "super":{"en":"Super active (very hard exercise)","ar":"عالي النشاط (ممارسة الرياضة الصعبة)"}, + "resultCalories": {"en": "Daily intake is (#) calories", "ar": "الإحتياج اليومي (#) سعرة حرارية"}, + "bmrDesc": {"en": "Calculates the amount of energy that the person’s body expends in a day", "ar": "معدل الأيض القاعدي: هو حساب كمية الطاقة التي يحتاجها الجسم في اليوم الواحد"}, + "idealWeightDesc": {"en": "Calculates the ideal body weight based on height, Weight, and Body Size", "ar": "حساب الوزن المثالي والوزن الصحي للجسم على أساس الطول، والوزن ،والجسم"}, + "bodyFrame": {"en": "Body Frame Size", "ar": "مقاس هيكل الجسم"}, + "bodyFrameSmall": {"en": "Small (fingers overlap)", "ar": "رفيع (الأصابع تتداخل)"}, + "bodyFrameMedium": {"en": "Medium (fingers touch)", "ar": "متوسط (الأصابع تتلامس)"}, + "bodyFrameLarge": {"en": "Large (fingers don't touch)", "ar": "عريض (الأصابع لا تتلامس)"}, + "bodyFatDesc": {"en": "Estimates the total body fat based on the size", "ar": "حساب الدهون في الجسم بناءاً على الحجم"}, + "essential":{"en":"The category falls under Essential Fat.","ar":"تندرج تحت فئة دهون أساسية"}, + "athlete":{"en":" The category falls under Athlete.","ar":"تندرج تحت فئة دهون جسم رياضي"}, + "fitness":{"en":" The category falls under Fitness.","ar":"تندرج تحت فئة دهون جسم صحي"}, + "acceptable":{"en":"The category falls under Acceptable","ar":"تندرج تحت فئة دهون مقبولة"}, + "obeseBodyFat":{"en":"The category falls under Obese.","ar":"تندرج تحت فئة دهون جسم سمين"}, + "invalid":{"en":"Invalid input for calculation.","ar":"البيانات المدخلة غير صالحة للحساب"}, + "more":{"en":"Please check the value you have entered, since the body fat percentage has crossed the limits.","ar":"يرجى التحقق من القيمة التي أدخلتها ، نظرًا لأن نسبة الدهون في الجسم قد تجاوزت الحدود"}, + "less":{"en":"Please check the value you have entered, since the body fat percentage cannot be this low.","ar":"يرجى التحقق من القيمة التي أدخلتها ، نظرًا لأن نسبة الدهون في الجسم لا يمكن أن تكون منخفضة"}, + "carbProteinDesc": {"en": "Calculates carbohydrate protein and fat ratio in calories and grams according to a pre-set ratio", "ar": "حساب نسب الكربوهيدرات و البروتينات و الدهون بالسعرات الحرارية والغرامات وفقا لنسب محددة مسبقا"}, + "calDay": {"en": "Calories Per Day", "ar": "السعرات الحرارية في اليوم الواحد"}, + "notSure": {"en": "Not sure? click here", "ar": "غير متأكد؟ اضغط هنا"}, + "selectDiet": {"en": "Select Diet Type", "ar": "حدد نوع النظام الغذائي"}, + "dietVeryLow":{"en":"Very Low Carb","ar":"حمية منخفضة جدا في الكربوهيدرات"}, + "dietLow":{"en":"Low Carb","ar":"حمية منخفضة الكربوهيدرات"}, + "dietModerate":{"en":"Moderate Carb","ar":"حمية معتدلة الكربوهيدرات"}, + "dietUSDA":{"en":"USDA Guidelines","ar":"ارشادات وزارة الزراعة الأمريكية"}, + "dietZone":{"en":"Zone Diet","ar":"حمية زون"}, }; diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart index 86382fe7..08b756ee 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/bmi_calculator.dart @@ -4,13 +4,11 @@ import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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 'package:flutter/services.dart'; -import '../health_calc_desc.dart'; import 'result_page.dart'; const activeCardColor = Color(0xff70777A); @@ -47,9 +45,10 @@ class _BMICalculatorState extends State { } double calculateBMI() { - if (_isHeightCM) { - convertToCm(_heightValue.toDouble()); - } + if (!_isHeightCM) _heightValue = convertToCm(_heightValue.toDouble()); + + if (!_isWeightKG) _weightValue = convertToKg(_weightValue); + bmiResult = _weightValue / pow(_heightValue / 100, 2); return bmiResult; diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/result_page.dart index 81fba296..fa12a9fe 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmi_calculator/result_page.dart @@ -78,7 +78,7 @@ class _ResultPageState extends State { mainAxisSize: MainAxisSize.min, children: [ Text( - TranslationBase.of(context).bodyMassIndex + widget.finalResult.toString(), + TranslationBase.of(context).bodyMassIndex + widget.finalResult.toStringAsFixed(2), style: TextStyle( fontSize: 16, letterSpacing: -0.64, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart index a2d96d89..974cd748 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart @@ -48,7 +48,7 @@ class _BmrCalculatorState extends State { // int height = 0; // int weight = 0; double bmrResult = 0; - String dropdownValue = 'Lighty Active (1-3) days per week'; + String dropdownValue = ''; double calories = 0; void updateColor(int type) { @@ -122,13 +122,13 @@ class _BmrCalculatorState extends State { } void calculateCalories() { - if (dropdownValue == "Almost Inactive(Little or no exercises)") { + if (dropdownValue == TranslationBase.of(context).inactiveAct) { calories = bmrResult * 1.2; - } else if (dropdownValue == "Lighty Active (1-3) days per week") { + } else if (dropdownValue == TranslationBase.of(context).light) { calories = bmrResult * 1.375; - } else if (dropdownValue == "very Active(6-7) days per week") { + } else if (dropdownValue == TranslationBase.of(context).very) { calories = bmrResult * 1.55; - } else if (dropdownValue == "Super Active(very hard exercises)") { + } else if (dropdownValue == TranslationBase.of(context).superAct) { calories = bmrResult * 1.725; } else if (dropdownValue == "") { calories = bmrResult * 10.725; @@ -137,6 +137,7 @@ class _BmrCalculatorState extends State { @override Widget build(BuildContext context) { + dropdownValue = TranslationBase.of(context).light; ProjectViewModel projectViewModel = Provider.of(context); _weightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).kg), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).lb), value: false)]; _heightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).cm), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).ft), value: false)]; @@ -161,7 +162,7 @@ class _BmrCalculatorState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Calculates the amount of energy that the person’s body expends in a day', + TranslationBase.of(context).bmrDesc, style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, @@ -362,14 +363,14 @@ class _BmrCalculatorState extends State { }); }, items: [ - 'Almost Inactive(Little or no exercises)', - 'Lighty Active (1-3) days per week', - 'very Active(6-7) days per week', - 'Super Active(very hard exercises)' + TranslationBase.of(context).inactiveAct, + TranslationBase.of(context).light, + TranslationBase.of(context).very, + TranslationBase.of(context).superAct, ].map>((String value) { return DropdownMenuItem( value: value, - child: Text(value), + child: Text(value, style: TextStyle(fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins', fontSize: 11, letterSpacing: -0.44, fontWeight: FontWeight.w600)), ); }).toList(), ), diff --git a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart index 22f915b0..a7bdbe0e 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart @@ -4,7 +4,6 @@ import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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'; @@ -23,7 +22,6 @@ class BodyFat extends StatefulWidget { } class _BodyFatState extends State { - final GlobalKey clinicDropdownKey = GlobalKey(); bool _isHeightCM = true; bool _isNeckKG = true; @@ -34,7 +32,6 @@ class _BodyFatState extends State { double _waistValue = 0; double _hipValue = 0; - TextEditingController _heightController = new TextEditingController(); TextEditingController _neckController = TextEditingController(); TextEditingController _waistController = TextEditingController(); @@ -45,12 +42,12 @@ class _BodyFatState extends State { List _waistPopupList = List(); List _hipPopupList = List(); - - bool isMale = false; + // bool isHeightCm = true; Color maleCard = activeCardColorGender; Color femaleCard = inactiveCardColorGender; + // Color neckCmCard = activeCardColor; // Color neckFtCard = inactiveCardColor; Color waistCmCard = activeCardColor; @@ -59,6 +56,7 @@ class _BodyFatState extends State { Color hipFtCard = inactiveCardColor; Color cmCard = activeCardColor; Color ftCard = inactiveCardColor; + // int neck = 10; // int heightCm = 0; // int heightFt = 0; @@ -67,6 +65,7 @@ class _BodyFatState extends State { double minRange; double maxRange; double overWeightBy; + // int waist = 5; double bodyFat = 0; double fat = 0; @@ -74,8 +73,6 @@ class _BodyFatState extends State { double calories = 0; String textResult = ''; - - @override void initState() { _neckController.text = _neckValue.toString(); @@ -105,8 +102,6 @@ class _BodyFatState extends State { } } - - void updateColorWaist(int type) { //MG/DLT card if (type == 1) { @@ -183,33 +178,33 @@ class _BodyFatState extends State { void showTextResult() { if (isMale == false) { if (bodyFat > 9 && bodyFat <= 13) { - textResult = 'The category falls under essential'; + textResult = TranslationBase.of(context).essential; } else if (bodyFat > 13 && bodyFat <= 20) { - textResult = 'The category falls under athlete'; + textResult = TranslationBase.of(context).athlete; } else if (bodyFat > 20 && bodyFat <= 24) { - textResult = 'The category falls under fitness'; + textResult = TranslationBase.of(context).fitness; } else if (bodyFat > 24 && bodyFat <= 31) { - textResult = 'The category falls under acceptable'; + textResult = TranslationBase.of(context).acceptable; } else if (bodyFat > 31 && bodyFat <= 60) { - textResult = 'The category falls under obese'; + textResult = TranslationBase.of(context).obeseBodyFat; } else if (bodyFat > 60) { - textResult = 'Please check the value you have entered, since the body fat percentage has crosed the limits.'; + textResult = TranslationBase.of(context).more; } else if (bodyFat <= 9) { - textResult = 'Please check the value you have entered, since the body fat percentage cannot be this low.'; + textResult = TranslationBase.of(context).less; } } else { if (bodyFat > 5 && fat <= 13) { - textResult = 'The category falls under essential'; + textResult = TranslationBase.of(context).essential; } else if (bodyFat > 13 && bodyFat <= 17) { - textResult = 'The category falls under athlete'; + textResult = TranslationBase.of(context).athlete; } else if (bodyFat > 17 && bodyFat <= 24) { - textResult = 'The category falls under fitness'; + textResult = TranslationBase.of(context).fitness; } else if (bodyFat > 24 && bodyFat <= 45) { - textResult = 'The category falls under obese'; + textResult = TranslationBase.of(context).obeseBodyFat; } else if (bodyFat > 45) { - textResult = 'Please check the value you have entered, since the body fat percentage has crosed the limits.'; + textResult = TranslationBase.of(context).more; } else if (bodyFat <= 5) { - textResult = 'Please check the value you have entered, since the body fat percentage cannot be this low.'; + textResult = TranslationBase.of(context).less; } } } @@ -234,12 +229,12 @@ class _BodyFatState extends State { Expanded( child: SingleChildScrollView( child: Container( - padding: EdgeInsets.all(20), + padding: EdgeInsets.all(20), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Estimates the total body fat based on\nthe size', + TranslationBase.of(context).bodyFatDesc, style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, @@ -346,14 +341,14 @@ class _BodyFatState extends State { 1, 270, _heightValue, - (text) { + (text) { _heightController.text = text; }, - (value) { + (value) { _heightValue = value; }, _isHeightCM ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, - (value) { + (value) { if (_isHeightCM != value) { setState(() { _isHeightCM = value; @@ -371,14 +366,14 @@ class _BodyFatState extends State { 1, 270, _neckValue, - (text) { - _neckController.text = text; + (text) { + _neckController.text = text; }, - (value) { - _neckValue = value; + (value) { + _neckValue = value; }, _isNeckKG ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, - (value) { + (value) { if (_isNeckKG != value) { setState(() { _isNeckKG = value; @@ -387,7 +382,6 @@ class _BodyFatState extends State { }, _neckPopupList, ), - SizedBox( height: 12.0, ), @@ -397,14 +391,14 @@ class _BodyFatState extends State { 1, 270, _waistValue, - (text) { - _waistController.text = text; + (text) { + _waistController.text = text; }, - (value) { + (value) { _waistValue = value; }, _isWaistKG ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, - (value) { + (value) { if (_isWaistKG != value) { setState(() { _isWaistKG = value; @@ -422,14 +416,14 @@ class _BodyFatState extends State { 1, 270, _hipValue, - (text) { + (text) { _hipController.text = text; }, - (value) { + (value) { _hipValue = value; }, _isHipKG ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, - (value) { + (value) { if (_isHipKG != value) { setState(() { _isHipKG = value; @@ -438,7 +432,6 @@ class _BodyFatState extends State { }, _hipPopupList, ), - SizedBox( height: 12.0, ), @@ -463,10 +456,10 @@ class _BodyFatState extends State { context, FadePage( page: FatResult( - bodyFat: bodyFat, - fat: fat, - textResult: textResult, - )), + bodyFat: bodyFat, + fat: fat, + textResult: textResult, + )), ); } }); @@ -477,6 +470,7 @@ class _BodyFatState extends State { ), ); } + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) { return Container( padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), @@ -534,15 +528,15 @@ class _BodyFatState extends State { prefixIcon: prefix == null ? null : Text( - "+" + prefix, - style: TextStyle( - fontSize: 14, - height: 21 / 14, - fontWeight: FontWeight.w500, - color: Color(0xff2E303A), - letterSpacing: -0.56, - ), - ), + "+" + prefix, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, + ), + ), contentPadding: EdgeInsets.zero, border: InputBorder.none, focusedBorder: InputBorder.none, @@ -683,5 +677,3 @@ class CommonDropDownView extends StatelessWidget { ); } } - - diff --git a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart index 2052e58f..b47ca233 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart @@ -3,7 +3,6 @@ import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -296,14 +295,15 @@ class _CalorieCalculatorState extends State { }); }, items: [ - 'Almost Inactive(Little or no exercises)', - 'Lighty Active (1-3) days per week', - 'very Active(6-7) days per week', - 'Super Active(very hard exercises)' + TranslationBase.of(context).inactiveAct, + TranslationBase.of(context).light, + TranslationBase.of(context).very, + TranslationBase.of(context).superAct, ].map>((String value) { return DropdownMenuItem( value: value, - child: Text(value), + child: Text(value, + style: TextStyle(fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins', fontSize: 11, letterSpacing: -0.44, fontWeight: FontWeight.w600)), ); }).toList(), ), diff --git a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart index ec19a91e..9202fdc2 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart @@ -35,7 +35,7 @@ class CalorieResultPage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Calories", + TranslationBase.of(context).calories, style: TextStyle( fontSize: 19, letterSpacing: -1.34, @@ -63,7 +63,7 @@ class CalorieResultPage extends StatelessWidget { height: 5.0, ), Text( - 'Calories', + TranslationBase.of(context).calories, style: TextStyle( fontSize: 18, letterSpacing: -1.08, @@ -78,7 +78,8 @@ class CalorieResultPage extends StatelessWidget { ), mHeight(20), Text( - 'Daily intake is ${calorie.toStringAsFixed(1)} calories', + TranslationBase.of(context).resultCalories.replaceAll("(#)", calorie.toStringAsFixed(1)), + // 'Daily intake is ${calorie.toStringAsFixed(1)} calories', style: TextStyle(fontSize: 14, letterSpacing: -0.56, fontWeight: FontWeight.w600, color: CustomColors.textColor), ), ], diff --git a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart index fa8e2bc5..31990a6b 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart @@ -1,13 +1,13 @@ +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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 'package:flutter/services.dart'; +import 'package:provider/provider.dart'; import 'carbs_result_page.dart'; @@ -38,27 +38,27 @@ class _CarbsState extends State { double fCalMeal; void calculateDietRatios() { - if (dropdownValue == 'Very Low Carb') { + if (dropdownValue == TranslationBase.of(context).dietVeryLow) { meals = 3; protein = 45; carbs = 10; fat = 45; - } else if (dropdownValue == 'Low Carb') { + } else if (dropdownValue == TranslationBase.of(context).dietLow) { meals = 3; protein = 40; carbs = 30; fat = 30; - } else if (dropdownValue == 'Moderate Carb') { + } else if (dropdownValue == TranslationBase.of(context).dietModerate) { meals = 3; protein = 25; carbs = 50; fat = 25; - } else if (dropdownValue == 'USDA Gudilines') { + } else if (dropdownValue == TranslationBase.of(context).dietUSDA) { meals = 3; protein = 15; carbs = 55; fat = 30; - } else if (dropdownValue == 'Zone Diet') { + } else if (dropdownValue == TranslationBase.of(context).dietZone) { meals = 3; protein = 30; carbs = 40; @@ -82,6 +82,7 @@ class _CarbsState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); return AppScaffold( isShowAppBar: true, isShowDecPage: false, @@ -107,7 +108,7 @@ class _CarbsState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Calculates carbohydrate protein and fat ratio in calories and grams according to a pre-set ratio', + TranslationBase.of(context).carbProteinDesc, style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, @@ -122,7 +123,7 @@ class _CarbsState extends State { mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end, children: [ - inputWidget("The Calories per day", "0", textController), + inputWidget(TranslationBase.of(context).calDay, "0", textController), InkWell( onTap: () { Navigator.push( @@ -133,7 +134,7 @@ class _CarbsState extends State { child: Padding( padding: const EdgeInsets.all(12.0), child: Text( - 'NOT SURE? CLICK HERE', + TranslationBase.of(context).notSure, style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, letterSpacing: -0.56, color: CustomColors.accentColor, decoration: TextDecoration.underline), ), ), @@ -159,7 +160,7 @@ class _CarbsState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Select Diet Type", + TranslationBase.of(context).selectDiet, style: TextStyle( fontSize: 11, letterSpacing: -0.44, @@ -186,10 +187,16 @@ class _CarbsState extends State { calculateDietRatios(); }); }, - items: ['Very Low Carb', 'Low Carb', 'Moderate Carb', 'USDA Gudilines', 'Zone Diet'].map>((String value) { + items: [ + TranslationBase.of(context).dietVeryLow, + TranslationBase.of(context).dietLow, + TranslationBase.of(context).dietModerate, + TranslationBase.of(context).dietUSDA, + TranslationBase.of(context).dietZone + ].map>((String value) { return DropdownMenuItem( value: value, - child: Text(value), + child: Text(value, style: TextStyle(fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins', fontSize: 11, letterSpacing: -0.44, fontWeight: FontWeight.w600)), ); }).toList(), ), diff --git a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart index 7e4e3b4f..24ca617b 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart @@ -1,11 +1,13 @@ +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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 'package:flutter/services.dart'; +import 'package:provider/provider.dart'; import 'ideal_body_result_page.dart'; @@ -34,7 +36,7 @@ class _IdealBodyState extends State { double overWeightBy; int weight = 0; double idealWeight = 0; - String dropdownValue = 'Medium(fingers touch)'; + String dropdownValue = TranslationBase.of(AppGlobal.context).bodyFrameMedium; double calories = 0; String textResult = ''; double maxIdealWeight; @@ -52,17 +54,15 @@ class _IdealBodyState extends State { List _heightPopupList = List(); List _weightPopupList = List(); - - void calculateIdealWeight() { heightInches = int.parse(_heightController.text) * .39370078740157477; heightFeet = heightInches / 12; idealWeight = (50 + 2.3 * (heightInches - 60)); - if (dropdownValue == 'Small(fingers overlap)') { + if (dropdownValue == TranslationBase.of(context).bodyFrameSmall) { idealWeight = idealWeight - 10; - } else if (dropdownValue == 'Medium(fingers touch)') { + } else if (dropdownValue == TranslationBase.of(context).bodyFrameMedium) { idealWeight = idealWeight; - } else if (dropdownValue == 'Large(fingers don\'n touch)') { + } else if (dropdownValue == TranslationBase.of(context).bodyFrameLarge) { idealWeight = idealWeight + 10; } @@ -75,6 +75,7 @@ class _IdealBodyState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); _weightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).kg), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).lb), value: false)]; _heightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).cm), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).ft), value: false)]; @@ -94,7 +95,7 @@ class _IdealBodyState extends State { child: Column( children: [ Text( - 'Calculates the ideal body weight based on height, Weight, and Body Size', + TranslationBase.of(context).idealWeightDesc, style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, @@ -177,7 +178,7 @@ class _IdealBodyState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Body Frame Size", + TranslationBase.of(context).bodyFrame, style: TextStyle( fontSize: 11, letterSpacing: -0.44, @@ -204,13 +205,14 @@ class _IdealBodyState extends State { }); }, items: [ - 'Small(fingers overlap)', - 'Medium(fingers touch)', - 'Large(fingers don\'n touch)', + TranslationBase.of(context).bodyFrameSmall, + TranslationBase.of(context).bodyFrameMedium, + TranslationBase.of(context).bodyFrameLarge, ].map>((String value) { return DropdownMenuItem( value: value, - child: Text(value), + child: Text(value, + style: TextStyle(fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins', fontSize: 11, letterSpacing: -0.44, fontWeight: FontWeight.w600)), ); }).toList(), ), @@ -498,5 +500,3 @@ class CommonDropDownView extends StatelessWidget { ); } } - - diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index e9f830e1..a406d420 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2624,10 +2624,74 @@ class TranslationBase { String get browseOffers => localizedValues["browseOffers"][locale.languageCode]; String get myCart => localizedValues["myCart"][locale.languageCode]; + String get neck => localizedValues["neck"][locale.languageCode]; + String get waist => localizedValues["waist"][locale.languageCode]; + String get hip => localizedValues["hip"][locale.languageCode]; + String get carbsProtin => localizedValues["carbsProtin"][locale.languageCode]; + + String get inactiveAct => localizedValues["inactiveAct"][locale.languageCode]; + + String get light => localizedValues["light"][locale.languageCode]; + + String get moderate => localizedValues["moderate"][locale.languageCode]; + + String get very => localizedValues["very"][locale.languageCode]; + + String get superAct => localizedValues["super"][locale.languageCode]; + + String get resultCalories => localizedValues["resultCalories"][locale.languageCode]; + + String get bmrDesc => localizedValues["bmrDesc"][locale.languageCode]; + + String get idealWeightDesc => localizedValues["idealWeightDesc"][locale.languageCode]; + + String get bodyFrame => localizedValues["bodyFrame"][locale.languageCode]; + + String get bodyFrameSmall => localizedValues["bodyFrameSmall"][locale.languageCode]; + + String get bodyFrameMedium => localizedValues["bodyFrameMedium"][locale.languageCode]; + + String get bodyFrameLarge => localizedValues["bodyFrameLarge"][locale.languageCode]; + + String get bodyFatDesc => localizedValues["bodyFatDesc"][locale.languageCode]; + + String get essential => localizedValues["essential"][locale.languageCode]; + + String get athlete => localizedValues["athlete"][locale.languageCode]; + + String get fitness => localizedValues["fitness"][locale.languageCode]; + + String get acceptable => localizedValues["acceptable"][locale.languageCode]; + + String get obeseBodyFat => localizedValues["obeseBodyFat"][locale.languageCode]; + + String get invalid => localizedValues["invalid"][locale.languageCode]; + + String get more => localizedValues["more"][locale.languageCode]; + + String get less => localizedValues["less"][locale.languageCode]; + + String get carbProteinDesc => localizedValues["carbProteinDesc"][locale.languageCode]; + + String get calDay => localizedValues["calDay"][locale.languageCode]; + + String get notSure => localizedValues["notSure"][locale.languageCode]; + + String get selectDiet => localizedValues["selectDiet"][locale.languageCode]; + + String get dietVeryLow => localizedValues["dietVeryLow"][locale.languageCode]; + + String get dietLow => localizedValues["dietLow"][locale.languageCode]; + + String get dietModerate => localizedValues["dietModerate"][locale.languageCode]; + + String get dietUSDA => localizedValues["dietUSDA"][locale.languageCode]; + + String get dietZone => localizedValues["dietZone"][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { From 5927f3e35f41117cdb012ec936e7e509ad8985c5 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 9 Nov 2021 13:11:45 +0200 Subject: [PATCH 32/70] pharmacy home page update --- lib/config/config.dart | 484 ++++++++++++------ .../parmacyModule/parmacy_module_service.dart | 63 ++- .../pharmacyModule/MostViewedViewModel.dart | 23 + lib/locator.dart | 8 +- .../screens/cart-page/cart-order-page.dart | 40 +- .../screens/pharmacy_module_page.dart | 6 +- .../product-details/product-detail.dart | 68 ++- .../widgets/home/MostViewedWidget.dart | 59 +++ lib/widgets/others/app_scaffold_widget.dart | 98 +++- 9 files changed, 608 insertions(+), 241 deletions(-) create mode 100644 lib/core/viewModels/pharmacyModule/MostViewedViewModel.dart create mode 100644 lib/pages/pharmacies/widgets/home/MostViewedWidget.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 200e5776..a277afea 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -15,8 +15,8 @@ const PACKAGES_CUSTOMER = '/api/customers'; 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/'; // Pharmacy UAT URLs // const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; @@ -38,7 +38,8 @@ const GET_GEO_ZONES = 'Services/Patients.svc/REST/GeoF_GetAllPoints'; const LOG_GEO_ZONES = 'Services/Patients.svc/REST/GeoF_InsertPatientFileInfo'; // Delivery Driver -const DRIVER_LOCATION = 'Services/Patients.svc/REST/PatientER_GetDriverLocation'; +const DRIVER_LOCATION = + 'Services/Patients.svc/REST/PatientER_GetDriverLocation'; //weather const WEATHER_INDICATOR = 'Services/Weather.svc/REST/GetCityInfo'; @@ -46,41 +47,60 @@ const WEATHER_INDICATOR = 'Services/Weather.svc/REST/GetCityInfo'; const GET_PRIVILEGE = 'Services/Patients.svc/REST/Service_Privilege'; // Wifi Credentials -const WIFI_CREDENTIALS = "Services/Patients.svc/Hmg_SMS_Get_By_ProjectID_And_PatientID"; +const WIFI_CREDENTIALS = + "Services/Patients.svc/Hmg_SMS_Get_By_ProjectID_And_PatientID"; ///Doctor -const GET_MY_DOCTOR = 'Services/Doctors.svc/REST/GetPatientDoctorAppointmentResult'; +const GET_MY_DOCTOR = + 'Services/Doctors.svc/REST/GetPatientDoctorAppointmentResult'; const GET_DOCTOR_PROFILE = 'Services/Doctors.svc/REST/GetDocProfiles'; -const GET_DOCTOR_PRE_POST_IMAGES = 'Services/Doctors.svc/REST/GetDoctorPrePostImages'; -const GET_DOCTOR_RATING_NOTES = 'Services/Doctors.svc/REST/dr_GetNotesDoctorRating'; -const GET_DOCTOR_RATING_DETAILS = 'Services/Doctors.svc/REST/dr_GetDoctorRatingDetails'; +const GET_DOCTOR_PRE_POST_IMAGES = + 'Services/Doctors.svc/REST/GetDoctorPrePostImages'; +const GET_DOCTOR_RATING_NOTES = + 'Services/Doctors.svc/REST/dr_GetNotesDoctorRating'; +const GET_DOCTOR_RATING_DETAILS = + 'Services/Doctors.svc/REST/dr_GetDoctorRatingDetails'; const GET_DOCTOR_RATING = 'Services/Doctors.svc/REST/dr_GetAvgDoctorRating'; ///Prescriptions const PRESCRIPTIONS = 'Services/Patients.svc/REST/GetPrescriptionApptList'; -const GET_PRESCRIPTIONS_ALL_ORDERS = 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; -const GET_PRESCRIPTION_REPORT = 'Services/Patients.svc/REST/INP_GetPrescriptionReport'; -const SEND_PRESCRIPTION_EMAIL = 'Services/Notifications.svc/REST/SendPrescriptionEmail'; -const GET_PRESCRIPTION_REPORT_ENH = 'Services/Patients.svc/REST/GetPrescriptionReport_enh'; +const GET_PRESCRIPTIONS_ALL_ORDERS = + 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; +const GET_PRESCRIPTION_REPORT = + 'Services/Patients.svc/REST/INP_GetPrescriptionReport'; +const SEND_PRESCRIPTION_EMAIL = + 'Services/Notifications.svc/REST/SendPrescriptionEmail'; +const GET_PRESCRIPTION_REPORT_ENH = + 'Services/Patients.svc/REST/GetPrescriptionReport_enh'; ///Lab Order const GET_Patient_LAB_ORDERS = 'Services/Patients.svc/REST/GetPatientLabOrders'; -const GET_Patient_LAB_SPECIAL_RESULT = 'Services/Patients.svc/REST/GetPatientLabSpecialResults'; -const SEND_LAB_RESULT_EMAIL = 'Services/Notifications.svc/REST/SendLabReportEmail'; -const GET_Patient_LAB_RESULT = 'Services/Patients.svc/REST/GetPatientLabResults'; -const GET_Patient_LAB_ORDERS_RESULT = 'Services/Patients.svc/REST/GetPatientLabOrdersResults'; -const SEND_COVID_LAB_RESULT_EMAIL = 'Services/Notifications.svc/REST/GenerateCOVIDReport'; -const COVID_PASSPORT_UPDATE = 'Services/Patients.svc/REST/Covid19_Certificate_PassportUpdate'; -const GET_PATIENT_PASSPORT_NUMBER = 'Services/Patients.svc/REST/Covid19_Certificate_GetPassport'; +const GET_Patient_LAB_SPECIAL_RESULT = + 'Services/Patients.svc/REST/GetPatientLabSpecialResults'; +const SEND_LAB_RESULT_EMAIL = + 'Services/Notifications.svc/REST/SendLabReportEmail'; +const GET_Patient_LAB_RESULT = + 'Services/Patients.svc/REST/GetPatientLabResults'; +const GET_Patient_LAB_ORDERS_RESULT = + 'Services/Patients.svc/REST/GetPatientLabOrdersResults'; +const SEND_COVID_LAB_RESULT_EMAIL = + 'Services/Notifications.svc/REST/GenerateCOVIDReport'; +const COVID_PASSPORT_UPDATE = + 'Services/Patients.svc/REST/Covid19_Certificate_PassportUpdate'; +const GET_PATIENT_PASSPORT_NUMBER = + 'Services/Patients.svc/REST/Covid19_Certificate_GetPassport'; /// const GET_PATIENT_ORDERS = 'Services/Patients.svc/REST/GetPatientRadOrders'; -const GET_PATIENT_LAB_ORDERS_BY_APPOINTMENT = 'Services/Patients.svc/REST/GetPatientLabResultsByAppointmentNo'; +const GET_PATIENT_LAB_ORDERS_BY_APPOINTMENT = + 'Services/Patients.svc/REST/GetPatientLabResultsByAppointmentNo'; -const GET_PATIENT_ORDERS_DETAILS = 'Services/Patients.svc/REST/Rad_UpdatePatientRadOrdersToRead'; +const GET_PATIENT_ORDERS_DETAILS = + 'Services/Patients.svc/REST/Rad_UpdatePatientRadOrdersToRead'; const GET_RAD_IMAGE_URL = 'Services/Patients.svc/Rest/GetRadImageURL'; -const SEND_RAD_REPORT_EMAIL = 'Services/Notifications.svc/REST/SendRadReportEmail'; +const SEND_RAD_REPORT_EMAIL = + 'Services/Notifications.svc/REST/SendRadReportEmail'; ///Feedback const SEND_FEEDBACK = 'Services/COCWS.svc/REST/InsertCOCItemInSPList'; @@ -92,28 +112,40 @@ const GET_PATIENT_AppointmentHistory = 'Services' '/Doctors.svc/REST/PateintHasAppoimentHistory_Async'; ///VITAL SIGN -const GET_PATIENT_VITAL_SIGN = 'Services/Doctors.svc/REST/Doctor_GetPatientVitalSign'; +const GET_PATIENT_VITAL_SIGN = + 'Services/Doctors.svc/REST/Doctor_GetPatientVitalSign'; ///Er Nearest -const GET_NEAREST_HOSPITAL = 'Services/Patients.svc/REST/Patient_GetProjectAvgERWaitingTime'; +const GET_NEAREST_HOSPITAL = + 'Services/Patients.svc/REST/Patient_GetProjectAvgERWaitingTime'; ///ED Online -const ER_GET_VISUAL_TRIAGE_QUESTIONS = "services/Doctors.svc/REST/ER_GetVisualTriageQuestions"; -const ER_SAVE_TRIAGE_INFORMATION = "services/Doctors.svc/REST/ER_SaveTriageInformation"; -const ER_GetPatientPaymentInformationForERClinic = "services/Doctors.svc/REST/ER_GetPatientPaymentInformationForERClinic"; +const ER_GET_VISUAL_TRIAGE_QUESTIONS = + "services/Doctors.svc/REST/ER_GetVisualTriageQuestions"; +const ER_SAVE_TRIAGE_INFORMATION = + "services/Doctors.svc/REST/ER_SaveTriageInformation"; +const ER_GetPatientPaymentInformationForERClinic = + "services/Doctors.svc/REST/ER_GetPatientPaymentInformationForERClinic"; ///Er Nearest -const GET_AMBULANCE_REQUEST = 'Services/Patients.svc/REST/PatientER_RRT_GetAllTransportationMethod'; -const GET_PATIENT_ALL_PRES_ORDERS = 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; -const GET_PICK_UP_REQUEST_BY_PRES_ORDER_ID = 'Services/Patients.svc/REST/PatientER_RRT_GetPickUpRequestByPresOrderID'; -const UPDATE_PRESS_ORDER = 'Services/Patients.svc/REST/PatientER_UpdatePresOrder'; -const INSERT_ER_INERT_PRES_ORDER = 'Services/Patients.svc/REST/PatientER_InsertPresOrder'; +const GET_AMBULANCE_REQUEST = + 'Services/Patients.svc/REST/PatientER_RRT_GetAllTransportationMethod'; +const GET_PATIENT_ALL_PRES_ORDERS = + 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; +const GET_PICK_UP_REQUEST_BY_PRES_ORDER_ID = + 'Services/Patients.svc/REST/PatientER_RRT_GetPickUpRequestByPresOrderID'; +const UPDATE_PRESS_ORDER = + 'Services/Patients.svc/REST/PatientER_UpdatePresOrder'; +const INSERT_ER_INERT_PRES_ORDER = + 'Services/Patients.svc/REST/PatientER_InsertPresOrder'; /// ER RRT const GET_ALL_RC_TRANSPORTATION = 'rc/api/Transportation/getalltransportation'; const GET_ALL_TRANSPORTATIONS_RC = 'rc/api/Transportation/getalltransportation'; -const GET_ALL_RRT_QUESTIONS = 'Services/Patients.svc/REST/PatientER_RRT_GetAllQuestions'; -const GET_RRT_SERVICE_PRICE = 'Services/Patients.svc/REST/PatientE_RealRRT_GetServicePrice'; +const GET_ALL_RRT_QUESTIONS = + 'Services/Patients.svc/REST/PatientER_RRT_GetAllQuestions'; +const GET_RRT_SERVICE_PRICE = + 'Services/Patients.svc/REST/PatientE_RealRRT_GetServicePrice'; const GET_ALL_TRANSPORTATIONS_ORDERS = 'rc/api/Transportation/get'; @@ -128,13 +160,15 @@ const GET_FINDUS_REQUEST = 'Services/Lists.svc/REST/Get_HMG_Locations'; const GET_LIVECHAT_REQUEST = 'Services/Patients.svc/REST/GetPatientICProjects'; ///babyInformation -const GET_BABYINFORMATION_REQUEST = 'Services/Community.svc/REST/GetBabyByUserID'; +const GET_BABYINFORMATION_REQUEST = + 'Services/Community.svc/REST/GetBabyByUserID'; ///Get Baby By User ID const GET_BABY_BY_USER_ID = 'Services/Community.svc/REST/GetBabyByUserID'; ///userInformation -const GET_USERINFORMATION_REQUEST = 'Services/Community.svc/REST/GetUserInformation_New'; +const GET_USERINFORMATION_REQUEST = + 'Services/Community.svc/REST/GetUserInformation_New'; ///Update email const UPDATE_PATENT_EMAIL = 'Services/Patients.svc/REST/UpdatePateintEmail'; @@ -156,24 +190,34 @@ const GET_TABLE_REQUEST = 'Services/Community.svc/REST/CreateVaccinationTable'; const GET_CITIES_REQUEST = 'Services/Lists.svc/REST/GetAllCities'; ///BloodDetails -const GET_BLOOD_REQUEST = 'services/PatientVarification.svc/REST/BloodDonation_GetBloodGroupDetails'; +const GET_BLOOD_REQUEST = + 'services/PatientVarification.svc/REST/BloodDonation_GetBloodGroupDetails'; -const SAVE_BLOOD_REQUEST = 'Services/PatientVarification.svc/REST/BloodDonation_RegisterBloodType'; +const SAVE_BLOOD_REQUEST = + 'Services/PatientVarification.svc/REST/BloodDonation_RegisterBloodType'; -const GET_BLOOD_AGREEMENT = 'Services/PatientVarification.svc/REST/CheckUserAgreementForBloodDonation'; -const SAVE_BLOOD_AGREEMENT = 'Services/PatientVarification.svc/REST/AddUserAgreementForBloodDonation'; +const GET_BLOOD_AGREEMENT = + 'Services/PatientVarification.svc/REST/CheckUserAgreementForBloodDonation'; +const SAVE_BLOOD_AGREEMENT = + 'Services/PatientVarification.svc/REST/AddUserAgreementForBloodDonation'; ///Reports const REPORTS = 'Services/Doctors.svc/REST/GetPatientMedicalReportStatusInfo'; -const INSERT_REQUEST_FOR_MEDICAL_REPORT = 'Services/Doctors.svc/REST/InsertRequestForMedicalReport'; -const SEND_MEDICAL_REPORT_EMAIL = 'Services/Notifications.svc/REST/SendMedicalReportEmail'; +const INSERT_REQUEST_FOR_MEDICAL_REPORT = + 'Services/Doctors.svc/REST/InsertRequestForMedicalReport'; +const SEND_MEDICAL_REPORT_EMAIL = + 'Services/Notifications.svc/REST/SendMedicalReportEmail'; ///Rate // const IS_LAST_APPOITMENT_RATED = 'Services/Doctors.svc/REST/IsLastAppoitmentRated'; -const IS_LAST_APPOITMENT_RATED = 'Services/Doctors.svc/REST/IsLastAppoitmentRated_Async'; -const GET_APPOINTMENT_DETAILS_BY_NO = 'Services/MobileNotifications.svc/REST/GetAppointmentDetailsByApptNo'; -const NEW_RATE_APPOINTMENT_URL = "Services/Doctors.svc/REST/AppointmentsRating_InsertAppointmentRate"; -const NEW_RATE_DOCTOR_URL = "Services/Doctors.svc/REST/DoctorsRating_InsertDoctorRate"; +const IS_LAST_APPOITMENT_RATED = + 'Services/Doctors.svc/REST/IsLastAppoitmentRated_Async'; +const GET_APPOINTMENT_DETAILS_BY_NO = + 'Services/MobileNotifications.svc/REST/GetAppointmentDetailsByApptNo'; +const NEW_RATE_APPOINTMENT_URL = + "Services/Doctors.svc/REST/AppointmentsRating_InsertAppointmentRate"; +const NEW_RATE_DOCTOR_URL = + "Services/Doctors.svc/REST/DoctorsRating_InsertDoctorRate"; const GET_QR_PARKING = 'Services/SWP.svc/REST/GetQRParkingByID'; @@ -181,7 +225,8 @@ const GET_QR_PARKING = 'Services/SWP.svc/REST/GetQRParkingByID'; const GET_CLINICS_LIST_URL = "Services/lists.svc/REST/GetClinicCentralized"; //URL to get active appointment list -const GET_ACTIVE_APPOINTMENTS_LIST_URL = "Services/Doctors.svc/Rest/Dr_GetAppointmentActiveNumber"; +const GET_ACTIVE_APPOINTMENTS_LIST_URL = + "Services/Doctors.svc/Rest/Dr_GetAppointmentActiveNumber"; //URL to get projects list const GET_PROJECTS_LIST = 'Services/Lists.svc/REST/GetProject'; @@ -190,93 +235,128 @@ const GET_PROJECTS_LIST = 'Services/Lists.svc/REST/GetProject'; const GET_DOCTORS_LIST_URL = "Services/Doctors.svc/REST/SearchDoctorsByTime"; //URL to dental doctors list -const GET_DENTAL_DOCTORS_LIST_URL = "Services/Doctors.svc/REST/Dental_DoctorChiefComplaintMapping"; +const GET_DENTAL_DOCTORS_LIST_URL = + "Services/Doctors.svc/REST/Dental_DoctorChiefComplaintMapping"; //URL to get doctor free slots const GET_DOCTOR_FREE_SLOTS = "Services/Doctors.svc/REST/GetDoctorFreeSlots"; //URL to insert appointment -const INSERT_SPECIFIC_APPOINTMENT = "Services/Doctors.svc/REST/InsertSpecificAppointment"; +const INSERT_SPECIFIC_APPOINTMENT = + "Services/Doctors.svc/REST/InsertSpecificAppointment"; //URL to get patient share -const GET_PATIENT_SHARE = "Services/Doctors.svc/REST/GetCheckinScreenAppointmentDetailsByAppointmentNO"; +const GET_PATIENT_SHARE = + "Services/Doctors.svc/REST/GetCheckinScreenAppointmentDetailsByAppointmentNO"; //URL to get patient appointment history -const GET_PATIENT_APPOINTMENT_HISTORY = "Services/Doctors.svc/REST/PateintHasAppoimentHistory"; +const GET_PATIENT_APPOINTMENT_HISTORY = + "Services/Doctors.svc/REST/PateintHasAppoimentHistory"; -const DOCTOR_SCHEDULE_URL = 'Services/Doctors.svc/REST/GetDoctorWorkingHoursTable'; +const DOCTOR_SCHEDULE_URL = + 'Services/Doctors.svc/REST/GetDoctorWorkingHoursTable'; -const SEND_REPORT_EYE_EMAIL = "Services/Notifications.svc/REST/SendGlassesPrescriptionEmail"; +const SEND_REPORT_EYE_EMAIL = + "Services/Notifications.svc/REST/SendGlassesPrescriptionEmail"; -const SEND_CONTACT_LENS_PRESCRIPTION_EMAIL = "Services/Notifications.svc/REST/SendContactLensPrescriptionEmail"; +const SEND_CONTACT_LENS_PRESCRIPTION_EMAIL = + "Services/Notifications.svc/REST/SendContactLensPrescriptionEmail"; //URL to get patient appointment curfew history // const GET_PATIENT_APPOINTMENT_CURFEW_HISTORY = "Services/Doctors.svc/REST/AppoimentHistoryForCurfew"; -const GET_PATIENT_APPOINTMENT_CURFEW_HISTORY = "Services/Doctors.svc/REST/AppoimentHistoryForCurfew_Async"; +const GET_PATIENT_APPOINTMENT_CURFEW_HISTORY = + "Services/Doctors.svc/REST/AppoimentHistoryForCurfew_Async"; //URL to confirm appointment -const CONFIRM_APPOINTMENT = "Services/MobileNotifications.svc/REST/ConfirmAppointment"; +const CONFIRM_APPOINTMENT = + "Services/MobileNotifications.svc/REST/ConfirmAppointment"; -const INSERT_VIDA_REQUEST = "Services/ER_VirtualCall.svc/REST/PatientER_VidaRequestInseart"; +const INSERT_VIDA_REQUEST = + "Services/ER_VirtualCall.svc/REST/PatientER_VidaRequestInseart"; //URL to cancel appointment const CANCEL_APPOINTMENT = "Services/Doctors.svc/REST/CancelAppointment"; //URL get appointment QR -const GENERATE_QR_APPOINTMENT = "Services/Doctors.svc/REST/GenerateQRAppointmentNo"; +const GENERATE_QR_APPOINTMENT = + "Services/Doctors.svc/REST/GenerateQRAppointmentNo"; //URL send email appointment QR -const EMAIL_QR_APPOINTMENT = "Services/Notifications.svc/REST/sendEmailForOnLineCheckin"; +const EMAIL_QR_APPOINTMENT = + "Services/Notifications.svc/REST/sendEmailForOnLineCheckin"; //URL check payment status -const CHECK_PAYMENT_STATUS = "Services/PayFort_Serv.svc/REST/GetRequestStatusByRequestID"; +const CHECK_PAYMENT_STATUS = + "Services/PayFort_Serv.svc/REST/GetRequestStatusByRequestID"; //URL create advance payment const CREATE_ADVANCE_PAYMENT = "Services/Doctors.svc/REST/CreateAdvancePayment"; -const HIS_CREATE_ADVANCE_PAYMENT = "Services/Patients.svc/REST/HIS_CreateAdvancePayment"; +const HIS_CREATE_ADVANCE_PAYMENT = + "Services/Patients.svc/REST/HIS_CreateAdvancePayment"; -const ADD_ADVANCE_NUMBER_REQUEST = 'Services/PayFort_Serv.svc/REST/AddAdvancedNumberRequest'; +const ADD_ADVANCE_NUMBER_REQUEST = + 'Services/PayFort_Serv.svc/REST/AddAdvancedNumberRequest'; -const IS_ALLOW_ASK_DOCTOR = 'Services/Doctors.svc/REST/GetPatientDoctorAppointmentResult'; -const GET_CALL_REQUEST_TYPE = 'Services/Doctors.svc/REST/GetCallRequestType_LOV'; -const ADD_VIDA_REQUEST = 'Services/ER_VirtualCall.svc/REST/PatientER_VidaRequestInseart'; +const IS_ALLOW_ASK_DOCTOR = + 'Services/Doctors.svc/REST/GetPatientDoctorAppointmentResult'; +const GET_CALL_REQUEST_TYPE = + 'Services/Doctors.svc/REST/GetCallRequestType_LOV'; +const ADD_VIDA_REQUEST = + 'Services/ER_VirtualCall.svc/REST/PatientER_VidaRequestInseart'; const SEND_CALL_REQUEST = 'Services/Doctors.svc/REST/InsertCallInfo'; -const GET_LIVECARE_CLINICS = 'Services/ER_VirtualCall.svc/REST/PatientER_GetClinics'; +const GET_LIVECARE_CLINICS = + 'Services/ER_VirtualCall.svc/REST/PatientER_GetClinics'; -const GET_LIVECARE_SCHEDULE_CLINICS = 'Services/Doctors.svc/REST/PatientER_GetClinicsHaveSchedule'; +const GET_LIVECARE_SCHEDULE_CLINICS = + 'Services/Doctors.svc/REST/PatientER_GetClinicsHaveSchedule'; -const GET_LIVECARE_SCHEDULE_CLINIC_DOCTOR_LIST = 'Services/Doctors.svc/REST/PatientER_GetDoctorByClinicID'; +const GET_LIVECARE_SCHEDULE_CLINIC_DOCTOR_LIST = + 'Services/Doctors.svc/REST/PatientER_GetDoctorByClinicID'; -const GET_LIVECARE_SCHEDULE_DOCTOR_TIME_SLOTS = 'Services/Doctors.svc/REST/PatientER_GetDoctorFreeSlots'; +const GET_LIVECARE_SCHEDULE_DOCTOR_TIME_SLOTS = + 'Services/Doctors.svc/REST/PatientER_GetDoctorFreeSlots'; -const INSERT_LIVECARE_SCHEDULE_APPOINTMENT = 'Services/Doctors.svc/REST/InsertSpecificAppoitmentForSchedule'; +const INSERT_LIVECARE_SCHEDULE_APPOINTMENT = + 'Services/Doctors.svc/REST/InsertSpecificAppoitmentForSchedule'; -const GET_PATIENT_SHARE_LIVECARE = "Services/Doctors.svc/REST/GetCheckinScreenAppointmentDetailsByAppointmentNOForLiveCare"; +const GET_PATIENT_SHARE_LIVECARE = + "Services/Doctors.svc/REST/GetCheckinScreenAppointmentDetailsByAppointmentNOForLiveCare"; -const GET_LIVECARE_CLINIC_TIMING = 'Services/ER_VirtualCall.svc/REST/PatientER_GetClinicsServiceTimingsSchedule'; +const GET_LIVECARE_CLINIC_TIMING = + 'Services/ER_VirtualCall.svc/REST/PatientER_GetClinicsServiceTimingsSchedule'; -const GET_ER_APPOINTMENT_FEES = 'Services/DoctorApplication.svc/REST/GetERAppointmentFees'; +const GET_ER_APPOINTMENT_FEES = + 'Services/DoctorApplication.svc/REST/GetERAppointmentFees'; const GET_ER_APPOINTMENT_TIME = 'Services/ER_VirtualCall.svc/REST/GetRestTime'; -const ADD_NEW_CALL_FOR_PATIENT_ER = 'Services/DoctorApplication.svc/REST/NewCallForPatientER'; +const ADD_NEW_CALL_FOR_PATIENT_ER = + 'Services/DoctorApplication.svc/REST/NewCallForPatientER'; -const GET_LIVECARE_HISTORY = 'Services/ER_VirtualCall.svc/REST/GetPatientErVirtualHistory'; -const CANCEL_LIVECARE_REQUEST = 'Services/ER_VirtualCall.svc/REST/DeleteErRequest'; -const SEND_LIVECARE_INVOICE_EMAIL = 'Services/Notifications.svc/REST/SendInvoiceForLiveCare'; +const GET_LIVECARE_HISTORY = + 'Services/ER_VirtualCall.svc/REST/GetPatientErVirtualHistory'; +const CANCEL_LIVECARE_REQUEST = + 'Services/ER_VirtualCall.svc/REST/DeleteErRequest'; +const SEND_LIVECARE_INVOICE_EMAIL = + 'Services/Notifications.svc/REST/SendInvoiceForLiveCare'; -const APPLE_PAY_INSERT_REQUEST = 'Services/PayFort_Serv.svc/REST/PayFort_ApplePayRequestData_Insert'; +const APPLE_PAY_INSERT_REQUEST = + 'Services/PayFort_Serv.svc/REST/PayFort_ApplePayRequestData_Insert'; const GET_USER_TERMS = 'Services/Patients.svc/REST/GetUserTermsAndConditions'; -const UPDATE_HEALTH_TERMS = 'services/Patients.svc/REST/UpdatePateintHealthSummaryReport'; +const UPDATE_HEALTH_TERMS = + 'services/Patients.svc/REST/UpdatePateintHealthSummaryReport'; -const GET_PATIENT_HEALTH_STATS = 'Services/Patients.svc/REST/Med_GetTransactionsSts'; +const GET_PATIENT_HEALTH_STATS = + 'Services/Patients.svc/REST/Med_GetTransactionsSts'; -const SEND_CHECK_IN_NFC_REQUEST = 'Services/Patients.svc/REST/Patient_CheckAppointmentValidation_ForNFC'; +const SEND_CHECK_IN_NFC_REQUEST = + 'Services/Patients.svc/REST/Patient_CheckAppointmentValidation_ForNFC'; -const HAS_DENTAL_PLAN = 'Services/Doctors.svc/REST/Dental_IsPatientHasOnGoingEstimation'; +const HAS_DENTAL_PLAN = + 'Services/Doctors.svc/REST/Dental_IsPatientHasOnGoingEstimation'; //URL to get medicine and pharmacies list const CHANNEL = 3; @@ -297,16 +377,21 @@ var DeviceTypeID = Platform.isIOS ? 1 : 2; const LANGUAGE_ID = 2; const GET_PHARMCY_ITEMS = "Services/Lists.svc/REST/GetPharmcyItems_Region"; const GET_PHARMACY_LIST = "Services/Patients.svc/REST/GetPharmcyList"; -const GET_PAtIENTS_INSURANCE = "Services/Patients.svc/REST/Get_PatientInsuranceDetails"; -const GET_PAtIENTS_INSURANCE_UPDATED = "Services/Patients.svc/REST/PatientER_GetPatientInsuranceCardUpdateHistory"; +const GET_PAtIENTS_INSURANCE = + "Services/Patients.svc/REST/Get_PatientInsuranceDetails"; +const GET_PAtIENTS_INSURANCE_UPDATED = + "Services/Patients.svc/REST/PatientER_GetPatientInsuranceCardUpdateHistory"; const INSURANCE_DETAILS = "Services/Patients.svc/REST/Get_InsuranceCheckList"; -const GET_PATIENT_INSURANCE_DETAILS = "Services/Patients.svc/REST/PatientER_GetPatientInsuranceDetails"; -const UPLOAD_INSURANCE_CARD = 'Services/Patients.svc/REST/PatientER_PatientInfoForInsuranceCardUpdate'; +const GET_PATIENT_INSURANCE_DETAILS = + "Services/Patients.svc/REST/PatientER_GetPatientInsuranceDetails"; +const UPLOAD_INSURANCE_CARD = + 'Services/Patients.svc/REST/PatientER_PatientInfoForInsuranceCardUpdate'; const GET_VACCINES = "Services/Patients.svc/REST/GetDoneVaccinesByPatientID"; const GET_VACCINES_EMAIL = "Services/Notifications.svc/REST/SendVaccinesEmail"; -const GET_PAtIENTS_INSURANCE_APPROVALS = "Services/Patients.svc/REST/GetApprovalStatus_Async"; +const GET_PAtIENTS_INSURANCE_APPROVALS = + "Services/Patients.svc/REST/GetApprovalStatus_Async"; // const GET_PAtIENTS_INSURANCE_APPROVALS = "Services/Patients.svc/REST/GetApprovalStatus"; const SEARCH_BOT = 'HabibiChatBotApi/BotInterface/GetVoiceCommandResponse'; @@ -317,54 +402,86 @@ const GET_PATIENT_SICK_LEAVE = 'Services/Patients.svc/REST/GetPatientSickLeave'; const SendSickLeaveEmail = 'Services/Notifications.svc/REST/SendSickLeaveEmail'; -const GET_PATIENT_AdVANCE_BALANCE_AMOUNT = 'Services/Patients.svc/REST/GetPatientAdvanceBalanceAmount'; -const GET_PATIENT_INFO_BY_ID = 'Services/Doctors.svc/REST/GetPatientInfoByPatientID'; -const GET_PATIENT_INFO_BY_ID_AND_MOBILE_NUMBER = 'Services/Patients.svc/REST/AP_GetPatientInfoByPatientIDandMobileNumber'; -const SEND_ACTIVATION_CODE_FOR_ADVANCE_PAYMENT = 'Services/Authentication.svc/REST/SendActivationCodeForAdvancePayment'; -const CHECK_ACTIVATION_CODE_FOR_ADVANCE_PAYMENT = 'Services/Authentication.svc/REST/CheckActivationCodeForAdvancePayment'; +const GET_PATIENT_AdVANCE_BALANCE_AMOUNT = + 'Services/Patients.svc/REST/GetPatientAdvanceBalanceAmount'; +const GET_PATIENT_INFO_BY_ID = + 'Services/Doctors.svc/REST/GetPatientInfoByPatientID'; +const GET_PATIENT_INFO_BY_ID_AND_MOBILE_NUMBER = + 'Services/Patients.svc/REST/AP_GetPatientInfoByPatientIDandMobileNumber'; +const SEND_ACTIVATION_CODE_FOR_ADVANCE_PAYMENT = + 'Services/Authentication.svc/REST/SendActivationCodeForAdvancePayment'; +const CHECK_ACTIVATION_CODE_FOR_ADVANCE_PAYMENT = + 'Services/Authentication.svc/REST/CheckActivationCodeForAdvancePayment'; -const GET_COVID_DRIVETHRU_PROJECT_LIST = 'Services/Doctors.svc/REST/COVID19_ProjectDriveThroughTestingCenter'; +const GET_COVID_DRIVETHRU_PROJECT_LIST = + 'Services/Doctors.svc/REST/COVID19_ProjectDriveThroughTestingCenter'; -const GET_COVID_DRIVETHRU_PAYMENT_INFO = 'Services/Doctors.svc/REST/COVID19_GetPatientPaymentInormation'; +const GET_COVID_DRIVETHRU_PAYMENT_INFO = + 'Services/Doctors.svc/REST/COVID19_GetPatientPaymentInormation'; -const GET_COVID_DRIVETHRU_FREE_SLOTS = 'Services/Doctors.svc/REST/COVID19_GetFreeSlots'; +const GET_COVID_DRIVETHRU_FREE_SLOTS = + 'Services/Doctors.svc/REST/COVID19_GetFreeSlots'; -const GET_COVID_DRIVETHRU_PROCEDURES_LIST = 'Services/Doctors.svc/REST/COVID19_GetTestProcedures'; +const GET_COVID_DRIVETHRU_PROCEDURES_LIST = + 'Services/Doctors.svc/REST/COVID19_GetTestProcedures'; ///Smartwatch Integration Services -const GET_PATIENT_LAST_RECORD = 'Services/Patients.svc/REST/Med_GetPatientLastRecord'; -const INSERT_PATIENT_HEALTH_DATA = 'Services/Patients.svc/REST/Med_InsertTransactions'; +const GET_PATIENT_LAST_RECORD = + 'Services/Patients.svc/REST/Med_GetPatientLastRecord'; +const INSERT_PATIENT_HEALTH_DATA = + 'Services/Patients.svc/REST/Med_InsertTransactions'; ///My Trackers -const GET_DIABETIC_RESULT_AVERAGE = 'Services/Patients.svc/REST/Patient_GetDiabeticResultAverage'; -const GET_DIABTEC_RESULT = 'Services/Patients.svc/REST/Patient_GetDiabtecResults'; -const ADD_DIABTEC_RESULT = 'Services/Patients.svc/REST/Patient_AddDiabtecResult'; - -const GET_BLOOD_PRESSURE_RESULT_AVERAGE = 'Services/Patients.svc/REST/Patient_GetBloodPressureResultAverage'; -const GET_BLOOD_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_GetBloodPressureResult'; -const ADD_BLOOD_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_AddBloodPressureResult'; - -const GET_WEIGHT_PRESSURE_RESULT_AVERAGE = 'Services/Patients.svc/REST/Patient_GetWeightMeasurementResultAverage'; -const GET_WEIGHT_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_GetWeightMeasurementResult'; -const ADD_WEIGHT_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_AddWeightMeasurementResult'; - -const ADD_ACTIVE_PRESCRIPTIONS_REPORT_BY_PATIENT_ID = 'Services/Patients.svc/Rest/GetActivePrescriptionReportByPatientID'; - -const GET_CALL_INFO_HOURS_RESULT = 'Services/Doctors.svc/REST/GetCallInfoHoursResult'; -const GET_CALL_REQUEST_TYPE_LOV = 'Services/Doctors.svc/REST/GetCallRequestType_LOV'; - -const UPDATE_DIABETIC_RESULT = 'Services/Patients.svc/REST/Patient_UpdateDiabeticResult'; - -const SEND_AVERAGE_BLOOD_SUGAR_REPORT = 'Services/Notifications.svc/REST/SendAverageBloodSugarReport'; -const DEACTIVATE_DIABETIC_STATUS = 'services/Patients.svc/REST/Patient_DeactivateDiabeticStatus'; -const DEACTIVATE_BLOOD_PRESSURES_STATUS = 'services/Patients.svc/REST/Patient_DeactivateBloodPressureStatus'; - -const UPDATE_BLOOD_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_UpdateBloodPressureResult'; -const SEND_AVERAGE_BLOOD_WEIGHT_REPORT = 'Services/Notifications.svc/REST/SendAverageBodyWeightReport'; -const SEND_AVERAGE_BLOOD_PRESSURE_REPORT = 'Services/Notifications.svc/REST/SendAverageBloodPressureReport'; - -const UPDATE_WEIGHT_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_UpdateWeightMeasurementResult'; -const DEACTIVATE_WEIGHT_PRESSURE_RESULT = 'services/Patients.svc/REST/Patient_DeactivateWeightMeasurementStatus'; +const GET_DIABETIC_RESULT_AVERAGE = + 'Services/Patients.svc/REST/Patient_GetDiabeticResultAverage'; +const GET_DIABTEC_RESULT = + 'Services/Patients.svc/REST/Patient_GetDiabtecResults'; +const ADD_DIABTEC_RESULT = + 'Services/Patients.svc/REST/Patient_AddDiabtecResult'; + +const GET_BLOOD_PRESSURE_RESULT_AVERAGE = + 'Services/Patients.svc/REST/Patient_GetBloodPressureResultAverage'; +const GET_BLOOD_PRESSURE_RESULT = + 'Services/Patients.svc/REST/Patient_GetBloodPressureResult'; +const ADD_BLOOD_PRESSURE_RESULT = + 'Services/Patients.svc/REST/Patient_AddBloodPressureResult'; + +const GET_WEIGHT_PRESSURE_RESULT_AVERAGE = + 'Services/Patients.svc/REST/Patient_GetWeightMeasurementResultAverage'; +const GET_WEIGHT_PRESSURE_RESULT = + 'Services/Patients.svc/REST/Patient_GetWeightMeasurementResult'; +const ADD_WEIGHT_PRESSURE_RESULT = + 'Services/Patients.svc/REST/Patient_AddWeightMeasurementResult'; + +const ADD_ACTIVE_PRESCRIPTIONS_REPORT_BY_PATIENT_ID = + 'Services/Patients.svc/Rest/GetActivePrescriptionReportByPatientID'; + +const GET_CALL_INFO_HOURS_RESULT = + 'Services/Doctors.svc/REST/GetCallInfoHoursResult'; +const GET_CALL_REQUEST_TYPE_LOV = + 'Services/Doctors.svc/REST/GetCallRequestType_LOV'; + +const UPDATE_DIABETIC_RESULT = + 'Services/Patients.svc/REST/Patient_UpdateDiabeticResult'; + +const SEND_AVERAGE_BLOOD_SUGAR_REPORT = + 'Services/Notifications.svc/REST/SendAverageBloodSugarReport'; +const DEACTIVATE_DIABETIC_STATUS = + 'services/Patients.svc/REST/Patient_DeactivateDiabeticStatus'; +const DEACTIVATE_BLOOD_PRESSURES_STATUS = + 'services/Patients.svc/REST/Patient_DeactivateBloodPressureStatus'; + +const UPDATE_BLOOD_PRESSURE_RESULT = + 'Services/Patients.svc/REST/Patient_UpdateBloodPressureResult'; +const SEND_AVERAGE_BLOOD_WEIGHT_REPORT = + 'Services/Notifications.svc/REST/SendAverageBodyWeightReport'; +const SEND_AVERAGE_BLOOD_PRESSURE_REPORT = + 'Services/Notifications.svc/REST/SendAverageBloodPressureReport'; + +const UPDATE_WEIGHT_PRESSURE_RESULT = + 'Services/Patients.svc/REST/Patient_UpdateWeightMeasurementResult'; +const DEACTIVATE_WEIGHT_PRESSURE_RESULT = + 'services/Patients.svc/REST/Patient_DeactivateWeightMeasurementStatus'; const GET_DOCTOR_RESPONSE = 'Services/Patients.svc/REST/GetDoctorResponse'; const UPDATE_READ_STATUS = 'Services/Patients.svc/REST/UpdateReadStatus'; const INSERT_CALL_INFO = 'Services/Doctors.svc/REST/InsertCallInfo'; @@ -372,25 +489,35 @@ const INSERT_CALL_INFO = 'Services/Doctors.svc/REST/InsertCallInfo'; const GET_PATIENT_ALLERGIES = 'Services/Patients.svc/REST/GetPatientAllergies'; // H2O -const H2O_GET_USER_PROGRESS = "Services/H2ORemainder.svc/REST/H2O_GetUserProgress"; -const H2O_INSERT_USER_ACTIVITY = "Services/H2ORemainder.svc/REST/H2O_InsertUserActivity"; -const H2O_GET_USER_DETAIL = "Services/H2ORemainder.svc/REST/H2O_GetUserDetails_New"; -const H2O_UPDATE_USER_DETAIL = "Services/H2ORemainder.svc/REST/H2O_UpdateUserDetails_New"; -const H2O_UNDO_USER_ACTIVITY = "Services/H2ORemainder.svc/REST/H2o_UndoUserActivity"; +const H2O_GET_USER_PROGRESS = + "Services/H2ORemainder.svc/REST/H2O_GetUserProgress"; +const H2O_INSERT_USER_ACTIVITY = + "Services/H2ORemainder.svc/REST/H2O_InsertUserActivity"; +const H2O_GET_USER_DETAIL = + "Services/H2ORemainder.svc/REST/H2O_GetUserDetails_New"; +const H2O_UPDATE_USER_DETAIL = + "Services/H2ORemainder.svc/REST/H2O_UpdateUserDetails_New"; +const H2O_UNDO_USER_ACTIVITY = + "Services/H2ORemainder.svc/REST/H2o_UndoUserActivity"; //E_Referral Services -const GET_ALL_RELATIONSHIP_TYPES = "Services/Patients.svc/REST/GetAllRelationshipTypes"; -const SEND_ACTIVATION_CODE_FOR_E_REFERRAL = 'Services/Authentication.svc/REST/SendActivationCodeForEReferral'; -const CHECK_ACTIVATION_CODE_FOR_E_REFERRAL = 'Services/Authentication.svc/REST/CheckActivationCodeForEReferral'; +const GET_ALL_RELATIONSHIP_TYPES = + "Services/Patients.svc/REST/GetAllRelationshipTypes"; +const SEND_ACTIVATION_CODE_FOR_E_REFERRAL = + 'Services/Authentication.svc/REST/SendActivationCodeForEReferral'; +const CHECK_ACTIVATION_CODE_FOR_E_REFERRAL = + 'Services/Authentication.svc/REST/CheckActivationCodeForEReferral'; const GET_ALL_CITIES = 'services/Lists.svc/rest/GetAllCities'; const CREATE_E_REFERRAL = "Services/Patients.svc/REST/CreateEReferral"; const GET_E_REFERRALS = "Services/Patients.svc/REST/GetEReferrals"; // Encillary Orders -const GET_ANCILLARY_ORDERS = 'Services/Doctors.svc/REST/GetOnlineAncillaryOrderList'; +const GET_ANCILLARY_ORDERS = + 'Services/Doctors.svc/REST/GetOnlineAncillaryOrderList'; -const GET_ANCILLARY_ORDERS_DETAILS = 'Services/Doctors.svc/REST/GetOnlineAncillaryOrderProcList'; +const GET_ANCILLARY_ORDERS_DETAILS = + 'Services/Doctors.svc/REST/GetOnlineAncillaryOrderProcList'; //Pharmacy wishlist // const GET_WISHLIST = "http://swd-pharapp-01:7200/api/shopping_cart_items/"; @@ -423,32 +550,50 @@ const GET_SHIPPING_OPTIONS = "get_shipping_option/"; const DELETE_SHOPPING_CART = "delete_shopping_cart_items/"; const DELETE_SHOPPING_CART_ALL = "delete_shopping_cart_item_by_customer/"; const ORDER_SHOPPING_CART = "orders"; -const GET_LACUM_ACCOUNT_INFORMATION = "Services/Patients.svc/REST/GetLakumAccountInformation"; -const GET_LACUM_GROUP_INFORMATION = "Services/Patients.svc/REST/GetlakumInQueryInfoGrouping"; -const LACUM_ACCOUNT_ACTIVATE = "Services/Patients.svc/REST/LakumAccountActivation"; -const LACUM_ACCOUNT_DEACTIVATE = "Services/Patients.svc/REST/LakumAccountDeactivation"; -const CREATE_LAKUM_ACCOUNT = "Services/Patients.svc/REST/PHR_CreateLakumAccount"; -const TRANSFER_YAHALA_LOYALITY_POINTS = "Services/Patients.svc/REST/TransferYaHalaLoyaltyPoints"; -const LAKUM_GET_USER_TERMS_AND_CONDITIONS = "Services/ERP.svc/REST/GetUserTermsAndConditionsForEPharmcy"; +const GET_LACUM_ACCOUNT_INFORMATION = + "Services/Patients.svc/REST/GetLakumAccountInformation"; +const GET_LACUM_GROUP_INFORMATION = + "Services/Patients.svc/REST/GetlakumInQueryInfoGrouping"; +const LACUM_ACCOUNT_ACTIVATE = + "Services/Patients.svc/REST/LakumAccountActivation"; +const LACUM_ACCOUNT_DEACTIVATE = + "Services/Patients.svc/REST/LakumAccountDeactivation"; +const CREATE_LAKUM_ACCOUNT = + "Services/Patients.svc/REST/PHR_CreateLakumAccount"; +const TRANSFER_YAHALA_LOYALITY_POINTS = + "Services/Patients.svc/REST/TransferYaHalaLoyaltyPoints"; +const LAKUM_GET_USER_TERMS_AND_CONDITIONS = + "Services/ERP.svc/REST/GetUserTermsAndConditionsForEPharmcy"; const PRESCRIPTION = 'Services/Patients.svc/REST/GetPrescriptionApptList'; const GET_RECOMMENDED_PRODUCT = 'alsoProduct/'; -const GET_MOST_VIEWED_PRODUCTS = "mostview?"; -const GET_NEW_PRODUCTS = "newproducts?"; +const GET_MOST_VIEWED_PRODUCTS = "mostview"; +const GET_NEW_PRODUCTS = "newproducts"; // Home Health Care -const HHC_GET_ALL_SERVICES = "Services/Patients.svc/REST/PatientER_HHC_GetAllServices"; -const HHC_GET_ALL_CMC_SERVICES = "Services/Patients.svc/REST/PatientER_CMC_GetAllServices"; -const PATIENT_ER_UPDATE_PRES_ORDER = "Services/Patients.svc/REST/PatientER_UpdatePresOrder"; -const GET_ORDER_DETAIL_BY_ID = "Services/Patients.svc/REST/PatientER_HHC_GetTransactionsForOrder"; -const GET_CMC_ORDER_DETAIL_BY_ID = "Services/Patients.svc/REST/PatientER_CMC_GetTransactionsForOrder"; +const HHC_GET_ALL_SERVICES = + "Services/Patients.svc/REST/PatientER_HHC_GetAllServices"; +const HHC_GET_ALL_CMC_SERVICES = + "Services/Patients.svc/REST/PatientER_CMC_GetAllServices"; +const PATIENT_ER_UPDATE_PRES_ORDER = + "Services/Patients.svc/REST/PatientER_UpdatePresOrder"; +const GET_ORDER_DETAIL_BY_ID = + "Services/Patients.svc/REST/PatientER_HHC_GetTransactionsForOrder"; +const GET_CMC_ORDER_DETAIL_BY_ID = + "Services/Patients.svc/REST/PatientER_CMC_GetTransactionsForOrder"; const GET_CHECK_UP_ITEMS = "Services/Patients.svc/REST/GetCheckUpItems"; -const PUSH_NOTIFICATION_GET_ALL_NOTIFICATIONS = 'Services/MobileNotifications.svc/REST/PushNotification_GetAllNotifications'; -const PUSH_NOTIFICATION_SET_MESSAGES_FROM_POOL_AS_READ = 'Services/MobileNotifications.svc/REST/PushNotification_SetMessagesFromPoolAsRead'; -const GET_PATIENT_ALL_PRES_ORD = 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; -const PATIENT_ER_INSERT_PRES_ORDER = 'Services/Patients.svc/REST/PatientER_InsertPresOrder'; +const PUSH_NOTIFICATION_GET_ALL_NOTIFICATIONS = + 'Services/MobileNotifications.svc/REST/PushNotification_GetAllNotifications'; +const PUSH_NOTIFICATION_SET_MESSAGES_FROM_POOL_AS_READ = + 'Services/MobileNotifications.svc/REST/PushNotification_SetMessagesFromPoolAsRead'; +const GET_PATIENT_ALL_PRES_ORD = + 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; +const PATIENT_ER_INSERT_PRES_ORDER = + 'Services/Patients.svc/REST/PatientER_InsertPresOrder'; const PHARMACY_MAKE_REVIEW = 'epharmacy/api/insertreviews'; -const BLOOD_DONATION_REGISTER_BLOOD_TYPE = 'Services/PatientVarification.svc/REST/BloodDonation_RegisterBloodType'; -const ADD_USER_AGREEMENT_FOR_BLOOD_DONATION = 'Services/PatientVarification.svc/REST/AddUserAgreementForBloodDonation'; +const BLOOD_DONATION_REGISTER_BLOOD_TYPE = + 'Services/PatientVarification.svc/REST/BloodDonation_RegisterBloodType'; +const ADD_USER_AGREEMENT_FOR_BLOOD_DONATION = + 'Services/PatientVarification.svc/REST/AddUserAgreementForBloodDonation'; // HHC RC SERVICES const HHC_GET_ALL_SERVICES_RC = "rc/api/HHC/getallhhc"; @@ -473,7 +618,6 @@ const GET_ALL_PRESCRIPTION_ORDERS_RC = "rc/api/prescription/list"; const GET_ALL_PRESCRIPTION_INFO_RC = "rc/api/Prescription/info"; const UPDATE_PRESCRIPTION_ORDER_RC = 'rc/api/prescription/update'; - //Pharmacy wishlist const GET_WISHLIST = "shopping_cart_items/"; const DELETE_WISHLIST = "delete_shopping_cart_item_by_product?customer_id="; @@ -492,17 +636,21 @@ const GET_CUSTOMER_INFO = "VerifyCustomer"; //Pharmacy -const GET_PHARMACY_CATEGORISE = 'categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id=0'; +const GET_PHARMACY_CATEGORISE = + 'categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id=0'; const GET_OFFERS_CATEGORISE = 'discountcategories'; const GET_OFFERS_PRODUCTS = 'offerproducts/'; -const GET_CATEGORISE_PARENT = 'categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id='; +const GET_CATEGORISE_PARENT = + 'categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id='; const GET_PARENT_PRODUCTS = 'products?categoryid='; -const GET_SUB_CATEGORISE = 'categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id='; +const GET_SUB_CATEGORISE = + 'categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id='; const GET_SUB_PRODUCTS = 'products?categoryid='; const GET_FINAL_PRODUCTS = 'products?fields=id,reviews,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&CategoryId='; const GET_CLINIC_CATEGORY = 'Services/Doctors.svc/REST/DP_GetClinicCategory'; -const GET_DISEASE_BY_CLINIC_ID = 'Services/Doctors.svc/REST/DP_GetDiseasesByClinicID'; +const GET_DISEASE_BY_CLINIC_ID = + 'Services/Doctors.svc/REST/DP_GetDiseasesByClinicID'; const SEARCH_DOCTOR_BY_TIME = 'Services/Doctors.svc/REST/SearchDoctorsByTime'; const TIMER_MIN = 10; @@ -518,13 +666,17 @@ const SCAN_QR_CODE = 'productbysku/'; const FILTERED_PRODUCTS = 'products?categoryids='; -const GET_DOCTOR_LIST_CALCULATION = "Services/Doctors.svc/REST/GetCallculationDoctors"; +const GET_DOCTOR_LIST_CALCULATION = + "Services/Doctors.svc/REST/GetCallculationDoctors"; -const GET_ALL_APPOINTMENTS_FOR_DENTAL_CLINIC = "Services/Patients.svc/REST/GetDentalAppointments"; +const GET_ALL_APPOINTMENTS_FOR_DENTAL_CLINIC = + "Services/Patients.svc/REST/GetDentalAppointments"; -const GET_DENTAL_APPOINTMENT_INVOICE = "Services/Patients.svc/REST/HIS_eInvoiceForDentalByAppointmentNo"; +const GET_DENTAL_APPOINTMENT_INVOICE = + "Services/Patients.svc/REST/HIS_eInvoiceForDentalByAppointmentNo"; -const SEND_DENTAL_APPOINTMENT_INVOICE_EMAIL = "Services/Notifications.svc/REST/SendInvoiceForDental"; +const SEND_DENTAL_APPOINTMENT_INVOICE_EMAIL = + "Services/Notifications.svc/REST/SendInvoiceForDental"; class AppGlobal { static var context; diff --git a/lib/core/service/parmacyModule/parmacy_module_service.dart b/lib/core/service/parmacyModule/parmacy_module_service.dart index 6969deac..cc330ed7 100644 --- a/lib/core/service/parmacyModule/parmacy_module_service.dart +++ b/lib/core/service/parmacyModule/parmacy_module_service.dart @@ -19,14 +19,19 @@ class PharmacyModuleService extends BaseService { List manufacturerList = List(); List bestSellerProducts = List(); List lastVisitedProducts = List(); + 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(); @@ -52,12 +57,13 @@ 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); + await sharedPref.setObject( + PHARMACY_CUSTOMER_ID, customerInfo.customerId); } // await generatePharmacyToken(); }, onFailure: (String error, int statusCode) { @@ -77,9 +83,11 @@ 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; @@ -93,7 +101,8 @@ 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)); @@ -111,7 +120,8 @@ 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); @@ -137,7 +147,8 @@ 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)); @@ -160,7 +171,9 @@ class PharmacyModuleService extends BaseService { 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)); @@ -176,4 +189,30 @@ class PharmacyModuleService extends BaseService { } } } + + Future getMostViewedProducts() async { + hasError = false; + Map queryParams = { + 'fields': + '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) { + mostViewedProducts.clear(); + response['products'].forEach((item) { + mostViewedProducts.add(PharmacyProduct.fromJson(item)); + }); + // print("most viewed products ---------"); + // print(response); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, queryParams: queryParams); + } catch (error) { + hasError = true; + super.error = error.toString(); + // throw error; + } + } } diff --git a/lib/core/viewModels/pharmacyModule/MostViewedViewModel.dart b/lib/core/viewModels/pharmacyModule/MostViewedViewModel.dart new file mode 100644 index 00000000..a0f51038 --- /dev/null +++ b/lib/core/viewModels/pharmacyModule/MostViewedViewModel.dart @@ -0,0 +1,23 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; +import 'package:diplomaticquarterapp/locator.dart'; + +class MostViewedViewModel extends BaseViewModel { + PharmacyModuleService _pharmacyService = locator(); + + List get mostViewedProducts => + _pharmacyService.mostViewedProducts; + + getMostViewedProducts() async { + setState(ViewState.BusyLocal); + await _pharmacyService.getMostViewedProducts(); + // if (_pharmacyService.hasError) { + // error = _pharmacyService.error; + // setState(ViewState.Error); + // } else { + setState(ViewState.Idle); + // } + } +} diff --git a/lib/locator.dart b/lib/locator.dart index 30d1f788..c0a8bd51 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -7,6 +7,7 @@ import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_ import 'package:diplomaticquarterapp/core/viewModels/ancillary_orders_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/user_information_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/MostViewedViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/product_categories_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; @@ -305,11 +306,14 @@ void setupLocator() { locator.registerFactory(() => BrandViewModel()); locator.registerFactory(() => BestSellerViewModel()); locator.registerFactory(() => LastVisitedViewModel()); + locator.registerFactory(() => MostViewedViewModel()); // Offer And Packages //---------------------- - locator.registerLazySingleton(() => OffersAndPackagesServices()); // offerPackagesServices Service - locator.registerFactory(() => OfferCategoriesViewModel()); // Categories View Model + locator.registerLazySingleton( + () => OffersAndPackagesServices()); // offerPackagesServices Service + locator.registerFactory( + () => OfferCategoriesViewModel()); // Categories View Model locator.registerFactory(() => PackagesViewModel()); // Products View Model //pharmacy 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 9c6fa42e..a2f3ba6c 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -22,7 +22,6 @@ import 'package:provider/provider.dart'; import 'cart-order-preview.dart'; class CartOrderPage extends StatefulWidget { - final Function(int) changeTab; const CartOrderPage({Key key, this.changeTab}) : super(key: key); @@ -38,7 +37,6 @@ class _CartOrderPageState extends State { void initState() { super.initState(); getData(); - } @override @@ -58,7 +56,8 @@ class _CartOrderPageState extends State { showHomeAppBarIcon: false, isShowDecPage: false, isMainPharmacyPages: true, - showPharmacyCart: false, + //isBottomBar: true, + showPharmacyCart: true, baseViewModel: model, backgroundColor: Colors.white, body: !(model.cartResponse.shoppingCarts == null || @@ -105,8 +104,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) { @@ -403,27 +402,32 @@ class _OrderBottomWidgetState extends State { onPressed: isAgree // && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0 ? () => { - if(cart.isCartItemsOutOfStock()){ - // Toast msg - AppToast.showErrorToast(message: TranslationBase.of(context).outOfStockMsg) - }else { - Navigator.push( - context, - FadePage( - page: - OrderPreviewPage(widget.addresses))) - } - } + if (cart.isCartItemsOutOfStock()) + { + // Toast msg + AppToast.showErrorToast( + message: TranslationBase.of(context) + .outOfStockMsg) + } + else + { + Navigator.push( + context, + FadePage( + page: OrderPreviewPage( + widget.addresses))) + } + } : null, child: new Text( "${TranslationBase.of(context).checkOut}", style: new TextStyle( color: - isAgree ? Colors.white : Colors.grey.shade300, + isAgree ? Colors.white : Colors.grey.shade300, fontSize: 14), ), color: Color(0xFF4CAF50), - disabledColor:Color(0xFF848484), + disabledColor: Color(0xFF848484), // disabledColor: Color(0xff005aff), ) // RaisedButton( diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 0d0716cc..1f90f454 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/BannerPager.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/BestSellerWidget.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/GridViewButtons.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/MostViewedWidget.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/PrescriptionsWidget.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/ShopByBrandWidget.dart'; @@ -56,10 +57,11 @@ class _PharmacyPageState extends State { children: [ BannerPager(model), PrescriptionsWidget(), -// ShopByBrandWidget(), + //ShopByBrandWidget(), + MostViewedWidget(), RecentlyViewedWidget(), BestSellerWidget(), - ShopByBrandWidget(), + //ShopByBrandWidget(), ], ), ), diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index d33e3178..a962eb43 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -100,7 +100,8 @@ class __ProductDetailPageState extends State { await addToWishlistFunction(itemID: itemID, model: model); }, deleteFromWishlistFunction: () async { - await deleteFromWishlistFunction(itemID: itemID, model: model); + await deleteFromWishlistFunction( + itemID: itemID, model: model); }, isInWishList: isInWishList, addToCartFunction: addToCartFunction, @@ -121,7 +122,8 @@ 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) ], ), ), @@ -139,11 +141,15 @@ 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, ), @@ -158,7 +164,8 @@ 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, @@ -195,12 +202,16 @@ 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, ) ], ), @@ -211,10 +222,14 @@ 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(); } @@ -226,12 +241,16 @@ 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, ), ], ), @@ -242,7 +261,8 @@ class __ProductDetailPageState extends State { children: [ FlatButton( onPressed: () async { - GifLoaderDialogUtils.showMyDialog(context); + GifLoaderDialogUtils.showMyDialog( + context); await model.getProductLocationData(); GifLoaderDialogUtils.hideDialog(context); @@ -254,12 +274,16 @@ 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, ), ], ), @@ -292,10 +316,12 @@ class __ProductDetailPageState extends State { product: widget.product, productDetailViewModel: model, addToWishlistFunction: (itemID) async { - await addToWishlistFunction(itemID: itemID, model: model); + await addToWishlistFunction( + itemID: itemID, model: model); }, deleteFromWishlistFunction: (itemID) async { - await deleteFromWishlistFunction(itemID: itemID, model: model); + await deleteFromWishlistFunction( + itemID: itemID, model: model); }, ) ], @@ -316,7 +342,8 @@ class __ProductDetailPageState extends State { )); } - addToShoppingCartFunction({quantity, itemID, ProductDetailViewModel model}) async { + addToShoppingCartFunction( + {quantity, itemID, ProductDetailViewModel model}) async { GifLoaderDialogUtils.showMyDialog(context); await model.addToCartData(quantity, itemID); GifLoaderDialogUtils.hideDialog(context); @@ -345,6 +372,7 @@ class __ProductDetailPageState extends State { } } -notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model}) async { +notifyMeWhenAvailable( + {itemId, customerId, ProductDetailViewModel model}) async { await model.notifyMe(customerId, itemId); } diff --git a/lib/pages/pharmacies/widgets/home/MostViewedWidget.dart b/lib/pages/pharmacies/widgets/home/MostViewedWidget.dart new file mode 100644 index 00000000..aa160baa --- /dev/null +++ b/lib/pages/pharmacies/widgets/home/MostViewedWidget.dart @@ -0,0 +1,59 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/MostViewedViewModel.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/final_products_page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductTileItem.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:flutter/material.dart'; + +class MostViewedWidget extends StatelessWidget { + const MostViewedWidget({Key key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getMostViewedProducts(), + allowAny: true, + builder: (_, model, wi) => NetworkBaseView( + isLocalLoader: true, + baseViewModel: model, + child: Container( + child: Column( + children: [ + ViewAllHomeWidget( + TranslationBase.of(context).mostViewed, + FinalProductsPage( + id: "", + productType: 4, + )), + if (model.state != ViewState.BusyLocal) + Container( + height: MediaQuery.of(context).size.height / 3 + 20, + child: ListView.builder( + itemBuilder: (ctx, i) => ProductTileItem( + model.mostViewedProducts[i], + MediaQuery.of(context).size.height / 4 + 20), + scrollDirection: Axis.horizontal, + itemCount: model.mostViewedProducts.length, + ), + ) + else + Container( + height: 80, + child: Center( + child: CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ), + ), + ), + ], + ), + ), + )); + } +} diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 8772a60e..25c1bbc4 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -134,7 +134,8 @@ class AppScaffold extends StatefulWidget { } class _AppScaffoldState extends State { - AuthenticatedUserObject authenticatedUserObject = locator(); + AuthenticatedUserObject authenticatedUserObject = + locator(); AppBarWidget appBar; @override @@ -183,7 +184,8 @@ class _AppScaffoldState extends State { builder: (BuildContext context) { return InkWell( onTap: () { - Provider.of(context, listen: false).changeCurrentTab(0); + Provider.of(context, listen: false) + .changeCurrentTab(0); }, child: Container( height: 2.0, @@ -213,9 +215,12 @@ class _AppScaffoldState extends State { AppGlobal.context = context; PharmacyPagesViewModel pagesViewModel = Provider.of(context); - bool isUserNotLogin = (!Provider.of(context, listen: false).isLogin && widget.isShowDecPage); + bool isUserNotLogin = + (!Provider.of(context, listen: false).isLogin && + widget.isShowDecPage); return Scaffold( - backgroundColor: widget.backgroundColor ?? CustomColors.appBackgroudGrey2Color, + backgroundColor: + widget.backgroundColor ?? CustomColors.appBackgroudGrey2Color, // appBar: widget.isShowPharmacyAppbar // ? pharmacyAppbar() @@ -248,7 +253,8 @@ class _AppScaffoldState extends State { isPharmacy: widget.isPharmacy, showPharmacyCart: widget.showPharmacyCart, isOfferPackages: widget.isOfferPackages, - showOfferPackagesCart: widget.showOfferPackagesCart, + showOfferPackagesCart: + widget.showOfferPackagesCart, isShowDecPage: widget.isShowDecPage, backButtonTab: widget.backButtonTab, ) @@ -287,7 +293,10 @@ class _AppScaffoldState extends State { widget.changeCurrentTab(value); } else { Navigator.pushAndRemoveUntil( - locator().navigatorKey.currentContext, MaterialPageRoute(builder: (context) => LandingPagePharmacy(currentTab: value)), (Route r) => false); + locator().navigatorKey.currentContext, + MaterialPageRoute( + builder: (context) => LandingPagePharmacy(currentTab: value)), + (Route r) => false); } } @@ -297,7 +306,9 @@ class _AppScaffoldState extends State { try { String barcode = result; GifLoaderDialogUtils.showMyDialog(context); - await BaseAppClient().getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode", onSuccess: (dynamic response, int statusCode) { + 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); @@ -307,7 +318,8 @@ class _AppScaffoldState extends State { AppToast.showErrorToast(message: "Product not found"); }); } catch (apiEx) { - AppToast.showErrorToast(message: "Something went wrong, please try again"); + AppToast.showErrorToast( + message: "Something went wrong, please try again"); } } catch (barcodeEx) {} } @@ -317,7 +329,10 @@ class _AppScaffoldState extends State { } buildBodyWidget(context) { - return Stack(children: [widget.body, widget.isHelp == true ? RobotIcon() : Container()]); + return Stack(children: [ + widget.body, + widget.isHelp == true ? RobotIcon() : Container() + ]); } } @@ -331,7 +346,16 @@ class NewAppBarWidget extends StatelessWidget with PreferredSizeWidget { final List appBarIcons; Function onTap; - NewAppBarWidget({Key key, this.showTitle = false, this.showDropDown = false, this.title = "", this.dropDownList, this.appBarIcons, this.dropdownIndexValue, this.dropDownIndexChange, this.onTap}) + NewAppBarWidget( + {Key key, + this.showTitle = false, + this.showDropDown = false, + this.title = "", + this.dropDownList, + this.appBarIcons, + this.dropdownIndexValue, + this.dropDownIndexChange, + this.onTap}) : super(key: key); @override @@ -356,7 +380,13 @@ class NewAppBarWidget extends StatelessWidget with PreferredSizeWidget { title, maxLines: 1, style: TextStyle( - fontSize: 24, fontFamily: (projectViewModel.isArabic ? 'Cairo' : 'Poppins'), fontWeight: FontWeight.w700, color: Color(0xff2B353E), letterSpacing: -1.44, height: 35 / 24), + fontSize: 24, + fontFamily: + (projectViewModel.isArabic ? 'Cairo' : 'Poppins'), + fontWeight: FontWeight.w700, + color: Color(0xff2B353E), + letterSpacing: -1.44, + height: 35 / 24), ), ), if (showDropDown) @@ -368,7 +398,8 @@ class NewAppBarWidget extends StatelessWidget with PreferredSizeWidget { alignedDropdown: true, child: DropdownButton( iconEnabledColor: CustomColors.grey2, - style: TextStyle(color: CustomColors.lightGreyColor, fontSize: 12), + style: TextStyle( + color: CustomColors.lightGreyColor, fontSize: 12), dropdownColor: CustomColors.lightGreyColor, value: dropdownIndexValue, items: [ @@ -379,7 +410,9 @@ class NewAppBarWidget extends StatelessWidget with PreferredSizeWidget { dropDownList[i], style: TextStyle( fontSize: 12, - fontFamily: (projectViewModel.isArabic ? 'Cairo' : 'Poppins'), + fontFamily: (projectViewModel.isArabic + ? 'Cairo' + : 'Poppins'), fontWeight: FontWeight.w600, color: Color(0xff2B2E31), letterSpacing: -.48, @@ -421,7 +454,8 @@ class NewAppBarWidget extends StatelessWidget with PreferredSizeWidget { } class AppBarWidget extends StatefulWidget with PreferredSizeWidget { - final AuthenticatedUserObject authenticatedUserObject = locator(); + final AuthenticatedUserObject authenticatedUserObject = + locator(); final String appBarTitle; final bool showHomeAppBarIcon; @@ -474,12 +508,22 @@ class AppBarWidgetState extends State { return AppBar( elevation: 0, - backgroundColor: widget.isPharmacy ? Colors.green : Theme.of(context).appBarTheme.color, + backgroundColor: widget.isPharmacy + ? Colors.green + : Theme.of(context).appBarTheme.color, textTheme: TextTheme( - headline6: TextStyle(color: Theme.of(context).textTheme.headline1.color, fontWeight: FontWeight.bold), + headline6: TextStyle( + color: Theme.of(context).textTheme.headline1.color, + fontWeight: FontWeight.bold), ), - title: Text(widget.authenticatedUserObject.isLogin || !widget.isShowDecPage ? widget.appBarTitle.toUpperCase() : TranslationBase.of(context).serviceInformationTitle, - style: TextStyle(fontWeight: FontWeight.bold, color: Theme.of(context).textTheme.headline1.color, fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans')), + title: Text( + widget.authenticatedUserObject.isLogin || !widget.isShowDecPage + ? widget.appBarTitle.toUpperCase() + : TranslationBase.of(context).serviceInformationTitle, + style: TextStyle( + fontWeight: FontWeight.bold, + color: Theme.of(context).textTheme.headline1.color, + fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans')), leading: Builder( builder: (BuildContext context) { return ArrowBack( @@ -491,7 +535,13 @@ class AppBarWidgetState extends State { actions: [ (widget.isPharmacy && widget.showPharmacyCart) ? IconButton( - icon: Badge(badgeContent: Text(orderPreviewViewModel.cartResponse.quantityCount.toString()), child: Icon(Icons.shopping_cart)), + icon: Badge( + badgeContent: Text( + orderPreviewViewModel.cartResponse.quantityCount + .toString(), + style: TextStyle(color: Colors.white), + ), + child: Icon(Icons.shopping_cart)), color: Colors.white, onPressed: () { // Navigator.of(context).popUntil(ModalRoute.withName('/')); @@ -504,7 +554,10 @@ class AppBarWidgetState extends State { position: BadgePosition.topStart(top: -15, start: -10), badgeContent: Text( _badgeText, - style: TextStyle(fontSize: 9, color: Colors.white, fontWeight: FontWeight.normal), + style: TextStyle( + fontSize: 9, + color: Colors.white, + fontWeight: FontWeight.normal), ), child: Icon(Icons.shopping_cart)), color: Colors.white, @@ -518,7 +571,10 @@ class AppBarWidgetState extends State { icon: Icon(FontAwesomeIcons.home), color: Colors.white, onPressed: () { - Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) => LandingPage()), (Route r) => false); + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute(builder: (context) => LandingPage()), + (Route r) => false); // Cart Click Event if (_onCartClick != null) _onCartClick(); From f8883f5439692746a96a05922920f5030fb051db Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 9 Nov 2021 14:07:12 +0200 Subject: [PATCH 33/70] first step from fixing check out process --- lib/config/config.dart | 4 +- .../screens/cart-page/cart-order-page.dart | 94 ++++++++++--------- .../screens/cart-page/cart-order-preview.dart | 35 +++---- .../cart-page/select_address_widget.dart | 2 +- .../select_payment_option_widget.dart | 2 +- .../screens/order-preview-page.dart | 48 ---------- .../screens/payment-method-select-page.dart | 50 ++++++++-- .../pharmacyAddresses/PharmacyAddresses.dart | 28 +++++- 8 files changed, 138 insertions(+), 125 deletions(-) delete mode 100644 lib/pages/pharmacies/screens/order-preview-page.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 200e5776..694cb602 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -15,8 +15,8 @@ const PACKAGES_CUSTOMER = '/api/customers'; 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/'; // Pharmacy UAT URLs // const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; 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 9c6fa42e..3b7d080f 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy-terms-conditions-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderItem.dart'; +import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.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'; @@ -22,7 +23,6 @@ import 'package:provider/provider.dart'; import 'cart-order-preview.dart'; class CartOrderPage extends StatefulWidget { - final Function(int) changeTab; const CartOrderPage({Key key, this.changeTab}) : super(key: key); @@ -38,7 +38,6 @@ class _CartOrderPageState extends State { void initState() { super.initState(); getData(); - } @override @@ -105,8 +104,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) { @@ -250,7 +249,7 @@ class _CartOrderPageState extends State { ? height * 0.15 : 0, color: Colors.white, - child: OrderBottomWidget(model.addresses, height), + child: OrderBottomWidget(model.addresses, height, model), ), ), ); @@ -268,8 +267,9 @@ class _CartOrderPageState extends State { class OrderBottomWidget extends StatefulWidget { final List addresses; final double height; + final OrderPreviewViewModel model; - OrderBottomWidget(this.addresses, this.height); + OrderBottomWidget(this.addresses, this.height, this.model); @override _OrderBottomWidgetState createState() => _OrderBottomWidgetState(); @@ -281,9 +281,10 @@ class _OrderBottomWidgetState extends State { @override Widget build(BuildContext context) { ProjectViewModel projectProvider = Provider.of(context); - OrderPreviewViewModel cart = Provider.of(context); - return !(cart.cartResponse.shoppingCarts == null || - cart.cartResponse.shoppingCarts.length == 0) + OrderPreviewViewModel model = Provider.of(context); + + return !(model.cartResponse.shoppingCarts == null || + model.cartResponse.shoppingCarts.length == 0) ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -373,7 +374,7 @@ class _OrderBottomWidgetState extends State { child: Row( children: [ Texts( - "${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotalWithVat).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", fontSize: projectProvider.isArabic ? 12 : 14, fontWeight: FontWeight.bold, ), @@ -391,7 +392,7 @@ class _OrderBottomWidgetState extends State { ), ), Texts( - "${cart.cartResponse.quantityCount} ${TranslationBase.of(context).items}", + "${model.cartResponse.quantityCount} ${TranslationBase.of(context).items}", fontSize: 10, color: Colors.grey, fontWeight: FontWeight.bold, @@ -403,50 +404,36 @@ class _OrderBottomWidgetState extends State { onPressed: isAgree // && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0 ? () => { - if(cart.isCartItemsOutOfStock()){ - // Toast msg - AppToast.showErrorToast(message: TranslationBase.of(context).outOfStockMsg) - }else { - Navigator.push( - context, - FadePage( - page: - OrderPreviewPage(widget.addresses))) - } - } + if (model + .isCartItemsOutOfStock()) + { + // Toast msg + AppToast.showErrorToast( + message: TranslationBase.of(context) + .outOfStockMsg) + } + else + { + _navigateToAddressPage(model + .user.patientIdentificationNo) + // Navigator.push( + // context, + // FadePage( + // page: + // OrderPreviewPage(widget.addresses))) + } + } : null, child: new Text( "${TranslationBase.of(context).checkOut}", style: new TextStyle( color: - isAgree ? Colors.white : Colors.grey.shade300, + isAgree ? Colors.white : Colors.grey.shade300, fontSize: 14), ), color: Color(0xFF4CAF50), - disabledColor:Color(0xFF848484), -// disabledColor: Color(0xff005aff), + disabledColor: Color(0xFF848484), ) -// RaisedButton( -// onPressed: isAgree -//// && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0 -// ? () => { -// Navigator.push( -// context, -// FadePage( -// page: -// OrderPreviewPage(widget.addresses))) -// } -// : null, -// child: new Text( -// "${TranslationBase.of(context).checkOut}", -// style: new TextStyle( -// color: -// isAgree ? Colors.white : Colors.grey.shade300, -// fontSize: 14), -// ), -// color: Color(0xff005aff), -// disabledColor: Color(0xff005aff), -// ) ], ), ), @@ -454,4 +441,19 @@ class _OrderBottomWidgetState extends State { ) : Container(); } + + _navigateToAddressPage(String identificationNo) { + Navigator.push(context, FadePage(page: PharmacyAddressesPage(orderPreviewViewModel: widget.model,))) + .then((result) async { + if (result != null) { + GifLoaderDialogUtils.showMyDialog(context); + var address = result; + widget.model.paymentCheckoutData.address = Addresses.fromJson(address.toJson()); + await widget.model.getInformationsByAddress(identificationNo); + await widget.model.getShoppingCart(); + // widget.changeMainState(); + GifLoaderDialogUtils.hideDialog(context); + } + }); + } } diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart index 50cee7c3..40af2e02 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart @@ -15,8 +15,9 @@ import 'lakum_widget.dart'; class OrderPreviewPage extends StatefulWidget { final List addresses; + final OrderPreviewViewModel model; - OrderPreviewPage(this.addresses); + OrderPreviewPage({this.addresses, this.model}); @override _OrderPreviewPageState createState() => _OrderPreviewPageState(); @@ -43,7 +44,7 @@ class _OrderPreviewPageState extends State { Widget build(BuildContext context) { final mediaQuery = MediaQuery.of(context); final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; - OrderPreviewViewModel model = Provider.of(context); + // OrderPreviewViewModel widget.model = Provider.of(context); return AppScaffold( appBarTitle: "${TranslationBase.of(context).checkOut}", isShowAppBar: true, @@ -52,7 +53,7 @@ class _OrderPreviewPageState extends State { isLoading: isLoading, isLocalLoader: true, backgroundColor: Colors.white, - // baseViewModel: model, + // baseViewModel: widget.model, body: Container( color: Color(0xFFF1F1F1), height: height * 0.90, @@ -61,19 +62,19 @@ class _OrderPreviewPageState extends State { color: Color(0xFFF1F1F1), child: Column( children: [ - SelectAddressWidget(model, widget.addresses, changeMainState), + SelectAddressWidget(widget.model, widget.addresses, changeMainState), SizedBox( height: 10, ), - SelectPaymentOptionWidget(model, changeMainState), + SelectPaymentOptionWidget(widget.model, changeMainState), SizedBox( height: 10, ), - model.paymentCheckoutData.lacumInformation != null + widget.model.paymentCheckoutData.lacumInformation != null ? Container( child: Column( children: [ - LakumWidget(model), + LakumWidget(widget.model), SizedBox( height: 10, ), @@ -95,8 +96,8 @@ class _OrderPreviewPageState extends State { color: Colors.black, ), ...List.generate( - model.cartResponse.shoppingCarts != null ? model.cartResponse.shoppingCarts.length : 0, - (index) => ProductOrderPreviewItem(model.cartResponse.shoppingCarts[index]), + widget.model.cartResponse.shoppingCarts != null ? widget.model.cartResponse.shoppingCarts.length : 0, + (index) => ProductOrderPreviewItem(widget.model.cartResponse.shoppingCarts[index]), ), ], ), @@ -104,7 +105,7 @@ class _OrderPreviewPageState extends State { Container( width: double.infinity, padding: EdgeInsets.all(8), - child: model.cartResponse.subtotal != null + child: widget.model.cartResponse.subtotal != null ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -127,7 +128,7 @@ class _OrderPreviewPageState extends State { fontWeight: FontWeight.w500, ), Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(widget.model.cartResponse.subtotal).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, @@ -151,7 +152,7 @@ class _OrderPreviewPageState extends State { fontWeight: FontWeight.w500, ), Texts( - "${TranslationBase.of(context).sar} ${(model.totalAdditionalShippingCharge).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(widget.model.totalAdditionalShippingCharge).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, @@ -175,7 +176,7 @@ class _OrderPreviewPageState extends State { fontWeight: FontWeight.w500, ), Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(widget.model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, @@ -199,7 +200,7 @@ class _OrderPreviewPageState extends State { fontWeight: FontWeight.bold, ), Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(widget.model.cartResponse.subtotal).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.bold, @@ -214,7 +215,7 @@ class _OrderPreviewPageState extends State { : Container(), ), SizedBox( - height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, + height: widget.model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, ) ], ), @@ -222,9 +223,9 @@ class _OrderPreviewPageState extends State { ), ), bottomSheet: Container( - height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, + height: widget.model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, color: Colors.white, - child: PaymentBottomWidget(model), + child: PaymentBottomWidget(widget.model), ), ); } 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 e03a4b35..4228af0a 100644 --- a/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart @@ -24,7 +24,7 @@ class _SelectAddressWidgetState extends State { AddressInfo address; _navigateToAddressPage(String identificationNo) { - Navigator.push(context, FadePage(page: PharmacyAddressesPage())).then((result) async { + Navigator.push(context, FadePage(page: PharmacyAddressesPage(orderPreviewViewModel: widget.model,))).then((result) async { if (result != null) { GifLoaderDialogUtils.showMyDialog(context); address = result; diff --git a/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart b/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart index 825e2577..66e1b16b 100644 --- a/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart @@ -20,7 +20,7 @@ class _SelectPaymentOptionWidgetState extends State { PaymentOption paymentOption; _navigateToPaymentOption() { - Navigator.push(context, FadePage(page: PaymentMethodSelectPage())) + Navigator.push(context, FadePage(page: PaymentMethodSelectPage(model: widget.model,))) .then((result) => { setState(() { if (result != null) { diff --git a/lib/pages/pharmacies/screens/order-preview-page.dart b/lib/pages/pharmacies/screens/order-preview-page.dart deleted file mode 100644 index 6b5f4f51..00000000 --- a/lib/pages/pharmacies/screens/order-preview-page.dart +++ /dev/null @@ -1,48 +0,0 @@ -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; -import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/GestureIconButton.dart'; -import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:flutter/material.dart'; - -class OrderPreviewPage extends StatelessWidget { - @override - Widget build(BuildContext context) { - return BaseView( - builder: (_, model, wi) => AppScaffold( - title: TranslationBase.of(context).shoppingCart, - isShowAppBar: true, - isShowDecPage: false, - baseViewModel: model, - backgroundColor: Colors.white, - body: Container( - width: double.infinity, - child: SingleChildScrollView( - child: Container( - margin: EdgeInsets.all(10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - GestureIconButton( - TranslationBase.of(context).deleteAllItems, - Icon(Icons.delete_outline_sharp, color: Colors.grey.shade800,), - onTap: () => {}, - ), - const Divider( - color: Colors.grey, - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - - ], - ), - ), - ), - ), - ), - ); - } -} - diff --git a/lib/pages/pharmacies/screens/payment-method-select-page.dart b/lib/pages/pharmacies/screens/payment-method-select-page.dart index 92065102..719fd45d 100644 --- a/lib/pages/pharmacies/screens/payment-method-select-page.dart +++ b/lib/pages/pharmacies/screens/payment-method-select-page.dart @@ -6,11 +6,19 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'cart-page/cart-order-preview.dart'; + class PaymentMethodSelectPage extends StatefulWidget { + final OrderPreviewViewModel model; + + const PaymentMethodSelectPage({Key key, this.model}) : super(key: key); + @override - _PaymentMethodSelectPageState createState() => _PaymentMethodSelectPageState(); + _PaymentMethodSelectPageState createState() => + _PaymentMethodSelectPageState(); } class _PaymentMethodSelectPageState extends State { @@ -79,7 +87,8 @@ class _PaymentMethodSelectPageState extends State { PaymentOption.installments, () => { setState(() { - selectedPaymentOption = PaymentOption.installments; + selectedPaymentOption = + PaymentOption.installments; }) }), if (Platform.isIOS) @@ -103,7 +112,21 @@ class _PaymentMethodSelectPageState extends State { padding: EdgeInsets.symmetric(horizontal: 16, vertical: 20), child: DefaultButton( TranslationBase.of(context).next, - selectedPaymentOption != null ? () => {Navigator.pop(context, selectedPaymentOption)} : null, + selectedPaymentOption != null + ? () { + + + widget.model.paymentCheckoutData.paymentOption = + selectedPaymentOption; + // Navigator.pop(context, selectedPaymentOption); + + Navigator.push( + context, + FadePage( + page: + OrderPreviewPage(model: widget.model,),),); + } + : null, color: Color(0xff5AB154), ), ), @@ -117,12 +140,14 @@ class PaymentMethodCard extends StatelessWidget { final PaymentOption paymentOption; final Function selectMethod; - PaymentMethodCard(this.cardWidth, this.selectedPaymentOption, this.paymentOption, this.selectMethod); + PaymentMethodCard(this.cardWidth, this.selectedPaymentOption, + this.paymentOption, this.selectMethod); @override Widget build(BuildContext context) { bool isSelected = false; - if (selectedPaymentOption != null && selectedPaymentOption == paymentOption) { + if (selectedPaymentOption != null && + selectedPaymentOption == paymentOption) { isSelected = true; } @@ -136,7 +161,9 @@ class PaymentMethodCard extends StatelessWidget { color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), - side: isSelected ? BorderSide(color: Colors.green, width: 2.0) : BorderSide(color: Colors.transparent, width: 0.0), + side: isSelected + ? BorderSide(color: Colors.green, width: 2.0) + : BorderSide(color: Colors.transparent, width: 0.0), ), child: Padding( padding: const EdgeInsets.all(12.0), @@ -145,7 +172,13 @@ class PaymentMethodCard extends StatelessWidget { Container( width: 24, height: 24, - decoration: containerColorRadiusBorderWidth(isSelected ? CustomColors.accentColor : Colors.transparent, 100, Colors.grey, 0.5), + decoration: containerColorRadiusBorderWidth( + isSelected + ? CustomColors.accentColor + : Colors.transparent, + 100, + Colors.grey, + 0.5), ), mWidth(12), Container( @@ -157,7 +190,8 @@ class PaymentMethodCard extends StatelessWidget { if (isSelected) Container( decoration: containerRadius(CustomColors.green, 200), - padding: EdgeInsets.only(top: 6, bottom: 6, left: 12, right: 12), + padding: + EdgeInsets.only(top: 6, bottom: 6, left: 12, right: 12), child: Text( TranslationBase.of(context).paymentSelected, style: TextStyle( diff --git a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart index b763e960..9fd40f2b 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart @@ -1,7 +1,9 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer_addresses_service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/AddAddress.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -13,7 +15,12 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +///TODO Elham* split this to tow files class PharmacyAddressesPage extends StatefulWidget { + + final OrderPreviewViewModel orderPreviewViewModel; + + const PharmacyAddressesPage({Key key, this.orderPreviewViewModel}) : super(key: key); @override _PharmacyAddressesState createState() => _PharmacyAddressesState(); } @@ -53,10 +60,13 @@ class _PharmacyAddressesState extends State { () { setState(() { model.setSelectedAddressIndex(index); + //TODO Elham* + widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[index].toJson()); }); }, model.selectedAddressIndex == index, (address) { + navigateToAddressPage(context, model, address); }), ), @@ -109,8 +119,8 @@ class _PharmacyAddressesState extends State { vPadding: 8, handler: () { model.saveSelectedAddressLocally(model.addresses[model.selectedAddressIndex]); - Navigator.pop(context, model.addresses[model.selectedAddressIndex]); - }, + _navigateToPaymentOption(); + }, ), ), ], @@ -119,6 +129,20 @@ class _PharmacyAddressesState extends State { ), ); } + + _navigateToPaymentOption() { + Navigator.push(context, FadePage(page: PaymentMethodSelectPage(model: widget.orderPreviewViewModel,))) + .then((result) => { + setState(() { + if (result != null) { + var paymentOption = result; + widget.orderPreviewViewModel.paymentCheckoutData.paymentOption = + paymentOption; + } + // widget.changeMainState(); + }) + }); + } } class AddressItemWidget extends StatelessWidget { From 6ffa07392c847de15ae38f3f05ab3abd461d2858 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 9 Nov 2021 15:36:58 +0300 Subject: [PATCH 34/70] Product detail page updates --- .../product_detail_view_model.dart | 38 ++-- lib/models/pharmacy/productDetailModel.dart | 204 ++++++++--------- .../product-details/footor/footer-widget.dart | 40 ++-- .../product-details/product-detail.dart | 8 +- .../product-name-and-price.dart | 67 ++---- .../product_detail_service.dart | 212 +++++++++--------- 6 files changed, 265 insertions(+), 304 deletions(-) diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index 98596ee0..2ae935dd 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -1,21 +1,20 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCart.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCartResponse.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/services/pharmacy_services/product_detail_service.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/navigation_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'; -class ProductDetailViewModel extends BaseViewModel{ +class ProductDetailViewModel extends BaseViewModel { ProductDetailService _productDetailService = locator(); List get productDetailService => _productDetailService.productDetailList; @@ -28,6 +27,11 @@ class ProductDetailViewModel extends BaseViewModel{ bool hasError = false; + num get stockQuantity => _productDetailService.stockQuantity; + + String get stockAvailability => _productDetailService.stockAvailability; + + bool get isStockAvailable => _productDetailService.isStockAvailable; Future getProductReviewsData(productID) async { hasError = false; @@ -72,8 +76,7 @@ class ProductDetailViewModel extends BaseViewModel{ setState(ViewState.ErrorLocal); } else { setState(ViewState.Idle); - Provider.of(locator().navigatorKey.currentContext, listen: false) - .setShoppingCartResponse( object); + Provider.of(locator().navigatorKey.currentContext, listen: false).setShoppingCartResponse(object); } } @@ -103,11 +106,9 @@ class ProductDetailViewModel extends BaseViewModel{ Future addToWishlistData(itemID) async { hasError = false; setState(ViewState.BusyLocal); - GifLoaderDialogUtils.showMyDialog( - locator().navigatorKey.currentContext); + GifLoaderDialogUtils.showMyDialog(locator().navigatorKey.currentContext); await _productDetailService.addToWishlist(itemID); - GifLoaderDialogUtils.hideDialog( - locator().navigatorKey.currentContext); + GifLoaderDialogUtils.hideDialog(locator().navigatorKey.currentContext); if (_productDetailService.hasError) { error = _productDetailService.error; @@ -127,15 +128,12 @@ class ProductDetailViewModel extends BaseViewModel{ setState(ViewState.Idle); } - Future deleteWishlistData(itemID) async { hasError = false; setState(ViewState.BusyLocal); - GifLoaderDialogUtils.showMyDialog( - locator().navigatorKey.currentContext); + GifLoaderDialogUtils.showMyDialog(locator().navigatorKey.currentContext); await _productDetailService.deleteItemFromWishlist(itemID); - GifLoaderDialogUtils.hideDialog( - locator().navigatorKey.currentContext); + GifLoaderDialogUtils.hideDialog(locator().navigatorKey.currentContext); if (_productDetailService.hasError) { error = _productDetailService.error; @@ -144,7 +142,6 @@ class ProductDetailViewModel extends BaseViewModel{ setState(ViewState.Idle); } - Future productSpecificationData(itemID) async { hasError = false; setState(ViewState.Busy); @@ -156,10 +153,7 @@ class ProductDetailViewModel extends BaseViewModel{ setState(ViewState.Idle); } - clearReview(){ - + clearReview() { productDetailService.clear(); - } - -} \ No newline at end of file +} diff --git a/lib/models/pharmacy/productDetailModel.dart b/lib/models/pharmacy/productDetailModel.dart index d2e8f010..724f1190 100644 --- a/lib/models/pharmacy/productDetailModel.dart +++ b/lib/models/pharmacy/productDetailModel.dart @@ -1,7 +1,3 @@ -// To parse this JSON data, do -// -// final productDetail = productDetailFromJson(jsonString); - import 'dart:convert'; List productDetailFromJson(String str) => List.from(json.decode(str).map((x) => ProductDetail.fromJson(x))); @@ -16,12 +12,12 @@ class ProductDetail { List reviews; factory ProductDetail.fromJson(Map json) => ProductDetail( - reviews: List.from(json["reviews"].map((x) => Review.fromJson(x))), - ); + reviews: List.from(json["reviews"].map((x) => Review.fromJson(x))), + ); Map toJson() => { - "reviews": List.from(reviews.map((x) => x.toJson())), - }; + "reviews": List.from(reviews.map((x) => x.toJson())), + }; } class Review { @@ -62,42 +58,42 @@ class Review { dynamic product; factory Review.fromJson(Map json) => Review( - id: json["id"], - position: json["position"], - reviewId: json["review_id"], - customerId: json["customer_id"], - productId: json["product_id"], - storeId: json["store_id"], - isApproved: json["is_approved"], - title: json["title"], - reviewText: json["review_text"], - replyText: json["reply_text"], - rating: json["rating"], - helpfulYesTotal: json["helpful_yes_total"], - helpfulNoTotal: json["helpful_no_total"], - createdOnUtc: DateTime.parse(json["created_on_utc"]), - customer: Customer.fromJson(json["customer"]), - product: json["product"], - ); + id: json["id"], + position: json["position"], + reviewId: json["review_id"], + customerId: json["customer_id"], + productId: json["product_id"], + storeId: json["store_id"], + isApproved: json["is_approved"], + title: json["title"], + reviewText: json["review_text"], + replyText: json["reply_text"], + rating: json["rating"], + helpfulYesTotal: json["helpful_yes_total"], + helpfulNoTotal: json["helpful_no_total"], + createdOnUtc: DateTime.parse(json["created_on_utc"]), + customer: Customer.fromJson(json["customer"]), + product: json["product"], + ); Map toJson() => { - "id": id, - "position": position, - "review_id": reviewId, - "customer_id": customerId, - "product_id": productId, - "store_id": storeId, - "is_approved": isApproved, - "title": title, - "review_text": reviewText, - "reply_text": replyText, - "rating": rating, - "helpful_yes_total": helpfulYesTotal, - "helpful_no_total": helpfulNoTotal, - "created_on_utc": createdOnUtc.toIso8601String(), - "customer": customer.toJson(), - "product": product, - }; + "id": id, + "position": position, + "review_id": reviewId, + "customer_id": customerId, + "product_id": productId, + "store_id": storeId, + "is_approved": isApproved, + "title": title, + "review_text": reviewText, + "reply_text": replyText, + "rating": rating, + "helpful_yes_total": helpfulYesTotal, + "helpful_no_total": helpfulNoTotal, + "created_on_utc": createdOnUtc.toIso8601String(), + "customer": customer.toJson(), + "product": product, + }; } class Customer { @@ -164,75 +160,73 @@ class Customer { dynamic registeredInStoreId; factory Customer.fromJson(Map json) => Customer( - fileNumber: json["file_number"], - iqamaNumber: json["iqama_number"], - isOutSa: json["is_out_sa"], - patientType: json["patient_type"], - gender: json["gender"], - birthDate: DateTime.parse(json["birth_date"]), - phone: json["phone"], - countryCode: json["country_code"], - yahalaAccountno: json["yahala_accountno"], - billingAddress: json["billing_address"], - shippingAddress: json["shipping_address"], - id: json["id"], - username: emailValues.map[json["username"]], - email: emailValues.map[json["email"]], - firstName: json["first_name"], - lastName: json["last_name"], - languageId: json["language_id"], - adminComment: json["admin_comment"], - isTaxExempt: json["is_tax_exempt"], - hasShoppingCartItems: json["has_shopping_cart_items"], - active: json["active"], - deleted: json["deleted"], - isSystemAccount: json["is_system_account"], - systemName: json["system_name"], - lastIpAddress: json["last_ip_address"], - createdOnUtc: json["created_on_utc"], - lastLoginDateUtc: json["last_login_date_utc"], - lastActivityDateUtc: json["last_activity_date_utc"], - registeredInStoreId: json["registered_in_store_id"], - ); + fileNumber: json["file_number"], + iqamaNumber: json["iqama_number"], + isOutSa: json["is_out_sa"], + patientType: json["patient_type"], + gender: json["gender"], + birthDate: DateTime.parse(json["birth_date"]), + phone: json["phone"], + countryCode: json["country_code"], + yahalaAccountno: json["yahala_accountno"], + billingAddress: json["billing_address"], + shippingAddress: json["shipping_address"], + id: json["id"], + username: emailValues.map[json["username"]], + email: emailValues.map[json["email"]], + firstName: json["first_name"], + lastName: json["last_name"], + languageId: json["language_id"], + adminComment: json["admin_comment"], + isTaxExempt: json["is_tax_exempt"], + hasShoppingCartItems: json["has_shopping_cart_items"], + active: json["active"], + deleted: json["deleted"], + isSystemAccount: json["is_system_account"], + systemName: json["system_name"], + lastIpAddress: json["last_ip_address"], + createdOnUtc: json["created_on_utc"], + lastLoginDateUtc: json["last_login_date_utc"], + lastActivityDateUtc: json["last_activity_date_utc"], + registeredInStoreId: json["registered_in_store_id"], + ); Map toJson() => { - "file_number": fileNumber, - "iqama_number": iqamaNumber, - "is_out_sa": isOutSa, - "patient_type": patientType, - "gender": gender, - "birth_date": birthDate.toIso8601String(), - "phone": phone, - "country_code": countryCode, - "yahala_accountno": yahalaAccountno, - "billing_address": billingAddress, - "shipping_address": shippingAddress, - "id": id, - "username": emailValues.reverse[username], - "email": emailValues.reverse[email], - "first_name": firstName, - "last_name": lastName, - "language_id": languageId, - "admin_comment": adminComment, - "is_tax_exempt": isTaxExempt, - "has_shopping_cart_items": hasShoppingCartItems, - "active": active, - "deleted": deleted, - "is_system_account": isSystemAccount, - "system_name": systemName, - "last_ip_address": lastIpAddress, - "created_on_utc": createdOnUtc, - "last_login_date_utc": lastLoginDateUtc, - "last_activity_date_utc": lastActivityDateUtc, - "registered_in_store_id": registeredInStoreId, - }; + "file_number": fileNumber, + "iqama_number": iqamaNumber, + "is_out_sa": isOutSa, + "patient_type": patientType, + "gender": gender, + "birth_date": birthDate.toIso8601String(), + "phone": phone, + "country_code": countryCode, + "yahala_accountno": yahalaAccountno, + "billing_address": billingAddress, + "shipping_address": shippingAddress, + "id": id, + "username": emailValues.reverse[username], + "email": emailValues.reverse[email], + "first_name": firstName, + "last_name": lastName, + "language_id": languageId, + "admin_comment": adminComment, + "is_tax_exempt": isTaxExempt, + "has_shopping_cart_items": hasShoppingCartItems, + "active": active, + "deleted": deleted, + "is_system_account": isSystemAccount, + "system_name": systemName, + "last_ip_address": lastIpAddress, + "created_on_utc": createdOnUtc, + "last_login_date_utc": lastLoginDateUtc, + "last_activity_date_utc": lastActivityDateUtc, + "registered_in_store_id": registeredInStoreId, + }; } enum Email { STEVE_GATES_NOP_COMMERCE_COM } -final emailValues = EnumValues({ - "steve_gates@nopCommerce.com": Email.STEVE_GATES_NOP_COMMERCE_COM -}); +final emailValues = EnumValues({"steve_gates@nopCommerce.com": Email.STEVE_GATES_NOP_COMMERCE_COM}); class EnumValues { Map map; diff --git a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart index 14dab3e5..72399498 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -68,7 +68,7 @@ class _FooterWidgetState extends State { Padding( padding: const EdgeInsets.all(8.0), child: Text( - "Quantity", + TranslationBase.of(context).quantity, style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold), ), ), @@ -157,17 +157,19 @@ class _FooterWidgetState extends State { ), ], ), - onPressed: () { - setState(() { - if (showUI) { - quantityUI = 80; - showUI = false; - } else { - quantityUI = 160; - showUI = true; - } - }); - }, + onPressed: widget.isAvailable && !widget.item.isRx + ? () { + setState(() { + if (showUI) { + quantityUI = 80; + showUI = false; + } else { + quantityUI = 160; + showUI = true; + } + }); + } + : null, ), ), SizedBox( @@ -207,20 +209,20 @@ class _FooterWidgetState extends State { ); } else { await widget.addToShoppingCartFunction(quantity: widget.quantity, itemID: widget.item.id, model: widget.model); - Navigator.of(context).pushNamed( - CART_ORDER_PAGE, - ); - // Navigator.push( - // context, - // FadePage(page: CartOrderPage()), + // Navigator.of(context).pushNamed( + // CART_ORDER_PAGE, // ); + Navigator.push( + context, + FadePage(page: CartOrderPage()), + ); } }, fontWeight: FontWeight.w600, borderColor: Colors.grey[800], borderRadius: 3, disableColor: Colors.grey[700], - color: !widget.isAvailable && widget.quantity > 0 || widget.quantity > widget.quantityLimit || widget.item.rxMessage != null ? Colors.grey : Colors.grey[800], + color: !widget.isAvailable && widget.quantity > 0 || widget.quantity > widget.quantityLimit || widget.item.isRx ? Colors.grey : Colors.grey[800], ), ), ], diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index d33e3178..015df6ed 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -87,6 +87,9 @@ class __ProductDetailPageState extends State { Widget build(BuildContext context) { return BaseView( allowAny: true, + onModelReady: (model) { + model.getProductReviewsData(widget.product.id); + }, builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).productDetails, isShowAppBar: true, @@ -146,6 +149,7 @@ class __ProductDetailPageState extends State { notifyMeWhenAvailable(itemId: itemId, customerId: customerId, model: model); }, isInWishList: isInWishList, + isStockAvailable: model.isStockAvailable, ), ), SizedBox( @@ -302,10 +306,10 @@ class __ProductDetailPageState extends State { ), ), bottomSheet: FooterWidget( - widget.product.stockAvailability != 'Out of stock', + model.isStockAvailable, widget.product.orderMaximumQuantity, widget.product.orderMinimumQuantity, - widget.product.stockQuantity, + model.stockQuantity, widget.product, quantity: quantity, isOverQuantity: isOverQuantity, diff --git a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart index 6d8ea11d..9401f3e0 100644 --- a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart +++ b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart @@ -1,7 +1,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.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:flutter/material.dart'; @@ -20,16 +19,12 @@ class ProductNameAndPrice extends StatefulWidget { final Function notifyMeWhenAvailable; final Function addToWishlistFunction; final Function deleteFromWishlistFunction; + final bool isStockAvailable; - AuthenticatedUserObject authenticatedUserObject = - locator(); + AuthenticatedUserObject authenticatedUserObject = locator(); ProductNameAndPrice(this.context, this.item, - {this.customerId, - this.isInWishList, - this.notifyMeWhenAvailable, - this.addToWishlistFunction, - this.deleteFromWishlistFunction}); + {this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, @required this.isStockAvailable}); @override _ProductNameAndPriceState createState() => _ProductNameAndPriceState(); @@ -51,25 +46,18 @@ class _ProductNameAndPriceState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Texts(widget.item.price.toString() + " " + "SR", - fontWeight: FontWeight.bold, fontSize: 20), + Texts(widget.item.price.toString() + " " + TranslationBase.of(context).sar, fontWeight: FontWeight.bold, fontSize: 20), Texts( - projectViewModel.isArabic - ? widget.item.stockAvailabilityn - : widget.item.stockAvailability, + projectViewModel.isArabic ? widget.item.stockAvailabilityn : widget.item.stockAvailability, fontWeight: FontWeight.bold, fontSize: 15, - color: widget.item.stockAvailability == 'Out of stock' - ? Colors.red - : Colors.green, + color: widget.isStockAvailable ? Colors.green : Colors.red, ), // SizedBox(width: 20), if (widget.authenticatedUserObject.isLogin) - widget.item.stockAvailability == 'Out of stock' && - widget.customerId != null + widget.isStockAvailable && widget.customerId != null ? InkWell( - onTap: () => widget.notifyMeWhenAvailable( - context, widget.item.id), + onTap: () => widget.notifyMeWhenAvailable(context, widget.item.id), child: Row(children: [ Texts( TranslationBase.of(context).notifyMe, @@ -85,23 +73,15 @@ class _ProductNameAndPriceState extends State { ]), ) : IconWithBg( - icon: !widget.isInWishList - ? Icons.favorite_border - : Icons.favorite, - color: !widget.isInWishList - ? Colors.white - : Colors.red[800], + icon: !widget.isInWishList ? Icons.favorite_border : Icons.favorite, + color: !widget.isInWishList ? Colors.white : Colors.red[800], onPress: () async { { if (widget.customerId != null) { if (!widget.isInWishList) { - - await widget - .addToWishlistFunction(widget.item.id); - + await widget.addToWishlistFunction(widget.item.id); } else { - await widget - .deleteFromWishlistFunction(widget.item.id); + await widget.deleteFromWishlistFunction(widget.item.id); } } else { return; @@ -118,13 +98,9 @@ class _ProductNameAndPriceState extends State { child: Container( margin: EdgeInsets.only(left: 5), child: Align( - alignment: projectViewModel.isArabic - ? Alignment.topRight - : Alignment.topLeft, + alignment: projectViewModel.isArabic ? Alignment.topRight : Alignment.topLeft, child: Text( - projectViewModel.isArabic - ? widget.item.namen - : widget.item.name, + projectViewModel.isArabic ? widget.item.namen : widget.item.name, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), ), ), @@ -140,8 +116,7 @@ class _ProductNameAndPriceState extends State { child: Row( children: [ RatingBar.readOnly( - initialRating: double.parse( - widget.item.approvedRatingSum.toString()), + initialRating: double.parse(widget.item.approvedRatingSum.toString()), size: 15.0, filledColor: Colors.yellow[700], emptyColor: Colors.grey[400], @@ -172,19 +147,9 @@ class _ProductNameAndPriceState extends State { Row( children: [ Text( - projectViewModel.isArabic - ? widget.item.rxMessagen.toString() - : widget.item.rxMessage.toString(), + projectViewModel.isArabic ? widget.item.rxMessagen.toString() : widget.item.rxMessage.toString(), style: TextStyle(color: Colors.red, fontSize: 10), ), - SizedBox( - width: 5, - ), - Icon( - FontAwesomeIcons.questionCircle, - color: Colors.red, - size: 15.0, - ) ], ) ], diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 47673eab..23379914 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -15,36 +15,53 @@ import 'package:diplomaticquarterapp/uitl/app_toast.dart'; class ProductDetailService extends BaseService { bool isLogin = false; + num _stockQuantity; + + num get stockQuantity => _stockQuantity; + + String _stockAvailability; + + String get stockAvailability => _stockAvailability; + + bool _isStockAvailable; + + bool get isStockAvailable => _isStockAvailable; + List _productDetailList = List(); + List get productDetailList => _productDetailList; List _productLocationList = List(); + List get productLocationList => _productLocationList; List _addToCartModel = List(); + List get addToCartModel => _addToCartModel; List _wishListProducts = List(); + List get wishListProducts => _wishListProducts; List _productSpecification = List(); - List get productSpecification => _productSpecification; - + List get productSpecification => _productSpecification; Future getProductReviews(productID) async { hasError = false; - await baseAppClient.getPharmacy(GET_PRODUCT_DETAIL+productID+"?fields=reviews", - onSuccess: (dynamic response, int statusCode) { - _productDetailList.clear(); - response['products'].forEach((item) { - _productDetailList.add(ProductDetail.fromJson(item)); - print(response); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }); + await baseAppClient.getPharmacy(GET_PRODUCT_DETAIL + productID + "?fields=reviews,stock_quantity,stock_availability,IsStockAvailable", onSuccess: (dynamic response, int statusCode) { + _productDetailList.clear(); + response['products'].forEach((item) { + _productDetailList.add(ProductDetail.fromJson(item)); + print(response); + }); + _stockQuantity = response['products'][0]['stock_quantity']; + _stockAvailability = response['products'][0]['stock_availability']; + _isStockAvailable = response['products'][0]['IsStockAvailable']; + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }); } Future getProductAvailabiltyDetail() async { @@ -52,29 +69,28 @@ class ProductDetailService extends BaseService { Map request; request = { - "Channel": 3, - "DeviceTypeID": 2, - "IPAdress": "10.20.10.20", - "LanguageID": 2, - "PatientOutSA": 0, - "SKU": "6720020025", - "SessionID": null, - "VersionID": 5.6, - "generalid": "Cs2020@2016\$2958", - "isDentalAllowedBackend": false + // "Channel": 3, + // "DeviceTypeID": 2, + // "IPAdress": "10.20.10.20", + // "LanguageID": 2, + // "PatientOutSA": 0, + // "SKU": "6720020025", + // "SessionID": null, + // "VersionID": 5.6, + // "generalid": "Cs2020@2016\$2958", + // "isDentalAllowedBackend": false }; - await baseAppClient.post(GET_LOCATION, - onSuccess: (dynamic response, int statusCode) { - _productLocationList.clear(); - response['PharmList'].forEach((item) { - _productLocationList.add(LocationModel.fromJson(item)); - print(_productLocationList); - print(response); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: request); + await baseAppClient.post(GET_LOCATION, onSuccess: (dynamic response, int statusCode) { + _productLocationList.clear(); + response['PharmList'].forEach((item) { + _productLocationList.add(LocationModel.fromJson(item)); + print(_productLocationList); + print(response); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: request); } Future addToCart(quantity, itemID) async { @@ -83,30 +99,22 @@ class ProductDetailService extends BaseService { Map request; request = { - "shopping_cart_item": - { - "quantity": quantity, - "shopping_cart_type": "1", - "product_id": itemID, - "customer_id": customerId, - "language_id": 1 - } + "shopping_cart_item": {"quantity": quantity, "shopping_cart_type": "1", "product_id": itemID, "customer_id": customerId, "language_id": 1} }; dynamic localRes; - - await baseAppClient.pharmacyPost(GET_SHOPPING_CART, isExternal: false, - onSuccess: (dynamic response, int statusCode) { - _addToCartModel.clear(); - response['shopping_carts'].forEach((item) { - _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); + + await baseAppClient.pharmacyPost(GET_SHOPPING_CART, isExternal: false, onSuccess: (dynamic response, int statusCode) { + _addToCartModel.clear(); + response['shopping_carts'].forEach((item) { + _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); } @@ -118,7 +126,7 @@ class ProductDetailService extends BaseService { }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage()); + AppToast.showErrorToast(message: error ?? Utils.generateContactAdminMessage()); }); } @@ -130,67 +138,61 @@ class ProductDetailService extends BaseService { request = { "shopping_cart_item": {"quantity": 1, "shopping_cart_type": "Wishlist", "product_id": itemID, "customer_id": customerId, "language_id": 1} }; - await baseAppClient.pharmacyPost(GET_SHOPPING_CART, - onSuccess: (dynamic response, int statusCode) { - _wishListProducts.clear(); - response['shopping_carts'].forEach((item) { - _wishListProducts.add(Wishlist.fromJson(item)); - }); - AppToast.showSuccessToast(message: 'You have added a product to the Wishlist'); - - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage()); - }, body: request); + await baseAppClient.pharmacyPost(GET_SHOPPING_CART, onSuccess: (dynamic response, int statusCode) { + _wishListProducts.clear(); + response['shopping_carts'].forEach((item) { + _wishListProducts.add(Wishlist.fromJson(item)); + }); + AppToast.showSuccessToast(message: 'You have added a product to the Wishlist'); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + AppToast.showErrorToast(message: error ?? Utils.generateContactAdminMessage()); + }, body: request); } Future getWishlistItems() async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; - await baseAppClient.getPharmacy(GET_WISHLIST+customerId+"?shopping_cart_type=2", - onSuccess: (dynamic response, int statusCode) { - _wishListProducts.clear(); - response['shopping_carts'].forEach((item) { - _wishListProducts.add(Wishlist.fromJson(item)); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }); + await baseAppClient.getPharmacy(GET_WISHLIST + customerId + "?shopping_cart_type=2", onSuccess: (dynamic response, int statusCode) { + _wishListProducts.clear(); + response['shopping_carts'].forEach((item) { + _wishListProducts.add(Wishlist.fromJson(item)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }); } Future deleteItemFromWishlist(itemID) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; - await baseAppClient.getPharmacy(DELETE_WISHLIST+customerId+"+&product_id="+itemID+"&cart_type=Wishlist", - onSuccess: (dynamic response, int statusCode) { - _wishListProducts.clear(); - response['shopping_carts'].forEach((item) { - _wishListProducts.add(Wishlist.fromJson(item)); - }); - AppToast.showSuccessToast(message: 'You have removed a product from the Wishlist'); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage()); - }); + await baseAppClient.getPharmacy(DELETE_WISHLIST + customerId + "+&product_id=" + itemID + "&cart_type=Wishlist", onSuccess: (dynamic response, int statusCode) { + _wishListProducts.clear(); + response['shopping_carts'].forEach((item) { + _wishListProducts.add(Wishlist.fromJson(item)); + }); + AppToast.showSuccessToast(message: 'You have removed a product from the Wishlist'); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + AppToast.showErrorToast(message: error ?? Utils.generateContactAdminMessage()); + }); } Future productSpecificationData(itemID) async { hasError = false; - await baseAppClient.getPharmacy(GET_SPECIFICATION+itemID, - onSuccess: (dynamic response, int statusCode) { - _productSpecification.clear(); - response['specification'].forEach((item) { - _productSpecification.add(SpecificationModel.fromJson(item)); - print(_productSpecification); - }); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }); + await baseAppClient.getPharmacy(GET_SPECIFICATION + itemID, onSuccess: (dynamic response, int statusCode) { + _productSpecification.clear(); + response['specification'].forEach((item) { + _productSpecification.add(SpecificationModel.fromJson(item)); + print(_productSpecification); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }); } - } From df9e58402d9d1904227559d4eefebb51a6848c84 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 9 Nov 2021 15:12:07 +0200 Subject: [PATCH 35/70] first step from update design --- .../screens/cart-page/cart-order-preview.dart | 4 +- .../cart-page/select_address_widget.dart | 12 +- .../select_payment_option_widget.dart | 12 +- .../screens/payment-method-select-page.dart | 66 ++++------- .../pharmacyAddresses/PharmacyAddresses.dart | 105 ++++++++++++------ 5 files changed, 109 insertions(+), 90 deletions(-) diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart index 40af2e02..cc2e1edc 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart @@ -62,11 +62,11 @@ class _OrderPreviewPageState extends State { color: Color(0xFFF1F1F1), child: Column( children: [ - SelectAddressWidget(widget.model, widget.addresses, changeMainState), + SelectAddressWidget(widget.model, widget.addresses, changeMainState, isUpdating: true,), SizedBox( height: 10, ), - SelectPaymentOptionWidget(widget.model, changeMainState), + SelectPaymentOptionWidget(widget.model, changeMainState,isUpdating: true,), SizedBox( height: 10, ), 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 4228af0a..a1634e21 100644 --- a/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart @@ -13,8 +13,10 @@ class SelectAddressWidget extends StatefulWidget { final OrderPreviewViewModel model; final List addresses; final Function changeMainState; + final bool isUpdating; - SelectAddressWidget(this.model, this.addresses, this.changeMainState); + SelectAddressWidget(this.model, this.addresses, this.changeMainState, + {this.isUpdating = false}); @override _SelectAddressWidgetState createState() => _SelectAddressWidgetState(); @@ -24,7 +26,7 @@ class _SelectAddressWidgetState extends State { AddressInfo address; _navigateToAddressPage(String identificationNo) { - Navigator.push(context, FadePage(page: PharmacyAddressesPage(orderPreviewViewModel: widget.model,))).then((result) async { + Navigator.push(context, FadePage(page: PharmacyAddressesPage(orderPreviewViewModel: widget.model,isUpdate: widget.isUpdating,changeMainState: widget.changeMainState,))).then((result) async { if (result != null) { GifLoaderDialogUtils.showMyDialog(context); address = result; @@ -39,15 +41,15 @@ class _SelectAddressWidgetState extends State { @override void initState() { - if (widget.model.paymentCheckoutData.address != null) { - address = AddressInfo.fromJson(widget.model.paymentCheckoutData.address.toJson()); - } super.initState(); } @override Widget build(BuildContext context) { OrderPreviewViewModel model = Provider.of(context); + if (widget.model.paymentCheckoutData.address != null) { + address = AddressInfo.fromJson(widget.model.paymentCheckoutData.address.toJson()); + } return Container( color: Colors.white, child: address == null diff --git a/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart b/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart index 66e1b16b..67692c5d 100644 --- a/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart @@ -9,8 +9,10 @@ import 'package:flutter/material.dart'; class SelectPaymentOptionWidget extends StatefulWidget { final OrderPreviewViewModel model; final Function changeMainState; + final bool isUpdating; - SelectPaymentOptionWidget(this.model, this.changeMainState); + + SelectPaymentOptionWidget(this.model, this.changeMainState, {this.isUpdating = false}); @override _SelectPaymentOptionWidgetState createState() => _SelectPaymentOptionWidgetState(); @@ -20,7 +22,7 @@ class _SelectPaymentOptionWidgetState extends State { PaymentOption paymentOption; _navigateToPaymentOption() { - Navigator.push(context, FadePage(page: PaymentMethodSelectPage(model: widget.model,))) + Navigator.push(context, FadePage(page: PaymentMethodSelectPage(model: widget.model,changeMainState:widget.changeMainState,isUpdating: widget.isUpdating,))) .then((result) => { setState(() { if (result != null) { @@ -35,14 +37,14 @@ class _SelectPaymentOptionWidgetState extends State { @override void initState() { - if (widget.model.paymentCheckoutData.paymentOption != null) { - paymentOption = widget.model.paymentCheckoutData.paymentOption; - } super.initState(); } @override Widget build(BuildContext context) { + if (widget.model.paymentCheckoutData.paymentOption != null) { + paymentOption = widget.model.paymentCheckoutData.paymentOption; + } return Container( color: Colors.white, child: paymentOption == null diff --git a/lib/pages/pharmacies/screens/payment-method-select-page.dart b/lib/pages/pharmacies/screens/payment-method-select-page.dart index 719fd45d..978afae3 100644 --- a/lib/pages/pharmacies/screens/payment-method-select-page.dart +++ b/lib/pages/pharmacies/screens/payment-method-select-page.dart @@ -13,8 +13,12 @@ import 'cart-page/cart-order-preview.dart'; class PaymentMethodSelectPage extends StatefulWidget { final OrderPreviewViewModel model; + final bool isUpdating; + final Function changeMainState; - const PaymentMethodSelectPage({Key key, this.model}) : super(key: key); + const PaymentMethodSelectPage( + {Key key, this.model, this.isUpdating = false, this.changeMainState}) + : super(key: key); @override _PaymentMethodSelectPageState createState() => @@ -114,17 +118,23 @@ class _PaymentMethodSelectPageState extends State { TranslationBase.of(context).next, selectedPaymentOption != null ? () { - - - widget.model.paymentCheckoutData.paymentOption = - selectedPaymentOption; + widget.model.paymentCheckoutData.paymentOption = + selectedPaymentOption; + if (widget.isUpdating) { + widget.changeMainState(); + Navigator.pop(context); + return; + } else { + Navigator.push( + context, + FadePage( + page: OrderPreviewPage( + model: widget.model, + ), + ), + ); + } // Navigator.pop(context, selectedPaymentOption); - - Navigator.push( - context, - FadePage( - page: - OrderPreviewPage(model: widget.model,),),); } : null, color: Color(0xff5AB154), @@ -204,40 +214,6 @@ class PaymentMethodCard extends StatelessWidget { ), ), ), - // Container( - // margin: EdgeInsets.symmetric(horizontal: 2, vertical: 0), - // child: Stack( - // children: [ - // Container( - // padding: EdgeInsets.symmetric(horizontal: 8, vertical: 8), - // margin: EdgeInsets.symmetric(horizontal: 14, vertical: 8), - // decoration: new BoxDecoration( - // color: Colors.grey.shade100, - // shape: BoxShape.rectangle, - // borderRadius: BorderRadius.circular(8), - // border: Border.fromBorderSide(BorderSide( - // color: isSelected ? Color(0xff20BC11) : Colors.grey.shade300, - // width: 0.8, - // )), - // ), - // width: cardWidth, - // child: Image.asset( - // getPaymentOptionImage(paymentOption), - // fit: BoxFit.cover, - // ), - // ), - // if (isSelected) - // Positioned( - // right: 1, - // child: Icon( - // Icons.check_circle, - // color: Color(0xff20BC11), - // size: 30, - // ), - // ), - // ], - // ), - // ), ), ); } diff --git a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart index 9fd40f2b..338fe87e 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart @@ -17,16 +17,22 @@ import 'package:flutter/material.dart'; ///TODO Elham* split this to tow files class PharmacyAddressesPage extends StatefulWidget { - final OrderPreviewViewModel orderPreviewViewModel; + final Function changeMainState; + + final bool isUpdate; + + const PharmacyAddressesPage( + {Key key, this.orderPreviewViewModel, this.isUpdate = false, this.changeMainState}) + : super(key: key); - const PharmacyAddressesPage({Key key, this.orderPreviewViewModel}) : super(key: key); @override _PharmacyAddressesState createState() => _PharmacyAddressesState(); } class _PharmacyAddressesState extends State { - void navigateToAddressPage(BuildContext ctx, PharmacyAddressesViewModel model, AddressInfo address) { + void navigateToAddressPage( + BuildContext ctx, PharmacyAddressesViewModel model, AddressInfo address) { Navigator.push( ctx, FadePage( @@ -61,12 +67,14 @@ class _PharmacyAddressesState extends State { setState(() { model.setSelectedAddressIndex(index); //TODO Elham* - widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[index].toJson()); + widget.orderPreviewViewModel.paymentCheckoutData + .address = + Addresses.fromJson( + model.addresses[index].toJson()); }); }, model.selectedAddressIndex == index, (address) { - navigateToAddressPage(context, model, address); }), ), @@ -88,8 +96,9 @@ class _PharmacyAddressesState extends State { }, ), ), - SizedBox(height: height * 0.10,) - + SizedBox( + height: height * 0.10, + ) ], ), ), @@ -118,9 +127,10 @@ class _PharmacyAddressesState extends State { fontSize: 14, vPadding: 8, handler: () { - model.saveSelectedAddressLocally(model.addresses[model.selectedAddressIndex]); - _navigateToPaymentOption(); - }, + model.saveSelectedAddressLocally( + model.addresses[model.selectedAddressIndex]); + _navigateToPaymentOption(model); + }, ), ), ], @@ -130,18 +140,31 @@ class _PharmacyAddressesState extends State { ); } - _navigateToPaymentOption() { - Navigator.push(context, FadePage(page: PaymentMethodSelectPage(model: widget.orderPreviewViewModel,))) - .then((result) => { - setState(() { - if (result != null) { - var paymentOption = result; - widget.orderPreviewViewModel.paymentCheckoutData.paymentOption = - paymentOption; - } - // widget.changeMainState(); - }) - }); + _navigateToPaymentOption(model) { + if(widget.isUpdate) { + print("sfsf"); + + widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[model.selectedAddressIndex].toJson()); + widget.changeMainState(); + Navigator.pop(context); + + return; + } + Navigator.push( + context, + FadePage( + page: PaymentMethodSelectPage( + model: widget.orderPreviewViewModel, + ))).then((result) => { + setState(() { + if (result != null) { + var paymentOption = result; + widget.orderPreviewViewModel.paymentCheckoutData.paymentOption = + paymentOption; + } + // widget.changeMainState(); + }) + }); } } @@ -152,7 +175,8 @@ class AddressItemWidget extends StatelessWidget { final bool isSelected; final Function(AddressInfo) onTabEditAddress; - AddressItemWidget(this.model, this.address, this.selectAddress, this.isSelected, this.onTabEditAddress); + AddressItemWidget(this.model, this.address, this.selectAddress, + this.isSelected, this.onTabEditAddress); @override Widget build(BuildContext context) { @@ -178,13 +202,18 @@ class AddressItemWidget extends StatelessWidget { decoration: new BoxDecoration( color: !isSelected ? Colors.white : Colors.green, shape: BoxShape.circle, - border: Border.all(color: Colors.grey, style: BorderStyle.solid, width: 1.0), + border: Border.all( + color: Colors.grey, + style: BorderStyle.solid, + width: 1.0), ), child: Padding( padding: const EdgeInsets.all(0.0), child: Icon( Icons.check, - color: isSelected ? Colors.white : Colors.transparent, + color: isSelected + ? Colors.white + : Colors.transparent, size: 25, ), ), @@ -197,7 +226,8 @@ class AddressItemWidget extends StatelessWidget { Expanded( child: Container( child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + margin: + EdgeInsets.symmetric(vertical: 12, horizontal: 12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -260,7 +290,8 @@ class AddressItemWidget extends StatelessWidget { ), ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 8), + padding: + const EdgeInsets.symmetric(horizontal: 8), child: SizedBox( child: Container( width: 1, @@ -278,13 +309,21 @@ class AddressItemWidget extends StatelessWidget { ConfirmDialog dialog = new ConfirmDialog( context: context, title: "Are you sure want to delete", - confirmMessage: "${address.address1} ${address.address2}", - okText: TranslationBase.of(context).delete, - cancelText: TranslationBase.of(context).cancel_nocaps, + confirmMessage: + "${address.address1} ${address.address2}", + okText: + TranslationBase.of(context).delete, + cancelText: TranslationBase.of(context) + .cancel_nocaps, okFunction: () => { - model.deleteAddresses(address).then((_) { - ConfirmDialog.closeAlertDialog(context); - AppToast.showErrorToast(message: "Address has been deleted"); + model + .deleteAddresses(address) + .then((_) { + ConfirmDialog.closeAlertDialog( + context); + AppToast.showErrorToast( + message: + "Address has been deleted"); }) }, cancelFunction: () => {}); From 1d1708bdcc6f40ed9ae80a7ca04a6d7462f445de Mon Sep 17 00:00:00 2001 From: devmirza121 Date: Tue, 9 Nov 2021 16:32:55 +0300 Subject: [PATCH 36/70] Health Calculator 4.0 --- lib/config/localized_values.dart | 40 ++ .../bmr_calculator/bmr_calculator.dart | 33 +- .../bmr_calculator/bmr_result_page.dart | 6 +- .../health_calculator/body_fat/body_fat.dart | 18 +- .../calorie_calculator.dart | 8 +- .../calorie_result_page.dart | 6 +- .../delivery_due/delivery_due.dart | 181 ++++---- .../delivery_due_result_page.dart | 196 ++++---- .../ideal_body/ideal_body.dart | 20 +- .../ideal_body/ideal_body_result_page.dart | 22 +- .../ovulation_period/ovulation_period.dart | 436 +++++++----------- .../ovulation_result_page.dart | 204 ++++---- lib/uitl/translations_delegate_base.dart | 43 ++ 13 files changed, 637 insertions(+), 576 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 3985f3fc..392d143a 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1635,4 +1635,44 @@ const Map localizedValues = { "waist": {"en": "Waist", "ar": "وسط"}, "hip": {"en": "Hip", "ar": "ورك او نتوء"}, "carbsProtin": {"en": "Carbs, Protein and Fat", "ar": "الكربوهيدرات والبروتينات والدهون"}, + "usefulInfo": {"en": "Useful Information", "ar": "Useful Information"}, + "babyAge": {"en": "Baby Age", "ar": "عمر الطفل الآن:"}, + "babyAgeAvail": {"en": "baby age is not available", "ar": "عمر الطفل غير متوفر"}, + "deliveryDue": {"en": "The delivery due date is estimated to be on the", "ar": "من المقدر أن يكون تاريخ استحقاق التسليم في"}, + + "almostInactive": {"en": "Almost Inactive(Little or no exercises)", "ar": "شبه غير نشط (تمارين قليلة أو معدومة)"}, + "lightActive1": {"en": "Lighty Active (1-3) days per week", "ar": "Lighty Active (1-3) أيام في الأسبوع"}, + "veryActive": {"en": "very Active(6-7) days per week", "ar": "نشط جدا (6-7) أيام في الأسبوع"}, + "superActive": {"en": "Super Active(very hard exercises)", "ar": "سوبر نشط (تمارين صعبة للغاية)"}, + + "dailyIntake": {"en": "Daily intake is", "ar": "المدخول اليومي"}, + "calculateAmount": {"en": "Calculates the amount of energy that the person’s body expends in a day", "ar": "تحسب كمية الطاقة التي يبذلها جسم الشخص في اليوم"}, + "bodyWillBurn": {"en": "This means the body will burn", "ar": "هذا يعني أن الجسم سوف يحترق"}, + "caloriesEachDay": {"en": "calories each day, if engaged in no activity for the entire day.. Note: Daily calorie requirement is", "ar": "السعرات الحرارية في كل يوم ، إذا لم تمارس أي نشاط طوال اليوم .. ملاحظة: متطلبات السعرات الحرارية اليومية هي"}, + "maintainWeight": {"en": "calories, to maintain the current weight.", "ar": "السعرات الحرارية للحفاظ على الوزن الحالي."}, + + "mediumFinger": {"en": "Medium(fingers touch)", "ar": "متوسطة (لمسة الأصابع)"}, + "smallFinger": {"en": "Small(fingers overlap)", "ar": "صغير (أصابع متداخلة)"}, + "largeFinger": {"en": "Large(fingers don\'n touch)", "ar": "كبير (لا تلمس الأصابع)"}, + "idealBodyWeight": {"en": "Calculates the ideal body weight based on height, Weight, and Body Size", "ar": "يحسب وزن الجسم المثالي بناءً على الطول والوزن وحجم الجسم"}, + "bodyFrameSize": {"en": "Body Frame Size", "ar": "حجم إطار الجسم"}, + + "idealWeightRange": {"en": "Ideal weight range is", "ar": "نطاق الوزن المثالي هو"}, + "currentWeightPerfect": {"en": "Congratulations! The current weight is perfect and considered healthy", "ar": "تهانينا! الوزن الحالي مثالي ويعتبر صحي"}, + "littleBitWeightMore": {"en": "This means that the weight is a little bit more than ideal weight by", "ar": "هذا يعني أن الوزن أكثر قليلاً من الوزن المثالي به"}, + "consultWithDoctor": {"en": "May wish to consult with the doctor for medical help. Click to view our list of Doctors", "ar": "قد ترغب في استشارة الطبيب للحصول على مساعدة طبية. انقر لعرض قائمة الأطباء لدينا"}, + "excessiveObesity": {"en": "Means that you suffer from excessive obesity by", "ar": "يعني أنك تعاني من السمنة المفرطة بها"}, + "mayWish": {"en": "May wish to consult with the doctor for medical help. Click to view our list of\n Doctors", "ar": "قد ترغب في استشارة الطبيب للحصول على مساعدة طبية. انقر لعرض قائمة الأطباء \ n الخاصة بنا"}, + + "essential": {"en": "The category falls under essential", "ar": "الفئة تندرج تحت الأساسية"}, + "athlete": {"en": "The category falls under athlete", "ar": "فئة تندرج تحت رياضي"}, + "fitness": {"en": "The category falls under fitness", "ar": "الفئة تندرج تحت اللياقة البدنية"}, + "acceptable": {"en": "The category falls under acceptable", "ar": "الفئة تندرج تحت مقبول"}, + "underObese": {"en": "The category falls under obese", "ar": "تندرج الفئة تحت السمنة"}, + "crossedLimits": {"en": "Please check the value you have entered, since the body fat percentage has crosed the limits.", "ar": "يرجى التحقق من القيمة التي أدخلتها ، لأن نسبة الدهون في الجسم تجاوزت الحدود."}, + "lowLimits": {"en": "Please check the value you have entered, since the body fat percentage cannot be this low.", "ar": "يرجى التحقق من القيمة التي أدخلتها ، حيث لا يمكن أن تكون نسبة الدهون في الجسم منخفضة."}, + "estimates": {"en": "Estimates the total body fat based on\nthe size", "ar": "تقدير إجمالي الدهون في الجسم بناءً على \ n الحجم"}, + + }; + diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart index 3512b4de..e2010445 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart @@ -49,7 +49,7 @@ class _BmrCalculatorState extends State { // int height = 0; // int weight = 0; double bmrResult = 0; - String dropdownValue = 'Lighty Active (1-3) days per week'; + String dropdownValue = null; double calories = 0; void updateColor(int type) { @@ -122,14 +122,14 @@ class _BmrCalculatorState extends State { bmrResult = bmrResult.roundToDouble(); } - void calculateCalories() { - if (dropdownValue == "Almost Inactive(Little or no exercises)") { + void calculateCalories(BuildContext context) { + if (dropdownValue == TranslationBase.of(context).almostInactive) { calories = bmrResult * 1.2; - } else if (dropdownValue == "Lighty Active (1-3) days per week") { + } else if (dropdownValue == TranslationBase.of(context).lightActive1) { calories = bmrResult * 1.375; - } else if (dropdownValue == "very Active(6-7) days per week") { + } else if (dropdownValue == TranslationBase.of(context).veryActive) { calories = bmrResult * 1.55; - } else if (dropdownValue == "Super Active(very hard exercises)") { + } else if (dropdownValue == TranslationBase.of(context).superActive) { calories = bmrResult * 1.725; } else if (dropdownValue == "") { calories = bmrResult * 10.725; @@ -138,6 +138,7 @@ class _BmrCalculatorState extends State { @override Widget build(BuildContext context) { + if (dropdownValue == null) dropdownValue = TranslationBase.of(context).lightActive1; ProjectViewModel projectViewModel = Provider.of(context); _weightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).kg), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).lb), value: false)]; _heightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).cm), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).ft), value: false)]; @@ -171,7 +172,7 @@ class _BmrCalculatorState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Calculates the amount of energy that the person’s body expends in a day', + TranslationBase.of(context).calculateAmount, style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, @@ -372,10 +373,10 @@ class _BmrCalculatorState extends State { }); }, items: [ - 'Almost Inactive(Little or no exercises)', - 'Lighty Active (1-3) days per week', - 'very Active(6-7) days per week', - 'Super Active(very hard exercises)' + TranslationBase.of(context).almostInactive, + TranslationBase.of(context).lightActive1, + TranslationBase.of(context).veryActive, + TranslationBase.of(context).superActive ].map>((String value) { return DropdownMenuItem( value: value, @@ -412,16 +413,16 @@ class _BmrCalculatorState extends State { onTap: () { setState(() { calculateBmr(); - calculateCalories(); + calculateCalories(context); { Navigator.push( context, FadePage( page: BmrResultPage( - bmrResult: bmrResult, - calories: calories, - )), + bmrResult: bmrResult, + calories: calories, + )), ); } }); @@ -661,5 +662,3 @@ class CommonDropDownView extends StatelessWidget { ); } } - - diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_result_page.dart index 53426f94..4ef6ad08 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_result_page.dart @@ -37,7 +37,7 @@ class BmrResultPage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Calories", + TranslationBase.of(context).calories, style: TextStyle( fontSize: 19, letterSpacing: -1.34, @@ -65,7 +65,7 @@ class BmrResultPage extends StatelessWidget { height: 5.0, ), Text( - 'Calories', + TranslationBase.of(context).calories, style: TextStyle( fontSize: 18, letterSpacing: -1.08, @@ -80,7 +80,7 @@ class BmrResultPage extends StatelessWidget { ), mHeight(20), Text( - 'This means the body will burn ( ${bmrResult.toStringAsFixed(1)} ) calories each day, if engaged in no activity for the entire day.. Note: Daily calorie requirement is ( ${calories.toStringAsFixed(1)} ) calories, to maintain the current weight.', + TranslationBase.of(context).bodyWillBurn+' ( ${bmrResult.toStringAsFixed(1)} )'+TranslationBase.of(context).caloriesEachDay+'( ${calories.toStringAsFixed(1)} ) '+TranslationBase.of(context).maintainWeight, style: TextStyle( fontSize: 14, letterSpacing: -0.56, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart index 1442afbd..5cdd8e3b 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart @@ -180,22 +180,22 @@ class _BodyFatState extends State { } } - void showTextResult() { + void showTextResult(BuildContext context) { if (isMale == false) { if (bodyFat > 9 && bodyFat <= 13) { - textResult = 'The category falls under essential'; + textResult = TranslationBase.of(context).essential; } else if (bodyFat > 13 && bodyFat <= 20) { - textResult = 'The category falls under athlete'; + textResult = TranslationBase.of(context).athlete; } else if (bodyFat > 20 && bodyFat <= 24) { - textResult = 'The category falls under fitness'; + textResult =TranslationBase.of(context).fitness; } else if (bodyFat > 24 && bodyFat <= 31) { - textResult = 'The category falls under acceptable'; + textResult =TranslationBase.of(context).acceptable; } else if (bodyFat > 31 && bodyFat <= 60) { - textResult = 'The category falls under obese'; + textResult =TranslationBase.of(context).underObese; } else if (bodyFat > 60) { - textResult = 'Please check the value you have entered, since the body fat percentage has crosed the limits.'; + textResult =TranslationBase.of(context).crossedLimits; } else if (bodyFat <= 9) { - textResult = 'Please check the value you have entered, since the body fat percentage cannot be this low.'; + textResult =TranslationBase.of(context).lowLimits; } } else { if (bodyFat > 5 && fat <= 13) { @@ -464,7 +464,7 @@ class _BodyFatState extends State { onTap: () { setState(() { calculateBodyFat(); - showTextResult(); + showTextResult(context); { Navigator.push( diff --git a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart index 74db1a30..f1db7e82 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart @@ -305,10 +305,10 @@ class _CalorieCalculatorState extends State { }); }, items: [ - 'Almost Inactive(Little or no exercises)', - 'Lighty Active (1-3) days per week', - 'very Active(6-7) days per week', - 'Super Active(very hard exercises)' + TranslationBase.of(context).almostInactive, + TranslationBase.of(context).lightActive, + TranslationBase.of(context).lightActive1, + TranslationBase.of(context).superActive, ].map>((String value) { return DropdownMenuItem( value: value, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart index dc27e051..68bd2d2c 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart @@ -37,7 +37,7 @@ class CalorieResultPage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Calories", + TranslationBase.of(context).calories, style: TextStyle( fontSize: 19, letterSpacing: -1.34, @@ -65,7 +65,7 @@ class CalorieResultPage extends StatelessWidget { height: 5.0, ), Text( - 'Calories', + TranslationBase.of(context).calories, style: TextStyle( fontSize: 18, letterSpacing: -1.08, @@ -80,7 +80,7 @@ class CalorieResultPage extends StatelessWidget { ), mHeight(20), Text( - 'Daily intake is ${calorie.toStringAsFixed(1)} calories', + TranslationBase.of(context).dailyIntake+' ${calorie.toStringAsFixed(1)} '+TranslationBase.of(context).calories, style: TextStyle( fontSize: 14, letterSpacing: -0.56, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/delivery_due/delivery_due.dart b/lib/pages/AlHabibMedicalService/health_calculator/delivery_due/delivery_due.dart index 1ada0ca1..b8528ea6 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/delivery_due/delivery_due.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/delivery_due/delivery_due.dart @@ -1,6 +1,8 @@ +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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'; @@ -44,103 +46,114 @@ class _DeliveryDueState extends State { showNewAppBarTitle: true, isShowDecPage: false, appBarTitle: TranslationBase.of(context).pregnancyTitle, - body: Padding( - padding: EdgeInsets.symmetric(horizontal: 35.0, vertical: 20.0), - child: SingleChildScrollView( - child: Container( - child: Column( - children: [ - Texts( - TranslationBase.of(context).pregnancyDesc, - ), - Divider( - //height: 2, - thickness: 2, - ), - Column( + body: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Container( + padding: EdgeInsets.symmetric(horizontal: 21.0, vertical: 21.0), + child: Column( children: [ - Texts( - TranslationBase.of(context).pregnancyDateLabel, + Text( + TranslationBase.of(context).pregnancyDesc, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + ), ), - InkWell( - onTap: () { - DatePicker.showDatePicker( - context, - showTitleActions: true, - minTime: DateTime(DateTime.now().year - 1, 1, 1), - maxTime: DateTime.now(), - onConfirm: (date) { - print('confirm $date'); - setState(() { - bloodSugarDate = date; - dateFrom = date.add(Duration(days: 10)); + Divider( + //height: 2, + thickness: 1, + ), + Column( + children: [ + Text( + TranslationBase.of(context).pregnancyDateLabel, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + ), + ), + InkWell( + onTap: () { + DatePicker.showDatePicker( + context, + showTitleActions: true, + minTime: DateTime(DateTime.now().year - 1, 1, 1), + maxTime: DateTime.now(), + onConfirm: (date) { + print('confirm $date'); + setState(() { + bloodSugarDate = date; + dateFrom = date.add(Duration(days: 10)); - dateTo = date.add(Duration(days: 20)); - conceivedDate = date.add(Duration(days: 14)); - deliveryDue = date.add(Duration(days: 280)); - firstTrimester = date.add(Duration(days: 85)); - secondTrimester = date.add(Duration(days: 190)); - thirdTrimester = date.add(Duration(days: 280)); - }); + dateTo = date.add(Duration(days: 20)); + conceivedDate = date.add(Duration(days: 14)); + deliveryDue = date.add(Duration(days: 280)); + firstTrimester = date.add(Duration(days: 85)); + secondTrimester = date.add(Duration(days: 190)); + thirdTrimester = date.add(Duration(days: 280)); + }); + }, + currentTime: DateTime.now(), + ); }, - currentTime: DateTime.now(), - ); - }, - child: Container( - padding: EdgeInsets.all(12), - margin: EdgeInsets.only(top: 15.0), - width: double.infinity, - height: 65, - decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( + child: Container( + padding: EdgeInsets.all(12), + margin: EdgeInsets.only(top: 15.0), + width: double.infinity, + height: 65, + decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Icon(Icons.date_range), - Texts(TranslationBase.of(context).date), + Row( + children: [ + Icon(Icons.date_range), + Texts(TranslationBase.of(context).date), + ], + ), + Texts(getDate()), ], ), - Texts(getDate()), - ], + ), ), - ), + ], ), + ], ), - SizedBox( - height: 280.0, - ), - Container( - height: 50.0, - width: 350.0, - child: DefaultButton( - TranslationBase.of(context).calculate, - () { - setState(() { - { - Navigator.push( - context, - FadePage( - page: DeliveryDueResult( - conceivedDate: conceivedDate, - dateFrom: dateFrom, - dateTo: dateTo, - deliveryDue: deliveryDue, - firstTrimester: firstTrimester, - secondTrimester: secondTrimester, - thirdTrimester: thirdTrimester, - )), - ); - } - }); - }, - ), - ), - ], + ), + ), + ), + Container( + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( + label: TranslationBase.of(context).calculate, + color: CustomColors.accentColor, + onTap: () { + setState(() { + { + Navigator.push( + context, + FadePage( + page: DeliveryDueResult( + conceivedDate: conceivedDate, + dateFrom: dateFrom, + dateTo: dateTo, + deliveryDue: deliveryDue, + firstTrimester: firstTrimester, + secondTrimester: secondTrimester, + thirdTrimester: thirdTrimester, + )), + ); + } + }); + }, ), ), - ), + ], ), ); } diff --git a/lib/pages/AlHabibMedicalService/health_calculator/delivery_due/delivery_due_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/delivery_due/delivery_due_result_page.dart index b546426b..f7431d1a 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/delivery_due/delivery_due_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/delivery_due/delivery_due_result_page.dart @@ -1,9 +1,12 @@ import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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'; @@ -29,78 +32,102 @@ class DeliveryDueResult extends StatelessWidget { showNewAppBarTitle: true, isShowDecPage: false, appBarTitle: TranslationBase.of(context).pregnancyTitle, - body: Padding( - padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 12.0), - child: SingleChildScrollView( - child: Container( - height: 750.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Texts( - TranslationBase.of(context).ovulationPeriod, - fontWeight: FontWeight.w400, - ), - Texts( - TranslationBase.of(context).from, - fontWeight: FontWeight.w400, - ), - Texts(DateFormat.yMMMEd().format(dateFrom), fontWeight: FontWeight.w800, fontSize: 21.0, color: Color(0xffC5272D)), - Texts( - TranslationBase.of(context).to, - fontWeight: FontWeight.w400, - ), - Texts(DateFormat.yMMMEd().format(dateTo), fontWeight: FontWeight.w800, fontSize: 21.0, color: Color(0xffC5272D)), - Texts( - TranslationBase.of(context).conceive, - fontWeight: FontWeight.w400, - ), - Texts( - DateFormat.yMMMEd().format(conceivedDate), - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Texts( - TranslationBase.of(context).firstTri, - fontWeight: FontWeight.w400, - ), - Texts( - DateFormat.yMMMEd().format(firstTrimester), - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Texts( - TranslationBase.of(context).secondTri, - fontWeight: FontWeight.w400, - ), - Texts( - DateFormat.yMMMEd().format(secondTrimester), - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Texts( - TranslationBase.of(context).thirdTri, - fontWeight: FontWeight.w400, - ), - Texts( - DateFormat.yMMMEd().format(thirdTrimester), - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Container( - width: 350, - child: DefaultButton( - TranslationBase.of(context).seeDoctorsList, - () { - getDoctorsList(context); - }, - ), - ), - ], + body: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Container( + padding: EdgeInsets.symmetric(horizontal: 21.0, vertical: 21.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Text( + TranslationBase.of(context).pregnancyTitle, + style: TextStyle( + fontSize: 19, + letterSpacing: -1.14, + fontWeight: FontWeight.w600, + ), + ), + Text( + TranslationBase.of(context).ovulationPeriod, + style: TextStyle( + fontSize: 14, + letterSpacing: -0.56, + fontWeight: FontWeight.w600, + color: CustomColors.textColor, + ), + ), + mHeight(20), + showItem(TranslationBase.of(context).from, DateFormat.yMMMEd().format(dateFrom), titleColor: CustomColors.accentColor), + mHeight(12), + showItem(TranslationBase.of(context).to, DateFormat.yMMMEd().format(dateTo), titleColor: CustomColors.accentColor), + mHeight(12), + mDivider(CustomColors.devider), + mHeight(12), + showItem(TranslationBase.of(context).conceive, DateFormat.yMMMEd().format(conceivedDate)), + mHeight(12), + mDivider(CustomColors.devider), + mHeight(12), + showItem(TranslationBase.of(context).firstTri, DateFormat.yMMMEd().format(firstTrimester)), + mHeight(12), + mDivider(CustomColors.devider), + mHeight(12), + showItem(TranslationBase.of(context).secondTri, DateFormat.yMMMEd().format(secondTrimester)), + mHeight(12), + mDivider(CustomColors.devider), + mHeight(12), + showItem(TranslationBase.of(context).thirdTri, DateFormat.yMMMEd().format(thirdTrimester)), + mHeight(12), + mDivider(CustomColors.devider), + mHeight(12), + ], + ).withBorderedContainer, + ), ), ), - ), + Container( + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( + label: TranslationBase.of(context).seeDoctorsList, + color: CustomColors.accentColor, + onTap: () { + getDoctorsList(context); + }, + ), + ), + ], + ), + ); + } + + Widget showItem(String title, String value, {Color titleColor}) { + return Container( + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: TextStyle( + fontSize: 14, + letterSpacing: -0.56, + color: titleColor ?? Colors.black, + fontWeight: FontWeight.w500, + // fontWeight: FontWeight.w600, + ), + ), + Text( + value, + style: TextStyle( + fontSize: 18, + letterSpacing: -1.08, + fontWeight: FontWeight.w600, + ), + ), + ], ), ); } @@ -145,20 +172,11 @@ class DeliveryDueResult extends StatelessWidget { if (doctorByHospital.length != 0) { _patientDoctorAppointmentListHospital[_patientDoctorAppointmentListHospital.indexOf(doctorByHospital[0])].patientDoctorAppointmentList.add(element); } else { - _patientDoctorAppointmentListHospital - .add(PatientDoctorAppointmentList(filterName: element.projectName, distanceInKMs: "0", patientDoctorAppointment: element)); + _patientDoctorAppointmentListHospital.add(PatientDoctorAppointmentList(filterName: element.projectName, distanceInKMs: "0", patientDoctorAppointment: element)); } }); - Navigator.push( - context, - FadePage( - page: SearchResults( - isLiveCareAppointment: false, - doctorsList: doctorsList, - patientDoctorAppointmentListHospital: - _patientDoctorAppointmentListHospital))); - + Navigator.push(context, FadePage(page: SearchResults(isLiveCareAppointment: false, doctorsList: doctorsList, patientDoctorAppointmentListHospital: _patientDoctorAppointmentListHospital))); } } }).catchError((err) { @@ -167,3 +185,19 @@ class DeliveryDueResult extends StatelessWidget { }); } } + +extension BorderedContainer on Widget { + Widget get withBorderedContainer => Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: this, + ); +} diff --git a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart index e414f028..265bb412 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart @@ -34,7 +34,7 @@ class _IdealBodyState extends State { double overWeightBy; int weight = 0; double idealWeight = 0; - String dropdownValue = 'Medium(fingers touch)'; + String dropdownValue = null; double calories = 0; String textResult = ''; double maxIdealWeight; @@ -58,11 +58,11 @@ class _IdealBodyState extends State { heightInches = int.parse(_heightController.text) * .39370078740157477; heightFeet = heightInches / 12; idealWeight = (50 + 2.3 * (heightInches - 60)); - if (dropdownValue == 'Small(fingers overlap)') { + if (dropdownValue == TranslationBase.of(context).smallFinger) { idealWeight = idealWeight - 10; - } else if (dropdownValue == 'Medium(fingers touch)') { + } else if (dropdownValue == TranslationBase.of(context).mediumFinger) { idealWeight = idealWeight; - } else if (dropdownValue == 'Large(fingers don\'n touch)') { + } else if (dropdownValue == TranslationBase.of(context).largeFinger) { idealWeight = idealWeight + 10; } @@ -75,6 +75,8 @@ class _IdealBodyState extends State { @override Widget build(BuildContext context) { + if(dropdownValue==null) + dropdownValue=TranslationBase.of(context).mediumFinger; _weightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).kg), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).lb), value: false)]; _heightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).cm), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).ft), value: false)]; @@ -103,7 +105,7 @@ class _IdealBodyState extends State { child: Column( children: [ Text( - 'Calculates the ideal body weight based on height, Weight, and Body Size', + TranslationBase.of(context).idealBodyWeight, style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, @@ -186,7 +188,7 @@ class _IdealBodyState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Body Frame Size", + TranslationBase.of(context).bodyFrameSize, style: TextStyle( fontSize: 11, letterSpacing: -0.44, @@ -213,9 +215,9 @@ class _IdealBodyState extends State { }); }, items: [ - 'Small(fingers overlap)', - 'Medium(fingers touch)', - 'Large(fingers don\'n touch)', + TranslationBase.of(context).smallFinger, + TranslationBase.of(context).mediumFinger, + TranslationBase.of(context).largeFinger, ].map>((String value) { return DropdownMenuItem( value: value, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body_result_page.dart index 6eec6dd8..a29d4bf0 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body_result_page.dart @@ -40,7 +40,7 @@ class IdealBodyResult extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Ideal weight range is', + TranslationBase.of(context).idealWeightRange, style: TextStyle( fontSize: 19, letterSpacing: -1.34, @@ -60,7 +60,7 @@ class IdealBodyResult extends StatelessWidget { Padding( padding: EdgeInsets.only(top: 8.0, left: 4.0), child: Text( - 'Kg', + " "+TranslationBase.of(context).kg+" ", style: TextStyle(color: Colors.red), ), ), @@ -80,7 +80,7 @@ class IdealBodyResult extends StatelessWidget { Padding( padding: EdgeInsets.only(top: 8.0, left: 4.0), child: Text( - 'Kg', + " "+TranslationBase.of(context).kg+" ", style: TextStyle(color: Colors.red), ), ), @@ -93,7 +93,7 @@ class IdealBodyResult extends StatelessWidget { ? Column( children: [ Texts( - 'Congratulations! The current weight is perfect and considered healthy', + TranslationBase.of(context).currentWeightPerfect, fontSize: 20.0, ), ], @@ -101,9 +101,9 @@ class IdealBodyResult extends StatelessWidget { : overWeightBy > 10 && overWeightBy < 17 ? Column( children: [ - Texts('This means that the weight is a little bit more than ideal weight by'), + Texts(TranslationBase.of(context).littleBitWeightMore), Texts(overWeightBy.toStringAsFixed(1)), - Texts('May wish to consult with the doctor for medical help. Click to view our list of Doctors'), + Texts(TranslationBase.of(context).consultWithDoctor), ], ) : overWeightBy >= 18 @@ -112,7 +112,7 @@ class IdealBodyResult extends StatelessWidget { child: Column( children: [ Texts( - 'Means that you suffer from excessive obesity by', + TranslationBase.of(context).excessiveObesity, ), SizedBox( height: 12.0, @@ -128,7 +128,7 @@ class IdealBodyResult extends StatelessWidget { SizedBox( height: 12.0, ), - Texts('May wish to consult with the doctor for medical help. Click to view our list of\n Doctors'), + Texts(TranslationBase.of(context).mayWish), ], ), ) @@ -139,7 +139,7 @@ class IdealBodyResult extends StatelessWidget { Padding( padding: const EdgeInsets.all(8.0), child: Texts( - 'Under Weight', + TranslationBase.of(context).underWeight, fontSize: 18.0, ), ), @@ -161,7 +161,7 @@ class IdealBodyResult extends StatelessWidget { child: Column( children: [ Text( - 'under wheight', + TranslationBase.of(context).underWeight, style: TextStyle( fontSize: 17, fontWeight: FontWeight.bold, @@ -182,7 +182,7 @@ class IdealBodyResult extends StatelessWidget { SizedBox( height: 12.0, ), - Texts('May wish to consult with the doctor for medical help. Click to view our list of Doctors'), + Texts(TranslationBase.of(context).mayWish), ], ), ), diff --git a/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_period.dart b/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_period.dart index 86699ed4..69894df3 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_period.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_period.dart @@ -1,6 +1,8 @@ +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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'; @@ -20,8 +22,9 @@ class _OvulationPeriodState extends State { DateTime bloodSugarDate = DateTime.now(); DateTime timeSugarDate = DateTime.now(); DateTime selectedDateTime = DateTime.now(); - int cycleLength = 0; - int lutealPhaseLength = 0; + + // int cycleLength = 0; + // int lutealPhaseLength = 0; String selectedDate; var dateFrom = DateTime.now(); var babyAgeWeeks; @@ -33,6 +36,9 @@ class _OvulationPeriodState extends State { var newFormat = DateFormat("yy-MM-dd"); String updatedDt; + TextEditingController cycleLengthController = new TextEditingController(); + TextEditingController lutelLengthController = new TextEditingController(); + String getTime() { return " ${timeSugarDate.hour}:${timeSugarDate.minute}"; } @@ -64,286 +70,176 @@ class _OvulationPeriodState extends State { showNewAppBarTitle: true, isShowDecPage: false, appBarTitle: TranslationBase.of(context).ovulation, - body: Padding( - padding: EdgeInsets.symmetric(horizontal: 25.0, vertical: 15.0), - child: SingleChildScrollView( - child: Container( - height: 700.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts(TranslationBase.of(context).ovulationDesc), - SizedBox( - height: 12.0, - ), - Divider( - //height: 2, - thickness: 2, - ), - SizedBox( - height: 12.0, - ), - InkWell( - onTap: () { - DatePicker.showDatePicker( - context, - showTitleActions: true, - minTime: DateTime(DateTime.now().year - 1, 1, 1), - maxTime: DateTime.now(), - onConfirm: (date) { - print('confirm $date'); - setState(() { - selectedDateTime = date; - }); - }, - currentTime: DateTime.now(), - ); - }, - child: Container( - padding: EdgeInsets.all(12), - width: double.infinity, - height: 65, - decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts(TranslationBase.of(context).date), - Texts(getDate()), - ], - ), - ), - ), - SizedBox( - height: 5.0, - ), - Texts( - TranslationBase.of(context).cycleLabel, - fontWeight: FontWeight.w400, - ), - SizedBox( - height: 5.0, - ), - Row( + body: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Container( + padding: EdgeInsets.all(21), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - width: 340.0, - height: 60.0, - decoration: BoxDecoration( - color: Colors.white, + Text( + TranslationBase.of(context).ovulationDesc, + style: TextStyle( + fontSize: 14, + letterSpacing: -0.54, + color: Colors.black, + fontWeight: FontWeight.w600, ), - child: Row( - children: [ - Padding( - padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), - child: Row( - children: [ - Expanded( - child: Center( - child: Text(cycleLength.toString()), - ), - ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (cycleLength < 45) cycleLength++; - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (cycleLength > 0) cycleLength--; - }); - }, - ), - ], - ), - ), - ], - ), - ), - ), - ), - Expanded( - child: Slider( - value: cycleLength.toDouble(), - min: 0, - max: 45, - onChanged: (double newValue) { - setState(() { - cycleLength = newValue.round(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), - ), - ], + ), + SizedBox( + height: 12.0, + ), + InkWell( + onTap: () { + DatePicker.showDatePicker( + context, + showTitleActions: true, + minTime: DateTime(DateTime.now().year - 1, 1, 1), + maxTime: DateTime.now(), + onConfirm: (date) { + print('confirm $date'); + setState(() { + selectedDateTime = date; + }); + }, + currentTime: DateTime.now(), + ); + }, + child: Container( + padding: EdgeInsets.all(12), + width: double.infinity, + height: 65, + decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts(TranslationBase.of(context).date), + Texts(getDate()), + ], + ), ), ), + SizedBox( + height: 12.0, + ), + inputWidget(TranslationBase.of(context).cycleLabel, "0", cycleLengthController), + SizedBox( + height: 12.0, + ), + inputWidget(TranslationBase.of(context).lutealLabel, "0", lutelLengthController), ], ), - Texts( - TranslationBase.of(context).lutealLabel, - fontWeight: FontWeight.w400, - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Container( - width: 340.0, - height: 60.0, - decoration: BoxDecoration( - color: Colors.white, + ), + ), + ), + Container( + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( + label: TranslationBase.of(context).calculate, + color: CustomColors.accentColor, + onTap: () { + calculateBabyInformation(); + Navigator.push( + context, + FadePage( + page: OvulationResult( + conceivedDate: conceivedDate, + dateFrom: dateFrom, + dateTo: dateTo, + deliveryDue: deliveryDue, + babyAge: babyAgeWeeks, + babyAgeDays: babyAgeDays, + ), + ), + ); + }, + ), + ), + ], + ), + ); + } + + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) { + return Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: InkWell( + onTap: hasSelection ? () {} : null, + child: Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _labelText, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.zero, + keyboardType: TextInputType.number, + controller: _controller, + onChanged: (value) => {}, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, ), - child: Row( - children: [ - Padding( - padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), - child: Row( - children: [ - Expanded( - child: Center( - child: Text(lutealPhaseLength.toString()), - ), - ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (lutealPhaseLength < 15) lutealPhaseLength++; - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (lutealPhaseLength > 0) lutealPhaseLength--; - }); - }, - ), - ], - ), - ), - ], - ), + prefixIconConstraints: BoxConstraints(minWidth: 50), + prefixIcon: prefix == null + ? null + : Text( + "+" + prefix, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, ), ), - ), - Expanded( - child: Slider( - value: lutealPhaseLength.toDouble(), - min: 0, - max: 15, - onChanged: (double newValue) { - setState(() { - lutealPhaseLength = newValue.round(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), - ), - ], - ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, ), - ], - ), - SizedBox( - height: 220.0, - ), - Container( - height: 50.0, - width: 350.0, - child: DefaultButton( - TranslationBase.of(context).calculate, - () { - calculateBabyInformation(); - Navigator.push( - context, - FadePage( - page: OvulationResult( - conceivedDate: conceivedDate, - dateFrom: dateFrom, - dateTo: dateTo, - deliveryDue: deliveryDue, - babyAge: babyAgeWeeks, - babyAgeDays: babyAgeDays, - )), - ); - }, ), - ), - ], + ], + ), ), - ), + if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined), + ], ), ), ); diff --git a/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_result_page.dart index bc345711..67ec7dea 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_result_page.dart @@ -1,9 +1,12 @@ import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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'; @@ -26,6 +29,7 @@ class OvulationResult extends StatelessWidget { this.babyAge, this.babyAgeDays, }); + //var newFormat = DateFormat("yy-MM-dd"); @override @@ -35,81 +39,105 @@ class OvulationResult extends StatelessWidget { showNewAppBarTitle: true, isShowDecPage: false, appBarTitle: TranslationBase.of(context).ovulation, - body: Padding( - padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 15.0), - child: SingleChildScrollView( - child: Container( - height: 750.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Texts( - 'The next ovulation period is estimated to be:', - fontWeight: FontWeight.w400, - ), - Texts( - 'From:', - fontWeight: FontWeight.w400, - ), - Texts( - DateFormat.yMMMEd().format(dateFrom), - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Texts( - 'To:', - fontWeight: FontWeight.w400, - ), - Texts( - DateFormat.yMMMEd().format(dateTo), - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Texts( - 'Useful Information:', - color: Color(0xffC5272D), - ), - Texts( - 'You have conceived on:', - fontWeight: FontWeight.w400, - ), - Texts( - DateFormat.yMMMEd().format(conceivedDate), - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Texts( - 'The baby\'s age right now:', - fontWeight: FontWeight.w400, - ), - Texts( - babyAge <= 0 ? "baby age is not available" : babyAge.toString() + " Weeks", - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Texts( - 'The delivery due date is estimated to be on the: ', - fontWeight: FontWeight.w400, - ), - Texts( - DateFormat.yMMMEd().format(deliveryDue), - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Container( - width: 350, - child: DefaultButton( - TranslationBase.of(context).seeDoctorsList, - () { - getDoctorsList(context); - }, - ), - ), - ], + body: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(21), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).ovulation, + style: TextStyle( + fontSize: 19, + letterSpacing: -1.14, + fontWeight: FontWeight.w600, + ), + ), + mHeight(20), + Text( + TranslationBase.of(context).ovulationPeriod, + style: TextStyle( + fontSize: 14, + letterSpacing: -0.56, + fontWeight: FontWeight.w600, + color: CustomColors.textColor, + ), + ), + mHeight(20), + showItem(TranslationBase.of(context).from, DateFormat.yMMMEd().format(dateFrom), titleColor: CustomColors.accentColor), + mHeight(12), + showItem(TranslationBase.of(context).to, DateFormat.yMMMEd().format(dateTo), titleColor: CustomColors.accentColor), + mHeight(12), + mDivider(CustomColors.devider), + mHeight(12), + Text( + TranslationBase.of(context).useFullInfo, + style: TextStyle( + fontSize: 14, + letterSpacing: -0.56, + color: CustomColors.accentColor, + fontWeight: FontWeight.w500, + ), + ), + mHeight(12), + showItem(TranslationBase.of(context).conceive, DateFormat.yMMMEd().format(conceivedDate)), + mHeight(12), + mDivider(CustomColors.devider), + mHeight(12), + showItem(TranslationBase.of(context).babyAge, babyAge <= 0 ? TranslationBase.of(context).babyAgeAvail : babyAge.toString() + TranslationBase.of(context).week), + + mHeight(12), + mDivider(CustomColors.devider), + mHeight(12), showItem(TranslationBase.of(context).deliveryDue, DateFormat.yMMMEd().format(deliveryDue)), + ], + ).withBorderedContainer, + ), ), ), - ), + Container( + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( + label: TranslationBase.of(context).viewDocList, + color: CustomColors.accentColor, + onTap: () { + getDoctorsList(context); + }, + ), + ), + ], + ), + ); + } + + Widget showItem(String title, String value, {Color titleColor}) { + return Container( + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: TextStyle( + fontSize: 14, + letterSpacing: -0.56, + color: titleColor ?? Colors.black, + fontWeight: FontWeight.w500, + // fontWeight: FontWeight.w600, + ), + ), + Text( + value, + style: TextStyle( + fontSize: 18, + letterSpacing: -1.08, + fontWeight: FontWeight.w600, + ), + ), + ], ), ); } @@ -148,26 +176,17 @@ class OvulationResult extends StatelessWidget { List doctorByHospital = _patientDoctorAppointmentListHospital .where( (elementClinic) => elementClinic.filterName == element.projectName, - ) + ) .toList(); if (doctorByHospital.length != 0) { _patientDoctorAppointmentListHospital[_patientDoctorAppointmentListHospital.indexOf(doctorByHospital[0])].patientDoctorAppointmentList.add(element); } else { - _patientDoctorAppointmentListHospital - .add(PatientDoctorAppointmentList(filterName: element.projectName, distanceInKMs: "0", patientDoctorAppointment: element)); + _patientDoctorAppointmentListHospital.add(PatientDoctorAppointmentList(filterName: element.projectName, distanceInKMs: "0", patientDoctorAppointment: element)); } }); - Navigator.push( - context, - FadePage( - page: SearchResults( - isLiveCareAppointment: false, - doctorsList: doctorsList, - patientDoctorAppointmentListHospital: - _patientDoctorAppointmentListHospital))); - + Navigator.push(context, FadePage(page: SearchResults(isLiveCareAppointment: false, doctorsList: doctorsList, patientDoctorAppointmentListHospital: _patientDoctorAppointmentListHospital))); } } }).catchError((err) { @@ -175,5 +194,20 @@ class OvulationResult extends StatelessWidget { print(err); }); } +} +extension BorderedContainer on Widget { + Widget get withBorderedContainer => Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: this, + ); } diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 6d454d05..0491cfd4 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2622,6 +2622,49 @@ class TranslationBase { String get waist => localizedValues["waist"][locale.languageCode]; String get hip => localizedValues["hip"][locale.languageCode]; String get carbsProtin => localizedValues["carbsProtin"][locale.languageCode]; + + String get useFullInfo => localizedValues["usefulInfo"][locale.languageCode]; + String get babyAge => localizedValues["babyAge"][locale.languageCode]; + String get babyAgeAvail => localizedValues["babyAgeAvail"][locale.languageCode]; + String get deliveryDue => localizedValues["deliveryDue"][locale.languageCode]; + + String get almostInactive => localizedValues["almostInactive"][locale.languageCode]; + String get lightActive1 => localizedValues["lightActive1"][locale.languageCode]; + String get veryActive => localizedValues["veryActive"][locale.languageCode]; + String get superActive => localizedValues["superActive"][locale.languageCode]; + + + String get dailyIntake => localizedValues["dailyIntake"][locale.languageCode]; + String get calculateAmount => localizedValues["calculateAmount"][locale.languageCode]; + String get bodyWillBurn => localizedValues["bodyWillBurn"][locale.languageCode]; + String get caloriesEachDay => localizedValues["caloriesEachDay"][locale.languageCode]; + String get maintainWeight => localizedValues["maintainWeight"][locale.languageCode]; + + String get mediumFinger => localizedValues["mediumFinger"][locale.languageCode]; + String get smallFinger => localizedValues["smallFinger"][locale.languageCode]; + String get largeFinger => localizedValues["largeFinger"][locale.languageCode]; + String get idealBodyWeight => localizedValues["idealBodyWeight"][locale.languageCode]; + String get bodyFrameSize => localizedValues["bodyFrameSize"][locale.languageCode]; + + String get idealWeightRange => localizedValues["idealWeightRange"][locale.languageCode]; + String get currentWeightPerfect => localizedValues["currentWeightPerfect"][locale.languageCode]; + String get littleBitWeightMore => localizedValues["littleBitWeightMore"][locale.languageCode]; + String get consultWithDoctor => localizedValues["consultWithDoctor"][locale.languageCode]; + String get excessiveObesity => localizedValues["excessiveObesity"][locale.languageCode]; + String get mayWish => localizedValues["mayWish"][locale.languageCode]; + + String get essential => localizedValues["essential"][locale.languageCode]; + String get athlete => localizedValues["athlete"][locale.languageCode]; + String get fitness => localizedValues["fitness"][locale.languageCode]; + String get acceptable => localizedValues["acceptable"][locale.languageCode]; + String get underObese => localizedValues["underObese"][locale.languageCode]; + String get crossedLimits => localizedValues["crossedLimits"][locale.languageCode]; + String get lowLimits => localizedValues["lowLimits"][locale.languageCode]; + String get estimates => localizedValues["estimates"][locale.languageCode]; + + + + } class TranslationBaseDelegate extends LocalizationsDelegate { From 590b7953566af1c08bbc1ad79f0ded341104e823 Mon Sep 17 00:00:00 2001 From: devmirza121 Date: Tue, 9 Nov 2021 16:38:14 +0300 Subject: [PATCH 37/70] Health Calculator 4.0 marge --- lib/config/localized_values.dart | 6 ++---- lib/uitl/translations_delegate_base.dart | 5 +---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 84ed8f54..4a8ee340 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1690,10 +1690,7 @@ const Map localizedValues = { "bodyFrameMedium": {"en": "Medium (fingers touch)", "ar": "متوسط (الأصابع تتلامس)"}, "bodyFrameLarge": {"en": "Large (fingers don't touch)", "ar": "عريض (الأصابع لا تتلامس)"}, "bodyFatDesc": {"en": "Estimates the total body fat based on the size", "ar": "حساب الدهون في الجسم بناءاً على الحجم"}, - "essential":{"en":"The category falls under Essential Fat.","ar":"تندرج تحت فئة دهون أساسية"}, - "athlete":{"en":" The category falls under Athlete.","ar":"تندرج تحت فئة دهون جسم رياضي"}, - "fitness":{"en":" The category falls under Fitness.","ar":"تندرج تحت فئة دهون جسم صحي"}, - "acceptable":{"en":"The category falls under Acceptable","ar":"تندرج تحت فئة دهون مقبولة"}, + "obeseBodyFat":{"en":"The category falls under Obese.","ar":"تندرج تحت فئة دهون جسم سمين"}, "invalid":{"en":"Invalid input for calculation.","ar":"البيانات المدخلة غير صالحة للحساب"}, "more":{"en":"Please check the value you have entered, since the body fat percentage has crossed the limits.","ar":"يرجى التحقق من القيمة التي أدخلتها ، نظرًا لأن نسبة الدهون في الجسم قد تجاوزت الحدود"}, @@ -1707,4 +1704,5 @@ const Map localizedValues = { "dietModerate":{"en":"Moderate Carb","ar":"حمية معتدلة الكربوهيدرات"}, "dietUSDA":{"en":"USDA Guidelines","ar":"ارشادات وزارة الزراعة الأمريكية"}, "dietZone":{"en":"Zone Diet","ar":"حمية زون"}, + }; diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 7b1a3071..80425967 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2721,14 +2721,11 @@ class TranslationBase { String get excessiveObesity => localizedValues["excessiveObesity"][locale.languageCode]; String get mayWish => localizedValues["mayWish"][locale.languageCode]; - String get essential => localizedValues["essential"][locale.languageCode]; - String get athlete => localizedValues["athlete"][locale.languageCode]; - String get fitness => localizedValues["fitness"][locale.languageCode]; - String get acceptable => localizedValues["acceptable"][locale.languageCode]; String get underObese => localizedValues["underObese"][locale.languageCode]; String get crossedLimits => localizedValues["crossedLimits"][locale.languageCode]; String get lowLimits => localizedValues["lowLimits"][locale.languageCode]; String get estimates => localizedValues["estimates"][locale.languageCode]; + String get submitReview => localizedValues["submitReview"][locale.languageCode]; From 14b85cc407081bda4bb91cca14dc1590983c9190 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 9 Nov 2021 17:21:58 +0300 Subject: [PATCH 38/70] Family files API changes --- .../send_activation_request.dart | 11 +- .../DrawerPages/family/add-family-member.dart | 170 +++--- .../DrawerPages/family/add-family_type.dart | 6 +- lib/pages/DrawerPages/family/my-family.dart | 498 ++++++++---------- .../family_files/family_files_provider.dart | 10 +- 5 files changed, 319 insertions(+), 376 deletions(-) diff --git a/lib/models/Authentication/send_activation_request.dart b/lib/models/Authentication/send_activation_request.dart index e9512102..867d2d95 100644 --- a/lib/models/Authentication/send_activation_request.dart +++ b/lib/models/Authentication/send_activation_request.dart @@ -25,6 +25,9 @@ class SendActivationRequest { String dob; int isHijri; String healthId; + int responseID; + int status; + SendActivationRequest( {this.patientMobileNumber, this.mobileNo, @@ -51,7 +54,9 @@ class SendActivationRequest { this.sMSSignature, this.dob, this.isHijri, - this.healthId}); + this.healthId, + this.responseID, + this.status}); SendActivationRequest.fromJson(Map json) { patientMobileNumber = json['PatientMobileNumber']; @@ -80,6 +85,8 @@ class SendActivationRequest { dob = json['DOB']; isHijri = json['IsHijri']; healthId = json['HealthId']; + responseID = json['ReponseID']; + status = json['Status']; } Map toJson() { @@ -110,6 +117,8 @@ class SendActivationRequest { data['DOB'] = dob; data['IsHijri'] = isHijri; data['HealthId'] = healthId; + data['ResponseID'] = responseID; + data['Status'] = status; return data; } } diff --git a/lib/pages/DrawerPages/family/add-family-member.dart b/lib/pages/DrawerPages/family/add-family-member.dart index 9fb20630..6d9064d7 100644 --- a/lib/pages/DrawerPages/family/add-family-member.dart +++ b/lib/pages/DrawerPages/family/add-family-member.dart @@ -1,7 +1,6 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/model/family-file/add_family_file_request.dart'; -import 'package:diplomaticquarterapp/core/model/family-file/insert_share_file_request.dart'; import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/services/family_files/family_files_provider.dart'; @@ -17,7 +16,6 @@ import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/otp/sms-popup.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; -import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -41,6 +39,7 @@ class _AddMember extends State { var familyFileProvider = FamilyFilesProvider(); var patientShareRequestID; + var patientShareResponseID; @override void initState() { @@ -50,67 +49,71 @@ class _AddMember extends State { @override Widget build(BuildContext context) { return AppScaffold( - appBarTitle: TranslationBase.of(context).myFamilyFiles, - isShowAppBar: true, - showNewAppBar: true, - showNewAppBarTitle: true, - body: isLoading == true - ? AppCircularProgressIndicator() - : SingleChildScrollView( - child: Container( - padding: EdgeInsets.only(top: 10, left: 20, right: 20, bottom: 30), + appBarTitle: TranslationBase.of(context).myFamilyFiles, + isShowAppBar: true, + showNewAppBar: true, + showNewAppBarTitle: true, + body: isLoading == true + ? AppCircularProgressIndicator() + : SingleChildScrollView( + child: Container( + padding: EdgeInsets.all(21.0), height: SizeConfig.realScreenHeight * .9, width: SizeConfig.realScreenWidth, - child: Column(children: [ - Expanded( - flex: 2, - child: AppText( - TranslationBase.of(context).enterNationalId, - fontSize: SizeConfig.textMultiplier * 3.5, - textAlign: TextAlign.left, - )), - Expanded( - flex: 4, - child: Column( - // mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - PhoneNumberSelectorWidget(onNumberChange: (value) => {mobileNo = value, validateForm()}, onCountryChange: (value) => countryCode = value), - //MobileNo(onNumberChange: (value) => {mobileNo = value, validateForm()}, onCountryChange: (value) => countryCode = value), - // Container( - // child: TextFields( - // controller: nationalIDorFile, - // onChanged: (value) => {validateForm()}, - // prefixIcon: Icon(loginType == 1 ? Icons.chrome_reader_mode : Icons.receipt, color: Colors.red), - // padding: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), - // hintText: loginType == 1 ? TranslationBase.of(context).nationalID : TranslationBase.of(context).fileNo, - // )) - SizedBox( - height: 12, - ), - inputWidget(loginType == 1 ? TranslationBase.of(context).nationalIdNumber : TranslationBase.of(context).medicalFileNumber, "Xxxxxxxxx", nationalIDorFile), - ], - ), - ), - Expanded( - flex: 3, + child: Column( + children: [ + Expanded( + flex: 1, + child: Text( + loginType == 1 ? TranslationBase.of(context).enterNationalId : TranslationBase.of(context).enterFile, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16), + )), + Expanded( + flex: 4, child: Column( - mainAxisAlignment: MainAxisAlignment.end, children: [ - Row( - children: [ - Expanded( - child: DefaultButton( - TranslationBase.of(context).add, - () => {this.addMember()}, - color: isButtonDisabled == true ? Colors.grey : CustomColors.accentColor, - textColor: Colors.white, - )) - ], + PhoneNumberSelectorWidget(onNumberChange: (value) => {mobileNo = value, validateForm()}, onCountryChange: (value) => countryCode = value), + SizedBox( + height: 12, ), + inputWidget(loginType == 1 ? TranslationBase.of(context).nationalIdNumber : TranslationBase.of(context).medicalFileNumber, "Xxxxxxxxx", nationalIDorFile), ], - )) - ]), - ))); + ), + ), + // Expanded( + // flex: 3, + // child: Column( + // mainAxisAlignment: MainAxisAlignment.end, + // children: [ + // Row( + // children: [ + // Expanded( + // child: DefaultButton( + // TranslationBase.of(context).add, + // () => {this.addMember()}, + // color: isButtonDisabled == true ? Colors.grey : CustomColors.accentColor, + // textColor: Colors.white, + // ), + // ) + // ], + // ), + // ], + // ), + // ) + ], + ), + ), + ), + bottomSheet: Container( + color: Colors.white, + padding: EdgeInsets.all(21.0), + child: DefaultButton( + TranslationBase.of(context).add, + () => {this.addMember()}, + color: isButtonDisabled == true ? Colors.grey : CustomColors.accentColor, + textColor: Colors.white, + )), + ); } void validateForm() { @@ -158,31 +161,30 @@ class _AddMember extends State { } insertFamilyData(addMemberResult) { - var request = InsertSharePatientFileReq(); - request.responseID = addMemberResult['ShareFamilyFileObj']['ReponseID']; - request.shareFamilyPatientName = addMemberResult['ShareFamilyFileObj']['SharedPatientName']; - request.status = 2; - if (request.patientOutSA == 1) { - request.regionID = 2; - } else { - request.regionID = 1; - } - loading(true); - familyFileProvider.insertNewMember(request).then((value) => sendActivationCode(value)).catchError((err){ - loading(false); - AppToast.showErrorToast(message: err); - }); + sendActivationCode(addMemberResult); + // var request = InsertSharePatientFileReq(); + // request.responseID = addMemberResult['ShareFamilyFileObj']['ReponseID']; + // request.shareFamilyPatientName = addMemberResult['ShareFamilyFileObj']['SharedPatientName']; + // request.status = 2; + // if (request.patientOutSA == 1) { + // request.regionID = 2; + // } else { + // request.regionID = 1; + // } + // loading(true); + // familyFileProvider.insertNewMember(request).then((value) => sendActivationCode(value)).catchError((err) { + // loading(false); + // AppToast.showErrorToast(message: err); + // }); } sendActivationCode(result) { // var request = this.getCommonRequest(); loading(true); - patientShareRequestID = result['PatientShareRequestID']; - familyFileProvider.sendActivationCode(mobileNo, countryCode, nationalIDorFile.text).then((result) => { - if (result != null && result['isSMSSent'] == true) {this.startSMSService(1, result)} - // {loading(false), this.startSMSService(type)} - // else - // {loading(false)} + patientShareResponseID = result['ShareFamilyFileObj']['ReponseID']; + familyFileProvider.sendActivationCode(mobileNo, countryCode, nationalIDorFile.text, patientShareResponseID).then((res) => { + patientShareRequestID = res['PatientShareRequestID'], + if (res != null && res['isSMSSent'] == true) {this.startSMSService(1, res)} }); } @@ -207,7 +209,7 @@ class _AddMember extends State { checkActivationCode(value, result) { Navigator.pop(context); GifLoaderDialogUtils.showMyDialog(context); - familyFileProvider.checkActivationCode(result['LogInTokenID'], value, nationalIDorFile.text, mobileNo).then((result) { + familyFileProvider.checkActivationCode(result['LogInTokenID'], value, nationalIDorFile.text, mobileNo, patientShareRequestID, patientShareResponseID).then((result) { SMSOTP.hideSMSBox(context); handleFamilyRequests(this.patientShareRequestID, 3); }).catchError((err) { @@ -219,12 +221,12 @@ class _AddMember extends State { } handleFamilyRequests(id, stauts) { - familyFileProvider.acceptAndRejectRecievedRequests(id, stauts).then((result) => { - sharedPref.remove(FAMILY_FILE), - Navigator.of(context).pushNamed( - MY_FAMILIY, - ) - }); + // familyFileProvider.acceptAndRejectRecievedRequests(id, stauts).then((result) => { + sharedPref.remove(FAMILY_FILE); + Navigator.of(context).pushNamed( + MY_FAMILIY, + ); + // }); } loading(flag) { diff --git a/lib/pages/DrawerPages/family/add-family_type.dart b/lib/pages/DrawerPages/family/add-family_type.dart index 533669c7..60e396c6 100644 --- a/lib/pages/DrawerPages/family/add-family_type.dart +++ b/lib/pages/DrawerPages/family/add-family_type.dart @@ -26,11 +26,11 @@ class AddFamilyMemberType extends StatelessWidget { padding: EdgeInsets.zero, physics: BouncingScrollPhysics(), children: [ - SizedBox(height: 12), + SizedBox(height: 21), HabibLogoWidget(), - SizedBox(height: 50), + SizedBox(height: 21), Text( - TranslationBase.of(context).logintypeRadio, + TranslationBase.of(context).registerInfoFamily, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16), ), GridView( diff --git a/lib/pages/DrawerPages/family/my-family.dart b/lib/pages/DrawerPages/family/my-family.dart index 1d2b470b..f3658fae 100644 --- a/lib/pages/DrawerPages/family/my-family.dart +++ b/lib/pages/DrawerPages/family/my-family.dart @@ -27,7 +27,6 @@ import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/ConfirmWithMessageDialog.dart'; -import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; @@ -159,113 +158,115 @@ class _MyFamily extends State with TickerProviderStateMixin { if (snapshot.hasError) return Padding(padding: EdgeInsets.all(10), child: Text(TranslationBase.of(context).noDataAvailable)); else - return ListView.separated( - itemBuilder: (context, index) { - if (snapshot.data.getAllSharedRecordsByStatusList[index].status == 3) - return Container( - margin: EdgeInsets.all(5), - decoration: cardRadius( - 15, - elevation: 0, - color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0xffFDA4B0) : Color(0xff6EA8FF), - ), - child: Container( - // height: 130,0xffFDA4B0 - width: MediaQuery.of(context).size.width, - padding: EdgeInsets.all(10), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - snapshot.data.getAllSharedRecordsByStatusList[index].patientName.toLowerCase().capitalizeFirstofEach, - fontSize: 18, - fontWeight: FontWeight.bold, - color: Colors.white, - ), - Texts(TranslationBase.of(context).fileNumber + ': ' + snapshot.data.getAllSharedRecordsByStatusList[index].responseID.toString(), - fontSize: 12, color: Colors.white), - Texts( - snapshot.data.getAllSharedRecordsByStatusList[index].age.toString() + - ' ' + - TranslationBase.of(context).years + - ', ' + - snapshot.data.getAllSharedRecordsByStatusList[index].genderDescription, - fontSize: 12, - color: Colors.white), - ], - ), - Column( + return checkActive(snapshot.data.getAllSharedRecordsByStatusList) > 0 + ? ListView.separated( + itemBuilder: (context, index) { + if (snapshot.data.getAllSharedRecordsByStatusList[index].status == 3) + return Container( + margin: EdgeInsets.all(5), + decoration: cardRadius( + 15, + elevation: 0, + color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0xffFDA4B0) : Color(0xff6EA8FF), + ), + child: Container( + // height: 130,0xffFDA4B0 + width: MediaQuery.of(context).size.width, + padding: EdgeInsets.all(10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - SizedBox(height: 10), - InkWell( - onTap: () { - switchUser(snapshot.data.getAllSharedRecordsByStatusList[index], context); - }, - child: Container( - decoration: BoxDecoration(color: Colors.black.withOpacity(0.1), borderRadius: BorderRadius.circular(20)), - padding: EdgeInsets.fromLTRB(15, 10, 15, 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SvgPicture.asset("assets/images/new-design/switch.svg", - height: 22, color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0Xff5A282E) : Colors.white), - SizedBox( - width: 5, - ), - // CupertinoSwitch( - // value: isSwitchUser, - // onChanged: (value) { - // setState(() { - // isSwitchUser = value; - // }); - // if (isSwitchUser == true) switchUser(snapshot.data.getAllSharedRecordsByStatusList[index], context); - // }, - // ), - Texts(TranslationBase.of(context).switchUser, - color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0Xff5A282E) : Colors.white, - fontSize: 12, - fontWeight: FontWeight.w600) - ], - ))), - SizedBox( - height: 10, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + snapshot.data.getAllSharedRecordsByStatusList[index].patientName.toLowerCase().capitalizeFirstofEach, + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + Texts(TranslationBase.of(context).fileNumber + ': ' + snapshot.data.getAllSharedRecordsByStatusList[index].responseID.toString(), + fontSize: 12, color: Colors.white), + Texts( + snapshot.data.getAllSharedRecordsByStatusList[index].age.toString() + + ' ' + + TranslationBase.of(context).years + + ', ' + + snapshot.data.getAllSharedRecordsByStatusList[index].genderDescription, + fontSize: 12, + color: Colors.white), + ], + ), + Column( + children: [ + SizedBox(height: 10), + InkWell( + onTap: () { + switchUser(snapshot.data.getAllSharedRecordsByStatusList[index], context); + }, + child: Container( + decoration: BoxDecoration(color: Colors.black.withOpacity(0.1), borderRadius: BorderRadius.circular(20)), + padding: EdgeInsets.fromLTRB(15, 10, 15, 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SvgPicture.asset("assets/images/new-design/switch.svg", + height: 22, color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0Xff5A282E) : Colors.white), + SizedBox( + width: 5, + ), + // CupertinoSwitch( + // value: isSwitchUser, + // onChanged: (value) { + // setState(() { + // isSwitchUser = value; + // }); + // if (isSwitchUser == true) switchUser(snapshot.data.getAllSharedRecordsByStatusList[index], context); + // }, + // ), + Texts(TranslationBase.of(context).switchUser, + color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0Xff5A282E) : Colors.white, + fontSize: 12, + fontWeight: FontWeight.w600) + ], + ))), + SizedBox( + height: 10, + ), + InkWell( + onTap: () { + deleteFamily(snapshot.data.getAllSharedRecordsByStatusList[index], context); + }, + child: Container( + decoration: BoxDecoration(color: Colors.black.withOpacity(0.1), borderRadius: BorderRadius.circular(20)), + padding: EdgeInsets.fromLTRB(15, 10, 15, 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SvgPicture.asset("assets/images/new-design/delete.svg", + height: 22, color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0Xff5A282E) : Colors.white), + SizedBox( + width: 5, + ), + Texts(TranslationBase.of(context).delete, + color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0Xff5A282E) : Colors.white, + fontSize: 12, + fontWeight: FontWeight.w600), + ], + ))), + SizedBox(height: 10), + ], ), - InkWell( - onTap: () { - deleteFamily(snapshot.data.getAllSharedRecordsByStatusList[index], context); - }, - child: Container( - decoration: BoxDecoration(color: Colors.black.withOpacity(0.1), borderRadius: BorderRadius.circular(20)), - padding: EdgeInsets.fromLTRB(15, 10, 15, 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SvgPicture.asset("assets/images/new-design/delete.svg", - height: 22, color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0Xff5A282E) : Colors.white), - SizedBox( - width: 5, - ), - Texts(TranslationBase.of(context).delete, - color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0Xff5A282E) : Colors.white, - fontSize: 12, - fontWeight: FontWeight.w600), - ], - ))), - SizedBox(height: 10), ], - ), - ], - ))); - else if (checkActive(snapshot.data.getAllSharedRecordsByStatusList) == 0) - return getNoDataWidget(context); - else - return SizedBox(height: 0); - }, - separatorBuilder: (context, index) => SizedBox(height: 0), - itemCount: snapshot.data.getAllSharedRecordsByStatusList.length); + ))); + // else if (checkActive(snapshot.data.getAllSharedRecordsByStatusList) == 0) + // return getNoDataWidget(context); + else + return SizedBox(height: 0); + }, + separatorBuilder: (context, index) => SizedBox(height: 0), + itemCount: snapshot.data.getAllSharedRecordsByStatusList.length) + : getNoDataWidget(context); } }, ), @@ -290,176 +291,98 @@ class _MyFamily extends State with TickerProviderStateMixin { child: Column( children: [ FractionallySizedBox( - widthFactor: 1.0, - child: AppExpandableNotifier( - title: TranslationBase.of(context).userViewRequest, - bodyWidget: FutureBuilder( - future: getUserViewRequest(), // async work - builder: (BuildContext context, AsyncSnapshot snapshot) { - switch (snapshot.connectionState) { - case ConnectionState.waiting: - return SizedBox(); + widthFactor: 1.0, + child: AppExpandableNotifier( + title: TranslationBase.of(context).userViewRequest, + bodyWidget: FutureBuilder( + future: getUserViewRequest(), // async work + builder: (BuildContext context, AsyncSnapshot snapshot) { + switch (snapshot.connectionState) { + case ConnectionState.waiting: + return SizedBox(); - default: - if (snapshot.hasError) - return Padding(padding: EdgeInsets.all(10), child: Text(TranslationBase.of(context).noDataAvailable)); - else - return ListView.separated( - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - padding: EdgeInsets.only(bottom: 14, top: 14, left: 21, right: 21), - itemBuilder: (context, _index) { - return Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(10.0), - ), - border: Border.all(width: 1, color: Color(0xffEFEFEF)), - boxShadow: [ - BoxShadow( - color: Color(0xff000000).withOpacity(.05), - //spreadRadius: 5, - blurRadius: 27, - offset: Offset(0, -3), - ), - ], - color: Colors.white), - child: Column( - children: [ - Column(children: [ - Padding( - padding: EdgeInsets.all(10), - child: Row(children: [ - Expanded(flex: 3, child: AppText(TranslationBase.of(context).name, fontWeight: FontWeight.w600)), - Expanded(flex: 1, child: AppText(TranslationBase.of(context).allow, fontWeight: FontWeight.w600)), - Expanded(flex: 1, child: AppText(TranslationBase.of(context).reject, fontWeight: FontWeight.w600)), - ])), - Padding( - padding: const EdgeInsets.only(left: 10.0, right: 10.0), - child: Divider(color: Colors.black, height: 1.5, thickness: 1.5), - ), - Column( - children: familyFileProvider.allSharedRecordsByStatusResponse.getAllSharedRecordsByStatusList.map((result) { - return Container( - padding: EdgeInsets.all(10), - child: Row( - children: [ - Expanded( - flex: 3, - child: Texts( - result.patientName, - fontWeight: FontWeight.w600, - fontSize: 12, - )), - Expanded( - flex: 1, - child: IconButton( - icon: SvgPicture.asset("assets/images/new-design/allow.svg", height: 22), - onPressed: () { - acceptRemoveRequest(result.iD, 3, context); - }, - )), - Expanded( - flex: 1, - child: IconButton( - icon: SvgPicture.asset("assets/images/new-design/reject.svg", height: 22), - color: Colors.white, - onPressed: () { - acceptRemoveRequest(result.iD, 4, context); - }, - )) - ], - )); - }).toList()) - ]) - ], - )); - }, - separatorBuilder: (context, index) => SizedBox(height: 14), - itemCount: 1); - } - }, - ))), - - // RoundedContainer( - // child: ExpansionTile( - // title: Text( - // TranslationBase.of(context).userViewRequest, - // style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, color: Colors.black), - // ), - // children: [ - // FutureBuilder( - // future: getUserViewRequest(), // async work - // builder: (BuildContext context, AsyncSnapshot snapshot) { - // switch (snapshot.connectionState) { - // case ConnectionState.waiting: - // return Padding(padding: EdgeInsets.only(top: 50), child: Text('Loading....')); - // default: - // if (snapshot.hasError) - // return Padding(padding: EdgeInsets.all(10), child: Text(TranslationBase.of(context).noDataAvailable)); - // else - // return Container( - // padding: EdgeInsets.all(15), - // child: Card( - // elevation: 3, - // shape: cardRadius(8), - // child: Column( - // children: [ - // Column(children: [ - // Padding( - // padding: EdgeInsets.all(10), - // child: Row(children: [ - // Expanded(flex: 3, child: AppText(TranslationBase.of(context).name, fontWeight: FontWeight.w600)), - // Expanded(flex: 1, child: AppText(TranslationBase.of(context).allow, fontWeight: FontWeight.w600)), - // Expanded(flex: 1, child: AppText(TranslationBase.of(context).reject, fontWeight: FontWeight.w600)), - // ])), - // Divider(color: Colors.black, height: 1.5, thickness: 1.5), - // Column( - // children: familyFileProvider.allSharedRecordsByStatusResponse.getAllSharedRecordsByStatusList.map((result) { - // return Container( - // padding: EdgeInsets.all(10), - // child: Row( - // children: [ - // Expanded( - // flex: 3, - // child: Texts( - // result.patientName, - // fontWeight: FontWeight.w600, - // fontSize: 12, - // )), - // Expanded( - // flex: 1, - // child: IconButton( - // icon: Icon( - // Icons.check_circle, - // color: Color(0xff349745), - // ), - // onPressed: () { - // acceptRemoveRequest(result.iD, 3, context); - // }, - // )), - // Expanded( - // flex: 1, - // child: IconButton( - // icon: Icon( - // Icons.close, - // color: Colors.red[900], - // ), - // onPressed: () { - // acceptRemoveRequest(result.iD, 4, context); - // }, - // )) - // ], - // )); - // }).toList()) - // ]) - // ], - // ))); - // } - // }) - // ], - // ), - // ), + default: + if (snapshot.hasError) + return Padding(padding: EdgeInsets.all(10), child: Text(TranslationBase.of(context).noDataAvailable)); + else + return ListView.separated( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + padding: EdgeInsets.only(bottom: 14, top: 14, left: 21, right: 21), + itemBuilder: (context, _index) { + return Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(10.0), + ), + border: Border.all(width: 1, color: Color(0xffEFEFEF)), + boxShadow: [ + BoxShadow( + color: Color(0xff000000).withOpacity(.05), + //spreadRadius: 5, + blurRadius: 27, + offset: Offset(0, -3), + ), + ], + color: Colors.white), + child: Column( + children: [ + Column(children: [ + Padding( + padding: EdgeInsets.all(10), + child: Row(children: [ + Expanded(flex: 3, child: AppText(TranslationBase.of(context).name, fontWeight: FontWeight.w600)), + Expanded(flex: 1, child: AppText(TranslationBase.of(context).allow, fontWeight: FontWeight.w600)), + Expanded(flex: 1, child: AppText(TranslationBase.of(context).reject, fontWeight: FontWeight.w600)), + ])), + Padding( + padding: const EdgeInsets.only(left: 10.0, right: 10.0), + child: Divider(color: Colors.black, height: 1.5, thickness: 1.5), + ), + Column( + children: familyFileProvider.allSharedRecordsByStatusResponse.getAllSharedRecordsByStatusList.map((result) { + return Container( + padding: EdgeInsets.all(10), + child: Row( + children: [ + Expanded( + flex: 3, + child: Texts( + result.patientName, + fontWeight: FontWeight.w600, + fontSize: 12, + )), + Expanded( + flex: 1, + child: IconButton( + icon: SvgPicture.asset("assets/images/new-design/allow.svg", height: 22), + onPressed: () { + acceptRemoveRequest(result.iD, 3, context); + }, + )), + Expanded( + flex: 1, + child: IconButton( + icon: SvgPicture.asset("assets/images/new-design/reject.svg", height: 22), + color: Colors.white, + onPressed: () { + acceptRemoveRequest(result.iD, 4, context); + }, + )) + ], + )); + }).toList()) + ]) + ], + )); + }, + separatorBuilder: (context, index) => SizedBox(height: 14), + itemCount: 1); + } + }, + ), + ), + ), SizedBox(height: 15), FractionallySizedBox( widthFactor: 1.0, @@ -521,18 +444,21 @@ class _MyFamily extends State with TickerProviderStateMixin { fontSize: 12, )), Expanded( - flex: 1, - child: Card( - // shape: cardRadius(10), - color: result.status == 3 ? Color(0xff349745) : Color(0xffD02127), - child: Padding( - padding: EdgeInsets.all(5), - child: AppText( - result.statusDescription, - color: Colors.white, - textAlign: TextAlign.center, - fontSize: 12, - )))), + flex: 1, + child: Card( + // shape: cardRadius(10), + color: result.status == 3 ? Color(0xff349745) : Color(0xffD02127), + child: Padding( + padding: EdgeInsets.all(5), + child: AppText( + result.statusDescription != null ? result.statusDescription : "", + color: Colors.white, + textAlign: TextAlign.center, + fontSize: 12, + ), + ), + ), + ), ], )); }).toList(), diff --git a/lib/services/family_files/family_files_provider.dart b/lib/services/family_files/family_files_provider.dart index ef7ad14d..cc151c7b 100644 --- a/lib/services/family_files/family_files_provider.dart +++ b/lib/services/family_files/family_files_provider.dart @@ -140,7 +140,7 @@ class FamilyFilesProvider with ChangeNotifier { } } - Future sendActivationCode(cellNumber, zipCode, patientIdentificationID) async { + Future sendActivationCode(cellNumber, zipCode, patientIdentificationID, responseID) async { try { dynamic localRes; var request = SendActivationRequest(); @@ -151,6 +151,8 @@ class FamilyFilesProvider with ChangeNotifier { request.loginType = request.searchType = 1; request.oTPSendType = 1; request.isRegister = false; + request.responseID = responseID; + request.status = 2; await new BaseAppClient().post(SEND_FAMILY_FILE_ACTIVATION, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { @@ -166,7 +168,7 @@ class FamilyFilesProvider with ChangeNotifier { } //TODO - Future checkActivationCode(loginTokenID, activationCode, indentification, mobileNo) async { + Future checkActivationCode(loginTokenID, activationCode, indentification, mobileNo, requestID, responseID) async { try { dynamic localRes; Map request = {}; @@ -175,6 +177,10 @@ class FamilyFilesProvider with ChangeNotifier { request['PatientIdentificationID'] = indentification; request['LogInTokenID'] = loginTokenID; request['activationCode'] = activationCode; + request['PatientShareRequestID'] = requestID; + request['ResponseID'] = responseID; + request['Status'] = 3; + // this.authService.authenticateRequest(request); await new BaseAppClient().post(CHECK_ACTIVATION_CODE, onSuccess: (dynamic response, int statusCode) { localRes = response; From 338c646a438424a850ab1783807c88e1ab6a4217 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 9 Nov 2021 17:32:30 +0300 Subject: [PATCH 39/70] updates --- .../health_calculator/body_fat/body_fat.dart | 100 ++++++++---------- lib/uitl/translations_delegate_base.dart | 28 ++++- 2 files changed, 69 insertions(+), 59 deletions(-) diff --git a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart index 5cdd8e3b..6aab447a 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart @@ -4,7 +4,6 @@ import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.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'; @@ -23,7 +22,6 @@ class BodyFat extends StatefulWidget { } class _BodyFatState extends State { - final GlobalKey clinicDropdownKey = GlobalKey(); bool _isHeightCM = true; bool _isNeckKG = true; @@ -34,7 +32,6 @@ class _BodyFatState extends State { double _waistValue = 0; double _hipValue = 0; - TextEditingController _heightController = new TextEditingController(); TextEditingController _neckController = TextEditingController(); TextEditingController _waistController = TextEditingController(); @@ -45,12 +42,12 @@ class _BodyFatState extends State { List _waistPopupList = List(); List _hipPopupList = List(); - - bool isMale = false; + // bool isHeightCm = true; Color maleCard = activeCardColorGender; Color femaleCard = inactiveCardColorGender; + // Color neckCmCard = activeCardColor; // Color neckFtCard = inactiveCardColor; Color waistCmCard = activeCardColor; @@ -59,6 +56,7 @@ class _BodyFatState extends State { Color hipFtCard = inactiveCardColor; Color cmCard = activeCardColor; Color ftCard = inactiveCardColor; + // int neck = 10; // int heightCm = 0; // int heightFt = 0; @@ -67,6 +65,7 @@ class _BodyFatState extends State { double minRange; double maxRange; double overWeightBy; + // int waist = 5; double bodyFat = 0; double fat = 0; @@ -74,8 +73,6 @@ class _BodyFatState extends State { double calories = 0; String textResult = ''; - - @override void initState() { _neckController.text = _neckValue.toString(); @@ -105,8 +102,6 @@ class _BodyFatState extends State { } } - - void updateColorWaist(int type) { //MG/DLT card if (type == 1) { @@ -187,29 +182,29 @@ class _BodyFatState extends State { } else if (bodyFat > 13 && bodyFat <= 20) { textResult = TranslationBase.of(context).athlete; } else if (bodyFat > 20 && bodyFat <= 24) { - textResult =TranslationBase.of(context).fitness; + textResult = TranslationBase.of(context).fitness; } else if (bodyFat > 24 && bodyFat <= 31) { - textResult =TranslationBase.of(context).acceptable; + textResult = TranslationBase.of(context).acceptable; } else if (bodyFat > 31 && bodyFat <= 60) { - textResult =TranslationBase.of(context).underObese; + textResult = TranslationBase.of(context).underObese; } else if (bodyFat > 60) { - textResult =TranslationBase.of(context).crossedLimits; + textResult = TranslationBase.of(context).crossedLimits; } else if (bodyFat <= 9) { - textResult =TranslationBase.of(context).lowLimits; + textResult = TranslationBase.of(context).lowLimits; } } else { if (bodyFat > 5 && fat <= 13) { - textResult = 'The category falls under essential'; + textResult = TranslationBase.of(context).essential; } else if (bodyFat > 13 && bodyFat <= 17) { - textResult = 'The category falls under athlete'; + textResult = TranslationBase.of(context).athlete; } else if (bodyFat > 17 && bodyFat <= 24) { - textResult = 'The category falls under fitness'; + textResult = TranslationBase.of(context).fitness; } else if (bodyFat > 24 && bodyFat <= 45) { - textResult = 'The category falls under obese'; + textResult = TranslationBase.of(context).underObese; } else if (bodyFat > 45) { - textResult = 'Please check the value you have entered, since the body fat percentage has crosed the limits.'; + textResult = TranslationBase.of(context).crossedLimits; } else if (bodyFat <= 5) { - textResult = 'Please check the value you have entered, since the body fat percentage cannot be this low.'; + textResult = TranslationBase.of(context).lowLimits; } } } @@ -242,12 +237,12 @@ class _BodyFatState extends State { Expanded( child: SingleChildScrollView( child: Container( - padding: EdgeInsets.all(20), + padding: EdgeInsets.all(20), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Estimates the total body fat based on\nthe size', + TranslationBase.of(context).bodyFatDesc, style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, @@ -354,14 +349,14 @@ class _BodyFatState extends State { 1, 270, _heightValue, - (text) { + (text) { _heightController.text = text; }, - (value) { + (value) { _heightValue = value; }, _isHeightCM ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, - (value) { + (value) { if (_isHeightCM != value) { setState(() { _isHeightCM = value; @@ -379,14 +374,14 @@ class _BodyFatState extends State { 1, 270, _neckValue, - (text) { - _neckController.text = text; + (text) { + _neckController.text = text; }, - (value) { - _neckValue = value; + (value) { + _neckValue = value; }, _isNeckKG ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, - (value) { + (value) { if (_isNeckKG != value) { setState(() { _isNeckKG = value; @@ -395,7 +390,6 @@ class _BodyFatState extends State { }, _neckPopupList, ), - SizedBox( height: 12.0, ), @@ -405,14 +399,14 @@ class _BodyFatState extends State { 1, 270, _waistValue, - (text) { - _waistController.text = text; + (text) { + _waistController.text = text; }, - (value) { + (value) { _waistValue = value; }, _isWaistKG ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, - (value) { + (value) { if (_isWaistKG != value) { setState(() { _isWaistKG = value; @@ -430,14 +424,14 @@ class _BodyFatState extends State { 1, 270, _hipValue, - (text) { + (text) { _hipController.text = text; }, - (value) { + (value) { _hipValue = value; }, _isHipKG ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, - (value) { + (value) { if (_isHipKG != value) { setState(() { _isHipKG = value; @@ -446,7 +440,6 @@ class _BodyFatState extends State { }, _hipPopupList, ), - SizedBox( height: 12.0, ), @@ -471,10 +464,10 @@ class _BodyFatState extends State { context, FadePage( page: FatResult( - bodyFat: bodyFat, - fat: fat, - textResult: textResult, - )), + bodyFat: bodyFat, + fat: fat, + textResult: textResult, + )), ); } }); @@ -485,6 +478,7 @@ class _BodyFatState extends State { ), ); } + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) { return Container( padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), @@ -542,15 +536,15 @@ class _BodyFatState extends State { prefixIcon: prefix == null ? null : Text( - "+" + prefix, - style: TextStyle( - fontSize: 14, - height: 21 / 14, - fontWeight: FontWeight.w500, - color: Color(0xff2E303A), - letterSpacing: -0.56, - ), - ), + "+" + prefix, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, + ), + ), contentPadding: EdgeInsets.zero, border: InputBorder.none, focusedBorder: InputBorder.none, @@ -691,5 +685,3 @@ class CommonDropDownView extends StatelessWidget { ); } } - - diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 80425967..d1bc500d 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2692,44 +2692,62 @@ class TranslationBase { String get dietZone => localizedValues["dietZone"][locale.languageCode]; String get useFullInfo => localizedValues["usefulInfo"][locale.languageCode]; + String get babyAge => localizedValues["babyAge"][locale.languageCode]; + String get babyAgeAvail => localizedValues["babyAgeAvail"][locale.languageCode]; + String get deliveryDue => localizedValues["deliveryDue"][locale.languageCode]; String get almostInactive => localizedValues["almostInactive"][locale.languageCode]; + String get lightActive1 => localizedValues["lightActive1"][locale.languageCode]; + String get veryActive => localizedValues["veryActive"][locale.languageCode]; - String get superActive => localizedValues["superActive"][locale.languageCode]; + String get superActive => localizedValues["superActive"][locale.languageCode]; String get dailyIntake => localizedValues["dailyIntake"][locale.languageCode]; + String get calculateAmount => localizedValues["calculateAmount"][locale.languageCode]; + String get bodyWillBurn => localizedValues["bodyWillBurn"][locale.languageCode]; + String get caloriesEachDay => localizedValues["caloriesEachDay"][locale.languageCode]; + String get maintainWeight => localizedValues["maintainWeight"][locale.languageCode]; String get mediumFinger => localizedValues["mediumFinger"][locale.languageCode]; + String get smallFinger => localizedValues["smallFinger"][locale.languageCode]; + String get largeFinger => localizedValues["largeFinger"][locale.languageCode]; + String get idealBodyWeight => localizedValues["idealBodyWeight"][locale.languageCode]; + String get bodyFrameSize => localizedValues["bodyFrameSize"][locale.languageCode]; String get idealWeightRange => localizedValues["idealWeightRange"][locale.languageCode]; + String get currentWeightPerfect => localizedValues["currentWeightPerfect"][locale.languageCode]; + String get littleBitWeightMore => localizedValues["littleBitWeightMore"][locale.languageCode]; + String get consultWithDoctor => localizedValues["consultWithDoctor"][locale.languageCode]; + String get excessiveObesity => localizedValues["excessiveObesity"][locale.languageCode]; + String get mayWish => localizedValues["mayWish"][locale.languageCode]; String get underObese => localizedValues["underObese"][locale.languageCode]; - String get crossedLimits => localizedValues["crossedLimits"][locale.languageCode]; - String get lowLimits => localizedValues["lowLimits"][locale.languageCode]; - String get estimates => localizedValues["estimates"][locale.languageCode]; - String get submitReview => localizedValues["submitReview"][locale.languageCode]; + String get crossedLimits => localizedValues["crossedLimits"][locale.languageCode]; + String get lowLimits => localizedValues["lowLimits"][locale.languageCode]; + String get estimates => localizedValues["estimates"][locale.languageCode]; + String get submitReview => localizedValues["submitReview"][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { From 11d37d26e53b658f6128cf42e0e5f6aac50b562e Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 9 Nov 2021 17:59:36 +0300 Subject: [PATCH 40/70] Product Detail page fix --- .../product-details/product-detail.dart | 394 +++++++++--------- .../product-name-and-price.dart | 2 +- .../product_detail_service.dart | 10 +- 3 files changed, 205 insertions(+), 201 deletions(-) diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 015df6ed..2676280f 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/core/enum/viewstate.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'; @@ -11,6 +12,7 @@ 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/progress_indicator/app_circular_progress_Indeicator.dart'; import 'package:flutter/material.dart'; import 'availability_info.dart'; @@ -87,8 +89,8 @@ class __ProductDetailPageState extends State { Widget build(BuildContext context) { return BaseView( allowAny: true, - onModelReady: (model) { - model.getProductReviewsData(widget.product.id); + onModelReady: (model) async { + await model.getProductReviewsData(widget.product.id).then((value) {}); }, builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).productDetails, @@ -108,215 +110,219 @@ class __ProductDetailPageState extends State { isInWishList: isInWishList, addToCartFunction: addToCartFunction, ), - body: SingleChildScrollView( - child: Column( - children: [ - Container( - width: double.infinity, - color: Colors.white, + body: model.state == ViewState.Idle + ? SingleChildScrollView( child: Column( children: [ - if (widget.product.images.isNotEmpty) - Container( - height: MediaQuery.of(context).size.height * .40, - child: Image.network( - widget.product.images[0].src.trim(), - fit: BoxFit.contain, - ), + Container( + width: double.infinity, + color: Colors.white, + child: Column( + children: [ + if (widget.product.images.isNotEmpty) + Container( + height: MediaQuery.of(context).size.height * .40, + child: Image.network( + widget.product.images[0].src.trim(), + fit: BoxFit.contain, + ), + ), + if (widget.product.discountDescription != null) DiscountDescription(product: widget.product) + ], ), - if (widget.product.discountDescription != null) DiscountDescription(product: widget.product) - ], - ), - ), - SizedBox( - height: 4, - ), - Container( - color: Colors.white, - child: ProductNameAndPrice( - context, - widget.product, - customerId: customerId, - addToWishlistFunction: (item) { - addToWishlistFunction(itemID: item, model: model); - setState(() {}); - }, - deleteFromWishlistFunction: (item) { - deleteFromWishlistFunction(itemID: item, model: model); - setState(() {}); - }, - notifyMeWhenAvailable: (context, itemId) { - notifyMeWhenAvailable(itemId: itemId, customerId: customerId, model: model); - }, - isInWishList: isInWishList, - isStockAvailable: model.isStockAvailable, - ), - ), - SizedBox( - height: 6, - ), - Container( - color: Colors.white, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ + ), + SizedBox( + height: 4, + ), Container( - padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10), - child: Texts( - TranslationBase.of(context).specification, - fontSize: 15, - fontWeight: FontWeight.bold, + color: Colors.white, + child: ProductNameAndPrice( + context, + widget.product, + customerId: customerId, + addToWishlistFunction: (item) { + addToWishlistFunction(itemID: item, model: model); + setState(() {}); + }, + deleteFromWishlistFunction: (item) { + deleteFromWishlistFunction(itemID: item, model: model); + setState(() {}); + }, + notifyMeWhenAvailable: (context, itemId) { + notifyMeWhenAvailable(itemId: itemId, customerId: customerId, model: model); + }, + isInWishList: isInWishList, + isStockAvailable: model.isStockAvailable, ), - width: double.infinity, ), - // Divider(color: Colors.grey), - ], - ), - ), - SizedBox( - height: 6, - ), - Container( - // width: 500, - margin: EdgeInsets.only(bottom: 6), - color: Colors.white, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = true; - isReviews = false; - isAvailability = false; - }); - }, - child: Text( - TranslationBase.of(context).details, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), - ), - color: Colors.white, + SizedBox( + height: 6, + ), + Container( + color: Colors.white, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10), + child: Texts( + TranslationBase.of(context).specification, + fontSize: 15, + fontWeight: FontWeight.bold, ), - CustomDivider( - color: isDetails ? Colors.green : Colors.transparent, - ) - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () async { - if (widget.product.approvedTotalReviews > 0) { - GifLoaderDialogUtils.showMyDialog(context); - await model.getProductReviewsData(widget.product.id); - GifLoaderDialogUtils.hideDialog(context); - } else { - model.clearReview(); - } - setState(() { - isDetails = false; - isReviews = true; - isAvailability = false; - }); - }, - child: Text( - TranslationBase.of(context).reviews, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + width: double.infinity, + ), + // Divider(color: Colors.grey), + ], + ), + ), + SizedBox( + height: 6, + ), + Container( + // width: 500, + margin: EdgeInsets.only(bottom: 6), + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Column( + children: [ + FlatButton( + onPressed: () { + setState(() { + isDetails = true; + isReviews = false; + isAvailability = false; + }); + }, + child: Text( + TranslationBase.of(context).details, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + CustomDivider( + color: isDetails ? Colors.green : Colors.transparent, + ) + ], ), - color: Colors.white, - ), - CustomDivider( - color: isReviews ? Colors.green : Colors.transparent, - ), - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () async { - GifLoaderDialogUtils.showMyDialog(context); - await model.getProductLocationData(); - GifLoaderDialogUtils.hideDialog(context); + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () async { + if (widget.product.approvedTotalReviews > 0) { + GifLoaderDialogUtils.showMyDialog(context); + await model.getProductReviewsData(widget.product.id); + GifLoaderDialogUtils.hideDialog(context); + } else { + model.clearReview(); + } + setState(() { + isDetails = false; + isReviews = true; + isAvailability = false; + }); + }, + child: Text( + TranslationBase.of(context).reviews, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + CustomDivider( + color: isReviews ? Colors.green : Colors.transparent, + ), + ], + ), + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () async { + GifLoaderDialogUtils.showMyDialog(context); + await model.getProductLocationData(); + GifLoaderDialogUtils.hideDialog(context); - setState(() { - isDetails = false; - isReviews = false; - isAvailability = true; - }); - }, - child: Text( - TranslationBase.of(context).availability, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + setState(() { + isDetails = false; + isReviews = false; + isAvailability = true; + }); + }, + child: Text( + TranslationBase.of(context).availability, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + CustomDivider( + color: isAvailability ? Colors.green : Colors.transparent, + ), + ], ), - color: Colors.white, - ), - CustomDivider( - color: isAvailability ? Colors.green : Colors.transparent, - ), - ], - ), - ], + ], + ), + SizedBox( + height: 10, + ), + isDetails + ? DetailsInfo( + product: widget.product, + ) + : isReviews + ? ReviewsInfo( + product: widget.product, + previousModel: model, + ) + : isAvailability + ? AvailabilityInfo( + previousModel: model, + ) + : Container(), + ], + ), ), SizedBox( height: 10, ), - isDetails - ? DetailsInfo( - product: widget.product, - ) - : isReviews - ? ReviewsInfo( - product: widget.product, - previousModel: model, - ) - : isAvailability - ? AvailabilityInfo( - previousModel: model, - ) - : Container(), + RecommendedProducts( + product: widget.product, + productDetailViewModel: model, + addToWishlistFunction: (itemID) async { + await addToWishlistFunction(itemID: itemID, model: model); + }, + deleteFromWishlistFunction: (itemID) async { + await deleteFromWishlistFunction(itemID: itemID, model: model); + }, + ) ], ), - ), - SizedBox( - height: 10, - ), - RecommendedProducts( - product: widget.product, - productDetailViewModel: model, - addToWishlistFunction: (itemID) async { - await addToWishlistFunction(itemID: itemID, model: model); - }, - deleteFromWishlistFunction: (itemID) async { - await deleteFromWishlistFunction(itemID: itemID, model: model); - }, ) - ], - ), - ), - bottomSheet: FooterWidget( - model.isStockAvailable, - widget.product.orderMaximumQuantity, - widget.product.orderMinimumQuantity, - model.stockQuantity, - widget.product, - quantity: quantity, - isOverQuantity: isOverQuantity, - addToCartFunction: addToCartFunction, - addToShoppingCartFunction: addToShoppingCartFunction, - model: model, - ), + : AppCircularProgressIndicator(), + bottomSheet: model.state == ViewState.Idle + ? FooterWidget( + model.isStockAvailable, + widget.product.orderMaximumQuantity, + widget.product.orderMinimumQuantity, + model.stockQuantity, + widget.product, + quantity: quantity, + isOverQuantity: isOverQuantity, + addToCartFunction: addToCartFunction, + addToShoppingCartFunction: addToShoppingCartFunction, + model: model, + ) + : SizedBox(), )); } diff --git a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart index 9401f3e0..e214d70e 100644 --- a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart +++ b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart @@ -24,7 +24,7 @@ class ProductNameAndPrice extends StatefulWidget { AuthenticatedUserObject authenticatedUserObject = locator(); ProductNameAndPrice(this.context, this.item, - {this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, @required this.isStockAvailable}); + {this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, this.isStockAvailable = false}); @override _ProductNameAndPriceState createState() => _ProductNameAndPriceState(); diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 23379914..795530ff 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -2,15 +2,11 @@ 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'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; class ProductDetailService extends BaseService { bool isLogin = false; @@ -57,7 +53,9 @@ class ProductDetailService extends BaseService { }); _stockQuantity = response['products'][0]['stock_quantity']; _stockAvailability = response['products'][0]['stock_availability']; - _isStockAvailable = response['products'][0]['IsStockAvailable']; + + // _isStockAvailable = response['products'][0]['IsStockAvailable']; + _isStockAvailable = _stockAvailability == "In stock" ? true : false; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; From 70304427f95c18e633969633f622c6aae5335c62 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 9 Nov 2021 18:31:53 +0300 Subject: [PATCH 41/70] Doc specialty fix --- lib/config/config.dart | 9 +++++++-- lib/pages/BookAppointment/widgets/DoctorView.dart | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 200e5776..280b6255 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -15,8 +15,8 @@ const PACKAGES_CUSTOMER = '/api/customers'; 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/'; // Pharmacy UAT URLs // const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; @@ -26,6 +26,11 @@ const BASE_URL = 'https://uat.hmgwebservices.com/'; const BASE_PHARMACY_URL = 'https://mdlaboratories.com/exacartapi/api/'; const PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapi/api/'; +// // Pharmacy Pre-Production URLs +// const BASE_PHARMACY_URL = 'https://mdlaboratories.com/exacartapitest/api/'; +// const PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapitest/api/'; + + // RC API URL const RC_BASE_URL = 'https://livecare.hmg.com/'; diff --git a/lib/pages/BookAppointment/widgets/DoctorView.dart b/lib/pages/BookAppointment/widgets/DoctorView.dart index 794ece31..1e2e48df 100644 --- a/lib/pages/BookAppointment/widgets/DoctorView.dart +++ b/lib/pages/BookAppointment/widgets/DoctorView.dart @@ -78,7 +78,8 @@ class DoctorView extends StatelessWidget { if (doctor.projectName != null) MyRichText(TranslationBase.of(context).branch, doctor.projectName, projectViewModel.isArabic), if (doctor.speciality != null) Text( - getDoctorSpeciality(this.doctor.speciality).trim(), + this.doctor.speciality[0].trim(), + // getDoctorSpeciality(this.doctor.speciality).trim(), style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.48, height: 18 / 12), ), if (doctor.nearestFreeSlot != null) From 62d904aa68f380b38c12b94cf5f69e7388708e83 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Tue, 9 Nov 2021 19:22:24 +0300 Subject: [PATCH 42/70] fixed issues --- lib/pages/final_products_page.dart | 11 ++- lib/pages/offers_categorise_page.dart | 22 ++--- lib/pages/parent_categorise_page.dart | 90 +++++-------------- .../pharmacies/widgets/ProductTileItem.dart | 35 ++++++-- .../widgets/home/PrescriptionsWidget.dart | 2 +- lib/pages/pharmacy_categorise.dart | 3 +- lib/pages/sub_categorise_page.dart | 16 +++- 7 files changed, 77 insertions(+), 102 deletions(-) diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index ea5ee011..63e684fe 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_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'; @@ -15,6 +16,7 @@ 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:provider/provider.dart'; import 'package:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; @@ -58,6 +60,7 @@ class _FinalProductsPageState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) { if (widget.productType == 1) { @@ -259,8 +262,8 @@ class _FinalProductsPageState extends State { ), ), ), - Texts( - model.finalProducts[index].name, + Texts(projectViewModel.isArabic ? model.finalProducts[index].namen : model.finalProducts[index].name, +// model.finalProducts[index].name, regular: true, fontSize: 12, fontWeight: FontWeight.w400, @@ -414,8 +417,8 @@ class _FinalProductsPageState extends State { ), Container( width: MediaQuery.of(context).size.width * 0.64, - child: Texts( - model.finalProducts[index].name, + child: Texts(projectViewModel.isArabic ? model.finalProducts[index].namen : model.finalProducts[index].name, +// model.finalProducts[index].name, regular: true, fontSize: 13.2, fontWeight: FontWeight.w500, diff --git a/lib/pages/offers_categorise_page.dart b/lib/pages/offers_categorise_page.dart index 263aef5c..a9e9622a 100644 --- a/lib/pages/offers_categorise_page.dart +++ b/lib/pages/offers_categorise_page.dart @@ -28,6 +28,7 @@ class _OffersCategorisePageState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectProvider = Provider.of(context); return BaseView( onModelReady: (model) => model.getOffersCategorise(), @@ -99,9 +100,8 @@ class _OffersCategorisePageState extends State { .height * 0.09, child: Center( - child: Texts( - model.categorise[index] - .name, + child: Texts(projectViewModel.isArabic ? model.categorise[index].namen : model.categorise[index].name, +// model.categorise[index].name, fontWeight: FontWeight.w600, fontSize: 13.8, @@ -117,8 +117,8 @@ class _OffersCategorisePageState extends State { String ids = model.categorise[index].id; - categoriseName = model - .categorise[index].name; + categoriseName = projectViewModel.isArabic ? model.categorise[index].namen : model.categorise[index].name; + //model.categorise[index].name; }), ], ), @@ -403,11 +403,8 @@ class _OffersCategorisePageState extends State { ), ), ), - Texts( - model - .products[ - index] - .name, + Texts( projectViewModel.isArabic ? model.products[index].namen : model.products[index].name, + // model.products[index].name, regular: true, fontSize: 12.58, fontWeight: @@ -649,9 +646,8 @@ class _OffersCategorisePageState extends State { SizedBox( height: 4.0, ), - Texts( - model.products[index] - .name, + Texts( projectViewModel.isArabic ? model.products[index].namen : model.products[index].name, + // model.products[index].name, regular: true, fontSize: 14.0, fontWeight: diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index d8c2279c..ecf33158 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -116,12 +116,12 @@ class _ParentCategorisePageState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: EdgeInsets.all(10.0), - child: InkWell( + InkWell( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: EdgeInsets.all(10.0), child: Container( child: Texts( TranslationBase.of(context).viewCategorise, @@ -129,70 +129,19 @@ class _ParentCategorisePageState extends State { fontWeight: FontWeight.w300, ), ), - onTap: () { - Navigator.push( - context, - FadePage( - page: SubCategoriseModalsheet( -// id: model.categorise[0].id, -// titleName: model.categorise[0].name, - )), - ); -// showModalBottomSheet( -// isScrollControlled: true, -// context: context, -// builder: (BuildContext context) { -// return Container( -// // height: MediaQuery.of(context) -// // .size -// // .height * -// // 0.89, -// color: Colors.white, -// child: Center( -// child: ListView.builder( -// scrollDirection: Axis.vertical, -// itemCount: model.categoriseParent.length, -// itemBuilder: (BuildContext context, int index) { -// return Container( -// child: Padding( -// padding: EdgeInsets.all(4.0), -// child: InkWell( -// child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// Texts(projectViewModel.isArabic -// ? model.categoriseParent[index].namen -// : model.categoriseParent[index].name), -// Divider( -// thickness: 0.6, -// color: Colors.black12, -// ) -// ], -// ), -// onTap: () { -// Navigator.push( -// context, -// FadePage( -// page: SubCategorisePage( -// title: model.categoriseParent[index].name, -// id: model.categoriseParent[index].id, -// parentId: id, -// )), -// ); -// }, -// ), -// ), -// ); -// }), -// ), -// ); -// }, -// ); - }, ), - ), Icon(Icons.arrow_forward) - ], + ], + ), + onTap: () { + Navigator.push( + context, + FadePage( + page: SubCategoriseModalsheet( + // id: model.categorise[0].id, + // titleName: model.categorise[0].name, + )), + );} ), Divider( thickness: 1.0, @@ -256,7 +205,8 @@ class _ParentCategorisePageState extends State { context, FadePage( page: SubCategorisePage( - title: model.categoriseParent[index].name, + title: projectViewModel.isArabic ? model.categoriseParent[index].namen : model.categoriseParent[index].name, +// title: model.categoriseParent[index].name, id: model.categoriseParent[index].id, parentId: id, )), @@ -289,7 +239,7 @@ class _ParentCategorisePageState extends State { width: 10.0, ), Texts( - 'Refine', + TranslationBase.of(context).refine, fontWeight: FontWeight.w600, ), ], diff --git a/lib/pages/pharmacies/widgets/ProductTileItem.dart b/lib/pages/pharmacies/widgets/ProductTileItem.dart index 278fc6aa..cb8560c4 100644 --- a/lib/pages/pharmacies/widgets/ProductTileItem.dart +++ b/lib/pages/pharmacies/widgets/ProductTileItem.dart @@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:rating_bar/rating_bar.dart'; class ProductTileItem extends StatelessWidget { final AppSharedPreferences sharedPref = AppSharedPreferences(); @@ -178,15 +179,31 @@ class ProductTileItem extends StatelessWidget { ), Row( children: [ - Expanded( - child: StarRating( - totalAverage: item.approvedTotalReviews > 0 - ? (item.approvedRatingSum.toDouble() / - item.approvedTotalReviews.toDouble()) - .toDouble() - : 0, - forceStars: true), - ), + // Expanded( + RatingBar.readOnly( + initialRating: item.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( + "(${item.approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ) +// StarRating( +// totalAverage: item.approvedTotalReviews > 0 +// ? (item.approvedRatingSum.toDouble() / +// item.approvedTotalReviews.toDouble()) +// .toDouble() +// : 0, +// forceStars: true), + // ), ], ), ], diff --git a/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart index 61177d1f..1e993694 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.19, + height: MediaQuery.of(context).size.height * 0.30, child: ListView.builder( scrollDirection: Axis.horizontal, shrinkWrap: true, diff --git a/lib/pages/pharmacy_categorise.dart b/lib/pages/pharmacy_categorise.dart index 8a965b6e..9ed1070f 100644 --- a/lib/pages/pharmacy_categorise.dart +++ b/lib/pages/pharmacy_categorise.dart @@ -80,7 +80,8 @@ class _PharmacyCategorisePageState extends State { page: model.categorise[index].id != '12' ? ParentCategorisePage( id: model.categorise[index].id, - titleName: model.categorise[index].name, + titleName: projectViewModel.isArabic ? model.categorise[index].namen : model.categorise[index].name, + // titleName: model.categorise[index].name, ) : FinalProductsPage( id: model.categorise[index].id, diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 9d2a1f6b..22b9151d 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_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'; @@ -17,6 +18,7 @@ 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'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'package:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; @@ -59,6 +61,7 @@ class _SubCategorisePageState extends State { Widget build(BuildContext context) { TextEditingController minField = TextEditingController(); TextEditingController maxField = TextEditingController(); + ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getSubCategorise(i: id), builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( @@ -136,7 +139,9 @@ class _SubCategorisePageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts(model.subCategorise[index].name), + Texts(projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, +// model.subCategorise[index].name + ), Divider( thickness: 0.6, color: Colors.black12, @@ -208,7 +213,8 @@ class _SubCategorisePageState extends State { height: MediaQuery.of(context).size.height * 0.10, child: Center( child: Texts( - model.subCategorise[index].name, + //projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, + model.subCategorise[index].name, fontSize: 14, fontWeight: FontWeight.w600, maxLines: 2, @@ -627,7 +633,8 @@ class _SubCategorisePageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - model.subProducts[index].name, + projectViewModel.isArabic ? model.subProducts[index].namen : model.subProducts[index].name, +// model.subProducts[index].name, regular: true, fontSize: 12, fontWeight: FontWeight.w400, @@ -757,7 +764,8 @@ class _SubCategorisePageState extends State { Container( width: MediaQuery.of(context).size.width * 0.65, child: Texts( - model.subProducts[index].name, + projectViewModel.isArabic ? model.subProducts[index].namen : model.subProducts[index].name, + // model.subProducts[index].name, regular: true, fontSize: 13.2, fontWeight: FontWeight.w500, From b7dc6ee4b12a761f1617364a9c6243fe6e7226d3 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 10 Nov 2021 08:27:07 +0200 Subject: [PATCH 43/70] change model --- .../screens/cart-page/cart-order-page.dart | 13 ++++++------- 1 file changed, 6 insertions(+), 7 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 3b7d080f..eb9bf6d7 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -281,10 +281,9 @@ class _OrderBottomWidgetState extends State { @override Widget build(BuildContext context) { ProjectViewModel projectProvider = Provider.of(context); - OrderPreviewViewModel model = Provider.of(context); - return !(model.cartResponse.shoppingCarts == null || - model.cartResponse.shoppingCarts.length == 0) + return !(widget.model.cartResponse.shoppingCarts == null || + widget.model.cartResponse.shoppingCarts.length == 0) ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -374,7 +373,7 @@ class _OrderBottomWidgetState extends State { child: Row( children: [ Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(widget.model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", fontSize: projectProvider.isArabic ? 12 : 14, fontWeight: FontWeight.bold, ), @@ -392,7 +391,7 @@ class _OrderBottomWidgetState extends State { ), ), Texts( - "${model.cartResponse.quantityCount} ${TranslationBase.of(context).items}", + "${widget.model.cartResponse.quantityCount} ${TranslationBase.of(context).items}", fontSize: 10, color: Colors.grey, fontWeight: FontWeight.bold, @@ -404,7 +403,7 @@ class _OrderBottomWidgetState extends State { onPressed: isAgree // && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0 ? () => { - if (model + if (widget.model .isCartItemsOutOfStock()) { // Toast msg @@ -414,7 +413,7 @@ class _OrderBottomWidgetState extends State { } else { - _navigateToAddressPage(model + _navigateToAddressPage(widget.model .user.patientIdentificationNo) // Navigator.push( // context, From 2c3c270c43ca6ace1f1177f3bb9a808692e9ba4f Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 10 Nov 2021 08:39:45 +0200 Subject: [PATCH 44/70] finish steps inside payment --- .../pharmacyAddresses/PharmacyAddresses.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart index 338fe87e..85bc7cb8 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart @@ -48,7 +48,7 @@ class _PharmacyAddressesState extends State { return BaseView( onModelReady: (model) => model.getAddressesList(), builder: (_, model, wi) => AppScaffold( - appBarTitle: TranslationBase.of(context).changeAddress, + appBarTitle: widget.isUpdate?TranslationBase.of(context).changeAddress:"Add Address", isShowAppBar: true, isPharmacy: true, baseViewModel: model, @@ -66,11 +66,6 @@ class _PharmacyAddressesState extends State { () { setState(() { model.setSelectedAddressIndex(index); - //TODO Elham* - widget.orderPreviewViewModel.paymentCheckoutData - .address = - Addresses.fromJson( - model.addresses[index].toJson()); }); }, model.selectedAddressIndex == index, @@ -127,6 +122,11 @@ class _PharmacyAddressesState extends State { fontSize: 14, vPadding: 8, handler: () { + //TODO Elham* + widget.orderPreviewViewModel.paymentCheckoutData + .address = + Addresses.fromJson( + model.addresses[model.selectedAddressIndex].toJson()); model.saveSelectedAddressLocally( model.addresses[model.selectedAddressIndex]); _navigateToPaymentOption(model); From c4e185ea60003f35265b64ead1e1fcb9f6fe8457 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Wed, 10 Nov 2021 09:40:12 +0300 Subject: [PATCH 45/70] fixed issues --- lib/config/localized_values.dart | 10 ++++++++ .../product_detail_view_model.dart | 16 ++++++------ lib/pages/final_products_page.dart | 2 +- lib/pages/parent_categorise_page.dart | 12 ++++----- .../pharmacies/ProductCheckTypeWidget.dart | 2 +- lib/pages/pharmacies/compare-list.dart | 19 ++++++++++---- .../product-details/product-detail.dart | 12 ++++----- .../product-name-and-price.dart | 10 ++++---- .../shared/product_details_app_bar.dart | 6 +++-- .../screens/recommended-product-page.dart | 4 +-- lib/pages/sub_categorise_page.dart | 10 ++++---- .../product_detail_service.dart | 25 +++++++++++++------ lib/uitl/translations_delegate_base.dart | 20 +++++++++++++++ lib/widgets/pharmacy/product_tile.dart | 2 +- 14 files changed, 100 insertions(+), 50 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 4a8ee340..7be2decb 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -630,6 +630,16 @@ const Map localizedValues = { "years-old": {"en": "years old", "ar": "سنة"}, "drag-point": {"en": "Drag point to change your age", "ar": "اسحب لتغيير عمرك"}, "refine": {"en": "Refine", "ar": "تصفية"}, + "max": {"en": "Max", "ar": "اعلى"}, + "addToCompareMsg": {"en": "You have added a product to the Compare list", "ar": "تمت الاضافه لقائمة المقارنه"}, + "itInListMsg": {"en": "Item is already in the list", "ar": "المنتج موجود في القائمه"}, + "compareListFull": {"en": "Your compare list is full", "ar": "قائمة المقارنة ممتلئه"}, + "addQuantity": {"en": "You should add quantity", "ar": "اختر الكمية"}, + "addToCartMsg": {"en": "You have added a product to the cart", "ar": "تمت اضافة المنتج بنجاح"}, + "addToWishlistMsg": {"en": "You have added a product to the Wishlist", "ar": "تمت الاضافة لقائمة الرغبات"}, + "notifyMeMsg": {"en": "You will be notified when product available", "ar": "سيتم اخبارك في حال توفر المنتج"}, + "removeFromWishlistMsg": {"en": "You have removed a product from the Wishlist", "ar": "تمت ازالة المنتج بنجاح"}, + "min": {"en": "Min", "ar": "اقل"}, "reset": {"en": "Reset", "ar": "اعادة تعيين"}, "apply": {"en": "Apply", "ar": "تطبيق"}, "viewCategorise": {"en": "View All Categories", "ar": "عرض جميع الفئات"}, diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index 2ae935dd..6eb1f4b9 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -55,10 +55,10 @@ class ProductDetailViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future notifyMe(customerId, itemID) async { + Future notifyMe(customerId, itemID, context) async { hasError = false; setState(ViewState.BusyLocal); - await _productDetailService.notifyMe(customerId, itemID); + await _productDetailService.notifyMe(customerId, itemID, context); if (_productDetailService.hasError) { error = _productDetailService.error; setState(ViewState.ErrorLocal); @@ -66,10 +66,10 @@ class ProductDetailViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future addToCartData(quantity, itemID) async { + Future addToCartData(quantity, itemID, context) async { hasError = false; setState(ViewState.BusyLocal); - var resp = await _productDetailService.addToCart(quantity, itemID); + var resp = await _productDetailService.addToCart(quantity, itemID, context); ShoppingCartResponse object = _handleGetShoppingCartResponse(resp); if (_productDetailService.hasError) { error = _productDetailService.error; @@ -103,11 +103,11 @@ class ProductDetailViewModel extends BaseViewModel { return cartResponse; } - Future addToWishlistData(itemID) async { + Future addToWishlistData(itemID, context) async { hasError = false; setState(ViewState.BusyLocal); GifLoaderDialogUtils.showMyDialog(locator().navigatorKey.currentContext); - await _productDetailService.addToWishlist(itemID); + await _productDetailService.addToWishlist(itemID, context); GifLoaderDialogUtils.hideDialog(locator().navigatorKey.currentContext); if (_productDetailService.hasError) { @@ -128,11 +128,11 @@ class ProductDetailViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future deleteWishlistData(itemID) async { + Future deleteWishlistData(itemID, context) async { hasError = false; setState(ViewState.BusyLocal); GifLoaderDialogUtils.showMyDialog(locator().navigatorKey.currentContext); - await _productDetailService.deleteItemFromWishlist(itemID); + await _productDetailService.deleteItemFromWishlist(itemID, context); GifLoaderDialogUtils.hideDialog(locator().navigatorKey.currentContext); if (_productDetailService.hasError) { diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 63e684fe..519c8c4d 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -530,6 +530,6 @@ class _FinalProductsPageState extends State { addToCartFunction(quantity, itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID); + await x.addToCartData(quantity, itemID, context); } } diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index ecf33158..1c52b7a5 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -368,7 +368,7 @@ class _ParentCategorisePageState extends State { Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts('Min'), + Texts(TranslationBase.of(context).min), Container( color: Colors.white, width: 200, @@ -385,7 +385,7 @@ class _ParentCategorisePageState extends State { Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts('Max'), + Texts(TranslationBase.of(context).max), Container( color: Colors.white, width: 200, @@ -588,7 +588,7 @@ class _ParentCategorisePageState extends State { bottom: 5.0, ), child: Texts( - 'offer'.toUpperCase(), + TranslationBase.of(context).offers.toUpperCase(), color: Colors.red, fontSize: 13.0, fontWeight: FontWeight.w900, @@ -876,8 +876,8 @@ class _ParentCategorisePageState extends State { ), Padding( padding: const EdgeInsets.all(8.0), - child: Text( - 'There is no data', + child: Text(TranslationBase.of(context).noData, + // 'There is no data', style: TextStyle(fontSize: 30), ), ) @@ -895,7 +895,7 @@ class _ParentCategorisePageState extends State { addToCartFunction(quantity, itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID); + await x.addToCartData(quantity, itemID, context); } bool isEntityListSelected(CategoriseParentModel masterKey) { diff --git a/lib/pages/pharmacies/ProductCheckTypeWidget.dart b/lib/pages/pharmacies/ProductCheckTypeWidget.dart index 2b88d30a..46c5e7a3 100644 --- a/lib/pages/pharmacies/ProductCheckTypeWidget.dart +++ b/lib/pages/pharmacies/ProductCheckTypeWidget.dart @@ -48,7 +48,7 @@ class _ProductCheckTypeWidgetState extends State { deleteWishListItem(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); GifLoaderDialogUtils.showMyDialog(context); - await x.deleteWishlistData(itemID); + await x.deleteWishlistData(itemID, context); await widget.model.getWishlistData(isLocalLoader: true); GifLoaderDialogUtils.hideDialog(context); } diff --git a/lib/pages/pharmacies/compare-list.dart b/lib/pages/pharmacies/compare-list.dart index c4da5ba2..afa5382f 100644 --- a/lib/pages/pharmacies/compare-list.dart +++ b/lib/pages/pharmacies/compare-list.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; class CompareList with ChangeNotifier { @@ -7,20 +8,28 @@ class CompareList with ChangeNotifier { List get productListItems => _product; - void addItem(data) { + void addItem(data, context) { if (_product.length == 0) { _product.add(data); - AppToast.showSuccessToast(message: 'You have added a product to the Compare list'); + AppToast.showSuccessToast(message:TranslationBase.of(context).addToCompareMsg + // 'You have added a product to the Compare list' + ); } else { for (int i = 0; i < _product.length; i++) { if (_product.length <= 4 && _product[i].id != data.id) { _product.add(data); - AppToast.showSuccessToast(message: 'You have added a product to the Compare list'); + AppToast.showSuccessToast(message:TranslationBase.of(context).addToCompareMsg + // 'You have added a product to the Compare list' + ); break; } else if(_product[i].id == data.id){ - AppToast.showErrorToast(message: 'the item is already in the list'); + AppToast.showErrorToast(message:TranslationBase.of(context).itInListMsg + // 'the item is already in the list' + ); } else if(_product.length == 4){ - AppToast.showErrorToast(message: 'your compare list is full'); + AppToast.showErrorToast(message: TranslationBase.of(context).compareListFull + // 'your compare list is full' + ); } } } diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 2676280f..3c44463e 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -328,19 +328,19 @@ class __ProductDetailPageState extends State { addToShoppingCartFunction({quantity, itemID, ProductDetailViewModel model}) async { GifLoaderDialogUtils.showMyDialog(context); - await model.addToCartData(quantity, itemID); + await model.addToCartData(quantity, itemID, context); GifLoaderDialogUtils.hideDialog(context); } addToWishlistFunction({itemID, ProductDetailViewModel model}) async { isInWishList = true; - await model.addToWishlistData(itemID); + await model.addToWishlistData(itemID, context); setState(() {}); } deleteFromWishlistFunction({itemID, ProductDetailViewModel model}) async { isInWishList = false; - await model.deleteWishlistData(itemID); + await model.deleteWishlistData(itemID, context); setState(() {}); } @@ -350,11 +350,11 @@ class __ProductDetailPageState extends State { ProductDetailViewModel model, }) async { GifLoaderDialogUtils.showMyDialog(context); - await model.addToCartData(quantity, itemID); + await model.addToCartData(quantity, itemID, context); GifLoaderDialogUtils.hideDialog(context); } } -notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model}) async { - await model.notifyMe(customerId, itemId); +notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model, context}) async { + await model.notifyMe(customerId, itemId, context); } diff --git a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart index e214d70e..a70d9fc2 100644 --- a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart +++ b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart @@ -128,11 +128,11 @@ class _ProductNameAndPriceState extends State { SizedBox( width: 10, ), - Texts( - "${widget.item.approvedRatingSum}", - fontWeight: FontWeight.bold, - fontSize: 12, - ), +// Texts( +// "${widget.item.approvedRatingSum}", +// fontWeight: FontWeight.bold, +// fontSize: 12, +// ), SizedBox( width: 30, ), 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 1626e24f..944e065c 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 @@ -157,7 +157,9 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { Navigator.of(context).pop(); } } else { - AppToast.showErrorToast(message: "you should add quantity"); + AppToast.showErrorToast(message: TranslationBase.of(context).addQuantity + // "you should add quantity" + ); } }), ListTile( @@ -184,7 +186,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { ), onTap: () { Provider.of(context, listen: false) - .addItem(specificationData); + .addItem(specificationData,context); Navigator.of(context).pop(); }, ), diff --git a/lib/pages/pharmacies/screens/recommended-product-page.dart b/lib/pages/pharmacies/screens/recommended-product-page.dart index 4ea089fa..b04201e5 100644 --- a/lib/pages/pharmacies/screens/recommended-product-page.dart +++ b/lib/pages/pharmacies/screens/recommended-product-page.dart @@ -534,13 +534,13 @@ class _RecommendedProductPageState extends State addToWishlistFunction(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); isInWishlist = true; - await x.addToWishlistData(itemID); + await x.addToWishlistData(itemID, context); } deleteFromWishlistFunction(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); isInWishlist = false; - await x.addToWishlistData(itemID); + await x.addToWishlistData(itemID, context); } } diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 22b9151d..01b061b6 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -213,8 +213,8 @@ class _SubCategorisePageState extends State { height: MediaQuery.of(context).size.height * 0.10, child: Center( child: Texts( - //projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, - model.subCategorise[index].name, + projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, + // model.subCategorise[index].name, fontSize: 14, fontWeight: FontWeight.w600, maxLines: 2, @@ -386,7 +386,7 @@ class _SubCategorisePageState extends State { Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts('Min'), + Texts(TranslationBase.of(context).min), Container( color: Colors.white, width: 200, @@ -403,7 +403,7 @@ class _SubCategorisePageState extends State { Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts('Max'), + Texts(TranslationBase.of(context).max), Container( color: Colors.white, width: 200, @@ -897,6 +897,6 @@ class _SubCategorisePageState extends State { addToCartFunction(quantity, itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID); + await x.addToCartData(quantity, itemID, context); } } diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 795530ff..7a50a37c 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/models/pharmacy/locationModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/specification.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; class ProductDetailService extends BaseService { @@ -91,7 +92,7 @@ class ProductDetailService extends BaseService { }, body: request); } - Future addToCart(quantity, itemID) async { + Future addToCart(quantity, itemID, context) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; Map request; @@ -106,7 +107,9 @@ class ProductDetailService extends BaseService { response['shopping_carts'].forEach((item) { _addToCartModel.add(Wishlist.fromJson(item)); }); - AppToast.showSuccessToast(message: 'You have added a product to the cart'); + AppToast.showSuccessToast(message: TranslationBase.of(context).addToCartMsg + // 'You have added a product to the cart' + ); localRes = response; }, onFailure: (String error, int statusCode) { hasError = true; @@ -117,10 +120,12 @@ class ProductDetailService extends BaseService { return Future.value(localRes); } - Future notifyMe(customerId, itemID) async { + Future notifyMe(customerId, itemID, context) async { hasError = false; await baseAppClient.getPharmacy(SUBSCRIBE_PRODUCT + "SinceId=$customerId&ProductId=$itemID", onSuccess: (dynamic response, int statusCode) { - AppToast.showSuccessToast(message: 'You will be notified when product available'); + AppToast.showSuccessToast(message: TranslationBase.of(context).notifyMeMsg + //'You will be notified when product available' + ); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; @@ -128,7 +133,7 @@ class ProductDetailService extends BaseService { }); } - Future addToWishlist(itemID) async { + Future addToWishlist(itemID, context) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; Map request; @@ -141,7 +146,9 @@ class ProductDetailService extends BaseService { response['shopping_carts'].forEach((item) { _wishListProducts.add(Wishlist.fromJson(item)); }); - AppToast.showSuccessToast(message: 'You have added a product to the Wishlist'); + AppToast.showSuccessToast(message: TranslationBase.of(context).addToWishlistMsg + // 'You have added a product to the Wishlist' + ); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; @@ -163,7 +170,7 @@ class ProductDetailService extends BaseService { }); } - Future deleteItemFromWishlist(itemID) async { + Future deleteItemFromWishlist(itemID, context) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; await baseAppClient.getPharmacy(DELETE_WISHLIST + customerId + "+&product_id=" + itemID + "&cart_type=Wishlist", onSuccess: (dynamic response, int statusCode) { @@ -171,7 +178,9 @@ class ProductDetailService extends BaseService { response['shopping_carts'].forEach((item) { _wishListProducts.add(Wishlist.fromJson(item)); }); - AppToast.showSuccessToast(message: 'You have removed a product from the Wishlist'); + AppToast.showSuccessToast(message: TranslationBase.of(context).removeFromWishlistMsg + // 'You have removed a product from the Wishlist' + ); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index d1bc500d..63d1719f 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1206,6 +1206,26 @@ class TranslationBase { String get refine => localizedValues['refine'][locale.languageCode]; + String get max => localizedValues['max'][locale.languageCode]; + + String get min => localizedValues['min'][locale.languageCode]; + + String get addToCompareMsg => localizedValues['addToCompareMsg'][locale.languageCode]; + + String get itInListMsg => localizedValues['itInListMsg'][locale.languageCode]; + + String get compareListFull => localizedValues['compareListFull'][locale.languageCode]; + + String get addQuantity => localizedValues['addQuantity'][locale.languageCode]; + + String get addToCartMsg => localizedValues['addToCartMsg'][locale.languageCode]; + + String get addToWishlistMsg => localizedValues['addToWishlistMsg'][locale.languageCode]; + + String get notifyMeMsg => localizedValues['notifyMeMsg'][locale.languageCode]; + + String get removeFromWishlistMsg => localizedValues['removeFromWishlistMsg'][locale.languageCode]; + String get apply => localizedValues['apply'][locale.languageCode]; String get reset => localizedValues['reset'][locale.languageCode]; diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index c63410ba..70a727bf 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -295,6 +295,6 @@ class productTile extends StatelessWidget { addToCartFunction(quantity, itemID, BuildContext context) async { ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID); + await x.addToCartData(quantity, itemID, context); } } From 3ec2f990b1dc0a4f9349653a97e992032daa4c20 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 10 Nov 2021 09:48:05 +0300 Subject: [PATCH 46/70] product detail page updates --- .../viewModels/pharmacyModule/product_detail_view_model.dart | 2 ++ lib/pages/landing/landing_page.dart | 4 ++-- .../pharmacies/screens/product-details/product-detail.dart | 4 ++++ .../screens/product-details/product-name-and-price.dart | 5 +++-- lib/services/pharmacy_services/product_detail_service.dart | 5 ++++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index 2ae935dd..980c62c2 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -31,6 +31,8 @@ class ProductDetailViewModel extends BaseViewModel { String get stockAvailability => _productDetailService.stockAvailability; + String get stockAvailabilityn => _productDetailService.stockAvailabilityn; + bool get isStockAvailable => _productDetailService.isStockAvailable; Future getProductReviewsData(productID) async { diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index cb26c8b7..2bca7a9e 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -241,14 +241,14 @@ class _LandingPageState extends State with WidgetsBindingObserver { pageController = PageController(keepPage: true); _firebaseMessaging.setAutoInitEnabled(true); - signalRUtil = new SignalRUtil(hubName: "https://VCallApi.hmg.com/WebRTCHub?source=mobile&username=2001273", context: context); + // signalRUtil = new SignalRUtil(hubName: "https://VCallApi.hmg.com/WebRTCHub?source=mobile&username=2001273", context: context); locationUtils = new LocationUtils(isShowConfirmDialog: false, context: context); WidgetsBinding.instance.addPostFrameCallback((_) { if (projectViewModel.isLogin && !projectViewModel.isLoginChild) { familyFileProvider.getSharedRecordByStatus(); } - if (!signalRUtil.getConnectionState()) signalRUtil.startSignalRConnection(); + // if (!signalRUtil.getConnectionState()) signalRUtil.startSignalRConnection(); }); // HMG (Guest/Internet) Wifi Access [Zohaib Kambrani] //for now commented to reduce this call will enable it when needed diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 2676280f..b1e6aff9 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.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'; @@ -14,6 +15,7 @@ import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'availability_info.dart'; import 'details_info.dart'; @@ -87,6 +89,7 @@ class __ProductDetailPageState extends State { } Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); return BaseView( allowAny: true, onModelReady: (model) async { @@ -153,6 +156,7 @@ class __ProductDetailPageState extends State { }, isInWishList: isInWishList, isStockAvailable: model.isStockAvailable, + stockAvailability: projectViewModel.isArabic ? model.stockAvailabilityn : model.stockAvailability, ), ), SizedBox( diff --git a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart index e214d70e..708e5df8 100644 --- a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart +++ b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart @@ -20,11 +20,12 @@ class ProductNameAndPrice extends StatefulWidget { final Function addToWishlistFunction; final Function deleteFromWishlistFunction; final bool isStockAvailable; + final String stockAvailability; AuthenticatedUserObject authenticatedUserObject = locator(); ProductNameAndPrice(this.context, this.item, - {this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, this.isStockAvailable = false}); + {this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, this.isStockAvailable, this.stockAvailability}); @override _ProductNameAndPriceState createState() => _ProductNameAndPriceState(); @@ -48,7 +49,7 @@ class _ProductNameAndPriceState extends State { children: [ Texts(widget.item.price.toString() + " " + TranslationBase.of(context).sar, fontWeight: FontWeight.bold, fontSize: 20), Texts( - projectViewModel.isArabic ? widget.item.stockAvailabilityn : widget.item.stockAvailability, + widget.stockAvailability, fontWeight: FontWeight.bold, fontSize: 15, color: widget.isStockAvailable ? Colors.green : Colors.red, diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 795530ff..29b7e943 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -16,8 +16,10 @@ class ProductDetailService extends BaseService { num get stockQuantity => _stockQuantity; String _stockAvailability; + String _stockAvailabilityn; String get stockAvailability => _stockAvailability; + String get stockAvailabilityn => _stockAvailabilityn; bool _isStockAvailable; @@ -45,7 +47,7 @@ class ProductDetailService extends BaseService { Future getProductReviews(productID) async { hasError = false; - await baseAppClient.getPharmacy(GET_PRODUCT_DETAIL + productID + "?fields=reviews,stock_quantity,stock_availability,IsStockAvailable", onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy(GET_PRODUCT_DETAIL + productID + "?fields=reviews,stock_quantity,stock_availability,stock_availabilityn,IsStockAvailable", onSuccess: (dynamic response, int statusCode) { _productDetailList.clear(); response['products'].forEach((item) { _productDetailList.add(ProductDetail.fromJson(item)); @@ -53,6 +55,7 @@ class ProductDetailService extends BaseService { }); _stockQuantity = response['products'][0]['stock_quantity']; _stockAvailability = response['products'][0]['stock_availability']; + _stockAvailabilityn = response['products'][0]['stock_availabilityn']; // _isStockAvailable = response['products'][0]['IsStockAvailable']; _isStockAvailable = _stockAvailability == "In stock" ? true : false; From 96ec3f29261ddfdedb6eaed6f9354d091c983127 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Wed, 10 Nov 2021 09:56:14 +0300 Subject: [PATCH 47/70] fix issues --- lib/pages/parent_categorise_page.dart | 41 ++++++++++++++++++++------- lib/pages/sub_categorise_page.dart | 33 +++++++++++++++++---- 2 files changed, 58 insertions(+), 16 deletions(-) diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 1c52b7a5..34567267 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -69,6 +69,7 @@ class _ParentCategorisePageState extends State { TextEditingController minField = TextEditingController(); TextEditingController maxField = TextEditingController(); ProjectViewModel projectViewModel = Provider.of(context); + ProjectViewModel projectProvider = Provider.of(context); return BaseView( onModelReady: (model) => model.getCategoriseParent(i: id), allowAny: true, @@ -615,13 +616,23 @@ class _ParentCategorisePageState extends State { color: Color(0xffb23838), borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: Texts( - model.parentProducts[index].rxMessage != null ? model.parentProducts[index].rxMessage : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ), + 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, +// ), ), ], ), @@ -752,13 +763,23 @@ class _ParentCategorisePageState extends State { color: Color(0xffb23838), borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: Texts( - model.parentProducts[index].rxMessage != null ? model.parentProducts[index].rxMessage : "", + 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, +// ), ), ], ), diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 01b061b6..178b511b 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -62,6 +62,7 @@ class _SubCategorisePageState extends State { TextEditingController minField = TextEditingController(); TextEditingController maxField = TextEditingController(); ProjectViewModel projectViewModel = Provider.of(context); + ProjectViewModel projectProvider = Provider.of(context); return BaseView( onModelReady: (model) => model.getSubCategorise(i: id), builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( @@ -614,13 +615,23 @@ class _SubCategorisePageState extends State { color: Color(0xffb23838), borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: Texts( - model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", + child:model.subProducts[index].rxMessage != null ? + Texts(projectProvider.isArabic + ? model.subProducts[index].rxMessagen + : model.subProducts[index].rxMessage, color: Colors.white, regular: true, fontSize: 10, fontWeight: FontWeight.w400, - ), + ) + : Texts(""), +// Texts( +// model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", +// color: Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: FontWeight.w400, +// ), ), ], ), @@ -736,13 +747,23 @@ class _SubCategorisePageState extends State { color: Color(0xffb23838), borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: Texts( - model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", + child: model.subProducts[index].rxMessage != null ? + Texts(projectProvider.isArabic + ? model.subProducts[index].rxMessagen + : model.subProducts[index].rxMessage, color: Colors.white, regular: true, fontSize: 10, fontWeight: FontWeight.w400, - ), + ) + : Texts(""), +// Texts( +// model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", +// color: Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: FontWeight.w400, +// ), ), ], ), From 8a168386daf03c2fa5dc97a457dda4a3181ff6da Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 10 Nov 2021 09:15:25 +0200 Subject: [PATCH 48/70] fix black screen which is appear in cart page --- .../screens/cart-page/cart-order-page.dart | 412 +++++++++--------- 1 file changed, 210 insertions(+), 202 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 eb9bf6d7..03799638 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -46,212 +46,216 @@ class _CartOrderPageState extends State { OrderPreviewViewModel model = Provider.of(context); final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; - AppScaffold appScaffold; - return NetworkBaseView( - isLoading: isLoading, - isLocalLoader: true, - child: appScaffold = AppScaffold( - appBarTitle: TranslationBase.of(context).shoppingCart, - isShowAppBar: true, - isPharmacy: true, - showHomeAppBarIcon: false, - isShowDecPage: false, - isMainPharmacyPages: true, - showPharmacyCart: false, - baseViewModel: model, - backgroundColor: Colors.white, - body: !(model.cartResponse.shoppingCarts == null || - model.cartResponse.shoppingCarts.length == 0) + return AppScaffold( + appBarTitle: TranslationBase.of(context).shoppingCart, + isShowAppBar: true, + isPharmacy: true, + showHomeAppBarIcon: false, + isShowDecPage: false, + isMainPharmacyPages: true, + showPharmacyCart: false, + baseViewModel: model, + backgroundColor: Colors.white, + body: NetworkBaseView( + isLoading: isLoading, + isLocalLoader: true, + child: !(model.cartResponse.shoppingCarts == null || + model.cartResponse.shoppingCarts.length == 0) ? Container( - height: height * 0.85, - width: double.infinity, - child: SingleChildScrollView( - child: Container( - margin: EdgeInsets.all(10), + height: height * 0.85, + width: double.infinity, + child: SingleChildScrollView( + child: Container( + margin: EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + GestureIconButton( + TranslationBase.of(context).deleteAllItems, + Icon( + Icons.delete_outline_sharp, + color: Colors.grey.shade700, + ), + onTap: () => {model.deleteShoppingCart()}, + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Container( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, children: [ - GestureIconButton( - TranslationBase.of(context).deleteAllItems, - Icon( - Icons.delete_outline_sharp, - color: Colors.grey.shade700, - ), - onTap: () => {model.deleteShoppingCart()}, - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Container( - child: Column( - children: [ - ...List.generate( - model.cartResponse.shoppingCarts != null - ? model.cartResponse.shoppingCarts.length - : 0, - (index) => ProductOrderItem( - model.cartResponse - .shoppingCarts[index], () { - print(model.cartResponse - .shoppingCarts[index].quantity); - model - .changeProductQuantity(model - .cartResponse - .shoppingCarts[index]) - .then((value) { - if (model.state != ViewState.Error) { - // appScaffold.appBar.badgeUpdater( - // '${value.quantityCount ?? 0}'); - } - if (model.state == - ViewState.ErrorLocal) { - Utils.showErrorToast(model.error); - } - }); - }, () { - model - .deleteProduct(model.cartResponse - .shoppingCarts[index]) - .then((value) { - if (model.state != ViewState.Error) { - // appScaffold.appBar.badgeUpdater( - // '${value.quantityCount ?? 0}'); - } - }); - })) - ], - ), - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 2, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).subtotal, - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - "${TranslationBase.of(context).vat}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).total, - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Image.asset( - "assets/images/pharmacy_module/payment.png", - width: mediaQuery.size.width - 20, - height: 30.0, - fit: BoxFit.scaleDown, - ), - SizedBox( - height: 120, - ) + ...List.generate( + model.cartResponse.shoppingCarts != null + ? model + .cartResponse.shoppingCarts.length + : 0, + (index) => ProductOrderItem( + model.cartResponse + .shoppingCarts[index], () { + print(model.cartResponse + .shoppingCarts[index].quantity); + model + .changeProductQuantity(model + .cartResponse + .shoppingCarts[index]) + .then((value) { + if (model.state != + ViewState.Error) { + // appScaffold.appBar.badgeUpdater( + // '${value.quantityCount ?? 0}'); + } + if (model.state == + ViewState.ErrorLocal) { + Utils.showErrorToast( + model.error); + } + }); + }, () { + model + .deleteProduct(model + .cartResponse + .shoppingCarts[index]) + .then((value) { + if (model.state != + ViewState.Error) { + // appScaffold.appBar.badgeUpdater( + // '${value.quantityCount ?? 0}'); + } + }); + })) ], ), ), - ), - ) - : 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, + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 2, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).subtotal, + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - TranslationBase.of(context).noData, -// 'There is no data', - style: TextStyle(fontSize: 30), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, ), - ) - ], + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + "${TranslationBase.of(context).vat}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).total, + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Image.asset( + "assets/images/pharmacy_module/payment.png", + width: mediaQuery.size.width - 20, + height: 30.0, + fit: BoxFit.scaleDown, + ), + SizedBox( + height: 120, + ) + ], + ), + ), + ), + ) + : 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, ), ), - bottomSheet: Container( - height: !(model.cartResponse.shoppingCarts == null || - model.cartResponse.shoppingCarts.length == 0) - ? height * 0.15 - : 0, - color: Colors.white, - child: OrderBottomWidget(model.addresses, height, model), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + TranslationBase.of(context).noData, +// 'There is no data', + style: TextStyle(fontSize: 30), + ), + ) + ], + ), ), ), + bottomSheet: Container( + height: !(model.cartResponse.shoppingCarts == null || + model.cartResponse.shoppingCarts.length == 0) + ? height * 0.15 + : 0, + color: Colors.white, + child: OrderBottomWidget(model.addresses, height, model), + ), ); } @@ -283,7 +287,7 @@ class _OrderBottomWidgetState extends State { ProjectViewModel projectProvider = Provider.of(context); return !(widget.model.cartResponse.shoppingCarts == null || - widget.model.cartResponse.shoppingCarts.length == 0) + widget.model.cartResponse.shoppingCarts.length == 0) ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -403,8 +407,7 @@ class _OrderBottomWidgetState extends State { onPressed: isAgree // && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0 ? () => { - if (widget.model - .isCartItemsOutOfStock()) + if (widget.model.isCartItemsOutOfStock()) { // Toast msg AppToast.showErrorToast( @@ -413,8 +416,8 @@ class _OrderBottomWidgetState extends State { } else { - _navigateToAddressPage(widget.model - .user.patientIdentificationNo) + _navigateToAddressPage(widget + .model.user.patientIdentificationNo) // Navigator.push( // context, // FadePage( @@ -442,12 +445,17 @@ class _OrderBottomWidgetState extends State { } _navigateToAddressPage(String identificationNo) { - Navigator.push(context, FadePage(page: PharmacyAddressesPage(orderPreviewViewModel: widget.model,))) - .then((result) async { + Navigator.push( + context, + FadePage( + page: PharmacyAddressesPage( + orderPreviewViewModel: widget.model, + ))).then((result) async { if (result != null) { GifLoaderDialogUtils.showMyDialog(context); var address = result; - widget.model.paymentCheckoutData.address = Addresses.fromJson(address.toJson()); + widget.model.paymentCheckoutData.address = + Addresses.fromJson(address.toJson()); await widget.model.getInformationsByAddress(identificationNo); await widget.model.getShoppingCart(); // widget.changeMainState(); From dc3d3bc7726cdfe5a0a4ea37ec6e174e12b4dfd7 Mon Sep 17 00:00:00 2001 From: devmirza121 Date: Wed, 10 Nov 2021 10:16:04 +0300 Subject: [PATCH 49/70] Health Calculator 5.0 --- lib/config/localized_values.dart | 7 +++- .../bmr_calculator/bmr_calculator.dart | 2 +- .../calorie_calculator.dart | 1 + .../health_calculator/carbs/carbs.dart | 2 +- .../carbs/carbs_result_page.dart | 32 +++++++++---------- .../ideal_body/ideal_body.dart | 2 +- lib/uitl/translations_delegate_base.dart | 5 +++ 7 files changed, 31 insertions(+), 20 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 4a8ee340..46f60222 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1636,7 +1636,7 @@ const Map localizedValues = { "waist": {"en": "Waist", "ar": "وسط"}, "hip": {"en": "Hip", "ar": "ورك او نتوء"}, "carbsProtin": {"en": "Carbs, Protein and Fat", "ar": "الكربوهيدرات والبروتينات والدهون"}, - "usefulInfo": {"en": "Useful Information", "ar": "Useful Information"}, + "usefulInfo": {"en": "Useful Information", "ar": "معلومات مفيدة"}, "babyAge": {"en": "Baby Age", "ar": "عمر الطفل الآن:"}, "babyAgeAvail": {"en": "baby age is not available", "ar": "عمر الطفل غير متوفر"}, "deliveryDue": {"en": "The delivery due date is estimated to be on the", "ar": "من المقدر أن يكون تاريخ استحقاق التسليم في"}, @@ -1705,4 +1705,9 @@ const Map localizedValues = { "dietUSDA":{"en":"USDA Guidelines","ar":"ارشادات وزارة الزراعة الأمريكية"}, "dietZone":{"en":"Zone Diet","ar":"حمية زون"}, + "Protein": {"en": "Protein", "ar": "بروتين"}, + "Cals": {"en": "Cals", "ar": "كالس"}, + "gramsPerDay": {"en": "Grams Per Day", "ar": "غرام في اليوم"}, + "gr": {"en": "gr", "ar": "غرام"}, + "gramsPerMeal": {"en": "Grams Per Meal", "ar": "عدد الجرامات لكل وجبة"}, }; diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart index e2010445..62020a62 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart @@ -357,7 +357,7 @@ class _BmrCalculatorState extends State { height: 18, child: DropdownButtonHideUnderline( child: DropdownButton( - value: dropdownValue, + value: dropdownValue, key: clinicDropdownKey, icon: Icon(Icons.arrow_downward), iconSize: 0, elevation: 16, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart index f1db7e82..b7e00652 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart @@ -290,6 +290,7 @@ class _CalorieCalculatorState extends State { child: DropdownButtonHideUnderline( child: DropdownButton( value: dropdownValue, + key: clinicDropdownKey, icon: Icon(Icons.arrow_downward), iconSize: 0, elevation: 16, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart index 31990a6b..9f2c6842 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart @@ -171,7 +171,7 @@ class _CarbsState extends State { height: 18, child: DropdownButtonHideUnderline( child: DropdownButton( - value: dropdownValue, + value: dropdownValue, key: clinicDropdownKey, icon: Icon(Icons.arrow_downward), iconSize: 0, elevation: 16, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs_result_page.dart index 43019deb..44363734 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs_result_page.dart @@ -91,10 +91,10 @@ class CarbsResult extends StatelessWidget { tableRow.add( TableRow( children: [ - Utils.tableColumnTitle("Description"), - Utils.tableColumnTitle("Protein"), - Utils.tableColumnTitle("Carbohydrate"), - Utils.tableColumnTitle("Fat"), + Utils.tableColumnTitle(TranslationBase.of(context).description), + Utils.tableColumnTitle(TranslationBase.of(context).Protein), + Utils.tableColumnTitle(TranslationBase.of(context).carbohydrate), + Utils.tableColumnTitle(TranslationBase.of(context).fat), ], ), ); @@ -102,10 +102,10 @@ class CarbsResult extends StatelessWidget { tableRow.add( TableRow( children: [ - Utils.tableColumnValue("Calories Per Day", isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(pCal.ceil().toString() + ' Cals', isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(cCal.ceil().toString() + ' Cals', isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(cCal.ceil().toString() + ' Cals', isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(TranslationBase.of(context).calDay, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(pCal.ceil().toString() + ' '+TranslationBase.of(context).Cals, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(cCal.ceil().toString() + ' '+TranslationBase.of(context).Cals, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(cCal.ceil().toString() + ' '+TranslationBase.of(context).Cals, isCapitable: false, mProjectViewModel: projectViewModel), ], ), ); @@ -113,20 +113,20 @@ class CarbsResult extends StatelessWidget { tableRow.add( TableRow( children: [ - Utils.tableColumnValue("Grams Per Day", isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(pCalGram.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(cCalGram.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(fCalGram.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(TranslationBase.of(context).gramsPerDay, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(pCalGram.ceil().toString() + ' '+TranslationBase.of(context).gr, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(cCalGram.ceil().toString() + ' '+TranslationBase.of(context).gr, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(fCalGram.ceil().toString() + ' '+TranslationBase.of(context).gr, isCapitable: false, mProjectViewModel: projectViewModel), ], ), ); tableRow.add( TableRow( children: [ - Utils.tableColumnValue('Grams Per Meal', isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(pCalMeal.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(cCalMeal.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(fCalMeal.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(TranslationBase.of(context).gramsPerMeal, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(pCalMeal.ceil().toString() + ' '+TranslationBase.of(context).gr, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(cCalMeal.ceil().toString() + ' '+TranslationBase.of(context).gr, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(fCalMeal.ceil().toString() + ' '+TranslationBase.of(context).gr, isCapitable: false, mProjectViewModel: projectViewModel), ], ), ); diff --git a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart index 265bb412..a594846e 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart @@ -200,7 +200,7 @@ class _IdealBodyState extends State { child: DropdownButtonHideUnderline( child: DropdownButton( value: dropdownValue, - icon: Icon(Icons.arrow_downward), + icon: Icon(Icons.arrow_downward), key: clinicDropdownKey, iconSize: 0, elevation: 16, isExpanded: true, diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 80425967..3c878c19 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2727,6 +2727,11 @@ class TranslationBase { String get estimates => localizedValues["estimates"][locale.languageCode]; String get submitReview => localizedValues["submitReview"][locale.languageCode]; + String get Protein => localizedValues["Protein"][locale.languageCode]; + String get Cals => localizedValues["Cals"][locale.languageCode]; + String get gramsPerDay => localizedValues["gramsPerDay"][locale.languageCode]; + String get gr => localizedValues["gr"][locale.languageCode]; + String get gramsPerMeal => localizedValues["gramsPerMeal"][locale.languageCode]; From d1e0b6ccd95cf01375f588b6dced6612b9f42e7c Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Wed, 10 Nov 2021 11:42:22 +0300 Subject: [PATCH 50/70] fix issue --- lib/pages/final_products_page.dart | 18 ++++- lib/pages/offers_categorise_page.dart | 78 +++++++++++--------- lib/pages/pharmacies/search_brands_page.dart | 12 ++- lib/pages/search_products_page.dart | 41 ++++++---- lib/pages/sub_categorise_page.dart | 2 +- 5 files changed, 93 insertions(+), 58 deletions(-) diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 519c8c4d..f65665b5 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -60,6 +60,7 @@ class _FinalProductsPageState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectProvider = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) { @@ -228,7 +229,7 @@ class _FinalProductsPageState extends State { ), child: model.finalProducts[index].rxMessage != null ? Texts( - languageID == 'ar' ? model.finalProducts[index].rxMessagen : model.finalProducts[index].rxMessage, + projectProvider.isArabic ? model.finalProducts[index].rxMessagen : model.finalProducts[index].rxMessage, color: Colors.white, regular: true, fontSize: 10, @@ -390,13 +391,22 @@ class _FinalProductsPageState extends State { color: Color(0xffb23838), borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: Texts( - model.finalProducts[index].rxMessage != null ? model.finalProducts[index].rxMessage : "", + child:model.finalProducts[index].rxMessage != null + ? Texts( + projectProvider.isArabic ? model.finalProducts[index].rxMessagen : model.finalProducts[index].rxMessage, color: Colors.white, regular: true, fontSize: 10, fontWeight: FontWeight.w600, - ), + ) + : Texts(""), +// Texts( +// model.finalProducts[index].rxMessage != null ? model.finalProducts[index].rxMessage : "", +// color: Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: FontWeight.w600, +// ), ), ], ), diff --git a/lib/pages/offers_categorise_page.dart b/lib/pages/offers_categorise_page.dart index a9e9622a..a4708830 100644 --- a/lib/pages/offers_categorise_page.dart +++ b/lib/pages/offers_categorise_page.dart @@ -275,7 +275,7 @@ class _OffersCategorisePageState extends State { bottom: 5.0, ), child: Texts( - 'offer' + TranslationBase.of(context).offers .toUpperCase(), color: Colors .red, @@ -338,25 +338,28 @@ class _OffersCategorisePageState extends State { .circular( 6)), ), - child: Texts( - model - .products[ - index] - .rxMessage != - null - ? model - .products[ - index] - .rxMessage - : "", - color: - Colors.white, + child: model.products[index].rxMessage != null + ? Texts( + projectProvider.isArabic + ? model.products[index].rxMessagen + : model.products[index].rxMessage, + color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight - .w400, - ), + fontWeight: FontWeight.w400, + ): Texts("") +// Texts( +// model.products[index].rxMessage != null ? +// model.products[index].rxMessage +// : "", +// color: +// Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: +// FontWeight +// .w400, +// ), ), ], ), @@ -508,7 +511,7 @@ class _OffersCategorisePageState extends State { child: Center( child: Texts( - 'offer' + TranslationBase.of(context).offers .toUpperCase(), color: Colors .red, @@ -576,25 +579,28 @@ class _OffersCategorisePageState extends State { .circular( 6)), ), - child: Texts( - model - .products[ - index] - .rxMessage != - null - ? model - .products[ - index] - .rxMessage - : "", - color: - Colors.white, + child: model.products[index].rxMessage != null + ? Texts( + projectProvider.isArabic + ? model.products[index].rxMessagen + : model.products[index].rxMessage, + color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight - .w400, - ), + fontWeight: FontWeight.w400, + ): Texts("") +// Texts( +// model.products[index].rxMessage != null +// ? model.products[index].rxMessage +// : "", +// color: +// Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: +// FontWeight +// .w400, +// ), ), ], ), diff --git a/lib/pages/pharmacies/search_brands_page.dart b/lib/pages/pharmacies/search_brands_page.dart index db9dbcb6..7ffe8d26 100644 --- a/lib/pages/pharmacies/search_brands_page.dart +++ b/lib/pages/pharmacies/search_brands_page.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/brand_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -9,6 +10,7 @@ import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:provider/provider.dart'; class SearchBrandsPage extends StatefulWidget { @override @@ -22,6 +24,7 @@ class _SearchBrandsPageState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectProvider = Provider.of(context); return BaseView( onModelReady: (model) => model.searchProducts(), builder: (BuildContext context, model, Widget child) => @@ -60,7 +63,7 @@ class _SearchBrandsPageState extends State { RegExp regExp = RegExp(r'([A-Za-z0-9 a space])'); if (value.isEmpty) { TranslationBase.of(context).pleaseEnterProductName; - }else if (regExp.hasMatch(value)){ + }else if (!regExp.hasMatch(value)){ AppToast.showErrorToast(message: TranslationBase.of(context).noArabicLetters); } return null; @@ -112,7 +115,7 @@ class _SearchBrandsPageState extends State { model.searchList.length == 0 ? Container( child: Text( - 'no data' + model.searchList.length.toString()), + TranslationBase.of(context).noData + model.searchList.length.toString()), ) : Expanded( child: Container( @@ -128,8 +131,9 @@ class _SearchBrandsPageState extends State { Padding( padding: const EdgeInsets.all(8.0), child: Container( - child: Text( - model.searchList[index].name, + child: Text( projectProvider.isArabic + ? model.searchList[index].namen + :model.searchList[index].name, style: TextStyle(fontSize: 20), ), ), diff --git a/lib/pages/search_products_page.dart b/lib/pages/search_products_page.dart index b7f08378..8ec9f014 100644 --- a/lib/pages/search_products_page.dart +++ b/lib/pages/search_products_page.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; // import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; @@ -13,6 +14,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:flutter/services.dart'; +import 'package:provider/provider.dart'; import 'base/base_view.dart'; @@ -28,6 +30,7 @@ class _SearchProductsPageState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectProvider = Provider.of(context); return BaseView( onModelReady: (model) => model.clearSearchList(), builder: (BuildContext context, PharmacyCategoriseViewModel model, @@ -67,7 +70,7 @@ class _SearchProductsPageState extends State { if (value.isEmpty) { TranslationBase.of(context) .pleaseEnterProductName; - } else if (regExp.hasMatch(value)) { + } else if (!regExp.hasMatch(value)) { AppToast.showErrorToast( message: TranslationBase.of(context) .noArabicLetters); @@ -220,19 +223,29 @@ class _SearchProductsPageState extends State { Radius.circular( 6)), ), - child: Texts( - model.searchList[index] - .rxMessage != - null - ? model - .searchList[index] - .rxMessage - : "", + child: model.searchList[index].rxMessage != null + ? Texts( + projectProvider.isArabic + ? model.searchList[index].rxMessagen + : model.searchList[index].rxMessage, color: Colors.white, regular: true, fontSize: 10, fontWeight: FontWeight.w400, - ), + ): Texts(""), +// Texts( +// model.searchList[index] +// .rxMessage != +// null +// ? model +// .searchList[index] +// .rxMessage +// : "", +// color: Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: FontWeight.w400, +// ), ), ], ), @@ -245,9 +258,11 @@ class _SearchProductsPageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts( - model - .searchList[index].name, + Texts(projectProvider.isArabic + ? model.searchList[index].namen + :model.searchList[index].name, + + // model.searchList[index].name, regular: true, fontSize: 12, fontWeight: FontWeight.w400, diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 178b511b..d5309383 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -884,7 +884,7 @@ class _SubCategorisePageState extends State { Padding( padding: const EdgeInsets.all(8.0), child: Text( - 'There is no data', + TranslationBase.of(context).noData, style: TextStyle(fontSize: 30), ), ) From 65aac99806e03753eec4aa8e5d1e26cd1d60c43f Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 10 Nov 2021 10:44:00 +0200 Subject: [PATCH 51/70] fix Availabilty part --- .../product-details/footor/footer-widget.dart | 8 +------- .../screens/product-details/product-detail.dart | 16 +++++++++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart index 72399498..644ab693 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -209,13 +209,7 @@ class _FooterWidgetState extends State { ); } else { await widget.addToShoppingCartFunction(quantity: widget.quantity, itemID: widget.item.id, model: widget.model); - // Navigator.of(context).pushNamed( - // CART_ORDER_PAGE, - // ); - Navigator.push( - context, - FadePage(page: CartOrderPage()), - ); + } }, fontWeight: FontWeight.w600, diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index b1e6aff9..6a8ac3ea 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart' import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.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,6 +15,7 @@ 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/progress_indicator/app_circular_progress_Indeicator.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -113,8 +115,7 @@ class __ProductDetailPageState extends State { isInWishList: isInWishList, addToCartFunction: addToCartFunction, ), - body: model.state == ViewState.Idle - ? SingleChildScrollView( + body: SingleChildScrollView( child: Column( children: [ Container( @@ -311,9 +312,9 @@ class __ProductDetailPageState extends State { ) ], ), - ) - : AppCircularProgressIndicator(), - bottomSheet: model.state == ViewState.Idle + ), + // : AppCircularProgressIndicator(), + bottomSheet: model.state == ViewState.Idle || model.state == ViewState.ErrorLocal ? FooterWidget( model.isStockAvailable, widget.product.orderMaximumQuantity, @@ -334,6 +335,11 @@ class __ProductDetailPageState extends State { GifLoaderDialogUtils.showMyDialog(context); await model.addToCartData(quantity, itemID); GifLoaderDialogUtils.hideDialog(context); + if(model.state != ViewState.ErrorLocal) + Navigator.push( + context, + FadePage(page: CartOrderPage()), + ); } addToWishlistFunction({itemID, ProductDetailViewModel model}) async { From 05e4e7be45d8a56795db3b783ae5130b7212adc2 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 10 Nov 2021 12:27:50 +0200 Subject: [PATCH 52/70] fix bottom bar in cart page --- lib/pages/final_products_page.dart | 7 +- lib/pages/parent_categorise_page.dart | 3 +- .../product-details/product-detail.dart | 6 +- .../shared/product_details_app_bar.dart | 13 +- lib/pages/sub_categorise_page.dart | 4 +- lib/uitl/utils.dart | 252 ++++++++++++++---- lib/widgets/others/app_scaffold_widget.dart | 4 +- lib/widgets/pharmacy/product_tile.dart | 6 +- 8 files changed, 220 insertions(+), 75 deletions(-) diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index f65665b5..91e953ad 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -10,6 +10,7 @@ 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/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart' as utils ; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -21,6 +22,7 @@ import 'package:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; + dynamic languageID; class FinalProductsPage extends StatefulWidget { @@ -487,7 +489,10 @@ class _FinalProductsPageState extends State { GifLoaderDialogUtils.showMyDialog(context); await addToCartFunction(1, model.finalProducts[index].id); GifLoaderDialogUtils.hideDialog(context); - Navigator.push(context, FadePage(page: CartOrderPage())); + // Navigator.push(context, FadePage(page: CartOrderPage())); + utils.Utils.navigateToCartPage(); + + } else { AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); } diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 34567267..65d9ea1c 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -12,6 +12,7 @@ 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/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; @@ -859,7 +860,7 @@ class _ParentCategorisePageState extends State { GifLoaderDialogUtils.showMyDialog(context); await addToCartFunction(1, model.parentProducts[index].id); GifLoaderDialogUtils.hideDialog(context); - Navigator.push(context, FadePage(page: CartOrderPage())); + Utils.navigateToCartPage(); } else { AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); } diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index baa92648..c4c1b26c 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -12,6 +12,7 @@ import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/sh import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.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:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; @@ -336,10 +337,7 @@ class __ProductDetailPageState extends State { await model.addToCartData(quantity, itemID, context); GifLoaderDialogUtils.hideDialog(context); if(model.state != ViewState.ErrorLocal) - Navigator.push( - context, - FadePage(page: CartOrderPage()), - ); + Utils.navigateToCartPage(); } addToWishlistFunction({itemID, ProductDetailViewModel model}) async { 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 944e065c..f58438cf 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 @@ -2,9 +2,11 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart' import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; +import 'package:diplomaticquarterapp/pages/landing/landing_page_pharmcy.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/navigation_service.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/material.dart'; @@ -74,10 +76,13 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { icon: Icons.shopping_cart, color: Colors.grey[800], onPress: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => CartOrderPage()), - ); + + Navigator.pushAndRemoveUntil( + locator().navigatorKey.currentContext, MaterialPageRoute(builder: (context) => LandingPagePharmacy(currentTab: 3)), (Route r) => false); + // Navigator.push( + // context, + // MaterialPageRoute(builder: (context) => CartOrderPage()), + // ); }), if (Provider.of(context, listen: false) diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index d5309383..92b20476 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -10,6 +10,7 @@ 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/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; @@ -845,8 +846,7 @@ class _SubCategorisePageState extends State { GifLoaderDialogUtils.showMyDialog(context); await addToCartFunction(1, model.subProducts[index].id); GifLoaderDialogUtils.hideDialog(context); - Navigator.push(context, FadePage(page: CartOrderPage())); - } else { + Utils.navigateToCartPage(); } else { AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); } }), diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index d23b91b2..f20f4243 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -16,6 +16,7 @@ import 'package:diplomaticquarterapp/pages/MyAppointments/MyAppointments.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_approval_screen.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_card_screen.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart'; +import 'package:diplomaticquarterapp/pages/landing/landing_page_pharmcy.dart'; import 'package:diplomaticquarterapp/pages/medical/active_medications/ActiveMedicationsPage.dart'; import 'package:diplomaticquarterapp/pages/medical/allergies_page.dart'; import 'package:diplomaticquarterapp/pages/medical/ask_doctor/ask_doctor_home_page.dart'; @@ -44,13 +45,14 @@ import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; import '../Constants.dart'; +import '../locator.dart'; import 'app_shared_preferences.dart'; import 'app_toast.dart'; import 'gif_loader_dialog_utils.dart'; +import 'navigation_service.dart'; AppSharedPreferences sharedPref = new AppSharedPreferences(); - class Utils { // static ProgressDialog pr; @@ -66,8 +68,10 @@ class Utils { /// Check The Internet Connection static Future checkConnection() async { - ConnectivityResult connectivityResult = await (Connectivity().checkConnectivity()); - if ((connectivityResult == ConnectivityResult.mobile) || (connectivityResult == ConnectivityResult.wifi)) { + ConnectivityResult connectivityResult = + await (Connectivity().checkConnectivity()); + if ((connectivityResult == ConnectivityResult.mobile) || + (connectivityResult == ConnectivityResult.wifi)) { return true; } else { return false; @@ -131,11 +135,19 @@ class Utils { } static String getAppointmentTransID(int projectID, int clinicID, int appoNo) { - return projectID.toString() + '-' + clinicID.toString() + '-' + appoNo.toString(); + return projectID.toString() + + '-' + + clinicID.toString() + + '-' + + appoNo.toString(); } static String getAdvancePaymentTransID(int projectID, int fileNumber) { - return projectID.toString() + '-' + fileNumber.toString() + '-' + DateTime.now().millisecondsSinceEpoch.toString(); + return projectID.toString() + + '-' + + fileNumber.toString() + + '-' + + DateTime.now().millisecondsSinceEpoch.toString(); } bool validateIDBox(String value, type) { @@ -195,14 +207,22 @@ class Utils { } static validEmail(email) { - return RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+").hasMatch(email); + return RegExp( + r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+") + .hasMatch(email); } - static List myMedicalList({ProjectViewModel projectViewModel, BuildContext context, bool isLogin, count}) { + static List myMedicalList( + {ProjectViewModel projectViewModel, + BuildContext context, + bool isLogin, + count}) { List medical = List(); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(5) ? Navigator.push(context, FadePage(page: MyAppointments())) : null, + onTap: () => projectViewModel.havePrivilege(5) + ? Navigator.push(context, FadePage(page: MyAppointments())) + : null, child: isLogin ? Stack(children: [ Container( @@ -229,7 +249,11 @@ class Utils { borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), - child: Text(count.toString(), style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.0)), + child: Text(count.toString(), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 12.0)), ), ), ) @@ -247,7 +271,11 @@ class Utils { borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), - child: Text(count.toString(), style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.0)), + child: Text(count.toString(), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 12.0)), ), ), ) @@ -274,7 +302,9 @@ class Utils { } medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(7) ? Navigator.push(context, FadePage(page: RadiologyHomePage())) : null, + onTap: () => projectViewModel.havePrivilege(7) + ? Navigator.push(context, FadePage(page: RadiologyHomePage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).radiology, imagePath: 'radiology.svg', @@ -284,7 +314,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(12) ? Navigator.push(context, FadePage(page: HomePrescriptionsPage())) : null, + onTap: () => projectViewModel.havePrivilege(12) + ? Navigator.push(context, FadePage(page: HomePrescriptionsPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).medicines, imagePath: 'medicine_prescription.svg', @@ -310,7 +342,8 @@ class Utils { medical.add(InkWell( onTap: () { - if (projectViewModel.havePrivilege(48)) Navigator.push(context, FadePage(page: ActiveMedicationsPage())); + if (projectViewModel.havePrivilege(48)) + Navigator.push(context, FadePage(page: ActiveMedicationsPage())); }, child: MedicalProfileItem( title: TranslationBase.of(context).myMedical, @@ -329,12 +362,17 @@ class Utils { ), ) : null, - child: - MedicalProfileItem(title: TranslationBase.of(context).myDoctor, imagePath: 'my_doc.svg', subTitle: TranslationBase.of(context).myDoctorSubtitle, isEnable: projectViewModel.havePrivilege(6)), + child: MedicalProfileItem( + title: TranslationBase.of(context).myDoctor, + imagePath: 'my_doc.svg', + subTitle: TranslationBase.of(context).myDoctorSubtitle, + isEnable: projectViewModel.havePrivilege(6)), )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(14) ? Navigator.push(context, FadePage(page: MyInvoices())) : null, + onTap: () => projectViewModel.havePrivilege(14) + ? Navigator.push(context, FadePage(page: MyInvoices())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).invoicesList, imagePath: 'invoice_list.svg', @@ -344,7 +382,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(14) ? Navigator.push(context, FadePage(page: EyeMeasurementsPage())) : null, + onTap: () => projectViewModel.havePrivilege(14) + ? Navigator.push(context, FadePage(page: EyeMeasurementsPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).eye, imagePath: 'eye_measurement.svg', @@ -354,7 +394,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(22) ? Navigator.push(context, FadePage(page: InsuranceCard())) : null, + onTap: () => projectViewModel.havePrivilege(22) + ? Navigator.push(context, FadePage(page: InsuranceCard())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).insurance, imagePath: 'insurance_card.svg', @@ -375,7 +417,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(18) ? Navigator.push(context, FadePage(page: InsuranceApproval())) : null, + onTap: () => projectViewModel.havePrivilege(18) + ? Navigator.push(context, FadePage(page: InsuranceApproval())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).insuranceApproval, imagePath: 'insurance_approval.svg', @@ -385,7 +429,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(23) ? Navigator.push(context, FadePage(page: AllergiesPage())) : null, + onTap: () => projectViewModel.havePrivilege(23) + ? Navigator.push(context, FadePage(page: AllergiesPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).allergies, imagePath: 'allergies_diagnosed.svg', @@ -395,7 +441,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(26) ? Navigator.push(context, FadePage(page: MyVaccines())) : null, + onTap: () => projectViewModel.havePrivilege(26) + ? Navigator.push(context, FadePage(page: MyVaccines())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).myVaccines, imagePath: 'vaccine_list.svg', @@ -405,7 +453,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(20) ? Navigator.push(context, FadePage(page: HomeReportPage())) : null, + onTap: () => projectViewModel.havePrivilege(20) + ? Navigator.push(context, FadePage(page: HomeReportPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).medical, imagePath: 'medical_report.svg', @@ -415,7 +465,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(19) ? Navigator.push(context, FadePage(page: MonthlyReportsPage())) : null, + onTap: () => projectViewModel.havePrivilege(19) + ? Navigator.push(context, FadePage(page: MonthlyReportsPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).monthly, imagePath: 'monthly_report.svg', @@ -425,7 +477,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(16) ? Navigator.push(context, FadePage(page: PatientSickLeavePage())) : null, + onTap: () => projectViewModel.havePrivilege(16) + ? Navigator.push(context, FadePage(page: PatientSickLeavePage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).sick, imagePath: 'sick_leave.svg', @@ -435,7 +489,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(47) ? Navigator.push(context, FadePage(page: MyBalancePage())) : null, + onTap: () => projectViewModel.havePrivilege(47) + ? Navigator.push(context, FadePage(page: MyBalancePage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).myBalance, imagePath: 'balance_credit.svg', @@ -452,7 +508,9 @@ class Utils { // )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(24) ? Navigator.push(context, FadePage(page: MyTrackers())) : null, + onTap: () => projectViewModel.havePrivilege(24) + ? Navigator.push(context, FadePage(page: MyTrackers())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).myTrackers, imagePath: 'tracker.svg', @@ -462,7 +520,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(30) ? Navigator.push(context, FadePage(page: SmartWatchInstructions())) : null, + onTap: () => projectViewModel.havePrivilege(30) + ? Navigator.push(context, FadePage(page: SmartWatchInstructions())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).smartWatchesSubtitle, imagePath: 'smart_watch.svg', @@ -472,9 +532,14 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(28) ? Navigator.push(context, FadePage(page: AskDoctorHomPage())) : null, + onTap: () => projectViewModel.havePrivilege(28) + ? Navigator.push(context, FadePage(page: AskDoctorHomPage())) + : null, child: MedicalProfileItem( - title: TranslationBase.of(context).askYourSubtitle, imagePath: 'ask_doctor.svg', subTitle: TranslationBase.of(context).askYour, isEnable: projectViewModel.havePrivilege(28)), + title: TranslationBase.of(context).askYourSubtitle, + imagePath: 'ask_doctor.svg', + subTitle: TranslationBase.of(context).askYour, + isEnable: projectViewModel.havePrivilege(28)), )); if (projectViewModel.havePrivilege(32) || true) { @@ -484,13 +549,18 @@ class Utils { if (projectViewModel.isLogin && userData_ != null) { String patientID = userData_.patientID.toString(); GifLoaderDialogUtils.showMyDialog(context); - projectViewModel.platformBridge().connectHMGInternetWifi(patientID).then((value) => {GifLoaderDialogUtils.hideDialog(context)}).catchError((err) { + projectViewModel + .platformBridge() + .connectHMGInternetWifi(patientID) + .then((value) => {GifLoaderDialogUtils.hideDialog(context)}) + .catchError((err) { print(err.toString()); }); } else { AlertDialogBox( context: context, - confirmMessage: "Please login with your account first to use this feature", + confirmMessage: + "Please login with your account first to use this feature", okText: "OK", okFunction: () { AlertDialogBox.closeAlertDialog(context); @@ -507,7 +577,9 @@ class Utils { } medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(40) ? launch('whatsapp://send?phone=18885521858&text=') : null, + onTap: () => projectViewModel.havePrivilege(40) + ? launch('whatsapp://send?phone=18885521858&text=') + : null, child: MedicalProfileItem( title: TranslationBase.of(context).chatbot, imagePath: 'chatbot.svg', @@ -519,13 +591,17 @@ class Utils { return medical; } - - - static List myMedicalListHomePage({ProjectViewModel projectViewModel, BuildContext context, bool isLogin, count}) { + static List myMedicalListHomePage( + {ProjectViewModel projectViewModel, + BuildContext context, + bool isLogin, + count}) { List medical = List(); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(5) ? Navigator.push(context, FadePage(page: MyAppointments())) : null, + onTap: () => projectViewModel.havePrivilege(5) + ? Navigator.push(context, FadePage(page: MyAppointments())) + : null, child: isLogin ? Stack(children: [ MedicalProfileItem( @@ -548,7 +624,11 @@ class Utils { borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), - child: Text(count.toString(), style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.0)), + child: Text(count.toString(), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 12.0)), ), ), ) @@ -566,7 +646,11 @@ class Utils { borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), - child: Text(count.toString(), style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.0)), + child: Text(count.toString(), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 12.0)), ), ), ) @@ -593,7 +677,9 @@ class Utils { } medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(7) ? Navigator.push(context, FadePage(page: RadiologyHomePage())) : null, + onTap: () => projectViewModel.havePrivilege(7) + ? Navigator.push(context, FadePage(page: RadiologyHomePage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).radiology, imagePath: 'radiology.svg', @@ -603,7 +689,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(12) ? Navigator.push(context, FadePage(page: HomePrescriptionsPage())) : null, + onTap: () => projectViewModel.havePrivilege(12) + ? Navigator.push(context, FadePage(page: HomePrescriptionsPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).medicines, imagePath: 'medicine_prescription.svg', @@ -621,19 +709,24 @@ class Utils { ), ) : null, - child: - MedicalProfileItem(title: TranslationBase.of(context).myDoctor, imagePath: 'my_doc.svg', subTitle: TranslationBase.of(context).myDoctorSubtitle, isEnable: projectViewModel.havePrivilege(6)), + child: MedicalProfileItem( + title: TranslationBase.of(context).myDoctor, + imagePath: 'my_doc.svg', + subTitle: TranslationBase.of(context).myDoctorSubtitle, + isEnable: projectViewModel.havePrivilege(6)), )); return medical; } - static Widget loadNetworkImage({@required String url, BoxFit fitting = BoxFit.cover}) { + static Widget loadNetworkImage( + {@required String url, BoxFit fitting = BoxFit.cover}) { return CachedNetworkImage( placeholderFadeInDuration: Duration(milliseconds: 250), fit: fitting, imageUrl: url, - placeholder: (context, url) => Container(child: Center(child: CircularProgressIndicator())), + placeholder: (context, url) => + Container(child: Center(child: CircularProgressIndicator())), errorWidget: (context, url, error) { return Icon( Icons.error, @@ -650,6 +743,14 @@ class Utils { return route.runtimeType == equalsTo; } + static navigateToCartPage() { + Navigator.pushAndRemoveUntil( + locator().navigatorKey.currentContext, + MaterialPageRoute( + builder: (context) => LandingPagePharmacy(currentTab: 3)), + (Route r) => false); + } + static Widget tableColumnTitle(String text, {bool showDivider = true}) { return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -658,7 +759,12 @@ class Utils { SizedBox(height: 6), Text( text, - style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.48, height: 18 / 12), + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff2E303A), + letterSpacing: -0.48, + height: 18 / 12), ), SizedBox(height: 5), if (showDivider) @@ -671,16 +777,27 @@ class Utils { ); } - static Widget tableColumnValue(String text, {bool isLast = false, bool isCapitable = true, ProjectViewModel mProjectViewModel}) { - ProjectViewModel projectViewModel = mProjectViewModel ?? Provider.of(AppGlobal.context); + static Widget tableColumnValue(String text, + {bool isLast = false, + bool isCapitable = true, + ProjectViewModel mProjectViewModel}) { + ProjectViewModel projectViewModel = + mProjectViewModel ?? Provider.of(AppGlobal.context); return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ SizedBox(height: 12), Text( - isCapitable && !projectViewModel.isArabic ? text.toLowerCase().capitalizeFirstofEach : text, - style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), + isCapitable && !projectViewModel.isArabic + ? text.toLowerCase().capitalizeFirstofEach + : text, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff575757), + letterSpacing: -0.4, + height: 16 / 10), ), SizedBox(height: 12), if (!isLast) @@ -693,7 +810,8 @@ class Utils { ); } - static Widget tableColumnValueWithUnderLine(String text, {bool isLast = false, bool isCapitable = true}) { + static Widget tableColumnValueWithUnderLine(String text, + {bool isLast = false, bool isCapitable = true}) { return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, @@ -704,7 +822,13 @@ class Utils { isCapitable ? text.toLowerCase().capitalizeFirstofEach : text, maxLines: 1, minFontSize: 6, - style: TextStyle(decoration: TextDecoration.underline, fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xffD02127), letterSpacing: -0.48, height: 18 / 12), + style: TextStyle( + decoration: TextDecoration.underline, + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xffD02127), + letterSpacing: -0.48, + height: 18 / 12), ), SizedBox(height: 10), if (!isLast) @@ -718,7 +842,13 @@ class Utils { } } -Widget applyShadow({Color color = Colors.grey, double shadowOpacity = 0.5, double spreadRadius = 2, double blurRadius = 7, Offset offset = const Offset(2, 2), @required Widget child}) { +Widget applyShadow( + {Color color = Colors.grey, + double shadowOpacity = 0.5, + double spreadRadius = 2, + double blurRadius = 7, + Offset offset = const Offset(2, 2), + @required Widget child}) { return Container( decoration: BoxDecoration( boxShadow: [ @@ -735,7 +865,8 @@ Widget applyShadow({Color color = Colors.grey, double shadowOpacity = 0.5, doubl } Future userData() async { - var userData = AuthenticatedUser.fromJson(await AppSharedPreferences().getObject(MAIN_USER)); + var userData = AuthenticatedUser.fromJson( + await AppSharedPreferences().getObject(MAIN_USER)); return userData; } @@ -749,9 +880,12 @@ extension IndexedIterable on Iterable { openAppStore({String androidPackageName, String iOSAppID}) async { if (Platform.isAndroid) { - assert(!(androidPackageName == null), "Should have valid value in androidPackageName parameter"); - if ((await FlutterHmsGmsAvailability.isGmsAvailable)) launch("market://details?id=com.ejada.hmg"); - if ((await FlutterHmsGmsAvailability.isHmsAvailable)) launch("appmarket://details?id=com.ejada.hmg"); + assert(!(androidPackageName == null), + "Should have valid value in androidPackageName parameter"); + if ((await FlutterHmsGmsAvailability.isGmsAvailable)) + launch("market://details?id=com.ejada.hmg"); + if ((await FlutterHmsGmsAvailability.isHmsAvailable)) + launch("appmarket://details?id=com.ejada.hmg"); } else if (Platform.isIOS) { assert((iOSAppID == null), "Should have valid value in iOSAppID parameter"); launch("https://itunes.apple.com/kr/app/apple-store/$iOSAppID)"); @@ -777,7 +911,11 @@ String labelFrom({@required String className}) { extension StringExtension on String { String capitalize() { - return this.splitMapJoin(RegExp(r'\w+'), onMatch: (m) => '${m.group(0)}'.substring(0, 1).toUpperCase() + '${m.group(0)}'.substring(1).toLowerCase(), onNonMatch: (n) => ' '); + return this.splitMapJoin(RegExp(r'\w+'), + onMatch: (m) => + '${m.group(0)}'.substring(0, 1).toUpperCase() + + '${m.group(0)}'.substring(1).toLowerCase(), + onNonMatch: (n) => ' '); } } diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 8772a60e..0dc0f318 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -21,6 +21,7 @@ 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.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'; @@ -494,8 +495,7 @@ class AppBarWidgetState extends State { icon: Badge(badgeContent: Text(orderPreviewViewModel.cartResponse.quantityCount.toString()), child: Icon(Icons.shopping_cart)), color: Colors.white, onPressed: () { - // Navigator.of(context).popUntil(ModalRoute.withName('/')); - Navigator.of(context).popAndPushNamed(CART_ORDER_PAGE); + Utils.navigateToCartPage(); }) : Container(), (widget.isOfferPackages && widget.showOfferPackagesCart) diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index 70a727bf..b7293ce1 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-ord import 'package:diplomaticquarterapp/pages/pharmacy/order/ProductReview.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -165,10 +166,7 @@ class productTile extends StatelessWidget { GifLoaderDialogUtils.showMyDialog(context); await addToCartFunction(1, productID, context); GifLoaderDialogUtils.hideDialog(context); - Navigator.push( - context, - FadePage(page: CartOrderPage()), - ); + Utils.navigateToCartPage(); }, ), ], From 289e74fd0ad384411c703de5f6ba911925d1f0b6 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 10 Nov 2021 16:02:41 +0300 Subject: [PATCH 53/70] fixes --- lib/core/service/medical/prescriptions_service.dart | 3 +-- lib/pages/BookAppointment/BookConfirm.dart | 1 + .../screens/product-details/product-name-and-price.dart | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/core/service/medical/prescriptions_service.dart b/lib/core/service/medical/prescriptions_service.dart index 4349f218..0a7d9e68 100644 --- a/lib/core/service/medical/prescriptions_service.dart +++ b/lib/core/service/medical/prescriptions_service.dart @@ -225,13 +225,12 @@ class PrescriptionsService extends BaseService { }, body: _requestPrescriptionReportEnh.toJson()); } - Future updatePressOrderRC({@required int presOrderID, @required String patientID}) async { + Future updatePressOrderRC({@required int presOrderID}) async { hasError = false; Map body = Map(); body['Id'] = presOrderID; body['StatusId'] = 6; body['ClickButton'] = 14; - body['PatientID'] = patientID; await baseAppClient.post(UPDATE_PRESCRIPTION_ORDER_RC, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { hasError = true; super.error = error; diff --git a/lib/pages/BookAppointment/BookConfirm.dart b/lib/pages/BookAppointment/BookConfirm.dart index 585e862d..bdf387d6 100644 --- a/lib/pages/BookAppointment/BookConfirm.dart +++ b/lib/pages/BookAppointment/BookConfirm.dart @@ -88,6 +88,7 @@ class _BookConfirmState extends State { null, widget.doctor.noOfPatientsRate, "", + ), isNeedToShowButton: false, ), diff --git a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart index 78a9a88e..0f25b236 100644 --- a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart +++ b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart @@ -25,7 +25,7 @@ class ProductNameAndPrice extends StatefulWidget { AuthenticatedUserObject authenticatedUserObject = locator(); ProductNameAndPrice(this.context, this.item, - {this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, this.isStockAvailable, this.stockAvailability}); + {this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, this.isStockAvailable = true, this.stockAvailability}); @override _ProductNameAndPriceState createState() => _ProductNameAndPriceState(); @@ -56,7 +56,7 @@ class _ProductNameAndPriceState extends State { ), // SizedBox(width: 20), if (widget.authenticatedUserObject.isLogin) - widget.isStockAvailable && widget.customerId != null + !widget.isStockAvailable && widget.customerId != null ? InkWell( onTap: () => widget.notifyMeWhenAvailable(context, widget.item.id), child: Row(children: [ From a35e14908883ee3eadfb2faa983d01c532479742 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Wed, 10 Nov 2021 15:19:19 +0200 Subject: [PATCH 54/70] product pagination --- .../service/pharmacy_categorise_service.dart | 10 +- .../pharmacy_categorise_view_model.dart | 77 +- lib/pages/parent_categorise_page.dart | 1945 ++++++++++------- .../screens/cart-page/cart-order-page.dart | 2 +- pubspec.yaml | 3 + 5 files changed, 1253 insertions(+), 784 deletions(-) diff --git a/lib/core/service/pharmacy_categorise_service.dart b/lib/core/service/pharmacy_categorise_service.dart index 023d0859..3cc45680 100644 --- a/lib/core/service/pharmacy_categorise_service.dart +++ b/lib/core/service/pharmacy_categorise_service.dart @@ -143,11 +143,14 @@ class PharmacyCategoriseService extends BaseService { ); } - Future getParentProducts({String id}) async { + Future getParentProducts( + {String id, int pageNumber, bool isLoading = false}) async { hasError = false; - _parentProductsList.clear(); + if (isLoading == false) { + _parentProductsList.clear(); + } String endPoint = id != null - ? GET_PARENT_PRODUCTS + "$id" + '&page=1&limit=50' + ? GET_PARENT_PRODUCTS + "$id" + '&page=' + '$pageNumber' + '&limit=24' : GET_PARENT_PRODUCTS + ""; await baseAppClient.getPharmacy( endPoint, @@ -155,6 +158,7 @@ class PharmacyCategoriseService extends BaseService { response['products'].forEach((item) { _parentProductsList.add(PharmacyProduct.fromJson(item)); }); + //pageNumber++; }, onFailure: (String error, int statusCode) { hasError = true; diff --git a/lib/core/viewModels/pharmacy_categorise_view_model.dart b/lib/core/viewModels/pharmacy_categorise_view_model.dart index 153ec12e..7fb68431 100644 --- a/lib/core/viewModels/pharmacy_categorise_view_model.dart +++ b/lib/core/viewModels/pharmacy_categorise_view_model.dart @@ -10,20 +10,36 @@ import 'base_view_model.dart'; class PharmacyCategoriseViewModel extends BaseViewModel { bool hasError = false; - PharmacyCategoriseService _pharmacyCategoriseService = locator(); - List get categorise => _pharmacyCategoriseService.categoriseList; + int firstSubsetIndex = 0; + int inPatientPageSize = 20; + int lastSubsetIndex = 20; - List get categoriseParent => _pharmacyCategoriseService.parentCategoriseList; + List filteredInPatientItems = List(); + List filteredMyInPatientItems = List(); - List get parentProducts => _pharmacyCategoriseService.parentProductsList; + PharmacyCategoriseService _pharmacyCategoriseService = + locator(); - List get subCategorise => _pharmacyCategoriseService.subCategoriseList; + List get categorise => + _pharmacyCategoriseService.categoriseList; - List get subProducts => _pharmacyCategoriseService.subProductsList; + List get categoriseParent => + _pharmacyCategoriseService.parentCategoriseList; - List get finalProducts => _pharmacyCategoriseService.finalProducts; - List get brandsList => _pharmacyCategoriseService.brandsList; + List get parentProducts => + _pharmacyCategoriseService.parentProductsList; + + List get subCategorise => + _pharmacyCategoriseService.subCategoriseList; + + List get subProducts => + _pharmacyCategoriseService.subProductsList; + + List get finalProducts => + _pharmacyCategoriseService.finalProducts; + List get brandsList => + _pharmacyCategoriseService.brandsList; List get searchList => _pharmacyCategoriseService.searchList; @@ -81,7 +97,7 @@ class PharmacyCategoriseViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getCategoriseParent({String i}) async { + Future getCategoriseParent({String i, int pageIndex, bool isLoading}) async { hasError = false; // _insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); @@ -90,15 +106,16 @@ class PharmacyCategoriseViewModel extends BaseViewModel { error = _pharmacyCategoriseService.error; setState(ViewState.ErrorLocal); } else - await getParentProducts(i: i); - await getBrands(id: i); + await getBrands(id: i); + await getParentProducts(i: i, pageIndex: pageIndex, isLoading: isLoading); } - Future getParentProducts({String i}) async { + Future getParentProducts({String i, int pageIndex, bool isLoading}) async { hasError = false; // _insuranceCardService.clearInsuranceCard(); - setState(ViewState.Busy); - await _pharmacyCategoriseService.getParentProducts(id: i); + setState(ViewState.BusyLocal); + await _pharmacyCategoriseService.getParentProducts( + id: i, pageNumber: pageIndex, isLoading: isLoading); if (_pharmacyCategoriseService.hasError) { error = _pharmacyCategoriseService.error; setState(ViewState.ErrorLocal); @@ -142,11 +159,13 @@ class PharmacyCategoriseViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getFilteredProducts({String categoryId, String brandId, String min, String max}) async { + Future getFilteredProducts( + {String categoryId, String brandId, String min, String max}) async { hasError = false; // _insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); - await _pharmacyCategoriseService.getFilteredProducts(categoryId: categoryId, brandId: brandId, max: max, min: min); + await _pharmacyCategoriseService.getFilteredProducts( + categoryId: categoryId, brandId: brandId, max: max, min: min); if (_pharmacyCategoriseService.hasError) { error = _pharmacyCategoriseService.error; setState(ViewState.ErrorLocal); @@ -154,7 +173,8 @@ class PharmacyCategoriseViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getFilteredSubProducts({String categoryId, String brandId, String min, String max}) async { + Future getFilteredSubProducts( + {String categoryId, String brandId, String min, String max}) async { hasError = false; // _insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); @@ -221,4 +241,27 @@ class PharmacyCategoriseViewModel extends BaseViewModel { setState(ViewState.Idle); } } + + addOnFilteredList() { + if (lastSubsetIndex < parentProducts.length) { + firstSubsetIndex = firstSubsetIndex + + (parentProducts.length - lastSubsetIndex < inPatientPageSize - 1 + ? parentProducts.length - lastSubsetIndex + : inPatientPageSize - 1); + lastSubsetIndex = lastSubsetIndex + + (parentProducts.length - lastSubsetIndex < inPatientPageSize - 1 + ? parentProducts.length - lastSubsetIndex + : inPatientPageSize - 1); + filteredInPatientItems + .addAll(parentProducts.sublist(firstSubsetIndex, lastSubsetIndex)); + setState(ViewState.Idle); + } + } + + removeOnFilteredList() { + if (lastSubsetIndex - inPatientPageSize - 1 > 0) { + filteredInPatientItems.removeAt(lastSubsetIndex - inPatientPageSize - 1); + setState(ViewState.Idle); + } + } } diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index d8c2279c..6a59b122 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_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'; @@ -22,6 +23,7 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.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'; @@ -30,12 +32,14 @@ class ParentCategorisePage extends StatefulWidget { String id; String titleName; - AuthenticatedUserObject authenticatedUserObject = locator(); + AuthenticatedUserObject authenticatedUserObject = + locator(); ParentCategorisePage({this.id, this.titleName}); @override - _ParentCategorisePageState createState() => _ParentCategorisePageState(id: id, titleName: titleName); + _ParentCategorisePageState createState() => + _ParentCategorisePageState(id: id, titleName: titleName); } class _ParentCategorisePageState extends State { @@ -49,7 +53,6 @@ class _ParentCategorisePageState extends State { this.productID, }); - Map values = {'huusam': false, 'ali': false, 'noor': false}; bool checkedBrands = false; bool checkedCategorise = false; String categoriseName = "Personal Care"; @@ -61,83 +64,111 @@ class _ParentCategorisePageState extends State { size: 29.0, ); + int pageIndex = 1; + List entityList = List(); List entityListBrands = List(); + RefreshController controller = RefreshController(); + @override Widget build(BuildContext context) { TextEditingController minField = TextEditingController(); TextEditingController maxField = TextEditingController(); ProjectViewModel projectViewModel = Provider.of(context); return BaseView( - onModelReady: (model) => model.getCategoriseParent(i: id), + onModelReady: (model) => model.getCategoriseParent( + i: id, pageIndex: pageIndex, isLoading: false), allowAny: true, - builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => AppScaffold( - isPharmacy: true, - appBarTitle: titleName, - isBottomBar: true, - isShowAppBar: true, - backgroundColor: Colors.white, - isShowDecPage: false, - baseViewModel: model, - body: SingleChildScrollView( - child: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: Image.network( - id == '1' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089188_personal-care_2.png' - : id == '2' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089189_skin-care_2.png' - : id == '3' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089190_health-care_2.png' - : id == '4' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089191_sexual-health_2.png' - : id == '5' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089192_beauty_2.png' - : id == '6' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089193_baby-child_2.png' - : id == '7' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089194_vitamins-supplements_2.png' - : id == '8' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' - : id == '9' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' - : id == '10' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' - : '', - fit: BoxFit.fill, - height: 160.0, - width: double.infinity), - ), - if (model.categoriseParent.length > 8) - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: EdgeInsets.all(10.0), - child: InkWell( - child: Container( - child: Texts( - TranslationBase.of(context).viewCategorise, + builder: + (BuildContext context, PharmacyCategoriseViewModel model, + Widget child) => + AppScaffold( + isPharmacy: true, + appBarTitle: titleName, + isBottomBar: true, + isShowAppBar: true, + backgroundColor: Colors.white, + isShowDecPage: false, + baseViewModel: model, + body: SmartRefresher( + enablePullDown: false, + controller: controller, + enablePullUp: true, + onLoading: () async { + setState(() { + ++pageIndex; + }); + await model.getParentProducts( + pageIndex: pageIndex, i: id, isLoading: true); + if (model.state != ViewState.BusyLocal && + pageIndex < 5) { + controller.loadComplete(); + } else { + controller.loadFailed(); + } + }, + child: SingleChildScrollView( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Image.network( + id == '1' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089188_personal-care_2.png' + : id == '2' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089189_skin-care_2.png' + : id == '3' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089190_health-care_2.png' + : id == '4' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089191_sexual-health_2.png' + : id == '5' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089192_beauty_2.png' + : id == '6' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089193_baby-child_2.png' + : id == '7' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089194_vitamins-supplements_2.png' + : id == '8' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' + : id == '9' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' + : id == '10' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' + : '', + fit: BoxFit.fill, + height: 160.0, + width: double.infinity), + ), + if (model.categoriseParent.length > 8) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: EdgeInsets.all(10.0), + child: InkWell( + child: Container( + child: Texts( + TranslationBase.of(context) + .viewCategorise, // 'View All Categories', - fontWeight: FontWeight.w300, - ), - ), - onTap: () { - Navigator.push( - context, - FadePage( - page: SubCategoriseModalsheet( + fontWeight: FontWeight.w300, + ), + ), + onTap: () { + Navigator.push( + context, + FadePage( + page: + SubCategoriseModalsheet( // id: model.categorise[0].id, // titleName: model.categorise[0].name, - )), - ); + )), + ); // showModalBottomSheet( // isScrollControlled: true, // context: context, @@ -188,759 +219,1145 @@ class _ParentCategorisePageState extends State { // ); // }, // ); - }, - ), + }, + ), + ), + Icon(Icons.arrow_forward) + ], + ), + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + ], ), - Icon(Icons.arrow_forward) - ], - ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, - ), - ], - ), //Expanded widget heree if nassery - Padding( - padding: EdgeInsets.only(top: 35.0), - child: Container( - height: MediaQuery.of(context).size.height * 0.2, - child: Center( - child: ListView.builder( - scrollDirection: Axis.horizontal, - itemCount: model.categoriseParent.length > 8 ? 8 : model.categoriseParent.length, - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: EdgeInsets.symmetric(horizontal: 8.0), - child: InkWell( - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 13.0), - child: Container( - height: 60.0, - width: 65.0, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.orange.shade200.withOpacity(0.45), - ), - child: Center( - child: Icon( - Icons.apps_sharp, - size: 32.0, - ), + Padding( + padding: EdgeInsets.only(top: 35.0), + child: Container( + height: + MediaQuery.of(context).size.height * 0.2, + child: Center( + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: + model.categoriseParent.length > 8 + ? 8 + : model.categoriseParent.length, + itemBuilder: + (BuildContext context, int index) { + return Padding( + padding: EdgeInsets.symmetric( + horizontal: 8.0), + child: InkWell( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Padding( + padding: + EdgeInsets.symmetric( + horizontal: 13.0), + child: Container( + height: 60.0, + width: 65.0, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors + .orange.shade200 + .withOpacity(0.45), + ), + child: Center( + child: Icon( + Icons.apps_sharp, + size: 32.0, + ), + ), + ), + ), + Container( + width: + MediaQuery.of(context) + .size + .width * + 0.197, + // height: MediaQuery.of(context) + // .size + // .height * + // 0.08, + child: Center( + child: Texts( + projectViewModel + .isArabic + ? model + .categoriseParent[ + index] + .namen + : model + .categoriseParent[ + index] + .name, + fontSize: 13.4, + fontWeight: + FontWeight.w600, + maxLines: 3, + ), + ), + ), + ], ), + onTap: () { + Navigator.push( + context, + FadePage( + page: SubCategorisePage( + title: model + .categoriseParent[index] + .name, + id: model + .categoriseParent[index] + .id, + parentId: id, + )), + ); + print(id); + }, ), + ); + }), + ), + ), + ), + + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 8.0), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + InkWell( + child: Row( + children: [ + Icon( + Icons.wrap_text, ), - Container( - width: MediaQuery.of(context).size.width * 0.197, - // height: MediaQuery.of(context) - // .size - // .height * - // 0.08, - child: Center( - child: Texts( - projectViewModel.isArabic ? model.categoriseParent[index].namen : model.categoriseParent[index].name, - fontSize: 13.4, - fontWeight: FontWeight.w600, - maxLines: 3, - ), - ), + SizedBox( + width: 10.0, + ), + Texts( + 'Refine', + fontWeight: FontWeight.w600, ), ], ), onTap: () { - Navigator.push( - context, - FadePage( - page: SubCategorisePage( - title: model.categoriseParent[index].name, - id: model.categoriseParent[index].id, - parentId: id, - )), - ); - print(id); - }, - ), - ); - }), - ), - ), - ), - - Divider( - thickness: 1.0, - color: Colors.grey.shade400, - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Row( - children: [ - Icon( - Icons.wrap_text, - ), - SizedBox( - width: 10.0, - ), - Texts( - 'Refine', - fontWeight: FontWeight.w600, - ), - ], - ), - onTap: () { - showModalBottomSheet( - isScrollControlled: true, - context: context, - builder: (BuildContext context) { - return DraggableScrollableSheet( - initialChildSize: 0.95, - maxChildSize: 0.95, - minChildSize: 0.9, - builder: (BuildContext context, ScrollController scrollController) { - return SingleChildScrollView( - controller: scrollController, - child: Container( - color: Colors.white, - height: MediaQuery.of(context).size.height * 1.95, - child: Column( - children: [ - Padding( - padding: EdgeInsets.all(8.0), - child: Row( - children: [ - Icon( - Icons.wrap_text, - ), - SizedBox( - width: 10.0, - ), - Texts( - TranslationBase.of(context).refine, + showModalBottomSheet( + isScrollControlled: true, + context: context, + builder: (BuildContext context) { + return DraggableScrollableSheet( + initialChildSize: 0.95, + maxChildSize: 0.95, + minChildSize: 0.9, + builder: (BuildContext context, + ScrollController + scrollController) { + return SingleChildScrollView( + controller: + scrollController, + child: Container( + color: Colors.white, + height: + MediaQuery.of(context) + .size + .height * + 1.95, + child: Column( + children: [ + Padding( + padding: + EdgeInsets.all( + 8.0), + child: Row( + children: [ + Icon( + Icons + .wrap_text, + ), + SizedBox( + width: 10.0, + ), + Texts( + TranslationBase.of( + context) + .refine, // 'Refine', - fontWeight: FontWeight.w600, - ), - SizedBox( - width: 250.0, - ), - InkWell( - child: Texts( + fontWeight: + FontWeight + .w600, + ), + SizedBox( + width: 250.0, + ), + InkWell( + child: Texts( // 'Close', - TranslationBase.of(context).closeIt, - color: Colors.red, - fontWeight: FontWeight.w600, - fontSize: 15.0, + TranslationBase.of( + context) + .closeIt, + color: Colors + .red, + fontWeight: + FontWeight + .w600, + fontSize: + 15.0, + ), + onTap: () { + Navigator.pop( + context); + }, + ), + ], + ), ), - onTap: () { - Navigator.pop(context); - }, - ), - ], - ), - ), - Divider( - thickness: 1.0, - color: Colors.black12, - ), - Column( - children: [ - ExpansionTile( - title: Texts(TranslationBase.of(context).categorise), - children: [ - ProcedureListWidget( - model: model, - masterList: model.categoriseParent, - removeHistory: (item) { - setState(() { - entityList.remove(item); - }); - }, - addHistory: (history) { - setState(() { - entityList.add(history); - }); - }, - addSelectedHistories: () { - //TODO build your fun herr - // widget.addSelectedHistories(); - }, - isEntityListSelected: (master) => isEntityListSelected(master), - ) - ], - ), - Divider( - thickness: 1.0, - color: Colors.black12, - ), - ExpansionTile( - title: Texts(TranslationBase.of(context).brands), - children: [ - ProcedureListWidget( - model: model, - masterList: model.brandsList, - removeHistory: (item) { - setState(() { - entityListBrands.remove(item); - }); - }, - addHistory: (history) { - setState(() { - entityListBrands.add(history); - }); - }, - addSelectedHistories: () { - //TODO build your fun herr - // widget.addSelectedHistories(); - }, - isEntityListSelected: (master) => isEntityListSelectedBrands(master), - ) - ], - ), - Divider( - thickness: 1.0, - color: Colors.black12, - ), - ExpansionTile( - title: Texts(TranslationBase.of(context).price), - children: [ - Container( - color: Color(0xffEEEEEE), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.start, + Divider( + thickness: 1.0, + color: + Colors.black12, + ), + Column( + children: [ + ExpansionTile( + title: Texts( + TranslationBase.of( + context) + .categorise), + children: [ + ProcedureListWidget( + model: + model, + masterList: + model + .categoriseParent, + removeHistory: + (item) { + setState( + () { + entityList + .remove(item); + }); + }, + addHistory: + (history) { + setState( + () { + entityList + .add(history); + }); + }, + addSelectedHistories: + () { + //TODO build your fun herr + // widget.addSelectedHistories(); + }, + isEntityListSelected: + (master) => + isEntityListSelected(master), + ) + ], + ), + Divider( + thickness: 1.0, + color: Colors + .black12, + ), + ExpansionTile( + title: Texts( + TranslationBase.of( + context) + .brands), + children: [ + ProcedureListWidget( + model: + model, + masterList: + model + .brandsList, + removeHistory: + (item) { + setState( + () { + entityListBrands + .remove(item); + }); + }, + addHistory: + (history) { + setState( + () { + entityListBrands + .add(history); + }); + }, + addSelectedHistories: + () { + //TODO build your fun herr + // widget.addSelectedHistories(); + }, + isEntityListSelected: + (master) => + isEntityListSelectedBrands(master), + ) + ], + ), + Divider( + thickness: 1.0, + color: Colors + .black12, + ), + ExpansionTile( + title: Texts( + TranslationBase.of( + context) + .price), + children: [ + Container( + color: Color( + 0xffEEEEEE), + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + children: [ + Column( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Texts('Min'), + Container( + color: Colors.white, + width: 200, + height: 40, + child: TextFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), + ), + controller: minField, + ), + ), + ], + ), + Column( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + Texts('Max'), + Container( + color: Colors.white, + width: 200, + height: 40, + child: TextFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), + ), + controller: maxField, + ), + ), + ], + ), + ], + ), + ) + ], + ), + Divider( + thickness: 1.0, + color: Colors + .black12, + ), + SizedBox( + height: MediaQuery.of( + context) + .size + .height * + 0.4, + ), + Padding( + padding: + EdgeInsets + .all( + 8.0), + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceEvenly, children: [ - Texts('Min'), Container( - color: Colors.white, - width: 200, - height: 40, - child: TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), - ), - controller: minField, + width: + 100, + child: + Button( + label: TranslationBase.of(context) + .reset, + backgroundColor: + Colors.red, ), ), - ], - ), - Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Texts('Max'), + SizedBox( + width: 30, + ), Container( - color: Colors.white, - width: 200, - height: 40, - child: TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), - ), - controller: maxField, + width: + 200, + child: + Button( + onTap: + () async { + String + categoriesId = + ""; + for (CategoriseParentModel category + in entityList) { + if (categoriesId == + "") { + categoriesId = category.id; + } else { + categoriesId = "$categoriesId,${category.id}"; + } + } + String + brandIds = + ""; + for (CategoriseParentModel brand + in entityListBrands) { + if (brandIds == + "") { + brandIds = brand.id; + } else { + brandIds = "$brandIds,${brand.id}"; + } + } + + GifLoaderDialogUtils.showMyDialog( + context); + + await model.getFilteredProducts( + min: minField.text.toString(), + max: maxField.text.toString(), + categoryId: categoriesId, + brandId: brandIds); + GifLoaderDialogUtils.hideDialog( + context); + + Navigator.pop( + context); + }, + label: TranslationBase.of(context) + .apply, + backgroundColor: + Colors.green, ), ), ], ), - ], - ), - ) + ), + ], + ), ], ), - Divider( - thickness: 1.0, - color: Colors.black12, + ), + ); + }); + }, + ); + }, + ), + Row( + children: [ + Container( + height: 44.0, + child: VerticalDivider( + color: Colors.black45, + thickness: 1.0, +//width: 0.3, +// indent: 0.0, + ), + ), + Padding( + padding: EdgeInsets.all(8.0), + child: InkWell( + child: styleIcon, + onTap: () { + setState(() { + if (styleOne == true) { + styleOne = false; + styleTwo = true; + styleIcon = Icon( + Icons.auto_awesome_mosaic, + color: CustomColors.green, + size: 29.0, + ); + } else { + styleOne = true; + styleTwo = false; + styleIcon = Icon( + Icons.widgets_sharp, + color: CustomColors.green, + size: 29.0, + ); + } + }); + }, + ), + ), + ], + ), + ], + ), + ), + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + model.parentProducts.isNotEmpty + ? styleOne == true + ? 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, + ), ), - SizedBox( - height: MediaQuery.of(context).size.height * 0.4, + margin: + EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, ), - Padding( - padding: EdgeInsets.all(8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + 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, children: [ - Container( - width: 100, - child: Button( - label: TranslationBase.of(context).reset, - backgroundColor: Colors.red, - ), - ), - SizedBox( - width: 30, + Stack( + children: [ + 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: + Texts( + 'offer' + .toUpperCase(), + color: + Colors.red, + fontSize: + 13.0, + fontWeight: + FontWeight.w900, + ), + ), + 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 + ? MediaQuery.of(context) + .size + .width / + 5 + : 0, + padding: + EdgeInsets + .all( + 4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), + borderRadius: + BorderRadius.only( + topLeft: + Radius.circular(6)), + ), + child: Texts( + model.parentProducts[index].rxMessage != + null + ? model + .parentProducts[index] + .rxMessage + : "", + color: Colors + .white, + regular: + true, + fontSize: + 10, + fontWeight: + FontWeight + .w400, + ), + ), + ], ), Container( - width: 200, - child: Button( - onTap: () async { - String categoriesId = ""; - for (CategoriseParentModel category in entityList) { - if (categoriesId == "") { - categoriesId = category.id; - } else { - categoriesId = "$categoriesId,${category.id}"; - } - } - String brandIds = ""; - for (CategoriseParentModel brand in entityListBrands) { - if (brandIds == "") { - brandIds = brand.id; - } else { - brandIds = "$brandIds,${brand.id}"; - } - } - - GifLoaderDialogUtils.showMyDialog(context); - - await model.getFilteredProducts( - min: minField.text.toString(), max: maxField.text.toString(), categoryId: categoriesId, brandId: brandIds); - GifLoaderDialogUtils.hideDialog(context); - - Navigator.pop(context); - }, - label: TranslationBase.of(context).apply, - backgroundColor: Colors.green, + 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, + ) + ], + ), + ], ), ), ], ), ), - ], - ), - ], - ), - ), - ); - }); - }, - ); - }, - ), - Row( - children: [ - Container( - height: 44.0, - child: VerticalDivider( - color: Colors.black45, - thickness: 1.0, -//width: 0.3, -// indent: 0.0, - ), - ), - Padding( - padding: EdgeInsets.all(8.0), - child: InkWell( - child: styleIcon, - onTap: () { - setState(() { - if (styleOne == true) { - styleOne = false; - styleTwo = true; - styleIcon = Icon( - Icons.auto_awesome_mosaic, - color: CustomColors.green, - size: 29.0, - ); - } else { - styleOne = true; - styleTwo = false; - styleIcon = Icon( - Icons.widgets_sharp, - color: CustomColors.green, - size: 29.0, - ); - } - }); - }, - ), - ), - ], - ), - ], - ), - ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, - ), - model.parentProducts.isNotEmpty - ? styleOne == true - ? 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), - ), - color: Colors.white, - ), - padding: EdgeInsets.symmetric(horizontal: 0), - width: MediaQuery.of(context).size.width / 3, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Stack( + ), + 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: [ - 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, + Stack( + children: [ + Column( + children: [ + Container( + decoration: + BoxDecoration(), + child: + Padding( + padding: + EdgeInsets + .only( + left: 9.0, + top: 8.0, + right: + 10.0, + ), + ), ), - child: Texts( - 'offer'.toUpperCase(), - color: Colors.red, - fontSize: 13.0, - fontWeight: FontWeight.w900, + 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), ), - ), - 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, - ), + 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: Texts( + model.parentProducts[index].rxMessage != + null + ? model + .parentProducts[index] + .rxMessage + : "", + color: Colors + .white, + regular: + true, + fontSize: + 10, + fontWeight: + FontWeight + .w400, + ), + ), + ], + ), + ], ), Container( - width: model.parentProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 5 : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), - borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), - ), - child: Texts( - model.parentProducts[index].rxMessage != null ? model.parentProducts[index].rxMessage : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, + margin: EdgeInsets + .symmetric( + horizontal: 0, + vertical: 0, ), - ), - ], - ), - 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: Column( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + SizedBox( + height: 4.0, ), - child: Center( + Container( + width: MediaQuery.of( + context) + .size + .width * + 0.635, child: Texts( - model.parentProducts[index].discountName, + projectViewModel + .isArabic + ? model + .parentProducts[ + index] + .namen + : model + .parentProducts[ + index] + .name, regular: true, - color: Colors.white, - fontSize: 10.4, + fontSize: + 13.2, + fontWeight: + FontWeight + .w500, + maxLines: 5, ), ), - ), - 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, + SizedBox( + height: 8.0, ), - 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: 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: [ + 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, + 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, + ) + ], + ), + ], ), - Texts( - "(${model.parentProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ) - ], - ), - ], + ), + widget.authenticatedUserObject + .isLogin + ? Container( + child: + IconButton( + icon: + Icon( + Icons + .shopping_cart, + size: + 18, + color: + CustomColors.green, + ), + 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(), + ], + ), ), + 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, ), - widget.authenticatedUserObject.isLogin - ? Container( - child: IconButton( - icon: Icon( - Icons.shopping_cart, - size: 18, - color: CustomColors.green, - ), - 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(), - ], - ), + ), + Padding( + padding: + const EdgeInsets.all(8.0), + child: Text( + '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( - 'There is no data', - style: TextStyle(fontSize: 30), - ), - ) - ], - ), - ), - ), - ) - ], - ), - ), - ), - )); + ) + ], + ), + ), + ), + ))); } addToCartFunction(quantity, itemID) async { @@ -949,7 +1366,8 @@ class _ParentCategorisePageState extends State { } bool isEntityListSelected(CategoriseParentModel masterKey) { - Iterable history = entityList.where((element) => masterKey.id == element.id); + Iterable history = + entityList.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } @@ -957,7 +1375,8 @@ class _ParentCategorisePageState extends State { } bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { - Iterable history = entityListBrands.where((element) => masterKey.id == element.id); + Iterable history = + entityListBrands.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } 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 a2f3ba6c..b246e7d9 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -56,7 +56,7 @@ class _CartOrderPageState extends State { showHomeAppBarIcon: false, isShowDecPage: false, isMainPharmacyPages: true, - //isBottomBar: true, + isBottomBar: true, showPharmacyCart: true, baseViewModel: model, backgroundColor: Colors.white, diff --git a/pubspec.yaml b/pubspec.yaml index da332f80..57c417a8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,6 +42,9 @@ dependencies: # Flutter Html View flutter_html: ^1.2.0 + # Pagnation + pull_to_refresh: ^1.6.2 + # Native flutter_device_type: ^0.2.0 local_auth: ^0.6.2+3 From 307e488a0ec6a5a066731f38c177f127b60954a5 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Wed, 10 Nov 2021 15:42:45 +0200 Subject: [PATCH 55/70] pharmacy product pagination --- lib/pages/sub_categorise_page.dart | 658 +++++++++++++++++++++-------- 1 file changed, 491 insertions(+), 167 deletions(-) diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 9d2a1f6b..64437611 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -13,6 +13,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'; @@ -27,12 +28,14 @@ class SubCategorisePage extends StatefulWidget { String title; String parentId; - AuthenticatedUserObject authenticatedUserObject = locator(); + AuthenticatedUserObject authenticatedUserObject = + locator(); SubCategorisePage({this.id, this.parentId, this.title}); @override - _SubCategorisePageState createState() => _SubCategorisePageState(id: id, title: title, parentId: parentId); + _SubCategorisePageState createState() => + _SubCategorisePageState(id: id, title: title, parentId: parentId); } class _SubCategorisePageState extends State { @@ -60,13 +63,17 @@ class _SubCategorisePageState extends State { TextEditingController minField = TextEditingController(); TextEditingController maxField = TextEditingController(); return BaseView( + allowAny: true, onModelReady: (model) => model.getSubCategorise(i: id), - builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( + builder: (BuildContext context, PharmacyCategoriseViewModel model, + Widget child) => + AppScaffold( appBarTitle: title, isBottomBar: false, isShowAppBar: true, - backgroundColor: Colors.white, + isPharmacy: true, isShowDecPage: false, + backgroundColor: Colors.white, baseViewModel: model, body: SingleChildScrollView( child: Container( @@ -93,7 +100,8 @@ class _SubCategorisePageState extends State { ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' : parentId == '9' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' - : parentId == '10' + : parentId == + '10' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' : '', fit: BoxFit.fill, @@ -105,12 +113,14 @@ class _SubCategorisePageState extends State { children: [ InkWell( child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Padding( padding: EdgeInsets.all(10.0), child: Container( - child: Texts(TranslationBase.of(context).viewCategorise), + child: Texts(TranslationBase.of(context) + .viewCategorise), ), ), Icon(Icons.arrow_forward) @@ -122,21 +132,30 @@ class _SubCategorisePageState extends State { context: context, builder: (BuildContext context) { return Container( - height: MediaQuery.of(context).size.height * 0.89, + height: + MediaQuery.of(context).size.height * + 0.89, color: Colors.white, child: Center( child: ListView.builder( scrollDirection: Axis.vertical, - itemCount: model.subCategorise.length, - itemBuilder: (BuildContext context, int index) { + itemCount: + model.subCategorise.length, + itemBuilder: (BuildContext context, + int index) { return Container( child: Padding( padding: EdgeInsets.all(8.0), child: InkWell( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ - Texts(model.subCategorise[index].name), + Texts(model + .subCategorise[ + index] + .name), Divider( thickness: 0.6, color: Colors.black12, @@ -147,8 +166,12 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: FinalProductsPage( - id: model.subCategorise[index].id, + page: + FinalProductsPage( + id: model + .subCategorise[ + index] + .id, ), ), ); @@ -181,19 +204,23 @@ class _SubCategorisePageState extends State { itemCount: model.subCategorise.length, itemBuilder: (BuildContext context, int index) { return Padding( - padding: EdgeInsets.symmetric(horizontal: 8.0), + padding: + EdgeInsets.symmetric(horizontal: 8.0), child: InkWell( child: Column( - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ Padding( - padding: EdgeInsets.symmetric(horizontal: 13.0), + padding: EdgeInsets.symmetric( + horizontal: 13.0), child: Container( height: 60.0, width: 65.0, decoration: BoxDecoration( shape: BoxShape.circle, - color: Colors.orange.shade200.withOpacity(0.45), + color: Colors.orange.shade200 + .withOpacity(0.45), ), child: Center( child: Icon( @@ -204,8 +231,14 @@ class _SubCategorisePageState extends State { ), ), Container( - width: MediaQuery.of(context).size.width * 0.17, - height: MediaQuery.of(context).size.height * 0.10, + width: MediaQuery.of(context) + .size + .width * + 0.17, + height: MediaQuery.of(context) + .size + .height * + 0.10, child: Center( child: Texts( model.subCategorise[index].name, @@ -266,16 +299,21 @@ class _SubCategorisePageState extends State { initialChildSize: 0.95, maxChildSize: 0.95, minChildSize: 0.9, - builder: (BuildContext context, ScrollController scrollController) { + builder: (BuildContext context, + ScrollController scrollController) { return SingleChildScrollView( controller: scrollController, child: Container( color: Colors.white, - height: MediaQuery.of(context).size.height * 1.95, + height: MediaQuery.of(context) + .size + .height * + 1.95, child: Column( children: [ Padding( - padding: EdgeInsets.all(8.0), + padding: + EdgeInsets.all(8.0), child: Row( children: [ Icon( @@ -285,23 +323,30 @@ class _SubCategorisePageState extends State { width: 10.0, ), Texts( - TranslationBase.of(context).refine, + TranslationBase.of( + context) + .refine, // 'Refine', - fontWeight: FontWeight.w600, + fontWeight: + FontWeight.w600, ), SizedBox( width: 250.0, ), InkWell( child: Texts( - TranslationBase.of(context).closeIt, + TranslationBase.of( + context) + .closeIt, // 'Close', color: Colors.red, - fontWeight: FontWeight.w600, + fontWeight: + FontWeight.w600, fontSize: 15.0, ), onTap: () { - Navigator.pop(context); + Navigator.pop( + context); }, ), ], @@ -314,26 +359,39 @@ class _SubCategorisePageState extends State { Column( children: [ ExpansionTile( - title: Texts(TranslationBase.of(context).categorise), + title: Texts( + TranslationBase.of( + context) + .categorise), children: [ ProcedureListWidget( model: model, - masterList: model.subCategorise, - removeHistory: (item) { + masterList: model + .subCategorise, + removeHistory: + (item) { setState(() { - entityList.remove(item); + entityList + .remove( + item); }); }, - addHistory: (history) { + addHistory: + (history) { setState(() { - entityList.add(history); + entityList.add( + history); }); }, - addSelectedHistories: () { + addSelectedHistories: + () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: (master) => isEntityListSelected(master), + isEntityListSelected: + (master) => + isEntityListSelected( + master), ) ], ), @@ -342,26 +400,40 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts(TranslationBase.of(context).brands), + title: Texts( + TranslationBase.of( + context) + .brands), children: [ ProcedureListWidget( model: model, - masterList: model.brandsList, - removeHistory: (item) { + masterList: model + .brandsList, + removeHistory: + (item) { setState(() { - entityListBrands.remove(item); + entityListBrands + .remove( + item); }); }, - addHistory: (history) { + addHistory: + (history) { setState(() { - entityListBrands.add(history); + entityListBrands + .add( + history); }); }, - addSelectedHistories: () { + addSelectedHistories: + () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: (master) => isEntityListSelectedBrands(master), + isEntityListSelected: + (master) => + isEntityListSelectedBrands( + master), ) ], ), @@ -370,43 +442,69 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts(TranslationBase.of(context).price), + title: Texts( + TranslationBase.of( + context) + .price), children: [ Container( - color: Color(0xffEEEEEE), + color: Color( + 0xffEEEEEE), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + mainAxisAlignment: + MainAxisAlignment + .spaceAround, children: [ Column( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .start, children: [ - Texts('Min'), + Texts( + 'Min'), Container( - color: Colors.white, - width: 200, - height: 40, - child: TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), + color: Colors + .white, + width: + 200, + height: + 40, + child: + TextFormField( + decoration: + InputDecoration( + border: + OutlineInputBorder(), ), - controller: minField, + controller: + minField, ), ), ], ), Column( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .start, children: [ - Texts('Max'), + Texts( + 'Max'), Container( - color: Colors.white, - width: 200, - height: 40, - child: TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), + color: Colors + .white, + width: + 200, + height: + 40, + child: + TextFormField( + decoration: + InputDecoration( + border: + OutlineInputBorder(), ), - controller: maxField, + controller: + maxField, ), ), ], @@ -421,20 +519,31 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), SizedBox( - height: MediaQuery.of(context).size.height * 0.4, + height: MediaQuery.of( + context) + .size + .height * + 0.4, ), Padding( - padding: EdgeInsets.all(8.0), + padding: + EdgeInsets.all(8.0), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisAlignment: + MainAxisAlignment + .spaceEvenly, children: [ Expanded( child: Container( width: 100, child: Button( - label: TranslationBase.of(context).reset, + label: TranslationBase.of( + context) + .reset, // 'Reset', - backgroundColor: Colors.red, + backgroundColor: + Colors + .red, ), ), ), @@ -444,33 +553,66 @@ class _SubCategorisePageState extends State { Container( width: 200, child: Button( - onTap: () async { - String categoriesId = ""; - for (CategoriseParentModel category in entityList) { - if (categoriesId == "") { - categoriesId = category.id; + onTap: + () async { + String + categoriesId = + ""; + for (CategoriseParentModel category + in entityList) { + if (categoriesId == + "") { + categoriesId = + category + .id; } else { - categoriesId = "$categoriesId,${category.id}"; + categoriesId = + "$categoriesId,${category.id}"; } } - String brandIds = ""; - for (CategoriseParentModel brand in entityListBrands) { - if (brandIds == "") { - brandIds = brand.id; + String + brandIds = + ""; + for (CategoriseParentModel brand + in entityListBrands) { + if (brandIds == + "") { + brandIds = + brand + .id; } else { - brandIds = "$brandIds,${brand.id}"; + brandIds = + "$brandIds,${brand.id}"; } } - GifLoaderDialogUtils.showMyDialog(context); + GifLoaderDialogUtils + .showMyDialog( + context); await model.getFilteredSubProducts( - min: minField.text.toString(), max: maxField.text.toString(), categoryId: categoriesId, brandId: brandIds); - GifLoaderDialogUtils.hideDialog(context); - Navigator.pop(context); + min: minField + .text + .toString(), + max: maxField + .text + .toString(), + categoryId: + categoriesId, + brandId: + brandIds); + GifLoaderDialogUtils + .hideDialog( + context); + Navigator.pop( + context); }, - label: TranslationBase.of(context).apply, + label: TranslationBase.of( + context) + .apply, // 'Apply', - backgroundColor: Colors.green, + backgroundColor: + Colors + .green, ), ), ], @@ -537,22 +679,30 @@ class _SubCategorisePageState extends State { model.subProducts.isNotEmpty ? styleOne == true ? Container( - height: model.subProducts.length * MediaQuery.of(context).size.height * 0.15, + height: model.subProducts.length * + MediaQuery.of(context).size.height * + 0.15, child: GridView.builder( physics: NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 0.5, mainAxisSpacing: 2.0, childAspectRatio: 0.9, ), itemCount: model.subProducts.length, - itemBuilder: (BuildContext context, int index) { + itemBuilder: + (BuildContext context, int index) { return NetworkBaseView( baseViewModel: model, child: InkWell( child: Card( - color: model.subProducts[index].discountName != null ? Color(0xffFFFF00) : Colors.white, + color: model.subProducts[index] + .discountName != + null + ? Color(0xffFFFF00) + : Colors.white, elevation: 0, shape: Border( right: BorderSide( @@ -578,62 +728,118 @@ class _SubCategorisePageState extends State { ), 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: 0), - width: MediaQuery.of(context).size.width / 3, + padding: EdgeInsets.symmetric( + horizontal: 0), + width: MediaQuery.of(context) + .size + .width / + 3, child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Stack( children: [ Container( - margin: EdgeInsets.fromLTRB(0, 16, 0, 0), - alignment: Alignment.center, + margin: EdgeInsets + .fromLTRB( + 0, 16, 0, 0), + alignment: + Alignment.center, child: Image.network( - model.subProducts[index].images.isNotEmpty - ? model.subProducts[index].images[0].thumb + model + .subProducts[ + index] + .images + .isNotEmpty + ? model + .subProducts[ + 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.subProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 5 : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), - borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), + width: model + .subProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5 + : 0, + padding: + EdgeInsets.all(4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), + borderRadius: + BorderRadius.only( + topLeft: Radius + .circular( + 6)), ), child: Texts( - model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", + model + .subProducts[ + index] + .rxMessage != + null + ? model + .subProducts[ + index] + .rxMessage + : "", color: Colors.white, regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight.w400, ), ), ], ), Container( - margin: EdgeInsets.symmetric( + margin: + EdgeInsets.symmetric( horizontal: 6, vertical: 0, ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Texts( - model.subProducts[index].name, + model + .subProducts[ + 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.subProducts[index].price}", bold: true, @@ -647,21 +853,37 @@ class _SubCategorisePageState extends State { // ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() // : 0, // forceStars: true), - RatingBar.readOnly( - initialRating: model.subProducts[index].approvedRatingSum.toDouble(), + RatingBar + .readOnly( + initialRating: model + .subProducts[ + 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, + filledColor: + Colors.yellow[ + 700], + emptyColor: + Colors.grey[ + 500], + isHalfAllowed: + true, + halfFilledIcon: + Icons + .star_half, + filledIcon: + Icons.star, + emptyIcon: + Icons.star, ), Texts( "(${model.subProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight + .w400, ) ], ), @@ -676,7 +898,9 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage(model.subProducts[index]), + page: ProductDetailPage( + model.subProducts[ + index]), )), }, )); @@ -684,11 +908,14 @@ class _SubCategorisePageState extends State { ), ) : Container( - height: model.subProducts.length * MediaQuery.of(context).size.height * 0.122, + height: model.subProducts.length * + MediaQuery.of(context).size.height * + 0.122, child: ListView.builder( physics: NeverScrollableScrollPhysics(), itemCount: model.subProducts.length, - itemBuilder: (BuildContext context, int index) { + itemBuilder: + (BuildContext context, int index) { return InkWell( child: Card( child: Row( @@ -698,9 +925,11 @@ class _SubCategorisePageState extends State { Column( children: [ Container( - decoration: BoxDecoration(), + decoration: + BoxDecoration(), child: Padding( - padding: EdgeInsets.only( + padding: + EdgeInsets.only( left: 9.0, top: 8.0, right: 10.0, @@ -708,33 +937,74 @@ class _SubCategorisePageState extends State { ), ), Container( - margin: EdgeInsets.fromLTRB(0, 0, 0, 0), - alignment: Alignment.center, - child: model.subProducts[index].images.isNotEmpty + margin: EdgeInsets + .fromLTRB( + 0, 0, 0, 0), + alignment: + Alignment.center, + child: model + .subProducts[ + index] + .images + .isNotEmpty ? Image.network( - model.subProducts[index].images[0].thumb, - fit: BoxFit.contain, - height: 70, - ) - : Text(TranslationBase.of(context).noImage), + model + .subProducts[ + index] + .images[0] + .thumb, + fit: BoxFit + .contain, + height: 70, + ) + : Text(TranslationBase + .of(context) + .noImage), ), ], ), Column( children: [ Container( - width: model.subProducts[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)), + width: model + .subProducts[ + 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.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", + model + .subProducts[ + index] + .rxMessage != + null + ? model + .subProducts[ + index] + .rxMessage + : "", color: Colors.white, regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight.w400, ), ), ], @@ -748,19 +1018,31 @@ class _SubCategorisePageState extends State { vertical: 0, ), child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ SizedBox( height: 4.0, ), Container( - width: MediaQuery.of(context).size.width * 0.65, + width: MediaQuery.of( + context) + .size + .width * + 0.65, child: Texts( - model.subProducts[index].name, + model + .subProducts[ + index] + .name, regular: true, fontSize: 13.2, - fontWeight: FontWeight.w500, + fontWeight: + FontWeight.w500, maxLines: 5, ), ), @@ -768,7 +1050,11 @@ class _SubCategorisePageState extends State { height: 8.0, ), Padding( - padding: const EdgeInsets.only(top: 4, bottom: 4), + padding: + const EdgeInsets + .only( + top: 4, + bottom: 4), child: Texts( "SAR ${model.subProducts[index].price}", bold: true, @@ -783,42 +1069,77 @@ class _SubCategorisePageState extends State { // : 0, // forceStars: true), RatingBar.readOnly( - initialRating: model.subProducts[index].approvedRatingSum.toDouble(), + initialRating: model + .subProducts[ + index] + .approvedRatingSum + .toDouble(), size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], + filledColor: Colors + .yellow[700], + emptyColor: Colors + .grey[500], isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + halfFilledIcon: + Icons.star_half, + filledIcon: + Icons.star, + emptyIcon: + Icons.star, ), Texts( "(${model.subProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight.w400, ) ], ), ], ), ), - widget.authenticatedUserObject.isLogin + widget.authenticatedUserObject + .isLogin ? Container( child: IconButton( icon: Icon( - Icons.shopping_cart, + Icons + .shopping_cart, size: 18, - color: CustomColors.green, + color: + CustomColors + .green, ), - onPressed: () async { - if (model.subProducts[index].rxMessage == null) { - GifLoaderDialogUtils.showMyDialog(context); - await addToCartFunction(1, model.subProducts[index].id); - GifLoaderDialogUtils.hideDialog(context); - Navigator.push(context, FadePage(page: CartOrderPage())); + onPressed: + () async { + if (model + .subProducts[ + index] + .rxMessage == + null) { + GifLoaderDialogUtils + .showMyDialog( + context); + await addToCartFunction( + 1, + model + .subProducts[ + index] + .id); + GifLoaderDialogUtils + .hideDialog( + context); + Navigator.push( + context, + FadePage( + page: + CartOrderPage())); } else { - AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); + AppToast.showErrorToast( + message: TranslationBase.of( + context) + .needPrescription); } }), ) @@ -830,7 +1151,8 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage(model.subProducts[index]), + page: ProductDetailPage( + model.subProducts[index]), )), }, ); @@ -872,7 +1194,8 @@ class _SubCategorisePageState extends State { } bool isEntityListSelected(CategoriseParentModel masterKey) { - Iterable history = entityList.where((element) => masterKey.id == element.id); + Iterable history = + entityList.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } @@ -880,7 +1203,8 @@ class _SubCategorisePageState extends State { } bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { - Iterable history = entityListBrands.where((element) => masterKey.id == element.id); + Iterable history = + entityListBrands.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } From f88864efd4ce2ef069ea95a9d5c178c755d91611 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 10 Nov 2021 16:20:34 +0200 Subject: [PATCH 56/70] fix calling missing APi --- .../pharmacy/pharmacyAddresses/PharmacyAddresses.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart index 85bc7cb8..5eb93ae4 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart @@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/AddAddress.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/widgets/buttons/borderedButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; @@ -121,12 +122,20 @@ class _PharmacyAddressesState extends State { backgroundColor: Color(0xFF5AB145), fontSize: 14, vPadding: 8, - handler: () { + handler: () async { //TODO Elham* widget.orderPreviewViewModel.paymentCheckoutData .address = Addresses.fromJson( model.addresses[model.selectedAddressIndex].toJson()); + + GifLoaderDialogUtils.showMyDialog(context); + + + await widget.orderPreviewViewModel.getInformationsByAddress(widget.orderPreviewViewModel.user.patientIdentificationNo); + await widget.orderPreviewViewModel.getShoppingCart(); + // widget.changeMainState(); + GifLoaderDialogUtils.hideDialog(context); model.saveSelectedAddressLocally( model.addresses[model.selectedAddressIndex]); _navigateToPaymentOption(model); From a3fdb35c3047d7c6a034db3f8cafffb8cd891e6e Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 10 Nov 2021 17:25:07 +0300 Subject: [PATCH 57/70] fixes --- .../screens/cart-page/cart-order-preview.dart | 2 +- .../cart-page/payment_bottom_widget.dart | 2 +- .../pharmacyAddresses/PharmacyAddresses.dart | 64 ++++++------------- 3 files changed, 21 insertions(+), 47 deletions(-) diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart index cc2e1edc..8fab19c0 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart @@ -200,7 +200,7 @@ class _OrderPreviewPageState extends State { fontWeight: FontWeight.bold, ), Texts( - "${TranslationBase.of(context).sar} ${(widget.model.cartResponse.subtotal).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(widget.model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.bold, 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 389b4331..45e37abd 100644 --- a/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart @@ -40,7 +40,7 @@ class PaymentBottomWidget extends StatelessWidget { child: Row( children: [ Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", fontSize: 14, fontWeight: FontWeight.bold, color: Color(0xff929295), diff --git a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart index 85bc7cb8..4e3d7d9d 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart @@ -22,17 +22,14 @@ class PharmacyAddressesPage extends StatefulWidget { final bool isUpdate; - const PharmacyAddressesPage( - {Key key, this.orderPreviewViewModel, this.isUpdate = false, this.changeMainState}) - : super(key: key); + const PharmacyAddressesPage({Key key, this.orderPreviewViewModel, this.isUpdate = false, this.changeMainState}) : super(key: key); @override _PharmacyAddressesState createState() => _PharmacyAddressesState(); } class _PharmacyAddressesState extends State { - void navigateToAddressPage( - BuildContext ctx, PharmacyAddressesViewModel model, AddressInfo address) { + void navigateToAddressPage(BuildContext ctx, PharmacyAddressesViewModel model, AddressInfo address) { Navigator.push( ctx, FadePage( @@ -48,7 +45,7 @@ class _PharmacyAddressesState extends State { return BaseView( onModelReady: (model) => model.getAddressesList(), builder: (_, model, wi) => AppScaffold( - appBarTitle: widget.isUpdate?TranslationBase.of(context).changeAddress:"Add Address", + appBarTitle: widget.isUpdate ? TranslationBase.of(context).changeAddress : "Add Address", isShowAppBar: true, isPharmacy: true, baseViewModel: model, @@ -123,12 +120,8 @@ class _PharmacyAddressesState extends State { vPadding: 8, handler: () { //TODO Elham* - widget.orderPreviewViewModel.paymentCheckoutData - .address = - Addresses.fromJson( - model.addresses[model.selectedAddressIndex].toJson()); - model.saveSelectedAddressLocally( - model.addresses[model.selectedAddressIndex]); + widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[model.selectedAddressIndex].toJson()); + model.saveSelectedAddressLocally(model.addresses[model.selectedAddressIndex]); _navigateToPaymentOption(model); }, ), @@ -141,15 +134,13 @@ class _PharmacyAddressesState extends State { } _navigateToPaymentOption(model) { - if(widget.isUpdate) { - print("sfsf"); - + if (widget.isUpdate) { widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[model.selectedAddressIndex].toJson()); widget.changeMainState(); Navigator.pop(context); - return; } + Navigator.push( context, FadePage( @@ -159,8 +150,7 @@ class _PharmacyAddressesState extends State { setState(() { if (result != null) { var paymentOption = result; - widget.orderPreviewViewModel.paymentCheckoutData.paymentOption = - paymentOption; + widget.orderPreviewViewModel.paymentCheckoutData.paymentOption = paymentOption; } // widget.changeMainState(); }) @@ -175,8 +165,7 @@ class AddressItemWidget extends StatelessWidget { final bool isSelected; final Function(AddressInfo) onTabEditAddress; - AddressItemWidget(this.model, this.address, this.selectAddress, - this.isSelected, this.onTabEditAddress); + AddressItemWidget(this.model, this.address, this.selectAddress, this.isSelected, this.onTabEditAddress); @override Widget build(BuildContext context) { @@ -202,18 +191,13 @@ class AddressItemWidget extends StatelessWidget { decoration: new BoxDecoration( color: !isSelected ? Colors.white : Colors.green, shape: BoxShape.circle, - border: Border.all( - color: Colors.grey, - style: BorderStyle.solid, - width: 1.0), + border: Border.all(color: Colors.grey, style: BorderStyle.solid, width: 1.0), ), child: Padding( padding: const EdgeInsets.all(0.0), child: Icon( Icons.check, - color: isSelected - ? Colors.white - : Colors.transparent, + color: isSelected ? Colors.white : Colors.transparent, size: 25, ), ), @@ -226,8 +210,7 @@ class AddressItemWidget extends StatelessWidget { Expanded( child: Container( child: Container( - margin: - EdgeInsets.symmetric(vertical: 12, horizontal: 12), + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -290,8 +273,7 @@ class AddressItemWidget extends StatelessWidget { ), ), Padding( - padding: - const EdgeInsets.symmetric(horizontal: 8), + padding: const EdgeInsets.symmetric(horizontal: 8), child: SizedBox( child: Container( width: 1, @@ -309,21 +291,13 @@ class AddressItemWidget extends StatelessWidget { ConfirmDialog dialog = new ConfirmDialog( context: context, title: "Are you sure want to delete", - confirmMessage: - "${address.address1} ${address.address2}", - okText: - TranslationBase.of(context).delete, - cancelText: TranslationBase.of(context) - .cancel_nocaps, + confirmMessage: "${address.address1} ${address.address2}", + okText: TranslationBase.of(context).delete, + cancelText: TranslationBase.of(context).cancel_nocaps, okFunction: () => { - model - .deleteAddresses(address) - .then((_) { - ConfirmDialog.closeAlertDialog( - context); - AppToast.showErrorToast( - message: - "Address has been deleted"); + model.deleteAddresses(address).then((_) { + ConfirmDialog.closeAlertDialog(context); + AppToast.showErrorToast(message: "Address has been deleted"); }) }, cancelFunction: () => {}); From b09bc3bef99593e0d7d8c66a1809bdb9723878bb Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Wed, 10 Nov 2021 16:27:25 +0200 Subject: [PATCH 58/70] merge dev to hussam pharmacy fix --- lib/config/config.dart | 477 ++++++++---- lib/pages/parent_categorise_page.dart | 608 +++++++++------ .../screens/cart-page/cart-order-page.dart | 354 +++++---- .../product-details/product-detail.dart | 402 +++++----- lib/pages/sub_categorise_page.dart | 720 +++++++++++++----- 5 files changed, 1603 insertions(+), 958 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 9214156f..229865e1 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -30,7 +30,6 @@ const PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapi/api/'; // const BASE_PHARMACY_URL = 'https://mdlaboratories.com/exacartapitest/api/'; // const PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapitest/api/'; - // RC API URL const RC_BASE_URL = 'https://livecare.hmg.com/'; @@ -43,7 +42,8 @@ const GET_GEO_ZONES = 'Services/Patients.svc/REST/GeoF_GetAllPoints'; const LOG_GEO_ZONES = 'Services/Patients.svc/REST/GeoF_InsertPatientFileInfo'; // Delivery Driver -const DRIVER_LOCATION = 'Services/Patients.svc/REST/PatientER_GetDriverLocation'; +const DRIVER_LOCATION = + 'Services/Patients.svc/REST/PatientER_GetDriverLocation'; //weather const WEATHER_INDICATOR = 'Services/Weather.svc/REST/GetCityInfo'; @@ -51,41 +51,60 @@ const WEATHER_INDICATOR = 'Services/Weather.svc/REST/GetCityInfo'; const GET_PRIVILEGE = 'Services/Patients.svc/REST/Service_Privilege'; // Wifi Credentials -const WIFI_CREDENTIALS = "Services/Patients.svc/Hmg_SMS_Get_By_ProjectID_And_PatientID"; +const WIFI_CREDENTIALS = + "Services/Patients.svc/Hmg_SMS_Get_By_ProjectID_And_PatientID"; ///Doctor -const GET_MY_DOCTOR = 'Services/Doctors.svc/REST/GetPatientDoctorAppointmentResult'; +const GET_MY_DOCTOR = + 'Services/Doctors.svc/REST/GetPatientDoctorAppointmentResult'; const GET_DOCTOR_PROFILE = 'Services/Doctors.svc/REST/GetDocProfiles'; -const GET_DOCTOR_PRE_POST_IMAGES = 'Services/Doctors.svc/REST/GetDoctorPrePostImages'; -const GET_DOCTOR_RATING_NOTES = 'Services/Doctors.svc/REST/dr_GetNotesDoctorRating'; -const GET_DOCTOR_RATING_DETAILS = 'Services/Doctors.svc/REST/dr_GetDoctorRatingDetails'; +const GET_DOCTOR_PRE_POST_IMAGES = + 'Services/Doctors.svc/REST/GetDoctorPrePostImages'; +const GET_DOCTOR_RATING_NOTES = + 'Services/Doctors.svc/REST/dr_GetNotesDoctorRating'; +const GET_DOCTOR_RATING_DETAILS = + 'Services/Doctors.svc/REST/dr_GetDoctorRatingDetails'; const GET_DOCTOR_RATING = 'Services/Doctors.svc/REST/dr_GetAvgDoctorRating'; ///Prescriptions const PRESCRIPTIONS = 'Services/Patients.svc/REST/GetPrescriptionApptList'; -const GET_PRESCRIPTIONS_ALL_ORDERS = 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; -const GET_PRESCRIPTION_REPORT = 'Services/Patients.svc/REST/INP_GetPrescriptionReport'; -const SEND_PRESCRIPTION_EMAIL = 'Services/Notifications.svc/REST/SendPrescriptionEmail'; -const GET_PRESCRIPTION_REPORT_ENH = 'Services/Patients.svc/REST/GetPrescriptionReport_enh'; +const GET_PRESCRIPTIONS_ALL_ORDERS = + 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; +const GET_PRESCRIPTION_REPORT = + 'Services/Patients.svc/REST/INP_GetPrescriptionReport'; +const SEND_PRESCRIPTION_EMAIL = + 'Services/Notifications.svc/REST/SendPrescriptionEmail'; +const GET_PRESCRIPTION_REPORT_ENH = + 'Services/Patients.svc/REST/GetPrescriptionReport_enh'; ///Lab Order const GET_Patient_LAB_ORDERS = 'Services/Patients.svc/REST/GetPatientLabOrders'; -const GET_Patient_LAB_SPECIAL_RESULT = 'Services/Patients.svc/REST/GetPatientLabSpecialResults'; -const SEND_LAB_RESULT_EMAIL = 'Services/Notifications.svc/REST/SendLabReportEmail'; -const GET_Patient_LAB_RESULT = 'Services/Patients.svc/REST/GetPatientLabResults'; -const GET_Patient_LAB_ORDERS_RESULT = 'Services/Patients.svc/REST/GetPatientLabOrdersResults'; -const SEND_COVID_LAB_RESULT_EMAIL = 'Services/Notifications.svc/REST/GenerateCOVIDReport'; -const COVID_PASSPORT_UPDATE = 'Services/Patients.svc/REST/Covid19_Certificate_PassportUpdate'; -const GET_PATIENT_PASSPORT_NUMBER = 'Services/Patients.svc/REST/Covid19_Certificate_GetPassport'; +const GET_Patient_LAB_SPECIAL_RESULT = + 'Services/Patients.svc/REST/GetPatientLabSpecialResults'; +const SEND_LAB_RESULT_EMAIL = + 'Services/Notifications.svc/REST/SendLabReportEmail'; +const GET_Patient_LAB_RESULT = + 'Services/Patients.svc/REST/GetPatientLabResults'; +const GET_Patient_LAB_ORDERS_RESULT = + 'Services/Patients.svc/REST/GetPatientLabOrdersResults'; +const SEND_COVID_LAB_RESULT_EMAIL = + 'Services/Notifications.svc/REST/GenerateCOVIDReport'; +const COVID_PASSPORT_UPDATE = + 'Services/Patients.svc/REST/Covid19_Certificate_PassportUpdate'; +const GET_PATIENT_PASSPORT_NUMBER = + 'Services/Patients.svc/REST/Covid19_Certificate_GetPassport'; /// const GET_PATIENT_ORDERS = 'Services/Patients.svc/REST/GetPatientRadOrders'; -const GET_PATIENT_LAB_ORDERS_BY_APPOINTMENT = 'Services/Patients.svc/REST/GetPatientLabResultsByAppointmentNo'; +const GET_PATIENT_LAB_ORDERS_BY_APPOINTMENT = + 'Services/Patients.svc/REST/GetPatientLabResultsByAppointmentNo'; -const GET_PATIENT_ORDERS_DETAILS = 'Services/Patients.svc/REST/Rad_UpdatePatientRadOrdersToRead'; +const GET_PATIENT_ORDERS_DETAILS = + 'Services/Patients.svc/REST/Rad_UpdatePatientRadOrdersToRead'; const GET_RAD_IMAGE_URL = 'Services/Patients.svc/Rest/GetRadImageURL'; -const SEND_RAD_REPORT_EMAIL = 'Services/Notifications.svc/REST/SendRadReportEmail'; +const SEND_RAD_REPORT_EMAIL = + 'Services/Notifications.svc/REST/SendRadReportEmail'; ///Feedback const SEND_FEEDBACK = 'Services/COCWS.svc/REST/InsertCOCItemInSPList'; @@ -97,28 +116,40 @@ const GET_PATIENT_AppointmentHistory = 'Services' '/Doctors.svc/REST/PateintHasAppoimentHistory_Async'; ///VITAL SIGN -const GET_PATIENT_VITAL_SIGN = 'Services/Doctors.svc/REST/Doctor_GetPatientVitalSign'; +const GET_PATIENT_VITAL_SIGN = + 'Services/Doctors.svc/REST/Doctor_GetPatientVitalSign'; ///Er Nearest -const GET_NEAREST_HOSPITAL = 'Services/Patients.svc/REST/Patient_GetProjectAvgERWaitingTime'; +const GET_NEAREST_HOSPITAL = + 'Services/Patients.svc/REST/Patient_GetProjectAvgERWaitingTime'; ///ED Online -const ER_GET_VISUAL_TRIAGE_QUESTIONS = "services/Doctors.svc/REST/ER_GetVisualTriageQuestions"; -const ER_SAVE_TRIAGE_INFORMATION = "services/Doctors.svc/REST/ER_SaveTriageInformation"; -const ER_GetPatientPaymentInformationForERClinic = "services/Doctors.svc/REST/ER_GetPatientPaymentInformationForERClinic"; +const ER_GET_VISUAL_TRIAGE_QUESTIONS = + "services/Doctors.svc/REST/ER_GetVisualTriageQuestions"; +const ER_SAVE_TRIAGE_INFORMATION = + "services/Doctors.svc/REST/ER_SaveTriageInformation"; +const ER_GetPatientPaymentInformationForERClinic = + "services/Doctors.svc/REST/ER_GetPatientPaymentInformationForERClinic"; ///Er Nearest -const GET_AMBULANCE_REQUEST = 'Services/Patients.svc/REST/PatientER_RRT_GetAllTransportationMethod'; -const GET_PATIENT_ALL_PRES_ORDERS = 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; -const GET_PICK_UP_REQUEST_BY_PRES_ORDER_ID = 'Services/Patients.svc/REST/PatientER_RRT_GetPickUpRequestByPresOrderID'; -const UPDATE_PRESS_ORDER = 'Services/Patients.svc/REST/PatientER_UpdatePresOrder'; -const INSERT_ER_INERT_PRES_ORDER = 'Services/Patients.svc/REST/PatientER_InsertPresOrder'; +const GET_AMBULANCE_REQUEST = + 'Services/Patients.svc/REST/PatientER_RRT_GetAllTransportationMethod'; +const GET_PATIENT_ALL_PRES_ORDERS = + 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; +const GET_PICK_UP_REQUEST_BY_PRES_ORDER_ID = + 'Services/Patients.svc/REST/PatientER_RRT_GetPickUpRequestByPresOrderID'; +const UPDATE_PRESS_ORDER = + 'Services/Patients.svc/REST/PatientER_UpdatePresOrder'; +const INSERT_ER_INERT_PRES_ORDER = + 'Services/Patients.svc/REST/PatientER_InsertPresOrder'; /// ER RRT const GET_ALL_RC_TRANSPORTATION = 'rc/api/Transportation/getalltransportation'; const GET_ALL_TRANSPORTATIONS_RC = 'rc/api/Transportation/getalltransportation'; -const GET_ALL_RRT_QUESTIONS = 'Services/Patients.svc/REST/PatientER_RRT_GetAllQuestions'; -const GET_RRT_SERVICE_PRICE = 'Services/Patients.svc/REST/PatientE_RealRRT_GetServicePrice'; +const GET_ALL_RRT_QUESTIONS = + 'Services/Patients.svc/REST/PatientER_RRT_GetAllQuestions'; +const GET_RRT_SERVICE_PRICE = + 'Services/Patients.svc/REST/PatientE_RealRRT_GetServicePrice'; const GET_ALL_TRANSPORTATIONS_ORDERS = 'rc/api/Transportation/get'; @@ -133,13 +164,15 @@ const GET_FINDUS_REQUEST = 'Services/Lists.svc/REST/Get_HMG_Locations'; const GET_LIVECHAT_REQUEST = 'Services/Patients.svc/REST/GetPatientICProjects'; ///babyInformation -const GET_BABYINFORMATION_REQUEST = 'Services/Community.svc/REST/GetBabyByUserID'; +const GET_BABYINFORMATION_REQUEST = + 'Services/Community.svc/REST/GetBabyByUserID'; ///Get Baby By User ID const GET_BABY_BY_USER_ID = 'Services/Community.svc/REST/GetBabyByUserID'; ///userInformation -const GET_USERINFORMATION_REQUEST = 'Services/Community.svc/REST/GetUserInformation_New'; +const GET_USERINFORMATION_REQUEST = + 'Services/Community.svc/REST/GetUserInformation_New'; ///Update email const UPDATE_PATENT_EMAIL = 'Services/Patients.svc/REST/UpdatePateintEmail'; @@ -161,24 +194,34 @@ const GET_TABLE_REQUEST = 'Services/Community.svc/REST/CreateVaccinationTable'; const GET_CITIES_REQUEST = 'Services/Lists.svc/REST/GetAllCities'; ///BloodDetails -const GET_BLOOD_REQUEST = 'services/PatientVarification.svc/REST/BloodDonation_GetBloodGroupDetails'; +const GET_BLOOD_REQUEST = + 'services/PatientVarification.svc/REST/BloodDonation_GetBloodGroupDetails'; -const SAVE_BLOOD_REQUEST = 'Services/PatientVarification.svc/REST/BloodDonation_RegisterBloodType'; +const SAVE_BLOOD_REQUEST = + 'Services/PatientVarification.svc/REST/BloodDonation_RegisterBloodType'; -const GET_BLOOD_AGREEMENT = 'Services/PatientVarification.svc/REST/CheckUserAgreementForBloodDonation'; -const SAVE_BLOOD_AGREEMENT = 'Services/PatientVarification.svc/REST/AddUserAgreementForBloodDonation'; +const GET_BLOOD_AGREEMENT = + 'Services/PatientVarification.svc/REST/CheckUserAgreementForBloodDonation'; +const SAVE_BLOOD_AGREEMENT = + 'Services/PatientVarification.svc/REST/AddUserAgreementForBloodDonation'; ///Reports const REPORTS = 'Services/Doctors.svc/REST/GetPatientMedicalReportStatusInfo'; -const INSERT_REQUEST_FOR_MEDICAL_REPORT = 'Services/Doctors.svc/REST/InsertRequestForMedicalReport'; -const SEND_MEDICAL_REPORT_EMAIL = 'Services/Notifications.svc/REST/SendMedicalReportEmail'; +const INSERT_REQUEST_FOR_MEDICAL_REPORT = + 'Services/Doctors.svc/REST/InsertRequestForMedicalReport'; +const SEND_MEDICAL_REPORT_EMAIL = + 'Services/Notifications.svc/REST/SendMedicalReportEmail'; ///Rate // const IS_LAST_APPOITMENT_RATED = 'Services/Doctors.svc/REST/IsLastAppoitmentRated'; -const IS_LAST_APPOITMENT_RATED = 'Services/Doctors.svc/REST/IsLastAppoitmentRated_Async'; -const GET_APPOINTMENT_DETAILS_BY_NO = 'Services/MobileNotifications.svc/REST/GetAppointmentDetailsByApptNo'; -const NEW_RATE_APPOINTMENT_URL = "Services/Doctors.svc/REST/AppointmentsRating_InsertAppointmentRate"; -const NEW_RATE_DOCTOR_URL = "Services/Doctors.svc/REST/DoctorsRating_InsertDoctorRate"; +const IS_LAST_APPOITMENT_RATED = + 'Services/Doctors.svc/REST/IsLastAppoitmentRated_Async'; +const GET_APPOINTMENT_DETAILS_BY_NO = + 'Services/MobileNotifications.svc/REST/GetAppointmentDetailsByApptNo'; +const NEW_RATE_APPOINTMENT_URL = + "Services/Doctors.svc/REST/AppointmentsRating_InsertAppointmentRate"; +const NEW_RATE_DOCTOR_URL = + "Services/Doctors.svc/REST/DoctorsRating_InsertDoctorRate"; const GET_QR_PARKING = 'Services/SWP.svc/REST/GetQRParkingByID'; @@ -186,7 +229,8 @@ const GET_QR_PARKING = 'Services/SWP.svc/REST/GetQRParkingByID'; const GET_CLINICS_LIST_URL = "Services/lists.svc/REST/GetClinicCentralized"; //URL to get active appointment list -const GET_ACTIVE_APPOINTMENTS_LIST_URL = "Services/Doctors.svc/Rest/Dr_GetAppointmentActiveNumber"; +const GET_ACTIVE_APPOINTMENTS_LIST_URL = + "Services/Doctors.svc/Rest/Dr_GetAppointmentActiveNumber"; //URL to get projects list const GET_PROJECTS_LIST = 'Services/Lists.svc/REST/GetProject'; @@ -195,93 +239,128 @@ const GET_PROJECTS_LIST = 'Services/Lists.svc/REST/GetProject'; const GET_DOCTORS_LIST_URL = "Services/Doctors.svc/REST/SearchDoctorsByTime"; //URL to dental doctors list -const GET_DENTAL_DOCTORS_LIST_URL = "Services/Doctors.svc/REST/Dental_DoctorChiefComplaintMapping"; +const GET_DENTAL_DOCTORS_LIST_URL = + "Services/Doctors.svc/REST/Dental_DoctorChiefComplaintMapping"; //URL to get doctor free slots const GET_DOCTOR_FREE_SLOTS = "Services/Doctors.svc/REST/GetDoctorFreeSlots"; //URL to insert appointment -const INSERT_SPECIFIC_APPOINTMENT = "Services/Doctors.svc/REST/InsertSpecificAppointment"; +const INSERT_SPECIFIC_APPOINTMENT = + "Services/Doctors.svc/REST/InsertSpecificAppointment"; //URL to get patient share -const GET_PATIENT_SHARE = "Services/Doctors.svc/REST/GetCheckinScreenAppointmentDetailsByAppointmentNO"; +const GET_PATIENT_SHARE = + "Services/Doctors.svc/REST/GetCheckinScreenAppointmentDetailsByAppointmentNO"; //URL to get patient appointment history -const GET_PATIENT_APPOINTMENT_HISTORY = "Services/Doctors.svc/REST/PateintHasAppoimentHistory"; +const GET_PATIENT_APPOINTMENT_HISTORY = + "Services/Doctors.svc/REST/PateintHasAppoimentHistory"; -const DOCTOR_SCHEDULE_URL = 'Services/Doctors.svc/REST/GetDoctorWorkingHoursTable'; +const DOCTOR_SCHEDULE_URL = + 'Services/Doctors.svc/REST/GetDoctorWorkingHoursTable'; -const SEND_REPORT_EYE_EMAIL = "Services/Notifications.svc/REST/SendGlassesPrescriptionEmail"; +const SEND_REPORT_EYE_EMAIL = + "Services/Notifications.svc/REST/SendGlassesPrescriptionEmail"; -const SEND_CONTACT_LENS_PRESCRIPTION_EMAIL = "Services/Notifications.svc/REST/SendContactLensPrescriptionEmail"; +const SEND_CONTACT_LENS_PRESCRIPTION_EMAIL = + "Services/Notifications.svc/REST/SendContactLensPrescriptionEmail"; //URL to get patient appointment curfew history // const GET_PATIENT_APPOINTMENT_CURFEW_HISTORY = "Services/Doctors.svc/REST/AppoimentHistoryForCurfew"; -const GET_PATIENT_APPOINTMENT_CURFEW_HISTORY = "Services/Doctors.svc/REST/AppoimentHistoryForCurfew_Async"; +const GET_PATIENT_APPOINTMENT_CURFEW_HISTORY = + "Services/Doctors.svc/REST/AppoimentHistoryForCurfew_Async"; //URL to confirm appointment -const CONFIRM_APPOINTMENT = "Services/MobileNotifications.svc/REST/ConfirmAppointment"; +const CONFIRM_APPOINTMENT = + "Services/MobileNotifications.svc/REST/ConfirmAppointment"; -const INSERT_VIDA_REQUEST = "Services/ER_VirtualCall.svc/REST/PatientER_VidaRequestInseart"; +const INSERT_VIDA_REQUEST = + "Services/ER_VirtualCall.svc/REST/PatientER_VidaRequestInseart"; //URL to cancel appointment const CANCEL_APPOINTMENT = "Services/Doctors.svc/REST/CancelAppointment"; //URL get appointment QR -const GENERATE_QR_APPOINTMENT = "Services/Doctors.svc/REST/GenerateQRAppointmentNo"; +const GENERATE_QR_APPOINTMENT = + "Services/Doctors.svc/REST/GenerateQRAppointmentNo"; //URL send email appointment QR -const EMAIL_QR_APPOINTMENT = "Services/Notifications.svc/REST/sendEmailForOnLineCheckin"; +const EMAIL_QR_APPOINTMENT = + "Services/Notifications.svc/REST/sendEmailForOnLineCheckin"; //URL check payment status -const CHECK_PAYMENT_STATUS = "Services/PayFort_Serv.svc/REST/GetRequestStatusByRequestID"; +const CHECK_PAYMENT_STATUS = + "Services/PayFort_Serv.svc/REST/GetRequestStatusByRequestID"; //URL create advance payment const CREATE_ADVANCE_PAYMENT = "Services/Doctors.svc/REST/CreateAdvancePayment"; -const HIS_CREATE_ADVANCE_PAYMENT = "Services/Patients.svc/REST/HIS_CreateAdvancePayment"; +const HIS_CREATE_ADVANCE_PAYMENT = + "Services/Patients.svc/REST/HIS_CreateAdvancePayment"; -const ADD_ADVANCE_NUMBER_REQUEST = 'Services/PayFort_Serv.svc/REST/AddAdvancedNumberRequest'; +const ADD_ADVANCE_NUMBER_REQUEST = + 'Services/PayFort_Serv.svc/REST/AddAdvancedNumberRequest'; -const IS_ALLOW_ASK_DOCTOR = 'Services/Doctors.svc/REST/GetPatientDoctorAppointmentResult'; -const GET_CALL_REQUEST_TYPE = 'Services/Doctors.svc/REST/GetCallRequestType_LOV'; -const ADD_VIDA_REQUEST = 'Services/ER_VirtualCall.svc/REST/PatientER_VidaRequestInseart'; +const IS_ALLOW_ASK_DOCTOR = + 'Services/Doctors.svc/REST/GetPatientDoctorAppointmentResult'; +const GET_CALL_REQUEST_TYPE = + 'Services/Doctors.svc/REST/GetCallRequestType_LOV'; +const ADD_VIDA_REQUEST = + 'Services/ER_VirtualCall.svc/REST/PatientER_VidaRequestInseart'; const SEND_CALL_REQUEST = 'Services/Doctors.svc/REST/InsertCallInfo'; -const GET_LIVECARE_CLINICS = 'Services/ER_VirtualCall.svc/REST/PatientER_GetClinics'; +const GET_LIVECARE_CLINICS = + 'Services/ER_VirtualCall.svc/REST/PatientER_GetClinics'; -const GET_LIVECARE_SCHEDULE_CLINICS = 'Services/Doctors.svc/REST/PatientER_GetClinicsHaveSchedule'; +const GET_LIVECARE_SCHEDULE_CLINICS = + 'Services/Doctors.svc/REST/PatientER_GetClinicsHaveSchedule'; -const GET_LIVECARE_SCHEDULE_CLINIC_DOCTOR_LIST = 'Services/Doctors.svc/REST/PatientER_GetDoctorByClinicID'; +const GET_LIVECARE_SCHEDULE_CLINIC_DOCTOR_LIST = + 'Services/Doctors.svc/REST/PatientER_GetDoctorByClinicID'; -const GET_LIVECARE_SCHEDULE_DOCTOR_TIME_SLOTS = 'Services/Doctors.svc/REST/PatientER_GetDoctorFreeSlots'; +const GET_LIVECARE_SCHEDULE_DOCTOR_TIME_SLOTS = + 'Services/Doctors.svc/REST/PatientER_GetDoctorFreeSlots'; -const INSERT_LIVECARE_SCHEDULE_APPOINTMENT = 'Services/Doctors.svc/REST/InsertSpecificAppoitmentForSchedule'; +const INSERT_LIVECARE_SCHEDULE_APPOINTMENT = + 'Services/Doctors.svc/REST/InsertSpecificAppoitmentForSchedule'; -const GET_PATIENT_SHARE_LIVECARE = "Services/Doctors.svc/REST/GetCheckinScreenAppointmentDetailsByAppointmentNOForLiveCare"; +const GET_PATIENT_SHARE_LIVECARE = + "Services/Doctors.svc/REST/GetCheckinScreenAppointmentDetailsByAppointmentNOForLiveCare"; -const GET_LIVECARE_CLINIC_TIMING = 'Services/ER_VirtualCall.svc/REST/PatientER_GetClinicsServiceTimingsSchedule'; +const GET_LIVECARE_CLINIC_TIMING = + 'Services/ER_VirtualCall.svc/REST/PatientER_GetClinicsServiceTimingsSchedule'; -const GET_ER_APPOINTMENT_FEES = 'Services/DoctorApplication.svc/REST/GetERAppointmentFees'; +const GET_ER_APPOINTMENT_FEES = + 'Services/DoctorApplication.svc/REST/GetERAppointmentFees'; const GET_ER_APPOINTMENT_TIME = 'Services/ER_VirtualCall.svc/REST/GetRestTime'; -const ADD_NEW_CALL_FOR_PATIENT_ER = 'Services/DoctorApplication.svc/REST/NewCallForPatientER'; +const ADD_NEW_CALL_FOR_PATIENT_ER = + 'Services/DoctorApplication.svc/REST/NewCallForPatientER'; -const GET_LIVECARE_HISTORY = 'Services/ER_VirtualCall.svc/REST/GetPatientErVirtualHistory'; -const CANCEL_LIVECARE_REQUEST = 'Services/ER_VirtualCall.svc/REST/DeleteErRequest'; -const SEND_LIVECARE_INVOICE_EMAIL = 'Services/Notifications.svc/REST/SendInvoiceForLiveCare'; +const GET_LIVECARE_HISTORY = + 'Services/ER_VirtualCall.svc/REST/GetPatientErVirtualHistory'; +const CANCEL_LIVECARE_REQUEST = + 'Services/ER_VirtualCall.svc/REST/DeleteErRequest'; +const SEND_LIVECARE_INVOICE_EMAIL = + 'Services/Notifications.svc/REST/SendInvoiceForLiveCare'; -const APPLE_PAY_INSERT_REQUEST = 'Services/PayFort_Serv.svc/REST/PayFort_ApplePayRequestData_Insert'; +const APPLE_PAY_INSERT_REQUEST = + 'Services/PayFort_Serv.svc/REST/PayFort_ApplePayRequestData_Insert'; const GET_USER_TERMS = 'Services/Patients.svc/REST/GetUserTermsAndConditions'; -const UPDATE_HEALTH_TERMS = 'services/Patients.svc/REST/UpdatePateintHealthSummaryReport'; +const UPDATE_HEALTH_TERMS = + 'services/Patients.svc/REST/UpdatePateintHealthSummaryReport'; -const GET_PATIENT_HEALTH_STATS = 'Services/Patients.svc/REST/Med_GetTransactionsSts'; +const GET_PATIENT_HEALTH_STATS = + 'Services/Patients.svc/REST/Med_GetTransactionsSts'; -const SEND_CHECK_IN_NFC_REQUEST = 'Services/Patients.svc/REST/Patient_CheckAppointmentValidation_ForNFC'; +const SEND_CHECK_IN_NFC_REQUEST = + 'Services/Patients.svc/REST/Patient_CheckAppointmentValidation_ForNFC'; -const HAS_DENTAL_PLAN = 'Services/Doctors.svc/REST/Dental_IsPatientHasOnGoingEstimation'; +const HAS_DENTAL_PLAN = + 'Services/Doctors.svc/REST/Dental_IsPatientHasOnGoingEstimation'; //URL to get medicine and pharmacies list const CHANNEL = 3; @@ -302,16 +381,21 @@ var DeviceTypeID = Platform.isIOS ? 1 : 2; const LANGUAGE_ID = 2; const GET_PHARMCY_ITEMS = "Services/Lists.svc/REST/GetPharmcyItems_Region"; const GET_PHARMACY_LIST = "Services/Patients.svc/REST/GetPharmcyList"; -const GET_PAtIENTS_INSURANCE = "Services/Patients.svc/REST/Get_PatientInsuranceDetails"; -const GET_PAtIENTS_INSURANCE_UPDATED = "Services/Patients.svc/REST/PatientER_GetPatientInsuranceCardUpdateHistory"; +const GET_PAtIENTS_INSURANCE = + "Services/Patients.svc/REST/Get_PatientInsuranceDetails"; +const GET_PAtIENTS_INSURANCE_UPDATED = + "Services/Patients.svc/REST/PatientER_GetPatientInsuranceCardUpdateHistory"; const INSURANCE_DETAILS = "Services/Patients.svc/REST/Get_InsuranceCheckList"; -const GET_PATIENT_INSURANCE_DETAILS = "Services/Patients.svc/REST/PatientER_GetPatientInsuranceDetails"; -const UPLOAD_INSURANCE_CARD = 'Services/Patients.svc/REST/PatientER_PatientInfoForInsuranceCardUpdate'; +const GET_PATIENT_INSURANCE_DETAILS = + "Services/Patients.svc/REST/PatientER_GetPatientInsuranceDetails"; +const UPLOAD_INSURANCE_CARD = + 'Services/Patients.svc/REST/PatientER_PatientInfoForInsuranceCardUpdate'; const GET_VACCINES = "Services/Patients.svc/REST/GetDoneVaccinesByPatientID"; const GET_VACCINES_EMAIL = "Services/Notifications.svc/REST/SendVaccinesEmail"; -const GET_PAtIENTS_INSURANCE_APPROVALS = "Services/Patients.svc/REST/GetApprovalStatus_Async"; +const GET_PAtIENTS_INSURANCE_APPROVALS = + "Services/Patients.svc/REST/GetApprovalStatus_Async"; // const GET_PAtIENTS_INSURANCE_APPROVALS = "Services/Patients.svc/REST/GetApprovalStatus"; const SEARCH_BOT = 'HabibiChatBotApi/BotInterface/GetVoiceCommandResponse'; @@ -322,54 +406,86 @@ const GET_PATIENT_SICK_LEAVE = 'Services/Patients.svc/REST/GetPatientSickLeave'; const SendSickLeaveEmail = 'Services/Notifications.svc/REST/SendSickLeaveEmail'; -const GET_PATIENT_AdVANCE_BALANCE_AMOUNT = 'Services/Patients.svc/REST/GetPatientAdvanceBalanceAmount'; -const GET_PATIENT_INFO_BY_ID = 'Services/Doctors.svc/REST/GetPatientInfoByPatientID'; -const GET_PATIENT_INFO_BY_ID_AND_MOBILE_NUMBER = 'Services/Patients.svc/REST/AP_GetPatientInfoByPatientIDandMobileNumber'; -const SEND_ACTIVATION_CODE_FOR_ADVANCE_PAYMENT = 'Services/Authentication.svc/REST/SendActivationCodeForAdvancePayment'; -const CHECK_ACTIVATION_CODE_FOR_ADVANCE_PAYMENT = 'Services/Authentication.svc/REST/CheckActivationCodeForAdvancePayment'; +const GET_PATIENT_AdVANCE_BALANCE_AMOUNT = + 'Services/Patients.svc/REST/GetPatientAdvanceBalanceAmount'; +const GET_PATIENT_INFO_BY_ID = + 'Services/Doctors.svc/REST/GetPatientInfoByPatientID'; +const GET_PATIENT_INFO_BY_ID_AND_MOBILE_NUMBER = + 'Services/Patients.svc/REST/AP_GetPatientInfoByPatientIDandMobileNumber'; +const SEND_ACTIVATION_CODE_FOR_ADVANCE_PAYMENT = + 'Services/Authentication.svc/REST/SendActivationCodeForAdvancePayment'; +const CHECK_ACTIVATION_CODE_FOR_ADVANCE_PAYMENT = + 'Services/Authentication.svc/REST/CheckActivationCodeForAdvancePayment'; -const GET_COVID_DRIVETHRU_PROJECT_LIST = 'Services/Doctors.svc/REST/COVID19_ProjectDriveThroughTestingCenter'; +const GET_COVID_DRIVETHRU_PROJECT_LIST = + 'Services/Doctors.svc/REST/COVID19_ProjectDriveThroughTestingCenter'; -const GET_COVID_DRIVETHRU_PAYMENT_INFO = 'Services/Doctors.svc/REST/COVID19_GetPatientPaymentInormation'; +const GET_COVID_DRIVETHRU_PAYMENT_INFO = + 'Services/Doctors.svc/REST/COVID19_GetPatientPaymentInormation'; -const GET_COVID_DRIVETHRU_FREE_SLOTS = 'Services/Doctors.svc/REST/COVID19_GetFreeSlots'; +const GET_COVID_DRIVETHRU_FREE_SLOTS = + 'Services/Doctors.svc/REST/COVID19_GetFreeSlots'; -const GET_COVID_DRIVETHRU_PROCEDURES_LIST = 'Services/Doctors.svc/REST/COVID19_GetTestProcedures'; +const GET_COVID_DRIVETHRU_PROCEDURES_LIST = + 'Services/Doctors.svc/REST/COVID19_GetTestProcedures'; ///Smartwatch Integration Services -const GET_PATIENT_LAST_RECORD = 'Services/Patients.svc/REST/Med_GetPatientLastRecord'; -const INSERT_PATIENT_HEALTH_DATA = 'Services/Patients.svc/REST/Med_InsertTransactions'; +const GET_PATIENT_LAST_RECORD = + 'Services/Patients.svc/REST/Med_GetPatientLastRecord'; +const INSERT_PATIENT_HEALTH_DATA = + 'Services/Patients.svc/REST/Med_InsertTransactions'; ///My Trackers -const GET_DIABETIC_RESULT_AVERAGE = 'Services/Patients.svc/REST/Patient_GetDiabeticResultAverage'; -const GET_DIABTEC_RESULT = 'Services/Patients.svc/REST/Patient_GetDiabtecResults'; -const ADD_DIABTEC_RESULT = 'Services/Patients.svc/REST/Patient_AddDiabtecResult'; - -const GET_BLOOD_PRESSURE_RESULT_AVERAGE = 'Services/Patients.svc/REST/Patient_GetBloodPressureResultAverage'; -const GET_BLOOD_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_GetBloodPressureResult'; -const ADD_BLOOD_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_AddBloodPressureResult'; - -const GET_WEIGHT_PRESSURE_RESULT_AVERAGE = 'Services/Patients.svc/REST/Patient_GetWeightMeasurementResultAverage'; -const GET_WEIGHT_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_GetWeightMeasurementResult'; -const ADD_WEIGHT_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_AddWeightMeasurementResult'; - -const ADD_ACTIVE_PRESCRIPTIONS_REPORT_BY_PATIENT_ID = 'Services/Patients.svc/Rest/GetActivePrescriptionReportByPatientID'; - -const GET_CALL_INFO_HOURS_RESULT = 'Services/Doctors.svc/REST/GetCallInfoHoursResult'; -const GET_CALL_REQUEST_TYPE_LOV = 'Services/Doctors.svc/REST/GetCallRequestType_LOV'; - -const UPDATE_DIABETIC_RESULT = 'Services/Patients.svc/REST/Patient_UpdateDiabeticResult'; - -const SEND_AVERAGE_BLOOD_SUGAR_REPORT = 'Services/Notifications.svc/REST/SendAverageBloodSugarReport'; -const DEACTIVATE_DIABETIC_STATUS = 'services/Patients.svc/REST/Patient_DeactivateDiabeticStatus'; -const DEACTIVATE_BLOOD_PRESSURES_STATUS = 'services/Patients.svc/REST/Patient_DeactivateBloodPressureStatus'; - -const UPDATE_BLOOD_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_UpdateBloodPressureResult'; -const SEND_AVERAGE_BLOOD_WEIGHT_REPORT = 'Services/Notifications.svc/REST/SendAverageBodyWeightReport'; -const SEND_AVERAGE_BLOOD_PRESSURE_REPORT = 'Services/Notifications.svc/REST/SendAverageBloodPressureReport'; - -const UPDATE_WEIGHT_PRESSURE_RESULT = 'Services/Patients.svc/REST/Patient_UpdateWeightMeasurementResult'; -const DEACTIVATE_WEIGHT_PRESSURE_RESULT = 'services/Patients.svc/REST/Patient_DeactivateWeightMeasurementStatus'; +const GET_DIABETIC_RESULT_AVERAGE = + 'Services/Patients.svc/REST/Patient_GetDiabeticResultAverage'; +const GET_DIABTEC_RESULT = + 'Services/Patients.svc/REST/Patient_GetDiabtecResults'; +const ADD_DIABTEC_RESULT = + 'Services/Patients.svc/REST/Patient_AddDiabtecResult'; + +const GET_BLOOD_PRESSURE_RESULT_AVERAGE = + 'Services/Patients.svc/REST/Patient_GetBloodPressureResultAverage'; +const GET_BLOOD_PRESSURE_RESULT = + 'Services/Patients.svc/REST/Patient_GetBloodPressureResult'; +const ADD_BLOOD_PRESSURE_RESULT = + 'Services/Patients.svc/REST/Patient_AddBloodPressureResult'; + +const GET_WEIGHT_PRESSURE_RESULT_AVERAGE = + 'Services/Patients.svc/REST/Patient_GetWeightMeasurementResultAverage'; +const GET_WEIGHT_PRESSURE_RESULT = + 'Services/Patients.svc/REST/Patient_GetWeightMeasurementResult'; +const ADD_WEIGHT_PRESSURE_RESULT = + 'Services/Patients.svc/REST/Patient_AddWeightMeasurementResult'; + +const ADD_ACTIVE_PRESCRIPTIONS_REPORT_BY_PATIENT_ID = + 'Services/Patients.svc/Rest/GetActivePrescriptionReportByPatientID'; + +const GET_CALL_INFO_HOURS_RESULT = + 'Services/Doctors.svc/REST/GetCallInfoHoursResult'; +const GET_CALL_REQUEST_TYPE_LOV = + 'Services/Doctors.svc/REST/GetCallRequestType_LOV'; + +const UPDATE_DIABETIC_RESULT = + 'Services/Patients.svc/REST/Patient_UpdateDiabeticResult'; + +const SEND_AVERAGE_BLOOD_SUGAR_REPORT = + 'Services/Notifications.svc/REST/SendAverageBloodSugarReport'; +const DEACTIVATE_DIABETIC_STATUS = + 'services/Patients.svc/REST/Patient_DeactivateDiabeticStatus'; +const DEACTIVATE_BLOOD_PRESSURES_STATUS = + 'services/Patients.svc/REST/Patient_DeactivateBloodPressureStatus'; + +const UPDATE_BLOOD_PRESSURE_RESULT = + 'Services/Patients.svc/REST/Patient_UpdateBloodPressureResult'; +const SEND_AVERAGE_BLOOD_WEIGHT_REPORT = + 'Services/Notifications.svc/REST/SendAverageBodyWeightReport'; +const SEND_AVERAGE_BLOOD_PRESSURE_REPORT = + 'Services/Notifications.svc/REST/SendAverageBloodPressureReport'; + +const UPDATE_WEIGHT_PRESSURE_RESULT = + 'Services/Patients.svc/REST/Patient_UpdateWeightMeasurementResult'; +const DEACTIVATE_WEIGHT_PRESSURE_RESULT = + 'services/Patients.svc/REST/Patient_DeactivateWeightMeasurementStatus'; const GET_DOCTOR_RESPONSE = 'Services/Patients.svc/REST/GetDoctorResponse'; const UPDATE_READ_STATUS = 'Services/Patients.svc/REST/UpdateReadStatus'; const INSERT_CALL_INFO = 'Services/Doctors.svc/REST/InsertCallInfo'; @@ -377,25 +493,35 @@ const INSERT_CALL_INFO = 'Services/Doctors.svc/REST/InsertCallInfo'; const GET_PATIENT_ALLERGIES = 'Services/Patients.svc/REST/GetPatientAllergies'; // H2O -const H2O_GET_USER_PROGRESS = "Services/H2ORemainder.svc/REST/H2O_GetUserProgress"; -const H2O_INSERT_USER_ACTIVITY = "Services/H2ORemainder.svc/REST/H2O_InsertUserActivity"; -const H2O_GET_USER_DETAIL = "Services/H2ORemainder.svc/REST/H2O_GetUserDetails_New"; -const H2O_UPDATE_USER_DETAIL = "Services/H2ORemainder.svc/REST/H2O_UpdateUserDetails_New"; -const H2O_UNDO_USER_ACTIVITY = "Services/H2ORemainder.svc/REST/H2o_UndoUserActivity"; +const H2O_GET_USER_PROGRESS = + "Services/H2ORemainder.svc/REST/H2O_GetUserProgress"; +const H2O_INSERT_USER_ACTIVITY = + "Services/H2ORemainder.svc/REST/H2O_InsertUserActivity"; +const H2O_GET_USER_DETAIL = + "Services/H2ORemainder.svc/REST/H2O_GetUserDetails_New"; +const H2O_UPDATE_USER_DETAIL = + "Services/H2ORemainder.svc/REST/H2O_UpdateUserDetails_New"; +const H2O_UNDO_USER_ACTIVITY = + "Services/H2ORemainder.svc/REST/H2o_UndoUserActivity"; //E_Referral Services -const GET_ALL_RELATIONSHIP_TYPES = "Services/Patients.svc/REST/GetAllRelationshipTypes"; -const SEND_ACTIVATION_CODE_FOR_E_REFERRAL = 'Services/Authentication.svc/REST/SendActivationCodeForEReferral'; -const CHECK_ACTIVATION_CODE_FOR_E_REFERRAL = 'Services/Authentication.svc/REST/CheckActivationCodeForEReferral'; +const GET_ALL_RELATIONSHIP_TYPES = + "Services/Patients.svc/REST/GetAllRelationshipTypes"; +const SEND_ACTIVATION_CODE_FOR_E_REFERRAL = + 'Services/Authentication.svc/REST/SendActivationCodeForEReferral'; +const CHECK_ACTIVATION_CODE_FOR_E_REFERRAL = + 'Services/Authentication.svc/REST/CheckActivationCodeForEReferral'; const GET_ALL_CITIES = 'services/Lists.svc/rest/GetAllCities'; const CREATE_E_REFERRAL = "Services/Patients.svc/REST/CreateEReferral"; const GET_E_REFERRALS = "Services/Patients.svc/REST/GetEReferrals"; // Encillary Orders -const GET_ANCILLARY_ORDERS = 'Services/Doctors.svc/REST/GetOnlineAncillaryOrderList'; +const GET_ANCILLARY_ORDERS = + 'Services/Doctors.svc/REST/GetOnlineAncillaryOrderList'; -const GET_ANCILLARY_ORDERS_DETAILS = 'Services/Doctors.svc/REST/GetOnlineAncillaryOrderProcList'; +const GET_ANCILLARY_ORDERS_DETAILS = + 'Services/Doctors.svc/REST/GetOnlineAncillaryOrderProcList'; //Pharmacy wishlist // const GET_WISHLIST = "http://swd-pharapp-01:7200/api/shopping_cart_items/"; @@ -428,32 +554,50 @@ const GET_SHIPPING_OPTIONS = "get_shipping_option/"; const DELETE_SHOPPING_CART = "delete_shopping_cart_items/"; const DELETE_SHOPPING_CART_ALL = "delete_shopping_cart_item_by_customer/"; const ORDER_SHOPPING_CART = "orders"; -const GET_LACUM_ACCOUNT_INFORMATION = "Services/Patients.svc/REST/GetLakumAccountInformation"; -const GET_LACUM_GROUP_INFORMATION = "Services/Patients.svc/REST/GetlakumInQueryInfoGrouping"; -const LACUM_ACCOUNT_ACTIVATE = "Services/Patients.svc/REST/LakumAccountActivation"; -const LACUM_ACCOUNT_DEACTIVATE = "Services/Patients.svc/REST/LakumAccountDeactivation"; -const CREATE_LAKUM_ACCOUNT = "Services/Patients.svc/REST/PHR_CreateLakumAccount"; -const TRANSFER_YAHALA_LOYALITY_POINTS = "Services/Patients.svc/REST/TransferYaHalaLoyaltyPoints"; -const LAKUM_GET_USER_TERMS_AND_CONDITIONS = "Services/ERP.svc/REST/GetUserTermsAndConditionsForEPharmcy"; +const GET_LACUM_ACCOUNT_INFORMATION = + "Services/Patients.svc/REST/GetLakumAccountInformation"; +const GET_LACUM_GROUP_INFORMATION = + "Services/Patients.svc/REST/GetlakumInQueryInfoGrouping"; +const LACUM_ACCOUNT_ACTIVATE = + "Services/Patients.svc/REST/LakumAccountActivation"; +const LACUM_ACCOUNT_DEACTIVATE = + "Services/Patients.svc/REST/LakumAccountDeactivation"; +const CREATE_LAKUM_ACCOUNT = + "Services/Patients.svc/REST/PHR_CreateLakumAccount"; +const TRANSFER_YAHALA_LOYALITY_POINTS = + "Services/Patients.svc/REST/TransferYaHalaLoyaltyPoints"; +const LAKUM_GET_USER_TERMS_AND_CONDITIONS = + "Services/ERP.svc/REST/GetUserTermsAndConditionsForEPharmcy"; const PRESCRIPTION = 'Services/Patients.svc/REST/GetPrescriptionApptList'; const GET_RECOMMENDED_PRODUCT = 'alsoProduct/'; const GET_MOST_VIEWED_PRODUCTS = "mostview"; const GET_NEW_PRODUCTS = "newproducts"; // Home Health Care -const HHC_GET_ALL_SERVICES = "Services/Patients.svc/REST/PatientER_HHC_GetAllServices"; -const HHC_GET_ALL_CMC_SERVICES = "Services/Patients.svc/REST/PatientER_CMC_GetAllServices"; -const PATIENT_ER_UPDATE_PRES_ORDER = "Services/Patients.svc/REST/PatientER_UpdatePresOrder"; -const GET_ORDER_DETAIL_BY_ID = "Services/Patients.svc/REST/PatientER_HHC_GetTransactionsForOrder"; -const GET_CMC_ORDER_DETAIL_BY_ID = "Services/Patients.svc/REST/PatientER_CMC_GetTransactionsForOrder"; +const HHC_GET_ALL_SERVICES = + "Services/Patients.svc/REST/PatientER_HHC_GetAllServices"; +const HHC_GET_ALL_CMC_SERVICES = + "Services/Patients.svc/REST/PatientER_CMC_GetAllServices"; +const PATIENT_ER_UPDATE_PRES_ORDER = + "Services/Patients.svc/REST/PatientER_UpdatePresOrder"; +const GET_ORDER_DETAIL_BY_ID = + "Services/Patients.svc/REST/PatientER_HHC_GetTransactionsForOrder"; +const GET_CMC_ORDER_DETAIL_BY_ID = + "Services/Patients.svc/REST/PatientER_CMC_GetTransactionsForOrder"; const GET_CHECK_UP_ITEMS = "Services/Patients.svc/REST/GetCheckUpItems"; -const PUSH_NOTIFICATION_GET_ALL_NOTIFICATIONS = 'Services/MobileNotifications.svc/REST/PushNotification_GetAllNotifications'; -const PUSH_NOTIFICATION_SET_MESSAGES_FROM_POOL_AS_READ = 'Services/MobileNotifications.svc/REST/PushNotification_SetMessagesFromPoolAsRead'; -const GET_PATIENT_ALL_PRES_ORD = 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; -const PATIENT_ER_INSERT_PRES_ORDER = 'Services/Patients.svc/REST/PatientER_InsertPresOrder'; +const PUSH_NOTIFICATION_GET_ALL_NOTIFICATIONS = + 'Services/MobileNotifications.svc/REST/PushNotification_GetAllNotifications'; +const PUSH_NOTIFICATION_SET_MESSAGES_FROM_POOL_AS_READ = + 'Services/MobileNotifications.svc/REST/PushNotification_SetMessagesFromPoolAsRead'; +const GET_PATIENT_ALL_PRES_ORD = + 'Services/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; +const PATIENT_ER_INSERT_PRES_ORDER = + 'Services/Patients.svc/REST/PatientER_InsertPresOrder'; const PHARMACY_MAKE_REVIEW = 'epharmacy/api/insertreviews'; -const BLOOD_DONATION_REGISTER_BLOOD_TYPE = 'Services/PatientVarification.svc/REST/BloodDonation_RegisterBloodType'; -const ADD_USER_AGREEMENT_FOR_BLOOD_DONATION = 'Services/PatientVarification.svc/REST/AddUserAgreementForBloodDonation'; +const BLOOD_DONATION_REGISTER_BLOOD_TYPE = + 'Services/PatientVarification.svc/REST/BloodDonation_RegisterBloodType'; +const ADD_USER_AGREEMENT_FOR_BLOOD_DONATION = + 'Services/PatientVarification.svc/REST/AddUserAgreementForBloodDonation'; // HHC RC SERVICES const HHC_GET_ALL_SERVICES_RC = "rc/api/HHC/getallhhc"; @@ -478,7 +622,6 @@ const GET_ALL_PRESCRIPTION_ORDERS_RC = "rc/api/prescription/list"; const GET_ALL_PRESCRIPTION_INFO_RC = "rc/api/Prescription/info"; const UPDATE_PRESCRIPTION_ORDER_RC = 'rc/api/prescription/update'; - //Pharmacy wishlist const GET_WISHLIST = "shopping_cart_items/"; const DELETE_WISHLIST = "delete_shopping_cart_item_by_product?customer_id="; @@ -497,17 +640,21 @@ const GET_CUSTOMER_INFO = "VerifyCustomer"; //Pharmacy -const GET_PHARMACY_CATEGORISE = 'categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id=0'; +const GET_PHARMACY_CATEGORISE = + 'categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id=0'; const GET_OFFERS_CATEGORISE = 'discountcategories'; const GET_OFFERS_PRODUCTS = 'offerproducts/'; -const GET_CATEGORISE_PARENT = 'categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id='; +const GET_CATEGORISE_PARENT = + 'categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id='; const GET_PARENT_PRODUCTS = 'products?categoryid='; -const GET_SUB_CATEGORISE = 'categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id='; +const GET_SUB_CATEGORISE = + 'categories?fields=id,name,namen,description,image,localized_names,display_order,parent_category_id,is_leaf&parent_id='; const GET_SUB_PRODUCTS = 'products?categoryid='; const GET_FINAL_PRODUCTS = 'products?fields=id,reviews,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&CategoryId='; const GET_CLINIC_CATEGORY = 'Services/Doctors.svc/REST/DP_GetClinicCategory'; -const GET_DISEASE_BY_CLINIC_ID = 'Services/Doctors.svc/REST/DP_GetDiseasesByClinicID'; +const GET_DISEASE_BY_CLINIC_ID = + 'Services/Doctors.svc/REST/DP_GetDiseasesByClinicID'; const SEARCH_DOCTOR_BY_TIME = 'Services/Doctors.svc/REST/SearchDoctorsByTime'; const TIMER_MIN = 10; @@ -523,13 +670,17 @@ const SCAN_QR_CODE = 'productbysku/'; const FILTERED_PRODUCTS = 'products?categoryids='; -const GET_DOCTOR_LIST_CALCULATION = "Services/Doctors.svc/REST/GetCallculationDoctors"; +const GET_DOCTOR_LIST_CALCULATION = + "Services/Doctors.svc/REST/GetCallculationDoctors"; -const GET_ALL_APPOINTMENTS_FOR_DENTAL_CLINIC = "Services/Patients.svc/REST/GetDentalAppointments"; +const GET_ALL_APPOINTMENTS_FOR_DENTAL_CLINIC = + "Services/Patients.svc/REST/GetDentalAppointments"; -const GET_DENTAL_APPOINTMENT_INVOICE = "Services/Patients.svc/REST/HIS_eInvoiceForDentalByAppointmentNo"; +const GET_DENTAL_APPOINTMENT_INVOICE = + "Services/Patients.svc/REST/HIS_eInvoiceForDentalByAppointmentNo"; -const SEND_DENTAL_APPOINTMENT_INVOICE_EMAIL = "Services/Notifications.svc/REST/SendInvoiceForDental"; +const SEND_DENTAL_APPOINTMENT_INVOICE_EMAIL = + "Services/Notifications.svc/REST/SendInvoiceForDental"; class AppGlobal { static var context; diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index b1ad22de..b3a7e092 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -33,12 +33,14 @@ class ParentCategorisePage extends StatefulWidget { String id; String titleName; - AuthenticatedUserObject authenticatedUserObject = locator(); + AuthenticatedUserObject authenticatedUserObject = + locator(); ParentCategorisePage({this.id, this.titleName}); @override - _ParentCategorisePageState createState() => _ParentCategorisePageState(id: id, titleName: titleName); + _ParentCategorisePageState createState() => + _ParentCategorisePageState(id: id, titleName: titleName); } class _ParentCategorisePageState extends State { @@ -145,36 +147,34 @@ class _ParentCategorisePageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ InkWell( - child:Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: EdgeInsets.all(10.0), - - child: Container( - child: Texts( - TranslationBase.of(context) - .viewCategorise, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: EdgeInsets.all(10.0), + child: Container( + child: Texts( + TranslationBase.of(context) + .viewCategorise, // 'View All Categories', - fontWeight: FontWeight.w300, + fontWeight: FontWeight.w300, + ), ), ), - ), - Icon(Icons.arrow_forward) - ], - ), onTap: () { - Navigator.push( - context, - FadePage( - page: - SubCategoriseModalsheet( + Icon(Icons.arrow_forward) + ], + ), + onTap: () { + Navigator.push( + context, + FadePage( + page: SubCategoriseModalsheet( // id: model.categorise[0].id, // titleName: model.categorise[0].name, - )), - - );} - ), + )), + ); + }), Divider( thickness: 1.0, color: Colors.grey.shade400, @@ -262,10 +262,16 @@ class _ParentCategorisePageState extends State { context, FadePage( page: SubCategorisePage( - title: projectViewModel.isArabic ? model.categoriseParent[index].namen : model.categoriseParent[index].name, -// title:model - .categoriseParent[index] - .name, + title: projectViewModel + .isArabic + ? model + .categoriseParent[ + index] + .namen + : model + .categoriseParent[ + index] + .name, id: model .categoriseParent[index] .id, @@ -349,13 +355,15 @@ class _ParentCategorisePageState extends State { .refine, // 'Refine', - fontWeight: FontWeight.w600, - ), - SizedBox( - width: 250.0, - ), - InkWell( - child: Texts( + fontWeight: + FontWeight + .w600, + ), + SizedBox( + width: 250.0, + ), + InkWell( + child: Texts( // 'Close', TranslationBase.of( context) @@ -594,39 +602,47 @@ class _ParentCategorisePageState extends State { } } - GifLoaderDialogUtils.showMyDialog(context); + GifLoaderDialogUtils.showMyDialog( + context); - await model.getFilteredProducts( - min: minField.text.toString(), max: maxField.text.toString(), categoryId: categoriesId, brandId: brandIds); - GifLoaderDialogUtils.hideDialog(context); + await model.getFilteredProducts( + min: minField.text.toString(), + max: maxField.text.toString(), + categoryId: categoriesId, + brandId: brandIds); + GifLoaderDialogUtils.hideDialog( + context); - Navigator.pop(context); - }, - label: TranslationBase.of(context).apply, - backgroundColor: Colors.green, + Navigator.pop( + context); + }, + label: TranslationBase.of(context) + .apply, + backgroundColor: + Colors.green, + ), + ), + ], + ), ), - ), - ], - ), + ], + ), + ], ), - ], - ), - ], - ), - ), - ); - }); - }, - ); - }, - ), - Row( - children: [ - Container( - height: 44.0, - child: VerticalDivider( - color: Colors.black45, - thickness: 1.0, + ), + ); + }); + }, + ); + }, + ), + Row( + children: [ + Container( + height: 44.0, + child: VerticalDivider( + color: Colors.black45, + thickness: 1.0, //width: 0.3, // indent: 0.0, ), @@ -779,7 +795,8 @@ class _ParentCategorisePageState extends State { ), child: Texts( - TranslationBase.of(context).offers + TranslationBase.of(context) + .offers .toUpperCase(), color: Colors.red, @@ -821,55 +838,55 @@ class _ParentCategorisePageState extends State { height: 80, ), ), - Container( - width: model.parentProducts[index].rxMessage != - null - ? MediaQuery.of(context) - .size - .width / - 5 - : 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( +// width: model.parentProducts[index].rxMessage != +// null +// ? MediaQuery.of(context) +// .size +// .width / +// 5 +// : 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( @@ -954,98 +971,167 @@ class _ParentCategorisePageState extends State { // ? (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, + 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, + ) + ], + ), + ], ), - Texts( - "(${model.parentProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ) - ], - ), - ], + ), + ], + ), ), ), - ], - ), - ), - ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage(model.parentProducts[index]), - )), + 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( + ), + ) + : 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: [ - Container( - decoration: BoxDecoration(), - child: Padding( - padding: EdgeInsets.only( - left: 9.0, - top: 8.0, - right: 10.0, + 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), + ), + ], ), - ), - ), - 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(""), + 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, @@ -1053,46 +1139,72 @@ class _ParentCategorisePageState extends State { // 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: [ + 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() @@ -1204,8 +1316,10 @@ class _ParentCategorisePageState extends State { Padding( padding: const EdgeInsets.all(8.0), - child: Text(TranslationBase.of(context).noData, - // 'There is no data', + child: Text( + TranslationBase.of(context) + .noData, + // 'There is no data', style: TextStyle(fontSize: 30), ), @@ -1228,7 +1342,8 @@ class _ParentCategorisePageState extends State { } bool isEntityListSelected(CategoriseParentModel masterKey) { - Iterable history = entityList.where((element) => masterKey.id == element.id); + Iterable history = + entityList.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } @@ -1236,7 +1351,8 @@ class _ParentCategorisePageState extends State { } bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { - Iterable history = entityListBrands.where((element) => masterKey.id == element.id); + Iterable history = + entityListBrands.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } 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 cefa5dd7..524501e1 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -23,7 +23,6 @@ import 'package:provider/provider.dart'; import 'cart-order-preview.dart'; class CartOrderPage extends StatefulWidget { - final Function(int) changeTab; const CartOrderPage({Key key, this.changeTab}) : super(key: key); @@ -61,197 +60,192 @@ class _CartOrderPageState extends State { isLoading: isLoading, isLocalLoader: true, child: !(model.cartResponse.shoppingCarts == null || - model.cartResponse.shoppingCarts.length == 0) + model.cartResponse.shoppingCarts.length == 0) ? Container( - height: height * 0.85, - width: double.infinity, - child: SingleChildScrollView( - child: Container( - margin: EdgeInsets.all(10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - GestureIconButton( - TranslationBase.of(context).deleteAllItems, - Icon( - Icons.delete_outline_sharp, - color: Colors.grey.shade700, - ), - onTap: () => {model.deleteShoppingCart()}, - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Container( + height: height * 0.85, + width: double.infinity, + child: SingleChildScrollView( + child: Container( + margin: EdgeInsets.all(10), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - ...List.generate( - model.cartResponse.shoppingCarts != null - ? model - .cartResponse.shoppingCarts.length - : 0, - (index) => ProductOrderItem( - model.cartResponse - .shoppingCarts[index], () { - print(model.cartResponse - .shoppingCarts[index].quantity); - model - .changeProductQuantity(model - .cartResponse - .shoppingCarts[index]) - .then((value) { - if (model.state != - ViewState.Error) { - // appScaffold.appBar.badgeUpdater( - // '${value.quantityCount ?? 0}'); - } - if (model.state == - ViewState.ErrorLocal) { - Utils.showErrorToast( - model.error); - } - }); - }, () { - model - .deleteProduct(model - .cartResponse - .shoppingCarts[index]) - .then((value) { - if (model.state != - ViewState.Error) { - // appScaffold.appBar.badgeUpdater( - // '${value.quantityCount ?? 0}'); - } - }); - })) + GestureIconButton( + TranslationBase.of(context).deleteAllItems, + Icon( + Icons.delete_outline_sharp, + color: Colors.grey.shade700, + ), + onTap: () => {model.deleteShoppingCart()}, + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Container( + child: Column( + children: [ + ...List.generate( + model.cartResponse.shoppingCarts != null + ? model.cartResponse.shoppingCarts.length + : 0, + (index) => ProductOrderItem( + model.cartResponse + .shoppingCarts[index], () { + print(model.cartResponse + .shoppingCarts[index].quantity); + model + .changeProductQuantity(model + .cartResponse + .shoppingCarts[index]) + .then((value) { + if (model.state != ViewState.Error) { + // appScaffold.appBar.badgeUpdater( + // '${value.quantityCount ?? 0}'); + } + if (model.state == + ViewState.ErrorLocal) { + Utils.showErrorToast(model.error); + } + }); + }, () { + model + .deleteProduct(model.cartResponse + .shoppingCarts[index]) + .then((value) { + if (model.state != ViewState.Error) { + // appScaffold.appBar.badgeUpdater( + // '${value.quantityCount ?? 0}'); + } + }); + })) + ], + ), + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 2, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).subtotal, + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + "${TranslationBase.of(context).vat}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).total, + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Image.asset( + "assets/images/pharmacy_module/payment.png", + width: mediaQuery.size.width - 20, + height: 30.0, + fit: BoxFit.scaleDown, + ), + SizedBox( + height: 120, + ) ], ), ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 2, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).subtotal, - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - "${TranslationBase.of(context).vat}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).total, - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.bold, + ), + ) + : 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, ), - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.bold, + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + TranslationBase.of(context).noData, +// 'There is no data', + style: TextStyle(fontSize: 30), ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Image.asset( - "assets/images/pharmacy_module/payment.png", - width: mediaQuery.size.width - 20, - height: 30.0, - fit: BoxFit.scaleDown, - ), - SizedBox( - height: 120, - ) - ], - ), - ), - ), - ) - : 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), - ), - ) - ], - ), - ), ), bottomSheet: Container( height: !(model.cartResponse.shoppingCarts == null || - model.cartResponse.shoppingCarts.length == 0) + model.cartResponse.shoppingCarts.length == 0) ? height * 0.15 : 0, color: Colors.white, @@ -435,7 +429,7 @@ class _OrderBottomWidgetState extends State { fontSize: 14), ), color: Color(0xFF4CAF50), - disabledColor:Color(0xFF848484), + disabledColor: Color(0xFF848484), // disabledColor: Color(0xff005aff), ) ], diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index c4c1b26c..51580c2c 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -111,211 +111,240 @@ class __ProductDetailPageState extends State { await addToWishlistFunction(itemID: itemID, model: model); }, deleteFromWishlistFunction: () async { - await deleteFromWishlistFunction(itemID: itemID, model: model); + await deleteFromWishlistFunction( + itemID: itemID, model: model); }, isInWishList: isInWishList, addToCartFunction: addToCartFunction, ), body: SingleChildScrollView( + child: Column( + children: [ + Container( + width: double.infinity, + color: Colors.white, child: Column( children: [ - Container( - width: double.infinity, - color: Colors.white, - child: Column( - children: [ - if (widget.product.images.isNotEmpty) - Container( - height: MediaQuery.of(context).size.height * .40, - child: Image.network( - widget.product.images[0].src.trim(), - fit: BoxFit.contain, - ), - ), - if (widget.product.discountDescription != null) DiscountDescription(product: widget.product) - ], + if (widget.product.images.isNotEmpty) + Container( + height: MediaQuery.of(context).size.height * .40, + child: Image.network( + widget.product.images[0].src.trim(), + fit: BoxFit.contain, + ), ), - ), - SizedBox( - height: 4, - ), - Container( - color: Colors.white, - child: ProductNameAndPrice( - context, - widget.product, + if (widget.product.discountDescription != null) + DiscountDescription(product: widget.product) + ], + ), + ), + SizedBox( + height: 4, + ), + Container( + color: Colors.white, + child: ProductNameAndPrice( + context, + widget.product, + customerId: customerId, + addToWishlistFunction: (item) { + addToWishlistFunction(itemID: item, model: model); + setState(() {}); + }, + deleteFromWishlistFunction: (item) { + deleteFromWishlistFunction( + itemID: item, model: model); + setState(() {}); + }, + notifyMeWhenAvailable: (context, itemId) { + notifyMeWhenAvailable( + itemId: itemId, customerId: customerId, - addToWishlistFunction: (item) { - addToWishlistFunction(itemID: item, model: model); - setState(() {}); - }, - deleteFromWishlistFunction: (item) { - deleteFromWishlistFunction(itemID: item, model: model); - setState(() {}); - }, - notifyMeWhenAvailable: (context, itemId) { - notifyMeWhenAvailable(itemId: itemId, customerId: customerId, model: model); - }, - isInWishList: isInWishList, - isStockAvailable: model.isStockAvailable, - stockAvailability: projectViewModel.isArabic ? model.stockAvailabilityn : model.stockAvailability, - ), - ), - SizedBox( - height: 6, - ), + model: model); + }, + isInWishList: isInWishList, + isStockAvailable: model.isStockAvailable, + stockAvailability: projectViewModel.isArabic + ? model.stockAvailabilityn + : model.stockAvailability, + ), + ), + SizedBox( + height: 6, + ), + Container( + color: Colors.white, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ Container( - color: Colors.white, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10), - child: Texts( - TranslationBase.of(context).specification, - fontSize: 15, - fontWeight: FontWeight.bold, - ), - width: double.infinity, - ), - // Divider(color: Colors.grey), - ], + padding: EdgeInsets.symmetric( + vertical: 15, horizontal: 10), + child: Texts( + TranslationBase.of(context).specification, + fontSize: 15, + fontWeight: FontWeight.bold, ), + width: double.infinity, ), - SizedBox( - height: 6, - ), - Container( - // width: 500, - margin: EdgeInsets.only(bottom: 6), - color: Colors.white, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = true; - isReviews = false; - isAvailability = false; - }); - }, - child: Text( - TranslationBase.of(context).details, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - CustomDivider( - color: isDetails ? Colors.green : Colors.transparent, - ) - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () async { - if (widget.product.approvedTotalReviews > 0) { - GifLoaderDialogUtils.showMyDialog(context); - await model.getProductReviewsData(widget.product.id); - GifLoaderDialogUtils.hideDialog(context); - } else { - model.clearReview(); - } - setState(() { - isDetails = false; - isReviews = true; - isAvailability = false; - }); - }, - child: Text( - TranslationBase.of(context).reviews, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - CustomDivider( - color: isReviews ? Colors.green : Colors.transparent, - ), - ], + // Divider(color: Colors.grey), + ], + ), + ), + SizedBox( + height: 6, + ), + Container( + // width: 500, + margin: EdgeInsets.only(bottom: 6), + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Column( + children: [ + FlatButton( + onPressed: () { + setState(() { + isDetails = true; + isReviews = false; + isAvailability = false; + }); + }, + child: Text( + TranslationBase.of(context).details, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), ), - SizedBox( - width: 20, + color: Colors.white, + ), + CustomDivider( + color: isDetails + ? Colors.green + : Colors.transparent, + ) + ], + ), + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () async { + if (widget.product.approvedTotalReviews > + 0) { + GifLoaderDialogUtils.showMyDialog( + context); + await model.getProductReviewsData( + widget.product.id); + GifLoaderDialogUtils.hideDialog( + context); + } else { + model.clearReview(); + } + setState(() { + isDetails = false; + isReviews = true; + isAvailability = false; + }); + }, + child: Text( + TranslationBase.of(context).reviews, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), ), - Column( - children: [ - FlatButton( - onPressed: () async { - GifLoaderDialogUtils.showMyDialog(context); - await model.getProductLocationData(); - GifLoaderDialogUtils.hideDialog(context); + color: Colors.white, + ), + CustomDivider( + color: isReviews + ? Colors.green + : Colors.transparent, + ), + ], + ), + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () async { + GifLoaderDialogUtils.showMyDialog( + context); + await model.getProductLocationData(); + GifLoaderDialogUtils.hideDialog(context); - setState(() { - isDetails = false; - isReviews = false; - isAvailability = true; - }); - }, - child: Text( - TranslationBase.of(context).availability, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - CustomDivider( - color: isAvailability ? Colors.green : Colors.transparent, - ), - ], + setState(() { + isDetails = false; + isReviews = false; + isAvailability = true; + }); + }, + child: Text( + TranslationBase.of(context).availability, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), ), - ], - ), - SizedBox( - height: 10, - ), - isDetails - ? DetailsInfo( - product: widget.product, - ) - : isReviews - ? ReviewsInfo( - product: widget.product, - previousModel: model, - ) - : isAvailability - ? AvailabilityInfo( - previousModel: model, - ) - : Container(), - ], - ), + color: Colors.white, + ), + CustomDivider( + color: isAvailability + ? Colors.green + : Colors.transparent, + ), + ], + ), + ], ), SizedBox( height: 10, ), - RecommendedProducts( - product: widget.product, - productDetailViewModel: model, - addToWishlistFunction: (itemID) async { - await addToWishlistFunction(itemID: itemID, model: model); - }, - deleteFromWishlistFunction: (itemID) async { - await deleteFromWishlistFunction(itemID: itemID, model: model); - }, - ) + isDetails + ? DetailsInfo( + product: widget.product, + ) + : isReviews + ? ReviewsInfo( + product: widget.product, + previousModel: model, + ) + : isAvailability + ? AvailabilityInfo( + previousModel: model, + ) + : Container(), ], ), ), - // : AppCircularProgressIndicator(), - bottomSheet: model.state == ViewState.Idle || model.state == ViewState.ErrorLocal + SizedBox( + height: 10, + ), + RecommendedProducts( + product: widget.product, + productDetailViewModel: model, + addToWishlistFunction: (itemID) async { + await addToWishlistFunction( + itemID: itemID, model: model); + }, + deleteFromWishlistFunction: (itemID) async { + await deleteFromWishlistFunction( + itemID: itemID, model: model); + }, + ) + ], + ), + ), + // : AppCircularProgressIndicator(), + bottomSheet: model.state == ViewState.Idle || + model.state == ViewState.ErrorLocal ? FooterWidget( model.isStockAvailable, widget.product.orderMaximumQuantity, @@ -332,12 +361,12 @@ class __ProductDetailPageState extends State { )); } - addToShoppingCartFunction({quantity, itemID, ProductDetailViewModel model}) async { + addToShoppingCartFunction( + {quantity, itemID, ProductDetailViewModel model}) async { GifLoaderDialogUtils.showMyDialog(context); await model.addToCartData(quantity, itemID, context); GifLoaderDialogUtils.hideDialog(context); - if(model.state != ViewState.ErrorLocal) - Utils.navigateToCartPage(); + if (model.state != ViewState.ErrorLocal) Utils.navigateToCartPage(); } addToWishlistFunction({itemID, ProductDetailViewModel model}) async { @@ -363,6 +392,7 @@ class __ProductDetailPageState extends State { } } -notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model, context}) async { +notifyMeWhenAvailable( + {itemId, customerId, ProductDetailViewModel model, context}) async { await model.notifyMe(customerId, itemId, context); } diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 92b20476..c82c1063 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -30,12 +30,14 @@ class SubCategorisePage extends StatefulWidget { String title; String parentId; - AuthenticatedUserObject authenticatedUserObject = locator(); + AuthenticatedUserObject authenticatedUserObject = + locator(); SubCategorisePage({this.id, this.parentId, this.title}); @override - _SubCategorisePageState createState() => _SubCategorisePageState(id: id, title: title, parentId: parentId); + _SubCategorisePageState createState() => + _SubCategorisePageState(id: id, title: title, parentId: parentId); } class _SubCategorisePageState extends State { @@ -66,7 +68,9 @@ class _SubCategorisePageState extends State { ProjectViewModel projectProvider = Provider.of(context); return BaseView( onModelReady: (model) => model.getSubCategorise(i: id), - builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( + builder: (BuildContext context, PharmacyCategoriseViewModel model, + Widget child) => + PharmacyAppScaffold( appBarTitle: title, isBottomBar: false, isShowAppBar: true, @@ -98,7 +102,8 @@ class _SubCategorisePageState extends State { ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' : parentId == '9' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' - : parentId == '10' + : parentId == + '10' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' : '', fit: BoxFit.fill, @@ -110,12 +115,14 @@ class _SubCategorisePageState extends State { children: [ InkWell( child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Padding( padding: EdgeInsets.all(10.0), child: Container( - child: Texts(TranslationBase.of(context).viewCategorise), + child: Texts(TranslationBase.of(context) + .viewCategorise), ), ), Icon(Icons.arrow_forward) @@ -127,21 +134,37 @@ class _SubCategorisePageState extends State { context: context, builder: (BuildContext context) { return Container( - height: MediaQuery.of(context).size.height * 0.89, + height: + MediaQuery.of(context).size.height * + 0.89, color: Colors.white, child: Center( child: ListView.builder( scrollDirection: Axis.vertical, - itemCount: model.subCategorise.length, - itemBuilder: (BuildContext context, int index) { + itemCount: + model.subCategorise.length, + itemBuilder: (BuildContext context, + int index) { return Container( child: Padding( padding: EdgeInsets.all(8.0), child: InkWell( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ - Texts(projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, + Texts( + projectViewModel + .isArabic + ? model + .subCategorise[ + index] + .namen + : model + .subCategorise[ + index] + .name, // model.subCategorise[index].name ), Divider( @@ -154,8 +177,12 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: FinalProductsPage( - id: model.subCategorise[index].id, + page: + FinalProductsPage( + id: model + .subCategorise[ + index] + .id, ), ), ); @@ -188,19 +215,23 @@ class _SubCategorisePageState extends State { itemCount: model.subCategorise.length, itemBuilder: (BuildContext context, int index) { return Padding( - padding: EdgeInsets.symmetric(horizontal: 8.0), + padding: + EdgeInsets.symmetric(horizontal: 8.0), child: InkWell( child: Column( - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ Padding( - padding: EdgeInsets.symmetric(horizontal: 13.0), + padding: EdgeInsets.symmetric( + horizontal: 13.0), child: Container( height: 60.0, width: 65.0, decoration: BoxDecoration( shape: BoxShape.circle, - color: Colors.orange.shade200.withOpacity(0.45), + color: Colors.orange.shade200 + .withOpacity(0.45), ), child: Center( child: Icon( @@ -211,12 +242,22 @@ class _SubCategorisePageState extends State { ), ), Container( - width: MediaQuery.of(context).size.width * 0.17, - height: MediaQuery.of(context).size.height * 0.10, + width: MediaQuery.of(context) + .size + .width * + 0.17, + height: MediaQuery.of(context) + .size + .height * + 0.10, child: Center( child: Texts( - projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, - // model.subCategorise[index].name, + projectViewModel.isArabic + ? model.subCategorise[index] + .namen + : model.subCategorise[index] + .name, + // model.subCategorise[index].name, fontSize: 14, fontWeight: FontWeight.w600, maxLines: 2, @@ -274,16 +315,21 @@ class _SubCategorisePageState extends State { initialChildSize: 0.95, maxChildSize: 0.95, minChildSize: 0.9, - builder: (BuildContext context, ScrollController scrollController) { + builder: (BuildContext context, + ScrollController scrollController) { return SingleChildScrollView( controller: scrollController, child: Container( color: Colors.white, - height: MediaQuery.of(context).size.height * 1.95, + height: MediaQuery.of(context) + .size + .height * + 1.95, child: Column( children: [ Padding( - padding: EdgeInsets.all(8.0), + padding: + EdgeInsets.all(8.0), child: Row( children: [ Icon( @@ -293,23 +339,30 @@ class _SubCategorisePageState extends State { width: 10.0, ), Texts( - TranslationBase.of(context).refine, + TranslationBase.of( + context) + .refine, // 'Refine', - fontWeight: FontWeight.w600, + fontWeight: + FontWeight.w600, ), SizedBox( width: 250.0, ), InkWell( child: Texts( - TranslationBase.of(context).closeIt, + TranslationBase.of( + context) + .closeIt, // 'Close', color: Colors.red, - fontWeight: FontWeight.w600, + fontWeight: + FontWeight.w600, fontSize: 15.0, ), onTap: () { - Navigator.pop(context); + Navigator.pop( + context); }, ), ], @@ -322,26 +375,39 @@ class _SubCategorisePageState extends State { Column( children: [ ExpansionTile( - title: Texts(TranslationBase.of(context).categorise), + title: Texts( + TranslationBase.of( + context) + .categorise), children: [ ProcedureListWidget( model: model, - masterList: model.subCategorise, - removeHistory: (item) { + masterList: model + .subCategorise, + removeHistory: + (item) { setState(() { - entityList.remove(item); + entityList + .remove( + item); }); }, - addHistory: (history) { + addHistory: + (history) { setState(() { - entityList.add(history); + entityList.add( + history); }); }, - addSelectedHistories: () { + addSelectedHistories: + () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: (master) => isEntityListSelected(master), + isEntityListSelected: + (master) => + isEntityListSelected( + master), ) ], ), @@ -350,26 +416,40 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts(TranslationBase.of(context).brands), + title: Texts( + TranslationBase.of( + context) + .brands), children: [ ProcedureListWidget( model: model, - masterList: model.brandsList, - removeHistory: (item) { + masterList: model + .brandsList, + removeHistory: + (item) { setState(() { - entityListBrands.remove(item); + entityListBrands + .remove( + item); }); }, - addHistory: (history) { + addHistory: + (history) { setState(() { - entityListBrands.add(history); + entityListBrands + .add( + history); }); }, - addSelectedHistories: () { + addSelectedHistories: + () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: (master) => isEntityListSelectedBrands(master), + isEntityListSelected: + (master) => + isEntityListSelectedBrands( + master), ) ], ), @@ -378,43 +458,71 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts(TranslationBase.of(context).price), + title: Texts( + TranslationBase.of( + context) + .price), children: [ Container( - color: Color(0xffEEEEEE), + color: Color( + 0xffEEEEEE), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + mainAxisAlignment: + MainAxisAlignment + .spaceAround, children: [ Column( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .start, children: [ - Texts(TranslationBase.of(context).min), + Texts(TranslationBase.of( + context) + .min), Container( - color: Colors.white, - width: 200, - height: 40, - child: TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), + color: Colors + .white, + width: + 200, + height: + 40, + child: + TextFormField( + decoration: + InputDecoration( + border: + OutlineInputBorder(), ), - controller: minField, + controller: + minField, ), ), ], ), Column( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .start, children: [ - Texts(TranslationBase.of(context).max), + Texts(TranslationBase.of( + context) + .max), Container( - color: Colors.white, - width: 200, - height: 40, - child: TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), + color: Colors + .white, + width: + 200, + height: + 40, + child: + TextFormField( + decoration: + InputDecoration( + border: + OutlineInputBorder(), ), - controller: maxField, + controller: + maxField, ), ), ], @@ -429,20 +537,31 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), SizedBox( - height: MediaQuery.of(context).size.height * 0.4, + height: MediaQuery.of( + context) + .size + .height * + 0.4, ), Padding( - padding: EdgeInsets.all(8.0), + padding: + EdgeInsets.all(8.0), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisAlignment: + MainAxisAlignment + .spaceEvenly, children: [ Expanded( child: Container( width: 100, child: Button( - label: TranslationBase.of(context).reset, + label: TranslationBase.of( + context) + .reset, // 'Reset', - backgroundColor: Colors.red, + backgroundColor: + Colors + .red, ), ), ), @@ -452,33 +571,66 @@ class _SubCategorisePageState extends State { Container( width: 200, child: Button( - onTap: () async { - String categoriesId = ""; - for (CategoriseParentModel category in entityList) { - if (categoriesId == "") { - categoriesId = category.id; + onTap: + () async { + String + categoriesId = + ""; + for (CategoriseParentModel category + in entityList) { + if (categoriesId == + "") { + categoriesId = + category + .id; } else { - categoriesId = "$categoriesId,${category.id}"; + categoriesId = + "$categoriesId,${category.id}"; } } - String brandIds = ""; - for (CategoriseParentModel brand in entityListBrands) { - if (brandIds == "") { - brandIds = brand.id; + String + brandIds = + ""; + for (CategoriseParentModel brand + in entityListBrands) { + if (brandIds == + "") { + brandIds = + brand + .id; } else { - brandIds = "$brandIds,${brand.id}"; + brandIds = + "$brandIds,${brand.id}"; } } - GifLoaderDialogUtils.showMyDialog(context); + GifLoaderDialogUtils + .showMyDialog( + context); await model.getFilteredSubProducts( - min: minField.text.toString(), max: maxField.text.toString(), categoryId: categoriesId, brandId: brandIds); - GifLoaderDialogUtils.hideDialog(context); - Navigator.pop(context); + min: minField + .text + .toString(), + max: maxField + .text + .toString(), + categoryId: + categoriesId, + brandId: + brandIds); + GifLoaderDialogUtils + .hideDialog( + context); + Navigator.pop( + context); }, - label: TranslationBase.of(context).apply, + label: TranslationBase.of( + context) + .apply, // 'Apply', - backgroundColor: Colors.green, + backgroundColor: + Colors + .green, ), ), ], @@ -545,22 +697,30 @@ class _SubCategorisePageState extends State { model.subProducts.isNotEmpty ? styleOne == true ? Container( - height: model.subProducts.length * MediaQuery.of(context).size.height * 0.15, + height: model.subProducts.length * + MediaQuery.of(context).size.height * + 0.15, child: GridView.builder( physics: NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 0.5, mainAxisSpacing: 2.0, childAspectRatio: 0.9, ), itemCount: model.subProducts.length, - itemBuilder: (BuildContext context, int index) { + itemBuilder: + (BuildContext context, int index) { return NetworkBaseView( baseViewModel: model, child: InkWell( child: Card( - color: model.subProducts[index].discountName != null ? Color(0xffFFFF00) : Colors.white, + color: model.subProducts[index] + .discountName != + null + ? Color(0xffFFFF00) + : Colors.white, elevation: 0, shape: Border( right: BorderSide( @@ -586,45 +746,95 @@ class _SubCategorisePageState extends State { ), 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: 0), - width: MediaQuery.of(context).size.width / 3, + padding: EdgeInsets.symmetric( + horizontal: 0), + width: MediaQuery.of(context) + .size + .width / + 3, child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Stack( children: [ Container( - margin: EdgeInsets.fromLTRB(0, 16, 0, 0), - alignment: Alignment.center, + margin: EdgeInsets + .fromLTRB( + 0, 16, 0, 0), + alignment: + Alignment.center, child: Image.network( - model.subProducts[index].images.isNotEmpty - ? model.subProducts[index].images[0].thumb + model + .subProducts[ + index] + .images + .isNotEmpty + ? model + .subProducts[ + 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.subProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 5 : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), - borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), + width: model + .subProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5 + : 0, + padding: + EdgeInsets.all(4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), + borderRadius: + BorderRadius.only( + topLeft: Radius + .circular( + 6)), ), - child:model.subProducts[index].rxMessage != null ? - Texts(projectProvider.isArabic - ? model.subProducts[index].rxMessagen - : model.subProducts[index].rxMessage, - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ) + child: model + .subProducts[ + index] + .rxMessage != + null + ? Texts( + projectProvider + .isArabic + ? model + .subProducts[ + index] + .rxMessagen + : model + .subProducts[ + index] + .rxMessage, + color: Colors + .white, + regular: true, + fontSize: 10, + fontWeight: + FontWeight + .w400, + ) : Texts(""), // Texts( // model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", @@ -637,22 +847,39 @@ class _SubCategorisePageState extends State { ], ), Container( - margin: EdgeInsets.symmetric( + margin: + EdgeInsets.symmetric( horizontal: 6, vertical: 0, ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ Texts( - projectViewModel.isArabic ? model.subProducts[index].namen : model.subProducts[index].name, + projectViewModel + .isArabic + ? model + .subProducts[ + index] + .namen + : model + .subProducts[ + index] + .name, // model.subProducts[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.subProducts[index].price}", bold: true, @@ -666,21 +893,37 @@ class _SubCategorisePageState extends State { // ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() // : 0, // forceStars: true), - RatingBar.readOnly( - initialRating: model.subProducts[index].approvedRatingSum.toDouble(), + RatingBar + .readOnly( + initialRating: model + .subProducts[ + 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, + filledColor: + Colors.yellow[ + 700], + emptyColor: + Colors.grey[ + 500], + isHalfAllowed: + true, + halfFilledIcon: + Icons + .star_half, + filledIcon: + Icons.star, + emptyIcon: + Icons.star, ), Texts( "(${model.subProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight + .w400, ) ], ), @@ -695,7 +938,9 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage(model.subProducts[index]), + page: ProductDetailPage( + model.subProducts[ + index]), )), }, )); @@ -703,11 +948,14 @@ class _SubCategorisePageState extends State { ), ) : Container( - height: model.subProducts.length * MediaQuery.of(context).size.height * 0.122, + height: model.subProducts.length * + MediaQuery.of(context).size.height * + 0.122, child: ListView.builder( physics: NeverScrollableScrollPhysics(), itemCount: model.subProducts.length, - itemBuilder: (BuildContext context, int index) { + itemBuilder: + (BuildContext context, int index) { return InkWell( child: Card( child: Row( @@ -717,9 +965,11 @@ class _SubCategorisePageState extends State { Column( children: [ Container( - decoration: BoxDecoration(), + decoration: + BoxDecoration(), child: Padding( - padding: EdgeInsets.only( + padding: + EdgeInsets.only( left: 9.0, top: 8.0, right: 10.0, @@ -727,36 +977,82 @@ class _SubCategorisePageState extends State { ), ), Container( - margin: EdgeInsets.fromLTRB(0, 0, 0, 0), - alignment: Alignment.center, - child: model.subProducts[index].images.isNotEmpty + margin: EdgeInsets + .fromLTRB( + 0, 0, 0, 0), + alignment: + Alignment.center, + child: model + .subProducts[ + index] + .images + .isNotEmpty ? Image.network( - model.subProducts[index].images[0].thumb, - fit: BoxFit.contain, - height: 70, - ) - : Text(TranslationBase.of(context).noImage), + model + .subProducts[ + index] + .images[0] + .thumb, + fit: BoxFit + .contain, + height: 70, + ) + : Text(TranslationBase + .of(context) + .noImage), ), ], ), Column( children: [ Container( - width: model.subProducts[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)), + width: model + .subProducts[ + 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.subProducts[index].rxMessage != null ? - Texts(projectProvider.isArabic - ? model.subProducts[index].rxMessagen - : model.subProducts[index].rxMessage, - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ) + child: model + .subProducts[ + index] + .rxMessage != + null + ? Texts( + projectProvider + .isArabic + ? model + .subProducts[ + index] + .rxMessagen + : model + .subProducts[ + index] + .rxMessage, + color: Colors + .white, + regular: true, + fontSize: 10, + fontWeight: + FontWeight + .w400, + ) : Texts(""), // Texts( // model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", @@ -777,20 +1073,38 @@ class _SubCategorisePageState extends State { vertical: 0, ), child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ SizedBox( height: 4.0, ), Container( - width: MediaQuery.of(context).size.width * 0.65, + width: MediaQuery.of( + context) + .size + .width * + 0.65, child: Texts( - projectViewModel.isArabic ? model.subProducts[index].namen : model.subProducts[index].name, - // model.subProducts[index].name, + projectViewModel + .isArabic + ? model + .subProducts[ + index] + .namen + : model + .subProducts[ + index] + .name, + // model.subProducts[index].name, regular: true, fontSize: 13.2, - fontWeight: FontWeight.w500, + fontWeight: + FontWeight.w500, maxLines: 5, ), ), @@ -798,7 +1112,11 @@ class _SubCategorisePageState extends State { height: 8.0, ), Padding( - padding: const EdgeInsets.only(top: 4, bottom: 4), + padding: + const EdgeInsets + .only( + top: 4, + bottom: 4), child: Texts( "SAR ${model.subProducts[index].price}", bold: true, @@ -813,41 +1131,74 @@ class _SubCategorisePageState extends State { // : 0, // forceStars: true), RatingBar.readOnly( - initialRating: model.subProducts[index].approvedRatingSum.toDouble(), + initialRating: model + .subProducts[ + index] + .approvedRatingSum + .toDouble(), size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], + filledColor: Colors + .yellow[700], + emptyColor: Colors + .grey[500], isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + halfFilledIcon: + Icons.star_half, + filledIcon: + Icons.star, + emptyIcon: + Icons.star, ), Texts( "(${model.subProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight.w400, ) ], ), ], ), ), - widget.authenticatedUserObject.isLogin + widget.authenticatedUserObject + .isLogin ? Container( child: IconButton( icon: Icon( - Icons.shopping_cart, + Icons + .shopping_cart, size: 18, - color: CustomColors.green, + color: + CustomColors + .green, ), - onPressed: () async { - if (model.subProducts[index].rxMessage == null) { - GifLoaderDialogUtils.showMyDialog(context); - await addToCartFunction(1, model.subProducts[index].id); - GifLoaderDialogUtils.hideDialog(context); - Utils.navigateToCartPage(); } else { - AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); + onPressed: + () async { + if (model + .subProducts[ + index] + .rxMessage == + null) { + GifLoaderDialogUtils + .showMyDialog( + context); + await addToCartFunction( + 1, + model + .subProducts[ + index] + .id); + GifLoaderDialogUtils + .hideDialog( + context); + Utils + .navigateToCartPage(); + } else { + AppToast.showErrorToast( + message: TranslationBase.of( + context) + .needPrescription); } }), ) @@ -859,7 +1210,8 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage(model.subProducts[index]), + page: ProductDetailPage( + model.subProducts[index]), )), }, ); @@ -901,7 +1253,8 @@ class _SubCategorisePageState extends State { } bool isEntityListSelected(CategoriseParentModel masterKey) { - Iterable history = entityList.where((element) => masterKey.id == element.id); + Iterable history = + entityList.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } @@ -909,7 +1262,8 @@ class _SubCategorisePageState extends State { } bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { - Iterable history = entityListBrands.where((element) => masterKey.id == element.id); + Iterable history = + entityListBrands.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } From 7a8ed5b0146b935ce0c0c5aeae17b0d79f2b20c7 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 10 Nov 2021 18:05:07 +0300 Subject: [PATCH 59/70] Total amount calculation fixes --- lib/core/model/pharmacies/ShoppingCartResponse.dart | 4 +++- lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart | 4 +++- .../pharmacies/screens/cart-page/cart-order-preview.dart | 2 +- .../pharmacies/screens/cart-page/payment_bottom_widget.dart | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/core/model/pharmacies/ShoppingCartResponse.dart b/lib/core/model/pharmacies/ShoppingCartResponse.dart index 332f63b6..1d90464d 100644 --- a/lib/core/model/pharmacies/ShoppingCartResponse.dart +++ b/lib/core/model/pharmacies/ShoppingCartResponse.dart @@ -8,6 +8,7 @@ class ShoppingCartResponse { double subtotalWithVat; double subtotalVatAmount; double subtotalVatRate; + double totalAmount; List shoppingCarts; ShoppingCartResponse( @@ -16,7 +17,8 @@ class ShoppingCartResponse { this.subtotal=0.0, this.subtotalWithVat = 0.0, this.subtotalVatAmount = 0.0, - this.subtotalVatRate = 0.0 , + this.subtotalVatRate = 0.0, + this.totalAmount = 0.0, this.shoppingCarts}); diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index d498d095..7d908441 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -107,6 +107,7 @@ class OrderPreviewViewModel extends BaseViewModel { } ShoppingCartResponse _handleGetShoppingCartResponse(Map res) { + cartResponse.totalAmount = 0.0; totalAdditionalShippingCharge = 0; if (res == null) { error = "response is null"; @@ -124,7 +125,7 @@ class OrderPreviewViewModel extends BaseViewModel { if (paymentCheckoutData.shippingOption != null) { totalAdditionalShippingCharge = paymentCheckoutData.shippingOption.rate; cartResponse.subtotalVatAmount += paymentCheckoutData.shippingOption.rateVat; - cartResponse.subtotal += paymentCheckoutData.shippingOption.rate + paymentCheckoutData.shippingOption.rateVat; + cartResponse.totalAmount += (paymentCheckoutData.shippingOption.rate + paymentCheckoutData.shippingOption.rateVat); } res["shopping_carts"].forEach((item) { @@ -132,6 +133,7 @@ class OrderPreviewViewModel extends BaseViewModel { cartResponse.shoppingCarts.add(shoppingCart); totalAdditionalShippingCharge += shoppingCart.product.additionalShippingCharge; }); + cartResponse.totalAmount = (cartResponse.subtotalWithVat + totalAdditionalShippingCharge + paymentCheckoutData.shippingOption.rateVat); return cartResponse; } diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart index 8fab19c0..0110984c 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart @@ -200,7 +200,7 @@ class _OrderPreviewPageState extends State { fontWeight: FontWeight.bold, ), Texts( - "${TranslationBase.of(context).sar} ${(widget.model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(widget.model.cartResponse.totalAmount).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.bold, 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 45e37abd..24592fe7 100644 --- a/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart @@ -40,7 +40,7 @@ class PaymentBottomWidget extends StatelessWidget { child: Row( children: [ Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(model.cartResponse.totalAmount).toStringAsFixed(2)}", fontSize: 14, fontWeight: FontWeight.bold, color: Color(0xff929295), From 464ad9a3cba67685888719fb2350f678b647cb3c Mon Sep 17 00:00:00 2001 From: Haroon Amjad Date: Wed, 10 Nov 2021 22:18:30 +0300 Subject: [PATCH 60/70] Shopping cart fix --- lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index 7d908441..4aa01776 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -133,7 +133,7 @@ class OrderPreviewViewModel extends BaseViewModel { cartResponse.shoppingCarts.add(shoppingCart); totalAdditionalShippingCharge += shoppingCart.product.additionalShippingCharge; }); - cartResponse.totalAmount = (cartResponse.subtotalWithVat + totalAdditionalShippingCharge + paymentCheckoutData.shippingOption.rateVat); + if (paymentCheckoutData.shippingOption != null) cartResponse.totalAmount = (cartResponse.subtotalWithVat + totalAdditionalShippingCharge + paymentCheckoutData.shippingOption.rateVat); return cartResponse; } From 9ccb155761f2c8074d460a029d7f89f91caaa553 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Thu, 11 Nov 2021 09:19:26 +0200 Subject: [PATCH 61/70] sub categorise fix --- lib/pages/sub_categorise_page.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index c82c1063..d28adc10 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -68,6 +68,7 @@ class _SubCategorisePageState extends State { ProjectViewModel projectProvider = Provider.of(context); return BaseView( onModelReady: (model) => model.getSubCategorise(i: id), + allowAny: true, builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( From d630c6c45f4c3fa464b2a3c065fa957b856c623d Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Thu, 11 Nov 2021 11:00:35 +0300 Subject: [PATCH 62/70] Pharmacy fixes --- lib/config/localized_values.dart | 2 +- .../product_detail_view_model.dart | 4 +- .../product-details/product-detail.dart | 97 +-- lib/pages/sub_categorise_page.dart | 695 +++++------------- .../product_detail_service.dart | 4 +- 5 files changed, 207 insertions(+), 595 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 54a04592..aef5913f 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -636,7 +636,7 @@ const Map localizedValues = { "compareListFull": {"en": "Your compare list is full", "ar": "قائمة المقارنة ممتلئه"}, "addQuantity": {"en": "You should add quantity", "ar": "اختر الكمية"}, "addToCartMsg": {"en": "You have added a product to the cart", "ar": "تمت اضافة المنتج بنجاح"}, - "addToWishlistMsg": {"en": "You have added a product to the Wishlist", "ar": "تمت الاضافة لقائمة الرغبات"}, + "addToWishlistMsg": {"en": "You have added a product to the Wishlist", "ar": "تمت الاضافة لقائمة المفضله"}, "notifyMeMsg": {"en": "You will be notified when product available", "ar": "سيتم اخبارك في حال توفر المنتج"}, "removeFromWishlistMsg": {"en": "You have removed a product from the Wishlist", "ar": "تمت ازالة المنتج بنجاح"}, "min": {"en": "Min", "ar": "اقل"}, diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index 68483a93..df895e28 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -46,10 +46,10 @@ class ProductDetailViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getProductLocationData() async { + Future getProductLocationData(String productSKU) async { hasError = false; setState(ViewState.BusyLocal); - await _productDetailService.getProductAvailabiltyDetail(); + await _productDetailService.getProductAvailabiltyDetail(productSKU); if (_productDetailService.hasError) { error = _productDetailService.error; setState(ViewState.ErrorLocal); diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 51580c2c..ad802349 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -4,7 +4,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart' import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.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'; @@ -15,8 +14,6 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -111,8 +108,7 @@ class __ProductDetailPageState extends State { await addToWishlistFunction(itemID: itemID, model: model); }, deleteFromWishlistFunction: () async { - await deleteFromWishlistFunction( - itemID: itemID, model: model); + await deleteFromWishlistFunction(itemID: itemID, model: model); }, isInWishList: isInWishList, addToCartFunction: addToCartFunction, @@ -133,8 +129,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) ], ), ), @@ -152,21 +147,15 @@ 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, isStockAvailable: model.isStockAvailable, - stockAvailability: projectViewModel.isArabic - ? model.stockAvailabilityn - : model.stockAvailability, + stockAvailability: projectViewModel.isArabic ? model.stockAvailabilityn : model.stockAvailability, ), ), SizedBox( @@ -179,8 +168,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, @@ -217,16 +205,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, ) ], ), @@ -237,14 +221,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(); } @@ -256,16 +236,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, ), ], ), @@ -276,9 +252,8 @@ class __ProductDetailPageState extends State { children: [ FlatButton( onPressed: () async { - GifLoaderDialogUtils.showMyDialog( - context); - await model.getProductLocationData(); + GifLoaderDialogUtils.showMyDialog(context); + await model.getProductLocationData(widget.product.sku); GifLoaderDialogUtils.hideDialog(context); setState(() { @@ -289,16 +264,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, ), ], ), @@ -327,24 +298,22 @@ class __ProductDetailPageState extends State { SizedBox( height: 10, ), - RecommendedProducts( - product: widget.product, - productDetailViewModel: model, - addToWishlistFunction: (itemID) async { - await addToWishlistFunction( - itemID: itemID, model: model); - }, - deleteFromWishlistFunction: (itemID) async { - await deleteFromWishlistFunction( - itemID: itemID, model: model); - }, - ) + if (projectViewModel.isLogin) + RecommendedProducts( + product: widget.product, + productDetailViewModel: model, + addToWishlistFunction: (itemID) async { + await addToWishlistFunction(itemID: itemID, model: model); + }, + deleteFromWishlistFunction: (itemID) async { + await deleteFromWishlistFunction(itemID: itemID, model: model); + }, + ) ], ), ), // : AppCircularProgressIndicator(), - bottomSheet: model.state == ViewState.Idle || - model.state == ViewState.ErrorLocal + bottomSheet: model.state == ViewState.Idle || model.state == ViewState.ErrorLocal ? FooterWidget( model.isStockAvailable, widget.product.orderMaximumQuantity, @@ -361,8 +330,7 @@ class __ProductDetailPageState extends State { )); } - addToShoppingCartFunction( - {quantity, itemID, ProductDetailViewModel model}) async { + addToShoppingCartFunction({quantity, itemID, ProductDetailViewModel model}) async { GifLoaderDialogUtils.showMyDialog(context); await model.addToCartData(quantity, itemID, context); GifLoaderDialogUtils.hideDialog(context); @@ -392,7 +360,6 @@ class __ProductDetailPageState extends State { } } -notifyMeWhenAvailable( - {itemId, customerId, ProductDetailViewModel model, context}) async { +notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model, context}) async { await model.notifyMe(customerId, itemId, context); } diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index c82c1063..e4200239 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -4,7 +4,6 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_deta import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_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/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; @@ -13,7 +12,6 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; 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/entity_checkbox_list.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; @@ -30,14 +28,12 @@ class SubCategorisePage extends StatefulWidget { String title; String parentId; - AuthenticatedUserObject authenticatedUserObject = - locator(); + AuthenticatedUserObject authenticatedUserObject = locator(); SubCategorisePage({this.id, this.parentId, this.title}); @override - _SubCategorisePageState createState() => - _SubCategorisePageState(id: id, title: title, parentId: parentId); + _SubCategorisePageState createState() => _SubCategorisePageState(id: id, title: title, parentId: parentId); } class _SubCategorisePageState extends State { @@ -67,10 +63,9 @@ class _SubCategorisePageState extends State { ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectProvider = Provider.of(context); return BaseView( + allowAny: true, onModelReady: (model) => model.getSubCategorise(i: id), - builder: (BuildContext context, PharmacyCategoriseViewModel model, - Widget child) => - PharmacyAppScaffold( + builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( appBarTitle: title, isBottomBar: false, isShowAppBar: true, @@ -102,8 +97,7 @@ class _SubCategorisePageState extends State { ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' : parentId == '9' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' - : parentId == - '10' + : parentId == '10' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' : '', fit: BoxFit.fill, @@ -115,14 +109,12 @@ class _SubCategorisePageState extends State { children: [ InkWell( child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: EdgeInsets.all(10.0), child: Container( - child: Texts(TranslationBase.of(context) - .viewCategorise), + child: Texts(TranslationBase.of(context).viewCategorise), ), ), Icon(Icons.arrow_forward) @@ -134,37 +126,22 @@ class _SubCategorisePageState extends State { context: context, builder: (BuildContext context) { return Container( - height: - MediaQuery.of(context).size.height * - 0.89, + height: MediaQuery.of(context).size.height * 0.89, color: Colors.white, child: Center( child: ListView.builder( scrollDirection: Axis.vertical, - itemCount: - model.subCategorise.length, - itemBuilder: (BuildContext context, - int index) { + itemCount: model.subCategorise.length, + itemBuilder: (BuildContext context, int index) { return Container( child: Padding( padding: EdgeInsets.all(8.0), child: InkWell( child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - projectViewModel - .isArabic - ? model - .subCategorise[ - index] - .namen - : model - .subCategorise[ - index] - .name, + projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, // model.subCategorise[index].name ), Divider( @@ -177,12 +154,8 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: - FinalProductsPage( - id: model - .subCategorise[ - index] - .id, + page: FinalProductsPage( + id: model.subCategorise[index].id, ), ), ); @@ -215,23 +188,19 @@ class _SubCategorisePageState extends State { itemCount: model.subCategorise.length, itemBuilder: (BuildContext context, int index) { return Padding( - padding: - EdgeInsets.symmetric(horizontal: 8.0), + padding: EdgeInsets.symmetric(horizontal: 8.0), child: InkWell( child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ Padding( - padding: EdgeInsets.symmetric( - horizontal: 13.0), + padding: EdgeInsets.symmetric(horizontal: 13.0), child: Container( height: 60.0, width: 65.0, decoration: BoxDecoration( shape: BoxShape.circle, - color: Colors.orange.shade200 - .withOpacity(0.45), + color: Colors.orange.shade200.withOpacity(0.45), ), child: Center( child: Icon( @@ -242,21 +211,11 @@ class _SubCategorisePageState extends State { ), ), Container( - width: MediaQuery.of(context) - .size - .width * - 0.17, - height: MediaQuery.of(context) - .size - .height * - 0.10, + width: MediaQuery.of(context).size.width * 0.17, + height: MediaQuery.of(context).size.height * 0.10, child: Center( child: Texts( - projectViewModel.isArabic - ? model.subCategorise[index] - .namen - : model.subCategorise[index] - .name, + projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, // model.subCategorise[index].name, fontSize: 14, fontWeight: FontWeight.w600, @@ -315,21 +274,16 @@ class _SubCategorisePageState extends State { initialChildSize: 0.95, maxChildSize: 0.95, minChildSize: 0.9, - builder: (BuildContext context, - ScrollController scrollController) { + builder: (BuildContext context, ScrollController scrollController) { return SingleChildScrollView( controller: scrollController, child: Container( color: Colors.white, - height: MediaQuery.of(context) - .size - .height * - 1.95, + height: MediaQuery.of(context).size.height * 1.95, child: Column( children: [ Padding( - padding: - EdgeInsets.all(8.0), + padding: EdgeInsets.all(8.0), child: Row( children: [ Icon( @@ -339,30 +293,23 @@ class _SubCategorisePageState extends State { width: 10.0, ), Texts( - TranslationBase.of( - context) - .refine, + TranslationBase.of(context).refine, // 'Refine', - fontWeight: - FontWeight.w600, + fontWeight: FontWeight.w600, ), SizedBox( width: 250.0, ), InkWell( child: Texts( - TranslationBase.of( - context) - .closeIt, + TranslationBase.of(context).closeIt, // 'Close', color: Colors.red, - fontWeight: - FontWeight.w600, + fontWeight: FontWeight.w600, fontSize: 15.0, ), onTap: () { - Navigator.pop( - context); + Navigator.pop(context); }, ), ], @@ -375,39 +322,26 @@ class _SubCategorisePageState extends State { Column( children: [ ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .categorise), + title: Texts(TranslationBase.of(context).categorise), children: [ ProcedureListWidget( model: model, - masterList: model - .subCategorise, - removeHistory: - (item) { + masterList: model.subCategorise, + removeHistory: (item) { setState(() { - entityList - .remove( - item); + entityList.remove(item); }); }, - addHistory: - (history) { + addHistory: (history) { setState(() { - entityList.add( - history); + entityList.add(history); }); }, - addSelectedHistories: - () { + addSelectedHistories: () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: - (master) => - isEntityListSelected( - master), + isEntityListSelected: (master) => isEntityListSelected(master), ) ], ), @@ -416,40 +350,26 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .brands), + title: Texts(TranslationBase.of(context).brands), children: [ ProcedureListWidget( model: model, - masterList: model - .brandsList, - removeHistory: - (item) { + masterList: model.brandsList, + removeHistory: (item) { setState(() { - entityListBrands - .remove( - item); + entityListBrands.remove(item); }); }, - addHistory: - (history) { + addHistory: (history) { setState(() { - entityListBrands - .add( - history); + entityListBrands.add(history); }); }, - addSelectedHistories: - () { + addSelectedHistories: () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: - (master) => - isEntityListSelectedBrands( - master), + isEntityListSelected: (master) => isEntityListSelectedBrands(master), ) ], ), @@ -458,71 +378,43 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .price), + title: Texts(TranslationBase.of(context).price), children: [ Container( - color: Color( - 0xffEEEEEE), + color: Color(0xffEEEEEE), child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column( - mainAxisAlignment: - MainAxisAlignment - .start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts(TranslationBase.of( - context) - .min), + Texts(TranslationBase.of(context).min), Container( - color: Colors - .white, - width: - 200, - height: - 40, - child: - TextFormField( - decoration: - InputDecoration( - border: - OutlineInputBorder(), + color: Colors.white, + width: 200, + height: 40, + child: TextFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), ), - controller: - minField, + controller: minField, ), ), ], ), Column( - mainAxisAlignment: - MainAxisAlignment - .start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts(TranslationBase.of( - context) - .max), + Texts(TranslationBase.of(context).max), Container( - color: Colors - .white, - width: - 200, - height: - 40, - child: - TextFormField( - decoration: - InputDecoration( - border: - OutlineInputBorder(), + color: Colors.white, + width: 200, + height: 40, + child: TextFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), ), - controller: - maxField, + controller: maxField, ), ), ], @@ -537,31 +429,20 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), SizedBox( - height: MediaQuery.of( - context) - .size - .height * - 0.4, + height: MediaQuery.of(context).size.height * 0.4, ), Padding( - padding: - EdgeInsets.all(8.0), + padding: EdgeInsets.all(8.0), child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceEvenly, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Expanded( child: Container( width: 100, child: Button( - label: TranslationBase.of( - context) - .reset, + label: TranslationBase.of(context).reset, // 'Reset', - backgroundColor: - Colors - .red, + backgroundColor: Colors.red, ), ), ), @@ -571,66 +452,33 @@ class _SubCategorisePageState extends State { Container( width: 200, child: Button( - onTap: - () async { - String - categoriesId = - ""; - for (CategoriseParentModel category - in entityList) { - if (categoriesId == - "") { - categoriesId = - category - .id; + onTap: () async { + String categoriesId = ""; + for (CategoriseParentModel category in entityList) { + if (categoriesId == "") { + categoriesId = category.id; } else { - categoriesId = - "$categoriesId,${category.id}"; + categoriesId = "$categoriesId,${category.id}"; } } - String - brandIds = - ""; - for (CategoriseParentModel brand - in entityListBrands) { - if (brandIds == - "") { - brandIds = - brand - .id; + String brandIds = ""; + for (CategoriseParentModel brand in entityListBrands) { + if (brandIds == "") { + brandIds = brand.id; } else { - brandIds = - "$brandIds,${brand.id}"; + brandIds = "$brandIds,${brand.id}"; } } - GifLoaderDialogUtils - .showMyDialog( - context); + GifLoaderDialogUtils.showMyDialog(context); await model.getFilteredSubProducts( - min: minField - .text - .toString(), - max: maxField - .text - .toString(), - categoryId: - categoriesId, - brandId: - brandIds); - GifLoaderDialogUtils - .hideDialog( - context); - Navigator.pop( - context); + min: minField.text.toString(), max: maxField.text.toString(), categoryId: categoriesId, brandId: brandIds); + GifLoaderDialogUtils.hideDialog(context); + Navigator.pop(context); }, - label: TranslationBase.of( - context) - .apply, + label: TranslationBase.of(context).apply, // 'Apply', - backgroundColor: - Colors - .green, + backgroundColor: Colors.green, ), ), ], @@ -697,30 +545,22 @@ class _SubCategorisePageState extends State { model.subProducts.isNotEmpty ? styleOne == true ? Container( - height: model.subProducts.length * - MediaQuery.of(context).size.height * - 0.15, + height: model.subProducts.length * MediaQuery.of(context).size.height * 0.15, child: GridView.builder( physics: NeverScrollableScrollPhysics(), - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 0.5, mainAxisSpacing: 2.0, childAspectRatio: 0.9, ), itemCount: model.subProducts.length, - itemBuilder: - (BuildContext context, int index) { + itemBuilder: (BuildContext context, int index) { return NetworkBaseView( baseViewModel: model, child: InkWell( child: Card( - color: model.subProducts[index] - .discountName != - null - ? Color(0xffFFFF00) - : Colors.white, + color: model.subProducts[index].discountName != null ? Color(0xffFFFF00) : Colors.white, elevation: 0, shape: Border( right: BorderSide( @@ -746,94 +586,43 @@ class _SubCategorisePageState extends State { ), 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: 0), - width: MediaQuery.of(context) - .size - .width / - 3, + padding: EdgeInsets.symmetric(horizontal: 0), + width: MediaQuery.of(context).size.width / 3, child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ Container( - margin: EdgeInsets - .fromLTRB( - 0, 16, 0, 0), - alignment: - Alignment.center, + margin: EdgeInsets.fromLTRB(0, 16, 0, 0), + alignment: Alignment.center, child: Image.network( - model - .subProducts[ - index] - .images - .isNotEmpty - ? model - .subProducts[ - index] - .images[0] - .thumb + model.subProducts[index].images.isNotEmpty + ? model.subProducts[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 - .subProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 5 - : 0, - padding: - EdgeInsets.all(4), - decoration: - BoxDecoration( - color: Color( - 0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), + width: model.subProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 5 : 0, + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + color: Color(0xffb23838), + borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: model - .subProducts[ - index] - .rxMessage != - null + child: model.subProducts[index].rxMessage != null ? Texts( - projectProvider - .isArabic - ? model - .subProducts[ - index] - .rxMessagen - : model - .subProducts[ - index] - .rxMessage, - color: Colors - .white, + projectProvider.isArabic ? model.subProducts[index].rxMessagen : model.subProducts[index].rxMessage, + color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight - .w400, + fontWeight: FontWeight.w400, ) : Texts(""), // Texts( @@ -847,39 +636,22 @@ class _SubCategorisePageState extends State { ], ), Container( - margin: - EdgeInsets.symmetric( + margin: EdgeInsets.symmetric( horizontal: 6, vertical: 0, ), child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - projectViewModel - .isArabic - ? model - .subProducts[ - index] - .namen - : model - .subProducts[ - index] - .name, + projectViewModel.isArabic ? model.subProducts[index].namen : model.subProducts[index].name, // model.subProducts[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.subProducts[index].price}", bold: true, @@ -893,37 +665,21 @@ class _SubCategorisePageState extends State { // ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() // : 0, // forceStars: true), - RatingBar - .readOnly( - initialRating: model - .subProducts[ - index] - .approvedRatingSum - .toDouble(), + RatingBar.readOnly( + initialRating: model.subProducts[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, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, ), Texts( "(${model.subProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: - FontWeight - .w400, + fontWeight: FontWeight.w400, ) ], ), @@ -938,9 +694,7 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage( - model.subProducts[ - index]), + page: ProductDetailPage(model.subProducts[index]), )), }, )); @@ -948,14 +702,11 @@ class _SubCategorisePageState extends State { ), ) : Container( - height: model.subProducts.length * - MediaQuery.of(context).size.height * - 0.122, + height: model.subProducts.length * MediaQuery.of(context).size.height * 0.122, child: ListView.builder( physics: NeverScrollableScrollPhysics(), itemCount: model.subProducts.length, - itemBuilder: - (BuildContext context, int index) { + itemBuilder: (BuildContext context, int index) { return InkWell( child: Card( child: Row( @@ -965,11 +716,9 @@ class _SubCategorisePageState extends State { Column( children: [ Container( - decoration: - BoxDecoration(), + decoration: BoxDecoration(), child: Padding( - padding: - EdgeInsets.only( + padding: EdgeInsets.only( left: 9.0, top: 8.0, right: 10.0, @@ -977,81 +726,34 @@ class _SubCategorisePageState extends State { ), ), Container( - margin: EdgeInsets - .fromLTRB( - 0, 0, 0, 0), - alignment: - Alignment.center, - child: model - .subProducts[ - index] - .images - .isNotEmpty + margin: EdgeInsets.fromLTRB(0, 0, 0, 0), + alignment: Alignment.center, + child: model.subProducts[index].images.isNotEmpty ? Image.network( - model - .subProducts[ - index] - .images[0] - .thumb, - fit: BoxFit - .contain, + model.subProducts[index].images[0].thumb, + fit: BoxFit.contain, height: 70, ) - : Text(TranslationBase - .of(context) - .noImage), + : Text(TranslationBase.of(context).noImage), ), ], ), Column( children: [ Container( - width: model - .subProducts[ - 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)), + width: model.subProducts[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 - .subProducts[ - index] - .rxMessage != - null + child: model.subProducts[index].rxMessage != null ? Texts( - projectProvider - .isArabic - ? model - .subProducts[ - index] - .rxMessagen - : model - .subProducts[ - index] - .rxMessage, - color: Colors - .white, + projectProvider.isArabic ? model.subProducts[index].rxMessagen : model.subProducts[index].rxMessage, + color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight - .w400, + fontWeight: FontWeight.w400, ) : Texts(""), // Texts( @@ -1073,38 +775,20 @@ class _SubCategorisePageState extends State { vertical: 0, ), child: Column( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - crossAxisAlignment: - CrossAxisAlignment - .start, + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: 4.0, ), Container( - width: MediaQuery.of( - context) - .size - .width * - 0.65, + width: MediaQuery.of(context).size.width * 0.65, child: Texts( - projectViewModel - .isArabic - ? model - .subProducts[ - index] - .namen - : model - .subProducts[ - index] - .name, + projectViewModel.isArabic ? model.subProducts[index].namen : model.subProducts[index].name, // model.subProducts[index].name, regular: true, fontSize: 13.2, - fontWeight: - FontWeight.w500, + fontWeight: FontWeight.w500, maxLines: 5, ), ), @@ -1112,11 +796,7 @@ class _SubCategorisePageState extends State { height: 8.0, ), Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), + padding: const EdgeInsets.only(top: 4, bottom: 4), child: Texts( "SAR ${model.subProducts[index].price}", bold: true, @@ -1131,74 +811,42 @@ class _SubCategorisePageState extends State { // : 0, // forceStars: true), RatingBar.readOnly( - initialRating: model - .subProducts[ - index] - .approvedRatingSum - .toDouble(), + initialRating: model.subProducts[index].approvedRatingSum.toDouble(), size: 15.0, - filledColor: Colors - .yellow[700], - emptyColor: Colors - .grey[500], + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], isHalfAllowed: true, - halfFilledIcon: - Icons.star_half, - filledIcon: - Icons.star, - emptyIcon: - Icons.star, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, ), Texts( "(${model.subProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ) ], ), ], ), ), - widget.authenticatedUserObject - .isLogin + widget.authenticatedUserObject.isLogin ? Container( child: IconButton( icon: Icon( - Icons - .shopping_cart, + Icons.shopping_cart, size: 18, - color: - CustomColors - .green, + color: CustomColors.green, ), - onPressed: - () async { - if (model - .subProducts[ - index] - .rxMessage == - null) { - GifLoaderDialogUtils - .showMyDialog( - context); - await addToCartFunction( - 1, - model - .subProducts[ - index] - .id); - GifLoaderDialogUtils - .hideDialog( - context); - Utils - .navigateToCartPage(); + onPressed: () async { + if (model.subProducts[index].rxMessage == null) { + GifLoaderDialogUtils.showMyDialog(context); + await addToCartFunction(1, model.subProducts[index].id); + GifLoaderDialogUtils.hideDialog(context); + Utils.navigateToCartPage(); } else { - AppToast.showErrorToast( - message: TranslationBase.of( - context) - .needPrescription); + AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); } }), ) @@ -1210,8 +858,7 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage( - model.subProducts[index]), + page: ProductDetailPage(model.subProducts[index]), )), }, ); @@ -1253,8 +900,7 @@ class _SubCategorisePageState extends State { } bool isEntityListSelected(CategoriseParentModel masterKey) { - Iterable history = - entityList.where((element) => masterKey.id == element.id); + Iterable history = entityList.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } @@ -1262,8 +908,7 @@ class _SubCategorisePageState extends State { } bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { - Iterable history = - entityListBrands.where((element) => masterKey.id == element.id); + Iterable history = entityListBrands.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 47fefded..e3e0fb7f 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -66,7 +66,7 @@ class ProductDetailService extends BaseService { }); } - Future getProductAvailabiltyDetail() async { + Future getProductAvailabiltyDetail(String productSKU) async { hasError = false; Map request; @@ -76,7 +76,7 @@ class ProductDetailService extends BaseService { // "IPAdress": "10.20.10.20", // "LanguageID": 2, // "PatientOutSA": 0, - // "SKU": "6720020025", + "SKU": productSKU, // "SessionID": null, // "VersionID": 5.6, // "generalid": "Cs2020@2016\$2958", From fb1d07fcbad03e0ef60c26b57541be4c9c745dc0 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 11 Nov 2021 10:56:33 +0200 Subject: [PATCH 63/70] fix cart back button --- lib/pages/pharmacies/screens/cart-page/cart-order-page.dart | 5 +++++ pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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..9d096053 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -9,6 +9,7 @@ import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderItem.d import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.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.dart'; import 'package:diplomaticquarterapp/widgets/buttons/GestureIconButton.dart'; @@ -20,6 +21,7 @@ import 'package:flutter/material.dart'; import 'package:http/http.dart'; import 'package:provider/provider.dart'; +import '../../../../locator.dart'; import 'cart-order-preview.dart'; class CartOrderPage extends StatefulWidget { @@ -55,6 +57,9 @@ class _CartOrderPageState extends State { isMainPharmacyPages: true, showPharmacyCart: false, baseViewModel: model, + backButtonTab: (){ + widget.changeTab(0); + }, backgroundColor: Colors.white, body: NetworkBaseView( isLoading: isLoading, diff --git a/pubspec.yaml b/pubspec.yaml index 57c417a8..73c9cea9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -43,7 +43,7 @@ dependencies: flutter_html: ^1.2.0 # Pagnation - pull_to_refresh: ^1.6.2 + pull_to_refresh: 1.6.2 # Native flutter_device_type: ^0.2.0 From 333247faa2b3fd03887bb7dbc763c0dade83e9ec Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Thu, 11 Nov 2021 12:47:46 +0300 Subject: [PATCH 64/70] fixed issues --- lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart index 1e993694..8dd59e63 100644 --- a/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart +++ b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart @@ -19,6 +19,8 @@ class PrescriptionsWidget extends StatelessWidget { @override Widget build(BuildContext context) { + + ProjectViewModel projectProvider = Provider.of(context); return BaseView( onModelReady: (model) async { if (Provider.of(context, listen: false).isLogin) { @@ -98,7 +100,7 @@ class PrescriptionsWidget extends StatelessWidget { color: Colors.green, borderRadius: BorderRadius.circular(30.0)), child: Text( - model.languageID == "ar" + projectProvider.isArabic ? model.prescriptionsList[index].isInOutPatientDescriptionN.toString() : model.prescriptionsList[index].isInOutPatientDescription.toString(), style: TextStyle( From 300668cc81c53e068fb1592458846892df5534bf Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Thu, 11 Nov 2021 12:03:23 +0200 Subject: [PATCH 65/70] sub Categorise fixed --- .../pharmacy_categorise_view_model.dart | 15 +- lib/pages/parent_categorise_page.dart | 970 ++++---- lib/pages/sub_categorise_page.dart | 2164 +++++++++-------- 3 files changed, 1573 insertions(+), 1576 deletions(-) diff --git a/lib/core/viewModels/pharmacy_categorise_view_model.dart b/lib/core/viewModels/pharmacy_categorise_view_model.dart index 7fb68431..fcae18d2 100644 --- a/lib/core/viewModels/pharmacy_categorise_view_model.dart +++ b/lib/core/viewModels/pharmacy_categorise_view_model.dart @@ -5,6 +5,8 @@ import 'package:diplomaticquarterapp/core/model/pharmacy/pharmacy_categorise.dar import 'package:diplomaticquarterapp/core/model/pharmacy/scan_qr_model.dart'; import 'package:diplomaticquarterapp/core/service/pharmacy_categorise_service.dart'; import 'package:diplomaticquarterapp/locator.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:flutter/cupertino.dart'; import 'base_view_model.dart'; @@ -97,23 +99,29 @@ class PharmacyCategoriseViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getCategoriseParent({String i, int pageIndex, bool isLoading}) async { + Future getCategoriseParent( + {String i, int pageIndex, bool isLoading, BuildContext context}) async { hasError = false; // _insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); + // GifLoaderDialogUtils.showMyDialog(context); await _pharmacyCategoriseService.getCategoriseParent(id: i); if (_pharmacyCategoriseService.hasError) { error = _pharmacyCategoriseService.error; setState(ViewState.ErrorLocal); } else await getBrands(id: i); - await getParentProducts(i: i, pageIndex: pageIndex, isLoading: isLoading); + await getParentProducts( + i: i, pageIndex: pageIndex, isLoading: isLoading, context: context); + // GifLoaderDialogUtils.showMyDialog(context); } - Future getParentProducts({String i, int pageIndex, bool isLoading}) async { + Future getParentProducts( + {String i, int pageIndex, bool isLoading, BuildContext context}) async { hasError = false; // _insuranceCardService.clearInsuranceCard(); setState(ViewState.BusyLocal); + //GifLoaderDialogUtils.showMyDialog(context); await _pharmacyCategoriseService.getParentProducts( id: i, pageNumber: pageIndex, isLoading: isLoading); if (_pharmacyCategoriseService.hasError) { @@ -121,6 +129,7 @@ class PharmacyCategoriseViewModel extends BaseViewModel { setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); + //GifLoaderDialogUtils.hideDialog(context); } Future getSubCategorise({String i}) async { diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index b3a7e092..461e837c 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -14,6 +14,7 @@ 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/uitl/utils.dart'; +import 'package:diplomaticquarterapp/widgets/Loader/gif_loader_container.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; @@ -80,7 +81,7 @@ class _ParentCategorisePageState extends State { ProjectViewModel projectProvider = Provider.of(context); return BaseView( onModelReady: (model) => model.getCategoriseParent( - i: id, pageIndex: pageIndex, isLoading: false), + i: id, pageIndex: pageIndex, isLoading: false, context: context), allowAny: true, builder: (BuildContext context, PharmacyCategoriseViewModel model, @@ -102,7 +103,10 @@ class _ParentCategorisePageState extends State { ++pageIndex; }); await model.getParentProducts( - pageIndex: pageIndex, i: id, isLoading: true); + pageIndex: pageIndex, + i: id, + isLoading: true, + context: context); if (model.state != ViewState.BusyLocal && pageIndex < 5) { controller.loadComplete(); @@ -685,159 +689,150 @@ class _ParentCategorisePageState extends State { ), model.parentProducts.isNotEmpty ? styleOne == true - ? 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), + ? 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, + ), ), - color: Colors.white, - ), - padding: EdgeInsets - .symmetric( - horizontal: 0), - width: MediaQuery.of( - context) - .size - .width / - 3, - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - Stack( + margin: EdgeInsets + .symmetric( + horizontal: 8, + vertical: 4, + ), + 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, children: [ - 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, - ), + Stack( + children: [ + if (model + .parentProducts[index] + .discountName != + null) + RotatedBox( + quarterTurns: + 4, child: - Texts( - TranslationBase.of(context) - .offers - .toUpperCase(), - color: - Colors.red, - fontSize: - 13.0, - fontWeight: - FontWeight.w900, + 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), ), ), - 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( - 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 @@ -887,67 +882,280 @@ 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: 6, + horizontal: 0, vertical: 0, ), child: Column( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, 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 + SizedBox( + height: 4.0, + ), + Container( + width: MediaQuery.of(context) + .size + .width * + 0.635, + child: + Texts( + projectViewModel + .isArabic + ? model + .parentProducts[ + index] + .namen + : model .parentProducts[index] - .discountName, - regular: - true, - color: - Colors.white, - fontSize: - 10.4, - ), - ), + .name, + regular: + true, + fontSize: + 13.2, + fontWeight: + FontWeight + .w500, + maxLines: + 5, ), - Texts( - projectViewModel - .isArabic - ? model - .parentProducts[ - index] - .namen - : model - .parentProducts[index] - .name, - regular: - true, - fontSize: - 12, - fontWeight: - FontWeight - .w700, + ), + SizedBox( + height: 8.0, ), Padding( padding: const EdgeInsets @@ -966,11 +1174,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 @@ -1006,258 +1214,11 @@ class _ParentCategorisePageState extends State { ], ), ), - ], - ), - ), - ), - 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( + widget.authenticatedUserObject + .isLogin + ? Container( + child: IconButton( + icon: Icon( Icons .shopping_cart, size: @@ -1265,8 +1226,7 @@ class _ParentCategorisePageState extends State { color: CustomColors.green, ), - onPressed: - () async { + onPressed: () async { if (model.parentProducts[index].rxMessage == null) { GifLoaderDialogUtils.showMyDialog(context); @@ -1278,54 +1238,66 @@ class _ParentCategorisePageState extends State { AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); } }), - ) - : Container(), - ], + ) + : 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, ), ), - 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), + ), + ) + ], ), - 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/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index d28adc10..25c0f939 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -77,984 +77,774 @@ class _SubCategorisePageState extends State { isShowAppBar: true, backgroundColor: Colors.white, isShowDecPage: false, - baseViewModel: model, - body: SingleChildScrollView( - child: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: Image.network( - parentId == '1' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089188_personal-care_2.png' - : parentId == '2' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089189_skin-care_2.png' - : parentId == '3' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089190_health-care_2.png' - : parentId == '4' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089191_sexual-health_2.png' - : parentId == '5' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089192_beauty_2.png' - : parentId == '6' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089193_baby-child_2.png' - : parentId == '7' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089194_vitamins-supplements_2.png' - : parentId == '8' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' - : parentId == '9' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' - : parentId == - '10' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' - : '', - fit: BoxFit.fill, - height: 160.0, - width: double.infinity), - ), - if (model.subCategorise.length > 8) - Column( - children: [ - InkWell( - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: EdgeInsets.all(10.0), - child: Container( - child: Texts(TranslationBase.of(context) - .viewCategorise), + //baseViewModel: model, + body: NetworkBaseView( + baseViewModel: model, + child: SingleChildScrollView( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Image.network( + parentId == '1' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089188_personal-care_2.png' + : parentId == '2' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089189_skin-care_2.png' + : parentId == '3' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089190_health-care_2.png' + : parentId == '4' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089191_sexual-health_2.png' + : parentId == '5' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089192_beauty_2.png' + : parentId == '6' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089193_baby-child_2.png' + : parentId == '7' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089194_vitamins-supplements_2.png' + : parentId == '8' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' + : parentId == '9' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' + : parentId == + '10' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' + : '', + fit: BoxFit.fill, + height: 160.0, + width: double.infinity), + ), + if (model.subCategorise.length > 8) + Column( + children: [ + InkWell( + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: EdgeInsets.all(10.0), + child: Container( + child: Texts(TranslationBase.of(context) + .viewCategorise), + ), ), - ), - Icon(Icons.arrow_forward) - ], - ), - onTap: () { - showModalBottomSheet( - isScrollControlled: true, - context: context, - builder: (BuildContext context) { - return Container( - height: - MediaQuery.of(context).size.height * - 0.89, - color: Colors.white, - child: Center( - child: ListView.builder( - scrollDirection: Axis.vertical, - itemCount: - model.subCategorise.length, - itemBuilder: (BuildContext context, - int index) { - return Container( - child: Padding( - padding: EdgeInsets.all(8.0), - child: InkWell( - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - Texts( - projectViewModel - .isArabic - ? model - .subCategorise[ - index] - .namen - : model + Icon(Icons.arrow_forward) + ], + ), + onTap: () { + showModalBottomSheet( + isScrollControlled: true, + context: context, + builder: (BuildContext context) { + return Container( + height: + MediaQuery.of(context).size.height * + 0.89, + color: Colors.white, + child: Center( + child: ListView.builder( + scrollDirection: Axis.vertical, + itemCount: + model.subCategorise.length, + itemBuilder: + (BuildContext context, + int index) { + return Container( + child: Padding( + padding: + EdgeInsets.all(8.0), + child: InkWell( + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Texts( + projectViewModel + .isArabic + ? model + .subCategorise[ + index] + .namen + : model + .subCategorise[ + index] + .name, +// model.subCategorise[index].name + ), + Divider( + thickness: 0.6, + color: + Colors.black12, + ) + ], + ), + onTap: () { + Navigator.push( + context, + FadePage( + page: + FinalProductsPage( + id: model .subCategorise[ index] - .name, -// model.subCategorise[index].name - ), - Divider( - thickness: 0.6, - color: Colors.black12, - ) - ], - ), - onTap: () { - Navigator.push( - context, - FadePage( - page: - FinalProductsPage( - id: model - .subCategorise[ - index] - .id, + .id, + ), ), - ), - ); - }, + ); + }, + ), ), - ), - ); - }), - ), - ); - }, - ); - }, - ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, - ), - ], - ), + ); + }), + ), + ); + }, + ); + }, + ), + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + ], + ), //Expanded widget heree if nassery - Padding( - padding: EdgeInsets.only(top: 35.0), - child: Container( - height: MediaQuery.of(context).size.height * 0.2, - child: Center( - child: ListView.builder( - scrollDirection: Axis.horizontal, - itemCount: model.subCategorise.length, - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: - EdgeInsets.symmetric(horizontal: 8.0), - child: InkWell( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Padding( - padding: EdgeInsets.symmetric( - horizontal: 13.0), - child: Container( - height: 60.0, - width: 65.0, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.orange.shade200 - .withOpacity(0.45), + Padding( + padding: EdgeInsets.only(top: 35.0), + child: Container( + height: MediaQuery.of(context).size.height * 0.2, + child: Center( + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: model.subCategorise.length, + itemBuilder: + (BuildContext context, int index) { + return Padding( + padding: + EdgeInsets.symmetric(horizontal: 8.0), + child: InkWell( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Padding( + padding: EdgeInsets.symmetric( + horizontal: 13.0), + child: Container( + height: 60.0, + width: 65.0, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.orange.shade200 + .withOpacity(0.45), + ), + child: Center( + child: Icon( + Icons.apps_sharp, + size: 32.0, + ), + ), ), + ), + Container( + width: MediaQuery.of(context) + .size + .width * + 0.17, + height: MediaQuery.of(context) + .size + .height * + 0.10, child: Center( - child: Icon( - Icons.apps_sharp, - size: 32.0, + child: Texts( + projectViewModel.isArabic + ? model + .subCategorise[index] + .namen + : model + .subCategorise[index] + .name, + // model.subCategorise[index].name, + fontSize: 14, + fontWeight: FontWeight.w600, + maxLines: 2, ), ), ), - ), - Container( - width: MediaQuery.of(context) - .size - .width * - 0.17, - height: MediaQuery.of(context) - .size - .height * - 0.10, - child: Center( - child: Texts( - projectViewModel.isArabic - ? model.subCategorise[index] - .namen - : model.subCategorise[index] - .name, - // model.subCategorise[index].name, - fontSize: 14, - fontWeight: FontWeight.w600, - maxLines: 2, + ], + ), + onTap: () { + Navigator.push( + context, + FadePage( + page: FinalProductsPage( + id: model + .subCategorise[index].id, ), ), - ), - ], + ); + }, ), - onTap: () { - Navigator.push( - context, - FadePage( - page: FinalProductsPage( - id: model.subCategorise[index].id, - ), - ), - ); - }, - ), - ); - }), + ); + }), + ), ), ), - ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Row( - children: [ - Icon(Icons.wrap_text), - SizedBox( - width: 10.0, - ), - Texts( - TranslationBase.of(context).refine, + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + child: Row( + children: [ + Icon(Icons.wrap_text), + SizedBox( + width: 10.0, + ), + Texts( + TranslationBase.of(context).refine, // 'Refine', - fontWeight: FontWeight.w600, - ), - ], - ), - onTap: () { - showModalBottomSheet( - isScrollControlled: true, - context: context, - builder: (BuildContext context) { - return DraggableScrollableSheet( - initialChildSize: 0.95, - maxChildSize: 0.95, - minChildSize: 0.9, - builder: (BuildContext context, - ScrollController scrollController) { - return SingleChildScrollView( - controller: scrollController, - child: Container( - color: Colors.white, - height: MediaQuery.of(context) - .size - .height * - 1.95, - child: Column( - children: [ - Padding( - padding: - EdgeInsets.all(8.0), - child: Row( - children: [ - Icon( - Icons.wrap_text, - ), - SizedBox( - width: 10.0, - ), - Texts( - TranslationBase.of( - context) - .refine, -// 'Refine', - fontWeight: - FontWeight.w600, - ), - SizedBox( - width: 250.0, - ), - InkWell( - child: Texts( + fontWeight: FontWeight.w600, + ), + ], + ), + onTap: () { + showModalBottomSheet( + isScrollControlled: true, + context: context, + builder: (BuildContext context) { + return DraggableScrollableSheet( + initialChildSize: 0.95, + maxChildSize: 0.95, + minChildSize: 0.9, + builder: (BuildContext context, + ScrollController + scrollController) { + return SingleChildScrollView( + controller: scrollController, + child: Container( + color: Colors.white, + height: MediaQuery.of(context) + .size + .height * + 1.95, + child: Column( + children: [ + Padding( + padding: + EdgeInsets.all(8.0), + child: Row( + children: [ + Icon( + Icons.wrap_text, + ), + SizedBox( + width: 10.0, + ), + Texts( TranslationBase.of( context) - .closeIt, -// 'Close', - color: Colors.red, + .refine, +// 'Refine', fontWeight: FontWeight.w600, - fontSize: 15.0, ), - onTap: () { - Navigator.pop( - context); - }, - ), - ], - ), - ), - Divider( - thickness: 1.0, - color: Colors.black12, - ), - Column( - children: [ - ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .categorise), - children: [ - ProcedureListWidget( - model: model, - masterList: model - .subCategorise, - removeHistory: - (item) { - setState(() { - entityList - .remove( - item); - }); - }, - addHistory: - (history) { - setState(() { - entityList.add( - history); - }); - }, - addSelectedHistories: - () { - //TODO build your fun herr - // widget.addSelectedHistories(); - }, - isEntityListSelected: - (master) => - isEntityListSelected( - master), - ) - ], - ), - Divider( - thickness: 1.0, - color: Colors.black12, - ), - ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .brands), - children: [ - ProcedureListWidget( - model: model, - masterList: model - .brandsList, - removeHistory: - (item) { - setState(() { - entityListBrands - .remove( - item); - }); - }, - addHistory: - (history) { - setState(() { - entityListBrands - .add( - history); - }); - }, - addSelectedHistories: - () { - //TODO build your fun herr - // widget.addSelectedHistories(); + SizedBox( + width: 250.0, + ), + InkWell( + child: Texts( + TranslationBase.of( + context) + .closeIt, +// 'Close', + color: Colors.red, + fontWeight: + FontWeight + .w600, + fontSize: 15.0, + ), + onTap: () { + Navigator.pop( + context); }, - isEntityListSelected: - (master) => - isEntityListSelectedBrands( - master), - ) + ), ], ), - Divider( - thickness: 1.0, - color: Colors.black12, - ), - ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .price), - children: [ - Container( - color: Color( - 0xffEEEEEE), - child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - children: [ - Column( - mainAxisAlignment: - MainAxisAlignment - .start, - children: [ - Texts(TranslationBase.of( - context) - .min), - Container( - color: Colors - .white, - width: - 200, - height: - 40, - child: - TextFormField( - decoration: - InputDecoration( - border: - OutlineInputBorder(), + ), + Divider( + thickness: 1.0, + color: Colors.black12, + ), + Column( + children: [ + ExpansionTile( + title: Texts( + TranslationBase.of( + context) + .categorise), + children: [ + ProcedureListWidget( + model: model, + masterList: model + .subCategorise, + removeHistory: + (item) { + setState(() { + entityList + .remove( + item); + }); + }, + addHistory: + (history) { + setState(() { + entityList.add( + history); + }); + }, + addSelectedHistories: + () { + //TODO build your fun herr + // widget.addSelectedHistories(); + }, + isEntityListSelected: + (master) => + isEntityListSelected( + master), + ) + ], + ), + Divider( + thickness: 1.0, + color: Colors.black12, + ), + ExpansionTile( + title: Texts( + TranslationBase.of( + context) + .brands), + children: [ + ProcedureListWidget( + model: model, + masterList: model + .brandsList, + removeHistory: + (item) { + setState(() { + entityListBrands + .remove( + item); + }); + }, + addHistory: + (history) { + setState(() { + entityListBrands + .add( + history); + }); + }, + addSelectedHistories: + () { + //TODO build your fun herr + // widget.addSelectedHistories(); + }, + isEntityListSelected: + (master) => + isEntityListSelectedBrands( + master), + ) + ], + ), + Divider( + thickness: 1.0, + color: Colors.black12, + ), + ExpansionTile( + title: Texts( + TranslationBase.of( + context) + .price), + children: [ + Container( + color: Color( + 0xffEEEEEE), + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + children: [ + Column( + mainAxisAlignment: + MainAxisAlignment + .start, + children: [ + Texts(TranslationBase.of( + context) + .min), + Container( + color: Colors + .white, + width: + 200, + height: + 40, + child: + TextFormField( + decoration: + InputDecoration( + border: + OutlineInputBorder(), + ), + controller: + minField, ), - controller: - minField, ), - ), - ], - ), - Column( - mainAxisAlignment: - MainAxisAlignment - .start, - children: [ - Texts(TranslationBase.of( - context) - .max), - Container( - color: Colors - .white, - width: - 200, - height: - 40, - child: - TextFormField( - decoration: - InputDecoration( - border: - OutlineInputBorder(), + ], + ), + Column( + mainAxisAlignment: + MainAxisAlignment + .start, + children: [ + Texts(TranslationBase.of( + context) + .max), + Container( + color: Colors + .white, + width: + 200, + height: + 40, + child: + TextFormField( + decoration: + InputDecoration( + border: + OutlineInputBorder(), + ), + controller: + maxField, ), - controller: - maxField, ), - ), - ], - ), - ], - ), - ) - ], - ), - Divider( - thickness: 1.0, - color: Colors.black12, - ), - SizedBox( - height: MediaQuery.of( - context) - .size - .height * - 0.4, - ), - Padding( - padding: - EdgeInsets.all(8.0), - child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceEvenly, - children: [ - Expanded( - child: Container( - width: 100, - child: Button( - label: TranslationBase.of( - context) - .reset, + ], + ), + ], + ), + ) + ], + ), + Divider( + thickness: 1.0, + color: Colors.black12, + ), + SizedBox( + height: MediaQuery.of( + context) + .size + .height * + 0.4, + ), + Padding( + padding: + EdgeInsets.all( + 8.0), + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceEvenly, + children: [ + Expanded( + child: + Container( + width: 100, + child: Button( + label: TranslationBase.of( + context) + .reset, // 'Reset', - backgroundColor: - Colors - .red, + backgroundColor: + Colors + .red, + ), ), ), - ), - SizedBox( - width: 30, - ), - Container( - width: 200, - child: Button( - onTap: - () async { - String - categoriesId = - ""; - for (CategoriseParentModel category - in entityList) { - if (categoriesId == - "") { - categoriesId = - category - .id; - } else { - categoriesId = - "$categoriesId,${category.id}"; + SizedBox( + width: 30, + ), + Container( + width: 200, + child: Button( + onTap: + () async { + String + categoriesId = + ""; + for (CategoriseParentModel category + in entityList) { + if (categoriesId == + "") { + categoriesId = + category.id; + } else { + categoriesId = + "$categoriesId,${category.id}"; + } } - } - String - brandIds = - ""; - for (CategoriseParentModel brand - in entityListBrands) { - if (brandIds == - "") { - brandIds = - brand - .id; - } else { - brandIds = - "$brandIds,${brand.id}"; + String + brandIds = + ""; + for (CategoriseParentModel brand + in entityListBrands) { + if (brandIds == + "") { + brandIds = + brand.id; + } else { + brandIds = + "$brandIds,${brand.id}"; + } } - } - GifLoaderDialogUtils - .showMyDialog( - context); + GifLoaderDialogUtils + .showMyDialog( + context); - await model.getFilteredSubProducts( - min: minField - .text - .toString(), - max: maxField - .text - .toString(), - categoryId: - categoriesId, - brandId: - brandIds); - GifLoaderDialogUtils - .hideDialog( - context); - Navigator.pop( - context); - }, - label: TranslationBase.of( - context) - .apply, + await model.getFilteredSubProducts( + min: minField + .text + .toString(), + max: maxField + .text + .toString(), + categoryId: + categoriesId, + brandId: + brandIds); + GifLoaderDialogUtils + .hideDialog( + context); + Navigator.pop( + context); + }, + label: TranslationBase.of( + context) + .apply, // 'Apply', - backgroundColor: - Colors - .green, + backgroundColor: + Colors + .green, + ), ), - ), - ], - ), - ), - ], - ), - ], - ), - ), - ); - }); - }, - ); - }, - ), - Row( - children: [ - Container( - height: 44.0, - child: VerticalDivider( - color: Colors.black45, - thickness: 1.0, - //width: 0.3, - // indent: 0.0, - ), - ), - Padding( - padding: EdgeInsets.all(8.0), - child: InkWell( - child: styleIcon, - onTap: () { - setState(() { - if (styleOne == true) { - styleOne = false; - styleTwo = true; - styleIcon = Icon( - Icons.auto_awesome_mosaic, - color: CustomColors.green, - size: 29.0, - ); - } else { - styleOne = true; - styleTwo = false; - styleIcon = Icon( - Icons.widgets_sharp, - color: CustomColors.green, - size: 29.0, - ); - } - }); - }, - ), - ), - ], - ), - ], - ), - ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, - ), - model.subProducts.isNotEmpty - ? styleOne == true - ? Container( - height: model.subProducts.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.subProducts.length, - itemBuilder: - (BuildContext context, int index) { - return NetworkBaseView( - baseViewModel: model, - child: InkWell( - child: Card( - color: model.subProducts[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), - ), - color: Colors.white, - ), - padding: EdgeInsets.symmetric( - horizontal: 0), - width: MediaQuery.of(context) - .size - .width / - 3, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Stack( - children: [ - Container( - margin: EdgeInsets - .fromLTRB( - 0, 16, 0, 0), - alignment: - Alignment.center, - child: Image.network( - model - .subProducts[ - index] - .images - .isNotEmpty - ? model - .subProducts[ - 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 - .subProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 5 - : 0, - padding: - EdgeInsets.all(4), - decoration: - BoxDecoration( - color: Color( - 0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), + ], ), - child: model - .subProducts[ - index] - .rxMessage != - null - ? Texts( - projectProvider - .isArabic - ? model - .subProducts[ - index] - .rxMessagen - : model - .subProducts[ - index] - .rxMessage, - color: Colors - .white, - regular: true, - fontSize: 10, - fontWeight: - FontWeight - .w400, - ) - : Texts(""), -// Texts( -// model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", -// color: Colors.white, -// regular: true, -// fontSize: 10, -// fontWeight: FontWeight.w400, -// ), ), ], ), - Container( - margin: - EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, - ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - Texts( - projectViewModel - .isArabic - ? model - .subProducts[ - index] - .namen - : model - .subProducts[ - index] - .name, -// model.subProducts[index].name, - regular: true, - fontSize: 12, - fontWeight: - FontWeight.w400, - ), - Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), - child: Texts( - "SAR ${model.subProducts[index].price}", - bold: true, - fontSize: 14, - ), - ), - Row( - children: [ -// StarRating( -// totalAverage: model.subProducts[index].approvedRatingSum > 0 -// ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() -// : 0, -// forceStars: true), - RatingBar - .readOnly( - initialRating: model - .subProducts[ - 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.subProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: - FontWeight - .w400, - ) - ], - ), - ], - ), - ), ], ), ), - ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage( - model.subProducts[ - index]), - )), - }, - )); + ); + }); }, + ); + }, + ), + Row( + children: [ + Container( + height: 44.0, + child: VerticalDivider( + color: Colors.black45, + thickness: 1.0, + //width: 0.3, + // indent: 0.0, + ), + ), + Padding( + padding: EdgeInsets.all(8.0), + child: InkWell( + child: styleIcon, + onTap: () { + setState(() { + if (styleOne == true) { + styleOne = false; + styleTwo = true; + styleIcon = Icon( + Icons.auto_awesome_mosaic, + color: CustomColors.green, + size: 29.0, + ); + } else { + styleOne = true; + styleTwo = false; + styleIcon = Icon( + Icons.widgets_sharp, + color: CustomColors.green, + size: 29.0, + ); + } + }); + }, + ), ), - ) - : Container( - height: model.subProducts.length * - MediaQuery.of(context).size.height * - 0.122, - child: ListView.builder( + ], + ), + ], + ), + ), + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + model.subProducts.isNotEmpty + ? styleOne == true + ? Container( + height: model.subProducts.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.subProducts.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 + color: model.subProducts[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), + ), + color: Colors.white, + ), + padding: EdgeInsets.symmetric( + horizontal: 0), + width: MediaQuery.of(context) + .size + .width / + 3, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Stack( + children: [ + Container( + margin: + EdgeInsets.fromLTRB( + 0, 16, 0, 0), + alignment: + Alignment.center, + child: Image.network( + model .subProducts[ index] .images .isNotEmpty - ? Image.network( - model - .subProducts[ - index] - .images[0] - .thumb, - fit: BoxFit - .contain, - height: 70, - ) - : Text(TranslationBase - .of(context) - .noImage), + ? model + .subProducts[ + 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, ), - ], - ), - Column( - children: [ - Container( - width: model - .subProducts[ - 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 - .subProducts[ - index] - .rxMessage != - null - ? Texts( - projectProvider - .isArabic - ? model - .subProducts[ - index] - .rxMessagen - : model - .subProducts[ - index] - .rxMessage, - color: Colors - .white, - regular: true, - fontSize: 10, - fontWeight: - FontWeight - .w400, - ) - : Texts(""), + ), + Container( + width: model + .subProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5 + : 0, + padding: + EdgeInsets.all(4), + decoration: + BoxDecoration( + color: + Color(0xffb23838), + borderRadius: + BorderRadius.only( + topLeft: Radius + .circular( + 6)), + ), + child: model + .subProducts[ + index] + .rxMessage != + null + ? Texts( + projectProvider + .isArabic + ? model + .subProducts[ + index] + .rxMessagen + : model + .subProducts[ + index] + .rxMessage, + color: Colors + .white, + regular: true, + fontSize: 10, + fontWeight: + FontWeight + .w400, + ) + : Texts(""), // Texts( // model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", // color: Colors.white, @@ -1062,35 +852,21 @@ class _SubCategorisePageState extends State { // fontSize: 10, // fontWeight: FontWeight.w400, // ), - ), - ], - ), - ], - ), - Container( - height: 130.0, - 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.65, - child: Texts( + ], + ), + Container( + margin: + EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Texts( projectViewModel .isArabic ? model @@ -1101,110 +877,68 @@ class _SubCategorisePageState extends State { .subProducts[ index] .name, - // model.subProducts[index].name, +// model.subProducts[index].name, regular: true, - fontSize: 13.2, + fontSize: 12, fontWeight: - FontWeight.w500, - maxLines: 5, - ), - ), - SizedBox( - height: 8.0, - ), - Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), - child: Texts( - "SAR ${model.subProducts[index].price}", - bold: true, - fontSize: 14, + FontWeight.w400, ), - ), - Row( - children: [ -// StarRating( -// totalAverage: model.subProducts[index].approvedRatingSum > 0 -// ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() -// : 0, -// forceStars: true), - RatingBar.readOnly( - initialRating: model - .subProducts[ - 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, + Padding( + padding: + const EdgeInsets + .only( + top: 4, + bottom: 4), + child: Texts( + "SAR ${model.subProducts[index].price}", + bold: true, + fontSize: 14, ), - Texts( - "(${model.subProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w400, - ) - ], - ), - ], - ), - ), - widget.authenticatedUserObject - .isLogin - ? Container( - child: IconButton( - icon: Icon( - Icons - .shopping_cart, - size: 18, - color: - CustomColors - .green, + ), + Row( + children: [ +// StarRating( +// totalAverage: model.subProducts[index].approvedRatingSum > 0 +// ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() +// : 0, +// forceStars: true), + RatingBar.readOnly( + initialRating: model + .subProducts[ + 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, ), - onPressed: - () async { - if (model - .subProducts[ - index] - .rxMessage == - null) { - GifLoaderDialogUtils - .showMyDialog( - context); - await addToCartFunction( - 1, - model - .subProducts[ - index] - .id); - GifLoaderDialogUtils - .hideDialog( - context); - Utils - .navigateToCartPage(); - } else { - AppToast.showErrorToast( - message: TranslationBase.of( - context) - .needPrescription); - } - }), - ) - : Container(), - ], + Texts( + "(${model.subProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: + FontWeight + .w400, + ) + ], + ), + ], + ), + ), + ], + ), ), ), onTap: () => { @@ -1216,37 +950,319 @@ class _SubCategorisePageState extends State { )), }, ); - }), - ) - : 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, - style: TextStyle(fontSize: 30), + }, + ), + ) + : Container( + height: model.subProducts.length * + MediaQuery.of(context).size.height * + 0.122, + child: ListView.builder( + physics: NeverScrollableScrollPhysics(), + itemCount: model.subProducts.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 + .subProducts[ + index] + .images + .isNotEmpty + ? Image.network( + model + .subProducts[ + index] + .images[ + 0] + .thumb, + fit: BoxFit + .contain, + height: 70, + ) + : Text(TranslationBase.of( + context) + .noImage), + ), + ], + ), + Column( + children: [ + Container( + width: model + .subProducts[ + 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 + .subProducts[ + index] + .rxMessage != + null + ? Texts( + projectProvider + .isArabic + ? model + .subProducts[ + index] + .rxMessagen + : model + .subProducts[index] + .rxMessage, + color: Colors + .white, + regular: + true, + fontSize: + 10, + fontWeight: + FontWeight + .w400, + ) + : Texts(""), +// Texts( +// model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", +// color: Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: FontWeight.w400, +// ), + ), + ], + ), + ], + ), + Container( + height: 130.0, + 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.65, + child: Texts( + projectViewModel + .isArabic + ? model + .subProducts[ + index] + .namen + : model + .subProducts[ + index] + .name, + // model.subProducts[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.subProducts[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ +// StarRating( +// totalAverage: model.subProducts[index].approvedRatingSum > 0 +// ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() +// : 0, +// forceStars: true), + RatingBar.readOnly( + initialRating: model + .subProducts[ + 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.subProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: + FontWeight + .w400, + ) + ], + ), + ], + ), + ), + widget.authenticatedUserObject + .isLogin + ? Container( + child: IconButton( + icon: Icon( + Icons + .shopping_cart, + size: 18, + color: + CustomColors + .green, + ), + onPressed: + () async { + if (model + .subProducts[ + index] + .rxMessage == + null) { + GifLoaderDialogUtils + .showMyDialog( + context); + await addToCartFunction( + 1, + model + .subProducts[ + index] + .id); + GifLoaderDialogUtils + .hideDialog( + context); + Utils + .navigateToCartPage(); + } else { + AppToast.showErrorToast( + message: TranslationBase.of( + context) + .needPrescription); + } + }), + ) + : Container(), + ], + ), + ), + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage( + model.subProducts[ + 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, + style: TextStyle(fontSize: 30), + ), + ) + ], + ), ), ), - ), - ) - ], + ) + ], + ), ), ), ), From e917da91838ace226f152d43b0a7b4fe6e621ad4 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Thu, 11 Nov 2021 12:07:23 +0200 Subject: [PATCH 66/70] sub Categorise fixed --- lib/pages/sub_categorise_page.dart | 60 ++++++++++++++++-------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 070749d8..b7c5d244 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -28,12 +28,14 @@ class SubCategorisePage extends StatefulWidget { String title; String parentId; - AuthenticatedUserObject authenticatedUserObject = locator(); + AuthenticatedUserObject authenticatedUserObject = + locator(); SubCategorisePage({this.id, this.parentId, this.title}); @override - _SubCategorisePageState createState() => _SubCategorisePageState(id: id, title: title, parentId: parentId); + _SubCategorisePageState createState() => + _SubCategorisePageState(id: id, title: title, parentId: parentId); } class _SubCategorisePageState extends State { @@ -68,7 +70,6 @@ class _SubCategorisePageState extends State { builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( - builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( appBarTitle: title, isBottomBar: false, isShowAppBar: true, @@ -290,24 +291,24 @@ class _SubCategorisePageState extends State { ), ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 8.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Row( - children: [ - Icon(Icons.wrap_text), - SizedBox( - width: 10.0, - ), - Texts( - TranslationBase.of(context).refine, + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + child: Row( + children: [ + Icon(Icons.wrap_text), + SizedBox( + width: 10.0, + ), + Texts( + TranslationBase.of(context).refine, // 'Refine', fontWeight: FontWeight.w600, ), @@ -589,8 +590,8 @@ class _SubCategorisePageState extends State { ""; for (CategoriseParentModel category in entityList) { - if (categoriesId =="") { - + if (categoriesId == + "") { categoriesId = category.id; } else { @@ -599,12 +600,13 @@ class _SubCategorisePageState extends State { } } String - brandIds =""; + brandIds = + ""; for (CategoriseParentModel brand in entityListBrands) { - if (brandIds =="") { - + if (brandIds == + "") { brandIds = brand.id; } else { @@ -1267,7 +1269,8 @@ class _SubCategorisePageState extends State { } bool isEntityListSelected(CategoriseParentModel masterKey) { - Iterable history = entityList.where((element) => masterKey.id == element.id); + Iterable history = + entityList.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } @@ -1275,7 +1278,8 @@ class _SubCategorisePageState extends State { } bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { - Iterable history = entityListBrands.where((element) => masterKey.id == element.id); + Iterable history = + entityListBrands.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } From 275871bc398a09de36656128d521b4c301d18ef4 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 11 Nov 2021 12:09:58 +0200 Subject: [PATCH 67/70] fix addcustomeraddress --- lib/config/config.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 229865e1..75de78f4 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -543,7 +543,7 @@ const GET_CUSTOMERS_ADDRESSES = "Customers/"; const SUBSCRIBE_PRODUCT = "subscribe?"; const GET_ORDER = "orders?"; const GET_ORDER_DETAILS = "orders/"; -const ADD_CUSTOMER_ADDRESS = "epharmacy/api/addcustomeraddress"; +const ADD_CUSTOMER_ADDRESS = "addcustomeraddress"; const EDIT_CUSTOMER_ADDRESS = "epharmacy/api/editcustomeraddress"; const DELETE_CUSTOMER_ADDRESS = "epharmacy/api/deletecustomeraddress"; const GET_ADDRESS = "Customers/"; From 6ff829ab91728b29600b983435a94b402c859917 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 11 Nov 2021 12:42:34 +0200 Subject: [PATCH 68/70] fix cart order page --- .../pharmacyModule/OrderPreviewViewModel.dart | 11 ++-- .../screens/cart-page/cart-order-page.dart | 51 ++++++++++--------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index 4aa01776..e9f2a3d4 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -68,25 +68,26 @@ class OrderPreviewViewModel extends BaseViewModel { } Future changeProductQuantity(ShoppingCart product) async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); var resp = await _orderService.changeProductQuantity(product.id, product); - var object = _handleGetShoppingCartResponse(resp); + if (_orderService.hasError) { error = _orderService.error; setState(ViewState.ErrorLocal); } else { + var object = _handleGetShoppingCartResponse(resp); setState(ViewState.Idle); } - return object; + // return object; } Future deleteProduct(ShoppingCart product) async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); var resp = await _orderService.deleteProduct(product.id); var object = _handleGetShoppingCartResponse(resp); if (_orderService.hasError) { error = _orderService.error; - setState(ViewState.Error); + setState(ViewState.ErrorLocal); } else { setState(ViewState.Idle); } 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 9d096053..70858fa9 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -57,7 +57,7 @@ class _CartOrderPageState extends State { isMainPharmacyPages: true, showPharmacyCart: false, baseViewModel: model, - backButtonTab: (){ + backButtonTab: () { widget.changeTab(0); }, backgroundColor: Colors.white, @@ -99,32 +99,34 @@ class _CartOrderPageState extends State { : 0, (index) => ProductOrderItem( model.cartResponse - .shoppingCarts[index], () { - print(model.cartResponse - .shoppingCarts[index].quantity); - model - .changeProductQuantity(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.Error) { - // appScaffold.appBar.badgeUpdater( - // '${value.quantityCount ?? 0}'); - } if (model.state == ViewState.ErrorLocal) { Utils.showErrorToast(model.error); } - }); - }, () { - model - .deleteProduct(model.cartResponse - .shoppingCarts[index]) - .then((value) { - if (model.state != ViewState.Error) { - // appScaffold.appBar.badgeUpdater( - // '${value.quantityCount ?? 0}'); - } + GifLoaderDialogUtils.hideDialog( + context); }); })) ], @@ -254,7 +256,7 @@ class _CartOrderPageState extends State { ? height * 0.15 : 0, color: Colors.white, - child: OrderBottomWidget(model.addresses, height, model), + child: OrderBottomWidget(model.addresses, height, model, isLoading), ), ); } @@ -272,8 +274,9 @@ class OrderBottomWidget extends StatefulWidget { final List addresses; final double height; final OrderPreviewViewModel model; + final bool isLoading; - OrderBottomWidget(this.addresses, this.height, this.model); + OrderBottomWidget(this.addresses, this.height, this.model, this.isLoading); @override _OrderBottomWidgetState createState() => _OrderBottomWidgetState(); @@ -286,7 +289,7 @@ class _OrderBottomWidgetState extends State { Widget build(BuildContext context) { ProjectViewModel projectProvider = Provider.of(context); - return !(widget.model.cartResponse.shoppingCarts == null || + return ! widget.isLoading && !(widget.model.cartResponse.shoppingCarts == null || widget.model.cartResponse.shoppingCarts.length == 0) ? Column( crossAxisAlignment: CrossAxisAlignment.start, From adfa707edaf055227c070ddf1ff6f839fbde0e9e Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Thu, 11 Nov 2021 14:15:49 +0300 Subject: [PATCH 69/70] fix issue --- lib/config/localized_values.dart | 1 + .../pharmacies/screens/cart-page/payment_bottom_widget.dart | 5 +++-- lib/uitl/translations_delegate_base.dart | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index aef5913f..ae7d045d 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -631,6 +631,7 @@ const Map localizedValues = { "drag-point": {"en": "Drag point to change your age", "ar": "اسحب لتغيير عمرك"}, "refine": {"en": "Refine", "ar": "تصفية"}, "max": {"en": "Max", "ar": "اعلى"}, + "compeleteOrderMsg": {"en": "Order has been placed successfully!!", "ar": "تم اتمام الطلب بنجاح"}, "addToCompareMsg": {"en": "You have added a product to the Compare list", "ar": "تمت الاضافه لقائمة المقارنه"}, "itInListMsg": {"en": "Item is already in the list", "ar": "المنتج موجود في القائمه"}, "compareListFull": {"en": "Your compare list is full", "ar": "قائمة المقارنة ممتلئه"}, 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 24592fe7..2bb9b975 100644 --- a/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart @@ -86,8 +86,9 @@ class PaymentBottomWidget extends StatelessWidget { await model.makeOrder(); if (model.state == ViewState.Idle) { AppToast.showSuccessToast( - message: - "Order has been placed successfully!!"); + message: TranslationBase.of(context).compeleteOrderMsg + // "Order has been placed successfully!!" + ); openPayment( model.orderListModel[0], model.authenticatedUserObject.user); } else { diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 94fbf76f..80e961b7 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1210,6 +1210,8 @@ class TranslationBase { String get min => localizedValues['min'][locale.languageCode]; + String get compeleteOrderMsg => localizedValues['compeleteOrderMsg'][locale.languageCode]; + String get addToCompareMsg => localizedValues['addToCompareMsg'][locale.languageCode]; String get itInListMsg => localizedValues['itInListMsg'][locale.languageCode]; From 4823919fcb701a4adc3894db34bc5eec32b700c3 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Thu, 11 Nov 2021 15:49:27 +0300 Subject: [PATCH 70/70] Pharmacy fixes --- lib/core/service/client/base_app_client.dart | 3 +- .../parmacyModule/order-preview-service.dart | 61 ++--- .../syncHealthData.dart | 28 ++- .../cart-page/payment_bottom_widget.dart | 2 + lib/pages/pharmacy/order/Order.dart | 8 +- lib/pages/pharmacy/order/OrderDetails.dart | 236 +++++++----------- .../pharmacyAddresses/PharmacyAddresses.dart | 61 ++--- 7 files changed, 150 insertions(+), 249 deletions(-) diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 23558ed1..1f6ca580 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -704,6 +704,7 @@ class BaseAppClient { body['PatientTypeID'] = body.containsKey('PatientTypeID') ? body['PatientTypeID'] != null + ? body['PatientTypeID'] : user['PatientType'] != null ? user['PatientType'] @@ -738,7 +739,7 @@ class BaseAppClient { print("statusCode :$statusCode"); if (statusCode < 200 || statusCode >= 400 || json == null) { var parsed = json.decode(utf8.decode(response.bodyBytes)); - onFailure(parsed['error']['ErrorEndUserMsg'] ?? 'Error While Fetching data', statusCode); + onFailure(parsed['error']['ErrorEndUserMsgN'] ?? 'Error While Fetching data', statusCode); } else { // var parsed = json.decode(response.body.toString()); var parsed = json.decode(utf8.decode(response.bodyBytes)); diff --git a/lib/core/service/parmacyModule/order-preview-service.dart b/lib/core/service/parmacyModule/order-preview-service.dart index 0fc6f79a..899cc66b 100644 --- a/lib/core/service/parmacyModule/order-preview-service.dart +++ b/lib/core/service/parmacyModule/order-preview-service.dart @@ -7,7 +7,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; -import 'package:flutter/cupertino.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; class OrderPreviewService extends BaseService { @@ -25,8 +24,7 @@ class OrderPreviewService extends BaseService { 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", onSuccess: (dynamic response, int statusCode) { addresses.clear(); response['customers'][0]['addresses'].forEach((item) { addresses.add(Addresses.fromJson(item)); @@ -46,9 +44,7 @@ class OrderPreviewService extends BaseService { dynamic localRes; hasError = false; try { - await baseAppClient - .getPharmacy("$GET_SHIPPING_OPTIONS$customerId/${selectedAddress.id}", - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy("$GET_SHIPPING_OPTIONS$customerId/${selectedAddress.id}", onSuccess: (dynamic response, int statusCode) { localRes = response['shipping_option'][0]; }, onFailure: (String error, int statusCode) { hasError = true; @@ -68,8 +64,7 @@ class OrderPreviewService extends BaseService { dynamic localRes; hasError = false; try { - await baseAppClient.getPharmacy("$GET_SHOPPING_CART$customerId", - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy("$GET_SHOPPING_CART$customerId", onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { hasError = true; @@ -81,8 +76,7 @@ class OrderPreviewService extends BaseService { return Future.value(localRes); } - Future changeProductQuantity( - String productId, ShoppingCart product) async { + Future changeProductQuantity(String productId, ShoppingCart product) async { hasError = false; super.error = ""; dynamic localRes; @@ -96,8 +90,7 @@ class OrderPreviewService extends BaseService { Map body = Map(); body["shopping_cart_item"] = choppingCartObject; - await baseAppClient.pharmacyPost("$GET_SHOPPING_CART$productId", - isExternal: false, onSuccess: (response, statusCode) async { + await baseAppClient.pharmacyPost("$GET_SHOPPING_CART$productId", isExternal: false, onSuccess: (response, statusCode) async { localRes = response; }, onFailure: (String error, int statusCode) { hasError = true; @@ -114,8 +107,7 @@ class OrderPreviewService extends BaseService { Map body = Map(); - await baseAppClient.pharmacyPost("$DELETE_SHOPPING_CART$productId", - isExternal: false, onSuccess: (response, statusCode) async { + await baseAppClient.pharmacyPost("$DELETE_SHOPPING_CART$productId", isExternal: false, onSuccess: (response, statusCode) async { localRes = response; }, onFailure: (String error, int statusCode) { hasError = true; @@ -132,9 +124,7 @@ class OrderPreviewService extends BaseService { super.error = ""; dynamic localRes; - await baseAppClient - .getPharmacy("$DELETE_SHOPPING_CART_ALL$customerId/ShoppingCart", - onSuccess: (response, statusCode) async { + await baseAppClient.getPharmacy("$DELETE_SHOPPING_CART_ALL$customerId/ShoppingCart", onSuccess: (response, statusCode) async { localRes = response; }, onFailure: (String error, int statusCode) { hasError = true; @@ -152,8 +142,7 @@ class OrderPreviewService extends BaseService { body['IdentificationNo'] = identificationNo; try { - await baseAppClient.post(GET_LACUM_ACCOUNT_INFORMATION, - onSuccess: (response, statusCode) async { + await baseAppClient.post(GET_LACUM_ACCOUNT_INFORMATION, onSuccess: (response, statusCode) async { lacumInformation = LacumAccountInformation.fromJson(response); }, onFailure: (String error, int statusCode) { hasError = true; @@ -173,8 +162,7 @@ class OrderPreviewService extends BaseService { body['AccountNumber'] = "${lacumInformation.yahalaAccountNo}"; try { - await baseAppClient.post(GET_LACUM_GROUP_INFORMATION, - onSuccess: (response, statusCode) async { + await baseAppClient.post(GET_LACUM_GROUP_INFORMATION, onSuccess: (response, statusCode) async { lacumGroupInformation = LacumAccountInformation.fromJson(response); }, onFailure: (String error, int statusCode) { hasError = true; @@ -185,31 +173,29 @@ class OrderPreviewService extends BaseService { } } - Future makeOrder(PaymentCheckoutData paymentCheckoutData, - List shoppingCarts) async { + Future makeOrder(PaymentCheckoutData paymentCheckoutData, List shoppingCarts) async { paymentCheckoutData.address.isChecked = true; hasError = false; super.error = ""; - var languageID = - await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'en'); + var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'en'); var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); Map orderBody = Map(); orderBody['rx_attachments'] = ""; - orderBody['customer_language_id'] = languageID == 'ar' ? 1 : 2; + orderBody['customer_language_id'] = languageID == 'ar' ? 2 : 1; orderBody['billing_address'] = paymentCheckoutData.address; orderBody['pick_up_in_store'] = false; orderBody['payment_method_system_name'] = "Payments.PayFort"; - orderBody['shipping_method'] = languageID == 'ar' - ? paymentCheckoutData.shippingOption.namen - : paymentCheckoutData.shippingOption.name; - orderBody['shipping_rate_computation_method_system_name'] = - paymentCheckoutData - .shippingOption.shippingRateComputationMethodSystemName; + + if (paymentCheckoutData.shippingOption.shippingRateComputationMethodSystemName == "Shipping.Aramex") + orderBody['shipping_method'] = "Aramex Domestic"; + else + orderBody['shipping_method'] = "Fixed Price"; + + orderBody['shipping_rate_computation_method_system_name'] = paymentCheckoutData.shippingOption.shippingRateComputationMethodSystemName; orderBody['customer_id'] = int.parse(customerId); - orderBody['custom_values_xml'] = - "PaymentOption:${getPaymentOptionName(paymentCheckoutData.paymentOption)}"; + orderBody['custom_values_xml'] = "PaymentOption:${getPaymentOptionName(paymentCheckoutData.paymentOption)}"; orderBody['shippingOption'] = paymentCheckoutData.shippingOption; orderBody['shipping_address'] = paymentCheckoutData.address; orderBody['lakum_amount'] = paymentCheckoutData.usedLakumPoints; @@ -227,9 +213,7 @@ class OrderPreviewService extends BaseService { body['order'] = orderBody; try { - await baseAppClient.pharmacyPost(ORDER_SHOPPING_CART, - isExternal: false, - isAllowAny: true, onSuccess: (response, statusCode) async { + await baseAppClient.pharmacyPost(ORDER_SHOPPING_CART, isExternal: false, isAllowAny: true, onSuccess: (response, statusCode) async { orderList.clear(); response['orders'].forEach((item) { orderList.add(OrderDetailModel.fromJson(item)); @@ -271,8 +255,7 @@ class OrderPreviewService extends BaseService { jsonBody['DriverID'] = driverId; LatLng coordinates; - await baseAppClient.post(DRIVER_LOCATION, - onSuccess: (response, statusCode) async { + await baseAppClient.post(DRIVER_LOCATION, onSuccess: (response, statusCode) async { if (statusCode == 200) { dynamic locationObject = response['PatientER_GetDriverLocationList'][0]; double lat = locationObject['Latitude']; diff --git a/lib/pages/medical/smart_watch_health_data/syncHealthData.dart b/lib/pages/medical/smart_watch_health_data/syncHealthData.dart index 47be3c5f..ac497ba4 100644 --- a/lib/pages/medical/smart_watch_health_data/syncHealthData.dart +++ b/lib/pages/medical/smart_watch_health_data/syncHealthData.dart @@ -5,7 +5,6 @@ import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; -import 'package:diplomaticquarterapp/widgets/dialogs/alert_dialog.dart'; import 'package:fit_kit/fit_kit.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; @@ -85,7 +84,7 @@ class _syncHealthDataButtonState extends State { type, dateFrom: firstDayOfTheYear, dateTo: DateTime.now(), - limit: 1000500, + limit: 1000, ); if (type == DataType.DISTANCE) { @@ -241,30 +240,33 @@ class _syncHealthDataButtonState extends State { new healthData(MedCategoryID: 7, MedSubCategoryID: 0, MachineDate: DateUtil.convertDateToString(date), Value: totalDistance, TransactionsListID: TransactionsListID++, Notes: "")); Med_InsertTransactionsInputsList2.add( new healthData(MedCategoryID: 3, MedSubCategoryID: 0, MachineDate: DateUtil.convertDateToString(date), Value: avgTotalHeartRate, TransactionsListID: TransactionsListID++, Notes: "")); - - // Med_InsertTransactionsInputsList2.add(new healthData(MedCategoryID: 8 , MedSubCategoryID: 0 , MachineDate: DateUtil.convertDateToStringWithBackSlash(date) , Value: totalCalories , TransactionsListID: TransactionsListID++ , Notes: "")); }); + addInsertTransactionsInputsList(); + GifLoaderDialogUtils.hideDialog(context); - AlertDialogBox dialog = new AlertDialogBox( - context: context, - confirmMessage: TranslationBase.of(context).alreadySynced, - okText: TranslationBase.of(context).ok, - okFunction: () => { - AlertDialogBox.closeAlertDialog(context), - }, - ); + // AlertDialogBox dialog = new AlertDialogBox( + // context: context, + // confirmMessage: TranslationBase.of(context).alreadySynced, + // okText: TranslationBase.of(context).ok, + // okFunction: () => { + // AlertDialogBox.closeAlertDialog(context), + // }, + // ); - dialog.showAlertDialog(context); + // dialog.showAlertDialog(context); } addInsertTransactionsInputsList() { if (Med_InsertTransactionsInputsList2.isNotEmpty) { + GifLoaderDialogUtils.showMyDialog(context); SmartWatchIntegrationService service = new SmartWatchIntegrationService(); service.insertPatientHealthData(Med_InsertTransactionsInputsList2, context).then((res) { + GifLoaderDialogUtils.hideDialog(context); print(res); }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); print(err); }); } else { 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 2bb9b975..6eee6528 100644 --- a/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart @@ -192,6 +192,8 @@ class PaymentBottomWidget extends StatelessWidget { 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 04f644b9..8b3f8502 100644 --- a/lib/pages/pharmacy/order/Order.dart +++ b/lib/pages/pharmacy/order/Order.dart @@ -114,7 +114,7 @@ class _OrderPageState extends State } return Container( width: MediaQuery.of(context).size.width, - child: model.orders.length != 0 + child: deliveredOrderList.length != 0 ? SingleChildScrollView( child: Column( children: [ @@ -381,7 +381,7 @@ class _OrderPageState extends State } return Container( width: MediaQuery.of(context).size.width, - child: model.orders.length != 0 + child: processingOrderList.length != 0 ? SingleChildScrollView( child: Column( children: [ @@ -823,7 +823,7 @@ class _OrderPageState extends State } } return Container( - child: model.orders.length != 0 + child: pendingOrderList.length != 0 ? SingleChildScrollView( child: Column( children: [ @@ -1092,7 +1092,7 @@ class _OrderPageState extends State } } return Container( - child: model.orders.length != 0 + child: cancelledOrderList.length != 0 ? SingleChildScrollView( child: Column( children: [ diff --git a/lib/pages/pharmacy/order/OrderDetails.dart b/lib/pages/pharmacy/order/OrderDetails.dart index fc77beb5..ee360bb1 100644 --- a/lib/pages/pharmacy/order/OrderDetails.dart +++ b/lib/pages/pharmacy/order/OrderDetails.dart @@ -72,8 +72,7 @@ class _OrderDetailsPageState extends State { onModelReady: (model) { model.getOrderDetails(widget.orderModel.id).then((value) { setState(() { - isActiveDelivery = (value.orderStatusId == 995 && - (value.driverID != null && value.driverID.isNotEmpty)); + isActiveDelivery = (value.orderStatusId == 995 && (value.driverID != null && value.driverID.isNotEmpty)); }); }); }, @@ -111,39 +110,35 @@ class _OrderDetailsPageState extends State { ), ), Container( - margin: EdgeInsets.only(top: 15.0, right: 10.0), - padding: EdgeInsets.only(left: 11.0, right: 11.0), - decoration: BoxDecoration( - border: Border.all( + margin: EdgeInsets.only(top: 15.0, right: 10.0), + padding: EdgeInsets.only(left: 11.0, right: 11.0), + decoration: BoxDecoration( + border: Border.all( + color: getStatusBackgroundColor(), + style: BorderStyle.solid, + width: 5.0, + ), color: getStatusBackgroundColor(), - style: BorderStyle.solid, - width: 5.0, - ), - color: getStatusBackgroundColor(), - borderRadius: BorderRadius.circular(30.0)), - child: model.orderListModel[0].orderStatusId == 30 || - model.orderListModel[0].orderStatusId == 997 || - model.orderListModel[0].orderStatusId == 994 + borderRadius: BorderRadius.circular(30.0)), + child: model.orderListModel[0].orderStatusId == 30 || model.orderListModel[0].orderStatusId == 997 || model.orderListModel[0].orderStatusId == 994 // deliveredOrderList[index].orderStatusId == 30 - ? Text( + ? Text( // deliveredOrderList[0].orderStatus.toString().substring(12), - TranslationBase.of(context).deliveredOrder, - style: TextStyle( - color: Colors.white, - fontSize: 15.0, - fontWeight: FontWeight.bold, - ), - ) - : Text( - languageID == "ar" - ? model.orderListModel[0].orderStatusn.toString() - : model.orderListModel[0].orderStatus.toString(), - style: TextStyle( - color: Colors.white, - fontSize: 13.0, - fontWeight: FontWeight.bold, - ), - ) + TranslationBase.of(context).deliveredOrder, + style: TextStyle( + color: Colors.white, + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ) + : Text( + languageID == "ar" ? model.orderListModel[0].orderStatusn.toString() : model.orderListModel[0].orderStatus.toString(), + style: TextStyle( + color: Colors.white, + fontSize: 13.0, + fontWeight: FontWeight.bold, + ), + ) // Text( // languageID == "ar" // ? model.orderListModel[0].orderStatusn @@ -155,64 +150,50 @@ class _OrderDetailsPageState extends State { // fontWeight: FontWeight.bold, // ), // ), - ), + ), ], ), Container( margin: EdgeInsets.only(left: 10.0, top: 13.0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "${model.orderListModel[0].shippingAddress.firstName} ${model.orderListModel[0].shippingAddress.lastName}", - style: TextStyle( - fontSize: 15.0, - fontWeight: FontWeight.bold, - ), - ), - ]), + child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text( + "${model.orderListModel[0].shippingAddress.firstName} ${model.orderListModel[0].shippingAddress.lastName}", + style: TextStyle( + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ), + ]), ), Container( margin: EdgeInsets.fromLTRB(10.0, 5.0, 1.0, 5.0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - model.orderListModel[0].shippingAddress.address1 - .toString() - , - style: TextStyle( - fontSize: 10.0, - fontWeight: FontWeight.bold, - color: Colors.grey, - ), - ), - ]), + child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text( + model.orderListModel[0].shippingAddress.address1.toString(), + style: TextStyle( + fontSize: 10.0, + fontWeight: FontWeight.bold, + color: Colors.grey, + ), + ), + ]), ), Container( margin: EdgeInsets.fromLTRB(10.0, 5.0, 1.0, 5.0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - model.orderListModel[0].shippingAddress.address2 - .toString() - + - ' ' + - model.orderListModel[0].shippingAddress - .country - .toString() + - ' ' + - model.orderListModel[0].shippingAddress - .zipPostalCode - .toString(), - style: TextStyle( - fontSize: 10.0, - fontWeight: FontWeight.bold, - color: Colors.grey, - ), - ), - ]), + child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text( + model.orderListModel[0].shippingAddress.address2.toString() + + ' ' + + model.orderListModel[0].shippingAddress.country.toString() + + ' ' + + model.orderListModel[0].shippingAddress.zipPostalCode.toString(), + style: TextStyle( + fontSize: 10.0, + fontWeight: FontWeight.bold, + color: Colors.grey, + ), + ), + ]), ), Container( child: Row( @@ -227,9 +208,7 @@ class _OrderDetailsPageState extends State { Container( margin: EdgeInsets.only(top: 5.0, bottom: 5.0), child: Text( - model.orderListModel[0].shippingAddress - .phoneNumber - .toString(), + model.orderListModel[0].shippingAddress.phoneNumber.toString(), style: TextStyle( fontSize: 15.0, ), @@ -267,9 +246,7 @@ class _OrderDetailsPageState extends State { ), Container( child: flutterImage.Image.asset( - model.orderListModel[0] - .shippingRateComputationMethodSystemName != - "Shipping.Aramex" + model.orderListModel[0].shippingRateComputationMethodSystemName != "Shipping.Aramex" ? "assets/images/pharmacy_module/payment/LogoParmacyGreen.png" : "assets/images/pharmacy_module/payment/aramex_shipping_logo.png", fit: BoxFit.contain, @@ -320,8 +297,7 @@ class _OrderDetailsPageState extends State { Container( margin: EdgeInsets.only(bottom: 10.0, top: 10.0), child: Text( - model.orderListModel[0].paymentName - .toString(), + model.orderListModel[0].paymentName.toString(), style: TextStyle( fontSize: 13.0, fontWeight: FontWeight.bold, @@ -368,9 +344,9 @@ class _OrderDetailsPageState extends State { totalPrice: "${(model.orderListModel[0].orderItems[index].product.price * model.orderListModel[0].orderItems[index].quantity).toStringAsFixed(2)}", qyt: model.orderListModel[0].orderItems[index].quantity.toString(), isOrderDetails: true, - imgs: model.orderListModel[0].orderItems[index].product.images != null && - model.orderListModel[0].orderItems[index].product.images.length != 0 - ? model.orderListModel[0].orderItems[index].product.images[0].src.toString() : null, + imgs: model.orderListModel[0].orderItems[index].product.images != null && model.orderListModel[0].orderItems[index].product.images.length != 0 + ? model.orderListModel[0].orderItems[index].product.images[0].src.toString() + : null, status: model.orderListModel[0].orderStatusId, product: model.orderListModel[0].orderItems[index].product, ), @@ -421,8 +397,7 @@ class _OrderDetailsPageState extends State { ), ), Text( - model.orderListModel[0].orderSubtotalExclTax - .toString(), + model.orderListModel[0].orderSubtotalExclTax.toString(), style: TextStyle( fontSize: 13.0, ), @@ -460,8 +435,7 @@ class _OrderDetailsPageState extends State { ), ), Text( - model.orderListModel[0].orderShippingExclTax - .toString(), + model.orderListModel[0].orderShippingExclTax.toString(), style: TextStyle( fontSize: 13.0, ), @@ -555,23 +529,16 @@ class _OrderDetailsPageState extends State { print(model.orderListModel.toString()); print("calc = ${5.9 * 3}"); // TODO MOSA - openPayment( - model.orderListModel[0], model.user); + openPayment(model.orderListModel[0], model.user); }, child: Container( -// margin: EdgeInsets.only(top: 20.0), + padding: EdgeInsets.only(left: 10.0, right: 10.0), height: 50.0, color: Colors.transparent, child: Container( - padding: EdgeInsets.only( - left: 130.0, right: 130.0), - decoration: BoxDecoration( - border: Border.all( - color: Colors.green, - style: BorderStyle.solid, - width: 4.0), - color: Colors.green, - borderRadius: BorderRadius.circular(5.0)), + padding: EdgeInsets.only(left: 130.0, right: 130.0), + decoration: + BoxDecoration(border: Border.all(color: Colors.green, style: BorderStyle.solid, width: 4.0), color: Colors.green, borderRadius: BorderRadius.circular(5.0)), child: Center( child: Text( TranslationBase.of(context).payOnline, @@ -589,8 +556,7 @@ class _OrderDetailsPageState extends State { isCancel ? InkWell( onTap: () { - presentConfirmDialog( - model, widget.orderModel.id); + presentConfirmDialog(model, widget.orderModel.id); // model.orderListModel[0].id//(widget.orderModel.id)); // }, @@ -601,10 +567,7 @@ class _OrderDetailsPageState extends State { child: Center( child: Text( TranslationBase.of(context).cancelOrder, - style: TextStyle( - color: Colors.red[900], - fontWeight: FontWeight.bold, - decoration: TextDecoration.underline), + style: TextStyle(color: Colors.red[900], fontWeight: FontWeight.bold, decoration: TextDecoration.underline), ), ), ), @@ -623,12 +586,8 @@ class _OrderDetailsPageState extends State { color: Colors.transparent, child: Center( child: Text( - TranslationBase.of(context) - .trackDeliveryDriver, - style: TextStyle( - color: Colors.green[900], - fontWeight: FontWeight.normal, - decoration: TextDecoration.none), + TranslationBase.of(context).trackDeliveryDriver, + style: TextStyle(color: Colors.green[900], fontWeight: FontWeight.normal, decoration: TextDecoration.none), ), ), ), @@ -646,20 +605,13 @@ class _OrderDetailsPageState extends State { Color getStatusBackgroundColor() { print(widget.orderModel.orderStatusId); // if(orderStatus == 'delivered') - if (widget.orderModel.orderStatusId == 30 || - widget.orderModel.orderStatusId == 997 || - widget.orderModel.orderStatusId == 994) + if (widget.orderModel.orderStatusId == 30 || widget.orderModel.orderStatusId == 997 || widget.orderModel.orderStatusId == 994) return Colors.blue[700]; - else if (widget.orderModel.orderStatusId == 20 || - widget.orderModel.orderStatusId == 995 || - widget.orderModel.orderStatusId == 998 || - widget.orderModel.orderStatusId == 999) + else if (widget.orderModel.orderStatusId == 20 || widget.orderModel.orderStatusId == 995 || widget.orderModel.orderStatusId == 998 || widget.orderModel.orderStatusId == 999) return Colors.green; else if (widget.orderModel.orderStatusId == 10) return Colors.orange[300]; - else if (widget.orderModel.orderStatusId == 40 || - widget.orderModel.orderStatusId == 996 || - widget.orderModel.orderStatusId == 200) return Colors.red[900]; + else if (widget.orderModel.orderStatusId == 40 || widget.orderModel.orderStatusId == 996 || widget.orderModel.orderStatusId == 200) return Colors.red[900]; } getCancelOrder(dataIsCancel) { @@ -693,8 +645,7 @@ 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) { + okFunction: () => cancelFunction.getCanceledOrder(id, context).then((value) { print(":D"); print(value); // Navigator.pop(context); @@ -730,20 +681,10 @@ class _OrderDetailsPageState extends State { 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) { @@ -770,14 +711,11 @@ class _OrderDetailsPageState extends State { onBrowserExit(AppoitmentAllHistoryResultList appo, bool isPaymentMade) { print("onBrowserExit Called!!!!"); if (isPaymentMade) { - AppToast.showSuccessToast( - message: "شكراً\nPayment status for your order is Paid"); + 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"); + AppToast.showErrorToast(message: "Transaction Failed!\Your transaction is field to some reason please try again or contact to the administration"); } } } diff --git a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart index 5eb93ae4..21bb77eb 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart @@ -23,17 +23,14 @@ class PharmacyAddressesPage extends StatefulWidget { final bool isUpdate; - const PharmacyAddressesPage( - {Key key, this.orderPreviewViewModel, this.isUpdate = false, this.changeMainState}) - : super(key: key); + const PharmacyAddressesPage({Key key, this.orderPreviewViewModel, this.isUpdate = false, this.changeMainState}) : super(key: key); @override _PharmacyAddressesState createState() => _PharmacyAddressesState(); } class _PharmacyAddressesState extends State { - void navigateToAddressPage( - BuildContext ctx, PharmacyAddressesViewModel model, AddressInfo address) { + void navigateToAddressPage(BuildContext ctx, PharmacyAddressesViewModel model, AddressInfo address) { Navigator.push( ctx, FadePage( @@ -49,7 +46,7 @@ class _PharmacyAddressesState extends State { return BaseView( onModelReady: (model) => model.getAddressesList(), builder: (_, model, wi) => AppScaffold( - appBarTitle: widget.isUpdate?TranslationBase.of(context).changeAddress:"Add Address", + appBarTitle: widget.isUpdate ? TranslationBase.of(context).changeAddress : TranslationBase.of(context).addAddress, isShowAppBar: true, isPharmacy: true, baseViewModel: model, @@ -124,20 +121,15 @@ class _PharmacyAddressesState extends State { vPadding: 8, handler: () async { //TODO Elham* - widget.orderPreviewViewModel.paymentCheckoutData - .address = - Addresses.fromJson( - model.addresses[model.selectedAddressIndex].toJson()); + widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[model.selectedAddressIndex].toJson()); GifLoaderDialogUtils.showMyDialog(context); - await widget.orderPreviewViewModel.getInformationsByAddress(widget.orderPreviewViewModel.user.patientIdentificationNo); await widget.orderPreviewViewModel.getShoppingCart(); // widget.changeMainState(); GifLoaderDialogUtils.hideDialog(context); - model.saveSelectedAddressLocally( - model.addresses[model.selectedAddressIndex]); + model.saveSelectedAddressLocally(model.addresses[model.selectedAddressIndex]); _navigateToPaymentOption(model); }, ), @@ -150,7 +142,7 @@ class _PharmacyAddressesState extends State { } _navigateToPaymentOption(model) { - if(widget.isUpdate) { + if (widget.isUpdate) { print("sfsf"); widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[model.selectedAddressIndex].toJson()); @@ -168,8 +160,7 @@ class _PharmacyAddressesState extends State { setState(() { if (result != null) { var paymentOption = result; - widget.orderPreviewViewModel.paymentCheckoutData.paymentOption = - paymentOption; + widget.orderPreviewViewModel.paymentCheckoutData.paymentOption = paymentOption; } // widget.changeMainState(); }) @@ -184,8 +175,7 @@ class AddressItemWidget extends StatelessWidget { final bool isSelected; final Function(AddressInfo) onTabEditAddress; - AddressItemWidget(this.model, this.address, this.selectAddress, - this.isSelected, this.onTabEditAddress); + AddressItemWidget(this.model, this.address, this.selectAddress, this.isSelected, this.onTabEditAddress); @override Widget build(BuildContext context) { @@ -211,18 +201,13 @@ class AddressItemWidget extends StatelessWidget { decoration: new BoxDecoration( color: !isSelected ? Colors.white : Colors.green, shape: BoxShape.circle, - border: Border.all( - color: Colors.grey, - style: BorderStyle.solid, - width: 1.0), + border: Border.all(color: Colors.grey, style: BorderStyle.solid, width: 1.0), ), child: Padding( padding: const EdgeInsets.all(0.0), child: Icon( Icons.check, - color: isSelected - ? Colors.white - : Colors.transparent, + color: isSelected ? Colors.white : Colors.transparent, size: 25, ), ), @@ -235,8 +220,7 @@ class AddressItemWidget extends StatelessWidget { Expanded( child: Container( child: Container( - margin: - EdgeInsets.symmetric(vertical: 12, horizontal: 12), + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -299,8 +283,7 @@ class AddressItemWidget extends StatelessWidget { ), ), Padding( - padding: - const EdgeInsets.symmetric(horizontal: 8), + padding: const EdgeInsets.symmetric(horizontal: 8), child: SizedBox( child: Container( width: 1, @@ -318,21 +301,13 @@ class AddressItemWidget extends StatelessWidget { ConfirmDialog dialog = new ConfirmDialog( context: context, title: "Are you sure want to delete", - confirmMessage: - "${address.address1} ${address.address2}", - okText: - TranslationBase.of(context).delete, - cancelText: TranslationBase.of(context) - .cancel_nocaps, + confirmMessage: "${address.address1} ${address.address2}", + okText: TranslationBase.of(context).delete, + cancelText: TranslationBase.of(context).cancel_nocaps, okFunction: () => { - model - .deleteAddresses(address) - .then((_) { - ConfirmDialog.closeAlertDialog( - context); - AppToast.showErrorToast( - message: - "Address has been deleted"); + model.deleteAddresses(address).then((_) { + ConfirmDialog.closeAlertDialog(context); + AppToast.showErrorToast(message: "Address has been deleted"); }) }, cancelFunction: () => {});