From bdededa39781124528b9a29e39c2d9a1e00fc259 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Wed, 22 Sep 2021 13:51:03 +0300 Subject: [PATCH 01/67] fixed arabic version --- lib/pages/pharmacies/my_reviews.dart | 4 +- lib/pages/pharmacy/order/Order.dart | 15 +++--- lib/pages/pharmacy/order/OrderDetails.dart | 33 ++++++++++-- lib/pages/sub_categorise_page.dart | 62 ++++++---------------- 4 files changed, 54 insertions(+), 60 deletions(-) diff --git a/lib/pages/pharmacies/my_reviews.dart b/lib/pages/pharmacies/my_reviews.dart index 7e7e33a0..efb93f96 100644 --- a/lib/pages/pharmacies/my_reviews.dart +++ b/lib/pages/pharmacies/my_reviews.dart @@ -44,8 +44,8 @@ class _MyReviewsPageState 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), ), ) diff --git a/lib/pages/pharmacy/order/Order.dart b/lib/pages/pharmacy/order/Order.dart index 2ba92674..7ffcbdbd 100644 --- a/lib/pages/pharmacy/order/Order.dart +++ b/lib/pages/pharmacy/order/Order.dart @@ -243,9 +243,10 @@ class _OrderPageState extends State color: Colors.blue[700], borderRadius: BorderRadius.circular(30.0)), - child: deliveredOrderList[index] - .orderStatusId == - 30 + child: deliveredOrderList[index].orderStatusId == 30 || + deliveredOrderList[index].orderStatusId == 997 || + deliveredOrderList[index].orderStatusId == 994 +// deliveredOrderList[index].orderStatusId == 30 ? Text( // deliveredOrderList[0].orderStatus.toString().substring(12), TranslationBase.of(context) @@ -508,9 +509,11 @@ class _OrderPageState extends State color: Colors.green, borderRadius: BorderRadius.circular(30.0)), - child: processingOrderList[index] - .orderStatusId == - 20 + child: processingOrderList[index].orderStatusId == 20 || + processingOrderList[index].orderStatusId == 995 || + processingOrderList[index].orderStatusId == 998 || + processingOrderList[index].orderStatusId == 999 +// processingOrderList[index].orderStatusId == 20 ? Text( // deliveredOrderList[0].orderStatus.toString().substring(12), TranslationBase.of(context) diff --git a/lib/pages/pharmacy/order/OrderDetails.dart b/lib/pages/pharmacy/order/OrderDetails.dart index 2f113e50..1275042a 100644 --- a/lib/pages/pharmacy/order/OrderDetails.dart +++ b/lib/pages/pharmacy/order/OrderDetails.dart @@ -121,17 +121,40 @@ class _OrderDetailsPageState extends State { ), color: getStatusBackgroundColor(), borderRadius: BorderRadius.circular(30.0)), - child: Text( + child: model.orderListModel[0].orderStatusId == 30 || + model.orderListModel[0].orderStatusId == 997 || + model.orderListModel[0].orderStatusId == 994 +// deliveredOrderList[index].orderStatusId == 30 + ? 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 - : model.orderListModel[0].orderStatus, -// TranslationBase.of(context).delivered, + ? 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 +// : model.orderListModel[0].orderStatus, +//// TranslationBase.of(context).delivered, +// style: TextStyle( +// color: Colors.white, +// fontSize: 13.0, +// fontWeight: FontWeight.bold, +// ), +// ), ), ], ), diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 084f2a8c..c7439044 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -540,61 +540,29 @@ class _SubCategorisePageState extends State { width: 200, child: Button( onTap: - () async { - String - categoriesId = - ""; - for (CategoriseParentModel category - in entityList) { - if (categoriesId == - "") { - categoriesId = - category - .id; + () 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); + 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, + label: TranslationBase.of(context).apply, // 'Apply', backgroundColor: Colors From 7427cd68ff6fb5b727f8c27d492503145f17c41d Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Sun, 3 Oct 2021 14:08:40 +0300 Subject: [PATCH 02/67] fix bottom nav bar ui --- .../pharmacy/bottom_nav_pharmacy_bar.dart | 35 ++++++++++--------- .../bottom_nav_pharmacy_home_item.dart | 8 ++--- .../pharmacy/bottom_nav_pharmacy_item.dart | 17 ++++++--- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart index 4921c1c5..237b4cae 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart @@ -44,17 +44,17 @@ class _BottomNavPharmacyBarState extends State { title: TranslationBase.of(context).Alhabibapp, ), - Container( - height: 65.0, - child: Center( - child: VerticalDivider( - color: Colors.grey, - thickness: 0.5, - width: 0.3, - indent: 25.5, - ), - ), - ), + // Container( + // height: 65.0, + // child: Center( + // child: VerticalDivider( + // color: Colors.grey, + // thickness: 0.5, + // width: 0.3, + // indent: 25.5, + // ), + // ), + // ), BottomNavPharmacyItem( icon: EvaIcons.list, @@ -79,12 +79,13 @@ class _BottomNavPharmacyBarState extends State { // Added Calendar Icon to access book appointment flow BottomNavPharmacyItem( - icon: EvaIcons.heart, - activeIcon: EvaIcons.heart, + icon: EvaIcons.home, + activeIcon: EvaIcons.home, changeIndex: _changeIndex, index: widget.index, - currentIndex: 2, - title: TranslationBase.of(context).wishList), + currentIndex: 0, + isHome: true, + title: TranslationBase.of(context).home), BottomNavPharmacyItem( icon: EvaIcons.person, @@ -95,8 +96,8 @@ class _BottomNavPharmacyBarState extends State { title: TranslationBase.of(context).myAccount, ), BottomNavPharmacyItem( - icon: EvaIcons.shoppingCart, - activeIcon: EvaIcons.shoppingCart, + icon: EvaIcons.shoppingCartOutline, + activeIcon: EvaIcons.shoppingCartOutline, changeIndex: _changeIndex, index: widget.index, currentIndex: 4, diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart index 2920b2c8..fba53c1c 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart @@ -59,16 +59,16 @@ class BottomNavHomeItem extends StatelessWidget { Container( child: Image.asset( 'assets/images/habib-logo.png', - height: 35.0, ), + height: 22.0, ), SizedBox( - height: 11, + height: 9, ), Texts( title, - textAlign: TextAlign.center, - color: currentIndex == index ? secondaryColor : Colors.grey, + textAlign: TextAlign.start, + color: currentIndex == index ? Colors.grey : Colors.grey, fontSize: 11, ), // Added TextAlign Property diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart index 47ff1b23..bff756f1 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart @@ -10,6 +10,7 @@ class BottomNavPharmacyItem extends StatelessWidget { final int index; final int currentIndex; final Function onTap; + final bool isHome; final IconData activeIcon; BottomNavPharmacyItem( @@ -19,7 +20,8 @@ class BottomNavPharmacyItem extends StatelessWidget { this.currentIndex, this.activeIcon, this.title, - this.onTap}); + this.onTap, + this.isHome = false}); @override Widget build(BuildContext context) { @@ -49,8 +51,11 @@ class BottomNavPharmacyItem extends StatelessWidget { ), Container( child: Icon(currentIndex == index ? activeIcon : icon, - color: - currentIndex == index ? secondaryColor : Colors.grey, + color: isHome + ? Color(0xff5AB145) + : currentIndex == index + ? Colors.grey + : Colors.grey, size: 22.0), ), SizedBox( @@ -61,8 +66,10 @@ class BottomNavPharmacyItem extends StatelessWidget { Texts( title, textAlign: TextAlign.center, - color: currentIndex == index ? secondaryColor : Colors.grey, - fontSize: 11, + color: currentIndex == index ? Colors.grey : Colors.grey, + fontWeight: + currentIndex == index ? FontWeight.bold : FontWeight.w400, + fontSize: currentIndex == index ? 13 : 11, ), ], ), From cc88f0f81e85e53befef061e82ebac0825530e16 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Sun, 3 Oct 2021 15:59:30 +0300 Subject: [PATCH 03/67] first step of fixing --- .../parmacyModule/parmacy_module_service.dart | 4 ++-- .../service/pharmacy_categorise_service.dart | 5 ++++- lib/pages/final_products_page.dart | 4 +++- .../screens/pharmacy_module_page.dart | 3 ++- .../pharmacies/widgets/manufacturerItem.dart | 18 +++++++++++------- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/lib/core/service/parmacyModule/parmacy_module_service.dart b/lib/core/service/parmacyModule/parmacy_module_service.dart index 72bc56c7..d982c519 100644 --- a/lib/core/service/parmacyModule/parmacy_module_service.dart +++ b/lib/core/service/parmacyModule/parmacy_module_service.dart @@ -121,9 +121,9 @@ class PharmacyModuleService extends BaseService { manufacturerList.clear(); response['manufacturer'].forEach((item) { Manufacturer manufacturer = Manufacturer.fromJson(item); - if (manufacturer.image != null) { + // if (manufacturer.image != null) { manufacturerList.add(Manufacturer.fromJson(item)); - } + // } }); }, onFailure: (String error, int statusCode) { hasError = true; diff --git a/lib/core/service/pharmacy_categorise_service.dart b/lib/core/service/pharmacy_categorise_service.dart index c13f0548..e3ae4c81 100644 --- a/lib/core/service/pharmacy_categorise_service.dart +++ b/lib/core/service/pharmacy_categorise_service.dart @@ -329,6 +329,7 @@ class PharmacyCategoriseService 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', @@ -346,7 +347,9 @@ class PharmacyCategoriseService extends BaseService { super.error = error; }, queryParams: queryParams); } catch (error) { - throw error; + hasError = true; + super.error = error.toString(); + // throw error; } } diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 843d1d56..78ed3383 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -49,6 +49,8 @@ class _FinalProductsPageState extends State { Widget build(BuildContext context) { return BaseView( onModelReady: (model) { + + //TODO Elham* fix all services in order handel errors in better way in the service if (widget.productType == 1) { model.getFinalProducts(i: id); } else if (widget.productType == 2) { @@ -71,7 +73,7 @@ class _FinalProductsPageState extends State { isBottomBar: false, isShowAppBar: true, backgroundColor: Colors.white, - isShowDecPage: false, + isShowDecPage: true, baseViewModel: model, body: Container( height: MediaQuery.of(context).size.height * 5.87, diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 9b91b77a..d21ee444 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -662,7 +662,8 @@ class _PharmacyPageState extends State { FadePage( page: FinalProductsPage( id: "", - productType: 4, + //TODO Elham* handel this to understans form where the number comming + productType: 20, ), ), ), diff --git a/lib/pages/pharmacies/widgets/manufacturerItem.dart b/lib/pages/pharmacies/widgets/manufacturerItem.dart index 574c37c5..a424512b 100644 --- a/lib/pages/pharmacies/widgets/manufacturerItem.dart +++ b/lib/pages/pharmacies/widgets/manufacturerItem.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/Manufacturer.dart'; +import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -37,13 +38,16 @@ class ManufacturerItem extends StatelessWidget { left: BorderSide(color: Colors.grey.shade300, width: 1), top: BorderSide(color: Colors.grey.shade300, width: 1)), ), - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 8), - child: Image.network( - item.image.src, - fit: BoxFit.cover, - ), - ), + ///TODO Elham* Improve design and check if they show the image and name or just name + child: item.image == null + ? Container(child: AppText(item.name)) + : Padding( + padding: EdgeInsets.symmetric(horizontal: 8), + child: Image.network( + item.image.src, + fit: BoxFit.cover, + ), + ), ), ), ); From 9b42d411ca5ed784245c425e7e980eb10520314c Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 4 Oct 2021 09:47:48 +0300 Subject: [PATCH 04/67] remove cart from product details --- lib/pages/pharmacies/product_detail.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pages/pharmacies/product_detail.dart b/lib/pages/pharmacies/product_detail.dart index 28afa2f4..06cae695 100644 --- a/lib/pages/pharmacies/product_detail.dart +++ b/lib/pages/pharmacies/product_detail.dart @@ -93,12 +93,10 @@ class __ProductDetailPageState extends State { if (customerId != null) { itemID = widget.product.id; checkWishlist(); -// getSpecificationData(itemID); } print("customerId:$customerId"); setState(() {}); -// getSpecificationData(itemID); } Widget build(BuildContext context) { @@ -943,6 +941,8 @@ class __ProductDetailPageState extends State { isShowAppBar: true, isPharmacy: true, isShowDecPage: false, + showPharmacyCart: false, + showHomeAppBarIcon: false, body: SingleChildScrollView( child: Column( children: [ From a6a7ed4e1b8429762a89ee799ef151a9da442085 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 4 Oct 2021 09:48:11 +0300 Subject: [PATCH 05/67] remove cart from product details --- lib/widgets/others/app_scafold_detail_page.dart | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/lib/widgets/others/app_scafold_detail_page.dart b/lib/widgets/others/app_scafold_detail_page.dart index 9960b1d1..b7f98b08 100644 --- a/lib/widgets/others/app_scafold_detail_page.dart +++ b/lib/widgets/others/app_scafold_detail_page.dart @@ -183,20 +183,6 @@ class AppBarWidget extends StatelessWidget with PreferredSizeWidget { ), centerTitle: true, actions: [ - isPharmacy - ? IconButton( - icon: Icon(Icons.shopping_cart), - color: Colors.grey, - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => CartOrderPage()), - ); -// Navigator.of(context) -// .popUntil(ModalRoute.withName('/')); - }) - : Container(), image != null ? InkWell( onTap: () => Navigator.push( From db277a62f549d33d7b69c1857d3371ad086cf584 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 4 Oct 2021 10:24:35 +0300 Subject: [PATCH 06/67] fix brand design --- .../screens/pharmacy_module_page.dart | 2 +- .../pharmacies/widgets/manufacturerItem.dart | 42 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index d21ee444..e5e9e230 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -590,7 +590,7 @@ class _PharmacyPageState extends State { ), ), Container( - height: 60, + height: 100, child: ListView.builder( itemBuilder: (ctx, i) => ManufacturerItem(model.manufacturerList[i]), diff --git a/lib/pages/pharmacies/widgets/manufacturerItem.dart b/lib/pages/pharmacies/widgets/manufacturerItem.dart index a424512b..df5fb166 100644 --- a/lib/pages/pharmacies/widgets/manufacturerItem.dart +++ b/lib/pages/pharmacies/widgets/manufacturerItem.dart @@ -24,31 +24,31 @@ class ManufacturerItem extends StatelessWidget { ), ); }, - child: Card( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + child: Container( margin: EdgeInsets.symmetric( - horizontal: 8, + horizontal: 12, vertical: 4, ), - child: Container( - decoration: BoxDecoration( - border: Border( - right: BorderSide(color: Colors.grey.shade300, width: 1), - bottom: BorderSide(color: Colors.grey.shade300, width: 1), - left: BorderSide(color: Colors.grey.shade300, width: 1), - top: BorderSide(color: Colors.grey.shade300, width: 1)), - ), - ///TODO Elham* Improve design and check if they show the image and name or just name - child: item.image == null - ? Container(child: AppText(item.name)) - : Padding( - padding: EdgeInsets.symmetric(horizontal: 8), - child: Image.network( - item.image.src, - fit: BoxFit.cover, - ), - ), + decoration: BoxDecoration( + borderRadius:BorderRadius.circular(12) , + border: Border( + right: BorderSide(color: Colors.grey.shade300, width: 1), + bottom: BorderSide(color: Colors.grey.shade300, width: 1), + left: BorderSide(color: Colors.grey.shade300, width: 1), + top: BorderSide(color: Colors.grey.shade300, width: 1)), ), + child: item.image == null + ? Padding( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 10), + child: AppText(item.name, fontWeight: FontWeight.w500,fontSize: 14,), + ) + : Padding( + padding: EdgeInsets.symmetric(horizontal: 8), + child: Image.network( + item.image.src, + fit: BoxFit.cover, + ), + ), ), ); } From dbf7ebf287b905bf279878de52883680d0a7450e Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 4 Oct 2021 10:47:08 +0300 Subject: [PATCH 07/67] fix most viewed & best sellers moduls --- lib/config/config.dart | 16 +- lib/config/localized_values.dart | 73 +- lib/core/service/client/base_app_client.dart | 216 +++-- .../service/pharmacy_categorise_service.dart | 54 +- .../product_categories_view_model.dart | 27 + lib/locator.dart | 9 +- lib/pages/final_products_page.dart | 897 +++++++++--------- lib/uitl/translations_delegate_base.dart | 44 +- .../others/app_scaffold_pharmacy_widget.dart | 2 +- 9 files changed, 773 insertions(+), 565 deletions(-) create mode 100644 lib/core/viewModels/product_categories_view_model.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 5af95569..660559d3 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -13,16 +13,16 @@ const PACKAGES_CUSTOMER = '/api/customers'; const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; const PACKAGES_ORDERS = '/api/orders'; -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/'; const PING_SERVICE = 'Services/Weather.svc/REST/CheckConnectivity'; @@ -551,8 +551,8 @@ 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 = diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 28d53047..7d764249 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -74,7 +74,10 @@ const Map localizedValues = { 'enterDocName': {'en': 'Enter Doctor name', 'ar': 'أدخل إسم الطبيب'}, 'search': {'en': 'Search', 'ar': 'بحث'}, 'noResultFound': {'en': 'No Result Found', 'ar': 'المنتج غير موجود'}, - 'pleaseEnterProductName': {'en': 'Please Enter Product Name', 'ar': 'ادخل اسم المنتج'}, + 'pleaseEnterProductName': { + 'en': 'Please Enter Product Name', + 'ar': 'ادخل اسم المنتج' + }, 'bookNow': {'en': 'BOOK NOW', 'ar': 'احجز الآن'}, 'docInfo': {'en': 'Doctor Information', 'ar': 'معلومات الطبيب'}, 'appoInfo': {'en': 'Appointment Information', 'ar': 'معلومات الموعد'}, @@ -621,7 +624,10 @@ const Map localizedValues = { "DepositorName": {"en": "Depositor Name", "ar": "اسم المودع *"}, "MobileNumber": {"en": "Mobile Number", "ar": "رقم الجوال"}, "Ok": {"en": "Ok", "ar": "حسنا"}, - "averageWaitingTime": {"en": "Average Waiting Time:", "ar": "متوسط ​​وقت الانتظار:"}, + "averageWaitingTime": { + "en": "Average Waiting Time:", + "ar": "متوسط ​​وقت الانتظار:" + }, "WaterConsumedInWeek": { "en": "Water consumed in a week", "ar": "معدل شرب الماء خلال الاسبوع" @@ -724,7 +730,7 @@ const Map localizedValues = { "products": {"en": "Products", "ar": "المنتجات"}, "reviews": {"en": "Reviews", "ar": "التقيمات"}, "brands": {"en": "Brands", "ar": "العلامات التجارية"}, - "productDetails": {"en": "Product Details", "ar": "تفاصيل المنتج"}, + "productDetails": {"en": "Product Details", "ar": "تفاصيل المنتج"}, // "medicationRefill": {"en": "Medication Refill", "ar": "تعبئة الأدوية"}, "pillReminder": {"en": "Pill Reminder", "ar": "تذكير الأدويه"}, "shippingAddresses": {"en": "Shipping Addresses", "ar": "عناوين الشحن"}, @@ -898,10 +904,7 @@ const Map localizedValues = { "myAccount": {"en": "My Account", "ar": "حسابي"}, "cart": {"en": "Cart", "ar": "التسوق"}, "Alhabibapp": {"en": "Al habib app", "ar": "تطبيق الحبيب"}, - "searchProductHere": { - "en": "Search Product here", - "ar": "البحث عن منتج" - }, + "searchProductHere": {"en": "Search Product here", "ar": "البحث عن منتج"}, "HHCNotAuthMsg": { "en": "This service provides a set of home health care services, continuous and comprehensive follow-up in their places of residence for those who cannot access health facilities, such as (laboratory analyzes - radiology - vaccinations - physical therapy), etc.", @@ -2239,39 +2242,55 @@ const Map localizedValues = { "ar": "وقت المواعيد الكلي:" }, "info-eye": { - "en": "This service allows you to view all the eye measurements, lenses, and eyeglasses that have been made in the Habib Medical Group.", - "ar": " خدمة قياسات النظر: هذه الخدمة تمكنك من الاطلاع على جميع قياسات النظر والعدسات والنظارات التي تمت في مجموعة الحبيب الطبية." + "en": + "This service allows you to view all the eye measurements, lenses, and eyeglasses that have been made in the Habib Medical Group.", + "ar": + " خدمة قياسات النظر: هذه الخدمة تمكنك من الاطلاع على جميع قياسات النظر والعدسات والنظارات التي تمت في مجموعة الحبيب الطبية." }, "info-vaccines": { - "en": "This service allows you to view all the vaccinations that were taken in Al Habib Medical Group.", - "ar": "خدمة تطعيماتي: هذه الخدمة تمكنك من الاطلاع على جميع التطعيمات التي تمت في مجموعة الحبيب الطبية." + "en": + "This service allows you to view all the vaccinations that were taken in Al Habib Medical Group.", + "ar": + "خدمة تطعيماتي: هذه الخدمة تمكنك من الاطلاع على جميع التطعيمات التي تمت في مجموعة الحبيب الطبية." }, "info-trackers": { - "en": "This service allows you to record the readings of the measurement of sugar, pressure, and weight and then refer to them as a reference in addition to view the statistics charts.", - "ar": "متابعة قراءاتي: هذه الخدمة تمكنك من تسجيل قراءات قياس السكر والضغط والوزن بشكل دوري ومن ثم الاطلاع عليها كمرجع وكذلك الاطلاع على الرسوم البيانية لمتابعة تطور الحالة." + "en": + "This service allows you to record the readings of the measurement of sugar, pressure, and weight and then refer to them as a reference in addition to view the statistics charts.", + "ar": + "متابعة قراءاتي: هذه الخدمة تمكنك من تسجيل قراءات قياس السكر والضغط والوزن بشكل دوري ومن ثم الاطلاع عليها كمرجع وكذلك الاطلاع على الرسوم البيانية لمتابعة تطور الحالة." }, "info-health-data": { - "en": "This service is designed to allows you to synchronize the health data from your smart watches into your health record system in Habib Medical Group so that the doctors you are visiting can analyze your health & activity level.", - "ar": "تم تصميم هذه الخدمة للسماح لك بمزامنة البيانات الصحية من ساعاتك الذكية الى نظام السجلات الصحية الخاص بك في مجموعة حبيب الطبية حتى يتمكن الأطباء الذين تزورهم من تحليل مستوى صحتك ونشاطك." + "en": + "This service is designed to allows you to synchronize the health data from your smart watches into your health record system in Habib Medical Group so that the doctors you are visiting can analyze your health & activity level.", + "ar": + "تم تصميم هذه الخدمة للسماح لك بمزامنة البيانات الصحية من ساعاتك الذكية الى نظام السجلات الصحية الخاص بك في مجموعة حبيب الطبية حتى يتمكن الأطباء الذين تزورهم من تحليل مستوى صحتك ونشاطك." }, "info-ask-doc": { - "en": "This service allows you to ask the doctor you have visited during the last 14 days. When you receive a response from the doctor, you will be notified via the system to view the doctor's reply.", - "ar": "اسال طبيبك: هذه الخدمة تمكنك من توجيه استفسارات الى الطبيب الذي قمت بزيارته خلال اخر 14 يوم وكذلك عند تلقى الرد من الطبيب سوف يتم ابلاغك عن طريق النظام للاطلاع على رد الطبيب." + "en": + "This service allows you to ask the doctor you have visited during the last 14 days. When you receive a response from the doctor, you will be notified via the system to view the doctor's reply.", + "ar": + "اسال طبيبك: هذه الخدمة تمكنك من توجيه استفسارات الى الطبيب الذي قمت بزيارته خلال اخر 14 يوم وكذلك عند تلقى الرد من الطبيب سوف يتم ابلاغك عن طريق النظام للاطلاع على رد الطبيب." }, "info-auto-wifi": { - "en": "This service allows you to connect to the Internet directly without the need for entering a user name or password.", - "ar": "الاتصال بالانترنت: هذه الخدمة تمكنك من الاتصال بالانترنت مباشرة دون الحاجة الى اسم مستخدم او كلمة مرور." - }, - "auto-wifi": { - "en": "Connect To Internet", - "ar": "الإتصال بالإنترنت" + "en": + "This service allows you to connect to the Internet directly without the need for entering a user name or password.", + "ar": + "الاتصال بالانترنت: هذه الخدمة تمكنك من الاتصال بالانترنت مباشرة دون الحاجة الى اسم مستخدم او كلمة مرور." }, + "auto-wifi": {"en": "Connect To Internet", "ar": "الإتصال بالإنترنت"}, "child-vaccine-info": { - "en": "This service to remind you of the deadlines of the necessary vaccinations for your child’s against diseases targeted by immunization according to the MOH vaccinations schedule by sending a reminding message and notifications of the vaccination date to the registered mobile phone.", - "ar": "هذه الخدمة تم تصميمها لتذكيرك بالمواعيد النهائية للتحصينات اللازمة لطفلك ضد الأمراض المستهدفة بالتحصين وفقًا لجدول تطعيمات وزارة الصحة عن طريق إرسال رسالة تذكير وإشعارات عن مواعيد التطعيم على الجوال المسجل." + "en": + "This service to remind you of the deadlines of the necessary vaccinations for your child’s against diseases targeted by immunization according to the MOH vaccinations schedule by sending a reminding message and notifications of the vaccination date to the registered mobile phone.", + "ar": + "هذه الخدمة تم تصميمها لتذكيرك بالمواعيد النهائية للتحصينات اللازمة لطفلك ضد الأمراض المستهدفة بالتحصين وفقًا لجدول تطعيمات وزارة الصحة عن طريق إرسال رسالة تذكير وإشعارات عن مواعيد التطعيم على الجوال المسجل." }, "h2o-info": { - "en": "This service is designed to help you to set drinking water goals and track the volume of water you are drinking on a daily basis. This service allows for schedule reminders and offers a basic statistical analysis of the amount of what you have consumed over the course of a day, week or month.", - "ar": "تم تصميم هذه الخدمة لمساعدتك في تحديد وتتبع كميات المياه التي يتوجب شربها بشكل يومي. كما توفر هذه الخدمة تذكيرات الجدول الزمني وتقدم تحليلًا إحصائيًا لمقدار ما استهلكته خلال اليوم أو الأسبوع أو الشهر." + "en": + "This service is designed to help you to set drinking water goals and track the volume of water you are drinking on a daily basis. This service allows for schedule reminders and offers a basic statistical analysis of the amount of what you have consumed over the course of a day, week or month.", + "ar": + "تم تصميم هذه الخدمة لمساعدتك في تحديد وتتبع كميات المياه التي يتوجب شربها بشكل يومي. كما توفر هذه الخدمة تذكيرات الجدول الزمني وتقدم تحليلًا إحصائيًا لمقدار ما استهلكته خلال اليوم أو الأسبوع أو الشهر." }, + + "mostViewed": {"en": "Most Viewed", "ar": "الأكثر مشاهدة"}, + "newProducts": {"en": "New Products", "ar": "منتجات جديدة"} }; diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index a6a2fb02..e74a353b 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -29,7 +29,8 @@ AppSharedPreferences sharedPref = new AppSharedPreferences(); /// onFailure: (String error, int statusCode) {}, /// body: Map(); /// -AuthenticatedUserObject authenticatedUserObject = locator(); +AuthenticatedUserObject authenticatedUserObject = + locator(); VitalSignService _vitalSignService = locator(); class BaseAppClient { @@ -49,10 +50,14 @@ class BaseAppClient { //Map profile = await sharedPref.getObj(DOCTOR_PROFILE); var pharmacyToken = await sharedPref.getString(PHARMACY_AUTORZIE_TOKEN); var user = await sharedPref.getObject(USER_PROFILE); - Map headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}; + Map headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }; if (!isExternal) { String token = await sharedPref.getString(TOKEN); - var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); + var languageID = + await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); if (body.containsKey('SetupID')) { body['SetupID'] = body.containsKey('SetupID') ? body['SetupID'] != null @@ -69,11 +74,12 @@ class BaseAppClient { body['generalid'] = GENERAL_ID; if (body.containsKey('isDentalAllowedBackend')) { - body['isDentalAllowedBackend'] = body.containsKey('isDentalAllowedBackend') - ? body['isDentalAllowedBackend'] != null - ? body['isDentalAllowedBackend'] - : IS_DENTAL_ALLOWED_BACKEND - : IS_DENTAL_ALLOWED_BACKEND; + body['isDentalAllowedBackend'] = + body.containsKey('isDentalAllowedBackend') + ? body['isDentalAllowedBackend'] != null + ? body['isDentalAllowedBackend'] + : IS_DENTAL_ALLOWED_BACKEND + : IS_DENTAL_ALLOWED_BACKEND; } body['DeviceTypeID'] = Platform.isAndroid ? 1 : 2; @@ -96,7 +102,9 @@ class BaseAppClient { : PATIENT_TYPE_ID; if (user != null) { body['TokenID'] = token; - body['PatientID'] = body['PatientID'] != null ? body['PatientID'] : user['PatientID']; + body['PatientID'] = body['PatientID'] != null + ? body['PatientID'] + : user['PatientID']; body['PatientOutSA'] = user['OutSA']; body['PatientOutSA'] = body.containsKey('PatientOutSA') ? body['PatientOutSA'] != null @@ -109,7 +117,10 @@ class BaseAppClient { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': pharmacyToken, - 'Mobilenumber': user != null ? Utils.getPhoneNumberWithoutZero(user['MobileNumber'].toString()) : "", + 'Mobilenumber': user != null + ? Utils.getPhoneNumberWithoutZero( + user['MobileNumber'].toString()) + : "", 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', 'Username': user['PatientID'].toString(), }; @@ -122,7 +133,8 @@ class BaseAppClient { print(jsonBody); if (await Utils.checkConnection()) { - final response = await http.post(url.trim(), body: json.encode(body), headers: headers); + final response = await http.post(url.trim(), + body: json.encode(body), headers: headers); final int statusCode = response.statusCode; print("statusCode :$statusCode"); if (statusCode < 200 || statusCode >= 400 || json == null) { @@ -134,7 +146,8 @@ class BaseAppClient { onSuccess(parsed, statusCode); } else { if (parsed['ErrorType'] == 4) { - navigateToAppUpdate(AppGlobal.context, parsed['ErrorEndUserMessage']); + navigateToAppUpdate( + AppGlobal.context, parsed['ErrorEndUserMessage']); } if (isAllowAny) { onSuccess(parsed, statusCode); @@ -149,24 +162,34 @@ class BaseAppClient { if (parsed != null) { onSuccess(parsed, statusCode); } else { - onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); + onFailure( + parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], + statusCode); logout(); } } - } else if (parsed['MessageStatus'] == 1 || parsed['SMSLoginRequired'] == true) { + } else if (parsed['MessageStatus'] == 1 || + parsed['SMSLoginRequired'] == true) { onSuccess(parsed, statusCode); - } else if (parsed['MessageStatus'] == 2 && parsed['IsAuthenticated']) { + } else if (parsed['MessageStatus'] == 2 && + parsed['IsAuthenticated']) { if (parsed['SameClinicApptList'] != null) { onSuccess(parsed, statusCode); } else { - if (parsed['message'] == null && parsed['ErrorEndUserMessage'] == null) { + if (parsed['message'] == null && + parsed['ErrorEndUserMessage'] == null) { if (parsed['ErrorSearchMsg'] == null) { - onFailure("Server Error found with no available message", statusCode); + onFailure("Server Error found with no available message", + statusCode); } else { onFailure(parsed['ErrorSearchMsg'], statusCode); } } else { - onFailure(parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); + onFailure( + parsed['message'] ?? + parsed['ErrorEndUserMessage'] ?? + parsed['ErrorMessage'], + statusCode); } } } else if (!parsed['IsAuthenticated']) { @@ -180,7 +203,9 @@ class BaseAppClient { if (parsed['message'] != null) { onFailure(parsed['message'] ?? parsed['message'], statusCode); } else { - onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); + onFailure( + parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], + statusCode); } } } @@ -217,13 +242,16 @@ class BaseAppClient { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': token ?? '', - 'Mobilenumber': user != null ? Utils.getPhoneNumberWithoutZero(user['MobileNumber'].toString()) : "", + 'Mobilenumber': user != null + ? Utils.getPhoneNumberWithoutZero(user['MobileNumber'].toString()) + : "", 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', 'Username': user != null ? user['PatientID'].toString() : "", }; if (!isExternal) { String token = await sharedPref.getString(TOKEN); - var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); + var languageID = + await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); if (body.containsKey('SetupID')) { body['SetupID'] = body.containsKey('SetupID') ? body['SetupID'] != null @@ -245,11 +273,12 @@ class BaseAppClient { : PATIENT_OUT_SA; if (body.containsKey('isDentalAllowedBackend')) { - body['isDentalAllowedBackend'] = body.containsKey('isDentalAllowedBackend') - ? body['isDentalAllowedBackend'] != null - ? body['isDentalAllowedBackend'] - : IS_DENTAL_ALLOWED_BACKEND - : IS_DENTAL_ALLOWED_BACKEND; + body['isDentalAllowedBackend'] = + body.containsKey('isDentalAllowedBackend') + ? body['isDentalAllowedBackend'] != null + ? body['isDentalAllowedBackend'] + : IS_DENTAL_ALLOWED_BACKEND + : IS_DENTAL_ALLOWED_BACKEND; } body['DeviceTypeID'] = Platform.isAndroid ? 1 : 2; @@ -272,7 +301,9 @@ class BaseAppClient { : PATIENT_TYPE_ID; if (user != null) { body['TokenID'] = token; - body['PatientID'] = body['PatientID'] != null ? body['PatientID'] : user['PatientID']; + body['PatientID'] = body['PatientID'] != null + ? body['PatientID'] + : user['PatientID']; body['PatientOutSA'] = user['OutSA']; body['SessionID'] = SESSION_ID; //getSe headers = { @@ -291,7 +322,8 @@ class BaseAppClient { print("Body : ${json.encode(body)}"); if (await Utils.checkConnection()) { - final response = await http.post(url.trim(), body: json.encode(body), headers: headers); + final response = await http.post(url.trim(), + body: json.encode(body), headers: headers); final int statusCode = response.statusCode; print("statusCode :$statusCode"); if (statusCode < 200 || statusCode >= 400 || json == null) { @@ -303,7 +335,8 @@ class BaseAppClient { onSuccess(parsed, statusCode); } else { if (parsed['ErrorType'] == 4) { - navigateToAppUpdate(AppGlobal.context, parsed['ErrorEndUserMessage']); + navigateToAppUpdate( + AppGlobal.context, parsed['ErrorEndUserMessage']); } if (isAllowAny) { onSuccess(parsed, statusCode); @@ -318,24 +351,34 @@ class BaseAppClient { if (parsed != null) { onSuccess(parsed, statusCode); } else { - onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); + onFailure( + parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], + statusCode); logout(); } } - } else if (parsed['MessageStatus'] == 1 || parsed['SMSLoginRequired'] == true) { + } else if (parsed['MessageStatus'] == 1 || + parsed['SMSLoginRequired'] == true) { onSuccess(parsed, statusCode); - } else if (parsed['MessageStatus'] == 2 && parsed['IsAuthenticated']) { + } else if (parsed['MessageStatus'] == 2 && + parsed['IsAuthenticated']) { if (parsed['SameClinicApptList'] != null) { onSuccess(parsed, statusCode); } else { - if (parsed['message'] == null && parsed['ErrorEndUserMessage'] == null) { + if (parsed['message'] == null && + parsed['ErrorEndUserMessage'] == null) { if (parsed['ErrorSearchMsg'] == null) { - onFailure("Server Error found with no available message", statusCode); + onFailure("Server Error found with no available message", + statusCode); } else { onFailure(parsed['ErrorSearchMsg'], statusCode); } } else { - onFailure(parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); + onFailure( + parsed['message'] ?? + parsed['ErrorEndUserMessage'] ?? + parsed['ErrorMessage'], + statusCode); } } } else if (!parsed['IsAuthenticated']) { @@ -349,7 +392,9 @@ class BaseAppClient { if (parsed['message'] != null) { onFailure(parsed['message'] ?? parsed['message'], statusCode); } else { - onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); + onFailure( + parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], + statusCode); } } } @@ -365,7 +410,8 @@ class BaseAppClient { } Future navigateToAppUpdate(context, String text) async { - Navigator.pushReplacement(context, FadePage(page: AppUpdatePage(appUpdateText: text))); + Navigator.pushReplacement( + context, FadePage(page: AppUpdatePage(appUpdateText: text))); } get(String endPoint, @@ -389,7 +435,10 @@ class BaseAppClient { if (await Utils.checkConnection()) { final response = await http.get( url.trim(), - headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}, + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, ); final int statusCode = response.statusCode; print("statusCode :$statusCode"); @@ -433,16 +482,20 @@ class BaseAppClient { 'Content-Type': 'text/html; charset=utf-8', 'Accept': 'application/json', 'Authorization': token ?? '', - 'Mobilenumber': user != null ? Utils.getPhoneNumberWithoutZero(user['MobileNumber'].toString()) : "", + 'Mobilenumber': user != null + ? Utils.getPhoneNumberWithoutZero(user['MobileNumber'].toString()) + : "", 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', 'Username': user != null ? user['PatientID'].toString() : "", + 'Host': "mdlaboratories.com", }); final int statusCode = response.statusCode; print("statusCode :$statusCode"); if (statusCode < 200 || statusCode >= 400 || json == null) { if (statusCode == 401) { - AppToast.showErrorToast(message: TranslationBase.of(AppGlobal.context).pharmacyRelogin); + AppToast.showErrorToast( + message: TranslationBase.of(AppGlobal.context).pharmacyRelogin); Navigator.of(AppGlobal.context).pushNamed(HOME); } else { onFailure('Error While Fetching data', statusCode); @@ -470,7 +523,10 @@ class BaseAppClient { final response = await http.post( url.trim(), body: json.encode(body), - headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}, + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, ); final int statusCode = response.statusCode; @@ -503,7 +559,10 @@ class BaseAppClient { if (await Utils.checkConnection()) { final response = await http.get( url.trim(), - headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}, + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, ); final int statusCode = response.statusCode; @@ -530,7 +589,10 @@ class BaseAppClient { final response = await http.put( url.trim(), body: json.encode(body), - headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}, + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, ); final int statusCode = response.statusCode; @@ -563,7 +625,10 @@ class BaseAppClient { if (await Utils.checkConnection()) { final response = await http.delete( url.trim(), - headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}, + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, ); final int statusCode = response.statusCode; @@ -583,8 +648,10 @@ class BaseAppClient { await sharedPref.remove(LOGIN_TOKEN_ID); await sharedPref.remove(PHARMACY_CUSTOMER_ID); await authenticatedUserObject.getUser(); - Provider.of(AppGlobal.context, listen: false).isLogin = false; - var model = Provider.of(AppGlobal.context, listen: false); + Provider.of(AppGlobal.context, listen: false).isLogin = + false; + var model = + Provider.of(AppGlobal.context, listen: false); _vitalSignService.weightKg = ""; _vitalSignService.heightCm = ""; model.setState(0, false); @@ -598,7 +665,8 @@ class BaseAppClient { static defaultHttpParameters() async { String token = await sharedPref.getString(TOKEN); - var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); + var languageID = + await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); var user = await sharedPref.getObject(USER_PROFILE); var params = {}; if (user != null) { @@ -634,7 +702,8 @@ class BaseAppClient { try { if (isExternal) { String token = await sharedPref.getString(TOKEN); - var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); + var languageID = + await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); var user = await sharedPref.getObject(USER_PROFILE); if (body.containsKey('SetupID')) { body['SetupID'] = body.containsKey('SetupID') @@ -657,11 +726,12 @@ class BaseAppClient { : PATIENT_OUT_SA; if (body.containsKey('isDentalAllowedBackend')) { - body['isDentalAllowedBackend'] = body.containsKey('isDentalAllowedBackend') - ? body['isDentalAllowedBackend'] != null - ? body['isDentalAllowedBackend'] - : IS_DENTAL_ALLOWED_BACKEND - : IS_DENTAL_ALLOWED_BACKEND; + body['isDentalAllowedBackend'] = + body.containsKey('isDentalAllowedBackend') + ? body['isDentalAllowedBackend'] != null + ? body['isDentalAllowedBackend'] + : IS_DENTAL_ALLOWED_BACKEND + : IS_DENTAL_ALLOWED_BACKEND; } body['DeviceTypeID'] = Platform.isAndroid ? 1 : 2; @@ -684,7 +754,9 @@ class BaseAppClient { : PATIENT_TYPE_ID; if (user != null) { body['TokenID'] = token; - body['PatientID'] = body['PatientID'] != null ? body['PatientID'] : user['PatientID']; + body['PatientID'] = body['PatientID'] != null + ? body['PatientID'] + : user['PatientID']; body['PatientOutSA'] = user['OutSA']; body['SessionID'] = SESSION_ID; //getSessionId(token); } @@ -696,14 +768,17 @@ class BaseAppClient { var ss = json.encode(body); if (await Utils.checkConnection()) { - final response = await http.post(url.trim(), body: json.encode(body), headers: { + final response = + await http.post(url.trim(), body: json.encode(body), headers: { // 'Content-Type': 'application/json', // 'Accept': 'application/json', // 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', 'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': token ?? '', - 'Mobilenumber': user != null ? Utils.getPhoneNumberWithoutZero(user['MobileNumber'].toString()) : "", + 'Mobilenumber': user != null + ? Utils.getPhoneNumberWithoutZero(user['MobileNumber'].toString()) + : "", 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', 'Username': user != null ? user['PatientID'].toString() : "", }); @@ -718,7 +793,8 @@ class BaseAppClient { onSuccess(parsed, statusCode); } else { if (parsed['ErrorType'] == 4) { - navigateToAppUpdate(AppGlobal.context, parsed['ErrorEndUserMessage']); + navigateToAppUpdate( + AppGlobal.context, parsed['ErrorEndUserMessage']); } if (isAllowAny) { onSuccess(parsed, statusCode); @@ -733,21 +809,31 @@ class BaseAppClient { if (parsed != null) { onSuccess(parsed, statusCode); } else { - onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); + onFailure( + parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], + statusCode); logout(); } } - } else if (parsed['MessageStatus'] == 1 || parsed['SMSLoginRequired'] == true) { + } else if (parsed['MessageStatus'] == 1 || + parsed['SMSLoginRequired'] == true) { onSuccess(parsed, statusCode); - } else if (parsed['MessageStatus'] == 2 && parsed['IsAuthenticated']) { - if (parsed['message'] == null && parsed['ErrorEndUserMessage'] == null) { + } else if (parsed['MessageStatus'] == 2 && + parsed['IsAuthenticated']) { + if (parsed['message'] == null && + parsed['ErrorEndUserMessage'] == null) { if (parsed['ErrorSearchMsg'] == null) { - onFailure("Server Error found with no available message", statusCode); + onFailure("Server Error found with no available message", + statusCode); } else { onFailure(parsed['ErrorSearchMsg'], statusCode); } } else { - onFailure(parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); + onFailure( + parsed['message'] ?? + parsed['ErrorEndUserMessage'] ?? + parsed['ErrorMessage'], + statusCode); } } else if (!parsed['IsAuthenticated']) { await logout(); @@ -760,7 +846,9 @@ class BaseAppClient { if (parsed['message'] != null) { onFailure(parsed['message'] ?? parsed['message'], statusCode); } else { - onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); + onFailure( + parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], + statusCode); } } } diff --git a/lib/core/service/pharmacy_categorise_service.dart b/lib/core/service/pharmacy_categorise_service.dart index c13f0548..ce24c980 100644 --- a/lib/core/service/pharmacy_categorise_service.dart +++ b/lib/core/service/pharmacy_categorise_service.dart @@ -95,8 +95,9 @@ class PharmacyCategoriseService extends BaseService { Future searchProducts({String productName}) async { hasError = false; _searchList.clear(); - String endPoint = - productName != null ? GET_SEARCH_PRODUCTS + "$productName" + '&language_id=1' : GET_SEARCH_PRODUCTS + ""; + String endPoint = productName != null + ? GET_SEARCH_PRODUCTS + "$productName" + '&language_id=1' + : GET_SEARCH_PRODUCTS + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -131,7 +132,8 @@ class PharmacyCategoriseService extends BaseService { Future getCategoriseParent({String id}) async { hasError = false; _parentCategoriseList.clear(); - String endPoint = id != null ? GET_CATEGORISE_PARENT + "$id" : GET_CATEGORISE_PARENT + ""; + String endPoint = + id != null ? GET_CATEGORISE_PARENT + "$id" : GET_CATEGORISE_PARENT + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -149,7 +151,9 @@ class PharmacyCategoriseService extends BaseService { Future getParentProducts({String id}) async { hasError = false; _parentProductsList.clear(); - String endPoint = id != null ? GET_PARENT_PRODUCTS + "$id" + '&page=1&limit=50' : GET_PARENT_PRODUCTS + ""; + String endPoint = id != null + ? GET_PARENT_PRODUCTS + "$id" + '&page=1&limit=50' + : GET_PARENT_PRODUCTS + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -168,7 +172,8 @@ class PharmacyCategoriseService extends BaseService { hasError = false; _subCategoriseList.clear(); - String endPoint = id != null ? GET_SUB_CATEGORISE + "$id" : GET_SUB_CATEGORISE + ""; + String endPoint = + id != null ? GET_SUB_CATEGORISE + "$id" : GET_SUB_CATEGORISE + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -186,7 +191,9 @@ class PharmacyCategoriseService extends BaseService { Future getSubProducts({String id}) async { hasError = false; _subProductsList.clear(); - String endPoint = id != null ? GET_SUB_PRODUCTS + "$id" + '&page=1&limit=50' : GET_SUB_PRODUCTS + ""; + String endPoint = id != null + ? GET_SUB_PRODUCTS + "$id" + '&page=1&limit=50' + : GET_SUB_PRODUCTS + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -204,7 +211,8 @@ class PharmacyCategoriseService extends BaseService { Future getFinalProducts({String id}) async { hasError = false; _finalProducts.clear(); - String endPoint = id != null ? GET_FINAL_PRODUCTS + "$id" : GET_FINAL_PRODUCTS + ""; + String endPoint = + id != null ? GET_FINAL_PRODUCTS + "$id" : GET_FINAL_PRODUCTS + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -241,11 +249,15 @@ class PharmacyCategoriseService extends BaseService { Future getLastVisitedProducts() async { String lastVisited = ""; - if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != null) { - lastVisited = await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS); + _finalProducts.clear(); + if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != + null) { + lastVisited = + await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS); 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) { _finalProducts.clear(); response['products'].forEach((item) { _finalProducts.add(PharmacyProduct.fromJson(item)); @@ -266,7 +278,8 @@ class PharmacyCategoriseService 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) { _finalProducts.clear(); response['products'].forEach((item) { _finalProducts.add(PharmacyProduct.fromJson(item)); @@ -280,7 +293,8 @@ class PharmacyCategoriseService extends BaseService { } } - Future getFilteredProducts({String categoryId, String brandId, String min, String max}) async { + Future getFilteredProducts( + {String categoryId, String brandId, String min, String max}) async { hasError = false; String endPoint; @@ -304,7 +318,8 @@ class PharmacyCategoriseService extends BaseService { ); } - Future getFilteredSubProducts({String categoryId, String brandId, String min, String max}) async { + Future getFilteredSubProducts( + {String categoryId, String brandId, String min, String max}) async { hasError = false; String endPoint; @@ -331,10 +346,11 @@ class PharmacyCategoriseService extends BaseService { Future getMostViewedProducts() async { 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', + 'mostview?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) { + await baseAppClient.getPharmacy(GET_MOST_VIEWED_PRODUCTS, + onSuccess: (dynamic response, int statusCode) { _finalProducts.clear(); response['products'].forEach((item) { _finalProducts.add(PharmacyProduct.fromJson(item)); @@ -352,10 +368,12 @@ class PharmacyCategoriseService extends BaseService { Future getNewProducts() async { Map queryParams = { - 'fields': 'Id,name,namen,localized_names,price,images,sku,stock_availability,published', + 'fields': + 'Id,name,namen,localized_names,price,images,sku,stock_availability,published', }; try { - await baseAppClient.getPharmacy(GET_NEW_PRODUCTS, onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy(GET_NEW_PRODUCTS, + onSuccess: (dynamic response, int statusCode) { _finalProducts.clear(); response['products'].forEach((item) { _finalProducts.add(PharmacyProduct.fromJson(item)); diff --git a/lib/core/viewModels/product_categories_view_model.dart b/lib/core/viewModels/product_categories_view_model.dart new file mode 100644 index 00000000..fa31accd --- /dev/null +++ b/lib/core/viewModels/product_categories_view_model.dart @@ -0,0 +1,27 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacy/pharmacy_categorise.dart'; +import 'package:diplomaticquarterapp/core/service/pharmacy_categorise_service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; +import 'package:diplomaticquarterapp/locator.dart'; + +class ProductCategoriesViewModel extends BaseViewModel { + bool hasError = false; + + PharmacyCategoriseService _pharmacyCategoriseService = + locator(); + + List get categorise => + _pharmacyCategoriseService.categoriseList; + + Future getCategorise() async { + hasError = false; + // _insuranceCardService.clearInsuranceCard(); + setState(ViewState.Busy); + await _pharmacyCategoriseService.getCategorise(); + if (_pharmacyCategoriseService.hasError) { + error = _pharmacyCategoriseService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } +} diff --git a/lib/locator.dart b/lib/locator.dart index bc8996b5..92c6bf63 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -7,6 +7,7 @@ import 'package:diplomaticquarterapp/core/viewModels/ancillary_orders_view_model import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/user_information_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/product_categories_view_model.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/recommendedProduct_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/weather/weather_view_model.dart'; // import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart'; @@ -294,6 +295,7 @@ void setupLocator() { locator.registerFactory(() => LacumTranferViewModel()); locator.registerFactory(() => LacumRegistrationViewModel()); locator.registerFactory(() => EdOnlineViewModel()); + locator.registerFactory(() => ProductCategoriesViewModel()); //pharmacy locator.registerFactory(() => PharmacyCategoriseViewModel()); @@ -302,11 +304,12 @@ void setupLocator() { // 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 // locator.registerFactory(() => PharmacyCategoriseViewModel()); // locator.registerFactory(() => OffersCategoriseViewModel()); diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 843d1d56..d5826706 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -1,6 +1,5 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_page.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; @@ -9,12 +8,11 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget 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_svg/flutter_svg.dart'; import 'package:flutter/src/widgets/image.dart' as flutterImage; import 'base/base_view.dart'; - dynamic languageID; + class FinalProductsPage extends StatefulWidget { final String id; final int productType; // 1 : default, 2 : manufacturer , 3 : recently viewed @@ -29,6 +27,7 @@ class _FinalProductsPageState extends State { String id; _FinalProductsPageState({this.id}); String categoriseName = "Personal Care"; + String appBarTitle = ""; bool styleOne = true; bool styleTwo = false; Icon styleIcon = Icon( @@ -45,29 +44,35 @@ class _FinalProductsPageState extends State { getLanguageID(); super.initState(); } + @override Widget build(BuildContext context) { return BaseView( onModelReady: (model) { if (widget.productType == 1) { model.getFinalProducts(i: id); + appBarTitle = TranslationBase.of(context).products; } else if (widget.productType == 2) { model.getManufacturerProducts(id); } else if (widget.productType == 3) { model.getLastVisitedProducts(); - } else if (widget.productType == 4){ + appBarTitle = TranslationBase.of(context).recentlyViewed; + } else if (widget.productType == 4) { model.getMostViewedProducts(); - } else if (widget.productType == 5){ + appBarTitle = TranslationBase.of(context).mostViewed; + } else if (widget.productType == 5) { model.getNewProducts(); + appBarTitle = TranslationBase.of(context).newProducts; } else { model.getBestSellerProducts(); + appBarTitle = TranslationBase.of(context).bestSellers; } }, allowAny: true, builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( - appBarTitle: TranslationBase.of(context).products, + appBarTitle: appBarTitle, isBottomBar: false, isShowAppBar: true, backgroundColor: Colors.white, @@ -86,7 +91,8 @@ class _FinalProductsPageState extends State { Padding( padding: EdgeInsets.all(8.0), child: Texts( - TranslationBase.of(context).products, + "$appBarTitle " + + TranslationBase.of(context).products, fontWeight: FontWeight.w600, ), ), @@ -138,464 +144,507 @@ class _FinalProductsPageState extends State { ), styleOne == true ? Expanded( - child:model.finalProducts.length > 0 - ? Container( - height: MediaQuery.of(context).size.height * 3.90, - child: GridView.builder( - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 0.5, - mainAxisSpacing: 2.0, - childAspectRatio: 1.0, - ), - itemCount: model.finalProducts.length, - itemBuilder: (BuildContext context, int index) { - return NetworkBaseView( - baseViewModel: model, - child: InkWell( - child: Card( - color: model.finalProducts[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 - .finalProducts[ - index] - .images - .isNotEmpty - ? model - .finalProducts[ - index] - .images[0] - .thumb - : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', - fit: BoxFit.cover, - height: 80, - ), - ), - Container( - width: model.finalProducts[index].rxMessage != null - ? MediaQuery.of( - context) - .size - .width / - 2.8 - : 0, - padding: - EdgeInsets.all(4), - decoration: BoxDecoration( - color: - Color(0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), - ), - child:model.finalProducts[index].rxMessage != null - ? Texts( languageID == 'ar' ? model.finalProducts[index].rxMessagen - : model.finalProducts[index].rxMessage, - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w600, - ): Texts(""), - ), - ], + child: model.finalProducts.length > 0 + ? Container( + height: MediaQuery.of(context).size.height * + 3.90, + child: GridView.builder( + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + crossAxisSpacing: 0.5, + mainAxisSpacing: 2.0, + childAspectRatio: 1.0, + ), + itemCount: model.finalProducts.length, + itemBuilder: + (BuildContext context, int index) { + return NetworkBaseView( + baseViewModel: model, + child: InkWell( + child: Card( + color: + model.finalProducts[index] + .discountName != + null + ? Color(0xffFFFF00) + : Colors.white, + elevation: 0, + shape: Border( + right: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + left: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + bottom: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + top: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + ), + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, ), - Container( - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, + child: Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.only( + topLeft: Radius.circular( + 110.0), + ), + color: Colors.white, ), + padding: EdgeInsets.symmetric( + horizontal: 0), + width: MediaQuery.of(context) + .size + .width / + 3, child: Column( crossAxisAlignment: CrossAxisAlignment .start, children: [ - if (model - .finalProducts[ - index] - .discountName != - null) - Container( - width: - double.infinity, - height: 13.0, - decoration: - BoxDecoration( - color: Color( - 0xff5AB145), + Stack( + children: [ + Container( + margin: EdgeInsets + .fromLTRB(0, 16, + 0, 0), + alignment: Alignment + .center, + child: + Image.network( + model + .finalProducts[ + index] + .images + .isNotEmpty + ? model + .finalProducts[ + index] + .images[0] + .thumb + : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', + fit: BoxFit.cover, + height: 80, + ), ), - child: Center( - child: Texts( + Container( + width: model + .finalProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 2.8 + : 0, + padding: + EdgeInsets.all( + 4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), + borderRadius: BorderRadius.only( + topLeft: Radius + .circular( + 6)), + ), + child: model + .finalProducts[ + index] + .rxMessage != + null + ? Texts( + languageID == + 'ar' + ? model + .finalProducts[ + index] + .rxMessagen + : model + .finalProducts[index] + .rxMessage, + color: Colors + .white, + regular: + true, + fontSize: + 10, + fontWeight: + FontWeight + .w600, + ) + : Texts(""), + ), + ], + ), + Container( + margin: EdgeInsets + .symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + if (model + .finalProducts[ + index] + .discountName != + null) + Container( + width: double + .infinity, + height: 13.0, + decoration: + BoxDecoration( + color: Color( + 0xff5AB145), + ), + child: Center( + child: Texts( + model + .finalProducts[ + index] + .discountName, + regular: + true, + color: Colors + .white, + fontSize: + 10.4, + ), + ), + ), + Texts( model .finalProducts[ index] - .discountName, + .name, regular: true, - color: - Colors.white, - fontSize: 10.4, + fontSize: 12, + fontWeight: + FontWeight + .w400, ), - ), - ), - Texts( - model - .finalProducts[ - index] - .name, - regular: true, - fontSize: 12, - fontWeight: - FontWeight.w400, - ), - Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), - child: Texts( - "SAR ${model.finalProducts[index].price}", - bold: true, - fontSize: 14, + Padding( + padding: + const EdgeInsets + .only( + top: 4, + bottom: + 4), + child: Texts( + "SAR ${model.finalProducts[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ + StarRating( + totalAverage: model.finalProducts[index].approvedRatingSum > + 0 + ? (model.finalProducts[index].approvedRatingSum.toDouble() / model.finalProducts[index].approvedRatingSum.toDouble()) + .toDouble() + : 0, + forceStars: + true), + Texts( + "(${model.finalProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: + FontWeight + .w400, + ) + ], + ), + ], ), ), - Row( - children: [ - StarRating( - totalAverage: model - .finalProducts[ - index] - .approvedRatingSum > - 0 - ? (model.finalProducts[index].approvedRatingSum - .toDouble() / - model - .finalProducts[index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: true), - Texts( - "(${model.finalProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w400, - ) - ], - ), ], ), ), - ], - ), + ), + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage( + model.finalProducts[ + index]), + )), + }, + )); + }, + ), + ) + : Container( + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Align( + alignment: Alignment.center, + child: Image.asset( + 'assets/images/pharmacy/empty_box.png', + width: 100, + height: 100, ), ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage( - model.finalProducts[index]), - )), - }, - )); - }, - ), - ) - : Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Align( - alignment: Alignment.center, - child: Image.asset( - 'assets/images/pharmacy/empty_box.png', - width: 100, - height: 100, - ), - ), - Text( - TranslationBase.of(context).noResult, - style: TextStyle( - fontSize: 20.0, + Text( + TranslationBase.of(context).noResult, + style: TextStyle( + fontSize: 20.0, // fontWeight: FontWeight.bold, + ), + ), + ], ), ), - ], - ), - ),) + ) : Expanded( child: model.finalProducts.length > 0 - ? Container( - height: MediaQuery.of(context).size.height * 5.0, - child: ListView.builder( - itemCount: model.finalProducts.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( + height: MediaQuery.of(context).size.height * + 5.0, + child: ListView.builder( + itemCount: model.finalProducts.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: + Image.network( + model + .finalProducts[ + index] + .images + .isNotEmpty + ? model + .finalProducts[ + index] + .images[0] + .thumb + : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', + fit: BoxFit + .contain, + height: 80, + ), + ), + ], ), - ), - Container( - margin: - EdgeInsets.fromLTRB( - 0, 0, 0, 0), - alignment: - Alignment.center, - child: Image.network( - model - .finalProducts[ - index] - .images - .isNotEmpty - ? model - .finalProducts[ - index] - .images[0] - .thumb - : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', - fit: BoxFit.contain, - height: 80, + Column( + children: [ + Container( + width: model + .finalProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 3.5 + : 0, + padding: + EdgeInsets.all( + 4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), + borderRadius: BorderRadius.only( + topLeft: Radius + .circular( + 6)), + ), + child: Texts( + model + .finalProducts[ + index] + .rxMessage != + null + ? model + .finalProducts[ + index] + .rxMessage + : "", + color: + Colors.white, + regular: true, + fontSize: 10, + fontWeight: + FontWeight + .w600, + ), + ), + ], ), + ], + ), + Container( + height: 100.0, + margin: + EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, ), - ], - ), - Column( - children: [ - Container( - width: model - .finalProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( + child: Column( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + SizedBox( + height: 4.0, + ), + Container( + width: MediaQuery.of( context) .size - .width / - 3.5 - : 0, - padding: - EdgeInsets.all(4), - decoration: BoxDecoration( - color: - Color(0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), - ), - child: Texts( - model - .finalProducts[ - index] - .rxMessage != - null - ? model + .width * + 0.65, + child: Texts( + model .finalProducts[ index] - .rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w600, - ), - ), - ], - ), - ], - ), - Container( - height: 100.0, - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, - ), - child: Column( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - SizedBox( - height: 4.0, - ), - Container( - width: - MediaQuery.of(context) - .size - .width * - 0.65, - child: Texts( - model.finalProducts[index] - .name, - regular: true, - fontSize: 13.2, - fontWeight: - FontWeight.w500, - maxLines: 5, - ), - ), - SizedBox( - height: 8.0, - ), - Padding( - padding: - const EdgeInsets.only( - top: 4, bottom: 4), - child: Texts( - "SAR ${model.finalProducts[index].price}", - bold: true, - fontSize: 14, + .name, + regular: true, + fontSize: 13.2, + fontWeight: + FontWeight.w500, + maxLines: 5, + ), + ), + SizedBox( + height: 8.0, + ), + Padding( + padding: + const EdgeInsets + .only( + top: 4, + bottom: 4), + child: Texts( + "SAR ${model.finalProducts[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ + StarRating( + totalAverage: model + .finalProducts[ + index] + .approvedRatingSum > + 0 + ? (model.finalProducts[index].approvedRatingSum.toDouble() / + model.finalProducts[index].approvedRatingSum + .toDouble()) + .toDouble() + : 0, + forceStars: + true), + Texts( + "(${model.finalProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: + FontWeight + .w400, + ) + ], + ), + ], ), ), - Row( - children: [ - StarRating( - totalAverage: model - .finalProducts[ - index] - .approvedRatingSum > - 0 - ? (model - .finalProducts[ - index] - .approvedRatingSum - .toDouble() / - model - .finalProducts[ - index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: true), - Texts( - "(${model.finalProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w400, - ) - ], - ), ], ), ), - ], + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage( + model.finalProducts[ + index]), + )), + }, + ); + }), + ) + : Container( + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Align( + alignment: Alignment.center, + child: Image.asset( + 'assets/images/pharmacy/empty_box.png', + width: 100, + height: 100, + ), ), - ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage( - model.finalProducts[index]), - )), - }, - ); - }), - ) - : Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Align( - alignment: Alignment.center, - child: Image.asset( - 'assets/images/pharmacy/empty_box.png', - width: 100, - height: 100, - ), - ), - Text( - TranslationBase.of(context).noResult, - style: TextStyle( - fontSize: 20.0, + Text( + TranslationBase.of(context).noResult, + style: TextStyle( + fontSize: 20.0, // fontWeight: FontWeight.bold, + ), + ), + ], ), ), - ], - ), - ), ) ], ), diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index f6363a22..158d8afb 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -66,8 +66,10 @@ class TranslationBase { localizedValues['enterDocName'][locale.languageCode]; String get search => localizedValues['search'][locale.languageCode]; - String get noResultFound => localizedValues['noResultFound'][locale.languageCode]; - String get pleaseEnterProductName => localizedValues['pleaseEnterProductName'][locale.languageCode]; + String get noResultFound => + localizedValues['noResultFound'][locale.languageCode]; + String get pleaseEnterProductName => + localizedValues['pleaseEnterProductName'][locale.languageCode]; String get bookNow => localizedValues['bookNow'][locale.languageCode]; @@ -669,7 +671,8 @@ class TranslationBase { String get mobileNumber => localizedValues['MobileNumber'][locale.languageCode]; String get ok => localizedValues['Ok'][locale.languageCode]; - String get averageWaitingTime => localizedValues['averageWaitingTime'][locale.languageCode]; + String get averageWaitingTime => + localizedValues['averageWaitingTime'][locale.languageCode]; String get waterConsumedInWeek => localizedValues['WaterConsumedInWeek'][locale.languageCode]; String get waterConsumedInMonth => @@ -731,9 +734,12 @@ class TranslationBase { String get brands => localizedValues['brands'][locale.languageCode]; String get products => localizedValues['products'][locale.languageCode]; String get reviews => localizedValues['reviews'][locale.languageCode]; - String get productDetails => localizedValues['productDetails'][locale.languageCode]; - String get noReviewsAvailable => localizedValues['noReviewsAvailable'][locale.languageCode]; - String get noLocationAvailable => localizedValues['noLocationAvailable'][locale.languageCode]; + String get productDetails => + localizedValues['productDetails'][locale.languageCode]; + String get noReviewsAvailable => + localizedValues['noReviewsAvailable'][locale.languageCode]; + String get noLocationAvailable => + localizedValues['noLocationAvailable'][locale.languageCode]; String get myPrescriptions => localizedValues['myPrescriptions'][locale.languageCode]; String get medicationRefill => @@ -912,7 +918,8 @@ class TranslationBase { String get refine => localizedValues['refine'][locale.languageCode]; String get apply => localizedValues['apply'][locale.languageCode]; String get reset => localizedValues['reset'][locale.languageCode]; - String get viewCategorise => localizedValues['viewCategorise'][locale.languageCode]; + String get viewCategorise => + localizedValues['viewCategorise'][locale.languageCode]; String get cart => localizedValues['cart'][locale.languageCode]; String get wishList => localizedValues['wishList'][locale.languageCode]; String get Alhabibapp => localizedValues['Alhabibapp'][locale.languageCode]; @@ -1389,14 +1396,13 @@ class TranslationBase { String get quantitySize => localizedValues['quantitySize'][locale.languageCode]; String get addToCart => localizedValues['addToCart'][locale.languageCode]; - String get addToWishlist => localizedValues['addToWishlist'][locale.languageCode]; + String get addToWishlist => + localizedValues['addToWishlist'][locale.languageCode]; String get buyNow => localizedValues['buyNow'][locale.languageCode]; String get quantityShortcut => localizedValues['quantityShortcut'][locale.languageCode]; - String get noData => - localizedValues['noData'][locale.languageCode]; - String get no_data => - localizedValues['no_data'][locale.languageCode]; + String get noData => localizedValues['noData'][locale.languageCode]; + String get no_data => localizedValues['no_data'][locale.languageCode]; String get year => localizedValues['Year'][locale.languageCode]; String get month => localizedValues['Month'][locale.languageCode]; @@ -1764,24 +1770,22 @@ class TranslationBase { String get timeNeeded => localizedValues["time-needed"][locale.languageCode]; String get totalTimeNeeded => localizedValues["total-time-needed"][locale.languageCode]; - String get infoEye => - localizedValues["info-eye"][locale.languageCode]; + String get infoEye => localizedValues["info-eye"][locale.languageCode]; String get infoVaccines => localizedValues["info-vaccines"][locale.languageCode]; String get infoTrackers => localizedValues["info-trackers"][locale.languageCode]; String get infoHealthData => localizedValues["info-health-data"][locale.languageCode]; - String get infoAskDoc => - localizedValues["info-ask-doc"][locale.languageCode]; + String get infoAskDoc => localizedValues["info-ask-doc"][locale.languageCode]; String get infoAutoWifi => localizedValues["info-auto-wifi"][locale.languageCode]; - String get autoWifi => - localizedValues["auto-wifi"][locale.languageCode]; + String get autoWifi => localizedValues["auto-wifi"][locale.languageCode]; String get childVaccineInfo => localizedValues["child-vaccine-info"][locale.languageCode]; - String get h2oInfo => - localizedValues["h2o-info"][locale.languageCode]; + String get h2oInfo => localizedValues["h2o-info"][locale.languageCode]; + String get mostViewed => localizedValues["mostViewed"][locale.languageCode]; + String get newProducts => localizedValues["newProducts"][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/others/app_scaffold_pharmacy_widget.dart b/lib/widgets/others/app_scaffold_pharmacy_widget.dart index 001bc955..a286baa5 100644 --- a/lib/widgets/others/app_scaffold_pharmacy_widget.dart +++ b/lib/widgets/others/app_scaffold_pharmacy_widget.dart @@ -71,7 +71,7 @@ class PharmacyAppScaffold extends StatelessWidget { ), title: Text(authenticatedUserObject.isLogin ? appBarTitle.toUpperCase() - : TranslationBase.of(context).serviceInformationTitle), + : appBarTitle.toUpperCase()), leading: Builder( builder: (BuildContext context) { return ArrowBack(); From 8ecd4a24d87ed6823b8dbd4cb4f28cf726e54fd0 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Mon, 4 Oct 2021 11:04:36 +0300 Subject: [PATCH 08/67] fix product tile --- lib/config/config.dart | 12 +- .../screens/pharmacy_module_page.dart | 2 +- .../pharmacies/widgets/ProductTileItem.dart | 177 +++++++++--------- lib/widgets/others/StarRating.dart | 2 +- 4 files changed, 95 insertions(+), 98 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 5af95569..0d0a0413 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -13,16 +13,16 @@ const PACKAGES_CUSTOMER = '/api/customers'; const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; const PACKAGES_ORDERS = '/api/orders'; -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/'; const PING_SERVICE = 'Services/Weather.svc/REST/CheckConnectivity'; diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 9b91b77a..e3dbf3a4 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -672,7 +672,7 @@ class _PharmacyPageState extends State { ), ), Container( - height: MediaQuery.of(context).size.height / 4 + 20, + height: MediaQuery.of(context).size.height / 4 + 22, child: ListView.builder( itemBuilder: (ctx, i) => ProductTileItem(model.bestSellerProduct[i]), diff --git a/lib/pages/pharmacies/widgets/ProductTileItem.dart b/lib/pages/pharmacies/widgets/ProductTileItem.dart index a7e71fab..b7a061d5 100644 --- a/lib/pages/pharmacies/widgets/ProductTileItem.dart +++ b/lib/pages/pharmacies/widgets/ProductTileItem.dart @@ -52,102 +52,99 @@ class ProductTileItem extends StatelessWidget { return InkWell( onTap: () => productOnClick(context), splashColor: Theme.of(context).primaryColor, - child: Card( - elevation: 2, - shape: Border(right: BorderSide(color: Colors.grey.shade300, width: 1)), - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 0, + child: Container( + margin: EdgeInsets.all(7), + decoration: BoxDecoration( + border:Border.all(color: Colors.grey.shade300,width: 0.5), + borderRadius: BorderRadius.circular(8) ), - child: Container( - padding: EdgeInsets.symmetric(horizontal: 4), - 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: (item.images != null && item.images.length > 0) - ? Image.network( - item.images[0].src, - fit: BoxFit.cover, - height: 80, - ) - : Image.asset( - "assets/images/no_image.png", - fit: BoxFit.cover, - height: 80, - ), + padding: EdgeInsets.symmetric(horizontal: 4), + width: MediaQuery.of(context).size.width / 2.8, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + children: [ + Container( + margin: EdgeInsets.fromLTRB(0, 16, 0, 0), + alignment: Alignment.center, + child: (item.images != null && item.images.length > 0) + ? Image.network( + item.images[0].src, + fit: BoxFit.cover, + height: 80, + ) + : Image.asset( + "assets/images/no_image.png", + fit: BoxFit.cover, + height: 80, ), - Container( - width: item.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: item.rxMessage != null ? Texts( - projectProvider.isArabic ? item.rxMessagen : item.rxMessage, - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ): Texts(""), + ), + Container( + width: item.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: item.rxMessage != null + ? Texts( + projectProvider.isArabic + ? item.rxMessagen + : item.rxMessage, + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, ) - ], + : Texts(""), + ) + ], + ), + SizedBox(height: 8,), + Container( + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, ), - Container( - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - projectProvider.isArabic ? item.namen : item.name, - regular: true, - fontSize: 12, - fontWeight: FontWeight.w400, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + projectProvider.isArabic ? item.namen : item.name, + regular: true, + fontSize: 12, + fontWeight: FontWeight.w400, + ), + Padding( + padding: const EdgeInsets.only(top: 4, bottom: 4), + child: Texts( + "SAR ${item.price}", + fontWeight: FontWeight.w600, + fontSize: 14, ), - Padding( - padding: const EdgeInsets.only(top: 4, bottom: 4), - child: Texts( - "SAR ${item.price}", - bold: true, - fontSize: 14, + ), + Row( + children: [ + Expanded( + child: StarRating( + totalAverage: item.approvedTotalReviews > 0 + ? (item.approvedRatingSum.toDouble() / + item.approvedTotalReviews.toDouble()) + .toDouble() + : 0, + forceStars: true), ), - ), - Row( - children: [ - Expanded( - child: StarRating( - totalAverage: item.approvedTotalReviews > 0 - ? (item.approvedRatingSum.toDouble() / - item.approvedTotalReviews.toDouble()) - .toDouble() - : 0, - forceStars: true), - ), - /*Texts( - "(${item.approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ),*/ - ], - ), - ], - ), - ) - ], - ), + ], + ), + ], + ), + ), + SizedBox(height: 5,), + ], ), ), ); diff --git a/lib/widgets/others/StarRating.dart b/lib/widgets/others/StarRating.dart index 5620b21a..74bdbfe3 100644 --- a/lib/widgets/others/StarRating.dart +++ b/lib/widgets/others/StarRating.dart @@ -30,7 +30,7 @@ class StarRating extends StatelessWidget { ) ), if (totalCount!=null) - SizedBox(width: 9.0), + SizedBox(width: 5.0), if (totalCount!=null) Texts("("+totalCount.toString()+")", style: "overline", color: Colors.grey[400],) ] From 01a77d5352c7ce323cfc327a13df1441401d7fd3 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Mon, 4 Oct 2021 11:07:58 +0300 Subject: [PATCH 09/67] fix bugs pharmacy --- lib/config/config.dart | 4 +- .../pharmacy_module_view_model.dart | 6 ++ .../screens/pharmacy_module_page.dart | 97 ++----------------- 3 files changed, 15 insertions(+), 92 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 5af95569..8b37bc66 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -13,8 +13,8 @@ const PACKAGES_CUSTOMER = '/api/customers'; const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; const PACKAGES_ORDERS = '/api/orders'; -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/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart index 90439128..072ef4c9 100644 --- a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart @@ -16,10 +16,12 @@ import 'package:diplomaticquarterapp/services/pharmacy_services/recommendedProdu import '../../../locator.dart'; class PharmacyModuleViewModel extends BaseViewModel { + PharmacyModuleService _pharmacyService = locator(); PrescriptionService _prescriptionService = locator(); + dynamic languageID = "en"; RecommendedProductService _recommendedProductService = locator(); @@ -45,6 +47,10 @@ class PharmacyModuleViewModel extends BaseViewModel { bool hasError = false; // List get pharmacyPrescriptionsList => PharmacyProduct.pharmacyPrescriptionsList ; + Future getLanguageID() async { + languageID = await sharedPref.getString(APP_LANGUAGE); + } + Future getPharmacyHomeData() async { if(authenticatedUserObject.isLogin) await generatePharmacyToken(); diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 9b91b77a..f81b16c1 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -29,50 +29,23 @@ import 'package:rating_bar/rating_bar.dart'; import '../../final_products_page.dart'; import 'lacum-activitaion-vida-page.dart'; -bool isInWishlist = false; -int price = 0; -var itemID; var product; -var customerId; -var item; -dynamic languageID; -List wishlistData; class PharmacyPage extends StatefulWidget { -// final PharmacyProduct product; -// PharmacyPage(this.product); @override _PharmacyPageState createState() => _PharmacyPageState(); } class _PharmacyPageState extends State { -// dynamic wishlistVar; - - getLanguageID() async { - languageID = await sharedPref.getString(APP_LANGUAGE); - } - -// List recommendedProductList = []; - List wishList = []; - - var model; -// String ProductId="4561"; - //String id ="3608"; - String productId = ""; - String id = ""; - @override - void initState() { - checkWishlist(); - // userInfo(widget.product.id, widget.product); - userInfo(id, product); - getLanguageID(); - } @override Widget build(BuildContext context) { return BaseView( - onModelReady: (model) => model.getPharmacyHomeData(), + onModelReady: (model) async { + await getLanguageID(); + await model.getPharmacyHomeData(); + }, allowAny: true, builder: (_, model, wi) => AppScaffold( title: "", @@ -87,7 +60,7 @@ class _PharmacyPageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ BannerPager(model), - // GridViewButtons(model), + GridViewButtons(model), Container( margin: EdgeInsets.fromLTRB(10, 10, 10, 10), child: Row( @@ -215,7 +188,7 @@ class _PharmacyPageState extends State { BorderRadius.circular( 30.0)), child: Text( - languageID == "ar" + model.languageID == "ar" ? model.prescriptionsList[index].isInOutPatientDescriptionN.toString() : model.prescriptionsList[index].isInOutPatientDescription.toString(), style: TextStyle( @@ -700,36 +673,6 @@ class _PharmacyPageState extends State { await x.addToWishlistData(itemID); } - checkWishlist() async { - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.checkWishlistData(); - for (int i = 0; i < x.wishListItems.length; i++) { - // itemID = x.wishListItems[i].id; - print("-------------wishlist---------------"); - print(itemID); -// print(product.id); - print(x.wishListItems[i].productId); - if (itemID == x.wishListItems[i].productId) { - isInWishlist = true; -// print('in wishlist'); - break; - } else { - isInWishlist = false; -// print('not in wishlist'); - } - } - } - - Future userInfo(id, product) async { - customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); - if (customerId != null) { - itemID = id; - product = product; - checkWishlist(); - } - print("customerId:$customerId"); - return customerId; - } } class GridViewButtons extends StatelessWidget { @@ -874,30 +817,4 @@ class GridViewCard extends StatelessWidget { " " + dateObj.year.toString(); } -} - -class test extends StatefulWidget { - @override - _testState createState() => _testState(); -} - -class _testState extends State { - @override - Widget build(BuildContext context) { - return Container(); - } -} -//addWishlistData() async { -// ProductDetailViewModel x = new ProductDetailViewModel(); -// await wishlistData.add(x.checkWishlistData()); -// print("-------------testWishlist---------------"); -// -//} - -// checkWishlist() async { -// ProductDetailViewModel x = new ProductDetailViewModel(); -// wishlistVar = await x.checkWishlistData(); -// print("wishlistVar>>>>>>>>>>>>>>>"); -// print(wishlistVar); -// -// } +} \ No newline at end of file From 806e07e4e60340b49296e9fad81a665c959a0e51 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 4 Oct 2021 12:13:52 +0300 Subject: [PATCH 10/67] products categories page fix --- lib/pages/parent_categorise_page.dart | 656 ++++++++++++++++++-------- lib/pages/pharmacy_categorise.dart | 1 + 2 files changed, 472 insertions(+), 185 deletions(-) diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 40bf2dc7..c3acb0ba 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -26,7 +26,8 @@ class ParentCategorisePage extends StatefulWidget { ParentCategorisePage({this.id, this.titleName}); @override - _ParentCategorisePageState createState() => _ParentCategorisePageState(id: id, titleName: titleName); + _ParentCategorisePageState createState() => + _ParentCategorisePageState(id: id, titleName: titleName); } class _ParentCategorisePageState extends State { @@ -57,7 +58,10 @@ class _ParentCategorisePageState extends State { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getCategoriseParent(i: id), - builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( + allowAny: true, + builder: (BuildContext context, PharmacyCategoriseViewModel model, + Widget child) => + PharmacyAppScaffold( appBarTitle: titleName, isBottomBar: false, isShowAppBar: true, @@ -108,7 +112,8 @@ class _ParentCategorisePageState extends State { child: InkWell( child: Container( child: Texts( - TranslationBase.of(context).viewCategorise, + TranslationBase.of(context) + .viewCategorise, // 'View All Categories', fontWeight: FontWeight.w300, ), @@ -126,22 +131,37 @@ class _ParentCategorisePageState extends State { color: Colors.white, child: Center( child: ListView.builder( - scrollDirection: Axis.vertical, - itemCount: model.categoriseParent.length, - itemBuilder: (BuildContext context, int index) { + scrollDirection: + Axis.vertical, + itemCount: model + .categoriseParent.length, + itemBuilder: + (BuildContext context, + int index) { return Container( child: Padding( - padding: EdgeInsets.all(4.0), + padding: + EdgeInsets.all(4.0), child: InkWell( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ - Texts(projectViewModel.isArabic - ? model.categoriseParent[index].namen - : model.categoriseParent[index].name), + Texts(projectViewModel + .isArabic + ? model + .categoriseParent[ + index] + .namen + : model + .categoriseParent[ + index] + .name), Divider( thickness: 0.6, - color: Colors.black12, + color: Colors + .black12, ) ], ), @@ -149,9 +169,16 @@ class _ParentCategorisePageState extends State { Navigator.push( context, FadePage( - page: SubCategorisePage( - title: model.categoriseParent[index].name, - id: model.categoriseParent[index].id, + page: + SubCategorisePage( + title: model + .categoriseParent[ + index] + .name, + id: model + .categoriseParent[ + index] + .id, parentId: id, )), ); @@ -185,22 +212,28 @@ 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( @@ -211,7 +244,10 @@ 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 * @@ -219,8 +255,12 @@ class _ParentCategorisePageState extends State { child: Center( child: Texts( projectViewModel.isArabic - ? model.categoriseParent[index].namen - : model.categoriseParent[index].name, + ? model + .categoriseParent[index] + .namen + : model + .categoriseParent[index] + .name, fontSize: 13.4, fontWeight: FontWeight.w600, maxLines: 3, @@ -234,8 +274,10 @@ 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, )), ); @@ -281,16 +323,21 @@ 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( @@ -301,7 +348,8 @@ class _ParentCategorisePageState extends State { ), Texts( 'Refine', - fontWeight: FontWeight.w600, + fontWeight: + FontWeight.w600, ), SizedBox( width: 250.0, @@ -310,11 +358,13 @@ class _ParentCategorisePageState extends State { child: Texts( 'Close', color: Colors.red, - fontWeight: FontWeight.w600, + fontWeight: + FontWeight.w600, fontSize: 15.0, ), onTap: () { - Navigator.pop(context); + Navigator.pop( + context); }, ), ], @@ -327,27 +377,37 @@ class _ParentCategorisePageState extends State { Column( children: [ ExpansionTile( - title: Texts('Categorise'), + title: + Texts('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), ) ], ), @@ -360,23 +420,33 @@ class _ParentCategorisePageState extends State { 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), ) ], ), @@ -388,40 +458,63 @@ class _ParentCategorisePageState extends State { title: Texts('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, ), ), ], @@ -436,18 +529,26 @@ 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: 'Reset', - backgroundColor: Colors.red, + backgroundColor: + Colors.red, ), ), SizedBox( @@ -456,38 +557,65 @@ 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 = ""; + String + brandIds = + ""; for (CategoriseParentModel brand in entityListBrands) { - if (brandIds == "") { - brandIds = brand.id; + 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: 'Apply', - backgroundColor: Colors.green, + backgroundColor: + Colors + .green, ), ), ], @@ -554,22 +682,28 @@ 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: model.parentProducts[index] + .discountName != + null ? Color(0xffFFFF00) : Colors.white, elevation: 0, @@ -597,106 +731,187 @@ 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 + width: model + .parentProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5 : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), + padding: + EdgeInsets.all(4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), borderRadius: - BorderRadius.only(topLeft: Radius.circular(6)), + 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, @@ -706,22 +921,25 @@ 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), + 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, ) ], ), @@ -736,7 +954,9 @@ class _ParentCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage(model.parentProducts[index]), + page: ProductDetailPage( + model.parentProducts[ + index]), )), }, )); @@ -744,11 +964,14 @@ 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( @@ -758,9 +981,11 @@ 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, @@ -768,11 +993,22 @@ class _ParentCategorisePageState extends State { ), ), Container( - margin: EdgeInsets.fromLTRB(0, 0, 0, 0), - alignment: Alignment.center, + margin: EdgeInsets + .fromLTRB( + 0, 0, 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.contain, height: 80, @@ -783,23 +1019,45 @@ class _ParentCategorisePageState extends State { Column( children: [ Container( - width: model.parentProducts[index].rxMessage != null - ? MediaQuery.of(context).size.width / 5 + width: model + .parentProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5 : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), + padding: + EdgeInsets.all(4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), borderRadius: - BorderRadius.only(topLeft: Radius.circular(6)), + 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, ), ), ], @@ -812,21 +1070,37 @@ 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.65, 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, ), ), @@ -834,7 +1108,11 @@ 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, @@ -844,21 +1122,26 @@ 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, + 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, ) ], ), @@ -872,7 +1155,8 @@ class _ParentCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage(model.parentProducts[index]), + page: ProductDetailPage(model + .parentProducts[index]), )), }, ); @@ -914,7 +1198,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; } @@ -922,7 +1207,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/pharmacy_categorise.dart b/lib/pages/pharmacy_categorise.dart index ff1920dc..b71c28ce 100644 --- a/lib/pages/pharmacy_categorise.dart +++ b/lib/pages/pharmacy_categorise.dart @@ -30,6 +30,7 @@ class _PharmacyCategorisePageState extends State { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getCategorise(), + allowAny: true, builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => AppScaffold( From c7a0d39aabb291af4fc230cf56e10c5334d68c0c Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 4 Oct 2021 15:37:58 +0300 Subject: [PATCH 11/67] first step of ProductDetailPage refactor --- lib/config/config.dart | 14 +- lib/pages/final_products_page.dart | 2 +- lib/pages/landing/landing_page_pharmcy.dart | 2 +- lib/pages/parent_categorise_page.dart | 2 +- lib/pages/pharmacies/product_detail.dart | 2198 ----------------- .../screens/pharmacy_module_page.dart | 2 +- .../product-details/availability_info.dart | 114 + .../screens/product-details/details_info.dart | 59 + .../product-details/discount_description.dart | 48 + .../product-details/footer-widget.dart | 492 ++++ .../product-details/product-detail.dart | 842 +++++++ .../product-name-and-price.dart | 177 ++ .../product-details/recommended_products.dart | 388 +++ .../screens/product-details/reviews_info.dart | 92 + .../pharmacies/widgets/ProductTileItem.dart | 2 +- lib/pages/search_products_page.dart | 2 +- lib/pages/sub_categorise_page.dart | 2 +- .../others/app_scafold_detail_page.dart | 49 +- 18 files changed, 2274 insertions(+), 2213 deletions(-) delete mode 100644 lib/pages/pharmacies/product_detail.dart create mode 100644 lib/pages/pharmacies/screens/product-details/availability_info.dart create mode 100644 lib/pages/pharmacies/screens/product-details/details_info.dart create mode 100644 lib/pages/pharmacies/screens/product-details/discount_description.dart create mode 100644 lib/pages/pharmacies/screens/product-details/footer-widget.dart create mode 100644 lib/pages/pharmacies/screens/product-details/product-detail.dart create mode 100644 lib/pages/pharmacies/screens/product-details/product-name-and-price.dart create mode 100644 lib/pages/pharmacies/screens/product-details/recommended_products.dart create mode 100644 lib/pages/pharmacies/screens/product-details/reviews_info.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 5af95569..6e18e0cd 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -13,16 +13,16 @@ const PACKAGES_CUSTOMER = '/api/customers'; const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; const PACKAGES_ORDERS = '/api/orders'; -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/'; const PING_SERVICE = 'Services/Weather.svc/REST/CheckConnectivity'; @@ -551,7 +551,7 @@ 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_MOST_VIEWED_PRODUCTS = "mostview"; const GET_NEW_PRODUCTS = "newproducts?"; // Home Health Care diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 78ed3383..51e9e60c 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -2,7 +2,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_page.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart'; diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 5da853fb..45f60bb7 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -3,7 +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/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/wishlist.dart'; diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 40bf2dc7..d7249c6b 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -2,7 +2,7 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.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/product_detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; diff --git a/lib/pages/pharmacies/product_detail.dart b/lib/pages/pharmacies/product_detail.dart deleted file mode 100644 index 06cae695..00000000 --- a/lib/pages/pharmacies/product_detail.dart +++ /dev/null @@ -1,2198 +0,0 @@ -import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.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/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/others/app_scafold_detail_page.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; -import 'package:rating_bar/rating_bar.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; -import 'screens/cart-order-page.dart'; -import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; - -int price = 0; -dynamic languageID; -bool isOverQuantity = false; -bool isInWishlit = false; -//int isSelected = 1; -bool isSelected= true; -String itemID; -var customerId; -CompareList compareItems = new CompareList(); -PharmacyProduct specificationData; -//Products recommendedData; - -class ProductDetailPage extends StatefulWidget { - final PharmacyProduct product; -// final Products recommendedProducts; - - - ProductDetailPage(this.product ); - - - @override - __ProductDetailPageState createState() => __ProductDetailPageState(); -} - -class __ProductDetailPageState extends State { - AppSharedPreferences sharedPref = AppSharedPreferences(); - - bool isTrue = true; - bool isDetails = true; - bool isReviews = false; - bool isAvailabilty = false; - dynamic wishlistItems; - //var model; - - // String ProductId="4561"; - // String productId = ""; - getLanguageID() async { - languageID = await sharedPref.getString(APP_LANGUAGE); - } - - checkWishlist() async { - GifLoaderDialogUtils.showMyDialog(context); - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.checkWishlistData(); - -// isInWishlit = x.wishListItems.map((e) => e.id.toString()).toList().contains(itemID); - - for (int i = 0; i < x.wishListItems.length; i++) { - if (itemID == x.wishListItems[i].product.id) { - isInWishlit = true; - break; - } else { - isInWishlit = false; - } - } - GifLoaderDialogUtils.hideDialog(context); - setState(() {}); - } - - - void initState() { - getLanguageID(); - price = 1; - specificationData = widget.product; - userInfo(); - super.initState(); - } - - void userInfo() async { - print(specificationData); - customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); - if (customerId != null) { - itemID = widget.product.id; - checkWishlist(); - } - print("customerId:$customerId"); - - setState(() {}); - } - - Widget build(BuildContext context) { - return customerId != null - ? DetailPageScafold( - appBarTitle: TranslationBase.of(context).productDetails, - isShowAppBar: true, - isPharmacy: true, - isShowDecPage: false, - body: SingleChildScrollView( - child: Column( - children: [ - Container( - width: double.infinity, - color: Colors.white, - child: Column( - children: [ - Image.network( - widget.product.images[0].src.trim(), - ), - widget.product.discountDescription != null - ? Container( - width: double.infinity, - height: 50, - color: Colors.yellowAccent, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 1, - child: Container( - alignment: Alignment.centerRight, - child: languageID == "ar" - ? Text( - widget.product - .discountDescriptionn, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 17), - ) - : Text( - widget.product - .discountDescription, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 17), - ), - ), - ), - SizedBox( - width: 10, - ), - Expanded( - flex: 0, - child: Container( - child: Image( - image: AssetImage( - 'assets/images/offer.png'), - ), - ), - ), - ], - ), - ) - : Container(), - ], - ), - ), - SizedBox( - height: 4, - ), - Container( - width: 500, - height: 220, - color: Colors.white, - child: productNameAndPrice(context, widget.product), - ), - SizedBox( - height: 6, - ), - Container( - width: 500, - height: 100, - color: Colors.white, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Text( - TranslationBase.of(context).specification, - style: TextStyle(fontWeight: FontWeight.bold), - ), - ), - ), - Divider(color: Colors.grey), - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Text( - TranslationBase.of(context).noData, -// "there is no data", - ), - ), - ), - ], - ), - ), - SizedBox( - height: 6, - ), - Container( - width: 500, - margin: EdgeInsets.only(bottom: 6), -// height: 350, - color: Colors.white, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = true; - isReviews = false; - isAvailabilty = false; - }); - }, - child: Text( - TranslationBase.of(context).details, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - isDetails - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container() - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = false; - isReviews = true; - isAvailabilty = false; - }); - }, - child: Text( - TranslationBase.of(context).reviews, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - isReviews - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container(), - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = false; - isReviews = false; - isAvailabilty = true; - }); - }, - child: Text( - TranslationBase.of(context).availability, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - isAvailabilty - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container(), - ], - ), - ], - ), - SizedBox( - height: 10, - ), - isDetails - ? Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - child: Text( - TranslationBase.of(context) - .description, - style: TextStyle( - fontSize: 17, - color: Colors.grey, - fontWeight: FontWeight.w600), - ), - ), - SizedBox( - height: 10, - ), - Divider(height: 1, color: Colors.grey), - SizedBox( - height: 15, - ), - Container( - child: Text( - languageID == "ar" - ? widget.product.fullDescriptionn - : widget.product.fullDescription ?? - "", - style: TextStyle( - fontSize: 16, - fontFamily: 'WorkSans-Regular'), - ), - ), - SizedBox( - height: 20, - ), - ]), - ) - -// Container( -// child: Text( -// languageID == 'ar' -// ? widget.product.fullDescriptionn -// : widget.product.fullDescription, -// style: TextStyle( -// fontSize: 16, -// fontFamily: 'WorkSans-Regular'), -// ), -// ), -// SizedBox( -// height: 10, -// ), -// Container( -// child: Text( -// TranslationBase.of(context).howToUse, -// style: TextStyle( -// fontSize: 17, -// color: Colors.grey, -// fontWeight: FontWeight.w600), -// ), -// ), -// SizedBox( -// height: 6, -// ), -// Divider( -// height: 2, -// color: Colors.grey), -// SizedBox( -// height: 10, -// ), -// Container( -// child: Text( -// languageID == 'ar' -// ? widget.product.shortDescriptionn -// : widget.product.shortDescription, -// style: TextStyle( -// fontSize: 16, -// fontFamily: 'WorkSans-Regular'), -// ), -// ), - // ], - // ), - // ) - : isReviews - ? BaseView( - onModelReady: (model) => - model.getProductReviewsData( - widget.product.id), - builder: (_, model, wi) => model - .productDetailService - .length != - 0 && - model.productDetailService[0] - .reviews.length != - 0 - ? ListView.builder( - physics: ScrollPhysics(), - itemCount: model - .productDetailService[0] - .reviews - .length, - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemBuilder: (BuildContext context, - int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - child: Row( - children: [ - Container( - child: Text( - model - .productDetailService[ - 0] - .reviews[ - index] - .customerId - .toString(), - style: TextStyle( - fontSize: 17, - color: Colors - .grey, - fontWeight: - FontWeight - .w600), - ), - ), - Container( - margin: - EdgeInsets.only( - left: 210), - child: RatingBar - .readOnly( - initialRating: model - .productDetailService[ - 0] - .reviews[ - index] - .rating - .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: 10, - ), - Container( - child: Text( - model - .productDetailService[ - 0] - .reviews[index] - .reviewText, - style: TextStyle( - fontSize: 20), - ), - ), - SizedBox( - height: 50, - ), - Divider( - height: 1, - color: Colors.grey), - ], - ), - ); - }, - ) - : Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text(TranslationBase.of(context).noReviewsAvailable,), -// Text('No Reviews Available'), - ), - ) - : isAvailabilty - ? BaseView( - onModelReady: (model) => - model.getProductLocationData(), - builder: (_, model, wi) => model - .productLocationService - .length == - 0 - ? Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text(TranslationBase.of(context).noLocationAvailable,), -// Text('No location Available'), - ) - : ListView.builder( - physics: ScrollPhysics(), - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemCount: model - .productLocationService - .length, - itemBuilder: - (BuildContext context, - int index) { - return Padding( - padding: - EdgeInsets.all(8.0), - child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// mainAxisAlignment: MainAxisAlignment.start, - children: [ - Row( -// crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: - MainAxisAlignment - .start, - children: [ - Expanded( - flex: 1, - child: Image.network(model - .productLocationService[ - index] - .projectImageUrl), - ), - SizedBox( - width: 10, - ), - Expanded( - flex: 4, - child: Text( - model - .productLocationService[ - index] - .locationDescription + - "\n" + - fixingString(model - .productLocationService[ - 0] - .cityName - .toString()), - 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: - () {}, - ), - ), - ], - ), - Divider( - height: 1.2, - color: Colors.grey) - ], - ), - ); - }, - ), - ) - : Container(), - ], - ), - ), - Row( - children: [ - customerId != null ? Container( - width: 410, - height: 50, - // margin: EdgeInsets.only(bottom: 5), - color: Colors.white, - child: Texts( - TranslationBase.of(context).recommended, - bold: true, - ), - ) - : Container(), - ], - ), - SingleChildScrollView( - child: Container( - width: 410, - color: Colors.white, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - // mainAxisAlignment: MainAxisAlignment.start, -// mainAxisSize: MainAxisSize.min, - children: [ - Container( - color: Colors.white, - height: 210, - margin: EdgeInsets.only(bottom: 75), - padding: EdgeInsets.only(bottom: 5), - // margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4), - child: BaseView( - - onModelReady: (model) => model.getRecommendedProducts(widget.product.id), - builder: (_, model, wi) => Container( - child: - model.recommendedProductList.length != null - ? Expanded( - child: ListView.builder( - scrollDirection: - Axis.horizontal, - shrinkWrap: true, - physics: ScrollPhysics(), - // physics: NeverScrollableScrollPhysics(), - itemCount: model.recommendedProductList.length, - itemBuilder: (context, index) { - return InkWell( - onTap: () - async { - GifLoaderDialogUtils.showMyDialog(context); - RecommendedProductModel data = model.recommendedProductList[index]; - var json = data.toJson(); - PharmacyProduct product = new PharmacyProduct.fromJson(json); - await Navigator.pushReplacement( - context, - FadePage( - page: ProductDetailPage(product), - )); - GifLoaderDialogUtils.hideDialog(context); - }, - child: Card( - elevation: 2, - shape: RoundedRectangleBorder( - side: BorderSide( - color: Colors.grey[300], - width: 2), - borderRadius: BorderRadius.circular(10)), - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 0, - ), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(15), - ), - ), - padding: EdgeInsets.symmetric(horizontal: 4), - width: MediaQuery.of(context).size.width / 3, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Stack( - children: [ - Container( - child: Align( - alignment: Alignment.topRight, - child: IconButton( - icon: Icon(model.recommendedProductList[index].isinwishlist != true ? Icons.favorite_border : Icons.favorite), - color: model.recommendedProductList[index].isinwishlist != true ? Colors.grey : Colors.red, - onPressed: () async { - - if (customerId != null ) { - if (!isInWishlit && model.recommendedProductList[index].isinwishlist != true) { - GifLoaderDialogUtils.showMyDialog(context); - await addToWishlistFunction(model.recommendedProductList[index].id); -// checkWishlist(); - GifLoaderDialogUtils.hideDialog(context); - setState((){ - model.recommendedProductList[index].isinwishlist= true; - }); - - } else { - GifLoaderDialogUtils.showMyDialog(context); - await deleteFromWishlistFunction(model.recommendedProductList[index].id); - GifLoaderDialogUtils.hideDialog(context); - setState((){ - model.recommendedProductList[index].isinwishlist = false; - }); - } - } else { - return ; - } - setState(() { - // checkWishlist(); - }); - }, - )), - -// child: Align( -// alignment: Alignment.topRight, -// child:itemID.contains(model.recommendedProductList[index]['id']) -// // !isInWishlist -// ? IconButton( -// icon: Icon(Icons.favorite_border), -// color: Colors.grey, -// iconSize: 30, -// onPressed: () { -// setState(() { -// if (customerId != null && isInWishlit ) { -// deleteFromWishlistFunction( -// model.recommendedProductList[index].id); -// } }); -// }, -// ) -// : IconButton( -// icon: Icon(Icons.favorite), -// color: Colors.red, -// iconSize: 30, -// onPressed: () { -// setState(() { -// if (customerId != null && !isInWishlit ) { -// addToWishlistFunction( -// model.recommendedProductList[index].id); -// } }); -// }, -// ) -// ), - ), - - Container( - margin: EdgeInsets.fromLTRB( - 0, - 16, - 10, - 16), - alignment: - Alignment.center, -// padding: EdgeInsets.only(left: 25, bottom: 20), - child: (model.recommendedProductList[index].images != null && - model.recommendedProductList[index].images.length > 0) - ? Image.network( - model.recommendedProductList[index].images[0].src.toString(), -// item.images[0].src, - fit: BoxFit.cover, - height: 60, - ) - : Image.asset( - "assets/images/no_image.png", - fit: BoxFit.cover, - height: 60, - ), - ), - Container( - width: model.recommendedProductList[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.recommendedProductList[index].rxMessage != null - ? Texts( - languageID == "ar" - ? model.recommendedProductList[index].rxMessagen - : model.recommendedProductList[index].rxMessage, - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ):Texts (""), - ), - ]), - Container( - margin: EdgeInsets - .symmetric( - horizontal: - 6, - vertical: 0, - ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - Text( - languageID == "ar" - ? model.recommendedProductList[index].namen - : model.recommendedProductList[index].name, - style: - TextStyle( - color: - Colors.black, - fontSize: - 13.0, -// fontWeight: FontWeight.bold, - ), - ), - Padding( -// padding: const EdgeInsets.only(top: 15, bottom: 10), - padding: const EdgeInsets.only( - top: - 10, - bottom: - 5), - child: - Texts( - "SAR ${model.recommendedProductList[index].price}", - bold: - true, - fontSize: - 14, - ), - ), - ], - ), - ), - Row( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: < - Widget>[ - Container( - padding: - EdgeInsets.only(right: 10), -// margin: EdgeInsets.only(left: 5), - child: - Align( - alignment: - Alignment.topLeft, - child: - RatingBar.readOnly( - initialRating: model.recommendedProductList[index].approvedRatingSum.toDouble(), -// initialRating: productRate, - size: - 13.0, - filledColor: - Colors.yellow[700], - emptyColor: - Colors.grey[500], - isHalfAllowed: - true, - halfFilledIcon: - Icons.star_half, - filledIcon: - Icons.star, - emptyIcon: - Icons.star, - ), - ), - ), - Texts( - "(${model.recommendedProductList[index].notApprovedTotalReviews.toString()})", -// bold: true, - fontSize: - 12, - ), - ]), - ], - ), - ), - ), - ); - }), - ) - : Container( - // color: Colors.white, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - // crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Texts(TranslationBase.of(context).nonRecommended, - color: Colors.black,), - ], - ), - ), - )), - ), - ], - ), - ), - ) - ], - ), - ), - bottomSheet: footerWidget( - widget.product.stockAvailability != 'Out of stock', - widget.product.orderMaximumQuantity, - widget.product.orderMinimumQuantity, - widget.product.stockQuantity, - widget.product), - ) - : AppScaffold( - appBarTitle: TranslationBase.of(context).productDetails, - isShowAppBar: true, - isPharmacy: true, - isShowDecPage: false, - showPharmacyCart: false, - showHomeAppBarIcon: false, - body: SingleChildScrollView( - child: Column( - children: [ - Container( - width: double.infinity, - color: Colors.white, - child: Column( - children: [ - Image.network( - widget.product.images[0].src.trim(), - ), - widget.product.discountDescription != null - ? Container( - width: double.infinity, - height: 50, - color: Colors.yellowAccent, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 1, - child: Container( - alignment: Alignment.centerRight, - child: languageID == 'ar' - ? Text( - widget.product - .discountDescriptionn, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 17), - ) - : Text( - widget.product - .discountDescription, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 17), - ), - ), - ), - SizedBox( - width: 10, - ), - Expanded( - flex: 0, - child: Container( - child: Image( - image: AssetImage( - 'assets/images/offer.png'), - ), - ), - ), - ], - ), - ) - : Container(), - ], - ), - ), - SizedBox( - height: 4, - ), - Container( - width: 500, - height: 150, - color: Colors.white, - child: productNameAndPrice(context, widget.product), - ), - SizedBox( - height: 6, - ), - Container( - width: 500, - height: 120, - color: Colors.white, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Text( - TranslationBase.of(context).specification, - style: TextStyle(fontWeight: FontWeight.bold), - ), - ), - ), - Divider(color: Colors.grey) - ], - ), - ), - SizedBox( - height: 6, - ), - Container( - width: 500, - margin: EdgeInsets.only(bottom: 100), -// height: 350, - color: Colors.white, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = true; - isReviews = false; - isAvailabilty = false; - }); - }, - child: Text( - TranslationBase.of(context).details, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - isDetails - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container() - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = false; - isReviews = true; - isAvailabilty = false; - }); - }, - child: Text( - TranslationBase.of(context).reviews, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - isReviews - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container(), - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = false; - isReviews = false; - isAvailabilty = true; - }); - }, - child: Text( - TranslationBase.of(context).availability, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - isAvailabilty - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container(), - ], - ), - ], - ), - SizedBox( - height: 10, - ), - isDetails - ? Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: Text( - TranslationBase.of(context).description, - style: TextStyle( - fontSize: 17, - color: Colors.grey, - fontWeight: FontWeight.w600), - ), - ), - SizedBox( - height: 6, - ), - Divider(height: 1, color: Colors.grey), - SizedBox( - height: 10, - ), - Container( - child: Text( - languageID == 'ar' - ? widget.product.shortDescriptionn - : widget.product.shortDescription, - style: TextStyle( - fontSize: 16, - fontFamily: 'WorkSans-Regular'), - ), - ), - SizedBox( - height: 10, - ), - Container( - child: Text( - TranslationBase.of(context).howToUse, - style: TextStyle( - fontSize: 17, - color: Colors.grey, - fontWeight: FontWeight.w600), - ), - ), - SizedBox( - height: 6, - ), - Divider(height: 2, color: Colors.grey), - SizedBox( - height: 10, - ), - Container( - child: Text( - languageID == 'ar' - ? widget.product.fullDescriptionn - : widget.product.fullDescription, - style: TextStyle( - fontSize: 16, - fontFamily: 'WorkSans-Regular'), - ), - ), - ], - ), - ) - : isReviews - ? BaseView( - onModelReady: (model) => - model.getProductReviewsData( - widget.product.id), - builder: (_, model, wi) => model - .productDetailService - .length != - 0 && - model.productDetailService[0] - .reviews.length != - 0 - ? ListView.builder( - physics: ScrollPhysics(), - itemCount: model - .productDetailService[0] - .reviews - .length, - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemBuilder: (BuildContext context, - int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - child: Row( - children: [ - Container( - child: Text( - model - .productDetailService[ - 0] - .reviews[ - index] - .customerId - .toString(), - style: TextStyle( - fontSize: 17, - color: Colors - .grey, - fontWeight: - FontWeight - .w600), - ), - ), - Container( - margin: - EdgeInsets.only( - left: 210), - child: RatingBar - .readOnly( - initialRating: model - .productDetailService[ - 0] - .reviews[ - index] - .rating - .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: 10, - ), - Container( - child: Text( - model - .productDetailService[ - 0] - .reviews[index] - .reviewText, - style: TextStyle( - fontSize: 20), - ), - ), - SizedBox( - height: 50, - ), - Divider( - height: 1, - color: Colors.grey), - ], - ), - ); - }, - ) - : Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text(TranslationBase.of(context).noReviewsAvailable), -// Text('No Reviews Available'), - ), - ) - : isAvailabilty - ? BaseView( - onModelReady: (model) => - model.getProductLocationData(), - builder: (_, model, wi) => - ListView.builder( - physics: ScrollPhysics(), - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemCount: model - .productLocationService.length, - itemBuilder: (BuildContext context, - int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// mainAxisAlignment: MainAxisAlignment.start, - children: [ - Row( -// crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Expanded( - flex: 1, - child: Image.network(model - .productLocationService[ - index] - .projectImageUrl), - ), - SizedBox( - width: 10, - ), - Expanded( - flex: 4, - child: Text( - model - .productLocationService[ - index] - .locationDescription + - "\n" + - fixingString(model - .productLocationService[ - 0] - .cityName - .toString()), - 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: () {}, - ), - ), - ], - ), - Divider( - height: 1.2, - color: Colors.grey) - ], - ), - ); - }, - ), - ) - : Container(), - ], - ), - ), -// ListView(scrollDirection: Axis.vertical, shrinkWrap: true, children: [Text('ENAD')]), - ], - ), - ), - bottomSheet: footerWidget( - widget.product.stockAvailability != 'Out of stock', - widget.product.orderMaximumQuantity, - widget.product.orderMinimumQuantity, - widget.product.stockQuantity, - widget.product), - ); - } -} - -class footerWidget extends StatefulWidget { - final bool isAvailble; - final int maxQuantity; - final int minQuantity; - final int quantityLimit; - final PharmacyProduct item; - - footerWidget(this.isAvailble, this.maxQuantity, this.minQuantity, - this.quantityLimit, this.item); - - @override - _footerWidgetState createState() => _footerWidgetState(); -} - -class _footerWidgetState extends State { - double quantityUI = 70; - bool showUI = false; - - @override - Widget build(BuildContext context) { - return Container( - width: double.infinity, - height: quantityUI, - color: Colors.white, - child: Column( - children: [ - showUI - ? Container( - width: double.infinity, - height: 90, - color: Colors.white, - child: Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - TranslationBase.of(context).quantity, - style: TextStyle( - fontSize: 15, fontWeight: FontWeight.bold), - ), - ), -// ListView( -// scrollDirection: Axis.horizontal, -// children: [ -// itemQuantity(), -// ], -// ), - Container( -// margin: EdgeInsets.symmetric(vertical: 20.0), - height: 50.0, - child: ListView( - scrollDirection: Axis.horizontal, - children: [ - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '1', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 1; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '2', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 2; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '3', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 3; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '4', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 4; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '5', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 5; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '6', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 6; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '7', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 7; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '8', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 8; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '9', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 9; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '10', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - price = 10; - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - return price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - Container( - width: 50.0, - child: TextField( - decoration: - InputDecoration(labelText: 'quantity #'), - onChanged: (text) { - print(price); - print(widget.quantityLimit); - if (int.tryParse(text) == null) { - text = ''; - } else { - setState(() { - price = int.parse(text); - if (price >= widget.quantityLimit) { - isOverQuantity = true; - } else { - isOverQuantity = false; - } - }); - } - }, - ), - ), - ], - ), - ) - ], - ), - ), - ) - : Container( - height: 20, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: 70, - height: 50, - child: FlatButton( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 4, - child: Text( - price.toString(), - style: TextStyle(fontSize: 20), - ), - ), - Expanded( - flex: 5, - child: Text( - TranslationBase.of(context).quantityShortcut, - style: TextStyle(fontSize: 16), - ), - ), - ], - ), - onPressed: () { - setState(() { - if (showUI) { - quantityUI = 70; - showUI = false; - } else { - quantityUI = 150; - showUI = true; - } - }); - }, - ), - ), - !widget.isAvailble && price > 0 || - price > widget.quantityLimit || - widget.item.rxMessage != null - ? Container( - width: 190, - height: 46, - color: Colors.grey, - child: Align( - alignment: Alignment.center, - child: Text( - TranslationBase.of(context).addToCart, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), - ), - ), - ) - : InkWell( - onTap: () { - addToCartFunction(price, widget.item.id, context); - }, - child: Container( - alignment: Alignment.center, - width: 190, - height: 46, - color: Colors.green, - child: Text( - TranslationBase.of(context).addToCart, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), - ), - ), - ), - SizedBox( - width: 5, - ), - !widget.isAvailble && price > 0 || - price > widget.quantityLimit || - widget.item.rxMessage != null - ? Container( - width: 120, - height: 46, - color: Colors.grey, - child: Align( - alignment: Alignment.center, - child: Text( - TranslationBase.of(context).buyNow, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), - ), - ), - ) - : InkWell( - onTap: () { - print('buy now'); - addToCartFunction(price, widget.item.id, context); - Navigator.push( - context, - FadePage(page: CartOrderPage()), - ); - }, - child: Container( - alignment: Alignment.center, - width: 120, - height: 46, - color: Colors.blue, - child: Text( - TranslationBase.of(context).buyNow, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), - ), - ), - ), - ], - ), - ], - ), - ); - } -} - -class productNameAndPrice extends StatefulWidget { - BuildContext context; - PharmacyProduct item; - - productNameAndPrice(this.context, this.item); - - @override - _productNameAndPriceState createState() => _productNameAndPriceState(); -} - -class _productNameAndPriceState extends State { - @override - Widget build(BuildContext context) { - return Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - children: [ - Text( - widget.item.price.toString() + " " + "SAR", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30), - ), - SizedBox( - width: 40, - ), - Text( - languageID == 'ar'? - widget.item.stockAvailabilityn : widget.item.stockAvailability , - style: widget.item.stockAvailability == 'Out of stock' - ? TextStyle(fontWeight: FontWeight.bold, color: Colors.red) - : TextStyle( - fontWeight: FontWeight.bold, color: Colors.green), - ), - SizedBox(width: 20), - widget.item.stockAvailability == 'Out of stock' && - customerId != null - ? InkWell( - onTap: () => - notifyMeWhenAvailable(context, widget.item.id), - child: Row(children: [ - Text( - TranslationBase.of(context).notifyMe, - style: TextStyle( - color: Colors.blue, - decoration: TextDecoration.underline, - ), - ), - SizedBox(width: 4), - Icon( - FontAwesomeIcons.bell, - color: Colors.blue, - size: 15.0, - ) - ]), - ) - : Container( - margin: languageID == 'ar' - ? EdgeInsets.only(right: 25) - : EdgeInsets.only(left: 25), - width: 40, - height: 40, - decoration: BoxDecoration( - color: Colors.grey, - borderRadius: BorderRadius.circular(30), - ), - child: IconButton( - icon: Icon(!isInWishlit - ? Icons.favorite_border - : Icons.favorite), - color: !isInWishlit ? Colors.white : Colors.red, - onPressed: () async { - if (customerId != null) { - if (!isInWishlit) { - GifLoaderDialogUtils.showMyDialog(context); - await addToWishlistFunction(widget.item.id); - GifLoaderDialogUtils.hideDialog(context); - } else { - await deleteFromWishlistFunction(widget.item.id); - } - } else { - return; - } - setState(() {}); - }, - )), - ], - ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - margin: EdgeInsets.only(left: 5), - child: Align( - alignment: - languageID == 'ar' ? Alignment.topRight : Alignment.topLeft, - child: Text( - languageID == 'ar' - ? widget.item.fullDescriptionn - : widget.item.fullDescription, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - ), - ), - ), - ), - Row( - children: [ - Expanded( - flex: 2, - child: Container( - margin: EdgeInsets.only(right: 150), - child: Align( - alignment: Alignment.bottomLeft, - child: RatingBar.readOnly( - initialRating: 3, - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, - ), - ), - ), - ), - Expanded( - flex: 1, - child: Container( - child: widget.item.rxMessage != null - ? Text( - languageID == 'ar' - ? widget.item.rxMessagen.toString() - : widget.item.rxMessage.toString(), - style: TextStyle(color: Colors.red, fontSize: 10), - ) - : Container()), - ), - widget.item.rxMessage != null - ? Icon( - FontAwesomeIcons.questionCircle, - color: Colors.red, - size: 15.0, - ) - : Container(), - ], - ), - ], - ); - } -} - -slideDetail() { - return Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 15.0), - decoration: const BoxDecoration( - border: Border( - top: BorderSide(width: 0.5, color: Colors.grey), - left: BorderSide(width: 0.5, color: Colors.grey), - right: BorderSide(width: 0.5, color: Colors.grey), - bottom: BorderSide(width: 0.5, color: Colors.grey), - ), - color: Colors.white, - ), - child: const Text('1', - textAlign: TextAlign.center, - style: TextStyle(color: Color(0xFF000000))), - ), - ) - ], - ); -} - -fixingString(txt) { - String stringTxt; - String newTxt; - stringTxt = txt.toString(); - newTxt = stringTxt.split('.')[1]; - - return newTxt; -} - -//getLanguageID() async { -// languageID = await sharedPref.getString(APP_LANGUAGE); -//} - -getSpecificationData(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - specificationData = await x.productSpecificationData(itemID); -} - -addToCartFunction(quantity, itemID, BuildContext context) async { - GifLoaderDialogUtils.showMyDialog(context); - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID).then((value) { - GifLoaderDialogUtils.hideDialog(context); - }); -} - -notifyMeWhenAvailable(context, itemId) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.notifyMe(customerId, itemId); -} - -addToWishlistFunction(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - isInWishlit = true; - await x.addToWishlistData(itemID); - -} - -deleteFromWishlistFunction(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - isInWishlit = false; - await x.deletWishlistData(itemID); -} - -checkWishlist() async { - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.checkWishlistData(); - -// isInWishlit = x.wishListItems.map((e) => e.id.toString()).toList().contains(itemID); - - for (int i = 0; i < x.wishListItems.length; i++) { - if (itemID == x.wishListItems[i].product.id) { - isInWishlit = true; - break; - } else { - isInWishlit = false; - } - } -} - -class sttingModalBottomSheet extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Container(); - } -} - -settingModalBottomSheet(context) { - showModalBottomSheet( - context: context, - builder: (BuildContext bc) { - return Container( - child: new Wrap( - children: [ - new ListTile( - leading: Icon(Icons.shopping_cart), - title: Text(TranslationBase.of(context) - .addToCart,), - onTap: () => { - if (price > 0) - {addToCartFunction(price, itemID, context)} - else - { - AppToast.showErrorToast( - message: "you should add quantity") - } - }), - ListTile( - leading: Icon(Icons.favorite_border), - title: Text(TranslationBase.of(context) - .addToWishlist,), - onTap: () => {addToWishlistFunction(itemID)}, - ), - ListTile( - leading: Icon(Icons.compare), - title: Text(TranslationBase.of(context) - .compare,), - onTap: () => { - Provider.of(context, listen: false) - .addItem(specificationData), - }, - ), - ], - ), - ); - }); -} diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index e5e9e230..6ede72a9 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -9,7 +9,7 @@ import 'package:diplomaticquarterapp/pages/landing/home_page.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; import 'package:diplomaticquarterapp/pages/offers_categorise_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product-brands.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/lacum-activitaion-vida-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/lakum-main-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/recommended-product-page.dart'; diff --git a/lib/pages/pharmacies/screens/product-details/availability_info.dart b/lib/pages/pharmacies/screens/product-details/availability_info.dart new file mode 100644 index 00000000..34a1d454 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/availability_info.dart @@ -0,0 +1,114 @@ +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:flutter/material.dart'; + +class AvailabilityInfo extends StatelessWidget { + + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => + model.getProductLocationData(), + builder: (_, model, wi) => model + .productLocationService + .length == + 0 + ? Container( + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text( + TranslationBase.of(context) + .noLocationAvailable, + ), +// Text('No location Available'), + ) + : ListView.builder( + physics: ScrollPhysics(), + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: model + .productLocationService + .length, + itemBuilder: + (BuildContext context, + int index) { + return Padding( + padding: + EdgeInsets.all(8.0), + child: Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// mainAxisAlignment: MainAxisAlignment.start, + children: [ + Row( +// crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .start, + children: [ + Expanded( + flex: 1, + child: Image.network(model + .productLocationService[ + index] + .projectImageUrl), + ), + SizedBox( + width: 10, + ), + Expanded( + flex: 4, + child: Text( + model + .productLocationService[ + index] + .locationDescription + + "\n" + + convertCityName( + model + .productLocationService[ + 0] + .cityName + .toString(), + ), + 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: + () {}, + ), + ), + ], + ), + Divider( + height: 1.2, + color: Colors.grey) + ], + ), + ); + }, + ), + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/details_info.dart b/lib/pages/pharmacies/screens/product-details/details_info.dart new file mode 100644 index 00000000..a347e941 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/details_info.dart @@ -0,0 +1,59 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class DetailsInfo extends StatelessWidget { + + final PharmacyProduct product; + + const DetailsInfo({Key key, this.product}) : super(key: key); + + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + child: Text( + TranslationBase.of(context) + .description, + style: TextStyle( + fontSize: 17, + color: Colors.grey, + fontWeight: FontWeight.w600), + ), + ), + SizedBox( + height: 10, + ), + Divider(height: 1, color: Colors.grey), + SizedBox( + height: 15, + ), + Container( + child: Text( + projectViewModel.isArabic + ? product.fullDescriptionn + : product + .fullDescription ?? + "", + style: TextStyle( + fontSize: 16, + fontFamily: 'WorkSans-Regular'), + ), + ), + SizedBox( + height: 20, + ), + ]), + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/discount_description.dart b/lib/pages/pharmacies/screens/product-details/discount_description.dart new file mode 100644 index 00000000..1c2b27d4 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/discount_description.dart @@ -0,0 +1,48 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:flutter/material.dart'; + +class DiscountDescription extends StatelessWidget { + final PharmacyProduct product; + + const DiscountDescription({Key key, this.product}) : super(key: key); + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + height: 50, + color: Colors.yellowAccent, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: 1, + child: Container( + alignment: Alignment.centerRight, + child: Text( + product + .discountDescription, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 17), + ), + ), + ), + SizedBox( + width: 10, + ), + Expanded( + flex: 0, + child: Container( + child: Image( + image: AssetImage( + 'assets/images/offer.png'), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/footer-widget.dart b/lib/pages/pharmacies/screens/product-details/footer-widget.dart new file mode 100644 index 00000000..db048b46 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/footer-widget.dart @@ -0,0 +1,492 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; + +import '../cart-order-page.dart'; + +class FooterWidget extends StatefulWidget { + final bool isAvailble; + final int maxQuantity; + final int minQuantity; + final int quantityLimit; + final PharmacyProduct item; + final Function addToCartFunction; + + int price; + bool isOverQuantity; + + FooterWidget(this.isAvailble, this.maxQuantity, this.minQuantity, + this.quantityLimit, this.item, {this.price, this.isOverQuantity = false, this.addToCartFunction}); + + @override + _FooterWidgetState createState() => _FooterWidgetState(); +} + +class _FooterWidgetState extends State { + double quantityUI = 70; + bool showUI = false; + + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + height: quantityUI, + color: Colors.white, + child: Column( + children: [ + showUI + ? Container( + width: double.infinity, + height: 90, + color: Colors.white, + child: Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + TranslationBase.of(context).quantity, + style: TextStyle( + fontSize: 15, fontWeight: FontWeight.bold), + ), + ), + + Container( + height: 50.0, + child: ListView( + scrollDirection: Axis.horizontal, + children: [ + InkWell( + child: Container( + alignment: Alignment.center, + width: 50.0, + color: Colors.white, + child: Text( + '1', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), + ), + ), + onTap: () { + setState(() { + widget.price = 1; + if (widget.price >= widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.isOverQuantity = false; + return widget.price; + } + }); + }, + ), + SizedBox( + width: 5, + ), + InkWell( + child: Container( + alignment: Alignment.center, + width: 50.0, + color: Colors.white, + child: Text( + '2', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), + ), + ), + onTap: () { + setState(() { + widget.price = 2; + if (widget.price >= widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.isOverQuantity = false; + return widget.price; + } + }); + }, + ), + SizedBox( + width: 5, + ), + InkWell( + child: Container( + alignment: Alignment.center, + width: 50.0, + color: Colors.white, + child: Text( + '3', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), + ), + ), + onTap: () { + setState(() { + widget.price = 3; + if (widget.price >= widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.isOverQuantity = false; + return widget.price; + } + }); + }, + ), + SizedBox( + width: 5, + ), + InkWell( + child: Container( + alignment: Alignment.center, + width: 50.0, + color: Colors.white, + child: Text( + '4', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), + ), + ), + onTap: () { + setState(() { + widget.price = 4; + if (widget.price >= widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.isOverQuantity = false; + return widget.price; + } + }); + }, + ), + SizedBox( + width: 5, + ), + InkWell( + child: Container( + alignment: Alignment.center, + width: 50.0, + color: Colors.white, + child: Text( + '5', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), + ), + ), + onTap: () { + setState(() { + widget.price = 5; + if (widget.price >= widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.isOverQuantity = false; + return widget.price; + } + }); + }, + ), + SizedBox( + width: 5, + ), + InkWell( + child: Container( + alignment: Alignment.center, + width: 50.0, + color: Colors.white, + child: Text( + '6', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), + ), + ), + onTap: () { + setState(() { + widget.price = 6; + if (widget.price >= widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.isOverQuantity = false; + return widget.price; + } + }); + }, + ), + SizedBox( + width: 5, + ), + InkWell( + child: Container( + alignment: Alignment.center, + width: 50.0, + color: Colors.white, + child: Text( + '7', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), + ), + ), + onTap: () { + setState(() { + widget.price = 7; + if (widget.price >= widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.isOverQuantity = false; + return widget.price; + } + }); + }, + ), + SizedBox( + width: 5, + ), + InkWell( + child: Container( + alignment: Alignment.center, + width: 50.0, + color: Colors.white, + child: Text( + '8', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), + ), + ), + onTap: () { + setState(() { + widget.price = 8; + if (widget.price >= widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.isOverQuantity = false; + return widget.price; + } + }); + }, + ), + SizedBox( + width: 5, + ), + InkWell( + child: Container( + alignment: Alignment.center, + width: 50.0, + color: Colors.white, + child: Text( + '9', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), + ), + ), + onTap: () { + setState(() { + widget.price = 9; + if (widget.price >= widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.isOverQuantity = false; + return widget.price; + } + }); + }, + ), + SizedBox( + width: 5, + ), + InkWell( + child: Container( + alignment: Alignment.center, + width: 50.0, + color: Colors.white, + child: Text( + '10', + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), + ), + ), + onTap: () { + setState(() { + widget.price = 10; + if (widget.price >= widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.isOverQuantity = false; + return widget.price; + } + }); + }, + ), + SizedBox( + width: 5, + ), + Container( + width: 50.0, + child: TextField( + decoration: + InputDecoration(labelText: 'quantity #'), + onChanged: (text) { + print(widget.price); + print(widget.quantityLimit); + if (int.tryParse(text) == null) { + text = ''; + } else { + setState(() { + widget.price = int.parse(text); + if (widget.price >= widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.isOverQuantity = false; + } + }); + } + }, + ), + ), + ], + ), + ) + ], + ), + ), + ) + : Container( + height: 20, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 70, + height: 50, + child: FlatButton( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: 4, + child: Text( + widget.price.toString(), + style: TextStyle(fontSize: 20), + ), + ), + Expanded( + flex: 5, + child: Text( + TranslationBase.of(context).quantityShortcut, + style: TextStyle(fontSize: 16), + ), + ), + ], + ), + onPressed: () { + setState(() { + if (showUI) { + quantityUI = 70; + showUI = false; + } else { + quantityUI = 150; + showUI = true; + } + }); + }, + ), + ), + !widget.isAvailble && widget.price > 0 || + widget.price > widget.quantityLimit || + widget.item.rxMessage != null + ? Container( + width: 190, + height: 46, + color: Colors.grey, + child: Align( + alignment: Alignment.center, + child: Text( + TranslationBase.of(context).addToCart, + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 15), + ), + ), + ) + : InkWell( + onTap: () { + widget.addToCartFunction(widget.price, widget.item.id, context); + }, + child: Container( + alignment: Alignment.center, + width: 190, + height: 46, + color: Colors.green, + child: Text( + TranslationBase.of(context).addToCart, + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 15), + ), + ), + ), + SizedBox( + width: 5, + ), + !widget.isAvailble && widget.price > 0 || + widget.price > widget.quantityLimit || + widget.item.rxMessage != null + ? Container( + width: 120, + height: 46, + color: Colors.grey, + child: Align( + alignment: Alignment.center, + child: Text( + TranslationBase.of(context).buyNow, + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 15), + ), + ), + ) + : InkWell( + onTap: () { + print('buy now'); + widget.addToCartFunction(widget.price, widget.item.id, context); + Navigator.push( + context, + FadePage(page: CartOrderPage()), + ); + }, + child: Container( + alignment: Alignment.center, + width: 120, + height: 46, + color: Colors.blue, + child: Text( + TranslationBase.of(context).buyNow, + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 15), + ), + ), + ), + ], + ), + ], + ), + ); + } +} \ No newline at end of file diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart new file mode 100644 index 00000000..b0777c19 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -0,0 +1,842 @@ +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.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/compare-list.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'; +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/others/app_scafold_detail_page.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; +import 'package:rating_bar/rating_bar.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; +import '../cart-order-page.dart'; +import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; + +import 'availability_info.dart'; +import 'details_info.dart'; +import 'discount_description.dart'; +import 'footer-widget.dart'; + +int price = 0; +bool isOverQuantity = false; +bool isInWishList = false; +bool isSelected = true; +String itemID; +var customerId; +CompareList compareItems = new CompareList(); +PharmacyProduct specificationData; + +class ProductDetailPage extends StatefulWidget { + final PharmacyProduct product; + + ProductDetailPage(this.product); + + @override + __ProductDetailPageState createState() => __ProductDetailPageState(); +} + +class __ProductDetailPageState extends State { + AppSharedPreferences sharedPref = AppSharedPreferences(); + + bool isTrue = true; + bool isDetails = true; + bool isReviews = false; + bool isAvailability = false; + + checkWishlist() async { + GifLoaderDialogUtils.showMyDialog(context); + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.checkWishlistData(); + + for (int i = 0; i < x.wishListItems.length; i++) { + if (itemID == x.wishListItems[i].product.id) { + isInWishList = true; + break; + } else { + isInWishList = false; + } + } + GifLoaderDialogUtils.hideDialog(context); + setState(() {}); + } + + void initState() { + price = 1; + specificationData = widget.product; + userInfo(); + super.initState(); + } + + void userInfo() async { + print(specificationData); + customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); + if (customerId != null) { + itemID = widget.product.id; + checkWishlist(); + } + setState(() {}); + } + + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + + return customerId != null + ? DetailPageScafold( + appBarTitle: TranslationBase.of(context).productDetails, + isShowAppBar: true, + isPharmacy: true, + isShowDecPage: false, + body: SingleChildScrollView( + child: Column( + children: [ + Container( + width: double.infinity, + color: Colors.white, + child: Column( + children: [ + Image.network( + widget.product.images[0].src.trim(), + ), + if (widget.product.discountDescription != null) + DiscountDescription(product: widget.product) + ], + ), + ), + SizedBox( + height: 4, + ), + Container( + width: 500, + height: 220, + color: Colors.white, + child: ProductNameAndPrice( + context, + widget.product, + customerId: customerId, + addToWishlistFunction: addToWishlistFunction, + deleteFromWishlistFunction: deleteFromWishlistFunction, + notifyMeWhenAvailable: notifyMeWhenAvailable, + isInWishList: isInWishList, + ), + ), + SizedBox( + height: 6, + ), + Container( + width: 500, + height: 100, + color: Colors.white, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Text( + TranslationBase.of(context).specification, + style: TextStyle(fontWeight: FontWeight.bold), + ), + ), + ), + Divider(color: Colors.grey), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Text( + TranslationBase.of(context).noData, + ), + ), + ), + ], + ), + ), + SizedBox( + height: 6, + ), + Container( + width: 500, + margin: EdgeInsets.only(bottom: 6), + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + 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, + ), + isDetails + ? Container( + width: 100, + height: 5, + color: Colors.green, + ) + : Container() + ], + ), + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () { + setState(() { + isDetails = false; + isReviews = true; + isAvailability = false; + }); + }, + child: Text( + TranslationBase.of(context).reviews, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + isReviews + ? Container( + width: 100, + height: 5, + color: Colors.green, + ) + : Container(), + ], + ), + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () { + setState(() { + isDetails = false; + isReviews = false; + isAvailability = true; + }); + }, + child: Text( + TranslationBase.of(context).availability, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + isAvailability + ? Container( + width: 100, + height: 5, + color: Colors.green, + ) + : Container(), + ], + ), + ], + ), + SizedBox( + height: 10, + ), + isDetails + ? DetailsInfo( + product: widget.product, + ) + : isReviews + ? ReviewsInfo( + product: widget.product, + ) + : isAvailability + ? AvailabilityInfo() + : Container(), + ], + ), + ), + Row( + children: [ + customerId != null + ? Container( + width: 410, + height: 50, + color: Colors.white, + child: Texts( + TranslationBase.of(context).recommended, + bold: true, + ), + ) + : Container(), + ], + ), + RecommendedProducts(product: widget.product) + ], + ), + ), + bottomSheet: FooterWidget( + widget.product.stockAvailability != 'Out of stock', + widget.product.orderMaximumQuantity, + widget.product.orderMinimumQuantity, + widget.product.stockQuantity, + widget.product, + price: price, + isOverQuantity: isOverQuantity, + addToCartFunction: addToCartFunction, + ), + ) + : AppScaffold( + appBarTitle: TranslationBase.of(context).productDetails, + isShowAppBar: true, + isPharmacy: true, + isShowDecPage: false, + showPharmacyCart: false, + showHomeAppBarIcon: false, + body: SingleChildScrollView( + child: Column( + children: [ + Container( + width: double.infinity, + color: Colors.white, + child: Column( + children: [ + Image.network( + widget.product.images[0].src.trim(), + ), + widget.product.discountDescription != null + ? Container( + width: double.infinity, + height: 50, + color: Colors.yellowAccent, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: 1, + child: Container( + alignment: Alignment.centerRight, + child: projectViewModel.isArabic + ? Text( + widget.product + .discountDescriptionn, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 17), + ) + : Text( + widget.product + .discountDescription, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 17), + ), + ), + ), + SizedBox( + width: 10, + ), + Expanded( + flex: 0, + child: Container( + child: Image( + image: AssetImage( + 'assets/images/offer.png'), + ), + ), + ), + ], + ), + ) + : Container(), + ], + ), + ), + SizedBox( + height: 4, + ), + Container( + width: 500, + height: 150, + color: Colors.white, + child: ProductNameAndPrice( + context, + widget.product, + customerId: customerId, + addToWishlistFunction: addToWishlistFunction, + deleteFromWishlistFunction: deleteFromWishlistFunction, + notifyMeWhenAvailable: notifyMeWhenAvailable, + isInWishList: isInWishList, + ), + ), + SizedBox( + height: 6, + ), + Container( + width: 500, + height: 120, + color: Colors.white, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Text( + TranslationBase.of(context).specification, + style: TextStyle(fontWeight: FontWeight.bold), + ), + ), + ), + Divider(color: Colors.grey) + ], + ), + ), + SizedBox( + height: 6, + ), + Container( + width: 500, + margin: EdgeInsets.only(bottom: 100), +// height: 350, + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + 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, + ), + isDetails + ? Container( + width: 100, + height: 5, + color: Colors.green, + ) + : Container() + ], + ), + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () { + setState(() { + isDetails = false; + isReviews = true; + isAvailability = false; + }); + }, + child: Text( + TranslationBase.of(context).reviews, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + isReviews + ? Container( + width: 100, + height: 5, + color: Colors.green, + ) + : Container(), + ], + ), + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () { + setState(() { + isDetails = false; + isReviews = false; + isAvailability = true; + }); + }, + child: Text( + TranslationBase.of(context).availability, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + isAvailability + ? Container( + width: 100, + height: 5, + color: Colors.green, + ) + : Container(), + ], + ), + ], + ), + SizedBox( + height: 10, + ), + isDetails + ? Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Text( + TranslationBase.of(context).description, + style: TextStyle( + fontSize: 17, + color: Colors.grey, + fontWeight: FontWeight.w600), + ), + ), + SizedBox( + height: 6, + ), + Divider(height: 1, color: Colors.grey), + SizedBox( + height: 10, + ), + Container( + child: Text( + projectViewModel.isArabic + ? widget.product.shortDescriptionn + : widget.product.shortDescription, + style: TextStyle( + fontSize: 16, + fontFamily: 'WorkSans-Regular'), + ), + ), + SizedBox( + height: 10, + ), + Container( + child: Text( + TranslationBase.of(context).howToUse, + style: TextStyle( + fontSize: 17, + color: Colors.grey, + fontWeight: FontWeight.w600), + ), + ), + SizedBox( + height: 6, + ), + Divider(height: 2, color: Colors.grey), + SizedBox( + height: 10, + ), + Container( + child: Text( + projectViewModel.isArabic + ? widget.product.fullDescriptionn + : widget.product.fullDescription, + style: TextStyle( + fontSize: 16, + fontFamily: 'WorkSans-Regular'), + ), + ), + ], + ), + ) + : isReviews + ? BaseView( + onModelReady: (model) => + model.getProductReviewsData( + widget.product.id), + builder: (_, model, wi) => model + .productDetailService + .length != + 0 && + model.productDetailService[0] + .reviews.length != + 0 + ? ListView.builder( + physics: ScrollPhysics(), + itemCount: model + .productDetailService[0] + .reviews + .length, + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemBuilder: (BuildContext context, + int index) { + return Padding( + padding: EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + child: Row( + children: [ + Container( + child: Text( + model + .productDetailService[ + 0] + .reviews[ + index] + .customerId + .toString(), + style: TextStyle( + fontSize: 17, + color: Colors + .grey, + fontWeight: + FontWeight + .w600), + ), + ), + Container( + margin: + EdgeInsets.only( + left: 210), + child: RatingBar + .readOnly( + initialRating: model + .productDetailService[ + 0] + .reviews[ + index] + .rating + .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: 10, + ), + Container( + child: Text( + model + .productDetailService[ + 0] + .reviews[index] + .reviewText, + style: TextStyle( + fontSize: 20), + ), + ), + SizedBox( + height: 50, + ), + Divider( + height: 1, + color: Colors.grey), + ], + ), + ); + }, + ) + : Container( + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text( + TranslationBase.of(context) + .noReviewsAvailable), + ), + ) + : isAvailability + ? BaseView( + onModelReady: (model) => + model.getProductLocationData(), + builder: (_, model, wi) => + ListView.builder( + physics: ScrollPhysics(), + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: model + .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(model + .productLocationService[ + index] + .projectImageUrl), + ), + SizedBox( + width: 10, + ), + Expanded( + flex: 4, + child: Text( + model + .productLocationService[ + index] + .locationDescription + + "\n" + + convertCityName( + model + .productLocationService[ + 0] + .cityName + .toString(), + ), + 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: () {}, + ), + ), + ], + ), + Divider( + height: 1.2, + color: Colors.grey) + ], + ), + ); + }, + ), + ) + : Container(), + ], + ), + ), + ], + ), + ), + bottomSheet: FooterWidget( + widget.product.stockAvailability != 'Out of stock', + widget.product.orderMaximumQuantity, + widget.product.orderMinimumQuantity, + widget.product.stockQuantity, + widget.product, + price: price, + isOverQuantity: isOverQuantity, + addToCartFunction: addToCartFunction, + ), + ); + } +} + +convertCityName(txt) { + String stringTxt; + String newTxt; + stringTxt = txt.toString(); + newTxt = stringTxt.split('.')[1]; + + return newTxt; +} + +addToCartFunction(quantity, itemID, BuildContext context) async { + GifLoaderDialogUtils.showMyDialog(context); + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.addToCartData(quantity, itemID).then((value) { + GifLoaderDialogUtils.hideDialog(context); + }); +} + +notifyMeWhenAvailable(context, itemId) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.notifyMe(customerId, itemId); +} + +addToWishlistFunction(itemID) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + isInWishList = true; + await x.addToWishlistData(itemID); +} + +deleteFromWishlistFunction(itemID) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + isInWishList = false; + await x.deletWishlistData(itemID); +} 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 new file mode 100644 index 00000000..428f49e8 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart @@ -0,0 +1,177 @@ + +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.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:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; +import 'package:rating_bar/rating_bar.dart'; + +class ProductNameAndPrice extends StatefulWidget { + BuildContext context; + PharmacyProduct item; + final customerId; + final bool isInWishList; + final Function notifyMeWhenAvailable; + final Function addToWishlistFunction; + final Function deleteFromWishlistFunction; + + + ProductNameAndPrice(this.context, this.item, + {this.customerId, + this.isInWishList, + this.notifyMeWhenAvailable, + this.addToWishlistFunction, + this.deleteFromWishlistFunction}); + + @override + _ProductNameAndPriceState createState() => _ProductNameAndPriceState(); +} + +class _ProductNameAndPriceState extends State { + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + + return Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + children: [ + Text( + widget.item.price.toString() + " " + "SAR", + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30), + ), + SizedBox( + width: 40, + ), + Text( + projectViewModel.isArabic + ? widget.item.stockAvailabilityn + : widget.item.stockAvailability, + style: widget.item.stockAvailability == 'Out of stock' + ? TextStyle(fontWeight: FontWeight.bold, color: Colors.red) + : TextStyle( + fontWeight: FontWeight.bold, color: Colors.green), + ), + SizedBox(width: 20), + widget.item.stockAvailability == 'Out of stock' && + widget.customerId != null + ? InkWell( + onTap: () => + widget.notifyMeWhenAvailable(context, widget.item.id), + child: Row(children: [ + Text( + TranslationBase.of(context).notifyMe, + style: TextStyle( + color: Colors.blue, + decoration: TextDecoration.underline, + ), + ), + SizedBox(width: 4), + Icon( + FontAwesomeIcons.bell, + color: Colors.blue, + size: 15.0, + ) + ]), + ) + : Container( + margin: projectViewModel.isArabic + ? EdgeInsets.only(right: 25) + : EdgeInsets.only(left: 25), + width: 40, + height: 40, + decoration: BoxDecoration( + color: Colors.grey, + borderRadius: BorderRadius.circular(30), + ), + child: IconButton( + icon: Icon(!widget.isInWishList + ? Icons.favorite_border + : Icons.favorite), + color: !widget.isInWishList ? Colors.white : Colors.red, + onPressed: () async { + if (widget.customerId != null) { + if (!widget.isInWishList) { + GifLoaderDialogUtils.showMyDialog(context); + await widget.addToWishlistFunction(widget.item.id); + GifLoaderDialogUtils.hideDialog(context); + } else { + await widget.deleteFromWishlistFunction(widget.item.id); + } + } else { + return; + } + setState(() {}); + }, + )), + ], + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + margin: EdgeInsets.only(left: 5), + child: Align( + alignment: + projectViewModel.isArabic ? Alignment.topRight : Alignment.topLeft, + child: Text( + projectViewModel.isArabic + ? widget.item.fullDescriptionn + : widget.item.fullDescription, + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), + ), + ), + ), + ), + Row( + children: [ + Expanded( + flex: 2, + child: Container( + margin: EdgeInsets.only(right: 150), + child: Align( + alignment: Alignment.bottomLeft, + child: RatingBar.readOnly( + initialRating: 3, + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), + ), + ), + ), + Expanded( + flex: 1, + child: Container( + child: widget.item.rxMessage != null + ? Text( + projectViewModel.isArabic + ? widget.item.rxMessagen.toString() + : widget.item.rxMessage.toString(), + style: TextStyle(color: Colors.red, fontSize: 10), + ) + : Container()), + ), + widget.item.rxMessage != null + ? Icon( + FontAwesomeIcons.questionCircle, + color: Colors.red, + size: 15.0, + ) + : Container(), + ], + ), + ], + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/recommended_products.dart b/lib/pages/pharmacies/screens/product-details/recommended_products.dart new file mode 100644 index 00000000..f40f1f08 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/recommended_products.dart @@ -0,0 +1,388 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_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-detail.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/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:rating_bar/rating_bar.dart'; + +class RecommendedProducts extends StatefulWidget { + final PharmacyProduct product; + + const RecommendedProducts({Key key, this.product}) : super(key: key); + + @override + _RecommendedProductsState createState() => _RecommendedProductsState(); +} + +class _RecommendedProductsState extends State { + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return SingleChildScrollView( + child: Container( + width: 410, + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + color: Colors.white, + height: 210, + margin: EdgeInsets.only(bottom: 75), + padding: EdgeInsets.only(bottom: 5), + // margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4), + child: BaseView( + onModelReady: (model) => model + .getRecommendedProducts(widget.product.id), + builder: (_, model, wi) => Container( + child: + model.recommendedProductList.length != null + ? ListView.builder( + scrollDirection: + Axis.horizontal, + shrinkWrap: true, + physics: ScrollPhysics(), + // physics: NeverScrollableScrollPhysics(), + itemCount: model + .recommendedProductList + .length, + itemBuilder: (context, index) { + return InkWell( + onTap: () async { + GifLoaderDialogUtils + .showMyDialog( + context); + RecommendedProductModel + data = + model.recommendedProductList[ + index]; + var json = data.toJson(); + PharmacyProduct product = + new PharmacyProduct + .fromJson(json); + await Navigator + .pushReplacement( + context, + FadePage( + page: + ProductDetailPage( + product), + ), + ); + GifLoaderDialogUtils + .hideDialog(context); + }, + child: Card( + elevation: 2, + shape: + RoundedRectangleBorder( + side: BorderSide( + color: Colors + .grey[300], + width: 2), + borderRadius: + BorderRadius + .circular(10), + ), + margin: + EdgeInsets.symmetric( + horizontal: 8, + vertical: 0, + ), + child: Container( + decoration: + BoxDecoration( + borderRadius: + BorderRadius.all( + Radius.circular(15), + ), + ), + padding: EdgeInsets + .symmetric( + horizontal: 4), + width: MediaQuery.of( + context) + .size + .width / + 3, + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Stack(children: [ + Container( + child: Align( + alignment: + Alignment + .topRight, + child: + IconButton( + icon: Icon(model.recommendedProductList[index].isinwishlist != + true + ? Icons + .favorite_border + : Icons + .favorite), + color: model.recommendedProductList[index].isinwishlist != + true + ? Colors + .grey + : Colors + .red, + onPressed: + () async { + if (customerId != + null) { + if (!isInWishList && + model.recommendedProductList[index].isinwishlist != + true) { + GifLoaderDialogUtils.showMyDialog( + context); + await addToWishlistFunction(model + .recommendedProductList[index] + .id); +// checkWishlist(); + GifLoaderDialogUtils.hideDialog( + context); + setState( + () { + model.recommendedProductList[index].isinwishlist = + true; + }); + } else { + GifLoaderDialogUtils.showMyDialog( + context); + await deleteFromWishlistFunction(model + .recommendedProductList[index] + .id); + GifLoaderDialogUtils.hideDialog( + context); + setState( + () { + model.recommendedProductList[index].isinwishlist = + false; + }); + } + } else { + return; + } + setState( + () { + // checkWishlist(); + }); + }, + ), + ), + ), + Container( + margin: EdgeInsets + .fromLTRB( + 0, + 16, + 10, + 16), + alignment: + Alignment + .center, + child: (model.recommendedProductList[index].images != + null && + model.recommendedProductList[index].images.length > + 0) + ? Image + .network( + model + .recommendedProductList[index] + .images[0] + .src + .toString(), + fit: BoxFit + .cover, + height: + 60, + ) + : Image + .asset( + "assets/images/no_image.png", + fit: BoxFit + .cover, + height: + 60, + ), + ), + Container( + width: model + .recommendedProductList[ + 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.recommendedProductList[index] + .rxMessage != + null + ? Texts( + projectViewModel.isArabic + ? model.recommendedProductList[index].rxMessagen + : model.recommendedProductList[index].rxMessage, + color: Colors + .white, + regular: + true, + fontSize: + 10, + fontWeight: + FontWeight.w400, + ) + : Texts(""), + ), + ]), + Container( + margin: EdgeInsets + .symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text( + projectViewModel + .isArabic + ? model + .recommendedProductList[ + index] + .namen + : model + .recommendedProductList[index] + .name, + style: + TextStyle( + color: Colors + .black, + fontSize: + 13.0, +// fontWeight: FontWeight.bold, + ), + ), + Padding( +// padding: const EdgeInsets.only(top: 15, bottom: 10), + padding: const EdgeInsets + .only( + top: 10, + bottom: + 5), + child: + Texts( + "SAR ${model.recommendedProductList[index].price}", + bold: + true, + fontSize: + 14, + ), + ), + ], + ), + ), + Row( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: < + Widget>[ + Container( + padding: EdgeInsets.only( + right: + 10), + child: + Align( + alignment: + Alignment + .topLeft, + child: RatingBar + .readOnly( + initialRating: model + .recommendedProductList[index] + .approvedRatingSum + .toDouble(), + size: + 13.0, + filledColor: + Colors.yellow[700], + emptyColor: + Colors.grey[500], + isHalfAllowed: + true, + halfFilledIcon: + Icons.star_half, + filledIcon: + Icons.star, + emptyIcon: + Icons.star, + ), + ), + ), + Texts( + "(${model.recommendedProductList[index].notApprovedTotalReviews.toString()})", +// bold: true, + fontSize: + 12, + ), + ]), + ], + ), + ), + ), + ); + }) + : Container( + // color: Colors.white, + child: Row( + mainAxisAlignment: + MainAxisAlignment.center, + // crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Texts( + TranslationBase.of(context) + .nonRecommended, + color: Colors.black, + ), + ], + ), + ), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/reviews_info.dart b/lib/pages/pharmacies/screens/product-details/reviews_info.dart new file mode 100644 index 00000000..a133fce3 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/reviews_info.dart @@ -0,0 +1,92 @@ +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/uitl/translations_delegate_base.dart'; +import 'package:flutter/material.dart'; +import 'package:rating_bar/rating_bar.dart'; + +class ReviewsInfo extends StatelessWidget { + final PharmacyProduct product; + + const ReviewsInfo({Key key, this.product}) : super(key: key); + + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getProductReviewsData(product.id), + builder: (_, model, wi) => model.productDetailService.length != 0 && + model.productDetailService[0].reviews.length != 0 + ? ListView.builder( + physics: ScrollPhysics(), + itemCount: model.productDetailService[0].reviews.length, + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Row( + children: [ + Container( + child: Text( + model.productDetailService[0].reviews[index] + .customerId + .toString(), + style: TextStyle( + fontSize: 17, + color: Colors.grey, + fontWeight: FontWeight.w600), + ), + ), + Container( + margin: EdgeInsets.only(left: 210), + child: RatingBar.readOnly( + initialRating: model.productDetailService[0] + .reviews[index].rating + .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: 10, + ), + Container( + child: Text( + model.productDetailService[0].reviews[index] + .reviewText, + style: TextStyle(fontSize: 20), + ), + ), + SizedBox( + height: 50, + ), + Divider(height: 1, color: Colors.grey), + ], + ), + ); + }, + ) + : Container( + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text( + TranslationBase.of(context).noReviewsAvailable, + ), +// Text('No Reviews Available'), + ), + ); + } +} diff --git a/lib/pages/pharmacies/widgets/ProductTileItem.dart b/lib/pages/pharmacies/widgets/ProductTileItem.dart index a7e71fab..c2781a98 100644 --- a/lib/pages/pharmacies/widgets/ProductTileItem.dart +++ b/lib/pages/pharmacies/widgets/ProductTileItem.dart @@ -1,7 +1,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/phramacy-product-detail-page.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; diff --git a/lib/pages/search_products_page.dart b/lib/pages/search_products_page.dart index 16720946..42d3e61b 100644 --- a/lib/pages/search_products_page.dart +++ b/lib/pages/search_products_page.dart @@ -2,7 +2,7 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product-brands.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 45617072..51c535b9 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -1,6 +1,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; diff --git a/lib/widgets/others/app_scafold_detail_page.dart b/lib/widgets/others/app_scafold_detail_page.dart index b7f98b08..99f78062 100644 --- a/lib/widgets/others/app_scafold_detail_page.dart +++ b/lib/widgets/others/app_scafold_detail_page.dart @@ -6,7 +6,9 @@ import 'package:diplomaticquarterapp/core/viewModels/base_view_model.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/compare-list.dart'; import 'package:diplomaticquarterapp/routes.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/bottom_bar.dart'; @@ -23,7 +25,7 @@ import '../progress_indicator/app_loader_widget.dart'; import 'arrow_back.dart'; import 'network_base_view.dart'; import 'not_auh_page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; class DetailPageScafold extends StatefulWidget { @@ -219,4 +221,49 @@ class AppBarWidget extends StatelessWidget with PreferredSizeWidget { @override Size get preferredSize => Size(double.maxFinite, 60); + + + settingModalBottomSheet(context) { + showModalBottomSheet( + context: context, + builder: (BuildContext bc) { + return Container( + child: new Wrap( + children: [ + new ListTile( + leading: Icon(Icons.shopping_cart), + title: Text( + TranslationBase.of(context).addToCart, + ), + onTap: () => { + if (price > 0) + {addToCartFunction(price, itemID, context)} + else + { + AppToast.showErrorToast( + message: "you should add quantity") + } + }), + ListTile( + leading: Icon(Icons.favorite_border), + title: Text( + TranslationBase.of(context).addToWishlist, + ), + onTap: () => {addToWishlistFunction(itemID)}, + ), + ListTile( + leading: Icon(Icons.compare), + title: Text( + TranslationBase.of(context).compare, + ), + onTap: () => { + Provider.of(context, listen: false) + .addItem(specificationData), + }, + ), + ], + ), + ); + }); + } } From 769dc4e0ac0492dc9cfc51d0b4b176180e1a8667 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 4 Oct 2021 16:03:38 +0300 Subject: [PATCH 12/67] first step of ProductDetailPage refactor --- .../screens/product-details/product-detail.dart | 12 ------------ lib/widgets/others/app_scafold_detail_page.dart | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index b0777c19..5f596e3a 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -117,8 +117,6 @@ class __ProductDetailPageState extends State { height: 4, ), Container( - width: 500, - height: 220, color: Colors.white, child: ProductNameAndPrice( context, @@ -134,8 +132,6 @@ class __ProductDetailPageState extends State { height: 6, ), Container( - width: 500, - height: 100, color: Colors.white, child: Column( mainAxisAlignment: MainAxisAlignment.start, @@ -151,14 +147,6 @@ class __ProductDetailPageState extends State { ), ), Divider(color: Colors.grey), - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Text( - TranslationBase.of(context).noData, - ), - ), - ), ], ), ), diff --git a/lib/widgets/others/app_scafold_detail_page.dart b/lib/widgets/others/app_scafold_detail_page.dart index 99f78062..595e0872 100644 --- a/lib/widgets/others/app_scafold_detail_page.dart +++ b/lib/widgets/others/app_scafold_detail_page.dart @@ -185,6 +185,18 @@ class AppBarWidget extends StatelessWidget with PreferredSizeWidget { ), centerTitle: true, actions: [ + /// TODO Elham* fix this + if(isPharmacy) + IconButton( + icon: Icon(Icons.shopping_cart), + color: Colors.grey, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => CartOrderPage()), + ); + }), image != null ? InkWell( onTap: () => Navigator.push( From 2265487ccda97354eb367687e225c086cb39721d Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 4 Oct 2021 16:10:00 +0300 Subject: [PATCH 13/67] remove cart cout & icon from AppBar --- .../pharmacies/screens/cart-order-page.dart | 73 ++++++++++++------- lib/widgets/others/app_scaffold_widget.dart | 53 +++++++------- 2 files changed, 73 insertions(+), 53 deletions(-) diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index 6c760fcd..c2ebf4b2 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -24,9 +24,10 @@ class CartOrderPage extends StatelessWidget { final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; AppScaffold appScaffold; return BaseView( - onModelReady: (model){ - model.getShoppingCart().then((value){ - appScaffold.appBar.badgeUpdater('${model.cartResponse.quantityCount ?? 0}'); + onModelReady: (model) { + model.getShoppingCart().then((value) { + appScaffold.appBar + .badgeUpdater('${model.cartResponse.quantityCount ?? 0}'); }); }, builder: (_, model, wi) => ChangeNotifierProvider.value( @@ -69,24 +70,40 @@ class CartOrderPage extends StatelessWidget { child: Column( children: [ ...List.generate( - cart.shoppingCarts != null ? cart.shoppingCarts.length : 0, + cart.shoppingCarts != null + ? cart.shoppingCarts.length + : 0, (index) => ProductOrderItem( - cart.shoppingCarts[index], () {print(cart.shoppingCarts[index].quantity); - model.changeProductQuantity(cart.shoppingCarts[index]).then((value) { - if (model.state != ViewState.Error) { - appScaffold.appBar.badgeUpdater('${value.quantityCount ?? 0}'); + cart.shoppingCarts[index], () { + print(cart.shoppingCarts[index] + .quantity); + model + .changeProductQuantity( + cart.shoppingCarts[index]) + .then((value) { + if (model.state != + ViewState.Error) { + appScaffold.appBar.badgeUpdater( + '${value.quantityCount ?? 0}'); } if (model.state == - ViewState.ErrorLocal) {Utils.showErrorToast(model.error);} + ViewState.ErrorLocal) { + Utils.showErrorToast( + model.error); + } + }); + }, () { + model + .deleteProduct( + cart.shoppingCarts[index]) + .then((value) { + if (model.state != + ViewState.Error) { + appScaffold.appBar.badgeUpdater( + '${value.quantityCount ?? 0}'); + } }); - }, - () { - model.deleteProduct(cart.shoppingCarts[index]).then((value){ - if (model.state != ViewState.Error) { - appScaffold.appBar.badgeUpdater('${value.quantityCount ?? 0}'); - } - }); - })) + })) ], ), ), @@ -200,7 +217,8 @@ class CartOrderPage extends StatelessWidget { ), Padding( padding: const EdgeInsets.all(8.0), - child: Text(TranslationBase.of(context).noData, + child: Text( + TranslationBase.of(context).noData, // 'There is no data', style: TextStyle(fontSize: 30), ), @@ -270,21 +288,20 @@ class _OrderBottomWidgetState extends State { width: 25.0, height: widget.height * 0.070, decoration: new BoxDecoration( - color: !isAgree - ? Color(0xffeeeeee) - : Colors.green, + color: + !isAgree ? Color(0xffeeeeee) : Colors.green, shape: BoxShape.circle, ), child: !isAgree ? null : Padding( - padding: const EdgeInsets.all(0.0), - child: Icon( - Icons.check, - color: Colors.white, - size: 25, - ), - ), + padding: const EdgeInsets.all(0.0), + child: Icon( + Icons.check, + color: Colors.white, + size: 25, + ), + ), ), ), Expanded( diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index b99ac1dc..962d0506 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -177,6 +177,7 @@ class AppBarWidget extends StatefulWidget with PreferredSizeWidget { } String _badgeText = "0"; + class AppBarWidgetState extends State { @override Widget build(BuildContext context) { @@ -218,33 +219,35 @@ class AppBarWidgetState extends State { centerTitle: true, actions: [ (widget.isPharmacy && widget.showPharmacyCart) - ? IconButton( - icon: Badge( - shape: BadgeShape.circle, - badgeContent: Text(_badgeText, style: TextStyle(color: Colors.white)), - child: Icon(Icons.shopping_cart)), - color: Colors.white, - onPressed: () { - Navigator.of(context).popUntil(ModalRoute.withName('/')); - }) + ? Container() + // ? IconButton( + // icon: Badge( + // shape: BadgeShape.circle, + // badgeContent: Text(_badgeText, style: TextStyle(color: Colors.white)), + // child: Icon(Icons.shopping_cart)), + // color: Colors.white, + // onPressed: () { + // Navigator.of(context).popUntil(ModalRoute.withName('/')); + // }) : Container(), (widget.isOfferPackages && widget.showOfferPackagesCart) - ? IconButton( - icon: Badge( - position: BadgePosition.topStart(top: -15, start: -10), - badgeContent: Text( - _badgeText, - style: TextStyle( - fontSize: 9, - color: Colors.white, - fontWeight: FontWeight.normal), - ), - child: Icon(Icons.shopping_cart)), - color: Colors.white, - onPressed: () { - // Cart Click Event - if (_onCartClick != null) _onCartClick(); - }) + ? Container() + // ? IconButton( + // icon: Badge( + // position: BadgePosition.topStart(top: -15, start: -10), + // badgeContent: Text( + // _badgeText, + // style: TextStyle( + // fontSize: 9, + // color: Colors.white, + // fontWeight: FontWeight.normal), + // ), + // child: Icon(Icons.shopping_cart)), + // color: Colors.white, + // onPressed: () { + // // Cart Click Event + // if (_onCartClick != null) _onCartClick(); + // }) : Container(), if (widget.showHomeAppBarIcon) IconButton( From a398ede172cf9d8dcbe75ad8280800bbf7aeaa21 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Mon, 4 Oct 2021 16:16:44 +0300 Subject: [PATCH 14/67] fix bugs pharmacy home --- .../parmacyModule/prescription_service.dart | 23 +- lib/core/viewModels/base_view_model.dart | 5 + .../pharmacyModule/BestSellerViewModel.dart | 5 + .../pharmacyModule/BrandViewModel.dart | 29 + .../pharmacyModule/LastVisitedViewModel.dart | 25 + .../pharmacyModule/PrescriptionViewModel.dart | 30 + .../pharmacy_module_view_model.dart | 81 +- lib/locator.dart | 9 + lib/pages/landing/landing_page_pharmcy.dart | 2 +- .../screens/pharmacy_module_page.dart | 1025 +++++++++-------- lib/widgets/others/network_base_view.dart | 17 +- 11 files changed, 652 insertions(+), 599 deletions(-) create mode 100644 lib/core/viewModels/pharmacyModule/BestSellerViewModel.dart create mode 100644 lib/core/viewModels/pharmacyModule/BrandViewModel.dart create mode 100644 lib/core/viewModels/pharmacyModule/LastVisitedViewModel.dart create mode 100644 lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart diff --git a/lib/core/service/parmacyModule/prescription_service.dart b/lib/core/service/parmacyModule/prescription_service.dart index d81c125d..6b34255b 100644 --- a/lib/core/service/parmacyModule/prescription_service.dart +++ b/lib/core/service/parmacyModule/prescription_service.dart @@ -9,36 +9,15 @@ class PrescriptionService extends BaseService { bool isFinished = true; bool hasError = false; String errorMsg = ''; - String url = ""; List _prescriptionsList = List(); List get prescriptionsList => _prescriptionsList; -// Future getPrescription() async { -// hasError = false; -// url = PRESCRIPTION; -// print("Print PRESCRIPTION url" + url); -// await baseAppClient.get(url, -// onSuccess: (dynamic response, int statusCode) { -// _prescriptionsList.clear(); -// response['PatientPrescriptionList'].forEach((item) { -// _prescriptionsList.add(Prescriptions.fromJson(item)); -// }); -// print(_prescriptionsList.length); -// print(response); -// }, onFailure: (String error, int statusCode) { -// hasError = true; -// super.error = error; -// }); -// } Future getPrescription() async { - url = PRESCRIPTION; - print("Print PRESCRIPTION url" + url); hasError = false; Map body = Map(); body['isDentalAllowedBackend'] = false; - print("Print PRESCRIPTION url" + url); - await baseAppClient.post(url, + await baseAppClient.post(PRESCRIPTION, onSuccess: (dynamic response, int statusCode) { _prescriptionsList.clear(); response['PatientPrescriptionList'].forEach((prescriptions) { diff --git a/lib/core/viewModels/base_view_model.dart b/lib/core/viewModels/base_view_model.dart index aab267e9..338fd339 100644 --- a/lib/core/viewModels/base_view_model.dart +++ b/lib/core/viewModels/base_view_model.dart @@ -15,6 +15,7 @@ class BaseViewModel extends ChangeNotifier { ViewState get state => _state; String error = ""; + String languageID = "en"; AuthenticatedUser user; AppSharedPreferences sharedPref = AppSharedPreferences(); @@ -51,6 +52,10 @@ class BaseViewModel extends ChangeNotifier { notifyListeners(); } + Future getSavedLanguage() async { + languageID = await sharedPref.getString(APP_LANGUAGE); + } + @override void dispose() { removeListener(() {}); diff --git a/lib/core/viewModels/pharmacyModule/BestSellerViewModel.dart b/lib/core/viewModels/pharmacyModule/BestSellerViewModel.dart new file mode 100644 index 00000000..8b28f7d7 --- /dev/null +++ b/lib/core/viewModels/pharmacyModule/BestSellerViewModel.dart @@ -0,0 +1,5 @@ +import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; + +class BestSellerViewModel extends BaseViewModel { + +} \ No newline at end of file diff --git a/lib/core/viewModels/pharmacyModule/BrandViewModel.dart b/lib/core/viewModels/pharmacyModule/BrandViewModel.dart new file mode 100644 index 00000000..8ffc057a --- /dev/null +++ b/lib/core/viewModels/pharmacyModule/BrandViewModel.dart @@ -0,0 +1,29 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/Manufacturer.dart'; +import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; + +import '../../../locator.dart'; + +class BrandViewModel extends BaseViewModel { + PharmacyModuleService _pharmacyService = locator(); + + List get manufacturerList => _pharmacyService.manufacturerList; + + Future getTopManufacturerList() async { + setState(ViewState.Busy); + await _pharmacyService.getTopManufacturerList(); + if (_pharmacyService.hasError) { + error = _pharmacyService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } + + @override + void dispose() { + + super.dispose(); + } +} diff --git a/lib/core/viewModels/pharmacyModule/LastVisitedViewModel.dart b/lib/core/viewModels/pharmacyModule/LastVisitedViewModel.dart new file mode 100644 index 00000000..efc628d6 --- /dev/null +++ b/lib/core/viewModels/pharmacyModule/LastVisitedViewModel.dart @@ -0,0 +1,25 @@ +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 '../../../locator.dart'; + +class LastVisitedViewModel extends BaseViewModel { + + PharmacyModuleService _pharmacyService = locator(); + + List get lastVisitedProducts => + _pharmacyService.lastVisitedProducts; + + getLastVisitedProducts() async { + setState(ViewState.Busy); + await _pharmacyService.getLastVisitedProducts(); + if (_pharmacyService.hasError) { + error = _pharmacyService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } +} \ No newline at end of file diff --git a/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart b/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart new file mode 100644 index 00000000..69caa40f --- /dev/null +++ b/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart @@ -0,0 +1,30 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/Prescriptions.dart'; +import 'package:diplomaticquarterapp/core/service/parmacyModule/prescription_service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; +import 'package:provider/provider.dart'; + +import '../../../locator.dart'; +import '../project_view_model.dart'; + +class PrescriptionViewModel extends BaseViewModel { + + PrescriptionService _prescriptionService = locator(); + + List get prescriptionsList => + _prescriptionService.prescriptionsList; + + getPrescription() async { + await getSavedLanguage(); + +/* + setState(ViewState.Busy); + await _prescriptionService.getPrescription(); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + }*/ + } +} \ No newline at end of file diff --git a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart index 072ef4c9..245841e6 100644 --- a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart @@ -19,36 +19,26 @@ class PharmacyModuleViewModel extends BaseViewModel { PharmacyModuleService _pharmacyService = locator(); - PrescriptionService _prescriptionService = locator(); - - dynamic languageID = "en"; - RecommendedProductService _recommendedProductService = locator(); List get bannerList => _pharmacyService.bannerItems; - List get manufacturerList => _pharmacyService.manufacturerList; - List get bestSellerProduct => _pharmacyService.bestSellerProducts; - List get lastVisitedProducts => - _pharmacyService.lastVisitedProducts; - List get recommendedProductList => _recommendedProductService.recommendedList; -// List> get recommendedProductList => -// _recommendedProductService.recommendedList; - - List get prescriptionsList => - _prescriptionService.prescriptionsList; - - bool hasError = false; -// List get pharmacyPrescriptionsList => PharmacyProduct.pharmacyPrescriptionsList ; - Future getLanguageID() async { - languageID = await sharedPref.getString(APP_LANGUAGE); + Future getBannerList() async { + setState(ViewState.BusyLocal); + await _pharmacyService.getBannerListList(); + if (_pharmacyService.hasError) + //{ + error = _pharmacyService.error; + // setState(ViewState.Error); + // }else + // setState(ViewState.Idle); } Future getPharmacyHomeData() async { @@ -64,11 +54,7 @@ class PharmacyModuleViewModel extends BaseViewModel { if (_pharmacyService.hasError) { error = _pharmacyService.error; setState(ViewState.Error); - } else { - await getBannerList(); } - } else { - await getBannerList(); } } @@ -82,7 +68,6 @@ class PharmacyModuleViewModel extends BaseViewModel { setState(ViewState.Idle); } } - Future generatePharmacyToken() async { setState(ViewState.Busy); await _pharmacyService.generatePharmacyToken(); @@ -94,16 +79,6 @@ class PharmacyModuleViewModel extends BaseViewModel { } } - Future getBannerList() async { - setState(ViewState.Busy); - await _pharmacyService.getBannerListList(); - if (_pharmacyService.hasError) { - error = _pharmacyService.error; - setState(ViewState.Error); - } else { - _getTopManufacturerList(); - } - } List getBannerImagesUrl() { List images = List(); @@ -115,40 +90,18 @@ class PharmacyModuleViewModel extends BaseViewModel { return images; } - _getTopManufacturerList() async { - await _pharmacyService.getTopManufacturerList(); - if (_pharmacyService.hasError) { - error = _pharmacyService.error; - setState(ViewState.Error); - } else { - setState(ViewState.Idle); - _getBestSellerProducts(); - } - } - - _getBestSellerProducts() async { + getBestSellerProducts() async { await _pharmacyService.getBestSellerProducts(); if (_pharmacyService.hasError) { error = _pharmacyService.error; setState(ViewState.Error); } else { - _getLastVisitedProducts(); } } - _getLastVisitedProducts() async { - await _pharmacyService.getLastVisitedProducts(); - if (_pharmacyService.hasError) { - error = _pharmacyService.error; - setState(ViewState.Error); - } else { - setState(ViewState.Idle); - } - } - //////////////////////////////////////////RecommendedProducts + getRecommendedProducts(productId) async { - hasError = false; setState(ViewState.Busy); await _recommendedProductService.getRecommendedProducts(productId); if (_recommendedProductService.hasError) { @@ -173,18 +126,6 @@ class PharmacyModuleViewModel extends BaseViewModel { } } - getPrescription() async { - print("Print PRESCRIPTION url"); - setState(ViewState.Busy); - await _prescriptionService.getPrescription(); - if (_prescriptionService.hasError) { - error = _prescriptionService.error; - setState(ViewState.Error); - } else { - setState(ViewState.Idle); - } - } - ///////////////////////or // getPrescriptions() async { diff --git a/lib/locator.dart b/lib/locator.dart index 92c6bf63..b855e5a7 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -120,6 +120,10 @@ import 'core/viewModels/pharmacies_view_model.dart'; import 'core/service/pharmacies_service.dart'; import 'core/service/insurance_service.dart'; import 'core/viewModels/insurance_card_View_model.dart'; +import 'core/viewModels/pharmacyModule/BestSellerViewModel.dart'; +import 'core/viewModels/pharmacyModule/BrandViewModel.dart'; +import 'core/viewModels/pharmacyModule/LastVisitedViewModel.dart'; +import 'core/viewModels/pharmacyModule/PrescriptionViewModel.dart'; import 'core/viewModels/pharmacyModule/brand_view_model.dart'; import 'core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; import 'core/viewModels/pharmacyModule/product_detail_view_model.dart'; @@ -302,6 +306,11 @@ void setupLocator() { locator.registerFactory(() => OffersCategoriseViewModel()); locator.registerFactory(() => BariatricsViewModel()); + locator.registerFactory(() => PrescriptionViewModel()); + locator.registerFactory(() => BrandViewModel()); + locator.registerFactory(() => BestSellerViewModel()); + locator.registerFactory(() => LastVisitedViewModel()); + // Offer And Packages //---------------------- locator.registerLazySingleton( diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 5da853fb..ab0abe72 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -172,7 +172,7 @@ class _LandingPagePharmacyState extends State { .getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode", onSuccess: (dynamic response, int statusCode) { print(response); - product = PharmacyProduct.fromJson(response["products"][0]); + var product = PharmacyProduct.fromJson(response["products"][0]); GifLoaderDialogUtils.hideDialog(context); Navigator.push(context, FadePage(page: ProductDetailPage(product))); }, onFailure: (String error, int statusCode) { diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index a5dc664c..d8d524e0 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -1,50 +1,46 @@ -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/model/pharmacies/recommendedProduct_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BrandViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/LastVisitedViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PrescriptionViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.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/landing/home_page.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; import 'package:diplomaticquarterapp/pages/offers_categorise_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product-brands.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/lacum-activitaion-vida-page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/lakum-main-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/recommended-product-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/BannerPager.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductTileItem.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/manufacturerItem.dart'; -import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.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/borderedButton.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'; -import 'package:flutter_svg/flutter_svg.dart'; +import 'package:provider/provider.dart'; import 'package:rating_bar/rating_bar.dart'; import '../../final_products_page.dart'; -import 'lacum-activitaion-vida-page.dart'; - -var product; class PharmacyPage extends StatefulWidget { - @override _PharmacyPageState createState() => _PharmacyPageState(); } class _PharmacyPageState extends State { - @override Widget build(BuildContext context) { return BaseView( onModelReady: (model) async { - await getLanguageID(); - await model.getPharmacyHomeData(); + // GifLoaderDialogUtils.showMyDialog(context); + await model.getSavedLanguage(); + await model.getBannerList(); + // GifLoaderDialogUtils.hideDialog(context); }, allowAny: true, builder: (_, model, wi) => AppScaffold( @@ -57,17 +53,21 @@ class _PharmacyPageState extends State { width: double.infinity, child: SingleChildScrollView( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + //crossAxisAlignment: CrossAxisAlignment.start, children: [ BannerPager(model), GridViewButtons(model), + //PrescriptionsWidget(), + ShopByBrandWidget(), + RecentlyViewedWidget(), + // TODO MOUSA Container( margin: EdgeInsets.fromLTRB(10, 10, 10, 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Texts( - TranslationBase.of(context).myPrescription, + TranslationBase.of(context).bestSellers, bold: true, ), BorderedButton( @@ -77,235 +77,533 @@ class _PharmacyPageState extends State { textColor: Colors.green, vPadding: 6, hPadding: 4, - handler: () { + handler: () => { Navigator.push( - context, FadePage(page: HomePrescriptionsPage())); + context, + FadePage( + page: FinalProductsPage( + id: "", + //TODO Elham* handel this to understans form where the number comming + productType: 20, + ), + ), + ), }, ), ], ), ), Container( - height: model.prescriptionsList.length > 0 - ? MediaQuery.of(context).size.height * 0.28 - : 0, - padding: - EdgeInsets.symmetric(horizontal: 18.0, vertical: 14.0), -// height: MediaQuery.of(context).size.height * 0.28, -// width: 200.0, -// height: MediaQuery.of(context).size.height / 4 + 20, - margin: EdgeInsets.only(left: 10), - child: BaseView( - onModelReady: (model) => model.getPrescription(), - builder: (_, model, wi) => model.prescriptionsList.length != - 0 -// model.getPrescription(); - ? ListView.builder( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - physics: ScrollPhysics(), - // physics: NeverScrollableScrollPhysics(), - itemCount: model.prescriptionsList.length, - itemBuilder: (context, index) { - return Container( -// width: 160.0, - height: - MediaQuery.of(context).size.height * 0.3, - padding: EdgeInsets.only( - bottom: 5.0, left: 5.0, right: 8.0), - margin: EdgeInsets.only(right: 10.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, + height: MediaQuery.of(context).size.height / 4 + 20, + child: ListView.builder( + itemBuilder: (ctx, i) => + ProductTileItem(model.bestSellerProduct[i]), + scrollDirection: Axis.horizontal, + itemCount: model.bestSellerProduct.length, + ), + ), + ], + ), + ), + ), + ), + ); + } +} + +class GridViewButtons extends StatelessWidget { + final PharmacyModuleViewModel model; + + GridViewButtons(this.model); + + @override + Widget build(BuildContext context) { + final gridHeight = (MediaQuery.of(context).size.width * 0.3) * 1.8; + return Container( + child: SizedBox( + height: gridHeight, + child: GridView.count( + childAspectRatio: 2.2, + crossAxisSpacing: 10, + mainAxisSpacing: 10, + controller: new ScrollController(keepScrollOffset: false), + shrinkWrap: true, + padding: const EdgeInsets.all(4.0), + crossAxisCount: 2, + children: [ + DashboardItem( + imageName: 'pharmacy_module/bg_1.png', + hasColorFilter: false, + opacity: 0.8, + child: GridViewCard( + TranslationBase.of(context).offersAndPromotions, + 'assets/images/pharmacy_module/offer_icon.png', () { + Navigator.push(context, FadePage(page: OffersCategorisePage())); + }), + ), + DashboardItem( + imageName: 'pharmacy_module/bg_2.png', + opacity: 0, + hasColorFilter: false, + child: GridViewCard(TranslationBase.of(context).medicationRefill, + 'assets/images/pharmacy_module/medication_icon.png', () { + // model.checkUserIsActivated().then((isActivated) { + // if (isActivated) { + // Navigator.push(context, FadePage(page: LakumMainPage())); + // } else { + // Navigator.push( + // context, FadePage(page: LakumActivationVidaPage())); + // } + // }); + }), + ), + DashboardItem( + imageName: 'pharmacy_module/bg_3.png', + opacity: 0, + hasColorFilter: false, + child: GridViewCard(TranslationBase.of(context).myPrescriptions, + 'assets/images/pharmacy_module/prescription_icon.png', () { + Navigator.push( + context, FadePage(page: HomePrescriptionsPage())); + }), + ), + DashboardItem( + imageName: 'pharmacy_module/bg_4.png', + opacity: 0, + hasColorFilter: false, + child: GridViewCard( + TranslationBase.of(context).searchAndScanMedication, + 'assets/images/pharmacy_module/search_scan_icon.png', + () {}), + ), + ], + ), + ), + ); + } +} + +class GridViewCard extends StatelessWidget { + final String text; + final String cardImage; + final Function handler; + + GridViewCard(this.text, this.cardImage, this.handler); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(4.0), + child: Container( + child: Row( + children: [ + Expanded( + flex: 2, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + flex: 2, + child: Padding( + padding: const EdgeInsets.all(6), + child: Texts( + text, + color: Colors.white, + fontSize: SizeConfig.textMultiplier * 1.5, + ), + ), + ), + Row( + children: [ + BorderedButton( + TranslationBase.of(context).viewAll, + handler: handler, + tPadding: 0, + bPadding: 0, + ), + Expanded(child: Container()), + ], + ), + ], + ), + ), + Expanded( + child: Align( + alignment: Alignment.centerRight, + child: Image.asset( + cardImage, + fit: BoxFit.cover, + ), + ), + ), + ], + ), + ), + ); + } + + String getDate(String date) { + DateTime dateObj = DateUtil.convertStringToDate(date); + return DateUtil.getWeekDay(dateObj.weekday) + + ", " + + dateObj.day.toString() + + " " + + DateUtil.getMonth(dateObj.month) + + " " + + dateObj.year.toString(); + } +} + +class PrescriptionsWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) async { + if (Provider.of(context, listen: false).isLogin) { + model.getPrescription(); + } + }, + allowAny: true, + builder: (_, model, wi) => model.prescriptionsList.length != 0 + ? Container( + height: model.prescriptionsList.length > 0 + ? MediaQuery.of(context).size.height * 0.28 + : 0, + child: Column( + children: [ + Container( + margin: EdgeInsets.fromLTRB(10, 10, 10, 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).myPrescription, + bold: true, + ), + BorderedButton( + TranslationBase.of(context).viewAll, + hasBorder: true, + borderColor: Colors.green, + textColor: Colors.green, + vPadding: 6, + hPadding: 4, + handler: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + HomePrescriptionsPage())); + }, + ), + ], + ), + ), + Container( + padding: + EdgeInsets.symmetric(horizontal: 18.0, vertical: 14.0), + margin: EdgeInsets.only(left: 10), + child: ListView.builder( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + physics: ScrollPhysics(), + // physics: NeverScrollableScrollPhysics(), + itemCount: model.prescriptionsList.length, + itemBuilder: (context, index) { + return Container( + height: MediaQuery.of(context).size.height * 0.3, + padding: EdgeInsets.only( + bottom: 5.0, left: 5.0, right: 8.0), + margin: EdgeInsets.only(right: 10.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: [ - Row( - children: [ - Column(children: [ - Container( - padding: EdgeInsets.only( - top: 10.0, - left: 10.0, - right: 10.0, - bottom: 15.0, - ), - child: CircleAvatar( - radius: 30, - backgroundColor: - Colors.transparent, - child: Image.network( - model.prescriptionsList[index] - .doctorImageURL, - width: 60, - height: 60, - ), - ), + Column(children: [ + Container( + padding: EdgeInsets.only( + top: 10.0, + left: 10.0, + right: 10.0, + bottom: 15.0, + ), + child: CircleAvatar( + radius: 30, + backgroundColor: Colors.transparent, + child: Image.network( + model.prescriptionsList[index] + .doctorImageURL, + width: 60, + height: 60, ), - ]), -// Column( -// // crossAxisAlignment: CrossAxisAlignment.center, -// children: [ -// Container( -// margin: EdgeInsets.only(left: 1), -// padding: EdgeInsets.only( -// top: 10.0, -// left: 10.0, -// right: 3.0, -// bottom: 15.0, -// ), -// child: Image.network( -// model.prescriptionsList[index] -// .doctorImageURL, -// width: 60, -// height: 60, -// ), -// ), -// ]), - Column( -// crossAxisAlignment: CrossAxisAlignment.center, - 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: 4.0, - ), - 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, -// fontWeight: FontWeight.bold, - ), - )), - 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, -// fontWeight: FontWeight.bold, - ), - ) - ]), - ], ), - ], - ), - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ + ), + ]), + Column( + 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, - ), - ), - Text( - model.prescriptionsList[index] - .doctorName - .toString(), + 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: 4.0, + ), + 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, - fontWeight: FontWeight.bold, ), - ), - ]), - ), - ], - ), - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.only(left: 5), - child: Text( - model.prescriptionsList[index] - .clinicDescription - .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.green, + color: Colors.black, fontSize: 15.0, -// fontWeight: FontWeight.bold, ), + ) + ]), + ], + ), + ], + ), + 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, ), ), - ], + Text( + model.prescriptionsList[index] + .doctorName + .toString(), + style: TextStyle( + color: Colors.black, + 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(), + ], + ), + 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, - ), - ), - ) - ]), - ]), - ); - }) - : Container(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), + ), + ) + ]), + ]), + ); + }), ), + ], + ), + ) + : Container(), + ); + } +} + +class ShopByBrandWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getTopManufacturerList(), + allowAny: true, + builder: (_, model, wi) => NetworkBaseView( + isLocalLoader: true, + baseViewModel: model, + child: Container( + child: Column( + children: [ + Container( + margin: EdgeInsets.fromLTRB(10, 10, 10, 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).shopByBrands, + bold: true, + ), + BorderedButton( + TranslationBase.of(context).viewAll, + hasBorder: true, + vPadding: 6, + hPadding: 4, + borderColor: Colors.green, + textColor: Colors.green, + handler: () => { + Navigator.push( + context, FadePage(page: ProductBrandsPage())), + }, + ), + ], + ), + ), + Container( + height: 100, + child: ListView.builder( + itemBuilder: (ctx, i) => + ManufacturerItem(model.manufacturerList[i]), + scrollDirection: Axis.horizontal, + itemCount: model.manufacturerList.length, + ), + ), + ], ), + ), + )); + } +} + +class RecentlyViewedWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getLastVisitedProducts(), + allowAny: true, + builder: (_, model, wi) => NetworkBaseView( + isLocalLoader: true, + baseViewModel: model, + child: Container( + child: Column( + children: [ + Container( + margin: EdgeInsets.fromLTRB(10, 10, 10, 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).recentlyViewed, + bold: true, + ), + BorderedButton( + TranslationBase.of(context).viewAll, + hasBorder: true, + vPadding: 6, + hPadding: 4, + borderColor: Colors.green, + textColor: Colors.green, + handler: () { + Navigator.push( + context, + FadePage( + page: FinalProductsPage( + id: "", + productType: 3, + ), + ), + ); + }, + ), + ], + ), + ), + Container( + height: model.lastVisitedProducts.length > 0 + ? MediaQuery.of(context).size.height / 4 + 20 + : 0, + child: ListView.builder( + itemBuilder: (ctx, i) => + ProductTileItem(model.lastVisitedProducts[i]), + scrollDirection: Axis.horizontal, + itemCount: model.lastVisitedProducts.length, + ), + ), + ], + ), + ), + )); + } +} + // Container( // margin: EdgeInsets.fromLTRB(10, 10, 10, 10), // child: Row( @@ -538,284 +836,3 @@ class _PharmacyPageState extends State { // ), // ), // ), - Container( - margin: EdgeInsets.fromLTRB(10, 10, 10, 0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).shopByBrands, - bold: true, - ), - BorderedButton( - TranslationBase.of(context).viewAll, - hasBorder: true, - vPadding: 6, - hPadding: 4, - borderColor: Colors.green, - textColor: Colors.green, - handler: () => { - Navigator.push( - context, FadePage(page: ProductBrandsPage())), - }, - ), - ], - ), - ), - Container( - height: 100, - child: ListView.builder( - itemBuilder: (ctx, i) => - ManufacturerItem(model.manufacturerList[i]), - scrollDirection: Axis.horizontal, - itemCount: model.manufacturerList.length, - ), - ), - Container( - margin: EdgeInsets.fromLTRB(10, 10, 10, 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).recentlyViewed, - bold: true, - ), - BorderedButton( - TranslationBase.of(context).viewAll, - hasBorder: true, - vPadding: 6, - hPadding: 4, - borderColor: Colors.green, - textColor: Colors.green, - handler: () { - Navigator.push( - context, - FadePage( - page: FinalProductsPage( - id: "", - productType: 3, - ), - ), - ); - }, - ), - ], - ), - ), - Container( - height: model.lastVisitedProducts.length > 0 - ? MediaQuery.of(context).size.height / 4 + 20 - : 0, - child: ListView.builder( - itemBuilder: (ctx, i) => - ProductTileItem(model.lastVisitedProducts[i]), - scrollDirection: Axis.horizontal, - itemCount: model.lastVisitedProducts.length, - ), - ), - Container( - margin: EdgeInsets.fromLTRB(10, 10, 10, 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).bestSellers, - bold: true, - ), - BorderedButton( - TranslationBase.of(context).viewAll, - hasBorder: true, - borderColor: Colors.green, - textColor: Colors.green, - vPadding: 6, - hPadding: 4, - handler: () => { - Navigator.push( - context, - FadePage( - page: FinalProductsPage( - id: "", - //TODO Elham* handel this to understans form where the number comming - productType: 20, - ), - ), - ), - }, - ), - ], - ), - ), - Container( - height: MediaQuery.of(context).size.height / 4 + 20, - child: ListView.builder( - itemBuilder: (ctx, i) => - ProductTileItem(model.bestSellerProduct[i]), - scrollDirection: Axis.horizontal, - itemCount: model.bestSellerProduct.length, - ), - ), - ], - ), - ), - ), - ), - ); - } - - addToWishlistFunction(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - isInWishlist = true; - await x.addToWishlistData(itemID); - } - - deleteFromWishlistFunction(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - isInWishlist = false; - await x.addToWishlistData(itemID); - } - -} - -class GridViewButtons extends StatelessWidget { - final PharmacyModuleViewModel model; - - GridViewButtons(this.model); - - @override - Widget build(BuildContext context) { - final gridHeight = (MediaQuery.of(context).size.width * 0.3) * 1.8; - return Container( - child: SizedBox( - height: gridHeight, - child: GridView.count( - childAspectRatio: 2.2, - crossAxisSpacing: 10, - mainAxisSpacing: 10, - controller: new ScrollController(keepScrollOffset: false), - shrinkWrap: true, - padding: const EdgeInsets.all(4.0), - crossAxisCount: 2, - children: [ - DashboardItem( - imageName: 'pharmacy_module/bg_1.png', - hasColorFilter: false, - opacity: 0.8, - child: GridViewCard( - TranslationBase.of(context).offersAndPromotions, - 'assets/images/pharmacy_module/offer_icon.png', () { - Navigator.push(context, FadePage(page: OffersCategorisePage())); - }), - ), - DashboardItem( - imageName: 'pharmacy_module/bg_2.png', - opacity: 0, - hasColorFilter: false, - child: GridViewCard(TranslationBase.of(context).medicationRefill, - 'assets/images/pharmacy_module/medication_icon.png', () { - model.checkUserIsActivated().then((isActivated) { - if (isActivated) { - Navigator.push(context, FadePage(page: LakumMainPage())); - } else { - Navigator.push( - context, FadePage(page: LakumActivationVidaPage())); - } - }); - }), - ), - DashboardItem( - imageName: 'pharmacy_module/bg_3.png', - opacity: 0, - hasColorFilter: false, - child: GridViewCard(TranslationBase.of(context).myPrescriptions, - 'assets/images/pharmacy_module/prescription_icon.png', () { - Navigator.push( - context, FadePage(page: PharmacyAddressesPage())); - }), - ), - DashboardItem( - imageName: 'pharmacy_module/bg_4.png', - opacity: 0, - hasColorFilter: false, - child: GridViewCard( - TranslationBase.of(context).searchAndScanMedication, - 'assets/images/pharmacy_module/search_scan_icon.png', - () {}), - ), - ], - ), - ), - ); - } -} - -class GridViewCard extends StatelessWidget { - final String text; - final String cardImage; - final Function handler; - - GridViewCard(this.text, this.cardImage, this.handler); - - @override - Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.all(4.0), - child: Container( - child: Row( - children: [ - Expanded( - flex: 2, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 2, - child: Padding( - padding: const EdgeInsets.all(6), - child: Texts( - text, - color: Colors.white, - fontSize: SizeConfig.textMultiplier * 1.5, - ), - ), - ), - Row( - children: [ - BorderedButton( - TranslationBase.of(context).viewAll, - handler: handler, - tPadding: 0, - bPadding: 0, - ), - Expanded(child: Container()), - ], - ), - ], - ), - ), - Expanded( - child: Align( - alignment: Alignment.centerRight, - child: Image.asset( - cardImage, - fit: BoxFit.cover, - ), - ), - ), - ], - ), - ), - ); - } - - String getDate(String date) { - DateTime dateObj = DateUtil.convertStringToDate(date); - return DateUtil.getWeekDay(dateObj.weekday) + - ", " + - dateObj.day.toString() + - " " + - DateUtil.getMonth(dateObj.month) + - " " + - dateObj.year.toString(); - } -} \ No newline at end of file diff --git a/lib/widgets/others/network_base_view.dart b/lib/widgets/others/network_base_view.dart index bca942f4..7b4918bd 100644 --- a/lib/widgets/others/network_base_view.dart +++ b/lib/widgets/others/network_base_view.dart @@ -9,8 +9,9 @@ import 'package:flutter_gifimage/flutter_gifimage.dart'; class NetworkBaseView extends StatefulWidget { final BaseViewModel baseViewModel; final Widget child; + final bool isLocalLoader; - NetworkBaseView({Key key, this.baseViewModel, this.child}); + NetworkBaseView({Key key, this.baseViewModel, this.child, this.isLocalLoader = false}); @override _NetworkBaseViewState createState() => _NetworkBaseViewState(); @@ -42,7 +43,19 @@ class _NetworkBaseViewState extends State{ return widget.child; break; case ViewState.Busy: - return Container( + if(widget.isLocalLoader) + return Container( + height: 100, + child: Center( + child:CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.red, + ), + ), + ), + ); + else return Container( height: MediaQuery.of(context).size.height, child: Stack( From 43e7bb9ff3a261ad6535e43c0c196d10e4d2601d Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Mon, 4 Oct 2021 16:18:47 +0300 Subject: [PATCH 15/67] fix bottom navigation bar --- lib/pages/landing/landing_page_pharmcy.dart | 38 +------------------ lib/pages/pharmacy/profile/profile.dart | 2 +- .../pharmacy_services/wishList_service.dart | 5 ++- .../pharmacy/bottom_nav_pharmacy_bar.dart | 33 +--------------- .../pharmacy/bottom_nav_pharmacy_item.dart | 15 +++++++- 5 files changed, 22 insertions(+), 71 deletions(-) diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 5da853fb..cb886f2d 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -110,35 +110,6 @@ class _LandingPagePharmacyState extends State { centerTitle: true, ) : null, - // : AppBar( - // backgroundColor: Color(0xff5AB145), - // elevation: 0, - // textTheme: TextTheme( - // headline6: TextStyle( - // color: Colors.white, fontWeight: FontWeight.bold), - // ), - // title: Text(getText(currentTab).toUpperCase()), - // leading: Builder( - // builder: (BuildContext context) { - // return IconButton( - // icon: Icon(Icons.arrow_back), - // color: Colors.white, - // onPressed: () => Scaffold.of(context).openDrawer(), - // ); - // }, - // ), - // actions: [ - // // IconButton( - // // iconSize: 70, - // // icon: SvgPicture.asset('assets/images/svg/robort_svg.svg', - // // height: 100, width: 100, fit: BoxFit.cover), - // // onPressed: () { - // // triggerRobot(); - // // } //do something, - // // ) - // ], - // centerTitle: true, - // ), extendBody: false, body: PageView( physics: NeverScrollableScrollPhysics(), @@ -146,14 +117,9 @@ class _LandingPagePharmacyState extends State { children: [ PharmacyPage(), PharmacyCategorisePage(), -// OffersCategorisePage(), - WishlistPage(false), PharmacyProfilePage(), -// Container( -// child: Text('text'), -// ), CartOrderPage(), - ], // Please do not remove the BookingOptions from this array + ], ), bottomNavigationBar: BottomNavPharmacyBar( changeIndex: _changeCurrentTab, @@ -172,7 +138,7 @@ class _LandingPagePharmacyState extends State { .getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode", onSuccess: (dynamic response, int statusCode) { print(response); - product = PharmacyProduct.fromJson(response["products"][0]); + var product = PharmacyProduct.fromJson(response["products"][0]); GifLoaderDialogUtils.hideDialog(context); Navigator.push(context, FadePage(page: ProductDetailPage(product))); }, onFailure: (String error, int statusCode) { diff --git a/lib/pages/pharmacy/profile/profile.dart b/lib/pages/pharmacy/profile/profile.dart index 918e9668..3cf28592 100644 --- a/lib/pages/pharmacy/profile/profile.dart +++ b/lib/pages/pharmacy/profile/profile.dart @@ -93,7 +93,7 @@ class _ProfilePageState extends State { }, builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).myAccount, - isShowAppBar: true, + isShowAppBar: false, isShowDecPage: false, isPharmacy: true, body: user != null diff --git a/lib/services/pharmacy_services/wishList_service.dart b/lib/services/pharmacy_services/wishList_service.dart index 5404a2bd..fb99e038 100644 --- a/lib/services/pharmacy_services/wishList_service.dart +++ b/lib/services/pharmacy_services/wishList_service.dart @@ -55,9 +55,10 @@ class WishListService extends BaseService { // } Future getWishlist() async { - var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); + //TODO we need to check why the customer id comes null + String customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID)?? "0"; hasError = false; - await baseAppClient.getPharmacy(GET_WISHLIST+customerId+"?shopping_cart_type=2", + await baseAppClient.getPharmacy(GET_WISHLIST+customerId +"?shopping_cart_type=2", onSuccess: (dynamic response, int statusCode) { _wishListProducts.clear(); response['shopping_carts'].forEach((item) { diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart index 237b4cae..ef861c56 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart @@ -17,7 +17,6 @@ class BottomNavPharmacyBar extends StatefulWidget { } class _BottomNavPharmacyBarState extends State { - int _index = 0; _changeIndex(int index) { widget.changeIndex(index); @@ -43,19 +42,6 @@ class _BottomNavPharmacyBarState extends State { currentIndex: 0, title: TranslationBase.of(context).Alhabibapp, ), - - // Container( - // height: 65.0, - // child: Center( - // child: VerticalDivider( - // color: Colors.grey, - // thickness: 0.5, - // width: 0.3, - // indent: 25.5, - // ), - // ), - // ), - BottomNavPharmacyItem( icon: EvaIcons.list, activeIcon: EvaIcons.list, @@ -64,20 +50,6 @@ class _BottomNavPharmacyBarState extends State { currentIndex: 1, title: TranslationBase.of(context).categorise, ), -// Expanded( -// child: SizedBox( -// height: 50, -// child: Column( -// mainAxisSize: MainAxisSize.min, -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// SizedBox(height: 22), -// ], -// ), -// ), -// ), - - // Added Calendar Icon to access book appointment flow BottomNavPharmacyItem( icon: EvaIcons.home, activeIcon: EvaIcons.home, @@ -86,13 +58,12 @@ class _BottomNavPharmacyBarState extends State { currentIndex: 0, isHome: true, title: TranslationBase.of(context).home), - BottomNavPharmacyItem( icon: EvaIcons.person, activeIcon: EvaIcons.person, changeIndex: _changeIndex, index: widget.index, - currentIndex: 3, + currentIndex: 2, title: TranslationBase.of(context).myAccount, ), BottomNavPharmacyItem( @@ -100,7 +71,7 @@ class _BottomNavPharmacyBarState extends State { activeIcon: EvaIcons.shoppingCartOutline, changeIndex: _changeIndex, index: widget.index, - currentIndex: 4, + currentIndex: 3, title: TranslationBase.of(context).cart) ], ), diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart index bff756f1..f31fa588 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart @@ -1,6 +1,10 @@ import 'package:diplomaticquarterapp/Constants.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/pages/login/welcome.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; class BottomNavPharmacyItem extends StatelessWidget { final String title; @@ -33,7 +37,16 @@ class BottomNavPharmacyItem extends StatelessWidget { child: InkWell( highlightColor: Colors.transparent, splashColor: Colors.transparent, - onTap: () => changeIndex(currentIndex), + onTap: () { + if(!Provider.of(context, listen: false).isLogin && (currentIndex == 2|| currentIndex == 3)) + Navigator.push( + context, + FadePage(page: WelcomeLogin()), + ); + else + changeIndex(currentIndex); + + }, child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, From 9a2d52309cf747cc498f560198754a79667c3177 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 4 Oct 2021 16:50:31 +0300 Subject: [PATCH 16/67] products categories page fix --- lib/pages/final_products_page.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index f4bd8b77..c2dd64b9 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -49,7 +49,6 @@ class _FinalProductsPageState extends State { Widget build(BuildContext context) { return BaseView( onModelReady: (model) { - //TODO Elham* fix all services in order handel errors in better way in the service if (widget.productType == 1) { model.getFinalProducts(i: id); @@ -78,7 +77,7 @@ class _FinalProductsPageState extends State { isBottomBar: false, isShowAppBar: true, backgroundColor: Colors.white, - isShowDecPage: true, + isShowDecPage: false, baseViewModel: model, body: Container( height: MediaQuery.of(context).size.height * 5.87, From fdb61c78c5743b96fdc3dd1dfbb723886bae63b6 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Mon, 4 Oct 2021 17:16:46 +0300 Subject: [PATCH 17/67] fix bugs pharmacy home --- .../pharmacyModule/BestSellerViewModel.dart | 21 + .../pharmacyModule/PrescriptionViewModel.dart | 9 +- .../pharmacy_module_view_model.dart | 48 +- lib/main.dart | 2 + .../screens/pharmacy_module_page.dart | 512 ++++++++++-------- lib/widgets/others/network_base_view.dart | 2 +- 6 files changed, 312 insertions(+), 282 deletions(-) diff --git a/lib/core/viewModels/pharmacyModule/BestSellerViewModel.dart b/lib/core/viewModels/pharmacyModule/BestSellerViewModel.dart index 8b28f7d7..f530999b 100644 --- a/lib/core/viewModels/pharmacyModule/BestSellerViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/BestSellerViewModel.dart @@ -1,5 +1,26 @@ +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 '../../../locator.dart'; + class BestSellerViewModel extends BaseViewModel { + PharmacyModuleService _pharmacyService = locator(); + + List get bestSellerProduct => + _pharmacyService.bestSellerProducts; + + getBestSellerProducts() async { + setState(ViewState.Busy); + await _pharmacyService.getBestSellerProducts(); + if (_pharmacyService.hasError) { + error = _pharmacyService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } + } \ No newline at end of file diff --git a/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart b/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart index 69caa40f..45fc8000 100644 --- a/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart @@ -2,10 +2,8 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/Prescriptions.dart'; import 'package:diplomaticquarterapp/core/service/parmacyModule/prescription_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; -import 'package:provider/provider.dart'; import '../../../locator.dart'; -import '../project_view_model.dart'; class PrescriptionViewModel extends BaseViewModel { @@ -15,16 +13,15 @@ class PrescriptionViewModel extends BaseViewModel { _prescriptionService.prescriptionsList; getPrescription() async { - await getSavedLanguage(); - -/* setState(ViewState.Busy); + await getSavedLanguage(); await _prescriptionService.getPrescription(); if (_prescriptionService.hasError) { error = _prescriptionService.error; setState(ViewState.Error); } else { setState(ViewState.Idle); - }*/ + } + } } \ No newline at end of file diff --git a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart index 245841e6..7bcb8f91 100644 --- a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart @@ -11,6 +11,8 @@ import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_s import 'package:diplomaticquarterapp/core/service/parmacyModule/prescription_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/recommendedProduct_service.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import '../../../locator.dart'; @@ -23,21 +25,23 @@ class PharmacyModuleViewModel extends BaseViewModel { List get bannerList => _pharmacyService.bannerItems; - List get bestSellerProduct => - _pharmacyService.bestSellerProducts; - List get recommendedProductList => _recommendedProductService.recommendedList; Future getBannerList() async { - setState(ViewState.BusyLocal); + _pharmacyService.bannerItems.clear(); + // setState(ViewState.BusyLocal); + GifLoaderDialogUtils.showMyDialog( + locator().navigatorKey.currentContext); await _pharmacyService.getBannerListList(); - if (_pharmacyService.hasError) - //{ - error = _pharmacyService.error; - // setState(ViewState.Error); - // }else + GifLoaderDialogUtils.hideDialog( + locator().navigatorKey.currentContext); + // if (_pharmacyService.hasError) + // { + // error = _pharmacyService.error; + // setState(ViewState.Error); + // } else // setState(ViewState.Idle); } @@ -90,17 +94,6 @@ class PharmacyModuleViewModel extends BaseViewModel { return images; } - getBestSellerProducts() async { - await _pharmacyService.getBestSellerProducts(); - if (_pharmacyService.hasError) { - error = _pharmacyService.error; - setState(ViewState.Error); - } else { - } - } - - - getRecommendedProducts(productId) async { setState(ViewState.Busy); await _recommendedProductService.getRecommendedProducts(productId); @@ -126,19 +119,4 @@ class PharmacyModuleViewModel extends BaseViewModel { } } - - ///////////////////////or -// getPrescriptions() async { -// setState(ViewState.Busy); -// await _prescriptionsService.getPrescriptions(); -// if (_prescriptionsService.hasError) { -// error = _prescriptionsService.error; -// setState(ViewState.Error); -// } else { -// _filterList(); -// await _getPrescriptionsOrders(); -// setState(ViewState.Idle); -// } -// } - } diff --git a/lib/main.dart b/lib/main.dart index 2f1e465f..dda4d57a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -7,6 +7,7 @@ import 'package:diplomaticquarterapp/services/robo_search/search_provider.dart'; import 'package:diplomaticquarterapp/theme/theme_value.dart'; import 'package:diplomaticquarterapp/uitl/LocalNotification.dart'; import 'package:diplomaticquarterapp/uitl/PlatformBridge.dart'; +import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; @@ -84,6 +85,7 @@ class _MyApp extends State { navigatorObservers: [ GAnalytics.shared.navObserver() ], + navigatorKey: locator().navigatorKey, showSemanticsDebugger: false, title: 'Diplomatic Quarter App', locale: projectProvider.appLocal, diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index d8d524e0..3ec3143d 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -1,4 +1,6 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BestSellerViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BrandViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/LastVisitedViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PrescriptionViewModel.dart'; @@ -35,9 +37,10 @@ class PharmacyPage extends StatefulWidget { class _PharmacyPageState extends State { @override Widget build(BuildContext context) { + return BaseView( onModelReady: (model) async { - // GifLoaderDialogUtils.showMyDialog(context); + // GifLoaderDialogUtils.showMyDialog(context); await model.getSavedLanguage(); await model.getBannerList(); // GifLoaderDialogUtils.hideDialog(context); @@ -49,7 +52,7 @@ class _PharmacyPageState extends State { isShowDecPage: false, baseViewModel: model, backgroundColor: Colors.white, - body: Container( + body: model.state != ViewState.BusyLocal ? Container( width: double.infinity, child: SingleChildScrollView( child: Column( @@ -57,54 +60,16 @@ class _PharmacyPageState extends State { children: [ BannerPager(model), GridViewButtons(model), - //PrescriptionsWidget(), + PrescriptionsWidget(), ShopByBrandWidget(), RecentlyViewedWidget(), - // TODO MOUSA - Container( - margin: EdgeInsets.fromLTRB(10, 10, 10, 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).bestSellers, - bold: true, - ), - BorderedButton( - TranslationBase.of(context).viewAll, - hasBorder: true, - borderColor: Colors.green, - textColor: Colors.green, - vPadding: 6, - hPadding: 4, - handler: () => { - Navigator.push( - context, - FadePage( - page: FinalProductsPage( - id: "", - //TODO Elham* handel this to understans form where the number comming - productType: 20, - ), - ), - ), - }, - ), - ], - ), - ), - Container( - height: MediaQuery.of(context).size.height / 4 + 20, - child: ListView.builder( - itemBuilder: (ctx, i) => - ProductTileItem(model.bestSellerProduct[i]), - scrollDirection: Axis.horizontal, - itemCount: model.bestSellerProduct.length, - ), - ), + BestSellerWidget(), ], ), ), + ) : Container( + height: 200, + color: Colors.red, ), ), ); @@ -265,225 +230,233 @@ class PrescriptionsWidget extends StatelessWidget { } }, allowAny: true, - builder: (_, model, wi) => model.prescriptionsList.length != 0 - ? Container( - height: model.prescriptionsList.length > 0 - ? MediaQuery.of(context).size.height * 0.28 - : 0, - child: Column( - children: [ - Container( - margin: EdgeInsets.fromLTRB(10, 10, 10, 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).myPrescription, - bold: true, - ), - BorderedButton( - TranslationBase.of(context).viewAll, - hasBorder: true, - borderColor: Colors.green, - textColor: Colors.green, - vPadding: 6, - hPadding: 4, - handler: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - HomePrescriptionsPage())); - }, - ), - ], + builder: (_, model, wi) => model.prescriptionsList.length > 0 + ? NetworkBaseView( + isLocalLoader: true, + baseViewModel: model, + child: Container( + height: model.prescriptionsList.length > 0 + ? MediaQuery.of(context).size.height * 0.28 + : 0, + child: Column( + children: [ + Container( + margin: EdgeInsets.fromLTRB(10, 10, 10, 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).myPrescription, + bold: true, + ), + BorderedButton( + TranslationBase.of(context).viewAll, + hasBorder: true, + borderColor: Colors.green, + textColor: Colors.green, + vPadding: 6, + hPadding: 4, + handler: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + HomePrescriptionsPage())); + }, + ), + ], + ), ), - ), - Container( - padding: - EdgeInsets.symmetric(horizontal: 18.0, vertical: 14.0), - margin: EdgeInsets.only(left: 10), - child: ListView.builder( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - physics: ScrollPhysics(), - // physics: NeverScrollableScrollPhysics(), - itemCount: model.prescriptionsList.length, - itemBuilder: (context, index) { - return Container( - height: MediaQuery.of(context).size.height * 0.3, - padding: EdgeInsets.only( - bottom: 5.0, left: 5.0, right: 8.0), - margin: EdgeInsets.only(right: 10.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: [ - Column(children: [ - Container( - padding: EdgeInsets.only( - top: 10.0, - left: 10.0, - right: 10.0, - bottom: 15.0, - ), - child: CircleAvatar( - radius: 30, - backgroundColor: Colors.transparent, - child: Image.network( - model.prescriptionsList[index] - .doctorImageURL, - width: 60, - height: 60, + Container( + padding: EdgeInsets.symmetric( + horizontal: 18.0, vertical: 14.0), + margin: EdgeInsets.only(left: 10), + child: ListView.builder( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + physics: ScrollPhysics(), + // physics: NeverScrollableScrollPhysics(), + itemCount: model.prescriptionsList.length, + itemBuilder: (context, index) { + return Container( + height: MediaQuery.of(context).size.height * 0.3, + padding: EdgeInsets.only( + bottom: 5.0, left: 5.0, right: 8.0), + margin: EdgeInsets.only(right: 10.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: [ + Column(children: [ + Container( + padding: EdgeInsets.only( + top: 10.0, + left: 10.0, + right: 10.0, + bottom: 15.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( + ]), + 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: 4.0, + ), color: Colors.green, - style: BorderStyle.solid, - width: 4.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, + ) + ]), + ], + ), + ], + ), + 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, + ), ), Text( - DateUtil.convertStringToDate(model - .prescriptionsList[index] - .appointmentDate - .toString()) - .toString() - .substring(0, 10), + model.prescriptionsList[index] + .doctorName + .toString(), style: TextStyle( color: Colors.black, fontSize: 15.0, + fontWeight: FontWeight.bold, ), - ) - ]), - ], - ), - ], - ), - 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, ), - ), - Text( + ]), + ), + ], + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(left: 5), + child: Text( model.prescriptionsList[index] - .doctorName + .clinicDescription .toString(), style: TextStyle( - color: Colors.black, + color: Colors.green, 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(), + ], + ), + 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, + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), ), - ), - ) - ]), - ]), - ); - }), - ), - ], + ) + ]), + ]), + ); + }), + ), + ], + ), ), ) : Container(), @@ -604,6 +577,65 @@ class RecentlyViewedWidget extends StatelessWidget { } } +class BestSellerWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getBestSellerProducts(), + allowAny: true, + builder: (_, model, wi) => NetworkBaseView( + isLocalLoader: true, + baseViewModel: model, + child: Container( + child: Column( + children: [ + Container( + margin: EdgeInsets.fromLTRB(10, 10, 10, 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).bestSellers, + bold: true, + ), + BorderedButton( + TranslationBase.of(context).viewAll, + hasBorder: true, + borderColor: Colors.green, + textColor: Colors.green, + vPadding: 6, + hPadding: 4, + handler: () => { + Navigator.push( + context, + FadePage( + page: FinalProductsPage( + id: "", + productType: 20, + ), + ), + ), + }, + ), + ], + ), + ), + Container( + height: MediaQuery.of(context).size.height / 4 + 20, + child: ListView.builder( + itemBuilder: (ctx, i) => + ProductTileItem(model.bestSellerProduct[i]), + scrollDirection: Axis.horizontal, + itemCount: model.bestSellerProduct.length, + ), + ), + ], + ), + ), + )); + } +} + // Container( // margin: EdgeInsets.fromLTRB(10, 10, 10, 10), // child: Row( diff --git a/lib/widgets/others/network_base_view.dart b/lib/widgets/others/network_base_view.dart index 7b4918bd..10b4da12 100644 --- a/lib/widgets/others/network_base_view.dart +++ b/lib/widgets/others/network_base_view.dart @@ -50,7 +50,7 @@ class _NetworkBaseViewState extends State{ child:CircularProgressIndicator( backgroundColor: Colors.white, valueColor: AlwaysStoppedAnimation( - Colors.red, + Colors.grey[500], ), ), ), From 2839af658a225a01a40c056714e152f10b0d238f Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 4 Oct 2021 18:03:06 +0300 Subject: [PATCH 18/67] fix issues --- .../product-details/availability_info.dart | 167 ++++++++---------- .../product-details/product-detail.dart | 164 ++++++++++++++--- .../screens/product-details/reviews_info.dart | 140 ++++++++------- 3 files changed, 281 insertions(+), 190 deletions(-) diff --git a/lib/pages/pharmacies/screens/product-details/availability_info.dart b/lib/pages/pharmacies/screens/product-details/availability_info.dart index 34a1d454..0c00d22a 100644 --- a/lib/pages/pharmacies/screens/product-details/availability_info.dart +++ b/lib/pages/pharmacies/screens/product-details/availability_info.dart @@ -2,112 +2,83 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_deta 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 { - @override Widget build(BuildContext context) { return BaseView( - onModelReady: (model) => - model.getProductLocationData(), - builder: (_, model, wi) => model - .productLocationService - .length == - 0 - ? Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text( - TranslationBase.of(context) - .noLocationAvailable, - ), -// Text('No location Available'), - ) - : ListView.builder( - physics: ScrollPhysics(), - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemCount: model - .productLocationService - .length, - itemBuilder: - (BuildContext context, - int index) { - return Padding( - padding: - EdgeInsets.all(8.0), - child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// mainAxisAlignment: MainAxisAlignment.start, - children: [ - Row( -// crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: - MainAxisAlignment - .start, - children: [ - Expanded( - flex: 1, - child: Image.network(model - .productLocationService[ - index] - .projectImageUrl), - ), - SizedBox( - width: 10, - ), - Expanded( - flex: 4, - child: Text( - model - .productLocationService[ - index] - .locationDescription + - "\n" + - convertCityName( - model - .productLocationService[ - 0] - .cityName - .toString(), + onModelReady: (model) => model.getProductLocationData(), + + builder: (_, model, wi) => NetworkBaseView( + baseViewModel: model, + child: model.productLocationService.length == 0 + ? Container( + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text( + TranslationBase.of(context).noLocationAvailable, + ), + ) + : ListView.builder( + physics: ScrollPhysics(), + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: model.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(model + .productLocationService[index].projectImageUrl), ), - 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: - () {}, - ), + SizedBox( + width: 10, + ), + Expanded( + flex: 4, + child: Text( + model.productLocationService[index] + .locationDescription + + "\n" + + convertCityName( + model.productLocationService[0].cityName + .toString(), + ), + 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: () {}, + ), + ), + ], + ), + Divider(height: 1.2, color: Colors.grey) + ], ), - ], - ), - Divider( - height: 1.2, - color: Colors.grey) - ], - ), - ); - }, + ); + }, + ), ), ); } diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 5f596e3a..d677b9b8 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/config/size_config.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.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/others/app_scafold_detail_page.dart'; +import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -46,13 +48,16 @@ class ProductDetailPage extends StatefulWidget { __ProductDetailPageState createState() => __ProductDetailPageState(); } -class __ProductDetailPageState extends State { +class __ProductDetailPageState extends State + with SingleTickerProviderStateMixin { + TabController _tabController; AppSharedPreferences sharedPref = AppSharedPreferences(); bool isTrue = true; bool isDetails = true; bool isReviews = false; bool isAvailability = false; + int _activeTab = 0; checkWishlist() async { GifLoaderDialogUtils.showMyDialog(context); @@ -74,10 +79,18 @@ class __ProductDetailPageState extends State { void initState() { price = 1; specificationData = widget.product; + _tabController = TabController(length: 3, vsync: this); + userInfo(); super.initState(); } + @override + void dispose() { + _tabController.dispose(); + super.dispose(); + } + void userInfo() async { print(specificationData); customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); @@ -90,6 +103,7 @@ class __ProductDetailPageState extends State { Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); + final screenSize = MediaQuery.of(context).size; return customerId != null ? DetailPageScafold( @@ -153,15 +167,87 @@ class __ProductDetailPageState extends State { SizedBox( height: 6, ), + // Container( + // height: 500, + // color: Colors.white, + // child: Scaffold( + // backgroundColor: Colors.white, + // extendBodyBehindAppBar: false, + // appBar: PreferredSize( + // preferredSize: Size.fromHeight( + // MediaQuery.of(context).size.height * 0.070), + // child: Container( + // height: MediaQuery.of(context).size.height * 0.070, + // decoration: BoxDecoration( + // border: Border( + // bottom: BorderSide( + // color: Theme.of(context).dividerColor, + // width: 0.5), //width: 0.7 + // ), + // color: Colors.white), + // child: Center( + // child: TabBar( + // isScrollable: false, + // controller: _tabController, + // // indicatorColor: Colors.transparent, + // indicatorWeight: 1.0, + // indicatorSize: TabBarIndicatorSize.tab, + // indicatorColor:Colors.green, + // labelColor: Theme.of(context).primaryColor, + // labelPadding: EdgeInsets.only( + // top: 0, left: 0, right: 0, bottom: 0), + // unselectedLabelColor: Colors.grey[800], + // tabs: [ + // tabWidget(screenSize, _activeTab == 0, + // TranslationBase.of(context).details, + // ), + // tabWidget(screenSize, _activeTab == 1, + // TranslationBase.of(context).review, + // ), + // tabWidget(screenSize, _activeTab == 2, + // TranslationBase.of(context).availability), + // ], + // ), + // ), + // ), + // ), + // body: Column( + // children: [ + // Expanded( + // child: TabBarView( + // physics: BouncingScrollPhysics(), + // controller: _tabController, + // children: [ + // DetailsInfo( + // product: widget.product, + // ), + // ReviewsInfo( + // product: widget.product, + // ), + // AvailabilityInfo() + // ], + // ), + // ), + // + // ], + // ), + // ), + // ), + + SizedBox( + height: 6, + ), + + //TODO Elham* Remove this Container( - width: 500, + // width: 500, margin: EdgeInsets.only(bottom: 6), color: Colors.white, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Column( children: [ @@ -181,13 +267,9 @@ class __ProductDetailPageState extends State { ), color: Colors.white, ), - isDetails - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container() + CustomDivider( + color: isDetails ? Colors.green : Colors.transparent, + ) ], ), SizedBox( @@ -211,13 +293,9 @@ class __ProductDetailPageState extends State { ), color: Colors.white, ), - isReviews - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container(), + CustomDivider( + color: isReviews ? Colors.green : Colors.transparent, + ), ], ), SizedBox( @@ -241,13 +319,9 @@ class __ProductDetailPageState extends State { ), color: Colors.white, ), - isAvailability - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container(), + CustomDivider( + color: isAvailability ? Colors.green : Colors.transparent, + ), ], ), ], @@ -795,6 +869,24 @@ class __ProductDetailPageState extends State { } } +class CustomDivider extends StatelessWidget { + const CustomDivider({ + Key key, + this.color, + }) : super(key: key); + + final Color color; + + @override + Widget build(BuildContext context) { + return Container( + width: 120, + height: 2, + color: color, + ); + } +} + convertCityName(txt) { String stringTxt; String newTxt; @@ -828,3 +920,27 @@ deleteFromWishlistFunction(itemID) async { isInWishList = false; await x.deletWishlistData(itemID); } + +//TODO Elham* move to file +Widget tabWidget( + Size screenSize, + bool isActive, + String title, +) { + return Center( + child: Container( + height: screenSize.height * 0.070, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AppText( + title, + fontSize: SizeConfig.textMultiplier * 1.5, + // color: Color(0xFF2B353E), + fontWeight: FontWeight.w700, + ), + ], + ), + ), + ); +} diff --git a/lib/pages/pharmacies/screens/product-details/reviews_info.dart b/lib/pages/pharmacies/screens/product-details/reviews_info.dart index a133fce3..ed1970cd 100644 --- a/lib/pages/pharmacies/screens/product-details/reviews_info.dart +++ b/lib/pages/pharmacies/screens/product-details/reviews_info.dart @@ -2,6 +2,7 @@ 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/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:rating_bar/rating_bar.dart'; @@ -14,79 +15,82 @@ class ReviewsInfo extends StatelessWidget { Widget build(BuildContext context) { return BaseView( onModelReady: (model) => model.getProductReviewsData(product.id), - builder: (_, model, wi) => model.productDetailService.length != 0 && - model.productDetailService[0].reviews.length != 0 - ? ListView.builder( - physics: ScrollPhysics(), - itemCount: model.productDetailService[0].reviews.length, - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: Row( - children: [ - Container( - child: Text( - model.productDetailService[0].reviews[index] - .customerId - .toString(), - style: TextStyle( - fontSize: 17, - color: Colors.grey, - fontWeight: FontWeight.w600), + builder: (_, model, wi) => NetworkBaseView( + baseViewModel:model , + child: model.productDetailService.length != 0 && + model.productDetailService[0].reviews.length != 0 + ? ListView.builder( + physics: ScrollPhysics(), + itemCount: model.productDetailService[0].reviews.length, + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Row( + children: [ + Container( + child: Text( + model.productDetailService[0].reviews[index] + .customerId + .toString(), + style: TextStyle( + fontSize: 17, + color: Colors.grey, + fontWeight: FontWeight.w600), + ), ), - ), - Container( - margin: EdgeInsets.only(left: 210), - child: RatingBar.readOnly( - initialRating: model.productDetailService[0] - .reviews[index].rating - .toDouble(), - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + Container( + margin: EdgeInsets.only(left: 210), + child: RatingBar.readOnly( + initialRating: model.productDetailService[0] + .reviews[index].rating + .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: 10, - ), - Container( - child: Text( - model.productDetailService[0].reviews[index] - .reviewText, - style: TextStyle(fontSize: 20), + SizedBox( + height: 10, ), - ), - SizedBox( - height: 50, - ), - Divider(height: 1, color: Colors.grey), - ], - ), - ); - }, - ) - : Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text( - TranslationBase.of(context).noReviewsAvailable, - ), + Container( + child: Text( + model.productDetailService[0].reviews[index] + .reviewText, + style: TextStyle(fontSize: 20), + ), + ), + SizedBox( + height: 50, + ), + Divider(height: 1, color: Colors.grey), + ], + ), + ); + }, + ) + : Container( + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text( + TranslationBase.of(context).noReviewsAvailable, + ), // Text('No Reviews Available'), - ), + ), + ), ); } } From f47d59c43fa81b7843a921fd1c5c0107b2df9b24 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Tue, 5 Oct 2021 10:13:11 +0300 Subject: [PATCH 19/67] fix bugs pharmacy home --- .../pharmacy_module_view_model.dart | 30 ++++++++----------- .../screens/pharmacy_module_page.dart | 5 +--- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart index 7bcb8f91..b07585a8 100644 --- a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart @@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart' import 'package:diplomaticquarterapp/core/model/pharmacies/Prescriptions.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; import 'package:diplomaticquarterapp/core/service/medical/prescriptions_service.dart'; + //import 'package:diplomaticquarterapp/core/model/prescriptions/perscription_pharmacy.dart'; import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_service.dart'; import 'package:diplomaticquarterapp/core/service/parmacyModule/prescription_service.dart'; @@ -14,21 +15,19 @@ import 'package:diplomaticquarterapp/services/pharmacy_services/recommendedProdu import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; - import '../../../locator.dart'; class PharmacyModuleViewModel extends BaseViewModel { - PharmacyModuleService _pharmacyService = locator(); - RecommendedProductService _recommendedProductService = locator(); + RecommendedProductService _recommendedProductService = + locator(); List get bannerList => _pharmacyService.bannerItems; - List get recommendedProductList => + List get recommendedProductList => _recommendedProductService.recommendedList; - Future getBannerList() async { _pharmacyService.bannerItems.clear(); // setState(ViewState.BusyLocal); @@ -37,17 +36,15 @@ class PharmacyModuleViewModel extends BaseViewModel { await _pharmacyService.getBannerListList(); GifLoaderDialogUtils.hideDialog( locator().navigatorKey.currentContext); - // if (_pharmacyService.hasError) - // { - // error = _pharmacyService.error; - // setState(ViewState.Error); - // } else - // setState(ViewState.Idle); + if (_pharmacyService.hasError) { + error = _pharmacyService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); } Future getPharmacyHomeData() async { - if(authenticatedUserObject.isLogin) - await generatePharmacyToken(); + if (authenticatedUserObject.isLogin) await generatePharmacyToken(); var data = await sharedPref.getObject(USER_PROFILE); var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); @@ -72,6 +69,7 @@ class PharmacyModuleViewModel extends BaseViewModel { setState(ViewState.Idle); } } + Future generatePharmacyToken() async { setState(ViewState.Busy); await _pharmacyService.generatePharmacyToken(); @@ -83,7 +81,6 @@ class PharmacyModuleViewModel extends BaseViewModel { } } - List getBannerImagesUrl() { List images = List(); images.add('assets/images/pharmacy_module/pharmacy_logo_green.png'); @@ -94,8 +91,8 @@ class PharmacyModuleViewModel extends BaseViewModel { return images; } - getRecommendedProducts(productId) async { - setState(ViewState.Busy); + getRecommendedProducts(productId) async { + setState(ViewState.Busy); await _recommendedProductService.getRecommendedProducts(productId); if (_recommendedProductService.hasError) { error = _recommendedProductService.error; @@ -118,5 +115,4 @@ class PharmacyModuleViewModel extends BaseViewModel { return false; } } - } diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 3ec3143d..2136f589 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -52,7 +52,7 @@ class _PharmacyPageState extends State { isShowDecPage: false, baseViewModel: model, backgroundColor: Colors.white, - body: model.state != ViewState.BusyLocal ? Container( + body: Container( width: double.infinity, child: SingleChildScrollView( child: Column( @@ -67,9 +67,6 @@ class _PharmacyPageState extends State { ], ), ), - ) : Container( - height: 200, - color: Colors.red, ), ), ); From 6fe41382c0099c147e6598f5b5e9251298306d32 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 5 Oct 2021 11:06:20 +0300 Subject: [PATCH 20/67] first step from design --- .../product-details/product-detail.dart | 26 +- .../product-name-and-price.dart | 225 +++++++++--------- 2 files changed, 132 insertions(+), 119 deletions(-) diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index d677b9b8..015e7958 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -119,8 +119,13 @@ class __ProductDetailPageState extends State color: Colors.white, child: Column( children: [ - Image.network( - widget.product.images[0].src.trim(), + 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) @@ -151,16 +156,17 @@ class __ProductDetailPageState extends State mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Text( - TranslationBase.of(context).specification, - style: TextStyle(fontWeight: FontWeight.bold), - ), + Container( + + padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10), + child: Texts( + TranslationBase.of(context).specification, + fontSize: 15, + fontWeight: FontWeight.bold, ), + width: double.infinity, ), - Divider(color: Colors.grey), + // Divider(color: Colors.grey), ], ), ), 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 428f49e8..14b94269 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,8 +1,8 @@ - import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.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'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; @@ -17,7 +17,6 @@ class ProductNameAndPrice extends StatefulWidget { final Function addToWishlistFunction; final Function deleteFromWishlistFunction; - ProductNameAndPrice(this.context, this.item, {this.customerId, this.isInWishList, @@ -30,7 +29,6 @@ class ProductNameAndPrice extends StatefulWidget { } class _ProductNameAndPriceState extends State { - @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); @@ -38,78 +36,72 @@ class _ProductNameAndPriceState extends State { return Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.all(8.0), + SizedBox(height: 10,), + FractionallySizedBox( + widthFactor: 0.95, child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( - widget.item.price.toString() + " " + "SAR", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30), - ), - SizedBox( - width: 40, - ), - Text( - projectViewModel.isArabic - ? widget.item.stockAvailabilityn - : widget.item.stockAvailability, - style: widget.item.stockAvailability == 'Out of stock' - ? TextStyle(fontWeight: FontWeight.bold, color: Colors.red) - : TextStyle( - fontWeight: FontWeight.bold, color: Colors.green), + Texts(widget.item.price.toString() + " " + "SAR", + fontWeight: FontWeight.bold, fontSize: 20 + ), + Texts( projectViewModel.isArabic + ? widget.item.stockAvailabilityn + : widget.item.stockAvailability, + fontWeight: FontWeight.bold, fontSize: 15, color: widget.item.stockAvailability == 'Out of stock'?Colors.red:Colors.green, ), - SizedBox(width: 20), + // SizedBox(width: 20), widget.item.stockAvailability == 'Out of stock' && - widget.customerId != null + widget.customerId != null ? InkWell( - onTap: () => - widget.notifyMeWhenAvailable(context, widget.item.id), - child: Row(children: [ - Text( - TranslationBase.of(context).notifyMe, - style: TextStyle( - color: Colors.blue, - decoration: TextDecoration.underline, - ), - ), - SizedBox(width: 4), - Icon( - FontAwesomeIcons.bell, - color: Colors.blue, - size: 15.0, - ) - ]), - ) + onTap: () => + widget.notifyMeWhenAvailable(context, widget.item.id), + child: Row(children: [ + Texts( + TranslationBase.of(context).notifyMe, + decoration: TextDecoration.underline, + color: Colors.blue, + ), + SizedBox(width: 4), + Icon( + FontAwesomeIcons.bell, + color: Colors.blue, + size: 15.0, + ) + ]), + ) : Container( - margin: projectViewModel.isArabic - ? EdgeInsets.only(right: 25) - : EdgeInsets.only(left: 25), - width: 40, - height: 40, - decoration: BoxDecoration( - color: Colors.grey, - borderRadius: BorderRadius.circular(30), - ), - child: IconButton( - icon: Icon(!widget.isInWishList - ? Icons.favorite_border - : Icons.favorite), - color: !widget.isInWishList ? Colors.white : Colors.red, - onPressed: () async { - if (widget.customerId != null) { - if (!widget.isInWishList) { - GifLoaderDialogUtils.showMyDialog(context); - await widget.addToWishlistFunction(widget.item.id); - GifLoaderDialogUtils.hideDialog(context); - } else { - await widget.deleteFromWishlistFunction(widget.item.id); - } - } else { - return; - } - setState(() {}); - }, - )), + margin: projectViewModel.isArabic + ? EdgeInsets.only(right: 25) + : EdgeInsets.only(left: 25), + width: 40, + height: 40, + decoration: BoxDecoration( + color: Colors.grey[300], + borderRadius: BorderRadius.circular(30), + ), + child: IconButton( + icon: Icon(!widget.isInWishList + ? Icons.favorite_border + : Icons.favorite), + color: !widget.isInWishList ? Colors.white : Colors.red, + onPressed: () async { + if (widget.customerId != null) { + if (!widget.isInWishList) { + GifLoaderDialogUtils.showMyDialog(context); + await widget + .addToWishlistFunction(widget.item.id); + GifLoaderDialogUtils.hideDialog(context); + } else { + await widget + .deleteFromWishlistFunction(widget.item.id); + } + } else { + return; + } + setState(() {}); + }, + )), ], ), ), @@ -118,59 +110,74 @@ 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.fullDescriptionn - : widget.item.fullDescription, + ? widget.item.namen + : widget.item.name, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), ), ), ), ), - Row( - children: [ - Expanded( - flex: 2, - child: Container( - margin: EdgeInsets.only(right: 150), + FractionallySizedBox( + widthFactor: 0.95, + child: Row( + children: [ + Container( child: Align( alignment: Alignment.bottomLeft, - child: RatingBar.readOnly( - initialRating: 3, - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + child: Row( + children: [ + RatingBar.readOnly( + initialRating:double.parse( widget.item.approvedRatingSum.toString()), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[400], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), + SizedBox(width: 10,), + Texts( + "${widget.item.approvedTotalReviews}", + fontSize: 12, + ), + SizedBox(width: 30,), + Texts( + "(${widget.item.approvedTotalReviews} ${TranslationBase.of(context).review})", + fontSize: 12, + ), + ], ), ), ), - ), - Expanded( - flex: 1, - child: Container( - child: widget.item.rxMessage != null - ? Text( - projectViewModel.isArabic - ? widget.item.rxMessagen.toString() - : widget.item.rxMessage.toString(), - style: TextStyle(color: Colors.red, fontSize: 10), - ) - : Container()), - ), - widget.item.rxMessage != null - ? Icon( - FontAwesomeIcons.questionCircle, - color: Colors.red, - size: 15.0, - ) - : Container(), - ], + Expanded( + flex: 1, + child: Container( + child: widget.item.rxMessage != null + ? Text( + projectViewModel.isArabic + ? widget.item.rxMessagen.toString() + : widget.item.rxMessage.toString(), + style: TextStyle(color: Colors.red, fontSize: 10), + ) + : Container()), + ), + widget.item.rxMessage != null + ? Icon( + FontAwesomeIcons.questionCircle, + color: Colors.red, + size: 15.0, + ) + : Container(), + ], + ), ), + SizedBox(height: 10,), ], ); } From d4fd95606e31943e0917f3d95b24df423f89e5c2 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 5 Oct 2021 11:40:13 +0300 Subject: [PATCH 21/67] add pharmacy icons for bottom nav --- assets/app_icons/config.json | 178 ++++++++++++++++++ assets/app_icons/fonts/DQIcons.ttf | Bin 28064 -> 32800 bytes lib/d_q_icons_icons.dart | 97 +++++++--- .../pharmacy/bottom_nav_pharmacy_bar.dart | 14 +- .../pharmacy/bottom_nav_pharmacy_item.dart | 7 +- 5 files changed, 265 insertions(+), 31 deletions(-) diff --git a/assets/app_icons/config.json b/assets/app_icons/config.json index e2e1afdb..ceb65b05 100644 --- a/assets/app_icons/config.json +++ b/assets/app_icons/config.json @@ -271,6 +271,184 @@ "search": [ "roboticon" ] + }, + { + "uid": "8ce732688587909ad0a9d8323eaca8ad", + "css": "marquee", + "code": 59590, + "src": "fontelico" + }, + { + "uid": "ec8496ef645f3be7b28147ec60cd9ab1", + "css": "crown-minus", + "code": 59589, + "src": "fontelico" + }, + { + "uid": "36ef9feb0754335302784521267a9ad4", + "css": "crown-plus", + "code": 59588, + "src": "fontelico" + }, + { + "uid": "186dec7a13156bbe2550790c158fb85d", + "css": "crown", + "code": 59587, + "src": "fontelico" + }, + { + "uid": "2a46f1d1c9bd036e17a74e46613c1636", + "css": "ie", + "code": 59586, + "src": "fontelico" + }, + { + "uid": "9c2b737b16ae2c8d66b7bfd29ba5ecd8", + "css": "chrome", + "code": 59584, + "src": "fontelico" + }, + { + "uid": "45861dd1e5ce4fde338bcccf01eeb808", + "css": "opera", + "code": 59585, + "src": "fontelico" + }, + { + "uid": "2bd5f98482d86649958312ea2ab5bb40", + "css": "emo-laugh", + "code": 59576, + "src": "fontelico" + }, + { + "uid": "fc92480dedc439d274d4e3e4b425edf4", + "css": "emo-squint", + "code": 59575, + "src": "fontelico" + }, + { + "uid": "4843d0d6050dd508d4c101a334f46db2", + "css": "emo-shoot", + "code": 59574, + "src": "fontelico" + }, + { + "uid": "04688d76a33ce7a7950e40fae79c08ac", + "css": "emo-cry", + "code": 59573, + "src": "fontelico" + }, + { + "uid": "e4b163acaaa08255819f2f78afe8f075", + "css": "cart_menu_icon", + "code": 59412, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M367.1 624.3H972.6A33.2 33.2 0 0 0 1004.7 601.7L1138.2 164.7A29.6 29.6 0 0 0 1132.9 137.3 34.3 34.3 0 0 0 1106.3 124.9H289.9L266.3 24.5A33 33 0 0 0 233.7 0H33.4A32.4 32.4 0 0 0 0 31.2 32.4 32.4 0 0 0 33.4 62.4H206.9L327.4 569.6A93.8 93.8 0 0 0 267.1 655.5 97.1 97.1 0 0 0 367.2 749.1H972.6A31.3 31.3 0 1 0 972.6 686.7H367.2A31.3 31.3 0 1 1 367.2 624.3ZM1061.9 187.3L947.4 561.9H394L305 187.3ZM1061.9 187.3M315.3 894.6A105.4 105.4 0 1 0 420.7 789.2 105.4 105.4 0 0 0 315.3 894.6ZM420.7 859.4A35.2 35.2 0 1 1 385.6 894.6 35.2 35.2 0 0 1 420.7 859.4ZM420.7 859.4M735.4 894.6A105.4 105.4 0 1 0 840.9 789.2 105.4 105.4 0 0 0 735.4 894.6ZM840.9 859.4A35.2 35.2 0 1 1 805.7 894.6 35.2 35.2 0 0 1 840.9 859.4ZM840.9 859.4", + "width": 1140 + }, + "search": [ + "cart_menu_icon" + ] + }, + { + "uid": "45f50872f02e050e19f0910ca3e0e8e6", + "css": "categories_menu_icon", + "code": 59413, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M332.7 458.9H126.3A126.3 126.3 0 0 1 0 332.7V126.3A126.3 126.3 0 0 1 126.3 0H332.7A126.3 126.3 0 0 1 459 126.3V332.7A126.3 126.3 0 0 1 332.7 458.9ZM126.3 61.2A65.1 65.1 0 0 0 61.2 126.3V332.7A65.1 65.1 0 0 0 126.3 397.8H332.7A65.1 65.1 0 0 0 397.8 332.7V126.3A65.1 65.1 0 0 0 332.7 61.2ZM873.8 458.9H667.3A126.3 126.3 0 0 1 541 332.6V126.3A126.3 126.3 0 0 1 667.3 0H873.9A126.3 126.3 0 0 1 1000.2 126.3V332.7A126.3 126.3 0 0 1 873.8 458.9ZM667.3 61.2A65.1 65.1 0 0 0 602.2 126.3V332.7A65.1 65.1 0 0 0 667.3 397.8H873.9A65.1 65.1 0 0 0 938.9 332.7V126.3A65.1 65.1 0 0 0 873.9 61.3ZM332.7 999.9H126.3A126.3 126.3 0 0 1 0 873.7V667.3A126.3 126.3 0 0 1 126.3 541H332.7A126.3 126.3 0 0 1 459 667.3V873.9A126.3 126.3 0 0 1 332.7 999.9ZM126.3 602.2A65.1 65.1 0 0 0 61.2 667.3V873.9A65.1 65.1 0 0 0 126.3 938.8H332.7A65.1 65.1 0 0 0 397.8 873.8V667.3A65.1 65.1 0 0 0 332.7 602.3ZM873.8 999.9H667.3A126.3 126.3 0 0 1 541 873.7V667.3A126.3 126.3 0 0 1 667.3 541H873.8A126.3 126.3 0 0 1 1000.1 667.3V873.9A126.3 126.3 0 0 1 873.8 999.9ZM667.3 602.2A65.1 65.1 0 0 0 602.2 667.3V873.9A65.1 65.1 0 0 0 667.3 938.8H873.8A65.1 65.1 0 0 0 938.8 873.8V667.3A65.1 65.1 0 0 0 873.8 602.3Z", + "width": 1000 + }, + "search": [ + "categories_menu_icon" + ] + }, + { + "uid": "de65d94899c08a719eb8f9b723f73fc4", + "css": "hmg_logo_icon", + "code": 59414, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M146 835.7S180.9 835.5 205.5 835.5L392.2 836.4C414.4 836.4 433 812.7 434 778.5L434 622.5C434 589.3 448.9 563.3 472 561.7L529.2 561.2C552.3 562.7 568.1 588.9 568.1 622L568.1 778.9C569.2 813.1 584.7 835.5 607.1 835.5L858.4 836.1 858.8 643.3C858.8 610.2 842.9 584.4 819.8 583L718.8 582.5C696.5 582.5 678.9 558.9 677.9 524.7L677.5 472.6C678.6 438.4 696.4 414.8 718.7 414.8L820.2 415.1C843.3 413.6 858.3 386.4 858.3 353.3L858.5 112.8A102.4 102.4 0 0 1 780.8 161.4L610.2 161.4C587.9 161.4 569.4 185.7 568.3 219.9V374.6C567.2 408.8 549.8 432.9 527.5 432.9L475.8 432C453.4 432 435.6 408.6 434.5 374.7L434.5 218.4C433.4 184.3 415.6 161.2 393.4 161.2L145.6 161.2 145.6 353.4C145.6 386.6 161.2 413.1 184.3 414.7L285.8 414.3C308.8 415.8 325.1 443.2 325.1 476.2L324.8 520.7C324.8 553.8 309.1 580.4 286 581.9L184.3 581.7C161.2 583.3 145.6 609.5 145.6 642.6ZM999.3 99.1V902.8A102.2 102.2 0 0 1 896 1000H102.8A101.9 101.9 0 0 1 0 902.8L0 97.6A102.3 102.3 0 0 1 103 0L895.4 0.3A104 104 0 0 1 999.3 99.1Z", + "width": 999 + }, + "search": [ + "hmg_logo_icon" + ] + }, + { + "uid": "baf8798b7336aad03b1d61cacc015142", + "css": "user_menu_icon", + "code": 59415, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M853.6 146.4A500 500 0 0 0 146.4 853.6 500 500 0 0 0 853.6 146.4ZM217 838.5A286.1 286.1 0 0 1 500 586.7 285 285 0 0 1 783 838.5 440.5 440.5 0 0 1 217 838.5ZM500 526.3A151.8 151.8 0 1 1 651.8 374.5 152.1 152.1 0 0 1 500 526.3ZM833.4 788.8A344.4 344.4 0 0 0 617.6 548.7 210.5 210.5 0 1 0 382.1 548.7 344.2 344.2 0 0 0 166.3 788.7 441.4 441.4 0 1 1 833.2 788.7ZM833.4 788.8", + "width": 1000 + }, + "search": [ + "user_menu_icon" + ] + }, + { + "uid": "d3f621623139837ff2fb5fe09cf16994", + "css": "cart_menu_icon-1", + "code": 59416, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M367.1 624.3H972.6A33.2 33.2 0 0 0 1004.7 601.7L1138.2 164.7A29.6 29.6 0 0 0 1132.9 137.3 34.3 34.3 0 0 0 1106.3 124.9H289.9L266.3 24.5A33 33 0 0 0 233.7 0H33.4A32.4 32.4 0 0 0 0 31.2 32.4 32.4 0 0 0 33.4 62.4H206.9L327.4 569.6A93.8 93.8 0 0 0 267.1 655.5 97.1 97.1 0 0 0 367.2 749.1H972.6A31.3 31.3 0 1 0 972.6 686.7H367.2A31.3 31.3 0 1 1 367.2 624.3ZM1061.9 187.3L947.4 561.9H394L305 187.3ZM1061.9 187.3M315.3 894.6A105.4 105.4 0 1 0 420.7 789.2 105.4 105.4 0 0 0 315.3 894.6ZM420.7 859.4A35.2 35.2 0 1 1 385.6 894.6 35.2 35.2 0 0 1 420.7 859.4ZM420.7 859.4M735.4 894.6A105.4 105.4 0 1 0 840.9 789.2 105.4 105.4 0 0 0 735.4 894.6ZM840.9 859.4A35.2 35.2 0 1 1 805.7 894.6 35.2 35.2 0 0 1 840.9 859.4ZM840.9 859.4", + "width": 1140 + }, + "search": [ + "cart_menu_icon" + ] + }, + { + "uid": "6aac6f399374da0b9c4811b6a7110627", + "css": "categories_menu_icon-1", + "code": 59417, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M332.7 458.9H126.3A126.3 126.3 0 0 1 0 332.7V126.3A126.3 126.3 0 0 1 126.3 0H332.7A126.3 126.3 0 0 1 459 126.3V332.7A126.3 126.3 0 0 1 332.7 458.9ZM126.3 61.2A65.1 65.1 0 0 0 61.2 126.3V332.7A65.1 65.1 0 0 0 126.3 397.8H332.7A65.1 65.1 0 0 0 397.8 332.7V126.3A65.1 65.1 0 0 0 332.7 61.2ZM873.8 458.9H667.3A126.3 126.3 0 0 1 541 332.6V126.3A126.3 126.3 0 0 1 667.3 0H873.9A126.3 126.3 0 0 1 1000.2 126.3V332.7A126.3 126.3 0 0 1 873.8 458.9ZM667.3 61.2A65.1 65.1 0 0 0 602.2 126.3V332.7A65.1 65.1 0 0 0 667.3 397.8H873.9A65.1 65.1 0 0 0 938.9 332.7V126.3A65.1 65.1 0 0 0 873.9 61.3ZM332.7 999.9H126.3A126.3 126.3 0 0 1 0 873.7V667.3A126.3 126.3 0 0 1 126.3 541H332.7A126.3 126.3 0 0 1 459 667.3V873.9A126.3 126.3 0 0 1 332.7 999.9ZM126.3 602.2A65.1 65.1 0 0 0 61.2 667.3V873.9A65.1 65.1 0 0 0 126.3 938.8H332.7A65.1 65.1 0 0 0 397.8 873.8V667.3A65.1 65.1 0 0 0 332.7 602.3ZM873.8 999.9H667.3A126.3 126.3 0 0 1 541 873.7V667.3A126.3 126.3 0 0 1 667.3 541H873.8A126.3 126.3 0 0 1 1000.1 667.3V873.9A126.3 126.3 0 0 1 873.8 999.9ZM667.3 602.2A65.1 65.1 0 0 0 602.2 667.3V873.9A65.1 65.1 0 0 0 667.3 938.8H873.8A65.1 65.1 0 0 0 938.8 873.8V667.3A65.1 65.1 0 0 0 873.8 602.3Z", + "width": 1000 + }, + "search": [ + "categories_menu_icon" + ] + }, + { + "uid": "0a4cf1ff2671b9ea852d635e27df1e69", + "css": "hmg_logo_icon-1", + "code": 59418, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M146 835.7S180.9 835.5 205.5 835.5L392.2 836.4C414.4 836.4 433 812.7 434 778.5L434 622.5C434 589.3 448.9 563.3 472 561.7L529.2 561.2C552.3 562.7 568.1 588.9 568.1 622L568.1 778.9C569.2 813.1 584.7 835.5 607.1 835.5L858.4 836.1 858.8 643.3C858.8 610.2 842.9 584.4 819.8 583L718.8 582.5C696.5 582.5 678.9 558.9 677.9 524.7L677.5 472.6C678.6 438.4 696.4 414.8 718.7 414.8L820.2 415.1C843.3 413.6 858.3 386.4 858.3 353.3L858.5 112.8A102.4 102.4 0 0 1 780.8 161.4L610.2 161.4C587.9 161.4 569.4 185.7 568.3 219.9V374.6C567.2 408.8 549.8 432.9 527.5 432.9L475.8 432C453.4 432 435.6 408.6 434.5 374.7L434.5 218.4C433.4 184.3 415.6 161.2 393.4 161.2L145.6 161.2 145.6 353.4C145.6 386.6 161.2 413.1 184.3 414.7L285.8 414.3C308.8 415.8 325.1 443.2 325.1 476.2L324.8 520.7C324.8 553.8 309.1 580.4 286 581.9L184.3 581.7C161.2 583.3 145.6 609.5 145.6 642.6ZM999.3 99.1V902.8A102.2 102.2 0 0 1 896 1000H102.8A101.9 101.9 0 0 1 0 902.8L0 97.6A102.3 102.3 0 0 1 103 0L895.4 0.3A104 104 0 0 1 999.3 99.1Z", + "width": 999 + }, + "search": [ + "hmg_logo_icon" + ] + }, + { + "uid": "d19eb878f1dee49848276b6d0faa6602", + "css": "wishlist_menu_icon", + "code": 59411, + "src": "custom_icons", + "selected": false, + "svg": { + "path": "M877.6 0A394.8 394.8 0 0 0 600.7 112.2 394.8 394.8 0 0 0 323.8 0 332.4 332.4 0 0 0 0 349 515.4 515.4 0 0 0 138.3 679.5 1351.1 1351.1 0 0 0 580.3 995.3 46.9 46.9 0 0 0 621.1 995.3 1351.1 1351.1 0 0 0 1063.1 679.5 515.4 515.4 0 0 0 1201.4 349 332.5 332.5 0 0 0 877.6 0ZM991.8 618.5A1233.8 1233.8 0 0 1 600.7 900.8 1233.7 1233.7 0 0 1 209.5 618.5 418.4 418.4 0 0 1 93.8 349 239.1 239.1 0 0 1 323.8 93.8 297.2 297.2 0 0 1 500.6 150.7 283.5 283.5 0 0 1 562 209.5 46.5 46.5 0 0 0 600.5 230H600.5A46.9 46.9 0 0 0 639.1 209.3 301.2 301.2 0 0 1 877.2 93.8 239.2 239.2 0 0 1 1107.1 349 418.4 418.4 0 0 1 991.8 618.5Z", + "width": 1201 + }, + "search": [ + "wishlist_menu_icon" + ] } ] } \ No newline at end of file diff --git a/assets/app_icons/fonts/DQIcons.ttf b/assets/app_icons/fonts/DQIcons.ttf index bc92c83de143966170d64f05992da0c9495e33f0..e0a15c88fa043bde0c93d16c0bde22f39f2e3a8f 100644 GIT binary patch delta 5201 zcmb_gX>c6Zaen<~?_*|Eqv+e!s-N zBj#(|B-Sm2GATZ6q_}%E49jq9^?BH8zo}1k44b{Y`VVldXgFQ3v$42$k*f8dbHnvJ zxQ;vAyC{FEzOL(V@!VIjz7xwsj8?PM|B0Aa&8&3IkVj#bd^V;-v(5j~z zsD870vtB2pN~&V@_391AZ#;nQvZR-6TYZ|Qk|L3aOcc^6eZ)@!BuJV_h^Qn?A|y&; zID={RRl2r%gPH{g8wI|g!x47F{Rm6#qa1c_J8id1=s@x!)fK-(R;Z&rGeqyAz z_al#_w+|qXq_=+^c_hNx{zZduaisc<2H`SE^_w~!A-G~vz0n|CJE^|eAlwD1{#Ao; zKcxEY2I0;~^*as1J(4PdixKXYRBtwj#8$5x(rVYO+>7~G{-wgU;^pEyrJ2%O-M;SY zJ&~T*ddt1feC_*&S0^=Vy{(nI>l4)PH)LXHyB674FMyv2k$n#@8Q z#7v^R8N580Rj!1pd?Fr=CGth!qFfY2S(n6kTI!NT6I0}jzfA~B^a;D$@T^gCt!Y2> zaUT0$J4Mm?%DF%kKnOK^=@U+m$GQF@zUg;Pt^eIo`m1%Ra%9VvHYusP=6FdANumI~ zzahHiu)*s>0H*9tPry?%*gBfL%>f>;;t6`-_1dT4?0UIv%a$V*mzorC7!9fUegW3e zmKH+lbKJk8RlFolN@N!qB~KEKTtWQAV_Db&`3h`?E)_x`^1#JRSfXvZil|A%AHI$D z|1i*jw`09A{A(2d9!w;HZ?hK-eTZWHr*{<^>-i8};1hQz(C2~YHYUNDYAYYETRZgO zI@V9ySoLoV%7RjTmaC!*b|V-`shCp`jD>u0D=@38kW)(eL@ zBGByrh2*C(|L6TtlzhP-xe_F-VLoNOS*-(O1O7 zoh1jzL4;o-nK0u%O^OPNT&h5+m`p&0A`}&q*_2Fp5uON6tRpZX3&{$;Vm!zS_QKA3 z7rnFDWahNP$1iExr5iDPZrtV8m!nZx*-vjA|KL#ipzB}RwbIwOva4V5`4srr#$Y&NP5bq* zrY0{vJ3RdCrDW*h@W{!9`Niu^_*`F{UpR@5H`MRc|C}4;yciq{q@T>74PpXi2TqX{ zIoCrG78OV`%0dp^Z<51cl5vZ89!o|1b%yVX zfGVPhso4)?oAcsfa0-D?(%Vm;Qk?Xa3W#%W$-C1tcjOLI~Q z29&^#xYe2#d6$b9(^hMI2a1A9vbn{bsu*j3<4X7JNau3t?d3MdCj)jTSW~Tn4Gc!R z6twXzXZMR9At^qwZ*SHmL=iuC>N9xB58-{2Am_||rd6LCcj zQ%R-RyjYT2VkQaI8jj2^7B-iZXiSIQlARqCp<75MnE#5U9&`*kcndIZ;mo+YMq3rD zx++)b3Zp|S?0m543Jo{?A#;=D3#8Sc)4^5twvP-tU`>uh+Z>*_ulrMb+;O`vowUnRQ^+1lazi>i2IKt!*~y0k znbu^mMaia&e;jU)MB2kg6p>o2{s3>4g2~+n_s7GrkZ~eqG8+Im3Qcmhshk%lO>Qe_ zs{F!^sOZI|c!0A@A)YgU6=nff4wkToI_>kI%A&Yorx;jPLT^7y}272NV6uvs16bu({O0LOyYkxfATnpFg_C?vn+_(9G1| zpO_gETy0?&HCaD;;T*u(3*$x;Cxq!3GnUpKj%1k4YI82fU|WhywjLB*5XrdELyvWI zaGhOa*xa27V<1|uf0=uV-o}irMD`KPbM?d2fS{~&%1Vx{O%Ebjh%$)Y)8U%KklWCC zQ7P#MNmJwo!t)7Zl&2WMe$YD;b6T1+PHFqD5c8Osqe6R>3bEtxYVYhl9b(O3LQA(t zI6i*-_&SGh>#t0XKR$4+Z=f|p!|Pf4d+Ldg?;L-L-Y#uIPnf-G$SiRtFdL|whT2`N z?b-(woP{Ye?$-9&XjmCLbYN2lg<@x}(!W~{&y`0vQEnbXGG5ImxL;ym5im2&V9tnH zHl9bNLKP#PKa8(fl|&X&OC~(WU{tXIr*E|aEqEJ=Ds)vKpVa{VV|i+N*9+dE`Cj;= zNN3k}O!!(wxx4h{*^52PBR=|L$IlHCK-d~a%_A9mLBi#bkv6nD`? zI`FoQv4tlSc|G71*^Pidu@PpHcf;hyJ)+3)C)2|RONAglh0?*{A8b^b^4$l9r~9)h z7tgy=*-vKE0zT>N=h|BL>>M4rF*3SyPix!VipFY>9oql&`SVZjKlFatI36?H_i%B2 zWDhx{8#vL3c@4Z^j>DG5P}Ep(Nyd1Lp)iW+4Q{0nEh3nb*jSOxxgu^X4qdVo$825C z6xewx6*+DHldl|mZTG&m4nw4OTmQiw#n1K)q}rhz?(W#!l}+*4wuzC$PX%g!YumbM zm+GgTe4_bt$H(?Q+T5y&0WlMZ)UK8L*ZOMT%RDpK(o_7X7&jWwFSE`>XKw%SiLUbY z&Th#W{OscskIx<$$zm!cx_q+Bl4yDM(Y8)4(=sse_|Z$jt)kM}{?yPZm#y}r{wGbAI<{el?{fMlsc1mtZRS*GTRG7t z1#Em&>Z+)@P`Dh^1_qtHFBDId+d5Nb8!rZ;DOgVRw7zeiwI8w}uWncgani67!^s{pMDQ#7 z?#@1l6z$=mq9Y|&xF0L|LR9))#(6McG=`Ylu(AP}+GTjb z2Y%32F`jV5j5n@;AGQi!WLg-%Zc_QTwU>)_KO^l04)m1XiD!eHS`c=jXl+onPDZ%IKri@F= rQ!C?icFH)hvUGOQ7S)UP<@qzG>HEN2)P zQZ{6yCZ@=gRm%X?J^*5~44?qVc~%D?dk+w+WaO4q_^ki`9BAGXAU_}{KRI#sw8|4e z{R@D6t=zfH14CvF(84bT`NbvKmxN|AFys^f6&Wxv zGB7X){m)`xU_JK#`~Tmp%^(pJAOaQviVC=;Fvs)Td}ZKfegRT(``zp#FdC>ginWE(0mvi~!O8NB1&miGPhhm?76Mxp1yr_d@-4g=F0eQYgBw^43rPHh(EtBHk^w{l`7Dz!F==j=XXa+)V)z0S0RiF3CM?e; te`3`DI%l&5+s2g1j@9oN4JI4Z9A-4w{G}$5kx^uFSe?e?IdxBfN&vflX~h5l diff --git a/lib/d_q_icons_icons.dart b/lib/d_q_icons_icons.dart index 5d1ff3c6..7376b1ca 100644 --- a/lib/d_q_icons_icons.dart +++ b/lib/d_q_icons_icons.dart @@ -11,7 +11,7 @@ /// fonts: /// - asset: fonts/DQIcons.ttf /// -/// +/// /// import 'package:flutter/widgets.dart'; @@ -19,25 +19,80 @@ class DQIcons { DQIcons._(); static const _kFontFam = 'DQIcons'; - static const _kFontPkg = null; + static const String _kFontPkg = null; - static const IconData blood_pressure = IconData(0xe800, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData blood = IconData(0xe801, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData bmi = IconData(0xe802, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData heart = IconData(0xe803, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData height = IconData(0xe804, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData outline = IconData(0xe805, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData thermometer = IconData(0xe806, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData weight_scale = IconData(0xe807, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData parking_icon = IconData(0xe808, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData blood_type_icon = IconData(0xe809, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData height_icon = IconData(0xe80a, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData online_payment_icon = IconData(0xe80b, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData search_medicine_icon = IconData(0xe80c, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData vital_sign_icon = IconData(0xe80d, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData weight_icon = IconData(0xe80e, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData my_medical_file = IconData(0xe80f, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData family = IconData(0xe810, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData calendar__2_ = IconData(0xe811, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData roboticon = IconData(0xe812, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData blood_pressure = + IconData(0xe800, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData blood = + IconData(0xe801, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData bmi = + IconData(0xe802, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData heart = + IconData(0xe803, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData height = + IconData(0xe804, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData outline = + IconData(0xe805, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData thermometer = + IconData(0xe806, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData weight_scale = + IconData(0xe807, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData parking_icon = + IconData(0xe808, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData blood_type_icon = + IconData(0xe809, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData height_icon = + IconData(0xe80a, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData online_payment_icon = + IconData(0xe80b, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData search_medicine_icon = + IconData(0xe80c, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData vital_sign_icon = + IconData(0xe80d, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData weight_icon = + IconData(0xe80e, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData my_medical_file = + IconData(0xe80f, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData family = + IconData(0xe810, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData calendar__2_ = + IconData(0xe811, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData roboticon = + IconData(0xe812, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData cart_menu_icon = + IconData(0xe814, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData categories_menu_icon = + IconData(0xe815, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData hmg_logo_icon = + IconData(0xe816, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData user_menu_icon = + IconData(0xe817, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData cart_menu_icon_1 = + IconData(0xe818, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData categories_menu_icon_1 = + IconData(0xe819, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData hmg_logo_icon_1 = + IconData(0xe81a, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData emo_cry = + IconData(0xe8b5, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData emo_shoot = + IconData(0xe8b6, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData emo_squint = + IconData(0xe8b7, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData emo_laugh = + IconData(0xe8b8, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData chrome = + IconData(0xe8c0, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData opera = + IconData(0xe8c1, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData ie = + IconData(0xe8c2, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData crown = + IconData(0xe8c3, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData crown_plus = + IconData(0xe8c4, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData crown_minus = + IconData(0xe8c5, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData marquee = + IconData(0xe8c6, fontFamily: _kFontFam, fontPackage: _kFontPkg); } diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart index ef861c56..d1490d74 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/d_q_icons_icons.dart'; import 'package:diplomaticquarterapp/pages/landing/home_page.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; @@ -17,7 +18,6 @@ class BottomNavPharmacyBar extends StatefulWidget { } class _BottomNavPharmacyBarState extends State { - _changeIndex(int index) { widget.changeIndex(index); } @@ -43,8 +43,8 @@ class _BottomNavPharmacyBarState extends State { title: TranslationBase.of(context).Alhabibapp, ), BottomNavPharmacyItem( - icon: EvaIcons.list, - activeIcon: EvaIcons.list, + icon: DQIcons.categories_menu_icon, + activeIcon: DQIcons.categories_menu_icon, changeIndex: _changeIndex, index: widget.index, currentIndex: 1, @@ -59,16 +59,16 @@ class _BottomNavPharmacyBarState extends State { isHome: true, title: TranslationBase.of(context).home), BottomNavPharmacyItem( - icon: EvaIcons.person, - activeIcon: EvaIcons.person, + icon: DQIcons.user_menu_icon, + activeIcon: DQIcons.user_menu_icon, changeIndex: _changeIndex, index: widget.index, currentIndex: 2, title: TranslationBase.of(context).myAccount, ), BottomNavPharmacyItem( - icon: EvaIcons.shoppingCartOutline, - activeIcon: EvaIcons.shoppingCartOutline, + icon: DQIcons.cart_menu_icon, + activeIcon: DQIcons.cart_menu_icon, changeIndex: _changeIndex, index: widget.index, currentIndex: 3, diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart index f31fa588..76a829cd 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart @@ -38,14 +38,15 @@ class BottomNavPharmacyItem extends StatelessWidget { highlightColor: Colors.transparent, splashColor: Colors.transparent, onTap: () { - if(!Provider.of(context, listen: false).isLogin && (currentIndex == 2|| currentIndex == 3)) + if (!Provider.of(context, listen: false) + .isLogin && + (currentIndex == 2 || currentIndex == 3)) Navigator.push( context, FadePage(page: WelcomeLogin()), ); else - changeIndex(currentIndex); - + changeIndex(currentIndex); }, child: Column( mainAxisSize: MainAxisSize.min, From 185d66e342b2702140efb264565c21729d1d184c Mon Sep 17 00:00:00 2001 From: mosazaid Date: Tue, 5 Oct 2021 11:45:30 +0300 Subject: [PATCH 22/67] fix bugs pharmacy home --- .../pharmacy_module_view_model.dart | 46 +- lib/pages/landing/home_page.dart | 2 +- lib/pages/login/login.dart | 4 + .../screens/pharmacy_module_page.dart | 800 +----------------- .../widgets/{ => home}/BannerPager.dart | 11 +- .../widgets/home/BestSellerWidget.dart | 43 + .../widgets/home/GridViewButtons.dart | 81 ++ .../pharmacies/widgets/home/GridViewCard.dart | 78 ++ .../widgets/home/PrescriptionsWidget.dart | 233 +++++ .../widgets/home/RecentlyViewedWidget.dart | 45 + .../widgets/home/ShopByBrandWidget.dart | 40 + .../widgets/home/ViewAllHomeWidget.dart | 44 + 12 files changed, 606 insertions(+), 821 deletions(-) rename lib/pages/pharmacies/widgets/{ => home}/BannerPager.dart (88%) create mode 100644 lib/pages/pharmacies/widgets/home/BestSellerWidget.dart create mode 100644 lib/pages/pharmacies/widgets/home/GridViewButtons.dart create mode 100644 lib/pages/pharmacies/widgets/home/GridViewCard.dart create mode 100644 lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart create mode 100644 lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart create mode 100644 lib/pages/pharmacies/widgets/home/ShopByBrandWidget.dart create mode 100644 lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart diff --git a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart index b07585a8..3f986bcc 100644 --- a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart @@ -28,22 +28,18 @@ class PharmacyModuleViewModel extends BaseViewModel { List get recommendedProductList => _recommendedProductService.recommendedList; - Future getBannerList() async { - _pharmacyService.bannerItems.clear(); - // setState(ViewState.BusyLocal); - GifLoaderDialogUtils.showMyDialog( - locator().navigatorKey.currentContext); - await _pharmacyService.getBannerListList(); - GifLoaderDialogUtils.hideDialog( - locator().navigatorKey.currentContext); + Future generatePharmacyToken() async { + setState(ViewState.Busy); + await _pharmacyService.generatePharmacyToken(); if (_pharmacyService.hasError) { error = _pharmacyService.error; - setState(ViewState.Error); - } else + setState(ViewState.ErrorLocal); + } else { setState(ViewState.Idle); + } } - Future getPharmacyHomeData() async { + Future verifyCustomer() async { if (authenticatedUserObject.isLogin) await generatePharmacyToken(); var data = await sharedPref.getObject(USER_PROFILE); @@ -52,16 +48,7 @@ class PharmacyModuleViewModel extends BaseViewModel { setState(ViewState.Busy); if (authenticatedUserObject.isLogin && data != null && customerId == null) { await _pharmacyService.makeVerifyCustomer(data); - if (_pharmacyService.hasError) { - error = _pharmacyService.error; - setState(ViewState.Error); - } } - } - - Future createUser() async { - setState(ViewState.Busy); - await _pharmacyService.createUser(); if (_pharmacyService.hasError) { error = _pharmacyService.error; setState(ViewState.ErrorLocal); @@ -70,9 +57,9 @@ class PharmacyModuleViewModel extends BaseViewModel { } } - Future generatePharmacyToken() async { + Future createUser() async { setState(ViewState.Busy); - await _pharmacyService.generatePharmacyToken(); + await _pharmacyService.createUser(); if (_pharmacyService.hasError) { error = _pharmacyService.error; setState(ViewState.ErrorLocal); @@ -81,6 +68,21 @@ class PharmacyModuleViewModel extends BaseViewModel { } } + Future getBannerList() async { + if (bannerList.isEmpty) { + GifLoaderDialogUtils.showMyDialog( + locator().navigatorKey.currentContext); + await _pharmacyService.getBannerListList(); + GifLoaderDialogUtils.hideDialog( + locator().navigatorKey.currentContext); + if (_pharmacyService.hasError) { + error = _pharmacyService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + } + List getBannerImagesUrl() { List images = List(); images.add('assets/images/pharmacy_module/pharmacy_logo_green.png'); diff --git a/lib/pages/landing/home_page.dart b/lib/pages/landing/home_page.dart index 9ba5ad9c..a34f3b57 100644 --- a/lib/pages/landing/home_page.dart +++ b/lib/pages/landing/home_page.dart @@ -826,7 +826,7 @@ class _HomePageState extends State { GifLoaderDialogUtils.showMyDialog(context); await pharmacyModuleViewModel.generatePharmacyToken().then((value) async { if (pharmacyModuleViewModel.error.isNotEmpty) { - await pharmacyModuleViewModel.createUser().then((value) { + await pharmacyModuleViewModel.verifyCustomer().then((value) { GifLoaderDialogUtils.hideDialog(context); Navigator.push(context, FadePage(page: LandingPagePharmacy())); }); diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index 70627f8d..2fc2100c 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -68,6 +68,10 @@ class _Login extends State { if(BASE_URL.contains("uat.")){ nationalIDorFile.text = "2001273"; mobileNumberController.text = mobileNo = "0555416043"; + } else { + // TODO Mousa Sheeeloh + nationalIDorFile.text = "3376044"; + mobileNumberController.text = mobileNo = "0555416575"; } } diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 2136f589..755b5cef 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -13,8 +13,13 @@ import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_h import 'package:diplomaticquarterapp/pages/offers_categorise_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product-brands.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/recommended-product-page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/widgets/BannerPager.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/BannerPager.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductTileItem.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/PrescriptionsWidget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/ShopByBrandWidget.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/manufacturerItem.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; @@ -72,796 +77,3 @@ class _PharmacyPageState extends State { ); } } - -class GridViewButtons extends StatelessWidget { - final PharmacyModuleViewModel model; - - GridViewButtons(this.model); - - @override - Widget build(BuildContext context) { - final gridHeight = (MediaQuery.of(context).size.width * 0.3) * 1.8; - return Container( - child: SizedBox( - height: gridHeight, - child: GridView.count( - childAspectRatio: 2.2, - crossAxisSpacing: 10, - mainAxisSpacing: 10, - controller: new ScrollController(keepScrollOffset: false), - shrinkWrap: true, - padding: const EdgeInsets.all(4.0), - crossAxisCount: 2, - children: [ - DashboardItem( - imageName: 'pharmacy_module/bg_1.png', - hasColorFilter: false, - opacity: 0.8, - child: GridViewCard( - TranslationBase.of(context).offersAndPromotions, - 'assets/images/pharmacy_module/offer_icon.png', () { - Navigator.push(context, FadePage(page: OffersCategorisePage())); - }), - ), - DashboardItem( - imageName: 'pharmacy_module/bg_2.png', - opacity: 0, - hasColorFilter: false, - child: GridViewCard(TranslationBase.of(context).medicationRefill, - 'assets/images/pharmacy_module/medication_icon.png', () { - // model.checkUserIsActivated().then((isActivated) { - // if (isActivated) { - // Navigator.push(context, FadePage(page: LakumMainPage())); - // } else { - // Navigator.push( - // context, FadePage(page: LakumActivationVidaPage())); - // } - // }); - }), - ), - DashboardItem( - imageName: 'pharmacy_module/bg_3.png', - opacity: 0, - hasColorFilter: false, - child: GridViewCard(TranslationBase.of(context).myPrescriptions, - 'assets/images/pharmacy_module/prescription_icon.png', () { - Navigator.push( - context, FadePage(page: HomePrescriptionsPage())); - }), - ), - DashboardItem( - imageName: 'pharmacy_module/bg_4.png', - opacity: 0, - hasColorFilter: false, - child: GridViewCard( - TranslationBase.of(context).searchAndScanMedication, - 'assets/images/pharmacy_module/search_scan_icon.png', - () {}), - ), - ], - ), - ), - ); - } -} - -class GridViewCard extends StatelessWidget { - final String text; - final String cardImage; - final Function handler; - - GridViewCard(this.text, this.cardImage, this.handler); - - @override - Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.all(4.0), - child: Container( - child: Row( - children: [ - Expanded( - flex: 2, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 2, - child: Padding( - padding: const EdgeInsets.all(6), - child: Texts( - text, - color: Colors.white, - fontSize: SizeConfig.textMultiplier * 1.5, - ), - ), - ), - Row( - children: [ - BorderedButton( - TranslationBase.of(context).viewAll, - handler: handler, - tPadding: 0, - bPadding: 0, - ), - Expanded(child: Container()), - ], - ), - ], - ), - ), - Expanded( - child: Align( - alignment: Alignment.centerRight, - child: Image.asset( - cardImage, - fit: BoxFit.cover, - ), - ), - ), - ], - ), - ), - ); - } - - String getDate(String date) { - DateTime dateObj = DateUtil.convertStringToDate(date); - return DateUtil.getWeekDay(dateObj.weekday) + - ", " + - dateObj.day.toString() + - " " + - DateUtil.getMonth(dateObj.month) + - " " + - dateObj.year.toString(); - } -} - -class PrescriptionsWidget extends StatelessWidget { - @override - Widget build(BuildContext context) { - return BaseView( - onModelReady: (model) async { - if (Provider.of(context, listen: false).isLogin) { - model.getPrescription(); - } - }, - allowAny: true, - builder: (_, model, wi) => model.prescriptionsList.length > 0 - ? NetworkBaseView( - isLocalLoader: true, - baseViewModel: model, - child: Container( - height: model.prescriptionsList.length > 0 - ? MediaQuery.of(context).size.height * 0.28 - : 0, - child: Column( - children: [ - Container( - margin: EdgeInsets.fromLTRB(10, 10, 10, 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).myPrescription, - bold: true, - ), - BorderedButton( - TranslationBase.of(context).viewAll, - hasBorder: true, - borderColor: Colors.green, - textColor: Colors.green, - vPadding: 6, - hPadding: 4, - handler: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - HomePrescriptionsPage())); - }, - ), - ], - ), - ), - Container( - padding: EdgeInsets.symmetric( - horizontal: 18.0, vertical: 14.0), - margin: EdgeInsets.only(left: 10), - child: ListView.builder( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - physics: ScrollPhysics(), - // physics: NeverScrollableScrollPhysics(), - itemCount: model.prescriptionsList.length, - itemBuilder: (context, index) { - return Container( - height: MediaQuery.of(context).size.height * 0.3, - padding: EdgeInsets.only( - bottom: 5.0, left: 5.0, right: 8.0), - margin: EdgeInsets.only(right: 10.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: [ - Column(children: [ - Container( - padding: EdgeInsets.only( - top: 10.0, - left: 10.0, - right: 10.0, - bottom: 15.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: 4.0, - ), - 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, - ), - )), - 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, - ), - ) - ]), - ], - ), - ], - ), - 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, - ), - ), - Text( - model.prescriptionsList[index] - .doctorName - .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, - ), - ), - ) - ]), - ]), - ); - }), - ), - ], - ), - ), - ) - : Container(), - ); - } -} - -class ShopByBrandWidget extends StatelessWidget { - @override - Widget build(BuildContext context) { - return BaseView( - onModelReady: (model) => model.getTopManufacturerList(), - allowAny: true, - builder: (_, model, wi) => NetworkBaseView( - isLocalLoader: true, - baseViewModel: model, - child: Container( - child: Column( - children: [ - Container( - margin: EdgeInsets.fromLTRB(10, 10, 10, 0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).shopByBrands, - bold: true, - ), - BorderedButton( - TranslationBase.of(context).viewAll, - hasBorder: true, - vPadding: 6, - hPadding: 4, - borderColor: Colors.green, - textColor: Colors.green, - handler: () => { - Navigator.push( - context, FadePage(page: ProductBrandsPage())), - }, - ), - ], - ), - ), - Container( - height: 100, - child: ListView.builder( - itemBuilder: (ctx, i) => - ManufacturerItem(model.manufacturerList[i]), - scrollDirection: Axis.horizontal, - itemCount: model.manufacturerList.length, - ), - ), - ], - ), - ), - )); - } -} - -class RecentlyViewedWidget extends StatelessWidget { - @override - Widget build(BuildContext context) { - return BaseView( - onModelReady: (model) => model.getLastVisitedProducts(), - allowAny: true, - builder: (_, model, wi) => NetworkBaseView( - isLocalLoader: true, - baseViewModel: model, - child: Container( - child: Column( - children: [ - Container( - margin: EdgeInsets.fromLTRB(10, 10, 10, 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).recentlyViewed, - bold: true, - ), - BorderedButton( - TranslationBase.of(context).viewAll, - hasBorder: true, - vPadding: 6, - hPadding: 4, - borderColor: Colors.green, - textColor: Colors.green, - handler: () { - Navigator.push( - context, - FadePage( - page: FinalProductsPage( - id: "", - productType: 3, - ), - ), - ); - }, - ), - ], - ), - ), - Container( - height: model.lastVisitedProducts.length > 0 - ? MediaQuery.of(context).size.height / 4 + 20 - : 0, - child: ListView.builder( - itemBuilder: (ctx, i) => - ProductTileItem(model.lastVisitedProducts[i]), - scrollDirection: Axis.horizontal, - itemCount: model.lastVisitedProducts.length, - ), - ), - ], - ), - ), - )); - } -} - -class BestSellerWidget extends StatelessWidget { - @override - Widget build(BuildContext context) { - return BaseView( - onModelReady: (model) => model.getBestSellerProducts(), - allowAny: true, - builder: (_, model, wi) => NetworkBaseView( - isLocalLoader: true, - baseViewModel: model, - child: Container( - child: Column( - children: [ - Container( - margin: EdgeInsets.fromLTRB(10, 10, 10, 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).bestSellers, - bold: true, - ), - BorderedButton( - TranslationBase.of(context).viewAll, - hasBorder: true, - borderColor: Colors.green, - textColor: Colors.green, - vPadding: 6, - hPadding: 4, - handler: () => { - Navigator.push( - context, - FadePage( - page: FinalProductsPage( - id: "", - productType: 20, - ), - ), - ), - }, - ), - ], - ), - ), - Container( - height: MediaQuery.of(context).size.height / 4 + 20, - child: ListView.builder( - itemBuilder: (ctx, i) => - ProductTileItem(model.bestSellerProduct[i]), - scrollDirection: Axis.horizontal, - itemCount: model.bestSellerProduct.length, - ), - ), - ], - ), - ), - )); - } -} - -// Container( -// margin: EdgeInsets.fromLTRB(10, 10, 10, 10), -// child: Row( -// mainAxisAlignment: MainAxisAlignment.spaceBetween, -// children: [ -// Texts( -// TranslationBase.of(context).recommended, -// bold: true, -// ), -// BorderedButton( -// TranslationBase.of(context).viewAll, -// hasBorder: true, -// borderColor: Colors.green, -// textColor: Colors.green, -// vPadding: 6, -// hPadding: 4, -// handler: () { -// Navigator.push( -// context, -// MaterialPageRoute( -// builder: (context) => -// RecommendedProductPage(productId : "2316"))); -// }, -// ), -// ], -// ), -// ), -// Container( -// height: model.recommendedProductList.length > 0 -// ? MediaQuery.of(context).size.height * 0.32 -// : 0, -// margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4), -//// padding: EdgeInsets.symmetric(horizontal: 5.0, vertical: 22.0), -//// margin: EdgeInsets.only(left: 10), -// child: BaseView( -// onModelReady: (model) => -// model.getRecommendedProducts(productId), -// builder: (_, model, wi) => model -// .recommendedProductList.length != -// null -// ? ListView.builder( -// scrollDirection: Axis.horizontal, -// shrinkWrap: true, -// physics: ScrollPhysics(), -// // physics: NeverScrollableScrollPhysics(), -// itemCount: model.recommendedProductList.length, -// itemBuilder: (context, index) { -// return Card( -// elevation: 2, -// shape: RoundedRectangleBorder( -// side: BorderSide( -// color: Colors.grey[300], width: 2), -// borderRadius: BorderRadius.circular(10)), -// margin: EdgeInsets.symmetric( -// horizontal: 8, -// vertical: 0, -// ), -// child: Container( -// decoration: BoxDecoration( -// borderRadius: BorderRadius.all( -// Radius.circular(15), -// ), -// ), -// padding: EdgeInsets.symmetric(horizontal: 4), -// width: MediaQuery.of(context).size.width / 3, -// child: Column( -// crossAxisAlignment: -// CrossAxisAlignment.start, -// children: [ -// Stack(children: [ -// Container( -// child: Align( -// alignment: Alignment.topRight, -// child: //true -// itemID.contains(model.recommendedProductList[index].id) -// // !isInWishlist -// ? IconButton( -// icon: Icon(Icons -// .favorite_border), -// color: Colors.grey, -// iconSize: 30, -// onPressed: () { -// setState(() { -// addToWishlistFunction( -// itemID); -// }); -// }, -// ) -// : IconButton( -// icon: Icon( -// Icons.favorite), -// color: Colors.red, -// iconSize: 30, -// onPressed: () { -// setState(() { -// deleteFromWishlistFunction( -// itemID); -// }); -// }, -// ) -//// -// ), -// ), -// Container( -// margin: EdgeInsets.fromLTRB( -// 0, 16, 10, 16), -// alignment: Alignment.center, -//// padding: EdgeInsets.only(left: 25, bottom: 20), -// child: (model.recommendedProductList[index].images != null && -// model.recommendedProductList[index].images.length > 0) -// ? Image.network( -// model.recommendedProductList[index].images[0].src.toString(), -//// item.images[0].src, -// fit: BoxFit.cover, -// height: 60, -// ) -// : Image.asset( -// "assets/images/no_image.png", -// fit: BoxFit.cover, -// height: 60, -// ), -// ), -// Container( -// width: model -// .recommendedProductList[ -// 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.recommendedProductList[index] -// .rxMessage != -// null -// ? model -// .recommendedProductList[ -// 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: [ -// Text( -// languageID == "ar" -// ? model.recommendedProductList[index].namen -// : model.recommendedProductList[index].name, -// style: TextStyle( -// color: Colors.black, -// fontSize: 13.0, -//// fontWeight: FontWeight.bold, -// ), -// ), -// Padding( -//// padding: const EdgeInsets.only(top: 15, bottom: 10), -// padding: const EdgeInsets.only( -// top: 10, bottom: 5), -// child: Texts( -// "SAR ${model.recommendedProductList[index].price}", -// bold: true, -// fontSize: 14, -// ), -// ), -// ], -// ), -// ), -// Row( -// crossAxisAlignment: -// CrossAxisAlignment.start, -// children: [ -// Container( -// padding: -// EdgeInsets.only(right: 10), -//// margin: EdgeInsets.only(left: 5), -// child: Align( -// alignment: Alignment.topLeft, -// child: RatingBar.readOnly( -// initialRating: model -// .recommendedProductList[ -// index] -// .approvedRatingSum -// .toDouble(), -//// initialRating: productRate, -// size: 13.0, -// filledColor: -// Colors.yellow[700], -// emptyColor: Colors.grey[500], -// isHalfAllowed: true, -// halfFilledIcon: -// Icons.star_half, -// filledIcon: Icons.star, -// emptyIcon: Icons.star, -// ), -// ), -// ), -// Texts( -// "(${model.recommendedProductList[index].approvedTotalReviews.toString()})", -//// bold: true, -// fontSize: 12, -// ), -// ]), -// ], -// ), -// ), -// ); -// }) -// : Container( -//// child: Text("NO DATA"), -// ), -// ), -// ), diff --git a/lib/pages/pharmacies/widgets/BannerPager.dart b/lib/pages/pharmacies/widgets/home/BannerPager.dart similarity index 88% rename from lib/pages/pharmacies/widgets/BannerPager.dart rename to lib/pages/pharmacies/widgets/home/BannerPager.dart index b088eefb..29d409eb 100644 --- a/lib/pages/pharmacies/widgets/BannerPager.dart +++ b/lib/pages/pharmacies/widgets/home/BannerPager.dart @@ -1,3 +1,4 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; import 'package:diplomaticquarterapp/pages/offers_categorise_page.dart'; @@ -43,7 +44,8 @@ class _BannerPagerState extends State { .mapIndexed( (item, index) => InkWell( onTap: () { - Navigator.push(context, FadePage(page: OffersCategorisePage())); + Navigator.push( + context, FadePage(page: OffersCategorisePage())); }, child: Container( margin: EdgeInsets.symmetric(horizontal: 1.0), @@ -55,10 +57,11 @@ class _BannerPagerState extends State { item, fit: BoxFit.cover, ) - : Image.network( - item, + : CachedNetworkImage( + imageUrl: item, fit: BoxFit.cover, - ), + errorWidget: (context, url, error) => + SizedBox()), ), ), ), diff --git a/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart b/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart new file mode 100644 index 00000000..5784acaa --- /dev/null +++ b/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart @@ -0,0 +1,43 @@ +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BestSellerViewModel.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:flutter/material.dart'; + +import '../../../final_products_page.dart'; +import '../ProductTileItem.dart'; +import 'ViewAllHomeWidget.dart'; + +class BestSellerWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getBestSellerProducts(), + allowAny: true, + builder: (_, model, wi) => NetworkBaseView( + isLocalLoader: true, + baseViewModel: model, + child: Container( + child: Column( + children: [ + ViewAllHomeWidget( + TranslationBase.of(context).bestSellers, + FinalProductsPage( + id: "", + productType: 20, + )), + Container( + height: MediaQuery.of(context).size.height / 4 + 20, + child: ListView.builder( + itemBuilder: (ctx, i) => + ProductTileItem(model.bestSellerProduct[i]), + scrollDirection: Axis.horizontal, + itemCount: model.bestSellerProduct.length, + ), + ), + ], + ), + ), + )); + } +} diff --git a/lib/pages/pharmacies/widgets/home/GridViewButtons.dart b/lib/pages/pharmacies/widgets/home/GridViewButtons.dart new file mode 100644 index 00000000..5d979136 --- /dev/null +++ b/lib/pages/pharmacies/widgets/home/GridViewButtons.dart @@ -0,0 +1,81 @@ +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; +import 'package:diplomaticquarterapp/pages/landing/home_page.dart'; +import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; + +import '../../../offers_categorise_page.dart'; +import 'GridViewCard.dart'; + +class GridViewButtons extends StatelessWidget { + final PharmacyModuleViewModel model; + + GridViewButtons(this.model); + + @override + Widget build(BuildContext context) { + final gridHeight = (MediaQuery.of(context).size.width * 0.3) * 1.8; + return Container( + child: SizedBox( + height: gridHeight, + child: GridView.count( + childAspectRatio: 2.2, + crossAxisSpacing: 10, + mainAxisSpacing: 10, + controller: new ScrollController(keepScrollOffset: false), + shrinkWrap: true, + padding: const EdgeInsets.all(4.0), + crossAxisCount: 2, + children: [ + DashboardItem( + imageName: 'pharmacy_module/bg_1.png', + hasColorFilter: false, + opacity: 0.8, + child: GridViewCard( + TranslationBase.of(context).offersAndPromotions, + 'assets/images/pharmacy_module/offer_icon.png', () { + Navigator.push(context, FadePage(page: OffersCategorisePage())); + }), + ), + DashboardItem( + imageName: 'pharmacy_module/bg_2.png', + opacity: 0, + hasColorFilter: false, + child: GridViewCard(TranslationBase.of(context).medicationRefill, + 'assets/images/pharmacy_module/medication_icon.png', () { + // model.checkUserIsActivated().then((isActivated) { + // if (isActivated) { + // Navigator.push(context, FadePage(page: LakumMainPage())); + // } else { + // Navigator.push( + // context, FadePage(page: LakumActivationVidaPage())); + // } + // }); + }), + ), + DashboardItem( + imageName: 'pharmacy_module/bg_3.png', + opacity: 0, + hasColorFilter: false, + child: GridViewCard(TranslationBase.of(context).myPrescriptions, + 'assets/images/pharmacy_module/prescription_icon.png', () { + Navigator.push( + context, FadePage(page: HomePrescriptionsPage())); + }), + ), + DashboardItem( + imageName: 'pharmacy_module/bg_4.png', + opacity: 0, + hasColorFilter: false, + child: GridViewCard( + TranslationBase.of(context).searchAndScanMedication, + 'assets/images/pharmacy_module/search_scan_icon.png', + () {}), + ), + ], + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/pages/pharmacies/widgets/home/GridViewCard.dart b/lib/pages/pharmacies/widgets/home/GridViewCard.dart new file mode 100644 index 00000000..99425aa1 --- /dev/null +++ b/lib/pages/pharmacies/widgets/home/GridViewCard.dart @@ -0,0 +1,78 @@ +import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:flutter/material.dart'; + +class GridViewCard extends StatelessWidget { + final String text; + final String cardImage; + final Function handler; + + GridViewCard(this.text, this.cardImage, this.handler); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(4.0), + child: Container( + child: Row( + children: [ + Expanded( + flex: 2, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + flex: 2, + child: Padding( + padding: const EdgeInsets.all(6), + child: Texts( + text, + color: Colors.white, + fontSize: SizeConfig.textMultiplier * 1.5, + ), + ), + ), + Row( + children: [ + BorderedButton( + TranslationBase.of(context).viewAll, + handler: handler, + tPadding: 0, + bPadding: 0, + ), + Expanded(child: Container()), + ], + ), + ], + ), + ), + Expanded( + child: Align( + alignment: Alignment.centerRight, + child: Image.asset( + cardImage, + fit: BoxFit.cover, + ), + ), + ), + ], + ), + ), + ); + } + + String getDate(String date) { + DateTime dateObj = DateUtil.convertStringToDate(date); + return DateUtil.getWeekDay(dateObj.weekday) + + ", " + + dateObj.day.toString() + + " " + + DateUtil.getMonth(dateObj.month) + + " " + + dateObj.year.toString(); + } +} \ No newline at end of file diff --git a/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart new file mode 100644 index 00000000..28556679 --- /dev/null +++ b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart @@ -0,0 +1,233 @@ +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PrescriptionViewModel.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_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/buttons/borderedButton.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +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'; + +class PrescriptionsWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) async { + if (Provider.of(context, listen: false).isLogin) { + model.getPrescription(); + } + }, + allowAny: true, + builder: (_, model, wi) => model.prescriptionsList.length > 0 + ? NetworkBaseView( + isLocalLoader: true, + baseViewModel: model, + child: Container( + height: model.prescriptionsList.length > 0 + ? MediaQuery.of(context).size.height * 0.28 + : 0, + child: Column( + children: [ + ViewAllHomeWidget( + TranslationBase.of(context).myPrescription, + HomePrescriptionsPage()), + Container( + padding: EdgeInsets.symmetric( + horizontal: 18.0, vertical: 14.0), + margin: EdgeInsets.only(left: 10), + child: ListView.builder( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + physics: ScrollPhysics(), + // physics: NeverScrollableScrollPhysics(), + itemCount: model.prescriptionsList.length, + itemBuilder: (context, index) { + return Container( + height: MediaQuery.of(context).size.height * 0.3, + padding: EdgeInsets.only( + bottom: 5.0, left: 5.0, right: 8.0), + margin: EdgeInsets.only(right: 10.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: [ + Column(children: [ + Container( + padding: EdgeInsets.only( + top: 10.0, + left: 10.0, + right: 10.0, + bottom: 15.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: 4.0, + ), + 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, + ), + )), + 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, + ), + ) + ]), + ], + ), + ], + ), + 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, + ), + ), + Text( + model.prescriptionsList[index] + .doctorName + .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, + ), + ), + ) + ]), + ]), + ); + }), + ), + ], + ), + ), + ) + : Container(), + ); + } +} diff --git a/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart b/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart new file mode 100644 index 00000000..b07c6da6 --- /dev/null +++ b/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart @@ -0,0 +1,45 @@ +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/LastVisitedViewModel.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:flutter/material.dart'; + +import '../../../final_products_page.dart'; +import '../ProductTileItem.dart'; +import 'ViewAllHomeWidget.dart'; + +class RecentlyViewedWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getLastVisitedProducts(), + allowAny: true, + builder: (_, model, wi) => NetworkBaseView( + isLocalLoader: true, + baseViewModel: model, + child: Container( + child: Column( + children: [ + ViewAllHomeWidget( + TranslationBase.of(context).recentlyViewed, + FinalProductsPage( + id: "", + productType: 3, + )), + Container( + height: model.lastVisitedProducts.length > 0 + ? MediaQuery.of(context).size.height / 4 + 20 + : 0, + child: ListView.builder( + itemBuilder: (ctx, i) => + ProductTileItem(model.lastVisitedProducts[i]), + scrollDirection: Axis.horizontal, + itemCount: model.lastVisitedProducts.length, + ), + ), + ], + ), + ), + )); + } +} \ No newline at end of file diff --git a/lib/pages/pharmacies/widgets/home/ShopByBrandWidget.dart b/lib/pages/pharmacies/widgets/home/ShopByBrandWidget.dart new file mode 100644 index 00000000..3d892a43 --- /dev/null +++ b/lib/pages/pharmacies/widgets/home/ShopByBrandWidget.dart @@ -0,0 +1,40 @@ +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BrandViewModel.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:flutter/material.dart'; + +import '../../product-brands.dart'; +import '../manufacturerItem.dart'; +import 'ViewAllHomeWidget.dart'; + +class ShopByBrandWidget extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getTopManufacturerList(), + allowAny: true, + builder: (_, model, wi) => NetworkBaseView( + isLocalLoader: true, + baseViewModel: model, + child: Container( + child: Column( + children: [ + ViewAllHomeWidget( + TranslationBase.of(context).shopByBrands, + ProductBrandsPage()), + Container( + height: 100, + child: ListView.builder( + itemBuilder: (ctx, i) => + ManufacturerItem(model.manufacturerList[i]), + scrollDirection: Axis.horizontal, + itemCount: model.manufacturerList.length, + ), + ), + ], + ), + ), + )); + } +} \ No newline at end of file diff --git a/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart b/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart new file mode 100644 index 00000000..25981466 --- /dev/null +++ b/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart @@ -0,0 +1,44 @@ +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:flutter/material.dart'; + +class ViewAllHomeWidget extends StatelessWidget { + + final String title; + final Widget navigationWidget; + + + ViewAllHomeWidget(this.title, this.navigationWidget); + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.fromLTRB(10, 10, 10, 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + title, + bold: true, + ), + BorderedButton( + TranslationBase.of(context).viewAll, + hasBorder: true, + borderColor: Colors.green, + textColor: Colors.green, + vPadding: 6, + hPadding: 4, + handler: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + navigationWidget)); + }, + ), + ], + ), + ); + } +} From d5f1a162c0be57cd4de91678c37a44bf4f84a7b1 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 5 Oct 2021 12:13:33 +0300 Subject: [PATCH 23/67] replace bottom sheet button --- .../screens/product-details/details_info.dart | 15 +-- .../product-details/footer-widget.dart | 112 ++++++------------ .../product-details/product-detail.dart | 39 +++--- .../product-name-and-price.dart | 5 +- lib/widgets/buttons/secondary_button.dart | 7 +- 5 files changed, 73 insertions(+), 105 deletions(-) diff --git a/lib/pages/pharmacies/screens/product-details/details_info.dart b/lib/pages/pharmacies/screens/product-details/details_info.dart index a347e941..bc5e7f80 100644 --- a/lib/pages/pharmacies/screens/product-details/details_info.dart +++ b/lib/pages/pharmacies/screens/product-details/details_info.dart @@ -1,6 +1,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -22,13 +23,11 @@ class DetailsInfo extends StatelessWidget { CrossAxisAlignment.start, children: [ Container( - child: Text( + child: Texts( TranslationBase.of(context) .description, - style: TextStyle( - fontSize: 17, - color: Colors.grey, - fontWeight: FontWeight.w600), + fontSize: 17, + color: Colors.grey, ), ), SizedBox( @@ -39,15 +38,13 @@ class DetailsInfo extends StatelessWidget { height: 15, ), Container( - child: Text( + child: Texts( projectViewModel.isArabic ? product.fullDescriptionn : product .fullDescription ?? "", - style: TextStyle( - fontSize: 16, - fontFamily: 'WorkSans-Regular'), + fontSize: 16, ), ), SizedBox( diff --git a/lib/pages/pharmacies/screens/product-details/footer-widget.dart b/lib/pages/pharmacies/screens/product-details/footer-widget.dart index db048b46..72a76f39 100644 --- a/lib/pages/pharmacies/screens/product-details/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footer-widget.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -9,7 +10,7 @@ class FooterWidget extends StatefulWidget { final bool isAvailble; final int maxQuantity; final int minQuantity; - final int quantityLimit; + final int quantityLimit; final PharmacyProduct item; final Function addToCartFunction; @@ -403,84 +404,47 @@ class _FooterWidgetState extends State { }, ), ), - !widget.isAvailble && widget.price > 0 || - widget.price > widget.quantityLimit || - widget.item.rxMessage != null - ? Container( - width: 190, - height: 46, - color: Colors.grey, - child: Align( - alignment: Alignment.center, - child: Text( - TranslationBase.of(context).addToCart, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), - ), - ), - ) - : InkWell( - onTap: () { - widget.addToCartFunction(widget.price, widget.item.id, context); - }, - child: Container( - alignment: Alignment.center, - width: 190, - height: 46, - color: Colors.green, - child: Text( - TranslationBase.of(context).addToCart, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), - ), + + Container( + width: MediaQuery.of(context).size.width* 0.4, + child: SecondaryButton( + label: TranslationBase.of(context).addToCart.toUpperCase(), + disabled: !widget.isAvailble && widget.price > 0 || + widget.price > widget.quantityLimit || + widget.item.rxMessage != null, + onTap: () { + widget.addToCartFunction(widget.price, widget.item.id, context); + }, + borderRadius: 5, + color:Colors.green, + + ), ), + SizedBox( width: 5, ), - !widget.isAvailble && widget.price > 0 || - widget.price > widget.quantityLimit || - widget.item.rxMessage != null - ? Container( - width: 120, - height: 46, - color: Colors.grey, - child: Align( - alignment: Alignment.center, - child: Text( - TranslationBase.of(context).buyNow, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), - ), - ), - ) - : InkWell( - onTap: () { - print('buy now'); - widget.addToCartFunction(widget.price, widget.item.id, context); - Navigator.push( - context, - FadePage(page: CartOrderPage()), - ); - }, - child: Container( - alignment: Alignment.center, - width: 120, - height: 46, - color: Colors.blue, - child: Text( - TranslationBase.of(context).buyNow, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 15), - ), + + Container( + width: MediaQuery.of(context).size.width* 0.3, + child: SecondaryButton( + label: TranslationBase.of(context).buyNow.toUpperCase(), + disabled: !widget.isAvailble && widget.price > 0 || + widget.price > widget.quantityLimit || + widget.item.rxMessage != null, + onTap: () { + widget.addToCartFunction( + widget.price, widget.item.id, context); + Navigator.push( + context, + FadePage(page: CartOrderPage()), + ); + }, + borderRadius: 5, + color: !widget.isAvailble && widget.price > 0 || + widget.price > widget.quantityLimit || + widget.item.rxMessage != null?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 015e7958..2a1bfc3f 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -157,8 +157,7 @@ class __ProductDetailPageState extends State crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - - padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10), + padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10), child: Texts( TranslationBase.of(context).specification, fontSize: 15, @@ -349,22 +348,26 @@ class __ProductDetailPageState extends State ], ), ), - Row( - children: [ - customerId != null - ? Container( - width: 410, - height: 50, - color: Colors.white, - child: Texts( - TranslationBase.of(context).recommended, - bold: true, - ), - ) - : Container(), - ], - ), - RecommendedProducts(product: widget.product) + + ///TODO Elham* check if we need recommanded + // Row( + // children: [ + // customerId != null + // ? Container( + // width: 410, + // height: 50, + // color: Colors.white, + // child: Texts( + // TranslationBase.of(context).recommended, + // bold: true, + // ), + // ) + // : Container(), + // ], + // ), + // RecommendedProducts(product: widget.product) + + SizedBox(height: 80,) ], ), ), 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 14b94269..0be6a213 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 @@ -143,12 +143,13 @@ class _ProductNameAndPriceState extends State { ), SizedBox(width: 10,), Texts( - "${widget.item.approvedTotalReviews}", + "${widget.item.approvedRatingSum}", + fontWeight: FontWeight.bold, fontSize: 12, ), SizedBox(width: 30,), Texts( - "(${widget.item.approvedTotalReviews} ${TranslationBase.of(context).review})", + "(${widget.item.approvedTotalReviews}${TranslationBase.of(context).review})", fontSize: 12, ), ], diff --git a/lib/widgets/buttons/secondary_button.dart b/lib/widgets/buttons/secondary_button.dart index 8c4ba851..9d5df436 100644 --- a/lib/widgets/buttons/secondary_button.dart +++ b/lib/widgets/buttons/secondary_button.dart @@ -29,7 +29,7 @@ class SecondaryButton extends StatefulWidget { this.small = false, this.disabled = false, this.borderColor, - this.noBorderRadius = false}) + this.noBorderRadius = false, this.borderRadius}) : super(key: key); final String label; @@ -43,6 +43,9 @@ class SecondaryButton extends StatefulWidget { final bool iconOnly; final bool disabled; final bool noBorderRadius; + final double borderRadius; + + @override _SecondaryButtonState createState() => _SecondaryButtonState(); @@ -169,7 +172,7 @@ class _SecondaryButtonState extends State child: ClipRRect( borderRadius: widget.noBorderRadius ? BorderRadius.all(Radius.circular(0.0)) - : BorderRadius.all(Radius.circular(10.0)), + : BorderRadius.all(Radius.circular(widget.borderRadius??10.0)), child: Stack( children: [ Positioned( From e20e90c20cb4156f10c82d5d73f4fe6585d62303 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 5 Oct 2021 14:38:15 +0300 Subject: [PATCH 24/67] fix quantity_box --- .../product-details/footer-widget.dart | 456 ------------------ .../product-details/footor/footer-widget.dart | 240 +++++++++ .../product-details/footor/quantity_box.dart | 42 ++ .../product-details/product-detail.dart | 2 +- 4 files changed, 283 insertions(+), 457 deletions(-) delete mode 100644 lib/pages/pharmacies/screens/product-details/footer-widget.dart create mode 100644 lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart create mode 100644 lib/pages/pharmacies/screens/product-details/footor/quantity_box.dart diff --git a/lib/pages/pharmacies/screens/product-details/footer-widget.dart b/lib/pages/pharmacies/screens/product-details/footer-widget.dart deleted file mode 100644 index 72a76f39..00000000 --- a/lib/pages/pharmacies/screens/product-details/footer-widget.dart +++ /dev/null @@ -1,456 +0,0 @@ -import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; -import 'package:flutter/material.dart'; - -import '../cart-order-page.dart'; - -class FooterWidget extends StatefulWidget { - final bool isAvailble; - final int maxQuantity; - final int minQuantity; - final int quantityLimit; - final PharmacyProduct item; - final Function addToCartFunction; - - int price; - bool isOverQuantity; - - FooterWidget(this.isAvailble, this.maxQuantity, this.minQuantity, - this.quantityLimit, this.item, {this.price, this.isOverQuantity = false, this.addToCartFunction}); - - @override - _FooterWidgetState createState() => _FooterWidgetState(); -} - -class _FooterWidgetState extends State { - double quantityUI = 70; - bool showUI = false; - - @override - Widget build(BuildContext context) { - return Container( - width: double.infinity, - height: quantityUI, - color: Colors.white, - child: Column( - children: [ - showUI - ? Container( - width: double.infinity, - height: 90, - color: Colors.white, - child: Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - TranslationBase.of(context).quantity, - style: TextStyle( - fontSize: 15, fontWeight: FontWeight.bold), - ), - ), - - Container( - height: 50.0, - child: ListView( - scrollDirection: Axis.horizontal, - children: [ - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '1', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - widget.price = 1; - if (widget.price >= widget.quantityLimit) { - widget.isOverQuantity = true; - } else { - widget.isOverQuantity = false; - return widget.price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '2', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - widget.price = 2; - if (widget.price >= widget.quantityLimit) { - widget.isOverQuantity = true; - } else { - widget.isOverQuantity = false; - return widget.price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '3', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - widget.price = 3; - if (widget.price >= widget.quantityLimit) { - widget.isOverQuantity = true; - } else { - widget.isOverQuantity = false; - return widget.price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '4', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - widget.price = 4; - if (widget.price >= widget.quantityLimit) { - widget.isOverQuantity = true; - } else { - widget.isOverQuantity = false; - return widget.price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '5', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - widget.price = 5; - if (widget.price >= widget.quantityLimit) { - widget.isOverQuantity = true; - } else { - widget.isOverQuantity = false; - return widget.price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '6', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - widget.price = 6; - if (widget.price >= widget.quantityLimit) { - widget.isOverQuantity = true; - } else { - widget.isOverQuantity = false; - return widget.price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '7', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - widget.price = 7; - if (widget.price >= widget.quantityLimit) { - widget.isOverQuantity = true; - } else { - widget.isOverQuantity = false; - return widget.price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '8', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - widget.price = 8; - if (widget.price >= widget.quantityLimit) { - widget.isOverQuantity = true; - } else { - widget.isOverQuantity = false; - return widget.price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '9', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - widget.price = 9; - if (widget.price >= widget.quantityLimit) { - widget.isOverQuantity = true; - } else { - widget.isOverQuantity = false; - return widget.price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - InkWell( - child: Container( - alignment: Alignment.center, - width: 50.0, - color: Colors.white, - child: Text( - '10', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 20), - ), - ), - onTap: () { - setState(() { - widget.price = 10; - if (widget.price >= widget.quantityLimit) { - widget.isOverQuantity = true; - } else { - widget.isOverQuantity = false; - return widget.price; - } - }); - }, - ), - SizedBox( - width: 5, - ), - Container( - width: 50.0, - child: TextField( - decoration: - InputDecoration(labelText: 'quantity #'), - onChanged: (text) { - print(widget.price); - print(widget.quantityLimit); - if (int.tryParse(text) == null) { - text = ''; - } else { - setState(() { - widget.price = int.parse(text); - if (widget.price >= widget.quantityLimit) { - widget.isOverQuantity = true; - } else { - widget.isOverQuantity = false; - } - }); - } - }, - ), - ), - ], - ), - ) - ], - ), - ), - ) - : Container( - height: 20, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: 70, - height: 50, - child: FlatButton( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 4, - child: Text( - widget.price.toString(), - style: TextStyle(fontSize: 20), - ), - ), - Expanded( - flex: 5, - child: Text( - TranslationBase.of(context).quantityShortcut, - style: TextStyle(fontSize: 16), - ), - ), - ], - ), - onPressed: () { - setState(() { - if (showUI) { - quantityUI = 70; - showUI = false; - } else { - quantityUI = 150; - showUI = true; - } - }); - }, - ), - ), - - Container( - width: MediaQuery.of(context).size.width* 0.4, - child: SecondaryButton( - label: TranslationBase.of(context).addToCart.toUpperCase(), - disabled: !widget.isAvailble && widget.price > 0 || - widget.price > widget.quantityLimit || - widget.item.rxMessage != null, - onTap: () { - widget.addToCartFunction(widget.price, widget.item.id, context); - }, - borderRadius: 5, - color:Colors.green, - - - ), - ), - - SizedBox( - width: 5, - ), - - Container( - width: MediaQuery.of(context).size.width* 0.3, - child: SecondaryButton( - label: TranslationBase.of(context).buyNow.toUpperCase(), - disabled: !widget.isAvailble && widget.price > 0 || - widget.price > widget.quantityLimit || - widget.item.rxMessage != null, - onTap: () { - widget.addToCartFunction( - widget.price, widget.item.id, context); - Navigator.push( - context, - FadePage(page: CartOrderPage()), - ); - }, - borderRadius: 5, - color: !widget.isAvailble && widget.price > 0 || - widget.price > widget.quantityLimit || - widget.item.rxMessage != null?Colors.grey:Colors.grey[800], - ), - ), - ], - ), - ], - ), - ); - } -} \ No newline at end of file diff --git a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart new file mode 100644 index 00000000..cca4eef5 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -0,0 +1,240 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/footor/quantity_box.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; + +import '../../cart-order-page.dart'; + +class FooterWidget extends StatefulWidget { + final bool isAvailable; + final int maxQuantity; + final int minQuantity; + final int quantityLimit; + final PharmacyProduct item; + final Function addToCartFunction; + + int price; + bool isOverQuantity; + + FooterWidget(this.isAvailable, this.maxQuantity, this.minQuantity, + this.quantityLimit, this.item, + {this.price, this.isOverQuantity = false, this.addToCartFunction}); + + @override + _FooterWidgetState createState() => _FooterWidgetState(); +} + +class _FooterWidgetState extends State { + double quantityUI = 70; + bool showUI = false; + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(0.0), + ), + border: Border.all(color: HexColor('#707070'), width: 0), + ), + width: double.infinity, + height: quantityUI, + child: Column( + children: [ + showUI + ? Container( + width: double.infinity, + height: 100, + color: Colors.white, + child: Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 10, + ), + Row( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + "Quantity", + style: TextStyle( + fontSize: 15, fontWeight: FontWeight.bold), + ), + ), + InkWell( + child: Icon(Icons.close, color: Colors.black), + onTap: () { + setState(() { + quantityUI = 70; + showUI = false; + }); + }, + ) + ], + mainAxisAlignment: MainAxisAlignment.spaceBetween, + ), + Container( + height: 50.0, + child: ListView( + scrollDirection: Axis.horizontal, + children: [ + SizedBox( + width: 5, + ), + for (int i = 1; i <= 10; i++) + QuantityBox( + label: i, + onTapFunc: onChangeValue, + isSelected: widget.price == i), + Column( + children: [ + Container( + width: 100, + decoration: BoxDecoration( + border: + Border.all(color: Colors.grey[300]), + color: Colors.white, + ), + child: TextField( + decoration: InputDecoration( + labelText: 'quantity #'), + onChanged: (text) { + print(widget.price); + print(widget.quantityLimit); + if (int.tryParse(text) == null) { + text = ''; + } else { + setState(() { + widget.price = int.parse(text); + if (widget.price >= + widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.isOverQuantity = false; + } + }); + } + }, + ), + ), + ], + ), + ], + ), + ) + ], + ), + ), + ) + : Container( + height: 20, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 70, + height: 50, + child: FlatButton( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: 4, + child: Text( + widget.price.toString(), + style: TextStyle(fontSize: 20), + ), + ), + Expanded( + flex: 5, + child: Text( + TranslationBase.of(context).quantityShortcut, + style: TextStyle(fontSize: 16), + ), + ), + ], + ), + onPressed: () { + setState(() { + if (showUI) { + quantityUI = 70; + showUI = false; + } else { + quantityUI = 150; + showUI = true; + } + }); + }, + ), + ), + Container( + width: MediaQuery.of(context).size.width * 0.4, + child: SecondaryButton( + label: TranslationBase.of(context).addToCart.toUpperCase(), + disabled: !widget.isAvailable && widget.price > 0 || + widget.price > widget.quantityLimit || + widget.item.rxMessage != null, + onTap: () { + widget.addToCartFunction( + widget.price, widget.item.id, context); + }, + borderRadius: 5, + color: Colors.green, + ), + ), + SizedBox( + width: 5, + ), + Container( + width: MediaQuery.of(context).size.width * 0.3, + child: SecondaryButton( + label: TranslationBase.of(context).buyNow.toUpperCase(), + disabled: !widget.isAvailable && widget.price > 0 || + widget.price > widget.quantityLimit || + widget.item.rxMessage != null, + onTap: () { + widget.addToCartFunction( + widget.price, widget.item.id, context); + Navigator.push( + context, + FadePage(page: CartOrderPage()), + ); + }, + borderRadius: 5, + color: !widget.isAvailable && widget.price > 0 || + widget.price > widget.quantityLimit || + widget.item.rxMessage != null + ? Colors.grey + : Colors.grey[800], + ), + ), + ], + ), + ], + ), + ); + } + + onChangeValue(int i) { + setState(() { + ///TODO Elham* Check this if its good + widget.price = i; + if (widget.price >= widget.quantityLimit) { + widget.isOverQuantity = true; + } else { + widget.isOverQuantity = false; + return widget.price; + } + }); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/footor/quantity_box.dart b/lib/pages/pharmacies/screens/product-details/footor/quantity_box.dart new file mode 100644 index 00000000..35e69e0c --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/footor/quantity_box.dart @@ -0,0 +1,42 @@ +import 'package:flutter/material.dart'; + +class QuantityBox extends StatelessWidget { + final int label; + final bool isSelected; + final Function(int) onTapFunc; + + QuantityBox({ + Key key, + this.label, + this.onTapFunc, this.isSelected = false, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + InkWell( + child: Container( + decoration: BoxDecoration( + border: Border.all(color:isSelected?Colors.green: Colors.grey[300]), + color: Colors.white, + ), + alignment: Alignment.center, + width: 50.0, + + child: Text( + '$label', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + ), + ), + onTap:(){ + onTapFunc(label); + } + ), + SizedBox( + width: 5, + ) + ], + ); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 2a1bfc3f..71dbbddd 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -28,7 +28,7 @@ import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'availability_info.dart'; import 'details_info.dart'; import 'discount_description.dart'; -import 'footer-widget.dart'; +import 'footor/footer-widget.dart'; int price = 0; bool isOverQuantity = false; From f3000d0ee3470af81c55511bb3ae95b7063682b0 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 5 Oct 2021 14:54:09 +0300 Subject: [PATCH 25/67] My account design fix --- lib/pages/pharmacy/profile/profile.dart | 577 ++++++------------ lib/widgets/pharmacy/my_account_items.dart | 50 ++ lib/widgets/pharmacy/my_account_services.dart | 52 ++ 3 files changed, 301 insertions(+), 378 deletions(-) create mode 100644 lib/widgets/pharmacy/my_account_items.dart create mode 100644 lib/widgets/pharmacy/my_account_services.dart diff --git a/lib/pages/pharmacy/profile/profile.dart b/lib/pages/pharmacy/profile/profile.dart index 3cf28592..0854f4bc 100644 --- a/lib/pages/pharmacy/profile/profile.dart +++ b/lib/pages/pharmacy/profile/profile.dart @@ -19,7 +19,10 @@ import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/pharmacy/my_account_items.dart'; +import 'package:diplomaticquarterapp/widgets/pharmacy/my_account_services.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -98,7 +101,7 @@ class _ProfilePageState extends State { isPharmacy: true, body: user != null ? Container( - color: Colors.white, + color: Colors.white, child: SingleChildScrollView( child: Column( children: [ @@ -108,47 +111,56 @@ class _ProfilePageState extends State { Container( child: Row( children: [ - Container( - padding: EdgeInsets.only( - top: 20.0, - left: 10.0, - right: 10.0, - bottom: 10.0, - ), - child: LargeAvatar( - name: user.firstName.toString(), - url: '', + Padding( + padding: EdgeInsets.symmetric( + horizontal: 15.0, vertical: 8.0), + child: Container( + padding: EdgeInsets.only( + top: 20.0, + left: 10.0, + right: 10.0, + bottom: 10.0, + ), + child: LargeAvatar( + radius: 55.0, + name: user.firstName.toString(), + url: + 'https://thumbs.dreamstime.com/b/default-avatar-profile-vector-user-profile-default-avatar-profile-vector-user-profile-profile-179376714.jpg', + ), ), ), - Column(children: [ - Row(children: [ - Text( - TranslationBase.of(context) - .welcome, - style: TextStyle( - fontSize: 14.0, + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row(children: [ + Texts( + TranslationBase.of(context) + .welcome, + fontSize: 16.0, + ), + ]), + SizedBox( + height: 5.0, + ), + Row(children: [ + Texts( + languageID == "ar" + ? user.firstNameN + .toString() + + " " + + user.lastNameN + .toString() + : user.firstName + .toString() + + " " + + user.lastName + .toString(), + fontSize: 17.0, fontWeight: FontWeight.bold, - color: Colors.grey), - ), - ]), - SizedBox( - height: 10, - ), - Row(children: [ - Text( - languageID == "ar" - ? user.firstNameN.toString() + - " " + - user.lastNameN.toString() - : user.firstName.toString() + - " " + - user.lastName.toString(), - style: TextStyle( - fontSize: 14.0, - fontWeight: FontWeight.bold), - ), - ]), - ]), + ), + ]), + ]), ], ), ) @@ -168,125 +180,53 @@ class _ProfilePageState extends State { Container( child: Row( children: [ - Expanded( - child: InkWell( - onTap: () { - if (customerId == null) { - AppToast.showErrorToast( - message: "Customer not found"); - return; - } - Navigator.push( - context, - FadePage( - page: OrderPage( - customerID: customerId))); - }, - child: Column( - children: [ -// Image(image: AssetImage('assets/images/pharmacy/orders_icon.svg')), - SvgPicture.asset( - 'assets/images/pharmacy/orders_icon.svg', - width: 50, - height: 50, - ), - SizedBox( - height: 5, - ), - Text( - TranslationBase.of(context).orders, - style: TextStyle( - fontSize: 13.0, - fontWeight: FontWeight.bold, - ), - ), - ], - ), - ), + AccountServices( + title: TranslationBase.of(context).orders, + serviceImage: + 'assets/images/pharmacy/orders_icon.svg', + onTap: () { + if (customerId == null) { + AppToast.showErrorToast( + message: "Customer not found"); + return; + } + Navigator.push( + context, + FadePage( + page: OrderPage( + customerID: customerId))); + }, ), - Expanded( - child: InkWell( - onTap: () { - Navigator.push(context, - FadePage(page: LakumMainPage())); - }, - child: Column( - children: [ - SvgPicture.asset( - 'assets/images/pharmacy/lakum_icon.svg', - width: 50, - height: 50, - ), - SizedBox( - height: 5, - ), - Text( - TranslationBase.of(context).lakum, - style: TextStyle( - fontSize: 13.0, - fontWeight: FontWeight.bold), - ), - ], - ), - ), + AccountServices( + title: TranslationBase.of(context).lakum, + serviceImage: + 'assets/images/pharmacy/lakum_icon.svg', + onTap: () { + Navigator.push(context, + FadePage(page: LakumMainPage())); + }, ), - Expanded( - child: InkWell( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - WishlistPage(true))); - }, - child: Column( - children: [ - SvgPicture.asset( - 'assets/images/pharmacy/wishlist_icon.svg', - width: 50, - height: 50, - ), - SizedBox( - height: 5, - ), - Text( - TranslationBase.of(context).wishlist, - style: TextStyle( - fontSize: 13.0, - fontWeight: FontWeight.bold, - ), - ), - ], - ), - ), - ), - Expanded( - child: InkWell( - onTap: () { - Navigator.push(context, - FadePage(page: MyReviewsPage())); - }, - child: Column( - children: [ - SvgPicture.asset( - 'assets/images/pharmacy/review_icon.svg', - width: 50, - height: 50, - ), - SizedBox( - height: 5, - ), - Text( - TranslationBase.of(context).reviews, - style: TextStyle( - fontSize: 13.0, - fontWeight: FontWeight.bold, - ), - ), - ], - ), - ), + AccountServices( + title: TranslationBase.of(context).wishlist, + serviceImage: + 'assets/images/pharmacy/wishlist_icon.svg', + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + WishlistPage(true))); + }, ), + AccountServices( + title: TranslationBase.of(context).reviews, + serviceImage: + 'assets/images/pharmacy/review_icon.svg', + onTap: () { + Navigator.push(context, + FadePage(page: MyReviewsPage())); + }, + ) ], )), SizedBox( @@ -303,16 +243,13 @@ class _ProfilePageState extends State { height: 10, ), Container( - padding: EdgeInsets.only(left: 10.0), + padding: EdgeInsets.symmetric(horizontal: 25.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - TranslationBase.of(context).myAccount, - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.bold), - ), + Texts(TranslationBase.of(context).myAccount, + fontSize: 16.0, + fontWeight: FontWeight.bold), SizedBox( height: 10, ), @@ -327,24 +264,11 @@ class _ProfilePageState extends State { FadePage( page: HomePrescriptionsPage())); }, - child: Row( - children: [ - SvgPicture.asset( + child: AccountItem( + title: TranslationBase.of(context) + .myPrescription, + itemIcon: 'assets/images/pharmacy/my_prescription_icon.svg', - width: 28, - height: 28, - ), - SizedBox( - width: 15, - ), - Text( - TranslationBase.of(context) - .myPrescription, - style: TextStyle( - fontSize: 13.0, - ), - ), - ], ), ), SizedBox( @@ -355,28 +279,16 @@ class _ProfilePageState extends State { height: 20, ), InkWell( - onTap: () { - Navigator.push(context, - FadePage(page: ComparePage())); - }, - child: Row( - children: [ - Image.asset( - 'assets/images/pharmacy/compare.png', - width: 35, - height: 35), - SizedBox( - width: 15, - ), - Text( - TranslationBase.of(context).compare, - style: TextStyle( - fontSize: 13.0, - ), - ), - ], - ), - ), + onTap: () { + Navigator.push(context, + FadePage(page: ComparePage())); + }, + child: AccountItem( + isTerms: true, + title: TranslationBase.of(context) + .compare, + itemIcon: + "assets/images/pharmacy/compare.png")), SizedBox( height: 5, ), @@ -391,25 +303,11 @@ class _ProfilePageState extends State { FadePage( page: HomePrescriptionsPage())); }, - child: Row( - children: [ - SvgPicture.asset( - 'assets/images/pharmacy/medication_refill_icon.svg', - width: 30, - height: 30, - ), - SizedBox( - width: 20, - ), - Text( - TranslationBase.of(context) - .medicationsRefill, - style: TextStyle( - fontSize: 13.0, - ), - ), - ], - ), + child: AccountItem( + title: TranslationBase.of(context) + .medicationsRefill, + itemIcon: + 'assets/images/pharmacy/medication_refill_icon.svg'), ), SizedBox( height: 5, @@ -423,23 +321,10 @@ class _ProfilePageState extends State { Navigator.push( context, FadePage(page: MyFamily())); }, - child: Row( - children: [ - SvgPicture.asset( + child: AccountItem( + title: TranslationBase.of(context).family, + itemIcon: 'assets/images/pharmacy/my_family_icon.svg', - width: 20, - height: 20, - ), - SizedBox( - width: 20, - ), - Text( - TranslationBase.of(context).family, - style: TextStyle( - fontSize: 13.0, - ), - ), - ], ), ), SizedBox( @@ -456,24 +341,11 @@ class _ProfilePageState extends State { FadePage( page: PharmacyAddressesPage())); }, - child: Row( - children: [ - SvgPicture.asset( + child: AccountItem( + itemIcon: 'assets/images/pharmacy/shipping_addresses_icon.svg', - width: 30, - height: 30, - ), - SizedBox( - width: 20, - ), - Text( - TranslationBase.of(context) - .shippingAddresses, - style: TextStyle( - fontSize: 13.0, - ), - ), - ], + title: TranslationBase.of(context) + .shippingAddresses, ), ), SizedBox( @@ -484,32 +356,19 @@ class _ProfilePageState extends State { height: 20, ), InkWell( - onTap: () { - Navigator.push( - context, - FadePage( - page: PharmacyTermsConditions())); - }, - child: Row( - children: [ - Image.asset( - 'assets/images/pharmacy/terms.png', - width: 25, - height: 25, - ), - SizedBox( - width: 10, - ), - Text( - TranslationBase.of(context) + onTap: () { + Navigator.push( + context, + FadePage( + page: + PharmacyTermsConditions())); + }, + child: AccountItem( + isTerms: true, + title: TranslationBase.of(context) .conditionsHMG, - style: TextStyle( - fontSize: 13.0, - ), - ), - ], - ), - ), + itemIcon: + 'assets/images/pharmacy/terms.png')), SizedBox( height: 5, ), @@ -518,39 +377,24 @@ class _ProfilePageState extends State { height: 20, ), InkWell( - onTap: () { - Navigator.push( - context, - FadePage( - page: LakumTermsConditions( - this.identificationNo, - this.firstName, - this.lastName, - this.mobileNo, - this.languageId))); - }, - child: Row( - children: [ - Image.asset( - 'assets/images/pharmacy/terms.png', - width: 25, - height: 25, - ), -// IconButton(icon: Icon(Icons.error_outline), iconSize: 30, -// color: Colors.black,), - SizedBox( - width: 10, - ), - Text( - TranslationBase.of(context) - .conditions, - style: TextStyle( - fontSize: 13.0, - ), - ), - ], - ), - ), + onTap: () { + Navigator.push( + context, + FadePage( + page: LakumTermsConditions( + this.identificationNo, + this.firstName, + this.lastName, + this.mobileNo, + this.languageId))); + }, + child: AccountItem( + title: TranslationBase.of(context) + .conditions, + itemIcon: + 'assets/images/pharmacy/terms.png', + isTerms: true, + )), ], ), ), @@ -567,77 +411,54 @@ class _ProfilePageState extends State { SizedBox( height: 10, ), - Container( - padding: EdgeInsets.only(left: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).reachUs, - style: TextStyle( + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 15.0, vertical: 8.0), + child: Container( + padding: EdgeInsets.only(left: 10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts(TranslationBase.of(context).reachUs, fontSize: 16.0, fontWeight: FontWeight.bold), - ), - SizedBox( - height: 5, - ), - Divider( - color: Colors.grey, - height: 20, - ), - InkWell( - onTap: () { - Navigator.push(context, - FadePage(page: LiveChatPage())); - }, - child: Row( - children: [ - SvgPicture.asset( - 'assets/images/pharmacy/contact_us_icon.svg', - width: 20, - height: 20, - ), - SizedBox( - width: 20, - ), - Text( - TranslationBase.of(context).contactUs, - style: TextStyle(fontSize: 13.0), - ), - ], + SizedBox( + height: 5, ), - ), - SizedBox( - height: 5, - ), - Divider( - color: Colors.grey, - height: 20, - ), - InkWell( - onTap: () { - Navigator.push(context, - FadePage(page: FindUsPage())); - }, - child: Row( - children: [ - SvgPicture.asset( - 'assets/images/pharmacy/our_locations_icon.svg', - width: 30, - height: 30, - ), - SizedBox( - width: 20, - ), - Text( - TranslationBase.of(context) - .ourLocations, - style: TextStyle(fontSize: 13.0), - ), - ], + Divider( + color: Colors.grey, + height: 20, ), - ) - ], + InkWell( + onTap: () { + Navigator.push(context, + FadePage(page: LiveChatPage())); + }, + child: AccountItem( + title: TranslationBase.of(context) + .contactUs, + itemIcon: + 'assets/images/pharmacy/contact_us_icon.svg'), + ), + SizedBox( + height: 5, + ), + Divider( + color: Colors.grey, + height: 20, + ), + InkWell( + onTap: () { + Navigator.push(context, + FadePage(page: FindUsPage())); + }, + child: AccountItem( + title: TranslationBase.of(context) + .ourLocations, + itemIcon: + 'assets/images/pharmacy/our_locations_icon.svg')) + ], + ), ), ) ], diff --git a/lib/widgets/pharmacy/my_account_items.dart b/lib/widgets/pharmacy/my_account_items.dart new file mode 100644 index 00000000..bb514e57 --- /dev/null +++ b/lib/widgets/pharmacy/my_account_items.dart @@ -0,0 +1,50 @@ +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class AccountItem extends StatelessWidget { + final String title; + final String itemIcon; + final bool isTerms; + + const AccountItem({this.title, this.itemIcon, this.isTerms = false}); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + isTerms == false + ? Container( + height: 35.0, + width: 35.0, + child: SvgPicture.asset( + '$itemIcon', + width: 35, + height: 35, + ), + ) + : Container( + height: 35.0, + width: 35.0, + child: Image.asset( + '$itemIcon', + width: 35, + height: 35, + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + SizedBox( + width: 20, + ), + Texts( + title, + fontSize: 15.0, + ), + ], + ) + ], + ); + } +} diff --git a/lib/widgets/pharmacy/my_account_services.dart b/lib/widgets/pharmacy/my_account_services.dart new file mode 100644 index 00000000..e3b9948d --- /dev/null +++ b/lib/widgets/pharmacy/my_account_services.dart @@ -0,0 +1,52 @@ +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class AccountServices extends StatelessWidget { + final String title; + final String serviceImage; + final Function onTap; + + const AccountServices({this.title, this.onTap, this.serviceImage}); + + @override + Widget build(BuildContext context) { + return Expanded( + child: InkWell( + onTap: onTap, + // () { + // if (customerId == null) { + // AppToast.showErrorToast( + // message: "Customer not found"); + // return; + // } + // Navigator.push( + // context, + // FadePage( + // page: OrderPage( + // customerID: customerId))); + // }, + child: Column( + children: [ +// Image(image: AssetImage('assets/images/pharmacy/orders_icon.svg')), + SvgPicture.asset( + '$serviceImage', + width: 55, + height: 55, + ), + SizedBox( + height: 7, + ), + Texts( + title, + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ], + ), + ), + ); + } +} From bb96201c2e5ee6a02bc41a663d687fb669cbaad2 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 5 Oct 2021 15:15:17 +0300 Subject: [PATCH 26/67] remove the custom scaffold --- .../screens/product-details/CustomIcon.dart | 29 ++++++++ .../product-details/ProductAppBar.dart | 66 +++++++++++++++++++ .../product-details/product-detail.dart | 41 +++++++----- .../product-name-and-price.dart | 65 ++++++++++-------- lib/widgets/others/app_scaffold_widget.dart | 42 +++++++----- 5 files changed, 182 insertions(+), 61 deletions(-) create mode 100644 lib/pages/pharmacies/screens/product-details/CustomIcon.dart create mode 100644 lib/pages/pharmacies/screens/product-details/ProductAppBar.dart diff --git a/lib/pages/pharmacies/screens/product-details/CustomIcon.dart b/lib/pages/pharmacies/screens/product-details/CustomIcon.dart new file mode 100644 index 00000000..c9a71afa --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/CustomIcon.dart @@ -0,0 +1,29 @@ +import 'package:flutter/material.dart'; + +class IconWithBg extends StatelessWidget { + final IconData icon; + final Color color; + final Function onPress; + + const IconWithBg({Key key, this.icon, this.color, this.onPress}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.only(left: 25), + width: 40, + height: 40, + decoration: BoxDecoration( + color: Colors.grey[300], + borderRadius: BorderRadius.circular(30), + ), + child: IconButton( + icon: Icon(icon), + color: color, + onPressed: () async { + onPress(); + }, + )); + } +} diff --git a/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart b/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart new file mode 100644 index 00000000..36c43364 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart @@ -0,0 +1,66 @@ +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +import '../cart-order-page.dart'; +import 'CustomIcon.dart'; + +class ProductAppBar extends StatelessWidget with PreferredSizeWidget { + @override + Widget build(BuildContext context) { + return Container( + color: Colors.white, + child: Column( + children: [ + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + IconWithBg( + icon: Icons.arrow_back_ios, + color: Colors.grey, + onPress: () { + Navigator.pop(context); + }, + ), + ], + ), + Row( + children: [ + IconWithBg( + icon: Icons.shopping_cart, + color: Colors.grey, + onPress: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => CartOrderPage()), + ); + }), + IconWithBg( + icon: FontAwesomeIcons.ellipsisV, + color: Colors.grey, + onPress: () { + //TODO Elham* + // settingModalBottomSheet(context); + }, + ), + ], + ) + ], + ), + ], + ), + ); + } + + @override + // TODO: implement preferredSize + @override + Size get preferredSize => Size(double.maxFinite, 50); +} + + diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 71dbbddd..08a622aa 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -25,6 +25,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_mo import '../cart-order-page.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'ProductAppBar.dart'; import 'availability_info.dart'; import 'details_info.dart'; import 'discount_description.dart'; @@ -106,11 +107,12 @@ class __ProductDetailPageState extends State final screenSize = MediaQuery.of(context).size; return customerId != null - ? DetailPageScafold( + ? AppScaffold( appBarTitle: TranslationBase.of(context).productDetails, isShowAppBar: true, isPharmacy: true, isShowDecPage: false, + customAppBar: ProductAppBar(), body: SingleChildScrollView( child: Column( children: [ @@ -119,14 +121,14 @@ class __ProductDetailPageState extends State 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.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) ], @@ -157,7 +159,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, @@ -273,7 +276,9 @@ class __ProductDetailPageState extends State color: Colors.white, ), CustomDivider( - color: isDetails ? Colors.green : Colors.transparent, + color: isDetails + ? Colors.green + : Colors.transparent, ) ], ), @@ -298,8 +303,10 @@ class __ProductDetailPageState extends State ), color: Colors.white, ), - CustomDivider( - color: isReviews ? Colors.green : Colors.transparent, + CustomDivider( + color: isReviews + ? Colors.green + : Colors.transparent, ), ], ), @@ -324,8 +331,10 @@ class __ProductDetailPageState extends State ), color: Colors.white, ), - CustomDivider( - color: isAvailability ? Colors.green : Colors.transparent, + CustomDivider( + color: isAvailability + ? Colors.green + : Colors.transparent, ), ], ), @@ -367,7 +376,9 @@ class __ProductDetailPageState extends State // ), // RecommendedProducts(product: widget.product) - SizedBox(height: 80,) + SizedBox( + height: 80, + ) ], ), ), 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 0be6a213..4f607e48 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 @@ -8,6 +8,8 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; import 'package:rating_bar/rating_bar.dart'; +import 'CustomIcon.dart'; + class ProductNameAndPrice extends StatefulWidget { BuildContext context; PharmacyProduct item; @@ -36,19 +38,25 @@ class _ProductNameAndPriceState extends State { return Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - SizedBox(height: 10,), + SizedBox( + height: 10, + ), FractionallySizedBox( widthFactor: 0.95, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Texts(widget.item.price.toString() + " " + "SAR", - fontWeight: FontWeight.bold, fontSize: 20 - ), - Texts( projectViewModel.isArabic - ? widget.item.stockAvailabilityn - : widget.item.stockAvailability, - fontWeight: FontWeight.bold, fontSize: 15, color: widget.item.stockAvailability == 'Out of stock'?Colors.red:Colors.green, + fontWeight: FontWeight.bold, fontSize: 20), + Texts( + projectViewModel.isArabic + ? widget.item.stockAvailabilityn + : widget.item.stockAvailability, + fontWeight: FontWeight.bold, + fontSize: 15, + color: widget.item.stockAvailability == 'Out of stock' + ? Colors.red + : Colors.green, ), // SizedBox(width: 20), widget.item.stockAvailability == 'Out of stock' && @@ -70,22 +78,13 @@ class _ProductNameAndPriceState extends State { ) ]), ) - : Container( - margin: projectViewModel.isArabic - ? EdgeInsets.only(right: 25) - : EdgeInsets.only(left: 25), - width: 40, - height: 40, - decoration: BoxDecoration( - color: Colors.grey[300], - borderRadius: BorderRadius.circular(30), - ), - child: IconButton( - icon: Icon(!widget.isInWishList - ? Icons.favorite_border - : Icons.favorite), - color: !widget.isInWishList ? Colors.white : Colors.red, - onPressed: () async { + : IconWithBg( + icon: !widget.isInWishList + ? Icons.favorite_border + : Icons.favorite, + color: !widget.isInWishList ? Colors.white : Colors.red, + onPress: () async { + { if (widget.customerId != null) { if (!widget.isInWishList) { GifLoaderDialogUtils.showMyDialog(context); @@ -100,8 +99,9 @@ class _ProductNameAndPriceState extends State { return; } setState(() {}); - }, - )), + } + }, + ) ], ), ), @@ -132,7 +132,8 @@ 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], @@ -141,13 +142,17 @@ class _ProductNameAndPriceState extends State { filledIcon: Icons.star, emptyIcon: Icons.star, ), - SizedBox(width: 10,), + SizedBox( + width: 10, + ), Texts( "${widget.item.approvedRatingSum}", fontWeight: FontWeight.bold, fontSize: 12, ), - SizedBox(width: 30,), + SizedBox( + width: 30, + ), Texts( "(${widget.item.approvedTotalReviews}${TranslationBase.of(context).review})", fontSize: 12, @@ -178,7 +183,9 @@ class _ProductNameAndPriceState extends State { ], ), ), - SizedBox(height: 10,), + SizedBox( + height: 10, + ), ], ); } diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index b99ac1dc..dcac916b 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -62,6 +62,8 @@ class AppScaffold extends StatelessWidget { locator(); AppBarWidget appBar; + final Widget customAppBar; + AppScaffold( {@required this.body, this.appBarTitle = '', @@ -85,7 +87,9 @@ class AppScaffold extends StatelessWidget { this.infoList, this.isHelp = false, this.showHomeAppBarIcon = true, - this.imagesInfo}); + this.imagesInfo, + appBar, + this.customAppBar}); AppScaffold setOnAppBarCartClick(VoidCallback onClick) { _onCartClick = onClick; @@ -99,16 +103,18 @@ class AppScaffold extends StatelessWidget { backgroundColor: backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, appBar: isShowAppBar - ? appBar = AppBarWidget( - appBarTitle: appBarTitle, - appBarIcons: appBarIcons, - showHomeAppBarIcon: showHomeAppBarIcon, - isPharmacy: isPharmacy, - showPharmacyCart: showPharmacyCart, - isOfferPackages: isOfferPackages, - showOfferPackagesCart: showOfferPackagesCart, - isShowDecPage: isShowDecPage, - ) + ? customAppBar != null + ? customAppBar + : appBar = AppBarWidget( + appBarTitle: appBarTitle, + appBarIcons: appBarIcons, + showHomeAppBarIcon: showHomeAppBarIcon, + isPharmacy: isPharmacy, + showPharmacyCart: showPharmacyCart, + isOfferPackages: isOfferPackages, + showOfferPackagesCart: showOfferPackagesCart, + isShowDecPage: isShowDecPage, + ) : null, bottomSheet: bottomSheet, body: SafeArea( @@ -177,6 +183,7 @@ class AppBarWidget extends StatefulWidget with PreferredSizeWidget { } String _badgeText = "0"; + class AppBarWidgetState extends State { @override Widget build(BuildContext context) { @@ -221,7 +228,8 @@ class AppBarWidgetState extends State { ? IconButton( icon: Badge( shape: BadgeShape.circle, - badgeContent: Text(_badgeText, style: TextStyle(color: Colors.white)), + badgeContent: + Text(_badgeText, style: TextStyle(color: Colors.white)), child: Icon(Icons.shopping_cart)), color: Colors.white, onPressed: () { @@ -365,10 +373,10 @@ class _RobotIcon extends State { bottom: -15); } - // setAnimation() async { - // /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || - // // var animation = - // // IS_TEXT_COMPLETED == ? true : false; +// setAnimation() async { +// /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || +// // var animation = +// // IS_TEXT_COMPLETED == ? true : false; - // } +// } } From 9e31d497ed6e6585d1a464935ae8b2fe1db44166 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Tue, 5 Oct 2021 15:33:08 +0300 Subject: [PATCH 27/67] fix wish list issue --- .../pharmacyModule/wishlist_view_model.dart | 15 +-- .../OfferAndPackageDetailPage.dart | 2 - .../pharmacies/ProductCheckTypeWidget.dart | 111 +++++------------- lib/pages/pharmacies/wishlist.dart | 83 ++++++------- lib/pages/pharmacy/profile/profile.dart | 4 +- 5 files changed, 69 insertions(+), 146 deletions(-) diff --git a/lib/core/viewModels/pharmacyModule/wishlist_view_model.dart b/lib/core/viewModels/pharmacyModule/wishlist_view_model.dart index 788b7f3c..9a619357 100644 --- a/lib/core/viewModels/pharmacyModule/wishlist_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/wishlist_view_model.dart @@ -12,20 +12,9 @@ class WishListViewModel extends BaseViewModel{ bool hasError = false; -// Future getWishlistData() async { -// setState(ViewState.Busy); -// await _wishlistService.getWishlist(); -// if (_wishlistService.hasError) { -// error = _wishlistService.error; -// setState(ViewState.Error); -// } else { -// setState(ViewState.Idle); -// } -// } - - Future getWishlistData() async { + Future getWishlistData({isLocalLoader = false}) async { hasError = false; - setState(ViewState.Busy); + setState(isLocalLoader ? ViewState.BusyLocal:ViewState.Busy); await _wishlistService.getWishlist(); if (_wishlistService.hasError) { error = _wishlistService.error; diff --git a/lib/pages/packages_offers/OfferAndPackageDetailPage.dart b/lib/pages/packages_offers/OfferAndPackageDetailPage.dart index d0e69d14..a0b30dbd 100644 --- a/lib/pages/packages_offers/OfferAndPackageDetailPage.dart +++ b/lib/pages/packages_offers/OfferAndPackageDetailPage.dart @@ -31,8 +31,6 @@ class OfferAndPackagesDetailState extends State{ @override Widget build(BuildContext context) { - getLanguageID(); - return BaseView( onModelReady: (model){ viewModel = model; diff --git a/lib/pages/pharmacies/ProductCheckTypeWidget.dart b/lib/pages/pharmacies/ProductCheckTypeWidget.dart index edecff62..5ea79396 100644 --- a/lib/pages/pharmacies/ProductCheckTypeWidget.dart +++ b/lib/pages/pharmacies/ProductCheckTypeWidget.dart @@ -1,113 +1,58 @@ -import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/wishlist.dart'; -import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/wishlist_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/widgets/pharmacy/product_tile.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/wishlist_view_model.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; - -AppSharedPreferences sharedPref = AppSharedPreferences(); -var languageID; +import 'package:provider/provider.dart'; class ProductCheckTypeWidget extends StatefulWidget { - final List wishlist; - final bool isTrue; + final WishListViewModel model; - ProductCheckTypeWidget(this.isTrue, this.wishlist); + ProductCheckTypeWidget({this.model}); @override _ProductCheckTypeWidgetState createState() => _ProductCheckTypeWidgetState(); } class _ProductCheckTypeWidgetState extends State { - void initState() { - getLanguageID(); - } @override Widget build(BuildContext context) { - return widget.isTrue - ? ListView.builder( - itemCount: widget.wishlist.length, - itemBuilder: (BuildContext context, int index) { - return Column( - children: [ - Container( - child: widget.isTrue - ? productTile( - productName: languageID == 'ar' - ? widget.wishlist[index].product.namen - : widget.wishlist[index].product.name, - productPrice: widget.wishlist[index].subtotal, - productRate: double.parse( - widget.wishlist[index].subtotalVatRate), - productImage: - widget.wishlist[index].product.images[0].src, - showLine: widget.isTrue, - productID: widget.wishlist[index].product.id, - onDelete: deleteWishListItem, - - ) - : productTile( - productName: languageID == 'ar' - ? widget.wishlist[index].product.namen - : widget.wishlist[index].product.name, - productPrice: widget.wishlist[index].subtotal, - productRate: double.parse( - widget.wishlist[index].subtotalVatRate), - productImage: - widget.wishlist[index].product.images[0].src, - showLine: widget.isTrue, - onDelete: deleteWishListItem, - - ), - ), - Divider(height: 1, color: Colors.grey) - ], - ); - }) - : GridView.count( - crossAxisCount: 2, - children: List.generate( - widget.wishlist.length, - (index) => productTile( - productName: widget.wishlist[index].product.name, - productPrice: widget.wishlist[index].subtotal, - productRate: - double.parse(widget.wishlist[index].subtotalVatRate), - productImage: - widget.wishlist[index].product.images[0].src, - showLine: widget.isTrue, - )), + ProjectViewModel projectViewModel = Provider.of(context); + return ListView.builder( + itemCount: widget.model.wishListList.length, + itemBuilder: (BuildContext context, int index) { + return Column( + children: [ + Container( + child: productTile( + productName: projectViewModel.isArabic + ? widget.model.wishListList[index].product.namen + : widget.model.wishListList[index].product.name, + productPrice: widget.model.wishListList[index].subtotal, + productRate: double.parse(widget.model.wishListList[index].subtotalVatRate), + productImage: widget.model.wishListList[index].product.images[0].src, + productID: widget.model.wishListList[index].product.id, + onDelete: deleteWishListItem, + + ), + ), + Divider(height: 1, color: Colors.grey) + ], ); + }); } deleteWishListItem(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); GifLoaderDialogUtils.showMyDialog(context); await x.deletWishlistData(itemID); - setState(() - async{ - await - //getWishlistData(); - Navigator.push(context, - FadePage(page: WishlistPage(false)), - ); - }); + await widget.model.getWishlistData(isLocalLoader: true); GifLoaderDialogUtils.hideDialog(context); - print("Delete"); } - getWishlistData() async { - WishListViewModel x = new WishListViewModel(); - await x.getWishlistData(); - } } -getLanguageID() async { - languageID = await sharedPref.getString(APP_LANGUAGE); -} diff --git a/lib/pages/pharmacies/wishlist.dart b/lib/pages/pharmacies/wishlist.dart index b75f709b..3d1c8114 100644 --- a/lib/pages/pharmacies/wishlist.dart +++ b/lib/pages/pharmacies/wishlist.dart @@ -5,68 +5,61 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -class WishlistPage extends StatefulWidget { - bool showBar; - WishlistPage(this.showBar); - @override - _WishlistPageState createState() => _WishlistPageState(); -} - -class _WishlistPageState extends State { - bool isTrue = true; +class WishlistPage extends StatelessWidget { + const WishlistPage({Key key}) : super(key: key); + @override Widget build(BuildContext context) { return BaseView( onModelReady: (model) => model.getWishlistData(), builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).wishlist, - isShowAppBar: widget.showBar, + isShowAppBar: true, isShowDecPage: false, isPharmacy: true, baseViewModel: model, body: model.wishListList.length == 0 ? 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), - ), - ) - ], + 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), + ), + ) + ], + ), + ), + ) : Container( - child: Column( - children: [ - Expanded( - flex: 20, - child: Container( - width: double.infinity, - height: - MediaQuery.of(context).size.height * 0.85, //250, - child: - ProductCheckTypeWidget(isTrue, model.wishListList), - ), - ), - ], + child: Column( + children: [ + Expanded( + flex: 20, + child: Container( + width: double.infinity, + height: MediaQuery.of(context).size.height * 0.85, //250, + child: ProductCheckTypeWidget(model: model,), ), ), + ], + ), + ), ), ); } } + diff --git a/lib/pages/pharmacy/profile/profile.dart b/lib/pages/pharmacy/profile/profile.dart index 3cf28592..a82a74eb 100644 --- a/lib/pages/pharmacy/profile/profile.dart +++ b/lib/pages/pharmacy/profile/profile.dart @@ -235,9 +235,7 @@ class _ProfilePageState extends State { onTap: () { Navigator.push( context, - MaterialPageRoute( - builder: (context) => - WishlistPage(true))); + FadePage(page: WishlistPage())); }, child: Column( children: [ From ad0c8eaffb0ba35a0b227830355a1ddb79a0c43d Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 5 Oct 2021 15:36:43 +0300 Subject: [PATCH 28/67] fix scaffold --- lib/widgets/others/app_scaffold_widget.dart | 69 ++++++++++----------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 87976dcb..93bccbd2 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -224,37 +224,36 @@ class AppBarWidgetState extends State { ), centerTitle: true, actions: [ - (widget.isPharmacy && widget.showPharmacyCart) - ? Container() - // ? IconButton( - // icon: Badge( - // shape: BadgeShape.circle, - // badgeContent: - Text(_badgeText, style: TextStyle(color: Colors.white)), - // child: Icon(Icons.shopping_cart)), - // color: Colors.white, - // onPressed: () { - // Navigator.of(context).popUntil(ModalRoute.withName('/')); - // }) - : Container(), + // (widget.isPharmacy && widget.showPharmacyCart) + // ? Container() + // // ? IconButton( + // // icon: Badge( + // // shape: BadgeShape.circle, + // // badgeContent: + // // Text(_badgeText, style: TextStyle(color: Colors.white)), + // // child: Icon(Icons.shopping_cart)), + // // color: Colors.white, + // // onPressed: () { + // // Navigator.of(context).popUntil(ModalRoute.withName('/')); + // // }) + // : Container(), (widget.isOfferPackages && widget.showOfferPackagesCart) - ? Container() - // ? IconButton( - // icon: Badge( - // position: BadgePosition.topStart(top: -15, start: -10), - // badgeContent: Text( - // _badgeText, - // style: TextStyle( - // fontSize: 9, - // color: Colors.white, - // fontWeight: FontWeight.normal), - // ), - // child: Icon(Icons.shopping_cart)), - // color: Colors.white, - // onPressed: () { - // // Cart Click Event - // if (_onCartClick != null) _onCartClick(); - // }) + ? IconButton( + icon: Badge( + position: BadgePosition.topStart(top: -15, start: -10), + badgeContent: Text( + _badgeText, + style: TextStyle( + fontSize: 9, + color: Colors.white, + fontWeight: FontWeight.normal), + ), + child: Icon(Icons.shopping_cart)), + color: Colors.white, + onPressed: () { + // Cart Click Event + if (_onCartClick != null) _onCartClick(); + }) : Container(), if (widget.showHomeAppBarIcon) IconButton( @@ -375,10 +374,10 @@ class _RobotIcon extends State { bottom: -15); } -// setAnimation() async { -// /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || -// // var animation = -// // IS_TEXT_COMPLETED == ? true : false; + // setAnimation() async { + // /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || + // // var animation = + // // IS_TEXT_COMPLETED == ? true : false; -// } + // } } From 594b2710b33fe1d99fab288e286a8d458e3dc6a6 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Tue, 5 Oct 2021 16:11:44 +0300 Subject: [PATCH 29/67] fix bugs pharmacy home --- .../model/pharmacies/PharmacyProduct.dart | 8 +-- lib/core/service/client/base_app_client.dart | 3 +- .../parmacyModule/parmacy_module_service.dart | 7 +- .../pharmacyModule/LastVisitedViewModel.dart | 2 +- lib/pages/landing/home_page.dart | 9 +-- .../screens/pharmacy_module_page.dart | 2 - .../pharmacies/widgets/ProductTileItem.dart | 22 ++++++- .../widgets/home/RecentlyViewedWidget.dart | 66 +++++++++++-------- .../widgets/home/ViewAllHomeWidget.dart | 4 +- .../product_detail_service.dart | 2 +- 10 files changed, 78 insertions(+), 47 deletions(-) diff --git a/lib/core/model/pharmacies/PharmacyProduct.dart b/lib/core/model/pharmacies/PharmacyProduct.dart index f69d035b..dbef5737 100644 --- a/lib/core/model/pharmacies/PharmacyProduct.dart +++ b/lib/core/model/pharmacies/PharmacyProduct.dart @@ -108,10 +108,10 @@ class PharmacyProduct { List manufacturerIds; List reviews; List images; - List attributes; + List attributes; List specifications; - List associatedProductIds; - List tags; + List associatedProductIds; + List tags; int vendorId; String seName; @@ -367,7 +367,7 @@ class PharmacyProduct { }); } if (json['attributes'] != null) { - attributes = new List(); + attributes = new List(); json['attributes'].forEach((v) { attributes.add(v); }); diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index e74a353b..d5e5a207 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -785,7 +785,8 @@ class BaseAppClient { final int statusCode = response.statusCode; print("statusCode :$statusCode"); if (statusCode < 200 || statusCode >= 400 || json == null) { - onFailure('Error While Fetching data', statusCode); + var parsed = json.decode(utf8.decode(response.bodyBytes)); + onFailure(parsed['error']['ErrorEndUserMsg'] ??'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/parmacy_module_service.dart b/lib/core/service/parmacyModule/parmacy_module_service.dart index d982c519..b32b86e0 100644 --- a/lib/core/service/parmacyModule/parmacy_module_service.dart +++ b/lib/core/service/parmacyModule/parmacy_module_service.dart @@ -113,7 +113,6 @@ class PharmacyModuleService extends BaseService { } Future getTopManufacturerList() async { - hasError = false; Map queryParams = {'page': '1', 'limit': '8'}; try { await baseAppClient.getPharmacy(GET_PHARMACY_TOP_MANUFACTURER, @@ -125,6 +124,7 @@ class PharmacyModuleService extends BaseService { manufacturerList.add(Manufacturer.fromJson(item)); // } }); + hasError = false; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; @@ -146,6 +146,7 @@ class PharmacyModuleService extends BaseService { response['products'].forEach((item) { bestSellerProducts.add(PharmacyProduct.fromJson(item)); }); + hasError = false; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; @@ -161,6 +162,7 @@ class PharmacyModuleService extends BaseService { null) { lastVisited = await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS); + // lastVisited = "2458,4561"; try { await baseAppClient .getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited", @@ -169,8 +171,9 @@ class PharmacyModuleService extends BaseService { response['products'].forEach((item) { lastVisitedProducts.add(PharmacyProduct.fromJson(item)); }); + hasError = false; }, onFailure: (String error, int statusCode) { - hasError = true; + hasError = true; // sharedPref.setString(PHARMACY_LAST_VISITED_PRODUCTS, ""); super.error = error; }); } catch (error) { diff --git a/lib/core/viewModels/pharmacyModule/LastVisitedViewModel.dart b/lib/core/viewModels/pharmacyModule/LastVisitedViewModel.dart index efc628d6..f38851d9 100644 --- a/lib/core/viewModels/pharmacyModule/LastVisitedViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/LastVisitedViewModel.dart @@ -13,7 +13,7 @@ class LastVisitedViewModel extends BaseViewModel { _pharmacyService.lastVisitedProducts; getLastVisitedProducts() async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _pharmacyService.getLastVisitedProducts(); if (_pharmacyService.hasError) { error = _pharmacyService.error; diff --git a/lib/pages/landing/home_page.dart b/lib/pages/landing/home_page.dart index a34f3b57..acc05e71 100644 --- a/lib/pages/landing/home_page.dart +++ b/lib/pages/landing/home_page.dart @@ -825,15 +825,10 @@ class _HomePageState extends State { } else { GifLoaderDialogUtils.showMyDialog(context); await pharmacyModuleViewModel.generatePharmacyToken().then((value) async { - if (pharmacyModuleViewModel.error.isNotEmpty) { - await pharmacyModuleViewModel.verifyCustomer().then((value) { - GifLoaderDialogUtils.hideDialog(context); - Navigator.push(context, FadePage(page: LandingPagePharmacy())); - }); - } else { + await pharmacyModuleViewModel.verifyCustomer().then((value) { GifLoaderDialogUtils.hideDialog(context); Navigator.push(context, FadePage(page: LandingPagePharmacy())); - } + }); }); } } diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 755b5cef..f62ebcef 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -45,10 +45,8 @@ class _PharmacyPageState extends State { return BaseView( onModelReady: (model) async { - // GifLoaderDialogUtils.showMyDialog(context); await model.getSavedLanguage(); await model.getBannerList(); - // GifLoaderDialogUtils.hideDialog(context); }, allowAny: true, builder: (_, model, wi) => AppScaffold( diff --git a/lib/pages/pharmacies/widgets/ProductTileItem.dart b/lib/pages/pharmacies/widgets/ProductTileItem.dart index b7a061d5..149b7860 100644 --- a/lib/pages/pharmacies/widgets/ProductTileItem.dart +++ b/lib/pages/pharmacies/widgets/ProductTileItem.dart @@ -24,6 +24,7 @@ class ProductTileItem extends StatelessWidget { void _saveLastVisitProducts() async { String lastVisited = ""; bool isIdExist = false; + List items = []; if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != null) { lastVisited = @@ -32,8 +33,27 @@ class ProductTileItem extends StatelessWidget { if (id == item.id) { isIdExist = true; } + items.add(id); }); } + + if(items.length >= 15){ + items.removeAt(0); + // lastVisited = lastVisited.replaceFirst(RegExp('$itemToRemove'), ''); + } + + lastVisited = ""; + for(int i = items.length - 1; i >= 0; i--){ + if (lastVisited == "") { + // it means there is no lastVisited yet + lastVisited = "${items[i]}"; + } else { + // there is lastVisited id's and this product id is not found + lastVisited += ",${items[i]}"; + } + } + + if (!isIdExist) { if (lastVisited == "") { // it means there is no lastVisited yet @@ -42,8 +62,8 @@ class ProductTileItem extends StatelessWidget { // there is lastVisited id's and this product id is not found lastVisited += ",${item.id}"; } - sharedPref.setString(PHARMACY_LAST_VISITED_PRODUCTS, lastVisited); } + sharedPref.setString(PHARMACY_LAST_VISITED_PRODUCTS, lastVisited); } @override diff --git a/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart b/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart index b07c6da6..aaedee65 100644 --- a/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart +++ b/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/LastVisitedViewModel.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -15,31 +16,44 @@ class RecentlyViewedWidget extends StatelessWidget { onModelReady: (model) => model.getLastVisitedProducts(), allowAny: true, builder: (_, model, wi) => NetworkBaseView( - isLocalLoader: true, - baseViewModel: model, - child: Container( - child: Column( - children: [ - ViewAllHomeWidget( - TranslationBase.of(context).recentlyViewed, - FinalProductsPage( - id: "", - productType: 3, - )), - Container( - height: model.lastVisitedProducts.length > 0 - ? MediaQuery.of(context).size.height / 4 + 20 - : 0, - child: ListView.builder( - itemBuilder: (ctx, i) => - ProductTileItem(model.lastVisitedProducts[i]), - scrollDirection: Axis.horizontal, - itemCount: model.lastVisitedProducts.length, - ), + isLocalLoader: true, + baseViewModel: model, + child: Container( + child: Column( + children: [ + ViewAllHomeWidget( + TranslationBase.of(context).recentlyViewed, + FinalProductsPage( + id: "", + productType: 3, + )), + if (model.state != ViewState.BusyLocal) + Container( + height: model.lastVisitedProducts.length > 0 + ? MediaQuery.of(context).size.height / 4 + 20 + : 0, + child: ListView.builder( + itemBuilder: (ctx, i) => + ProductTileItem(model.lastVisitedProducts[i]), + scrollDirection: Axis.horizontal, + itemCount: model.lastVisitedProducts.length, + ), + ) + else + Container( + height: 80, + child: Center( + child:CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ), + ), + ), + ], ), - ], - ), - ), - )); + ), + )); } -} \ No newline at end of file +} diff --git a/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart b/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart index 25981466..93a9df0c 100644 --- a/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart +++ b/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart @@ -14,7 +14,7 @@ class ViewAllHomeWidget extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.fromLTRB(10, 10, 10, 10), + margin: EdgeInsets.fromLTRB(16, 10, 16, 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -28,7 +28,7 @@ class ViewAllHomeWidget extends StatelessWidget { borderColor: Colors.green, textColor: Colors.green, vPadding: 6, - hPadding: 4, + hPadding: 8, handler: () { Navigator.push( context, diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index f85faf2c..0f86df23 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -98,7 +98,7 @@ class ProductDetailService extends BaseService { }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - AppToast.showErrorToast(message: 'something went wrong please try again'); + AppToast.showErrorToast(message: super.error??'something went wrong please try again'); }, body: request); } From 6acb8031d09d8b54e861b588d67f938ab456b8ee Mon Sep 17 00:00:00 2001 From: mosazaid Date: Tue, 5 Oct 2021 16:23:54 +0300 Subject: [PATCH 30/67] fix bugs pharmacy home --- .../pharmacyModule/BestSellerViewModel.dart | 12 ++-- .../pharmacyModule/BrandViewModel.dart | 12 ++-- .../pharmacyModule/LastVisitedViewModel.dart | 10 ++-- .../pharmacy_module_view_model.dart | 2 +- lib/pages/landing/home_page.dart | 1 + .../widgets/home/BestSellerWidget.dart | 15 ++++- .../widgets/home/RecentlyViewedWidget.dart | 4 +- .../widgets/home/ShopByBrandWidget.dart | 55 ++++++++++++------- .../widgets/home/ViewAllHomeWidget.dart | 4 +- 9 files changed, 72 insertions(+), 43 deletions(-) diff --git a/lib/core/viewModels/pharmacyModule/BestSellerViewModel.dart b/lib/core/viewModels/pharmacyModule/BestSellerViewModel.dart index f530999b..b03ee5b9 100644 --- a/lib/core/viewModels/pharmacyModule/BestSellerViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/BestSellerViewModel.dart @@ -13,14 +13,14 @@ class BestSellerViewModel extends BaseViewModel { _pharmacyService.bestSellerProducts; getBestSellerProducts() async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _pharmacyService.getBestSellerProducts(); - if (_pharmacyService.hasError) { - error = _pharmacyService.error; - setState(ViewState.Error); - } else { + // if (_pharmacyService.hasError) { + // error = _pharmacyService.error; + // setState(ViewState.Error); + // } else { setState(ViewState.Idle); - } + // } } } \ No newline at end of file diff --git a/lib/core/viewModels/pharmacyModule/BrandViewModel.dart b/lib/core/viewModels/pharmacyModule/BrandViewModel.dart index 8ffc057a..c1cdc8bc 100644 --- a/lib/core/viewModels/pharmacyModule/BrandViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/BrandViewModel.dart @@ -11,14 +11,14 @@ class BrandViewModel extends BaseViewModel { List get manufacturerList => _pharmacyService.manufacturerList; Future getTopManufacturerList() async { - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _pharmacyService.getTopManufacturerList(); - if (_pharmacyService.hasError) { - error = _pharmacyService.error; - setState(ViewState.Error); - } else { + // if (_pharmacyService.hasError) { + // error = _pharmacyService.error; + // setState(ViewState.Error); + // } else { setState(ViewState.Idle); - } + // } } @override diff --git a/lib/core/viewModels/pharmacyModule/LastVisitedViewModel.dart b/lib/core/viewModels/pharmacyModule/LastVisitedViewModel.dart index f38851d9..568e56f8 100644 --- a/lib/core/viewModels/pharmacyModule/LastVisitedViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/LastVisitedViewModel.dart @@ -15,11 +15,11 @@ class LastVisitedViewModel extends BaseViewModel { getLastVisitedProducts() async { setState(ViewState.BusyLocal); await _pharmacyService.getLastVisitedProducts(); - if (_pharmacyService.hasError) { - error = _pharmacyService.error; - setState(ViewState.Error); - } else { + // if (_pharmacyService.hasError) { + // error = _pharmacyService.error; + // setState(ViewState.Error); + // } else { setState(ViewState.Idle); - } + // } } } \ No newline at end of file diff --git a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart index 3f986bcc..facccf1e 100644 --- a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart @@ -40,7 +40,7 @@ class PharmacyModuleViewModel extends BaseViewModel { } Future verifyCustomer() async { - if (authenticatedUserObject.isLogin) await generatePharmacyToken(); + // if (authenticatedUserObject.isLogin) await generatePharmacyToken(); var data = await sharedPref.getObject(USER_PROFILE); var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); diff --git a/lib/pages/landing/home_page.dart b/lib/pages/landing/home_page.dart index acc05e71..4e19386b 100644 --- a/lib/pages/landing/home_page.dart +++ b/lib/pages/landing/home_page.dart @@ -825,6 +825,7 @@ class _HomePageState extends State { } else { GifLoaderDialogUtils.showMyDialog(context); await pharmacyModuleViewModel.generatePharmacyToken().then((value) async { + await pharmacyModuleViewModel.verifyCustomer().then((value) { GifLoaderDialogUtils.hideDialog(context); Navigator.push(context, FadePage(page: LandingPagePharmacy())); diff --git a/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart b/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart index 5784acaa..baf771b2 100644 --- a/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart +++ b/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BestSellerViewModel.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -26,6 +27,7 @@ class BestSellerWidget extends StatelessWidget { id: "", productType: 20, )), + if (model.state != ViewState.BusyLocal) Container( height: MediaQuery.of(context).size.height / 4 + 20, child: ListView.builder( @@ -34,7 +36,18 @@ class BestSellerWidget extends StatelessWidget { scrollDirection: Axis.horizontal, itemCount: model.bestSellerProduct.length, ), - ), + ) else + Container( + height: 80, + child: Center( + child: CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ), + ), + ), ], ), ), diff --git a/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart b/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart index aaedee65..15e9e700 100644 --- a/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart +++ b/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart @@ -18,7 +18,7 @@ class RecentlyViewedWidget extends StatelessWidget { builder: (_, model, wi) => NetworkBaseView( isLocalLoader: true, baseViewModel: model, - child: Container( + child: model.lastVisitedProducts.isNotEmpty ? Container( child: Column( children: [ ViewAllHomeWidget( @@ -53,7 +53,7 @@ class RecentlyViewedWidget extends StatelessWidget { ), ], ), - ), + ) : Container(), )); } } diff --git a/lib/pages/pharmacies/widgets/home/ShopByBrandWidget.dart b/lib/pages/pharmacies/widgets/home/ShopByBrandWidget.dart index 3d892a43..8f4f943d 100644 --- a/lib/pages/pharmacies/widgets/home/ShopByBrandWidget.dart +++ b/lib/pages/pharmacies/widgets/home/ShopByBrandWidget.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BrandViewModel.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -15,26 +16,38 @@ class ShopByBrandWidget extends StatelessWidget { onModelReady: (model) => model.getTopManufacturerList(), allowAny: true, builder: (_, model, wi) => NetworkBaseView( - isLocalLoader: true, - baseViewModel: model, - child: Container( - child: Column( - children: [ - ViewAllHomeWidget( - TranslationBase.of(context).shopByBrands, - ProductBrandsPage()), - Container( - height: 100, - child: ListView.builder( - itemBuilder: (ctx, i) => - ManufacturerItem(model.manufacturerList[i]), - scrollDirection: Axis.horizontal, - itemCount: model.manufacturerList.length, - ), + isLocalLoader: true, + baseViewModel: model, + child: Container( + child: Column( + children: [ + ViewAllHomeWidget(TranslationBase.of(context).shopByBrands, + ProductBrandsPage()), + if (model.state != ViewState.BusyLocal) + Container( + height: 100, + child: ListView.builder( + itemBuilder: (ctx, i) => + ManufacturerItem(model.manufacturerList[i]), + scrollDirection: Axis.horizontal, + itemCount: model.manufacturerList.length, + ), + ) + else + Container( + height: 80, + child: Center( + child: CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ), + ), + ), + ], ), - ], - ), - ), - )); + ), + )); } -} \ No newline at end of file +} diff --git a/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart b/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart index 93a9df0c..05c57f2e 100644 --- a/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart +++ b/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart @@ -21,14 +21,16 @@ class ViewAllHomeWidget extends StatelessWidget { Texts( title, bold: true, + fontSize: 16, ), BorderedButton( TranslationBase.of(context).viewAll, hasBorder: true, borderColor: Colors.green, textColor: Colors.green, + fontWeight: FontWeight.bold, vPadding: 6, - hPadding: 8, + hPadding: 14, handler: () { Navigator.push( context, From 7c15bca7465760e5fcb895f61dc6372eeb02f68f Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 5 Oct 2021 16:24:42 +0300 Subject: [PATCH 31/67] fix item --- .../screens/product-details/CustomIcon.dart | 4 +- .../product-details/ProductAppBar.dart | 139 ++++++++++++------ .../product-details/footor/footer-widget.dart | 5 +- .../product-details/product-detail.dart | 16 +- .../product-name-and-price.dart | 2 +- 5 files changed, 115 insertions(+), 51 deletions(-) diff --git a/lib/pages/pharmacies/screens/product-details/CustomIcon.dart b/lib/pages/pharmacies/screens/product-details/CustomIcon.dart index c9a71afa..fc8b2288 100644 --- a/lib/pages/pharmacies/screens/product-details/CustomIcon.dart +++ b/lib/pages/pharmacies/screens/product-details/CustomIcon.dart @@ -11,11 +11,11 @@ class IconWithBg extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.only(left: 25), + // margin: EdgeInsets.only(left: 25), width: 40, height: 40, decoration: BoxDecoration( - color: Colors.grey[300], + color: Colors.grey[200], borderRadius: BorderRadius.circular(30), ), child: IconButton( diff --git a/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart b/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart index 36c43364..c895d7c9 100644 --- a/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart +++ b/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart @@ -1,6 +1,11 @@ +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; +import '../../compare-list.dart'; import '../cart-order-page.dart'; import 'CustomIcon.dart'; @@ -9,58 +14,108 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { Widget build(BuildContext context) { return Container( color: Colors.white, - child: Column( - children: [ - SizedBox( - height: 30, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - IconWithBg( - icon: Icons.arrow_back_ios, - color: Colors.grey, - onPress: () { - Navigator.pop(context); - }, - ), - ], - ), - Row( - children: [ - IconWithBg( - icon: Icons.shopping_cart, + + child: FractionallySizedBox( + widthFactor: 0.95, + child: Column( + children: [ + SizedBox( + height: 30, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + IconWithBg( + icon: Icons.arrow_back_ios, color: Colors.grey, onPress: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => CartOrderPage()), - ); - }), - IconWithBg( - icon: FontAwesomeIcons.ellipsisV, - color: Colors.grey, - onPress: () { - //TODO Elham* - // settingModalBottomSheet(context); - }, - ), - ], - ) - ], - ), - ], + Navigator.pop(context); + }, + ), + ], + ), + Row( + children: [ + IconWithBg( + icon: Icons.shopping_cart, + color: Colors.grey, + onPress: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => CartOrderPage()), + ); + }), + SizedBox(width: 10,), + IconWithBg( + icon: FontAwesomeIcons.ellipsisV, + color: Colors.grey, + onPress: () { + settingModalBottomSheet(context); + }, + ), + ], + ) + ], + ), + ], + ), ), ); } + + @override // TODO: implement preferredSize @override Size get preferredSize => Size(double.maxFinite, 50); + + settingModalBottomSheet(context) { + showModalBottomSheet( + context: context, + builder: (BuildContext bc) { + return Container( + child: new Wrap( + children: [ + new ListTile( + leading: Icon(Icons.shopping_cart), + title: Text( + TranslationBase.of(context).addToCart, + ), + onTap: () => { + if (price > 0) + {addToCartFunction(price, itemID, context)} + else + { + AppToast.showErrorToast( + message: "you should add quantity") + } + }), + ListTile( + leading: Icon(Icons.favorite_border), + title: Text( + TranslationBase.of(context).addToWishlist, + ), + onTap: () => {addToWishlistFunction(itemID)}, + ), + ListTile( + leading: Icon(Icons.compare), + title: Text( + TranslationBase.of(context).compare, + ), + onTap: () => { + Provider.of(context, listen: false) + .addItem(specificationData), + }, + ), + ], + ), + ); + }); + } } 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 cca4eef5..88302480 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -178,7 +178,7 @@ class _FooterWidgetState extends State { ), ), Container( - width: MediaQuery.of(context).size.width * 0.4, + width: MediaQuery.of(context).size.width * 0.45, child: SecondaryButton( label: TranslationBase.of(context).addToCart.toUpperCase(), disabled: !widget.isAvailable && widget.price > 0 || @@ -188,6 +188,7 @@ class _FooterWidgetState extends State { widget.addToCartFunction( widget.price, widget.item.id, context); }, + borderRadius: 5, color: Colors.green, ), @@ -196,7 +197,7 @@ class _FooterWidgetState extends State { width: 5, ), Container( - width: MediaQuery.of(context).size.width * 0.3, + width: MediaQuery.of(context).size.width * 0.35, child: SecondaryButton( label: TranslationBase.of(context).buyNow.toUpperCase(), disabled: !widget.isAvailable && widget.price > 0 || diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 08a622aa..d2ce4f35 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -112,7 +112,7 @@ class __ProductDetailPageState extends State isShowAppBar: true, isPharmacy: true, isShowDecPage: false, - customAppBar: ProductAppBar(), + customAppBar: ProductAppBar(), body: SingleChildScrollView( child: Column( children: [ @@ -143,9 +143,17 @@ class __ProductDetailPageState extends State context, widget.product, customerId: customerId, - addToWishlistFunction: addToWishlistFunction, - deleteFromWishlistFunction: deleteFromWishlistFunction, - notifyMeWhenAvailable: notifyMeWhenAvailable, + addToWishlistFunction: (item) { + addToWishlistFunction(item); + setState(() {}); + }, + deleteFromWishlistFunction: (item) { + deleteFromWishlistFunction(item); + setState(() {}); + }, + notifyMeWhenAvailable: (context, itemId) { + notifyMeWhenAvailable(context, itemId); + }, isInWishList: isInWishList, ), ), 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 4f607e48..b7906b78 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 @@ -46,7 +46,7 @@ class _ProductNameAndPriceState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Texts(widget.item.price.toString() + " " + "SAR", + Texts(widget.item.price.toString() + " " + "SR", fontWeight: FontWeight.bold, fontSize: 20), Texts( projectViewModel.isArabic From 338901d4238592f264d03f275b6e875f93ad04a5 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 5 Oct 2021 16:29:56 +0300 Subject: [PATCH 32/67] remove add to cart --- .../pharmacies/screens/product-details/ProductAppBar.dart | 7 +++++++ .../pharmacies/screens/product-details/product-detail.dart | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart b/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart index c895d7c9..09d595f7 100644 --- a/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart +++ b/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -10,6 +11,11 @@ import '../cart-order-page.dart'; import 'CustomIcon.dart'; class ProductAppBar extends StatelessWidget with PreferredSizeWidget { + + final PharmacyProduct product; + + const ProductAppBar({Key key, this.product}) : super(key: key); + @override Widget build(BuildContext context) { return Container( @@ -80,6 +86,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { return Container( child: new Wrap( children: [ + if( product.stockAvailability != 'Out of stock') new ListTile( leading: Icon(Icons.shopping_cart), title: Text( diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index d2ce4f35..d9c623f9 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -58,7 +58,6 @@ class __ProductDetailPageState extends State bool isDetails = true; bool isReviews = false; bool isAvailability = false; - int _activeTab = 0; checkWishlist() async { GifLoaderDialogUtils.showMyDialog(context); @@ -112,7 +111,7 @@ class __ProductDetailPageState extends State isShowAppBar: true, isPharmacy: true, isShowDecPage: false, - customAppBar: ProductAppBar(), + customAppBar: ProductAppBar(product: widget.product,), body: SingleChildScrollView( child: Column( children: [ From a9d0b7a14b5c3619d1075697586ca84d0725545a Mon Sep 17 00:00:00 2001 From: mosazaid Date: Tue, 5 Oct 2021 16:42:48 +0300 Subject: [PATCH 33/67] fix bugs pharmacy home --- assets/images/pharmacy_module/bg_1.png | Bin 2898 -> 3581 bytes assets/images/pharmacy_module/bg_2.png | Bin 1463 -> 867 bytes assets/images/pharmacy_module/bg_3.png | Bin 1651 -> 1526 bytes assets/images/pharmacy_module/bg_4.png | Bin 1483 -> 1555 bytes .../pharmacies/widgets/home/BannerPager.dart | 2 +- .../pharmacies/widgets/home/GridViewCard.dart | 13 +++++++++---- 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/assets/images/pharmacy_module/bg_1.png b/assets/images/pharmacy_module/bg_1.png index 9505e556868edbfa5c1d80b2e7c4839248b886e4..0155a7b34691cd0035abee52998a3f309bc7c6ca 100644 GIT binary patch literal 3581 zcmX|@c|26@|HetAEJ?;=i4Z-HY{?R`WGR#+`^YlJI;I(87|Se-eIJEHwh&pSA^TwL zW`@WvTMLp9ipWxYkKZ4^^Ln4_e9pP=*L|+fb)P>@yoI?j&l!<3EG#TMrY1&~z?BS~ z4>;KX4PKxru&|s^v@o;21>BaGmlNBFS^ZhWabi+GG4)-HKg}(G>XiI8B85Q=XojF$ zoJoD*$-UuzR0ye;n9>&>+Z~KVZeUtHhoz8xQ5)(Z8HAdnvJMgB0^1!xFZVBNk@!F8J&ljc=x78J*t|#q6{@t zmN<9y3fsH<2LC~v_C`PPuzEwOY|A-6WQou=xTSj*qtU%N`^qJF@s!0LeW`s@p?2VI z@CUm|nu|d*;nan_YzexY5`IN9)-vyC{}X$G$Y_9|i9t<_^_S^K&#TWI?Pe};F)Ivf^AsTVp#m_!cg(zDgf&cjP z+J3TxES@`$SObhWQJz6+Q$%5mBJx>lT}WiJ5pJ z{*k~HuOHC<-@hpP$Ms=72DJ4TpnD4;?5lpc3PG0OHyTx<5rf#Yuk*&ineC z5J-*8csV>5kStQUUbMtB!R~MWSiNtwR=H^UeR#uHNp;0)^wyYnE*Hxx3BoR?%Hq+= zj#qz)WqUnzeT2oTQQWGC<`xNx0IjenAbfWv7My+=>Lk_WtEh0wH1OE+2^MZ&9~hHM z(9NI7BSAM}n2al$)@iyE`k!-%ReWnnS=jA@I{~IR5m)Ah5axv9G}NR03}!$5L$Qcc z}3syam0 zNfzl&K8ldC@tAIfCizGDOPRB=idH!Vpc};T=CTI4dA3<;u&6<0mB4Fwa*#3TKF#UCbOYpXVJ`A)_B}z8T|Wo+Q{f8sXMc z0vXf2M-CAnR`Ec69LQSfcixV)z7`cWAfc^)!?}Yaw-)Lox@3N(YQDG6`*XrxH$uHvh8yCPk!l+Dq_UhxZ=-B*OkzefybRsy^ORQ zPg_kW{2fW@NWe)lW(qMN*6qGIBxT3TSdG66A&p(CemiYspm&m7dh_CR;kIPVo8@jc zm2yiEX9^d!^7^0u;G<@g7>)DxKMjVUzh;eLZp?o(8Eh&Zvu&1x*$l|MoA=|9sJf^% z9nK8VzL|ns{p%(B-<~uf`&_ac_3xf&Q1zd<9T7LKUsaf=_on2Q|0UP&CSuU=p^|DH zrx{2_2Ob#{VHDqYradfP<_%fZ5F1eyQd{yZGe&e07;^>4cVZ*FPuvBLipt6Tb5?Uuykx zovzLRwJ=uYj`s!ALG%z=+lrFzdn5PLzmXT}`Z=3*mXp?eYQuG;mHFPE;8IzM2d*40M`<*1PS0x)kxU1xg5 z&GPA60)BF8CpXwtRcSa@8prHsYm;HO@1syhSyg0Y&9%ilBV~$)d25TBDCsd_E7-vz z%FJ-OQ0@*V{goE?x(L5;av>StF*s88A#c9s#*55oKDL$$>8^Lybva1_nOT$QWTQn+=`JS=q}REMDKsTti+Z&&CCuzIgtKaQ7!)*K>V~`apr+9}{Uvi&yF? z0(%(|ahlT|8fj~MwJ?Ps3Cd5KDXs6Ya0{8Y%HsxK`q;jW%~pHhCq!)PLFpTwMs!|x zubFKNn@SuS^{tx!1RhjaCK1 zN>$`;eNGrr`|Ct%F7VV;oiKiIpoO_mm73{Fs=R-Cu)(XiH%Mmtc`CW1ywq;JDRt2T ze3~k92N|I0f3_;MtdC?l%$F6YpMcVMIDh}o#LgG%Jy0YlO%9%`rEU-I*N#$|$WWcr zSw?|+@^_y;8yl#orX)kP##cPv<+;i*ez&~Yv$b*X#k^+}YauCqw~|I}Ztcb0C96rd zt7TAjG#1W5Jd{T(&EGT`h<^Pfs3PV}QIi&ls_IN&J`F19{;mDtGz0!~FMFzUf1)OD zf8%T2YMQaxJ<~IRZZm6G5uwS?1})x9&zTc#FKG`x^`BaEz6?XW{-^r-*M&;qxl6CY zq%urAxQfw1qUD7O8@o+Id2^0u=N%=rbLQ6Lz@*9WDq+bDg1Q>*f#O${-tK@QH}O?8 zN8y|303_AjHz>X#ctH3(j1Yp96impO`I$(*XG4ieOF{6|*(rjm%Zwg%e)@!gmU8IfJ?zYOX%SCa5)Do{{0d9Br=(0qJ6MYrq^Q zo@Bw7XZx@q?ztdw=Tt@6;bdWCQggee)og$H7bj{u3%kPQry~aqqjp|ht-8%8D{qAM zU|d=Xz7@NF{n+P*r)GoWkq=sygQ<^k&1b44h~zea=bEI zQ)77i?1nByxb@ramp1BA+Ggc_jSDU}>W5p3h7)^N r+Qd^YuM0vR{%=~c4IBX~$ zY~7{lEONT-Mho9ROj2c=-j!;v0cWnV8p9b&$)BOsZ+?bXUex} z&9`#Pwr$I}ZOplD&$@ENt5ngxc*Lnx(Y$xVt5n3QRl})N%73zE%e8IIw{Ok2Zq2uF z&$)HZxOBv;RK==O%e835s#L|QR>iAU#jIJ!tXs*jU&*jz$+2X_s#U|PRMNkG)4zVv zy?fHWd&H_#(Y$!Xs#L_PRK%)O#Hv-qt5wCTR>iAV#jIDwtXRgZS;nnd#;sb$ty{;g zTgR?k$F5z+uYX;~uU^QnU&ydu$gp6@uwluuVac&#$+2U}vSZ4!WXiH-%Clw4vu4V( zXUnu_%d}|Av}wz=Y0R~1%(ZLGwrk9`Y|XZ9&9`mMw{Fe1Z_T)G&bV;SxN*+8a?iPQ z&$@Kax^>XIcHbUbaR2}SM08S4Qvd}92MrVz6&4p47=JcGMNd&vRaRG6T3cIOTwGjU zUSD8&d3t($et?IHii?YjjgF9*s;jH4t*)=IyS&cO-QDi;`T9ru9?Sp$00Cl4M??Z< z3w&e%00~h^L_t(&-qoAu->bG2fVoN9bfiu9NScmx+@@`An>0L@z4^v7CA^;f=2KOzUVZ55sL*B6k4)IMW!kb-g-yP{fI4o25O!5n zKm9eqef1yYxe7>ot3rL&=|>K1+dOTVWq#(+KYyzM{Z?)wR($>aRSf&5_(_m<4-V~t zdcs3Y(?mGt4Z7bA)a_ovs;Ylfl&}6zmC~9}uU-0yHq$gp8;0zUO!`L;K(7-itNP!s zC_kpY0!RyWtJ>59bEc)2HuS`w;{^2Cl(VYp50zi4Ikb)rbWD%ZMYKj*OoQh6!oP#G z+kZK%>MxY%Y98$xfYn{2c zn9It+g0x;kZm$*dHPic=NL;SQ_vhxa@~|N71xfAYFb(N_p}6K;Z|I!Q3c#xRh5y|` zZm&Askcj;zT#|f1Sn%(>R@8i0khUwe*MAtie-(WRe#Lf*u!67|wC9nYPNNlez5H| z_Lc*r3#|NRY|rN$Rt)>X-`7jgwqSduMS^QKLrlcQ284D=Rs!pLGfno4c4EUWGqH4! zTRO*Va@Bj0W1dSN@# zl-ALJdeJ45OHZ?7xEGdRa#;J(r=ekS;I0&;T|xGWe>~1imOT&fJH$@*qteb+?A zXa|73;=;^;{m)oj^k%nTn18iG?T0e3_+vg4qIK)My;khLx|7*v4+Z5H87ngBCplQj zTwrL=h_jc&?x~urxNaI;emQAUUHNiY|28Z_JLm1yU{-&fozjnBC11u$bd?8-doT*n zcDRHjT2d8eTNa^v6)?<-StDKL!{TjU3{#dfvuQhh%6}nd?K(V^2v#%~ zXxc;8UU6Z@r8C5RHX!T^ur^N+lMogsB8@!SN!DI13f*DEwS!JMM64AHCX&Dkk}>T7 z6lo%RMT>~kp3aQ8+Q2D?fEA5gzdS4+osOI~Ez&IM!pwo1Bo-TrsW5xgis-61ES!u{ zwA+lmLijDUDYMytmw%RD4j^l7ErEHV{9X#{yAvd%9kTZ7rNg|W#C1d5DF?_3=!%7X zUYj~n+-r-UR(q~U)1wMA^K`E^W)iS8%z~_4IYm*eL z`K!EWYNLyc71k9!YQK%P;#Ko1n+sermX7U$QBp0bwULc1@_*<;m?dEq=_)~3wdlG* zb0wKDTr!r@_Go*Jk}1(k#Z}Mj8+lf-uA+6`N7*8WKDrd23khv}HnK__&`!*1Q2`-2 z<=|P{vd`*Y%nDqQG3LTQF&lsr+URV=NP=uLsleG(Tsw+brMhzF4N3V(>mNiv%p_xI z$DWNG<1Dro&wt)J6%ZZ;tTJ7>>rQU1t3DGsgiXd0+E!|>KmvMva63)|LVU`x*9zk#LNvADw1`ndd(VQmP%qCKsas3KMcv4Tm)5L11b#)TO- zJh&y|n$Tf(&nQs0B%Uf;@`Po^Bx5n{D6v;3Tvv7^E`L|2cIPbX5MIk(=&3s@-=NIs zWGtffjM!em-s~JEU{)M6qVfyFD$rHpse6jaYSVJ1$yh{7&PI%A@$bX(iyZ}o=#+zI zg>~i3>rbkD3uH!B#v!~|ogH=1fiIcI2wjWhm2ITu& z;Y58%5`VHClIn`{)cvra%#r{c(gtTEfxT9w{{BcN!znrCNLc}0L7sXFEF`le8AF@+ zY-CDyie_+d8;A>!HX@nd772BAvzi3~%D@JvhZ&j0$yi7`3+>eiHUxt}TtPsXF|1i# zdD|{3{PvQtyv(Ax5Yo1Zz04pP>;^SuGddiNS%0&-I*s%)?=B5XVui~GU_yJV1oqkm zgb!F;I3SQP8?jbdUD>mG$rs-Po0VCZj1k&>@b7tCg!j6Q8VLxygq78mAfSF8uta9m z@LF0-YX}loB zH-A0>mX%p>Oc~HR`V`yM^RT!cg7Qnis?RA;8TY^Lx$?W?#+nYhM)j^Qqb9M!dqjkG zRq=fN=5#PJUQio+bL=JowSC{17@gtN+8p1b%15q!+6LUsa@_jpnj~WZ?O^5iuGfX% z>yvSPI47RcN-g4gt2>&l_9rK=*5%rVHGk&r7}bI@i*mpkTKit#U!IP(gUc^l6zj^K z)d~?-o0!nro^0=q!kq8jF8lS|?6(Z5zxClEO3c^(`E2hlzIpaHT6ox!<0%w==JmmL z^U6o>`$aE2O*WEgVvxl5+S>SzfArm@za}Sxf`E$f7?O#YM@U`oE5GvZxNg_OdVet) zv<=2WXb=qV8fROsfAKFzKA={N_F%GDAFj81-ukZcP5)_EFimE7nl$uy7w^XN%?Sgl z-e~pB*?NDuJ@HlFP+tF+|B^1xIqjB@<5k3TU5p=>yOZO+tp5M`y7J1mKl8s3*Js~) zMNz)~z5l$lp*`=Gi`c97Vz%6!Uq#x${`ywW^`Ve1#{%d;c qFTsruKl=ESr}zHBkG}MpqWmB2!LP=l$}3X<0000un~5Q%zwLHAMbY}BA9=t(?&i>esja_Ye{r`p-pgl*gy0br4p*+g<|5B2N{&yr8aDDF8x6lOiJCrpv z4&7p#+*9(n+H~%HCZqA&`BD2hgd;t&zh_k zd+4oa~ULHD$H4e_&%R_HHE02fXSm&pK%VVkWSVxMb*4GCHiKRwj9VeE`sDb&!1xub= zBg9gJv5pW+ZM)0-S#!ryL$cO2Z0000W>;`!S#oArab#F=Wms`#SaD@o zab;I=Wms`#SaD@oab;L>Wms}%S#xJvb7xz0Xj^n?Ty<$(b!uI9YF>A1Uw3R@cx+&J zZDDzBVR>$1dT(NSZ)1CKWPEUBd~s!ca%TVk|AEHu*Z=?k5Px)1PE!B|2ODf{ZpO#R z$_p&~vFPHdRH(V&M zOHBW~vA(2>l;~UG-pP-!T*5z@@&tE_H=ar}+2GFL_ks10bup|f!#Cx^VX=az-JVq|SZkiWM$DQ6Y85Q(ncefnnrmcG2+T{? zEc&aK;04+yVHMQ?MMkZ8F7x1kmYtX@+k|R>JTi*B!2u6gI(q2#=OL4yV70s;{xGl> zMNrCS&wt7ls-fELPZqKRkL~gKfbpIT8ypq7+QIS z;#i%(hfxR%?Vioau%6(d_b?y~3k_hkJBWY>quj$?{2~wini7QSeHILytp+)>d6X}y z1q%c;dk3D|9W@lMcLdQ;Fb_Qrt9^&%H+anChckQV1EfKP5W94pW6$dCD%Z1P zeSgD4A4Gz(76gNRAo{Eb8;^Crhdyu?Kr>1n#Ci`UrolQD2{P{QfUj$;yGQd3SO-1y zkyx8v;VVy~-c5>i+e07c3LwN{xDV7mTxX-Rp5eX&P1vAmpuwh}-NTtY^wE6v3T3-5 zC4lARShqa%k-8#7bFlE)_bi1_YueVZXMe=HI(fIe336<6_Ka9ZoB|JnysZppniVSy zn*AKTq)B6`iOp<9QS>6%(m7+PQC6l)Zk1TXB3#V*jx$7lmJ}*sTUaNFr6wzEfgEm< z=r>2{jIq>s#v-q+MYuqgrirC`*OskIkS*6HK-o(>Q5?S9Y@rf98DA9!9<9bA7JqAz zoa0%#`iS!8*0*Rp2Xbrc(&eZ%BBBVeX9}qKkZ?Yd4b8{j$Er446W01^ z(#tndTlKD%Mh_H~RtK<_V`8aV0Dr4t1GSUMN(ZW#pi`%Du~crL)-s!Sk=wse>k97- zSdScpiVVuHN}LciPXacLilr32o*u7PzvSM2Z8X?4DwbO3kG^j*DTKl&06UHYR(r0y z7es05?*nofcpVh*U{fttYh9S_i|{tnrIq`s*hQJ?SE%~e=Mb*HXJfP`^8Ed)wDjP zkEh2{Ub-$Rhmb{WtlGLsSGS{_W<97A<$_fh<=k#Rq;!3IVl1TvR6FRvxRcAc{(5_z zQc53gK7BbQmQsT%$^lJN8Xk4y#h2f2KBV+7hS_ce#q;w-00000NkvXXu0mjfx8$}^ diff --git a/assets/images/pharmacy_module/bg_3.png b/assets/images/pharmacy_module/bg_3.png index 127c266984f68af8a40dc6f9aa0b95d0d7282ef4..3a28d5f97a3f46e35b4b57837922217cff447101 100644 GIT binary patch delta 1508 zcmVuNk3CL_J4}u_ON=~9iabnw-Sk3vz8LsF1LQ;UN?4RjS(Hm! zl}uZeOtT$WB7@VwzN9npI<(R%Dx3WSdxJoLFX@ zS!bPEXPsMUo?B_2T>t<7V-FPs0000ObW%=J00jmI85$dEYiw<9#m2|T$;{2p(DC#1 z%CrNx00001Vt-3VL_=rL4PpQQ1hh#+K~!ko?VD?tn>G-J>85Ftwn>^M-B=O`8G*QC z`O@`X+KfE~wq@$37~qhTMP-@UnVHpefY zMq?4`Qy%AfB#hdd$78-n{N&gxetfyH>Zj3Ys_ymYLVvCG7%PRgBUO*Vc0{XHq`#Of z5X|9#;VdQ=q;C8 zU-A7zw38D~qN~To7HaZBi@Mso4%pPyzFBSRYJcCXHg&Z>*1fvwacY_MW<3SXTHS!~ zEM}kwlS)T5P6SwsbGMtWMiL4$jBT;rDPVib3F;A~-{`FORcDiKx+)|Tlc6jvvBm}L zWumHp8J2&;3?_d)%LyHH6;3A-w2a2QZ+}GuypU3Sn6A2v8T*1y5Fei}wp!|HkV9tV za({9@){eRw8=vrt1f86#Jnt%k8+NHzNh#rcQ8h{x z{=a>3CP)LTyamOUtNC|xLi>6ZYDgqy0Dl*1>TS3|2G}8K0rfI;>u;?VDu530V)TR|$hVtR%#$&q%MV&3yn8 zcnuB`Cbdr_hq49&md5A)PU+II55T0vtu~aS(%3gG!>+7#n{{UTv#HV9aJ{Zq+<$G+ z2jHft@@3gnRhi~$DWk5eO*uiswupb^?j(I8f(GV5_+44CxlPyTDit6xv?vbQQP(Z# zjZYBhpmf{O^xY@i>%T=cdY+Yr$@;X?rl`VsOoq;iJZ54J?27`5&dkbKW7daa!jsZF zn)SGrU+bjL>O%V%)*GXx+2tH;j#UWUk9KShaUabDK; zuV+0KRZ(;C+7Ii^WBZ!Wv_tEpPeXQE))z`0tX)qj&!(R=cd%7lZnj^ZsI3 z-#TwDhV_+m_3=VbKm6o4FE0c3!_V748eP49JM;j%{{7X)s{a9(?>$lMNgv|?0000< KMNUMnLSTXy=jLbt delta 1634 zcmV-o2A%o#3-b(+B!8k%OjJbx00320fJtqVUS5P;UVvL(fm&aHTV8-$UVvL(fLmUG zTV8-$UVvL(fLmUGTV8-$UVvO*fLvdJU0{J;VS-;`gJ5EVU}J<~WQ1X4g<@reV`heA zXNP5Hhh=DpW@(6LX^CfQiD+wzX={pUY>R4bi)w9*Yi^8eZhwtzZ;fqmj&5*{ZgG!q za*uFwka2U7a&(b$b&_*+l682Lc6pWm|NjyCrr`hp01$LiPE!B|2ODf{ZpO#R$?B-l8RKX9LgU8P%V_4zVN8M`xcdC%dpPgo` ze~2pbp8Kb&Em5J1VJ$BxuDQn^aC%mH0j$K>)mOS2v)D81MnBl|Vhffp-@rLuE4!n( z2HzEOM#kxCp%!4?u`kwNj&;8$wBDOO>ulAbtACsq`?^{xFq2%>o>+MWD8+i=;`+GL zzh3o(*N1$k{t0v= z`J2=wnw)iH55P2bHMev*LZ@IQNlc=+dNW^H+S759ve?N9god)NHnr0OSG7X4_qR41 z5r2JE5}ke(DaD4(MslaaiK_81*0v|C^>$xp;}>>!PgjjyE%P_GkSrB!^>WoGRoFEf zwX$!l@~DSZZQ$yb+sE#n(66iQn1os^Xvq;t_uP9#Zm zQdVN@s?k-6ItqoNo*Q%-yPPOql*cGmF5q&hyT8Sh9x?~Wl)~={{LY81oDRz+AIrMY zpjpc4tkl{r$DGbu1r)}vmU)-$=YIr#(N};3eqpH&VD0V+_R|OWB(x*&At_i7bAR^c zwRh*MbI4HwZzVZM46W-!?x>x>Kj#D)H$yn}obb)4EtYPqqsZJ@+d6Me6{(77zO1cz z1@UORK2E!nVglA~fp2o51T#TXK5I6JjQ;IO{R5X8gft!fFKG*Mxf%>-`hdfBAE`4z#9WvkhXusPbdwW0VffWnUJ{*RK&u8CSQ&lPMi`5Ll zCBRZ4W$9>9oF2=KW4B`n`G3n-B4iT*B4u7kf!#||x^Uo>XVGkGD`^M~o*CV7nFA_M zO9(eE4Yq_JBUTg{In=6d zf+t4(d*_+`UIj{7;zG~ltf&c&j diff --git a/assets/images/pharmacy_module/bg_4.png b/assets/images/pharmacy_module/bg_4.png index 423ab4217680468c4f013c5d09a457d84f852444..234ebe7b4287b0975e21434433605315d29dbc7e 100644 GIT binary patch delta 1538 zcmV+d2L1WV3zH0xBYy!1P)t-s0000pW-}{QD@ko6GiE6}VkbFhFE?c?H)Ja|V=Xvk zEI4E=He@U}WGpviEH`5bV5vYLQQo;PIg33c12HjMo@P~QFupEc}P-uNmF`CRC-HQ zdrMY)OjdkNSA9-ceot9`P+EUbT7OYnfKpt6Q(b{nU4m6!f>mFGR$+u#VTD;@g<4~V zT4aY?WQSa3h<{yXh+b!jUTBJ6Xo_I}|NqP=Xc+(i02p*qPE!B{1_v1$8)|E8ZEnTJ z$H>Xd&CbyA^YqHJ1GoSH00Cl4M?_bB3fUh300fmuL_t(&-qo91ciKi2Mkh|wByDqP z-8!EnKwJdavH>T;27@nPt~#`KV$AvfKcx@SfFz?L(|_fqL2qK^VJ~UVo}*c@5aRVO zpT0ot>&wUYdqN2D^Pkv-YyXW9uXh6#_+wA}ie0(hiO&ktSvA`-kEgbG_fZ@uORC?p zceT9x1EKCy?ear^G`lB9{-7}H4=#m&P?&YW+Rm_k=iJV)&UVNFm#aI#YSnDZtS=TB zLymL?M^EI^tz?J5NYDB#pQn>8k=`Lx{C9nv{IR9Dw|YdKm!L zgu1$7tY1AhC1PnzR|bIUlrA&?6-^mdtxbcR_rk9Y0A>Ga9=UW501mZPVb$86n-cMG zN`Gw)K#j-&pq-O@qzY@(d+}8t@z|v%05pgi0JIC5R#frTrb``w?a~V->0twru(Ft@jTEq&JRx#qp_dcaMspk*nu76UI_x@p{aFFu-E6`IwdX@7amC{Xkf%Twy;0LtmJ>Q^)_tr-QDxplpk zHKuynteKwoGy`tltjp~gx%re?bGPAXMY<_-D|ZB6=`>mMLk}_PW;D0H(rL05BGbyD zORY7zl}e||dg>ucH&2MxjzPuL9JXp2PX6DEC z%B2A_|9zC0HO5VuTlvK$m3}sBYtD}s#*&r#%=h&b>(xKZ!$Km~CvHYQ4ke;gdW)05 zT#xyCL$Z!gC1$rQSx>aHIWM|K0)N&{WLk;jHZXuY+n-ui9@sy)vUvpHjQL^73gleo zP6F2MxVXkmnOnK)e5JQ!tFcOW%#+g6*P1iu$BvP(1F>$dR^9faz=G$&g>UmC^Ia{_fqAGCn^vp0_!?A<>Bj4uDYf&XKyPvM@0bUfcn`$ZjW4L&fZX%gm#32 z|HWl3S6wUhGtJfiEzjpeZhO*Ia7Q?G8)+ZC{Utty?gKl*MQ}%OhF03B_#obgCib4U zBgpe%dHC9NjMP!_R_yHu@Acz#(@H6uJ}G{GCB&Qk=&$wvKdrm~>Q6!lvG?vn_>VWV oVi^EVZ@N`QKo5R<`$~v^0l$#6x))qsDF6Tf07*qoM6N<$f)oPN8~^|S delta 1466 zcmV;r1x5Ok49g3UBYyzoP)t-s00010s#R^aNnW8$VWm)Drchy}QDLP}VWm%Dq)=d` zP+_G|VWv=FrBGp|P+_G|VWm)FrBPz0QDdf3W2RGNr&DF8RAr}CW~fzXs8(mGS7@nN zX{uRjs#{mZ>?Z(tzdAjVR5cva(}O5bFXA{uw`|yW_7V= zcClx7v1oU)X?U_}d9rGGvuk>@YkIS6d$etQv~GO0Zhf_HezkCZws3#8aeuaQfVXmi zw{wBFbb`2ag1B{qxORlOc7(Zig}Hc!x_E}Vd561thr4@-yLzXRx z?)U81>oHe#j(OH8JPoG{d)4OHXWfQ#m0{LrDCdTClOwMdG;_mhhI;^$tcuoaHTwH~ zg?U!Nj(^Ej23cpYoy-l#Xmjkd{(;)x-@p*-D-?6X`UqlfSl`Un471vxcI@zzmAZvXUuqm48o_zF% zjV49LSUZj>QZ{QAnvvp_*JwyOi_8$~0Iez!HWdfC{|LE7Iy0;TuQolKP0wZr9Z)so zw0~G(?W4JCbB)Hd%|3FM6+b#;7!#~Ani9mO6R^qa$WiDFlNewvnPY<3a*khko3bg~ zA+zSLx+R}I>(E^{U4*((HmM8~GG~=;V{G~zp>oKuJ0bfT5Z|#`IyA40JHjysqHLBa zn+$XWpEb@V)e+p$t?QJsW(`j(;r^<`%?4$&>ThSP zS&CC2*w9C-D!@H`)UtvXjXxt_<87{7n_fxdI?>K&B^&G2DeF4;_EkUiKoj3TD1V7r zV{D2BT6mkonYZe6J`Jn>3cImzWVM$7PwI(v`Uqf1iCBG`xWBqKE6d=tf^CinVjHEg zN?5td9N@XBr z<@h1M_Q;C;H~`}WtP`siG5h&8see`1=2Ek|B1=csA{M#RPpl%T3ONC*T#dFlh#0`r zu~zS~#qP0Q7s>;GRXf(JI^4l-SWK7$Z)U%c%@1u30e1Al@8DZH#Y}R)s3y*=cWfR< z##%boK%nBx3Ir<7EF>q-*EpMAfAvSk>NwTjaA^k`mGm$TG%9V=J7<1X-+$O_Mh)Ob zjmz-zYe0#ZR^A>Lb~zSU|7O!0z~%LjmGi7Po2LPM%Co{MT5jOQZD-ofC}UKP`fYiY zK76f*wliJS&-&=?-_URNBepYchINfb)~NV5`(No>eja^XIM9U5QSq}77uNw;g+4Cy z4qv%?IeSv>`U`$`=Q{jq`!nOy$|s;+k_U~xTzwBcydk { ) : CachedNetworkImage( imageUrl: item, - fit: BoxFit.cover, + fit: BoxFit.fitWidth, errorWidget: (context, url, error) => SizedBox()), ), diff --git a/lib/pages/pharmacies/widgets/home/GridViewCard.dart b/lib/pages/pharmacies/widgets/home/GridViewCard.dart index 99425aa1..a8e3fe9b 100644 --- a/lib/pages/pharmacies/widgets/home/GridViewCard.dart +++ b/lib/pages/pharmacies/widgets/home/GridViewCard.dart @@ -29,10 +29,15 @@ class GridViewCard extends StatelessWidget { flex: 2, child: Padding( padding: const EdgeInsets.all(6), - child: Texts( - text, - color: Colors.white, - fontSize: SizeConfig.textMultiplier * 1.5, + child: Column( + children: [ + Texts( + text, + color: Colors.white, + bold: true, + fontSize: SizeConfig.textMultiplier * 1.5, + ), + ], ), ), ), From c56e4a1a5c72d9ef376dd0165b6e59cd33c79622 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 5 Oct 2021 16:55:22 +0300 Subject: [PATCH 34/67] cart fix --- lib/widgets/buttons/GestureIconButton.dart | 68 ++++++++++------------ 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/lib/widgets/buttons/GestureIconButton.dart b/lib/widgets/buttons/GestureIconButton.dart index 841d7ea6..329755f6 100644 --- a/lib/widgets/buttons/GestureIconButton.dart +++ b/lib/widgets/buttons/GestureIconButton.dart @@ -3,12 +3,12 @@ import 'package:flutter/material.dart'; class GestureIconButton extends StatefulWidget { GestureIconButton( - this.label, - this.icon, { - Key key, - this.onTap, - this.backgroundColor, - }) : super(key: key); + this.label, + this.icon, { + Key key, + this.onTap, + this.backgroundColor, + }) : super(key: key); final String label; final Widget icon; @@ -29,41 +29,35 @@ class _GestureIconButtonState extends State { setState(() => _buttonLongPress = !_buttonLongPress), onLongPressEnd: (_) => setState(() => _buttonLongPress = !_buttonLongPress), - child: Wrap( - children: [ - Container( - decoration: BoxDecoration( - border: Border.all( - color: widget.backgroundColor != null - ? widget.backgroundColor - : Colors.grey[200], + child: Container( + decoration: BoxDecoration( + border: Border.all( + color: widget.backgroundColor != null + ? widget.backgroundColor + : Colors.grey[200], + ), + color: widget.backgroundColor != null + ? widget.backgroundColor + : Colors.grey.shade200, + borderRadius: BorderRadius.all(Radius.circular(8))), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: const EdgeInsets.only(right: 8.0), + child: widget.icon, ), - color: widget.backgroundColor != null - ? widget.backgroundColor - : Colors.grey.shade200, - borderRadius: BorderRadius.all(Radius.circular(8))), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Expanded( - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: const EdgeInsets.only(right: 8.0), - child: widget.icon, - ), - Texts( - widget.label, - color: _buttonLongPress ? Colors.white : Colors.black, - ), - ], - ), + Texts( + widget.label, + color: _buttonLongPress ? Colors.white : Colors.black, ), - ), + ], ), ), - ], + ), ), ); } From a5751f0d7065f7e428bf9109dc73aa09d78bdcc8 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 5 Oct 2021 17:20:38 +0300 Subject: [PATCH 35/67] handel un login cases --- .../pharmacies/screens/cart-order-page.dart | 2 + .../product-details/ProductAppBar.dart | 8 +- .../product-details/footor/footer-widget.dart | 18 +- .../product-details/product-detail.dart | 497 +----------------- .../product-name-and-price.dart | 6 + 5 files changed, 32 insertions(+), 499 deletions(-) diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index c2ebf4b2..3877ce29 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -36,6 +36,8 @@ class CartOrderPage extends StatelessWidget { appBarTitle: TranslationBase.of(context).shoppingCart, isShowAppBar: true, isPharmacy: true, + isShowDecPage: true, + description: "", baseViewModel: model, backgroundColor: Colors.white, body: !(model.cartResponse.shoppingCarts == null || diff --git a/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart b/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart index 09d595f7..2fad8016 100644 --- a/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart +++ b/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -6,6 +7,7 @@ import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; +import '../../../../locator.dart'; import '../../compare-list.dart'; import '../cart-order-page.dart'; import 'CustomIcon.dart'; @@ -14,7 +16,10 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { final PharmacyProduct product; - const ProductAppBar({Key key, this.product}) : super(key: key); + ProductAppBar({Key key, this.product}) : super(key: key); + + AuthenticatedUserObject authenticatedUserObject = + locator(); @override Widget build(BuildContext context) { @@ -42,6 +47,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { ), ], ), + if(authenticatedUserObject.isLogin) Row( children: [ IconWithBg( 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 88302480..3ecf4b83 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -1,4 +1,8 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; +import 'package:diplomaticquarterapp/pages/login/login.dart'; +import 'package:diplomaticquarterapp/pages/login/welcome.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/footor/quantity_box.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; @@ -6,6 +10,8 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; +import '../../../../../locator.dart'; +import '../../../../../routes.dart'; import '../../cart-order-page.dart'; class FooterWidget extends StatefulWidget { @@ -30,6 +36,8 @@ class FooterWidget extends StatefulWidget { class _FooterWidgetState extends State { double quantityUI = 70; bool showUI = false; + AuthenticatedUserObject authenticatedUserObject = + locator(); @override Widget build(BuildContext context) { @@ -185,10 +193,14 @@ class _FooterWidgetState extends State { widget.price > widget.quantityLimit || widget.item.rxMessage != null, onTap: () { - widget.addToCartFunction( - widget.price, widget.item.id, context); + if (!authenticatedUserObject.isLogin) { + Navigator.of(context).pushNamed( + WELCOME_LOGIN, + ); + } else + widget.addToCartFunction( + widget.price, widget.item.id, context); }, - borderRadius: 5, color: Colors.green, ), diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index d9c623f9..5e8f4dd5 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -105,8 +105,7 @@ class __ProductDetailPageState extends State ProjectViewModel projectViewModel = Provider.of(context); final screenSize = MediaQuery.of(context).size; - return customerId != null - ? AppScaffold( + return AppScaffold( appBarTitle: TranslationBase.of(context).productDetails, isShowAppBar: true, isPharmacy: true, @@ -399,500 +398,8 @@ class __ProductDetailPageState extends State isOverQuantity: isOverQuantity, addToCartFunction: addToCartFunction, ), - ) - : AppScaffold( - appBarTitle: TranslationBase.of(context).productDetails, - isShowAppBar: true, - isPharmacy: true, - isShowDecPage: false, - showPharmacyCart: false, - showHomeAppBarIcon: false, - body: SingleChildScrollView( - child: Column( - children: [ - Container( - width: double.infinity, - color: Colors.white, - child: Column( - children: [ - Image.network( - widget.product.images[0].src.trim(), - ), - widget.product.discountDescription != null - ? Container( - width: double.infinity, - height: 50, - color: Colors.yellowAccent, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - flex: 1, - child: Container( - alignment: Alignment.centerRight, - child: projectViewModel.isArabic - ? Text( - widget.product - .discountDescriptionn, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 17), - ) - : Text( - widget.product - .discountDescription, - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 17), - ), - ), - ), - SizedBox( - width: 10, - ), - Expanded( - flex: 0, - child: Container( - child: Image( - image: AssetImage( - 'assets/images/offer.png'), - ), - ), - ), - ], - ), - ) - : Container(), - ], - ), - ), - SizedBox( - height: 4, - ), - Container( - width: 500, - height: 150, - color: Colors.white, - child: ProductNameAndPrice( - context, - widget.product, - customerId: customerId, - addToWishlistFunction: addToWishlistFunction, - deleteFromWishlistFunction: deleteFromWishlistFunction, - notifyMeWhenAvailable: notifyMeWhenAvailable, - isInWishList: isInWishList, - ), - ), - SizedBox( - height: 6, - ), - Container( - width: 500, - height: 120, - color: Colors.white, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Container( - child: Text( - TranslationBase.of(context).specification, - style: TextStyle(fontWeight: FontWeight.bold), - ), - ), - ), - Divider(color: Colors.grey) - ], - ), - ), - SizedBox( - height: 6, - ), - Container( - width: 500, - margin: EdgeInsets.only(bottom: 100), -// height: 350, - color: Colors.white, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - 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, - ), - isDetails - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container() - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = false; - isReviews = true; - isAvailability = false; - }); - }, - child: Text( - TranslationBase.of(context).reviews, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - isReviews - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container(), - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = false; - isReviews = false; - isAvailability = true; - }); - }, - child: Text( - TranslationBase.of(context).availability, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), - ), - color: Colors.white, - ), - isAvailability - ? Container( - width: 100, - height: 5, - color: Colors.green, - ) - : Container(), - ], - ), - ], - ), - SizedBox( - height: 10, - ), - isDetails - ? Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: Text( - TranslationBase.of(context).description, - style: TextStyle( - fontSize: 17, - color: Colors.grey, - fontWeight: FontWeight.w600), - ), - ), - SizedBox( - height: 6, - ), - Divider(height: 1, color: Colors.grey), - SizedBox( - height: 10, - ), - Container( - child: Text( - projectViewModel.isArabic - ? widget.product.shortDescriptionn - : widget.product.shortDescription, - style: TextStyle( - fontSize: 16, - fontFamily: 'WorkSans-Regular'), - ), - ), - SizedBox( - height: 10, - ), - Container( - child: Text( - TranslationBase.of(context).howToUse, - style: TextStyle( - fontSize: 17, - color: Colors.grey, - fontWeight: FontWeight.w600), - ), - ), - SizedBox( - height: 6, - ), - Divider(height: 2, color: Colors.grey), - SizedBox( - height: 10, - ), - Container( - child: Text( - projectViewModel.isArabic - ? widget.product.fullDescriptionn - : widget.product.fullDescription, - style: TextStyle( - fontSize: 16, - fontFamily: 'WorkSans-Regular'), - ), - ), - ], - ), - ) - : isReviews - ? BaseView( - onModelReady: (model) => - model.getProductReviewsData( - widget.product.id), - builder: (_, model, wi) => model - .productDetailService - .length != - 0 && - model.productDetailService[0] - .reviews.length != - 0 - ? ListView.builder( - physics: ScrollPhysics(), - itemCount: model - .productDetailService[0] - .reviews - .length, - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemBuilder: (BuildContext context, - int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - child: Row( - children: [ - Container( - child: Text( - model - .productDetailService[ - 0] - .reviews[ - index] - .customerId - .toString(), - style: TextStyle( - fontSize: 17, - color: Colors - .grey, - fontWeight: - FontWeight - .w600), - ), - ), - Container( - margin: - EdgeInsets.only( - left: 210), - child: RatingBar - .readOnly( - initialRating: model - .productDetailService[ - 0] - .reviews[ - index] - .rating - .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: 10, - ), - Container( - child: Text( - model - .productDetailService[ - 0] - .reviews[index] - .reviewText, - style: TextStyle( - fontSize: 20), - ), - ), - SizedBox( - height: 50, - ), - Divider( - height: 1, - color: Colors.grey), - ], - ), - ); - }, - ) - : Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text( - TranslationBase.of(context) - .noReviewsAvailable), - ), - ) - : isAvailability - ? BaseView( - onModelReady: (model) => - model.getProductLocationData(), - builder: (_, model, wi) => - ListView.builder( - physics: ScrollPhysics(), - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemCount: model - .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(model - .productLocationService[ - index] - .projectImageUrl), - ), - SizedBox( - width: 10, - ), - Expanded( - flex: 4, - child: Text( - model - .productLocationService[ - index] - .locationDescription + - "\n" + - convertCityName( - model - .productLocationService[ - 0] - .cityName - .toString(), - ), - 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: () {}, - ), - ), - ], - ), - Divider( - height: 1.2, - color: Colors.grey) - ], - ), - ); - }, - ), - ) - : Container(), - ], - ), - ), - ], - ), - ), - bottomSheet: FooterWidget( - widget.product.stockAvailability != 'Out of stock', - widget.product.orderMaximumQuantity, - widget.product.orderMinimumQuantity, - widget.product.stockQuantity, - widget.product, - price: price, - isOverQuantity: isOverQuantity, - addToCartFunction: addToCartFunction, - ), ); + } } 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 b7906b78..619a4fb1 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,4 +1,5 @@ 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'; @@ -8,6 +9,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; import 'package:rating_bar/rating_bar.dart'; +import '../../../../locator.dart'; import 'CustomIcon.dart'; class ProductNameAndPrice extends StatefulWidget { @@ -19,6 +21,9 @@ class ProductNameAndPrice extends StatefulWidget { final Function addToWishlistFunction; final Function deleteFromWishlistFunction; + AuthenticatedUserObject authenticatedUserObject = + locator(); + ProductNameAndPrice(this.context, this.item, {this.customerId, this.isInWishList, @@ -59,6 +64,7 @@ class _ProductNameAndPriceState extends State { : Colors.green, ), // SizedBox(width: 20), + if(widget.authenticatedUserObject.isLogin) widget.item.stockAvailability == 'Out of stock' && widget.customerId != null ? InkWell( From 1e1e230908b0c713e31620e9b173ffd003b9e66e Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 5 Oct 2021 17:42:08 +0300 Subject: [PATCH 36/67] fix call service in case not login --- .../pharmacies/screens/product-details/availability_info.dart | 2 +- lib/pages/pharmacies/screens/product-details/reviews_info.dart | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pages/pharmacies/screens/product-details/availability_info.dart b/lib/pages/pharmacies/screens/product-details/availability_info.dart index 0c00d22a..55d2468c 100644 --- a/lib/pages/pharmacies/screens/product-details/availability_info.dart +++ b/lib/pages/pharmacies/screens/product-details/availability_info.dart @@ -10,7 +10,7 @@ class AvailabilityInfo extends StatelessWidget { Widget build(BuildContext context) { return BaseView( onModelReady: (model) => model.getProductLocationData(), - + allowAny: true, builder: (_, model, wi) => NetworkBaseView( baseViewModel: model, child: model.productLocationService.length == 0 diff --git a/lib/pages/pharmacies/screens/product-details/reviews_info.dart b/lib/pages/pharmacies/screens/product-details/reviews_info.dart index ed1970cd..c48e249f 100644 --- a/lib/pages/pharmacies/screens/product-details/reviews_info.dart +++ b/lib/pages/pharmacies/screens/product-details/reviews_info.dart @@ -15,6 +15,7 @@ class ReviewsInfo extends StatelessWidget { Widget build(BuildContext context) { return BaseView( onModelReady: (model) => model.getProductReviewsData(product.id), + allowAny: true, builder: (_, model, wi) => NetworkBaseView( baseViewModel:model , child: model.productDetailService.length != 0 && From 47e19c4ab5ecfa0aed24d0eb2cc39905231f834d Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 6 Oct 2021 11:06:10 +0300 Subject: [PATCH 37/67] add loader and cache on images --- .../product_detail_view_model.dart | 2 +- .../product-details/availability_info.dart | 136 +++-- .../product-details/discount_description.dart | 1 - .../product-details/footor/footer-widget.dart | 3 - .../product-details/product-detail.dart | 502 ++++++++---------- .../product-name-and-price.dart | 2 +- .../screens/product-details/reviews_info.dart | 146 +++-- .../icon_with_bg.dart} | 1 - .../product_details_app_bar.dart} | 8 +- 9 files changed, 354 insertions(+), 447 deletions(-) rename lib/pages/pharmacies/screens/product-details/{CustomIcon.dart => shared/icon_with_bg.dart} (93%) rename lib/pages/pharmacies/screens/product-details/{ProductAppBar.dart => shared/product_details_app_bar.dart} (96%) diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index c7ac0a04..2b1d3f86 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -36,7 +36,7 @@ class ProductDetailViewModel extends BaseViewModel{ Future getProductLocationData() async { hasError = false; - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _productDetailService.getProductAvailabiltyDetail(); if (_productDetailService.hasError) { error = _productDetailService.error; diff --git a/lib/pages/pharmacies/screens/product-details/availability_info.dart b/lib/pages/pharmacies/screens/product-details/availability_info.dart index 55d2468c..6a6fdfd5 100644 --- a/lib/pages/pharmacies/screens/product-details/availability_info.dart +++ b/lib/pages/pharmacies/screens/product-details/availability_info.dart @@ -6,80 +6,76 @@ 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 BaseView( - onModelReady: (model) => model.getProductLocationData(), - allowAny: true, - builder: (_, model, wi) => NetworkBaseView( - baseViewModel: model, - child: model.productLocationService.length == 0 - ? Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text( - TranslationBase.of(context).noLocationAvailable, - ), - ) - : ListView.builder( - physics: ScrollPhysics(), - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemCount: model.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(model - .productLocationService[index].projectImageUrl), - ), - SizedBox( - width: 10, - ), - Expanded( - flex: 4, - child: Text( - model.productLocationService[index] - .locationDescription + - "\n" + - convertCityName( - model.productLocationService[0].cityName - .toString(), - ), - 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: () {}, - ), - ), - ], - ), - Divider(height: 1.2, color: Colors.grey) - ], + return previousModel.productLocationService.length == 0 + ? Container( + 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(), + ), + 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: () {}, + ), + ), + ], ), - ), + Divider(height: 1.2, color: Colors.grey) + ], + ), + ); + }, ); } } diff --git a/lib/pages/pharmacies/screens/product-details/discount_description.dart b/lib/pages/pharmacies/screens/product-details/discount_description.dart index 1c2b27d4..1dde8175 100644 --- a/lib/pages/pharmacies/screens/product-details/discount_description.dart +++ b/lib/pages/pharmacies/screens/product-details/discount_description.dart @@ -1,5 +1,4 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; -import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:flutter/material.dart'; class DiscountDescription extends StatelessWidget { 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 3ecf4b83..7cdfe7f2 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -1,8 +1,5 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; -import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; -import 'package:diplomaticquarterapp/pages/login/login.dart'; -import 'package:diplomaticquarterapp/pages/login/welcome.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/footor/quantity_box.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 5e8f4dd5..c263f77a 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -25,7 +25,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_mo import '../cart-order-page.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; -import 'ProductAppBar.dart'; +import 'shared/product_details_app_bar.dart'; import 'availability_info.dart'; import 'details_info.dart'; import 'discount_description.dart'; @@ -102,304 +102,228 @@ class __ProductDetailPageState extends State } Widget build(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); - final screenSize = MediaQuery.of(context).size; - - return AppScaffold( - appBarTitle: TranslationBase.of(context).productDetails, - isShowAppBar: true, - isPharmacy: true, - isShowDecPage: false, - customAppBar: ProductAppBar(product: widget.product,), - body: SingleChildScrollView( - 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, + return BaseView( + allowAny: true, + builder: (_, model, wi) => AppScaffold( + appBarTitle: TranslationBase.of(context).productDetails, + isShowAppBar: true, + isPharmacy: true, + isShowDecPage: false, + customAppBar: ProductAppBar( + product: widget.product, + ), + body: SingleChildScrollView( + 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.discountDescription != null) + DiscountDescription(product: widget.product) + ], + ), ), - ), - SizedBox( - height: 4, - ), - Container( - color: Colors.white, - child: ProductNameAndPrice( - context, - widget.product, - customerId: customerId, - addToWishlistFunction: (item) { - addToWishlistFunction(item); - setState(() {}); - }, - deleteFromWishlistFunction: (item) { - deleteFromWishlistFunction(item); - setState(() {}); - }, - notifyMeWhenAvailable: (context, itemId) { - notifyMeWhenAvailable(context, itemId); - }, - isInWishList: isInWishList, + SizedBox( + height: 4, ), - ), - 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, + Container( + color: Colors.white, + child: ProductNameAndPrice( + context, + widget.product, + customerId: customerId, + addToWishlistFunction: (item) { + addToWishlistFunction(item); + setState(() {}); + }, + deleteFromWishlistFunction: (item) { + deleteFromWishlistFunction(item); + setState(() {}); + }, + notifyMeWhenAvailable: (context, itemId) { + notifyMeWhenAvailable(context, itemId); + }, + isInWishList: isInWishList, + ), + ), + 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, + ), + width: double.infinity, ), - width: double.infinity, - ), - // Divider(color: Colors.grey), - ], + // Divider(color: Colors.grey), + ], + ), ), - ), - SizedBox( - height: 6, - ), - // Container( - // height: 500, - // color: Colors.white, - // child: Scaffold( - // backgroundColor: Colors.white, - // extendBodyBehindAppBar: false, - // appBar: PreferredSize( - // preferredSize: Size.fromHeight( - // MediaQuery.of(context).size.height * 0.070), - // child: Container( - // height: MediaQuery.of(context).size.height * 0.070, - // decoration: BoxDecoration( - // border: Border( - // bottom: BorderSide( - // color: Theme.of(context).dividerColor, - // width: 0.5), //width: 0.7 - // ), - // color: Colors.white), - // child: Center( - // child: TabBar( - // isScrollable: false, - // controller: _tabController, - // // indicatorColor: Colors.transparent, - // indicatorWeight: 1.0, - // indicatorSize: TabBarIndicatorSize.tab, - // indicatorColor:Colors.green, - // labelColor: Theme.of(context).primaryColor, - // labelPadding: EdgeInsets.only( - // top: 0, left: 0, right: 0, bottom: 0), - // unselectedLabelColor: Colors.grey[800], - // tabs: [ - // tabWidget(screenSize, _activeTab == 0, - // TranslationBase.of(context).details, - // ), - // tabWidget(screenSize, _activeTab == 1, - // TranslationBase.of(context).review, - // ), - // tabWidget(screenSize, _activeTab == 2, - // TranslationBase.of(context).availability), - // ], - // ), - // ), - // ), - // ), - // body: Column( - // children: [ - // Expanded( - // child: TabBarView( - // physics: BouncingScrollPhysics(), - // controller: _tabController, - // children: [ - // DetailsInfo( - // product: widget.product, - // ), - // ReviewsInfo( - // product: widget.product, - // ), - // AvailabilityInfo() - // ], - // ), - // ), - // - // ], - // ), - // ), - // ), - - SizedBox( - height: 6, - ), - - //TODO Elham* Remove this - 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( + 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, ), - color: Colors.white, - ), - CustomDivider( - color: isDetails - ? Colors.green - : Colors.transparent, - ) - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = false; - isReviews = true; - isAvailability = false; - }); - }, - child: Text( - TranslationBase.of(context).reviews, - style: TextStyle( - fontSize: 16, - 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); + } + setState(() { + isDetails = false; + isReviews = true; + isAvailability = false; + }); + }, + child: Text( + TranslationBase.of(context).reviews, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), + ), + color: Colors.white, ), - color: Colors.white, - ), - CustomDivider( - color: isReviews - ? Colors.green - : Colors.transparent, - ), - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = false; - isReviews = false; - isAvailability = true; - }); - }, - child: Text( - TranslationBase.of(context).availability, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), + CustomDivider( + color: isReviews + ? 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, - ) - : isAvailability - ? AvailabilityInfo() - : Container(), - ], - ), - ), - - ///TODO Elham* check if we need recommanded - // Row( - // children: [ - // customerId != null - // ? Container( - // width: 410, - // height: 50, - // color: Colors.white, - // child: Texts( - // TranslationBase.of(context).recommended, - // bold: true, - // ), - // ) - // : Container(), - // ], - // ), - // RecommendedProducts(product: widget.product) + ], + ), + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () async { + GifLoaderDialogUtils.showMyDialog( + context); + await model.getProductLocationData(); + GifLoaderDialogUtils.hideDialog(context); - SizedBox( - height: 80, - ) - ], + 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, + ), + ], + ), + ], + ), + SizedBox( + height: 10, + ), + isDetails + ? DetailsInfo( + product: widget.product, + ) + : isReviews + ? ReviewsInfo( + product: widget.product, + previousModel: model, + ) + : isAvailability + ? AvailabilityInfo( + previousModel: model, + ) + : Container(), + ], + ), + ), + SizedBox( + height: 80, + ) + ], + ), ), - ), - bottomSheet: FooterWidget( - widget.product.stockAvailability != 'Out of stock', - widget.product.orderMaximumQuantity, - widget.product.orderMinimumQuantity, - widget.product.stockQuantity, - widget.product, - price: price, - isOverQuantity: isOverQuantity, - addToCartFunction: addToCartFunction, - ), - ); - + bottomSheet: FooterWidget( + widget.product.stockAvailability != 'Out of stock', + widget.product.orderMaximumQuantity, + widget.product.orderMinimumQuantity, + widget.product.stockQuantity, + widget.product, + price: price, + isOverQuantity: isOverQuantity, + addToCartFunction: addToCartFunction, + ), + )); } } 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 619a4fb1..4301ce36 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 @@ -10,7 +10,7 @@ import 'package:provider/provider.dart'; import 'package:rating_bar/rating_bar.dart'; import '../../../../locator.dart'; -import 'CustomIcon.dart'; +import 'shared/icon_with_bg.dart'; class ProductNameAndPrice extends StatefulWidget { BuildContext context; diff --git a/lib/pages/pharmacies/screens/product-details/reviews_info.dart b/lib/pages/pharmacies/screens/product-details/reviews_info.dart index c48e249f..15260071 100644 --- a/lib/pages/pharmacies/screens/product-details/reviews_info.dart +++ b/lib/pages/pharmacies/screens/product-details/reviews_info.dart @@ -1,97 +1,89 @@ 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/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:rating_bar/rating_bar.dart'; class ReviewsInfo extends StatelessWidget { final PharmacyProduct product; + final ProductDetailViewModel previousModel; - const ReviewsInfo({Key key, this.product}) : super(key: key); + const ReviewsInfo({Key key, this.product, this.previousModel}) : super(key: key); @override Widget build(BuildContext context) { - return BaseView( - onModelReady: (model) => model.getProductReviewsData(product.id), - allowAny: true, - builder: (_, model, wi) => NetworkBaseView( - baseViewModel:model , - child: model.productDetailService.length != 0 && - model.productDetailService[0].reviews.length != 0 - ? ListView.builder( - physics: ScrollPhysics(), - itemCount: model.productDetailService[0].reviews.length, - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: Row( - children: [ - Container( - child: Text( - model.productDetailService[0].reviews[index] - .customerId - .toString(), - style: TextStyle( - fontSize: 17, - color: Colors.grey, - fontWeight: FontWeight.w600), - ), - ), - Container( - margin: EdgeInsets.only(left: 210), - child: RatingBar.readOnly( - initialRating: model.productDetailService[0] - .reviews[index].rating - .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: 10, - ), - Container( - child: Text( - model.productDetailService[0].reviews[index] - .reviewText, - style: TextStyle(fontSize: 20), - ), - ), - SizedBox( - height: 50, - ), - Divider(height: 1, color: Colors.grey), - ], + return previousModel.productDetailService.length != 0 && + previousModel.productDetailService[0].reviews.length != 0 + ? ListView.builder( + physics: ScrollPhysics(), + itemCount: previousModel.productDetailService[0].reviews.length, + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Row( + children: [ + Container( + child: Text( + previousModel.productDetailService[0].reviews[index] + .customerId + .toString(), + style: TextStyle( + fontSize: 17, + color: Colors.grey, + fontWeight: FontWeight.w600), + ), ), - ); - }, - ) - : Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, + Container( + margin: EdgeInsets.only(left: 210), + child: RatingBar.readOnly( + initialRating: previousModel.productDetailService[0] + .reviews[index].rating + .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: 10, + ), + Container( child: Text( - TranslationBase.of(context).noReviewsAvailable, + previousModel.productDetailService[0].reviews[index] + .reviewText, + style: TextStyle(fontSize: 20), ), -// Text('No Reviews Available'), ), + SizedBox( + height: 50, + ), + Divider(height: 1, color: Colors.grey), + ], + ), + ); + }, + ) + : Container( + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text( + TranslationBase.of(context).noReviewsAvailable, ), +// Text('No Reviews Available'), ); } } diff --git a/lib/pages/pharmacies/screens/product-details/CustomIcon.dart b/lib/pages/pharmacies/screens/product-details/shared/icon_with_bg.dart similarity index 93% rename from lib/pages/pharmacies/screens/product-details/CustomIcon.dart rename to lib/pages/pharmacies/screens/product-details/shared/icon_with_bg.dart index fc8b2288..9033cd72 100644 --- a/lib/pages/pharmacies/screens/product-details/CustomIcon.dart +++ b/lib/pages/pharmacies/screens/product-details/shared/icon_with_bg.dart @@ -11,7 +11,6 @@ class IconWithBg extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - // margin: EdgeInsets.only(left: 25), width: 40, height: 40, decoration: BoxDecoration( diff --git a/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart similarity index 96% rename from lib/pages/pharmacies/screens/product-details/ProductAppBar.dart rename to lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart index 2fad8016..0fd1f03d 100644 --- a/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart +++ b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart @@ -7,10 +7,10 @@ import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; -import '../../../../locator.dart'; -import '../../compare-list.dart'; -import '../cart-order-page.dart'; -import 'CustomIcon.dart'; +import '../../../../../locator.dart'; +import '../../../compare-list.dart'; +import '../../cart-order-page.dart'; +import 'icon_with_bg.dart'; class ProductAppBar extends StatelessWidget with PreferredSizeWidget { From 3b79d0ac41deec5261b01a5d15c15953c184c560 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 6 Oct 2021 11:45:11 +0300 Subject: [PATCH 38/67] return the disable colors --- .../screens/product-details/footor/footer-widget.dart | 10 ++++++---- .../screens/product-details/product-detail.dart | 5 ++--- lib/widgets/buttons/secondary_button.dart | 5 +++-- 3 files changed, 11 insertions(+), 9 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 7cdfe7f2..4233e42a 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -189,13 +189,14 @@ class _FooterWidgetState extends State { disabled: !widget.isAvailable && widget.price > 0 || widget.price > widget.quantityLimit || widget.item.rxMessage != null, - onTap: () { + disableColor: Colors.green[400], + onTap: () async { if (!authenticatedUserObject.isLogin) { Navigator.of(context).pushNamed( WELCOME_LOGIN, ); } else - widget.addToCartFunction( + await widget.addToCartFunction( widget.price, widget.item.id, context); }, borderRadius: 5, @@ -212,8 +213,8 @@ class _FooterWidgetState extends State { disabled: !widget.isAvailable && widget.price > 0 || widget.price > widget.quantityLimit || widget.item.rxMessage != null, - onTap: () { - widget.addToCartFunction( + onTap: () async { + await widget.addToCartFunction( widget.price, widget.item.id, context); Navigator.push( context, @@ -221,6 +222,7 @@ class _FooterWidgetState extends State { ); }, borderRadius: 5, + disableColor: Colors.grey[700], color: !widget.isAvailable && widget.price > 0 || widget.price > widget.quantityLimit || widget.item.rxMessage != null diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index c263f77a..63765ed4 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -357,9 +357,8 @@ convertCityName(txt) { addToCartFunction(quantity, itemID, BuildContext context) async { GifLoaderDialogUtils.showMyDialog(context); ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID).then((value) { - GifLoaderDialogUtils.hideDialog(context); - }); + await x.addToCartData(quantity, itemID); + GifLoaderDialogUtils.hideDialog(context); } notifyMeWhenAvailable(context, itemId) async { diff --git a/lib/widgets/buttons/secondary_button.dart b/lib/widgets/buttons/secondary_button.dart index 9d5df436..4b2f23a9 100644 --- a/lib/widgets/buttons/secondary_button.dart +++ b/lib/widgets/buttons/secondary_button.dart @@ -29,7 +29,7 @@ class SecondaryButton extends StatefulWidget { this.small = false, this.disabled = false, this.borderColor, - this.noBorderRadius = false, this.borderRadius}) + this.noBorderRadius = false, this.borderRadius, this.disableColor}) : super(key: key); final String label; @@ -44,6 +44,7 @@ class SecondaryButton extends StatefulWidget { final bool disabled; final bool noBorderRadius; final double borderRadius; + final Color disableColor; @@ -183,7 +184,7 @@ class _SecondaryButtonState extends State height: 100, decoration: BoxDecoration( color: widget.disabled - ? Colors.grey + ? widget.disableColor??Colors.grey : widget.color ?? Theme.of(context).buttonColor), ), ), From 055b888ba239a61d74569b3cb7fe2b5357a4ce8a Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 6 Oct 2021 12:09:44 +0300 Subject: [PATCH 39/67] fix address --- .../AmbulanceRequestIndexPages/PickupLocation.dart | 8 ++++++-- .../pharmacy/pharmacyAddresses/AddAddress.dart | 13 +++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart b/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart index ce4eb2f7..e05f0e95 100644 --- a/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart +++ b/lib/pages/ErService/AmbulanceRequestIndexPages/PickupLocation.dart @@ -51,6 +51,9 @@ class _PickupLocationState extends State { void initState() { super.initState(); _getCurrentLocation(); + setState(() { + + }); } _getCurrentLocation() async { @@ -61,6 +64,7 @@ class _PickupLocationState extends State { _longitude = 0; _latitude = 0; }); + } @override @@ -89,8 +93,8 @@ class _PickupLocationState extends State { context, FadePage( page: PickupLocationFromMap( - latitude: _latitude, - longitude: _longitude, + latitude: _latitude??0, + longitude: _longitude??0, onPick: (value) { setState(() { _result = value; diff --git a/lib/pages/pharmacy/pharmacyAddresses/AddAddress.dart b/lib/pages/pharmacy/pharmacyAddresses/AddAddress.dart index 7569ed43..1665cb78 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/AddAddress.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/AddAddress.dart @@ -35,8 +35,14 @@ class _AddAddressPageState extends State { } else { _getCurrentLocation(); } + + setState(() { + }); } + + + _getCurrentLocation() async { await Geolocator.getLastKnownPosition().then((value) { _latitude = value.latitude; @@ -44,9 +50,12 @@ class _AddAddressPageState extends State { }).catchError((e) { _longitude = 0; _latitude = 0; + + }); } + @override Widget build(BuildContext context) { final mediaQuery = MediaQuery.of(context); @@ -63,8 +72,8 @@ class _AddAddressPageState extends State { body: Container( height: height * 1, child: PickupLocationFromMap( - latitude: _latitude, - longitude: _longitude, + latitude: _latitude??0, + longitude: _longitude??0, isWithAppBar: false, buttonColor: Color(0xFF5AB145), buttonLabel: TranslationBase.of(context).save, From 0d2d4c64c2e1faefadb6561448a02f49468e2b1c Mon Sep 17 00:00:00 2001 From: mosazaid Date: Wed, 6 Oct 2021 12:45:05 +0300 Subject: [PATCH 40/67] fix bugs pharmacy home and increase performance --- .../parmacyModule/parmacy_module_service.dart | 8 +- lib/pages/landing/landing_page_pharmcy.dart | 7 ++ .../pharmacies/widgets/ProductTileItem.dart | 81 ++++++++++--------- .../widgets/home/BestSellerWidget.dart | 4 +- .../pharmacies/widgets/home/GridViewCard.dart | 1 + .../widgets/home/RecentlyViewedWidget.dart | 4 +- .../widgets/home/ShopByBrandWidget.dart | 2 +- .../pharmacies/widgets/manufacturerItem.dart | 4 +- 8 files changed, 66 insertions(+), 45 deletions(-) diff --git a/lib/core/service/parmacyModule/parmacy_module_service.dart b/lib/core/service/parmacyModule/parmacy_module_service.dart index b32b86e0..5a0a9e54 100644 --- a/lib/core/service/parmacyModule/parmacy_module_service.dart +++ b/lib/core/service/parmacyModule/parmacy_module_service.dart @@ -113,6 +113,7 @@ class PharmacyModuleService extends BaseService { } Future getTopManufacturerList() async { + if (manufacturerList.isNotEmpty) return; Map queryParams = {'page': '1', 'limit': '8'}; try { await baseAppClient.getPharmacy(GET_PHARMACY_TOP_MANUFACTURER, @@ -121,7 +122,7 @@ class PharmacyModuleService extends BaseService { response['manufacturer'].forEach((item) { Manufacturer manufacturer = Manufacturer.fromJson(item); // if (manufacturer.image != null) { - manufacturerList.add(Manufacturer.fromJson(item)); + manufacturerList.add(Manufacturer.fromJson(item)); // } }); hasError = false; @@ -135,6 +136,8 @@ class PharmacyModuleService extends BaseService { } Future getBestSellerProducts() async { + if (bestSellerProducts.isNotEmpty) return; + Map queryParams = { 'fields': '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', @@ -173,7 +176,8 @@ class PharmacyModuleService extends BaseService { }); hasError = false; }, onFailure: (String error, int statusCode) { - hasError = true; // sharedPref.setString(PHARMACY_LAST_VISITED_PRODUCTS, ""); + hasError = + true; // sharedPref.setString(PHARMACY_LAST_VISITED_PRODUCTS, ""); super.error = error; }); } catch (error) { diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 9f00e27c..4927c163 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -2,6 +2,7 @@ import 'package:barcode_scan_fix/barcode_scan.dart'; 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/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; @@ -18,6 +19,8 @@ import 'package:diplomaticquarterapp/widgets/pharmacy/bottom_nav_pharmacy_bar.da import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import '../../locator.dart'; + class LandingPagePharmacy extends StatefulWidget { @override _LandingPagePharmacyState createState() => _LandingPagePharmacyState(); @@ -37,6 +40,10 @@ class _LandingPagePharmacyState extends State { void initState() { super.initState(); + locator().manufacturerList = []; + locator().bestSellerProducts = []; + locator().lastVisitedProducts = []; + pageController = PageController(keepPage: true); } diff --git a/lib/pages/pharmacies/widgets/ProductTileItem.dart b/lib/pages/pharmacies/widgets/ProductTileItem.dart index 07abe2db..a2400e63 100644 --- a/lib/pages/pharmacies/widgets/ProductTileItem.dart +++ b/lib/pages/pharmacies/widgets/ProductTileItem.dart @@ -13,8 +13,9 @@ import 'package:provider/provider.dart'; class ProductTileItem extends StatelessWidget { final AppSharedPreferences sharedPref = AppSharedPreferences(); final PharmacyProduct item; + final double itemHeight; - ProductTileItem(this.item); + ProductTileItem(this.item, this.itemHeight); void productOnClick(BuildContext ctx) { _saveLastVisitProducts(); @@ -92,12 +93,12 @@ class ProductTileItem extends StatelessWidget { ? Image.network( item.images[0].src, fit: BoxFit.cover, - height: 80, + height: itemHeight / 2, ) : Image.asset( "assets/images/no_image.png", fit: BoxFit.cover, - height: 80, + height: itemHeight / 2, ), ), Container( @@ -125,42 +126,48 @@ class ProductTileItem extends StatelessWidget { ], ), SizedBox(height: 8,), - Container( - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, + Padding( + padding: const EdgeInsets.symmetric(horizontal: 6.0), + child: Texts( + projectProvider.isArabic ? item.namen : item.name, + regular: true, + fontSize: 12, + fontWeight: FontWeight.w400, ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - projectProvider.isArabic ? item.namen : item.name, - regular: true, - fontSize: 12, - fontWeight: FontWeight.w400, - ), - Padding( - padding: const EdgeInsets.only(top: 4, bottom: 4), - child: Texts( - "SAR ${item.price}", - fontWeight: FontWeight.w600, - fontSize: 14, - ), - ), - Row( - children: [ - Expanded( - child: StarRating( - totalAverage: item.approvedTotalReviews > 0 - ? (item.approvedRatingSum.toDouble() / - item.approvedTotalReviews.toDouble()) - .toDouble() - : 0, - forceStars: true), + ), + Expanded( + child: Container( + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Padding( + padding: const EdgeInsets.only(top: 4, bottom: 4), + child: Texts( + "SAR ${item.price}", + fontWeight: FontWeight.w600, + fontSize: 14, ), - ], - ), - ], + ), + Row( + children: [ + Expanded( + child: StarRating( + totalAverage: item.approvedTotalReviews > 0 + ? (item.approvedRatingSum.toDouble() / + item.approvedTotalReviews.toDouble()) + .toDouble() + : 0, + forceStars: true), + ), + ], + ), + ], + ), ), ), SizedBox(height: 5,), diff --git a/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart b/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart index baf771b2..2814bc1c 100644 --- a/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart +++ b/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart @@ -29,10 +29,10 @@ class BestSellerWidget extends StatelessWidget { )), if (model.state != ViewState.BusyLocal) Container( - height: MediaQuery.of(context).size.height / 4 + 20, + height: MediaQuery.of(context).size.height / 3 + 20, child: ListView.builder( itemBuilder: (ctx, i) => - ProductTileItem(model.bestSellerProduct[i]), + ProductTileItem(model.bestSellerProduct[i], MediaQuery.of(context).size.height / 4 + 20), scrollDirection: Axis.horizontal, itemCount: model.bestSellerProduct.length, ), diff --git a/lib/pages/pharmacies/widgets/home/GridViewCard.dart b/lib/pages/pharmacies/widgets/home/GridViewCard.dart index a8e3fe9b..fd8bdada 100644 --- a/lib/pages/pharmacies/widgets/home/GridViewCard.dart +++ b/lib/pages/pharmacies/widgets/home/GridViewCard.dart @@ -47,6 +47,7 @@ class GridViewCard extends StatelessWidget { TranslationBase.of(context).viewAll, handler: handler, tPadding: 0, + textColor: Color(0xFF5ab145), bPadding: 0, ), Expanded(child: Container()), diff --git a/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart b/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart index 15e9e700..3e7cf5fe 100644 --- a/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart +++ b/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart @@ -30,11 +30,11 @@ class RecentlyViewedWidget extends StatelessWidget { if (model.state != ViewState.BusyLocal) Container( height: model.lastVisitedProducts.length > 0 - ? MediaQuery.of(context).size.height / 4 + 20 + ? MediaQuery.of(context).size.height / 3 + 20 : 0, child: ListView.builder( itemBuilder: (ctx, i) => - ProductTileItem(model.lastVisitedProducts[i]), + ProductTileItem(model.lastVisitedProducts[i], MediaQuery.of(context).size.height / 4 + 20), scrollDirection: Axis.horizontal, itemCount: model.lastVisitedProducts.length, ), diff --git a/lib/pages/pharmacies/widgets/home/ShopByBrandWidget.dart b/lib/pages/pharmacies/widgets/home/ShopByBrandWidget.dart index 8f4f943d..7fcdbfe8 100644 --- a/lib/pages/pharmacies/widgets/home/ShopByBrandWidget.dart +++ b/lib/pages/pharmacies/widgets/home/ShopByBrandWidget.dart @@ -25,7 +25,7 @@ class ShopByBrandWidget extends StatelessWidget { ProductBrandsPage()), if (model.state != ViewState.BusyLocal) Container( - height: 100, + height: 150, child: ListView.builder( itemBuilder: (ctx, i) => ManufacturerItem(model.manufacturerList[i]), diff --git a/lib/pages/pharmacies/widgets/manufacturerItem.dart b/lib/pages/pharmacies/widgets/manufacturerItem.dart index df5fb166..c5b6bf23 100644 --- a/lib/pages/pharmacies/widgets/manufacturerItem.dart +++ b/lib/pages/pharmacies/widgets/manufacturerItem.dart @@ -25,6 +25,7 @@ class ManufacturerItem extends StatelessWidget { ); }, child: Container( + width: 100, margin: EdgeInsets.symmetric( horizontal: 12, vertical: 4, @@ -38,8 +39,9 @@ class ManufacturerItem extends StatelessWidget { top: BorderSide(color: Colors.grey.shade300, width: 1)), ), child: item.image == null - ? Padding( + ? Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 10), + alignment: Alignment.topCenter, child: AppText(item.name, fontWeight: FontWeight.w500,fontSize: 14,), ) : Padding( From 2981eb3236252afc47902472b67fe8ee9e6a372a Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 6 Oct 2021 15:53:52 +0300 Subject: [PATCH 41/67] fix public card issues --- lib/pages/final_products_page.dart | 1 - lib/pages/pharmacies/my_reviews.dart | 2 +- .../product-details/availability_info.dart | 9 + .../product-details/footor/footer-widget.dart | 37 +- .../product-details/product-detail.dart | 134 ++---- .../product-details/recommended_products.dart | 442 ++++++++---------- .../shared/custom-divider.dart | 19 + .../shared/product_details_app_bar.dart | 100 ++-- .../others/app_scafold_detail_page.dart | 281 ----------- 9 files changed, 341 insertions(+), 684 deletions(-) create mode 100644 lib/pages/pharmacies/screens/product-details/shared/custom-divider.dart delete mode 100644 lib/widgets/others/app_scafold_detail_page.dart diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 31747141..fff272b3 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -49,7 +49,6 @@ class _FinalProductsPageState extends State { Widget build(BuildContext context) { return BaseView( onModelReady: (model) { - //TODO Elham* fix all services in order handel errors in better way in the service if (widget.productType == 1) { model.getFinalProducts(i: id); appBarTitle = TranslationBase.of(context).products; diff --git a/lib/pages/pharmacies/my_reviews.dart b/lib/pages/pharmacies/my_reviews.dart index 7e7e33a0..47aa382f 100644 --- a/lib/pages/pharmacies/my_reviews.dart +++ b/lib/pages/pharmacies/my_reviews.dart @@ -137,7 +137,7 @@ reviewDetails(data, rate, myRate) { : Alignment.topLeft, child: RichText( text: TextSpan( - text: data.product.price.toString() + + text: data.product.quantity.toString() + " " + data.product.currency, style: TextStyle( diff --git a/lib/pages/pharmacies/screens/product-details/availability_info.dart b/lib/pages/pharmacies/screens/product-details/availability_info.dart index 6a6fdfd5..9e717de6 100644 --- a/lib/pages/pharmacies/screens/product-details/availability_info.dart +++ b/lib/pages/pharmacies/screens/product-details/availability_info.dart @@ -78,4 +78,13 @@ class AvailabilityInfo extends StatelessWidget { }, ); } + + convertCityName(txt) { + String stringTxt; + String newTxt; + stringTxt = txt.toString(); + newTxt = stringTxt.split('.')[1]; + + return newTxt; + } } 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 4233e42a..43abcae5 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -19,12 +19,12 @@ class FooterWidget extends StatefulWidget { final PharmacyProduct item; final Function addToCartFunction; - int price; + int quantity; bool isOverQuantity; FooterWidget(this.isAvailable, this.maxQuantity, this.minQuantity, this.quantityLimit, this.item, - {this.price, this.isOverQuantity = false, this.addToCartFunction}); + {this.quantity, this.isOverQuantity = false, this.addToCartFunction}); @override _FooterWidgetState createState() => _FooterWidgetState(); @@ -97,7 +97,7 @@ class _FooterWidgetState extends State { QuantityBox( label: i, onTapFunc: onChangeValue, - isSelected: widget.price == i), + isSelected: widget.quantity == i), Column( children: [ Container( @@ -111,14 +111,14 @@ class _FooterWidgetState extends State { decoration: InputDecoration( labelText: 'quantity #'), onChanged: (text) { - print(widget.price); + print(widget.quantity); print(widget.quantityLimit); if (int.tryParse(text) == null) { text = ''; } else { setState(() { - widget.price = int.parse(text); - if (widget.price >= + widget.quantity = int.parse(text); + if (widget.quantity >= widget.quantityLimit) { widget.isOverQuantity = true; } else { @@ -156,7 +156,7 @@ class _FooterWidgetState extends State { Expanded( flex: 4, child: Text( - widget.price.toString(), + widget.quantity.toString(), style: TextStyle(fontSize: 20), ), ), @@ -186,8 +186,8 @@ class _FooterWidgetState extends State { width: MediaQuery.of(context).size.width * 0.45, child: SecondaryButton( label: TranslationBase.of(context).addToCart.toUpperCase(), - disabled: !widget.isAvailable && widget.price > 0 || - widget.price > widget.quantityLimit || + disabled: !widget.isAvailable && widget.quantity > 0 || + widget.quantity > widget.quantityLimit || widget.item.rxMessage != null, disableColor: Colors.green[400], onTap: () async { @@ -197,7 +197,7 @@ class _FooterWidgetState extends State { ); } else await widget.addToCartFunction( - widget.price, widget.item.id, context); + widget.quantity, widget.item.id, context); }, borderRadius: 5, color: Colors.green, @@ -210,12 +210,12 @@ class _FooterWidgetState extends State { width: MediaQuery.of(context).size.width * 0.35, child: SecondaryButton( label: TranslationBase.of(context).buyNow.toUpperCase(), - disabled: !widget.isAvailable && widget.price > 0 || - widget.price > widget.quantityLimit || + disabled: !widget.isAvailable && widget.quantity > 0 || + widget.quantity > widget.quantityLimit || widget.item.rxMessage != null, onTap: () async { await widget.addToCartFunction( - widget.price, widget.item.id, context); + widget.quantity, widget.item.id, context); Navigator.push( context, FadePage(page: CartOrderPage()), @@ -223,8 +223,8 @@ class _FooterWidgetState extends State { }, borderRadius: 5, disableColor: Colors.grey[700], - color: !widget.isAvailable && widget.price > 0 || - widget.price > widget.quantityLimit || + color: !widget.isAvailable && widget.quantity > 0 || + widget.quantity > widget.quantityLimit || widget.item.rxMessage != null ? Colors.grey : Colors.grey[800], @@ -239,13 +239,12 @@ class _FooterWidgetState extends State { onChangeValue(int i) { setState(() { - ///TODO Elham* Check this if its good - widget.price = i; - if (widget.price >= widget.quantityLimit) { + widget.quantity = i; + if (widget.quantity >= widget.quantityLimit) { widget.isOverQuantity = true; } else { widget.isOverQuantity = false; - return widget.price; + return widget.quantity; } }); } diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 63765ed4..f3524b35 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -1,43 +1,28 @@ 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/pharmacy_module_view_model.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/compare-list.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'; -import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/shared/custom-divider.dart'; +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/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:diplomaticquarterapp/widgets/others/app_scafold_detail_page.dart'; -import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; -import 'package:rating_bar/rating_bar.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; -import '../cart-order-page.dart'; -import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; -import 'shared/product_details_app_bar.dart'; import 'availability_info.dart'; import 'details_info.dart'; import 'discount_description.dart'; import 'footor/footer-widget.dart'; +import 'shared/product_details_app_bar.dart'; + + -int price = 0; -bool isOverQuantity = false; -bool isInWishList = false; -bool isSelected = true; String itemID; -var customerId; -CompareList compareItems = new CompareList(); PharmacyProduct specificationData; class ProductDetailPage extends StatefulWidget { @@ -49,23 +34,27 @@ class ProductDetailPage extends StatefulWidget { __ProductDetailPageState createState() => __ProductDetailPageState(); } -class __ProductDetailPageState extends State - with SingleTickerProviderStateMixin { - TabController _tabController; +class __ProductDetailPageState extends State{ AppSharedPreferences sharedPref = AppSharedPreferences(); bool isTrue = true; bool isDetails = true; bool isReviews = false; bool isAvailability = false; + String customerId; + bool isSelected = true; + bool isOverQuantity = false; + bool isInWishList = false; + int quantity = 0; + checkWishlist() async { GifLoaderDialogUtils.showMyDialog(context); - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.checkWishlistData(); + ProductDetailViewModel model = new ProductDetailViewModel(); + await model.checkWishlistData(); - for (int i = 0; i < x.wishListItems.length; i++) { - if (itemID == x.wishListItems[i].product.id) { + for (int i = 0; i < model.wishListItems.length; i++) { + if (itemID == model.wishListItems[i].product.id) { isInWishList = true; break; } else { @@ -77,9 +66,8 @@ class __ProductDetailPageState extends State } void initState() { - price = 1; + quantity = 1; specificationData = widget.product; - _tabController = TabController(length: 3, vsync: this); userInfo(); super.initState(); @@ -87,7 +75,6 @@ class __ProductDetailPageState extends State @override void dispose() { - _tabController.dispose(); super.dispose(); } @@ -111,6 +98,11 @@ class __ProductDetailPageState extends State isShowDecPage: false, customAppBar: ProductAppBar( product: widget.product, + model: model, + addToWishlistFunction: (item) { + addToWishlistFunction(itemID:item,model:model); + setState(() {}); + }, ), body: SingleChildScrollView( child: Column( @@ -143,15 +135,15 @@ class __ProductDetailPageState extends State widget.product, customerId: customerId, addToWishlistFunction: (item) { - addToWishlistFunction(item); + addToWishlistFunction(itemID:item,model:model); setState(() {}); }, deleteFromWishlistFunction: (item) { - deleteFromWishlistFunction(item); + deleteFromWishlistFunction(itemID: item, model: model); setState(() {}); }, notifyMeWhenAvailable: (context, itemId) { - notifyMeWhenAvailable(context, itemId); + notifyMeWhenAvailable(itemId:itemId, customerId: customerId, model: model); }, isInWishList: isInWishList, ), @@ -319,85 +311,33 @@ class __ProductDetailPageState extends State widget.product.orderMinimumQuantity, widget.product.stockQuantity, widget.product, - price: price, + quantity: quantity, isOverQuantity: isOverQuantity, addToCartFunction: addToCartFunction, ), )); } -} - -class CustomDivider extends StatelessWidget { - const CustomDivider({ - Key key, - this.color, - }) : super(key: key); - final Color color; + addToWishlistFunction({itemID, ProductDetailViewModel model}) async { + isInWishList = true; + await model.addToWishlistData(itemID); + } - @override - Widget build(BuildContext context) { - return Container( - width: 120, - height: 2, - color: color, - ); + deleteFromWishlistFunction({itemID, ProductDetailViewModel model}) async { + isInWishList = false; + await model.deletWishlistData(itemID); } } -convertCityName(txt) { - String stringTxt; - String newTxt; - stringTxt = txt.toString(); - newTxt = stringTxt.split('.')[1]; - - return newTxt; -} -addToCartFunction(quantity, itemID, BuildContext context) async { +addToCartFunction({quantity, itemID, BuildContext context,ProductDetailViewModel model}) async { GifLoaderDialogUtils.showMyDialog(context); - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID); + await model.addToCartData(quantity, itemID); GifLoaderDialogUtils.hideDialog(context); } -notifyMeWhenAvailable(context, itemId) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.notifyMe(customerId, itemId); +notifyMeWhenAvailable({itemId, customerId,ProductDetailViewModel model }) async { + await model.notifyMe(customerId, itemId); } -addToWishlistFunction(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - isInWishList = true; - await x.addToWishlistData(itemID); -} - -deleteFromWishlistFunction(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - isInWishList = false; - await x.deletWishlistData(itemID); -} -//TODO Elham* move to file -Widget tabWidget( - Size screenSize, - bool isActive, - String title, -) { - return Center( - child: Container( - height: screenSize.height * 0.070, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - AppText( - title, - fontSize: SizeConfig.textMultiplier * 1.5, - // color: Color(0xFF2B353E), - fontWeight: FontWeight.w700, - ), - ], - ), - ), - ); -} diff --git a/lib/pages/pharmacies/screens/product-details/recommended_products.dart b/lib/pages/pharmacies/screens/product-details/recommended_products.dart index f40f1f08..7222ad85 100644 --- a/lib/pages/pharmacies/screens/product-details/recommended_products.dart +++ b/lib/pages/pharmacies/screens/product-details/recommended_products.dart @@ -1,6 +1,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.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-detail.dart'; @@ -14,8 +15,23 @@ import 'package:rating_bar/rating_bar.dart'; class RecommendedProducts extends StatefulWidget { final PharmacyProduct product; + final String customerId; + final ProductDetailViewModel productDetailViewModel; + final bool isOverQuantity; + final bool isInWishList; + final Function addToWishlistFunction; + final Function deleteFromWishlistFunction; - const RecommendedProducts({Key key, this.product}) : super(key: key); + RecommendedProducts( + {Key key, + this.product, + this.productDetailViewModel, + this.customerId, + this.isOverQuantity = false, + this.isInWishList = false, + this.addToWishlistFunction, + this.deleteFromWishlistFunction}) + : super(key: key); @override _RecommendedProductsState createState() => _RecommendedProductsState(); @@ -39,273 +55,235 @@ class _RecommendedProductsState extends State { padding: EdgeInsets.only(bottom: 5), // margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4), child: BaseView( - onModelReady: (model) => model - .getRecommendedProducts(widget.product.id), + onModelReady: (model) => + model.getRecommendedProducts(widget.product.id), builder: (_, model, wi) => Container( - child: - model.recommendedProductList.length != null + child: model.recommendedProductList.length != null ? ListView.builder( - scrollDirection: - Axis.horizontal, + scrollDirection: Axis.horizontal, shrinkWrap: true, physics: ScrollPhysics(), // physics: NeverScrollableScrollPhysics(), - itemCount: model - .recommendedProductList - .length, + itemCount: model.recommendedProductList.length, itemBuilder: (context, index) { return InkWell( onTap: () async { - GifLoaderDialogUtils - .showMyDialog( - context); - RecommendedProductModel - data = - model.recommendedProductList[ - index]; + GifLoaderDialogUtils.showMyDialog(context); + RecommendedProductModel data = + model.recommendedProductList[index]; var json = data.toJson(); PharmacyProduct product = - new PharmacyProduct - .fromJson(json); - await Navigator - .pushReplacement( + new PharmacyProduct.fromJson(json); + await Navigator.pushReplacement( context, FadePage( - page: - ProductDetailPage( - product), + page: ProductDetailPage(product), ), ); - GifLoaderDialogUtils - .hideDialog(context); + GifLoaderDialogUtils.hideDialog(context); }, child: Card( elevation: 2, - shape: - RoundedRectangleBorder( + shape: RoundedRectangleBorder( side: BorderSide( - color: Colors - .grey[300], - width: 2), - borderRadius: - BorderRadius - .circular(10), + color: Colors.grey[300], width: 2), + borderRadius: BorderRadius.circular(10), ), - margin: - EdgeInsets.symmetric( + margin: EdgeInsets.symmetric( horizontal: 8, vertical: 0, ), child: Container( - decoration: - BoxDecoration( - borderRadius: - BorderRadius.all( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( Radius.circular(15), ), ), - padding: EdgeInsets - .symmetric( - horizontal: 4), - width: MediaQuery.of( - context) - .size - .width / - 3, + padding: EdgeInsets.symmetric(horizontal: 4), + width: MediaQuery.of(context).size.width / 3, child: Column( crossAxisAlignment: - CrossAxisAlignment - .start, + CrossAxisAlignment.start, children: [ Stack(children: [ Container( child: Align( - alignment: - Alignment - .topRight, - child: - IconButton( - icon: Icon(model.recommendedProductList[index].isinwishlist != - true - ? Icons - .favorite_border - : Icons - .favorite), - color: model.recommendedProductList[index].isinwishlist != - true - ? Colors - .grey - : Colors - .red, - onPressed: - () async { - if (customerId != - null) { - if (!isInWishList && - model.recommendedProductList[index].isinwishlist != + alignment: Alignment.topRight, + child: IconButton( + icon: Icon(model + .recommendedProductList[ + index] + .isinwishlist != + true + ? Icons.favorite_border + : Icons.favorite), + color: model + .recommendedProductList[ + index] + .isinwishlist != + true + ? Colors.grey + : Colors.red, + onPressed: () async { + if (widget.customerId != null) { + if (!widget.isInWishList && + model + .recommendedProductList[ + index] + .isinwishlist != true) { - GifLoaderDialogUtils.showMyDialog( - context); - await addToWishlistFunction(model - .recommendedProductList[index] - .id); + GifLoaderDialogUtils + .showMyDialog(context); + await widget.addToWishlistFunction( + itemID: model + .recommendedProductList[ + index] + .id, + model: widget + .productDetailViewModel); // checkWishlist(); - GifLoaderDialogUtils.hideDialog( - context); - setState( - () { - model.recommendedProductList[index].isinwishlist = - true; - }); + GifLoaderDialogUtils + .hideDialog(context); + setState(() { + model + .recommendedProductList[ + index] + .isinwishlist = true; + }); } else { - GifLoaderDialogUtils.showMyDialog( - context); - await deleteFromWishlistFunction(model - .recommendedProductList[index] - .id); - GifLoaderDialogUtils.hideDialog( - context); - setState( - () { - model.recommendedProductList[index].isinwishlist = - false; - }); + GifLoaderDialogUtils + .showMyDialog(context); + await widget.deleteFromWishlistFunction( + itemID: model + .recommendedProductList[ + index] + .id, + model: widget + .productDetailViewModel); + GifLoaderDialogUtils + .hideDialog(context); + setState(() { + model + .recommendedProductList[ + index] + .isinwishlist = false; + }); } } else { return; } - setState( - () { - // checkWishlist(); - }); + setState(() { + // checkWishlist(); + }); }, ), ), ), Container( - margin: EdgeInsets - .fromLTRB( - 0, - 16, - 10, - 16), - alignment: - Alignment - .center, - child: (model.recommendedProductList[index].images != - null && - model.recommendedProductList[index].images.length > - 0) - ? Image - .network( - model - .recommendedProductList[index] - .images[0] - .src - .toString(), - fit: BoxFit - .cover, - height: - 60, - ) - : Image - .asset( - "assets/images/no_image.png", - fit: BoxFit - .cover, - height: - 60, - ), + margin: EdgeInsets.fromLTRB( + 0, 16, 10, 16), + alignment: Alignment.center, + child: (model + .recommendedProductList[ + index] + .images != + null && + model + .recommendedProductList[ + index] + .images + .length > + 0) + ? Image.network( + model + .recommendedProductList[ + index] + .images[0] + .src + .toString(), + fit: BoxFit.cover, + height: 60, + ) + : Image.asset( + "assets/images/no_image.png", + fit: BoxFit.cover, + height: 60, + ), ), Container( width: model - .recommendedProductList[ - index] - .rxMessage != - null + .recommendedProductList[ + index] + .rxMessage != + null ? MediaQuery.of(context) - .size - .width / - 5 + .size + .width / + 5 : 0, - padding: - EdgeInsets - .all(4), - decoration: - BoxDecoration( - color: Color( - 0xffb23838), - borderRadius: - BorderRadius - .only( - topLeft: Radius - .circular( - 6), + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + color: Color(0xffb23838), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(6), ), ), - child: model.recommendedProductList[index] - .rxMessage != - null + child: model + .recommendedProductList[ + index] + .rxMessage != + null ? Texts( - projectViewModel.isArabic - ? model.recommendedProductList[index].rxMessagen - : model.recommendedProductList[index].rxMessage, - color: Colors - .white, - regular: - true, - fontSize: - 10, - fontWeight: - FontWeight.w400, - ) + projectViewModel.isArabic + ? model + .recommendedProductList[ + index] + .rxMessagen + : model + .recommendedProductList[ + index] + .rxMessage, + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ) : Texts(""), ), ]), Container( - margin: EdgeInsets - .symmetric( + margin: EdgeInsets.symmetric( horizontal: 6, vertical: 0, ), child: Column( crossAxisAlignment: - CrossAxisAlignment - .start, + CrossAxisAlignment.start, children: [ Text( - projectViewModel - .isArabic + projectViewModel.isArabic ? model - .recommendedProductList[ - index] - .namen + .recommendedProductList[ + index] + .namen : model - .recommendedProductList[index] - .name, - style: - TextStyle( - color: Colors - .black, - fontSize: - 13.0, + .recommendedProductList[ + index] + .name, + style: TextStyle( + color: Colors.black, + fontSize: 13.0, // fontWeight: FontWeight.bold, ), ), Padding( // padding: const EdgeInsets.only(top: 15, bottom: 10), - padding: const EdgeInsets - .only( - top: 10, - bottom: - 5), - child: - Texts( + padding: const EdgeInsets.only( + top: 10, bottom: 5), + child: Texts( "SAR ${model.recommendedProductList[index].price}", - bold: - true, - fontSize: - 14, + bold: true, + fontSize: 14, ), ), ], @@ -313,47 +291,35 @@ class _RecommendedProductsState extends State { ), Row( crossAxisAlignment: - CrossAxisAlignment - .start, - children: < - Widget>[ + CrossAxisAlignment.start, + children: [ Container( - padding: EdgeInsets.only( - right: - 10), - child: - Align( - alignment: - Alignment - .topLeft, - child: RatingBar - .readOnly( + padding: + EdgeInsets.only(right: 10), + child: Align( + alignment: Alignment.topLeft, + child: RatingBar.readOnly( initialRating: model - .recommendedProductList[index] + .recommendedProductList[ + index] .approvedRatingSum .toDouble(), - size: - 13.0, + size: 13.0, filledColor: - Colors.yellow[700], - emptyColor: - Colors.grey[500], - isHalfAllowed: - true, + Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, halfFilledIcon: - Icons.star_half, - filledIcon: - Icons.star, - emptyIcon: - Icons.star, + Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, ), ), ), Texts( "(${model.recommendedProductList[index].notApprovedTotalReviews.toString()})", // bold: true, - fontSize: - 12, + fontSize: 12, ), ]), ], @@ -363,20 +329,18 @@ class _RecommendedProductsState extends State { ); }) : Container( - // color: Colors.white, - child: Row( - mainAxisAlignment: - MainAxisAlignment.center, - // crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Texts( - TranslationBase.of(context) - .nonRecommended, - color: Colors.black, + // color: Colors.white, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + // crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Texts( + TranslationBase.of(context).nonRecommended, + color: Colors.black, + ), + ], + ), ), - ], - ), - ), ), ), ), diff --git a/lib/pages/pharmacies/screens/product-details/shared/custom-divider.dart b/lib/pages/pharmacies/screens/product-details/shared/custom-divider.dart new file mode 100644 index 00000000..268e79d0 --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/shared/custom-divider.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +class CustomDivider extends StatelessWidget { + const CustomDivider({ + Key key, + this.color, + }) : super(key: key); + + final Color color; + + @override + Widget build(BuildContext context) { + return Container( + width: 120, + height: 2, + color: color, + ); + } +} \ No newline at end of file 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 0fd1f03d..95689326 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 @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -13,19 +14,22 @@ import '../../cart-order-page.dart'; import 'icon_with_bg.dart'; class ProductAppBar extends StatelessWidget with PreferredSizeWidget { - final PharmacyProduct product; - ProductAppBar({Key key, this.product}) : super(key: key); + final ProductDetailViewModel model; + final Function addToWishlistFunction; + final int quantity; + + ProductAppBar({Key key, this.product, this.model, this.addToWishlistFunction, this.quantity}) + : super(key: key); AuthenticatedUserObject authenticatedUserObject = - locator(); + locator(); @override Widget build(BuildContext context) { return Container( color: Colors.white, - child: FractionallySizedBox( widthFactor: 0.95, child: Column( @@ -47,29 +51,31 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { ), ], ), - if(authenticatedUserObject.isLogin) - Row( - children: [ - IconWithBg( - icon: Icons.shopping_cart, + if (authenticatedUserObject.isLogin) + Row( + children: [ + IconWithBg( + icon: Icons.shopping_cart, + color: Colors.grey, + onPress: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => CartOrderPage()), + ); + }), + SizedBox( + width: 10, + ), + IconWithBg( + icon: FontAwesomeIcons.ellipsisV, color: Colors.grey, onPress: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => CartOrderPage()), - ); - }), - SizedBox(width: 10,), - IconWithBg( - icon: FontAwesomeIcons.ellipsisV, - color: Colors.grey, - onPress: () { - settingModalBottomSheet(context); - }, - ), - ], - ) + settingModalBottomSheet(context); + }, + ), + ], + ) ], ), ], @@ -78,10 +84,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { ); } - - @override - // TODO: implement preferredSize @override Size get preferredSize => Size(double.maxFinite, 50); @@ -92,27 +95,34 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { return Container( child: new Wrap( children: [ - if( product.stockAvailability != 'Out of stock') - new ListTile( - leading: Icon(Icons.shopping_cart), - title: Text( - TranslationBase.of(context).addToCart, - ), - onTap: () => { - if (price > 0) - {addToCartFunction(price, itemID, context)} - else - { - AppToast.showErrorToast( - message: "you should add quantity") - } - }), + if (product.stockAvailability != 'Out of stock') + new ListTile( + leading: Icon(Icons.shopping_cart), + title: Text( + TranslationBase.of(context).addToCart, + ), + onTap: () => { + if (quantity > 0) + { + addToCartFunction( + quantity: quantity, + itemID: itemID, + context: context, + model: model) + } + else + { + AppToast.showErrorToast( + message: "you should add quantity") + } + }), ListTile( leading: Icon(Icons.favorite_border), title: Text( TranslationBase.of(context).addToWishlist, ), - onTap: () => {addToWishlistFunction(itemID)}, + onTap: () => + {addToWishlistFunction(itemID: itemID, model: model)}, ), ListTile( leading: Icon(Icons.compare), @@ -130,5 +140,3 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { }); } } - - diff --git a/lib/widgets/others/app_scafold_detail_page.dart b/lib/widgets/others/app_scafold_detail_page.dart deleted file mode 100644 index 595e0872..00000000 --- a/lib/widgets/others/app_scafold_detail_page.dart +++ /dev/null @@ -1,281 +0,0 @@ -import 'package:diplomaticquarterapp/config/config.dart'; -import 'package:diplomaticquarterapp/config/size_config.dart'; -import 'package:diplomaticquarterapp/config/size_config.dart'; -import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; -import 'package:diplomaticquarterapp/core/viewModels/base_view_model.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/compare-list.dart'; -import 'package:diplomaticquarterapp/routes.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/bottom_bar.dart'; -import 'package:diplomaticquarterapp/widgets/progress_indicator/app_loader_widget.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:provider/provider.dart'; - -import '../../locator.dart'; -import 'floating_button_search.dart'; -import '../progress_indicator/app_loader_widget.dart'; -import 'arrow_back.dart'; -import 'network_base_view.dart'; -import 'not_auh_page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; - -class DetailPageScafold extends StatefulWidget { - final String appBarTitle; - final Widget body; - final Widget bottomSheet; - final bool isLoading; - final bool isShowAppBar; - final bool hasAppBarParam; - final BaseViewModel baseViewModel; - final bool isBottomBar; - final Widget floatingActionButton; - final bool isPharmacy; - final String title; - final String description; - final String image; - final bool isShowDecPage; - final List infoList; - final Color backgroundColor; - final double preferredSize; - final List appBarIcons; - final PreferredSizeWidget appBarWidget; - - DetailPageScafold( - {@required this.body, - this.appBarTitle = '', - this.isLoading = false, - this.isShowAppBar = false, - this.hasAppBarParam, - this.bottomSheet, - this.baseViewModel, - this.floatingActionButton, - this.isPharmacy = false, - this.title, - this.description, - this.isShowDecPage = true, - this.isBottomBar, - this.backgroundColor, - this.preferredSize = 0.0, - this.appBarIcons, - this.appBarWidget, - this.image, - this.infoList}); - - @override - _DetailPageScafoldState createState() => _DetailPageScafoldState(); -} - -class _DetailPageScafoldState extends State { - AuthenticatedUserObject authenticatedUserObject = - locator(); - - @override - Widget build(BuildContext context) { - AppGlobal.context = context; - PreferredSizeWidget appBar; - - if (this.widget.appBarWidget == null) { - PreferredSizeWidget appBarWidget = AppBarWidget( - widget.appBarTitle, - widget.appBarIcons, - widget.isShowAppBar, - isPharmacy: widget.isPharmacy, - isShowDecPage: widget.isShowDecPage, - image: widget.image, - ); - appBar = widget.preferredSize == 0 - ? appBarWidget - : PreferredSize( - child: appBarWidget, - preferredSize: Size.fromHeight(widget.preferredSize)); - } else { - appBar = this.widget.appBarWidget; - } - - return Scaffold( - backgroundColor: - widget.backgroundColor ?? Theme.of(context).scaffoldBackgroundColor, - appBar: appBar, - body: (!Provider.of(context, listen: false).isLogin && - widget.isShowDecPage) - ? NotAutPage( - title: widget.appBarTitle, - description: widget.description, - infoList: widget.infoList, - ) - : widget.baseViewModel != null - ? NetworkBaseView( - child: buildBodyWidget(), - baseViewModel: widget.baseViewModel, - ) - : buildBodyWidget(), - bottomSheet: widget.bottomSheet, - //floatingActionButton: floatingActionButton ?? floatingActionButton, - // bottomNavigationBar: - // this.isBottomBar == true ? BottomBarSearch() : SizedBox() - // floatingActionButton: FloatingSearchButton(), - ); - } - - buildAppLoaderWidget(bool isLoading) { - return isLoading ? AppLoaderWidget() : Container(); - } - - buildBodyWidget() { - // return body; //Stack(children: [body, buildAppLoaderWidget(isLoading)]); - return Stack(children: [ - widget.body, /*FloatingSearchButton()*/ - ]); - } -} - -class AppBarWidget extends StatelessWidget with PreferredSizeWidget { - final AuthenticatedUserObject authenticatedUserObject = - locator(); - - final String appBarTitle; - final List appBarIcons; - final bool isShowAppBar; - final bool isPharmacy; - final bool isShowDecPage; - final String image; - - AppBarWidget(this.appBarTitle, this.appBarIcons, this.isShowAppBar, - {this.isPharmacy = true, this.isShowDecPage = true, this.image}); - - @override - Widget build(BuildContext context) { - return buildAppBar(context); - } - - Widget buildAppBar(BuildContext context) { - return isShowAppBar - ? AppBar( - elevation: 0, - backgroundColor: Colors.white, -// isPharmacy ? Colors.green : Theme.of(context).appBarTheme.color, - textTheme: TextTheme( - headline6: - TextStyle(color: Colors.white, fontWeight: FontWeight.bold), - ), - title: Texts( - authenticatedUserObject.isLogin || !isShowDecPage - ? appBarTitle.toUpperCase() - : TranslationBase.of(context).serviceInformationTitle, - color: Colors.white, - bold: true, - ), - leading: Builder( - builder: (BuildContext context) { - return GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: () => Navigator.pop(context), - child: Icon(Icons.arrow_back_ios, color: Colors.grey), - ); - }, - ), - centerTitle: true, - actions: [ - /// TODO Elham* fix this - if(isPharmacy) - IconButton( - icon: Icon(Icons.shopping_cart), - color: Colors.grey, - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => CartOrderPage()), - ); - }), - image != null - ? InkWell( - onTap: () => Navigator.push( - context, - FadePage( - page: InsuranceUpdate(), - ), - ), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Image.asset( - image, - height: SizeConfig.heightMultiplier * 5, - width: SizeConfig.heightMultiplier * 5, - color: Colors.grey, - ), - ), - ) - : IconButton( - icon: Icon(FontAwesomeIcons.ellipsisV), - color: Colors.grey, - onPressed: () { - settingModalBottomSheet(context); - }, - ), - if (appBarIcons != null) ...appBarIcons - ], - ) - : Container( - height: 0, - width: 0, - ); - } - - @override - Size get preferredSize => Size(double.maxFinite, 60); - - - settingModalBottomSheet(context) { - showModalBottomSheet( - context: context, - builder: (BuildContext bc) { - return Container( - child: new Wrap( - children: [ - new ListTile( - leading: Icon(Icons.shopping_cart), - title: Text( - TranslationBase.of(context).addToCart, - ), - onTap: () => { - if (price > 0) - {addToCartFunction(price, itemID, context)} - else - { - AppToast.showErrorToast( - message: "you should add quantity") - } - }), - ListTile( - leading: Icon(Icons.favorite_border), - title: Text( - TranslationBase.of(context).addToWishlist, - ), - onTap: () => {addToWishlistFunction(itemID)}, - ), - ListTile( - leading: Icon(Icons.compare), - title: Text( - TranslationBase.of(context).compare, - ), - onTap: () => { - Provider.of(context, listen: false) - .addItem(specificationData), - }, - ), - ], - ), - ); - }); - } -} From 7de8c2588fb333e7830332f02f2f7704f71ca7dc Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 6 Oct 2021 16:17:34 +0300 Subject: [PATCH 42/67] fix coloring issue --- .../product-details/footor/footer-widget.dart | 11 +- .../product-name-and-price.dart | 127 +++++++++--------- .../product-details/shared/icon_with_bg.dart | 14 +- .../shared/product_details_app_bar.dart | 4 +- 4 files changed, 82 insertions(+), 74 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 43abcae5..854f5d4c 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -31,7 +31,7 @@ class FooterWidget extends StatefulWidget { } class _FooterWidgetState extends State { - double quantityUI = 70; + double quantityUI = 80; bool showUI = false; AuthenticatedUserObject authenticatedUserObject = locator(); @@ -77,7 +77,7 @@ class _FooterWidgetState extends State { child: Icon(Icons.close, color: Colors.black), onTap: () { setState(() { - quantityUI = 70; + quantityUI = 80; showUI = false; }); }, @@ -172,7 +172,7 @@ class _FooterWidgetState extends State { onPressed: () { setState(() { if (showUI) { - quantityUI = 70; + quantityUI = 80; showUI = false; } else { quantityUI = 150; @@ -189,7 +189,7 @@ class _FooterWidgetState extends State { disabled: !widget.isAvailable && widget.quantity > 0 || widget.quantity > widget.quantityLimit || widget.item.rxMessage != null, - disableColor: Colors.green[400], + disableColor: Color(0xFF4CAF50), onTap: () async { if (!authenticatedUserObject.isLogin) { Navigator.of(context).pushNamed( @@ -199,8 +199,9 @@ class _FooterWidgetState extends State { await widget.addToCartFunction( widget.quantity, widget.item.id, context); }, + borderColor: Color(0xFF4CAF50), borderRadius: 5, - color: Colors.green, + color: Color(0xFF4CAF50), ), ), 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 4301ce36..31662219 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 @@ -22,7 +22,7 @@ class ProductNameAndPrice extends StatefulWidget { final Function deleteFromWishlistFunction; AuthenticatedUserObject authenticatedUserObject = - locator(); + locator(); ProductNameAndPrice(this.context, this.item, {this.customerId, @@ -64,50 +64,52 @@ class _ProductNameAndPriceState extends State { : Colors.green, ), // SizedBox(width: 20), - if(widget.authenticatedUserObject.isLogin) - widget.item.stockAvailability == 'Out of stock' && - widget.customerId != null - ? InkWell( - onTap: () => - widget.notifyMeWhenAvailable(context, widget.item.id), - child: Row(children: [ - Texts( - TranslationBase.of(context).notifyMe, - decoration: TextDecoration.underline, - color: Colors.blue, - ), - SizedBox(width: 4), - Icon( - FontAwesomeIcons.bell, - color: Colors.blue, - size: 15.0, - ) - ]), - ) - : IconWithBg( - icon: !widget.isInWishList - ? Icons.favorite_border - : Icons.favorite, - color: !widget.isInWishList ? Colors.white : Colors.red, - onPress: () async { - { - if (widget.customerId != null) { - if (!widget.isInWishList) { - GifLoaderDialogUtils.showMyDialog(context); - await widget - .addToWishlistFunction(widget.item.id); - GifLoaderDialogUtils.hideDialog(context); + if (widget.authenticatedUserObject.isLogin) + widget.item.stockAvailability == 'Out of stock' && + widget.customerId != null + ? InkWell( + onTap: () => widget.notifyMeWhenAvailable( + context, widget.item.id), + child: Row(children: [ + Texts( + TranslationBase.of(context).notifyMe, + decoration: TextDecoration.underline, + color: Colors.blue, + ), + SizedBox(width: 4), + Icon( + FontAwesomeIcons.bell, + color: Colors.blue, + size: 15.0, + ) + ]), + ) + : IconWithBg( + 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) { + GifLoaderDialogUtils.showMyDialog(context); + await widget + .addToWishlistFunction(widget.item.id); + GifLoaderDialogUtils.hideDialog(context); + } else { + await widget + .deleteFromWishlistFunction(widget.item.id); + } } else { - await widget - .deleteFromWishlistFunction(widget.item.id); + return; } - } else { - return; + setState(() {}); } - setState(() {}); - } - }, - ) + }, + ) ], ), ), @@ -163,29 +165,32 @@ class _ProductNameAndPriceState extends State { "(${widget.item.approvedTotalReviews}${TranslationBase.of(context).review})", fontSize: 12, ), + SizedBox( + width: 70, + ), + if (widget.item.rxMessage != null) + Row( + children: [ + Text( + 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, + ) + ], + ) ], ), ), ), - Expanded( - flex: 1, - child: Container( - child: widget.item.rxMessage != null - ? Text( - projectViewModel.isArabic - ? widget.item.rxMessagen.toString() - : widget.item.rxMessage.toString(), - style: TextStyle(color: Colors.red, fontSize: 10), - ) - : Container()), - ), - widget.item.rxMessage != null - ? Icon( - FontAwesomeIcons.questionCircle, - color: Colors.red, - size: 15.0, - ) - : Container(), ], ), ), diff --git a/lib/pages/pharmacies/screens/product-details/shared/icon_with_bg.dart b/lib/pages/pharmacies/screens/product-details/shared/icon_with_bg.dart index 9033cd72..f2406614 100644 --- a/lib/pages/pharmacies/screens/product-details/shared/icon_with_bg.dart +++ b/lib/pages/pharmacies/screens/product-details/shared/icon_with_bg.dart @@ -17,12 +17,14 @@ class IconWithBg extends StatelessWidget { color: Colors.grey[200], borderRadius: BorderRadius.circular(30), ), - child: IconButton( - icon: Icon(icon), - color: color, - onPressed: () async { - onPress(); - }, + child: Center( + child: IconButton( + icon: Icon(icon, size: 20,), + color: color, + onPressed: () async { + onPress(); + }, + ), )); } } 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 95689326..13547fd1 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 @@ -43,7 +43,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { Row( children: [ IconWithBg( - icon: Icons.arrow_back_ios, + icon: Icons.arrow_back, color: Colors.grey, onPress: () { Navigator.pop(context); @@ -56,7 +56,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { children: [ IconWithBg( icon: Icons.shopping_cart, - color: Colors.grey, + color: Colors.grey[800], onPress: () { Navigator.push( context, From a41980b252bcc8f6d2e22e5c523c71d4ad386f7b Mon Sep 17 00:00:00 2001 From: mosazaid Date: Wed, 6 Oct 2021 16:18:08 +0300 Subject: [PATCH 43/67] fix bugs pharmacy wishlist --- .../pharmacyModule/PrescriptionViewModel.dart | 17 +- .../product_detail_view_model.dart | 16 +- lib/pages/landing/landing_page_pharmcy.dart | 157 ++--- .../screens/pharmacy_module_page.dart | 53 +- .../product-details/ProductAppBar.dart | 6 +- .../product-details/product-detail.dart | 587 +++++++++--------- .../product-name-and-price.dart | 2 - .../product-details/recommended_products.dart | 6 +- .../others/app_scafold_detail_page.dart | 3 +- 9 files changed, 433 insertions(+), 414 deletions(-) diff --git a/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart b/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart index 45fc8000..86a320e6 100644 --- a/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/PrescriptionViewModel.dart @@ -13,15 +13,16 @@ class PrescriptionViewModel extends BaseViewModel { _prescriptionService.prescriptionsList; getPrescription() async { - setState(ViewState.Busy); await getSavedLanguage(); - await _prescriptionService.getPrescription(); - if (_prescriptionService.hasError) { - error = _prescriptionService.error; - setState(ViewState.Error); - } else { - setState(ViewState.Idle); + if(prescriptionsList.isNotEmpty){ + setState(ViewState.Busy); + await _prescriptionService.getPrescription(); + if (_prescriptionService.hasError) { + error = _prescriptionService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } } - } } \ No newline at end of file diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index c7ac0a04..9da34312 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -5,6 +5,8 @@ import 'package:diplomaticquarterapp/models/pharmacy/locationModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/product_detail_service.dart'; import 'package:diplomaticquarterapp/models/pharmacy/specification.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import '../../../locator.dart'; @@ -69,8 +71,13 @@ class ProductDetailViewModel extends BaseViewModel{ Future addToWishlistData(itemID) async { hasError = false; - setState(ViewState.Busy); + setState(ViewState.BusyLocal); + GifLoaderDialogUtils.showMyDialog( + locator().navigatorKey.currentContext); await _productDetailService.addToWishlist(itemID); + GifLoaderDialogUtils.hideDialog( + locator().navigatorKey.currentContext); + if (_productDetailService.hasError) { error = _productDetailService.error; setState(ViewState.ErrorLocal); @@ -92,8 +99,13 @@ class ProductDetailViewModel extends BaseViewModel{ Future deletWishlistData(itemID) async { hasError = false; - setState(ViewState.Busy); + setState(ViewState.BusyLocal); + GifLoaderDialogUtils.showMyDialog( + locator().navigatorKey.currentContext); await _productDetailService.delteItemFromWishlist(itemID); + GifLoaderDialogUtils.hideDialog( + locator().navigatorKey.currentContext); + if (_productDetailService.hasError) { error = _productDetailService.error; setState(ViewState.ErrorLocal); diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 4927c163..41c4b694 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -49,88 +49,93 @@ class _LandingPagePharmacyState extends State { @override Widget build(BuildContext context) { - return 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, - ) - ], + return WillPopScope( + 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()), + ); + }, ), - 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', + ), + ), ); }, ), - ), - 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', ), - ), - ); - }, - ), - actions: [ - IconButton( - // iconSize: 70, - icon: Image.asset( - 'assets/images/new-design/qr-code.png', - ), - onPressed: _scanQrAndGetProduct //do something, - ) - ], - centerTitle: true, - ) - : null, - extendBody: false, - body: PageView( - physics: NeverScrollableScrollPhysics(), - controller: pageController, - children: [ - PharmacyPage(), - PharmacyCategorisePage(), - PharmacyProfilePage(), - CartOrderPage(), - ], - ), - bottomNavigationBar: BottomNavPharmacyBar( - changeIndex: _changeCurrentTab, - index: currentTab, + onPressed: _scanQrAndGetProduct //do something, + ) + ], + centerTitle: true, + ) + : null, + extendBody: false, + body: PageView( + physics: NeverScrollableScrollPhysics(), + controller: pageController, + children: [ + PharmacyPage(), + PharmacyCategorisePage(), + PharmacyProfilePage(), + CartOrderPage(), + ], + ), + bottomNavigationBar: BottomNavPharmacyBar( + changeIndex: _changeCurrentTab, + index: currentTab, + ), ), ); } diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index c158341d..ecc39d6c 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -46,31 +46,36 @@ class _PharmacyPageState extends State { @override Widget build(BuildContext context) { - return BaseView( - onModelReady: (model) async { - await model.getSavedLanguage(); - await model.getBannerList(); + return WillPopScope( + onWillPop: ()async{ + return false; }, - 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(); + }, + 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(), + ], + ), ), ), ), diff --git a/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart b/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart index 2fad8016..95332bc5 100644 --- a/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart +++ b/lib/pages/pharmacies/screens/product-details/ProductAppBar.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -15,8 +16,9 @@ import 'CustomIcon.dart'; class ProductAppBar extends StatelessWidget with PreferredSizeWidget { final PharmacyProduct product; + final ProductDetailViewModel model; - ProductAppBar({Key key, this.product}) : super(key: key); + ProductAppBar({Key key, this.product, this.model}) : super(key: key); AuthenticatedUserObject authenticatedUserObject = locator(); @@ -112,7 +114,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { title: Text( TranslationBase.of(context).addToWishlist, ), - onTap: () => {addToWishlistFunction(itemID)}, + onTap: () => {model.addToWishlistData(itemID)}, ), ListTile( leading: Icon(Icons.compare), diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 5e8f4dd5..c430d08d 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -1,28 +1,19 @@ 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/pharmacy_module_view_model.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/compare-list.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'; -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/others/app_scafold_detail_page.dart'; import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; -import 'package:rating_bar/rating_bar.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; -import '../cart-order-page.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'ProductAppBar.dart'; @@ -105,300 +96,307 @@ class __ProductDetailPageState extends State ProjectViewModel projectViewModel = Provider.of(context); final screenSize = MediaQuery.of(context).size; - return AppScaffold( - appBarTitle: TranslationBase.of(context).productDetails, - isShowAppBar: true, - isPharmacy: true, - isShowDecPage: false, - customAppBar: ProductAppBar(product: widget.product,), - body: SingleChildScrollView( - child: Column( - children: [ - Container( - width: double.infinity, - color: Colors.white, - child: Column( - children: [ - if (widget.product.images.isNotEmpty) + return BaseView( + builder: (_, model, wi) => AppScaffold( + appBarTitle: TranslationBase.of(context).productDetails, + isShowAppBar: true, + isPharmacy: true, + baseViewModel: model, + isShowDecPage: false, + customAppBar: ProductAppBar(product: widget.product,), + body: SingleChildScrollView( + 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) + ], + ), + ), + SizedBox( + height: 4, + ), + Container( + color: Colors.white, + child: ProductNameAndPrice( + context, + widget.product, + customerId: customerId, + addToWishlistFunction: (item) { + model.addToWishlistData(itemID); + setState(() { + + }); + }, + deleteFromWishlistFunction: (item) { + model.deletWishlistData(itemID); + setState(() { + + }); + }, + notifyMeWhenAvailable: (context, itemId) { + notifyMeWhenAvailable(context, itemId); + }, + isInWishList: isInWishList, + ), + ), + SizedBox( + height: 6, + ), + Container( + color: Colors.white, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ Container( - height: MediaQuery.of(context).size.height * .40, - child: Image.network( - widget.product.images[0].src.trim(), - fit: BoxFit.contain, + padding: EdgeInsets.symmetric( + vertical: 15, horizontal: 10), + child: Texts( + TranslationBase.of(context).specification, + fontSize: 15, + fontWeight: FontWeight.bold, ), + width: double.infinity, ), - if (widget.product.discountDescription != null) - DiscountDescription(product: widget.product) - ], + // Divider(color: Colors.grey), + ], + ), ), - ), - SizedBox( - height: 4, - ), - Container( - color: Colors.white, - child: ProductNameAndPrice( - context, - widget.product, - customerId: customerId, - addToWishlistFunction: (item) { - addToWishlistFunction(item); - setState(() {}); - }, - deleteFromWishlistFunction: (item) { - deleteFromWishlistFunction(item); - setState(() {}); - }, - notifyMeWhenAvailable: (context, itemId) { - notifyMeWhenAvailable(context, itemId); - }, - isInWishList: isInWishList, + SizedBox( + height: 6, ), - ), - 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, - ), - width: double.infinity, - ), - // Divider(color: Colors.grey), - ], + // Container( + // height: 500, + // color: Colors.white, + // child: Scaffold( + // backgroundColor: Colors.white, + // extendBodyBehindAppBar: false, + // appBar: PreferredSize( + // preferredSize: Size.fromHeight( + // MediaQuery.of(context).size.height * 0.070), + // child: Container( + // height: MediaQuery.of(context).size.height * 0.070, + // decoration: BoxDecoration( + // border: Border( + // bottom: BorderSide( + // color: Theme.of(context).dividerColor, + // width: 0.5), //width: 0.7 + // ), + // color: Colors.white), + // child: Center( + // child: TabBar( + // isScrollable: false, + // controller: _tabController, + // // indicatorColor: Colors.transparent, + // indicatorWeight: 1.0, + // indicatorSize: TabBarIndicatorSize.tab, + // indicatorColor:Colors.green, + // labelColor: Theme.of(context).primaryColor, + // labelPadding: EdgeInsets.only( + // top: 0, left: 0, right: 0, bottom: 0), + // unselectedLabelColor: Colors.grey[800], + // tabs: [ + // tabWidget(screenSize, _activeTab == 0, + // TranslationBase.of(context).details, + // ), + // tabWidget(screenSize, _activeTab == 1, + // TranslationBase.of(context).review, + // ), + // tabWidget(screenSize, _activeTab == 2, + // TranslationBase.of(context).availability), + // ], + // ), + // ), + // ), + // ), + // body: Column( + // children: [ + // Expanded( + // child: TabBarView( + // physics: BouncingScrollPhysics(), + // controller: _tabController, + // children: [ + // DetailsInfo( + // product: widget.product, + // ), + // ReviewsInfo( + // product: widget.product, + // ), + // AvailabilityInfo() + // ], + // ), + // ), + // + // ], + // ), + // ), + // ), + + SizedBox( + height: 6, ), - ), - SizedBox( - height: 6, - ), - // Container( - // height: 500, - // color: Colors.white, - // child: Scaffold( - // backgroundColor: Colors.white, - // extendBodyBehindAppBar: false, - // appBar: PreferredSize( - // preferredSize: Size.fromHeight( - // MediaQuery.of(context).size.height * 0.070), - // child: Container( - // height: MediaQuery.of(context).size.height * 0.070, - // decoration: BoxDecoration( - // border: Border( - // bottom: BorderSide( - // color: Theme.of(context).dividerColor, - // width: 0.5), //width: 0.7 - // ), - // color: Colors.white), - // child: Center( - // child: TabBar( - // isScrollable: false, - // controller: _tabController, - // // indicatorColor: Colors.transparent, - // indicatorWeight: 1.0, - // indicatorSize: TabBarIndicatorSize.tab, - // indicatorColor:Colors.green, - // labelColor: Theme.of(context).primaryColor, - // labelPadding: EdgeInsets.only( - // top: 0, left: 0, right: 0, bottom: 0), - // unselectedLabelColor: Colors.grey[800], - // tabs: [ - // tabWidget(screenSize, _activeTab == 0, - // TranslationBase.of(context).details, - // ), - // tabWidget(screenSize, _activeTab == 1, - // TranslationBase.of(context).review, - // ), - // tabWidget(screenSize, _activeTab == 2, - // TranslationBase.of(context).availability), - // ], - // ), - // ), - // ), - // ), - // body: Column( - // children: [ - // Expanded( - // child: TabBarView( - // physics: BouncingScrollPhysics(), - // controller: _tabController, - // children: [ - // DetailsInfo( - // product: widget.product, - // ), - // ReviewsInfo( - // product: widget.product, - // ), - // AvailabilityInfo() - // ], - // ), - // ), - // - // ], - // ), - // ), - // ), - - SizedBox( - height: 6, - ), - - //TODO Elham* Remove this - 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), + + //TODO Elham* Remove this + 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, ), - color: Colors.white, - ), - CustomDivider( - color: isDetails - ? Colors.green - : Colors.transparent, - ) - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = false; - isReviews = true; - isAvailability = false; - }); - }, - child: Text( - TranslationBase.of(context).reviews, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), + CustomDivider( + color: isDetails + ? Colors.green + : Colors.transparent, + ) + ], + ), + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () { + setState(() { + isDetails = false; + isReviews = true; + isAvailability = false; + }); + }, + child: Text( + TranslationBase.of(context).reviews, + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), + ), + color: Colors.white, ), - color: Colors.white, - ), - CustomDivider( - color: isReviews - ? Colors.green - : Colors.transparent, - ), - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = false; - isReviews = false; - isAvailability = true; - }); - }, - child: Text( - TranslationBase.of(context).availability, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), + CustomDivider( + color: isReviews + ? 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, - ) - : isAvailability - ? AvailabilityInfo() - : Container(), - ], + ], + ), + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () { + 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, + ), + ], + ), + ], + ), + SizedBox( + height: 10, + ), + isDetails + ? DetailsInfo( + product: widget.product, + ) + : isReviews + ? ReviewsInfo( + product: widget.product, + ) + : isAvailability + ? AvailabilityInfo() + : Container(), + ], + ), ), - ), - - ///TODO Elham* check if we need recommanded - // Row( - // children: [ - // customerId != null - // ? Container( - // width: 410, - // height: 50, - // color: Colors.white, - // child: Texts( - // TranslationBase.of(context).recommended, - // bold: true, - // ), - // ) - // : Container(), - // ], - // ), - // RecommendedProducts(product: widget.product) - - SizedBox( - height: 80, - ) - ], + + ///TODO Elham* check if we need recommanded + // Row( + // children: [ + // customerId != null + // ? Container( + // width: 410, + // height: 50, + // color: Colors.white, + // child: Texts( + // TranslationBase.of(context).recommended, + // bold: true, + // ), + // ) + // : Container(), + // ], + // ), + // RecommendedProducts(product: widget.product) + + SizedBox( + height: 80, + ) + ], + ), + ), + bottomSheet: FooterWidget( + widget.product.stockAvailability != 'Out of stock', + widget.product.orderMaximumQuantity, + widget.product.orderMinimumQuantity, + widget.product.stockQuantity, + widget.product, + price: price, + isOverQuantity: isOverQuantity, + addToCartFunction: addToCartFunction, ), ), - bottomSheet: FooterWidget( - widget.product.stockAvailability != 'Out of stock', - widget.product.orderMaximumQuantity, - widget.product.orderMinimumQuantity, - widget.product.stockQuantity, - widget.product, - price: price, - isOverQuantity: isOverQuantity, - addToCartFunction: addToCartFunction, - ), - ); + ); } } @@ -443,13 +441,8 @@ notifyMeWhenAvailable(context, itemId) async { await x.notifyMe(customerId, itemId); } -addToWishlistFunction(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - isInWishList = true; - await x.addToWishlistData(itemID); -} - deleteFromWishlistFunction(itemID) async { + ProductDetailViewModel x = new ProductDetailViewModel(); isInWishList = false; await x.deletWishlistData(itemID); 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 619a4fb1..670b3c71 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 @@ -93,10 +93,8 @@ class _ProductNameAndPriceState extends State { { if (widget.customerId != null) { if (!widget.isInWishList) { - GifLoaderDialogUtils.showMyDialog(context); await widget .addToWishlistFunction(widget.item.id); - GifLoaderDialogUtils.hideDialog(context); } else { await widget .deleteFromWishlistFunction(widget.item.id); diff --git a/lib/pages/pharmacies/screens/product-details/recommended_products.dart b/lib/pages/pharmacies/screens/product-details/recommended_products.dart index f40f1f08..2f56bf83 100644 --- a/lib/pages/pharmacies/screens/product-details/recommended_products.dart +++ b/lib/pages/pharmacies/screens/product-details/recommended_products.dart @@ -1,6 +1,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.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-detail.dart'; @@ -14,8 +15,9 @@ import 'package:rating_bar/rating_bar.dart'; class RecommendedProducts extends StatefulWidget { final PharmacyProduct product; + final ProductDetailViewModel productDetailModel; - const RecommendedProducts({Key key, this.product}) : super(key: key); + const RecommendedProducts({Key key, this.product, this.productDetailModel}) : super(key: key); @override _RecommendedProductsState createState() => _RecommendedProductsState(); @@ -146,7 +148,7 @@ class _RecommendedProductsState extends State { true) { GifLoaderDialogUtils.showMyDialog( context); - await addToWishlistFunction(model + await widget.productDetailModel.addToWishlistData(model .recommendedProductList[index] .id); // checkWishlist(); diff --git a/lib/widgets/others/app_scafold_detail_page.dart b/lib/widgets/others/app_scafold_detail_page.dart index 595e0872..fad30c41 100644 --- a/lib/widgets/others/app_scafold_detail_page.dart +++ b/lib/widgets/others/app_scafold_detail_page.dart @@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.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/insurance/insurance_update_screen.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; @@ -261,7 +262,7 @@ class AppBarWidget extends StatelessWidget with PreferredSizeWidget { title: Text( TranslationBase.of(context).addToWishlist, ), - onTap: () => {addToWishlistFunction(itemID)}, + onTap: () => {locator().addToWishlistData(itemID)}, ), ListTile( leading: Icon(Icons.compare), From 8b5e1e57c73ebeda96310391e0a8a8abe11a19b5 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Wed, 6 Oct 2021 16:24:17 +0300 Subject: [PATCH 44/67] fix bugs pharmacy wishlist --- .../product-details/product-detail.dart | 6 +- .../product-details/recommended_products.dart | 352 ------------------ 2 files changed, 1 insertion(+), 357 deletions(-) delete mode 100644 lib/pages/pharmacies/screens/product-details/recommended_products.dart diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index f3524b35..cec56f5d 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -20,8 +20,6 @@ import 'discount_description.dart'; import 'footor/footer-widget.dart'; import 'shared/product_details_app_bar.dart'; - - String itemID; PharmacyProduct specificationData; @@ -338,6 +336,4 @@ addToCartFunction({quantity, itemID, BuildContext context,ProductDetailViewModel notifyMeWhenAvailable({itemId, customerId,ProductDetailViewModel model }) async { await model.notifyMe(customerId, itemId); -} - - +} \ No newline at end of file diff --git a/lib/pages/pharmacies/screens/product-details/recommended_products.dart b/lib/pages/pharmacies/screens/product-details/recommended_products.dart deleted file mode 100644 index 7222ad85..00000000 --- a/lib/pages/pharmacies/screens/product-details/recommended_products.dart +++ /dev/null @@ -1,352 +0,0 @@ -import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.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-detail.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/transitions/fade_page.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; -import 'package:rating_bar/rating_bar.dart'; - -class RecommendedProducts extends StatefulWidget { - final PharmacyProduct product; - final String customerId; - final ProductDetailViewModel productDetailViewModel; - final bool isOverQuantity; - final bool isInWishList; - final Function addToWishlistFunction; - final Function deleteFromWishlistFunction; - - RecommendedProducts( - {Key key, - this.product, - this.productDetailViewModel, - this.customerId, - this.isOverQuantity = false, - this.isInWishList = false, - this.addToWishlistFunction, - this.deleteFromWishlistFunction}) - : super(key: key); - - @override - _RecommendedProductsState createState() => _RecommendedProductsState(); -} - -class _RecommendedProductsState extends State { - @override - Widget build(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); - return SingleChildScrollView( - child: Container( - width: 410, - color: Colors.white, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - color: Colors.white, - height: 210, - margin: EdgeInsets.only(bottom: 75), - padding: EdgeInsets.only(bottom: 5), - // margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4), - child: BaseView( - onModelReady: (model) => - model.getRecommendedProducts(widget.product.id), - builder: (_, model, wi) => Container( - child: model.recommendedProductList.length != null - ? ListView.builder( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - physics: ScrollPhysics(), - // physics: NeverScrollableScrollPhysics(), - itemCount: model.recommendedProductList.length, - itemBuilder: (context, index) { - return InkWell( - onTap: () async { - GifLoaderDialogUtils.showMyDialog(context); - RecommendedProductModel data = - model.recommendedProductList[index]; - var json = data.toJson(); - PharmacyProduct product = - new PharmacyProduct.fromJson(json); - await Navigator.pushReplacement( - context, - FadePage( - page: ProductDetailPage(product), - ), - ); - GifLoaderDialogUtils.hideDialog(context); - }, - child: Card( - elevation: 2, - shape: RoundedRectangleBorder( - side: BorderSide( - color: Colors.grey[300], width: 2), - borderRadius: BorderRadius.circular(10), - ), - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 0, - ), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(15), - ), - ), - padding: EdgeInsets.symmetric(horizontal: 4), - width: MediaQuery.of(context).size.width / 3, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Stack(children: [ - Container( - child: Align( - alignment: Alignment.topRight, - child: IconButton( - icon: Icon(model - .recommendedProductList[ - index] - .isinwishlist != - true - ? Icons.favorite_border - : Icons.favorite), - color: model - .recommendedProductList[ - index] - .isinwishlist != - true - ? Colors.grey - : Colors.red, - onPressed: () async { - if (widget.customerId != null) { - if (!widget.isInWishList && - model - .recommendedProductList[ - index] - .isinwishlist != - true) { - GifLoaderDialogUtils - .showMyDialog(context); - await widget.addToWishlistFunction( - itemID: model - .recommendedProductList[ - index] - .id, - model: widget - .productDetailViewModel); -// checkWishlist(); - GifLoaderDialogUtils - .hideDialog(context); - setState(() { - model - .recommendedProductList[ - index] - .isinwishlist = true; - }); - } else { - GifLoaderDialogUtils - .showMyDialog(context); - await widget.deleteFromWishlistFunction( - itemID: model - .recommendedProductList[ - index] - .id, - model: widget - .productDetailViewModel); - GifLoaderDialogUtils - .hideDialog(context); - setState(() { - model - .recommendedProductList[ - index] - .isinwishlist = false; - }); - } - } else { - return; - } - setState(() { - // checkWishlist(); - }); - }, - ), - ), - ), - Container( - margin: EdgeInsets.fromLTRB( - 0, 16, 10, 16), - alignment: Alignment.center, - child: (model - .recommendedProductList[ - index] - .images != - null && - model - .recommendedProductList[ - index] - .images - .length > - 0) - ? Image.network( - model - .recommendedProductList[ - index] - .images[0] - .src - .toString(), - fit: BoxFit.cover, - height: 60, - ) - : Image.asset( - "assets/images/no_image.png", - fit: BoxFit.cover, - height: 60, - ), - ), - Container( - width: model - .recommendedProductList[ - 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 - .recommendedProductList[ - index] - .rxMessage != - null - ? Texts( - projectViewModel.isArabic - ? model - .recommendedProductList[ - index] - .rxMessagen - : model - .recommendedProductList[ - index] - .rxMessage, - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ) - : Texts(""), - ), - ]), - Container( - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, - ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - projectViewModel.isArabic - ? model - .recommendedProductList[ - index] - .namen - : model - .recommendedProductList[ - index] - .name, - style: TextStyle( - color: Colors.black, - fontSize: 13.0, -// fontWeight: FontWeight.bold, - ), - ), - Padding( -// padding: const EdgeInsets.only(top: 15, bottom: 10), - padding: const EdgeInsets.only( - top: 10, bottom: 5), - child: Texts( - "SAR ${model.recommendedProductList[index].price}", - bold: true, - fontSize: 14, - ), - ), - ], - ), - ), - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - padding: - EdgeInsets.only(right: 10), - child: Align( - alignment: Alignment.topLeft, - child: RatingBar.readOnly( - initialRating: model - .recommendedProductList[ - index] - .approvedRatingSum - .toDouble(), - size: 13.0, - filledColor: - Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: - Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, - ), - ), - ), - Texts( - "(${model.recommendedProductList[index].notApprovedTotalReviews.toString()})", -// bold: true, - fontSize: 12, - ), - ]), - ], - ), - ), - ), - ); - }) - : Container( - // color: Colors.white, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - // crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Texts( - TranslationBase.of(context).nonRecommended, - color: Colors.black, - ), - ], - ), - ), - ), - ), - ), - ], - ), - ), - ); - } -} From 92540041253d3782982852ad4f1c9d245b4f45c0 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 6 Oct 2021 16:26:27 +0300 Subject: [PATCH 45/67] fix coloring issue --- .../screens/product-details/product-detail.dart | 1 + .../shared/product_details_app_bar.dart | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index f3524b35..b1bc4f4b 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -98,6 +98,7 @@ class __ProductDetailPageState extends State{ isShowDecPage: false, customAppBar: ProductAppBar( product: widget.product, + quantity: quantity, model: model, addToWishlistFunction: (item) { addToWishlistFunction(itemID:item,model:model); 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 13547fd1..99dfd546 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 @@ -20,7 +20,12 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { final Function addToWishlistFunction; final int quantity; - ProductAppBar({Key key, this.product, this.model, this.addToWishlistFunction, this.quantity}) + ProductAppBar( + {Key key, + this.product, + this.model, + this.addToWishlistFunction, + this.quantity}) : super(key: key); AuthenticatedUserObject authenticatedUserObject = @@ -71,7 +76,8 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { icon: FontAwesomeIcons.ellipsisV, color: Colors.grey, onPress: () { - settingModalBottomSheet(context); + settingModalBottomSheet( + context); }, ), ], @@ -84,7 +90,6 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { ); } - @override @override Size get preferredSize => Size(double.maxFinite, 50); @@ -121,8 +126,9 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { title: Text( TranslationBase.of(context).addToWishlist, ), - onTap: () => - {addToWishlistFunction(itemID: itemID, model: model)}, + onTap: () { + addToWishlistFunction(itemID: itemID, model: model); + }, ), ListTile( leading: Icon(Icons.compare), From b0b278a7e3d628eb6cd246042cd902d7005a1307 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 7 Oct 2021 09:14:48 +0300 Subject: [PATCH 46/67] fix bugs --- .../product_detail_view_model.dart | 10 +- .../pharmacies/ProductCheckTypeWidget.dart | 2 +- .../product-details/product-detail.dart | 8 +- .../screens/product-details/reviews_info.dart | 123 +++++++++--------- .../shared/product_details_app_bar.dart | 4 +- .../product_detail_service.dart | 12 +- 6 files changed, 85 insertions(+), 74 deletions(-) diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index 9c8e7ef4..968fe029 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -97,12 +97,12 @@ class ProductDetailViewModel extends BaseViewModel{ } - Future deletWishlistData(itemID) async { + Future deleteWishlistData(itemID) async { hasError = false; setState(ViewState.BusyLocal); GifLoaderDialogUtils.showMyDialog( locator().navigatorKey.currentContext); - await _productDetailService.delteItemFromWishlist(itemID); + await _productDetailService.deleteItemFromWishlist(itemID); GifLoaderDialogUtils.hideDialog( locator().navigatorKey.currentContext); @@ -125,4 +125,10 @@ class ProductDetailViewModel extends BaseViewModel{ setState(ViewState.Idle); } + clearReview(){ + + productDetailService.clear(); + + } + } \ No newline at end of file diff --git a/lib/pages/pharmacies/ProductCheckTypeWidget.dart b/lib/pages/pharmacies/ProductCheckTypeWidget.dart index edecff62..e6139d73 100644 --- a/lib/pages/pharmacies/ProductCheckTypeWidget.dart +++ b/lib/pages/pharmacies/ProductCheckTypeWidget.dart @@ -87,7 +87,7 @@ class _ProductCheckTypeWidgetState extends State { deleteWishListItem(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); GifLoaderDialogUtils.showMyDialog(context); - await x.deletWishlistData(itemID); + await x.deleteWishlistData(itemID); setState(() async{ await diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 8d459a92..3ef1758b 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -98,8 +98,8 @@ class __ProductDetailPageState extends State{ product: widget.product, quantity: quantity, model: model, - addToWishlistFunction: (item) { - addToWishlistFunction(itemID:item,model:model); + addToWishlistFunction: () { + addToWishlistFunction(itemID:itemID,model:model); setState(() {}); }, ), @@ -221,6 +221,8 @@ class __ProductDetailPageState extends State{ await model.getProductReviewsData( widget.product.id); GifLoaderDialogUtils.hideDialog(context); + } else { + model.clearReview(); } setState(() { isDetails = false; @@ -324,7 +326,7 @@ class __ProductDetailPageState extends State{ deleteFromWishlistFunction({itemID, ProductDetailViewModel model}) async { isInWishList = false; - await model.deletWishlistData(itemID); + await model.deleteWishlistData(itemID); } } diff --git a/lib/pages/pharmacies/screens/product-details/reviews_info.dart b/lib/pages/pharmacies/screens/product-details/reviews_info.dart index 15260071..64336d85 100644 --- a/lib/pages/pharmacies/screens/product-details/reviews_info.dart +++ b/lib/pages/pharmacies/screens/product-details/reviews_info.dart @@ -8,82 +8,83 @@ class ReviewsInfo extends StatelessWidget { final PharmacyProduct product; final ProductDetailViewModel previousModel; - const ReviewsInfo({Key key, this.product, this.previousModel}) : super(key: key); + const ReviewsInfo({Key key, this.product, this.previousModel}) + : super(key: key); @override Widget build(BuildContext context) { return previousModel.productDetailService.length != 0 && - previousModel.productDetailService[0].reviews.length != 0 + previousModel.productDetailService[0].reviews.length != 0 ? ListView.builder( - physics: ScrollPhysics(), - itemCount: previousModel.productDetailService[0].reviews.length, - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: Row( + physics: ScrollPhysics(), + itemCount: previousModel.productDetailService[0].reviews.length, + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - child: Text( - previousModel.productDetailService[0].reviews[index] - .customerId - .toString(), - style: TextStyle( - fontSize: 17, - color: Colors.grey, - fontWeight: FontWeight.w600), + child: Row( + children: [ + Container( + child: Text( + previousModel.productDetailService[0] + .reviews[index].customerId + .toString(), + style: TextStyle( + fontSize: 17, + color: Colors.grey, + fontWeight: FontWeight.w600), + ), + ), + Container( + margin: EdgeInsets.only(left: 210), + child: RatingBar.readOnly( + initialRating: previousModel + .productDetailService[0].reviews[index].rating + .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: 10, + ), Container( - margin: EdgeInsets.only(left: 210), - child: RatingBar.readOnly( - initialRating: previousModel.productDetailService[0] - .reviews[index].rating - .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( + previousModel + .productDetailService[0].reviews[index].reviewText, + style: TextStyle(fontSize: 20), ), ), + SizedBox( + height: 50, + ), + Divider(height: 1, color: Colors.grey), ], ), - ), - SizedBox( - height: 10, - ), - Container( - child: Text( - previousModel.productDetailService[0].reviews[index] - .reviewText, - style: TextStyle(fontSize: 20), - ), - ), - SizedBox( - height: 50, - ), - Divider(height: 1, color: Colors.grey), - ], - ), - ); - }, - ) + ); + }, + ) : Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text( - TranslationBase.of(context).noReviewsAvailable, - ), + padding: EdgeInsets.all(15), + alignment: Alignment.center, + child: Text( + TranslationBase.of(context).noReviewsAvailable, + ), // Text('No Reviews Available'), - ); + ); } } 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 99dfd546..d5fa1165 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 @@ -127,8 +127,8 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { TranslationBase.of(context).addToWishlist, ), onTap: () { - addToWishlistFunction(itemID: itemID, model: model); - }, + addToWishlistFunction(); + } ), ListTile( leading: Icon(Icons.compare), diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 0f86df23..990b5f23 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -7,6 +7,7 @@ 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'; class ProductDetailService extends BaseService { bool isLogin = false; @@ -98,7 +99,7 @@ class ProductDetailService extends BaseService { }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - AppToast.showErrorToast(message: super.error??'something went wrong please try again'); + AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage()); }, body: request); } @@ -109,7 +110,7 @@ class ProductDetailService extends BaseService { }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - AppToast.showErrorToast(message: 'something went wrong please try again'); + AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage()); }); } @@ -126,12 +127,13 @@ class ProductDetailService extends BaseService { _wishListProducts.clear(); response['shopping_carts'].forEach((item) { _wishListProducts.add(Wishlist.fromJson(item)); - AppToast.showSuccessToast(message: 'You have added a product to the Wishlist'); }); + AppToast.showSuccessToast(message: 'You have added a product to the Wishlist'); + }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - AppToast.showErrorToast(message: 'something went wrong please try again'); + AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage()); }, body: request); } @@ -149,7 +151,7 @@ class ProductDetailService extends BaseService { super.error = error; }); } - Future delteItemFromWishlist(itemID) async { + 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", From 4309952b170d5520e679628bd3bff464b3425e06 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Thu, 7 Oct 2021 10:12:33 +0300 Subject: [PATCH 47/67] fixed subCategories --- lib/config/config.dart | 12 +- lib/pages/parent_categorise_page.dart | 135 ++++++++++-------- lib/pages/pharmacies/my_reviews.dart | 4 +- lib/pages/pharmacies/wishlist.dart | 3 +- lib/pages/sub_categories_modalsheet.dart | 108 ++++++++++++++ .../pharmacy_services/review_service.dart | 2 + 6 files changed, 198 insertions(+), 66 deletions(-) create mode 100644 lib/pages/sub_categories_modalsheet.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 5af95569..2e7213c0 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -13,16 +13,16 @@ const PACKAGES_CUSTOMER = '/api/customers'; const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; const PACKAGES_ORDERS = '/api/orders'; -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/'; const PING_SERVICE = 'Services/Weather.svc/REST/CheckConnectivity'; diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 40bf2dc7..79b49871 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -16,7 +16,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:diplomaticquarterapp/pages/sub_categories_modalsheet.dart'; import 'base/base_view.dart'; class ParentCategorisePage extends StatefulWidget { @@ -114,56 +114,65 @@ class _ParentCategorisePageState extends State { ), ), 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.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, - )), - ); - }, - ), - ), - ); - }), - ), - ); - }, + 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, +// )), +// ); +// }, +// ), +// ), +// ); +// }), +// ), +// ); +// }, +// ); }, ), ), @@ -300,7 +309,8 @@ class _ParentCategorisePageState extends State { width: 10.0, ), Texts( - 'Refine', + TranslationBase.of(context).refine, +// 'Refine', fontWeight: FontWeight.w600, ), SizedBox( @@ -308,7 +318,8 @@ class _ParentCategorisePageState extends State { ), InkWell( child: Texts( - 'Close', +// 'Close', + TranslationBase.of(context).closeIt, color: Colors.red, fontWeight: FontWeight.w600, fontSize: 15.0, @@ -327,7 +338,9 @@ class _ParentCategorisePageState extends State { Column( children: [ ExpansionTile( - title: Texts('Categorise'), + title: Texts( TranslationBase.of( + context) + .categorise), children: [ ProcedureListWidget( model: model, @@ -356,7 +369,9 @@ class _ParentCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts('Brands'), + title: Texts( TranslationBase.of( + context) + .brands), children: [ ProcedureListWidget( model: model, @@ -385,7 +400,9 @@ class _ParentCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts('Price'), + title: Texts( TranslationBase.of( + context) + .price), children: [ Container( color: Color(0xffEEEEEE), @@ -446,7 +463,9 @@ class _ParentCategorisePageState extends State { Container( width: 100, child: Button( - label: 'Reset', + label: TranslationBase.of( + context) + .reset, backgroundColor: Colors.red, ), ), @@ -486,7 +505,9 @@ class _ParentCategorisePageState extends State { Navigator.pop(context); }, - label: 'Apply', + label: TranslationBase.of( + context) + .apply, backgroundColor: Colors.green, ), ), diff --git a/lib/pages/pharmacies/my_reviews.dart b/lib/pages/pharmacies/my_reviews.dart index efb93f96..029f8ca4 100644 --- a/lib/pages/pharmacies/my_reviews.dart +++ b/lib/pages/pharmacies/my_reviews.dart @@ -121,7 +121,7 @@ reviewDetails(data, rate, myRate) { : data.product.name, style: TextStyle( color: Colors.black54, - fontSize: languageID == 'ar' ? 7 : 13, + fontSize: languageID == 'ar' ? 12 : 13, fontWeight: FontWeight.bold), ), ), @@ -187,7 +187,7 @@ reviewDetails(data, rate, myRate) { padding: languageID == 'ar' ? EdgeInsets.only(right: 10) : EdgeInsets.only(left: 10), - child: Text(data.createdOnUtc.toString())), + child: Text(data.createdOnUtc.toString().substring(0 , 11))), ], ), ), diff --git a/lib/pages/pharmacies/wishlist.dart b/lib/pages/pharmacies/wishlist.dart index b75f709b..c90f2138 100644 --- a/lib/pages/pharmacies/wishlist.dart +++ b/lib/pages/pharmacies/wishlist.dart @@ -42,7 +42,8 @@ class _WishlistPageState extends State { Padding( padding: const EdgeInsets.all(8.0), child: Text( - 'There is no data', + TranslationBase.of(context).noData, +// 'There is no data', style: TextStyle(fontSize: 30), ), ) diff --git a/lib/pages/sub_categories_modalsheet.dart b/lib/pages/sub_categories_modalsheet.dart new file mode 100644 index 00000000..f1ff0e08 --- /dev/null +++ b/lib/pages/sub_categories_modalsheet.dart @@ -0,0 +1,108 @@ + +import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacy/pharmacy_categorise.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/pages/sub_categorise_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_pharmacy_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'base/base_view.dart'; +import 'package:provider/provider.dart'; + + + + +class SubCategoriseModalsheet extends StatefulWidget { + String id; + String titleName; + + SubCategoriseModalsheet({this.id, this.titleName}); + @override + _SubCategoriseModalsheetState createState() => _SubCategoriseModalsheetState(id: id, titleName: titleName); + +} + +class _SubCategoriseModalsheetState extends State { + String id; + String titleName; +// List categoriesList = []; + _SubCategoriseModalsheetState({this.id, this.titleName}); + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return BaseView( + onModelReady: (model) => model.getCategoriseParent(i: id), + builder: (_, model, wi) => AppScaffold( + // appBarTitle: titleName, + appBarTitle: TranslationBase.of(context).categorise, + isBottomBar: false, + isShowAppBar: true, + backgroundColor: Colors.white, + isShowDecPage: false, + baseViewModel: model, + body: Container( + 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), + SizedBox( + height: 10, + ), + 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, + )), + ); + }, + ), + ), + ); + }), + ), + ), + + ), + ); + } +// getCatName() { +// +// if (widget.id == '1' ) +// return Texts("text1"); +// else if (widget.id == '2' ) +// return Texts("text2"); +// else if (widget.id == '3') +// return Texts("text3"); +// else if (widget.id == '4' ) +// return Texts("text4"); +// } + + +} \ No newline at end of file diff --git a/lib/services/pharmacy_services/review_service.dart b/lib/services/pharmacy_services/review_service.dart index 44839955..c85d68e2 100644 --- a/lib/services/pharmacy_services/review_service.dart +++ b/lib/services/pharmacy_services/review_service.dart @@ -28,6 +28,8 @@ class ReviewService extends BaseService { _reviewList.clear(); response['reviews'].forEach((item) { _reviewList.add(Review.fromJson(item)); + print (response); + print (item['reviewText']); }); }, onFailure: (String error, int statusCode) { hasError = true; From 3dc28d318a85791f23806eeb2a108e5d9e57f1c2 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 7 Oct 2021 10:16:45 +0300 Subject: [PATCH 48/67] fix bugs on wish list --- lib/config/localized_values.dart | 1 + .../product-details/product-detail.dart | 42 +++++++---- .../shared/product_details_app_bar.dart | 69 +++++++++++-------- lib/uitl/translations_delegate_base.dart | 2 + 4 files changed, 72 insertions(+), 42 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 7d764249..3979e982 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1555,6 +1555,7 @@ const Map localizedValues = { "quantitySize": {"en": "Quantity", "ar": "كميه"}, "addToCart": {"en": "Add to Cart", "ar": "إضف للسلة"}, "addToWishlist": {"en": "Add to Wishlist", "ar": "اضف للمفضلة"}, + "removeFromWishlist": {"en": "Remove From Wishlist", "ar": "احذف للمفضلة"}, "noData": {"en": "There is no data", "ar": "لايوجد بيانات"}, "no_data": {"en": "No data", "ar": "لايوجد بيانات"}, "buyNow": {"en": "buy now", "ar": "إشتري الان"}, diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 3ef1758b..6ac5ec25 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -32,7 +32,7 @@ class ProductDetailPage extends StatefulWidget { __ProductDetailPageState createState() => __ProductDetailPageState(); } -class __ProductDetailPageState extends State{ +class __ProductDetailPageState extends State { AppSharedPreferences sharedPref = AppSharedPreferences(); bool isTrue = true; @@ -45,7 +45,6 @@ class __ProductDetailPageState extends State{ bool isInWishList = false; int quantity = 0; - checkWishlist() async { GifLoaderDialogUtils.showMyDialog(context); ProductDetailViewModel model = new ProductDetailViewModel(); @@ -98,10 +97,13 @@ class __ProductDetailPageState extends State{ product: widget.product, quantity: quantity, model: model, - addToWishlistFunction: () { - addToWishlistFunction(itemID:itemID,model:model); - setState(() {}); + addToWishlistFunction: () async { + await addToWishlistFunction(itemID: itemID, model: model); + }, + deleteFromWishlistFunction: () async { + await deleteFromWishlistFunction(itemID: itemID, model: model); }, + isInWishList:isInWishList ), body: SingleChildScrollView( child: Column( @@ -134,15 +136,19 @@ class __ProductDetailPageState extends State{ widget.product, customerId: customerId, addToWishlistFunction: (item) { - addToWishlistFunction(itemID:item,model:model); + addToWishlistFunction(itemID: item, model: model); 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, ), @@ -215,12 +221,14 @@ class __ProductDetailPageState extends State{ children: [ FlatButton( onPressed: () async { - if(widget.product.approvedTotalReviews>0) { + if (widget.product.approvedTotalReviews > + 0) { GifLoaderDialogUtils.showMyDialog( context); await model.getProductReviewsData( widget.product.id); - GifLoaderDialogUtils.hideDialog(context); + GifLoaderDialogUtils.hideDialog( + context); } else { model.clearReview(); } @@ -322,21 +330,27 @@ class __ProductDetailPageState extends State{ addToWishlistFunction({itemID, ProductDetailViewModel model}) async { isInWishList = true; await model.addToWishlistData(itemID); + setState(() {}); } deleteFromWishlistFunction({itemID, ProductDetailViewModel model}) async { isInWishList = false; await model.deleteWishlistData(itemID); + setState(() {}); } } - -addToCartFunction({quantity, itemID, BuildContext context,ProductDetailViewModel model}) async { +addToCartFunction( + {quantity, + itemID, + BuildContext context, + 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); -} \ No newline at end of file +} 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 d5fa1165..367e0d35 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 @@ -18,14 +18,18 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { final ProductDetailViewModel model; final Function addToWishlistFunction; + final Function deleteFromWishlistFunction; final int quantity; + final bool isInWishList; ProductAppBar( {Key key, this.product, this.model, this.addToWishlistFunction, - this.quantity}) + this.quantity, + this.deleteFromWishlistFunction, + this.isInWishList}) : super(key: key); AuthenticatedUserObject authenticatedUserObject = @@ -76,8 +80,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { icon: FontAwesomeIcons.ellipsisV, color: Colors.grey, onPress: () { - settingModalBottomSheet( - context); + settingModalBottomSheet(context); }, ), ], @@ -106,38 +109,48 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { title: Text( TranslationBase.of(context).addToCart, ), - onTap: () => { - if (quantity > 0) - { - addToCartFunction( - quantity: quantity, - itemID: itemID, - context: context, - model: model) - } - else - { - AppToast.showErrorToast( - message: "you should add quantity") - } - }), + onTap: () async { + if (quantity > 0) { + { + await addToCartFunction( + quantity: quantity, + itemID: itemID, + context: context, + model: model); + + Navigator.of(context).pop(); + } + } else { + AppToast.showErrorToast( + message: "you should add quantity"); + } + }), ListTile( - leading: Icon(Icons.favorite_border), - title: Text( - TranslationBase.of(context).addToWishlist, - ), - onTap: () { - addToWishlistFunction(); - } - ), + leading: Icon( + !isInWishList ? Icons.favorite_border : Icons.favorite, + color: !isInWishList ? Colors.white : Colors.red[800], + ), + title: Text( + isInWishList + ? TranslationBase.of(context).removeFromWishlist + : TranslationBase.of(context).addToWishlist, + ), + onTap: () async { + if (isInWishList) + await deleteFromWishlistFunction(); + else + await addToWishlistFunction(); + Navigator.of(context).pop(); + }), ListTile( leading: Icon(Icons.compare), title: Text( TranslationBase.of(context).compare, ), - onTap: () => { + onTap: () { Provider.of(context, listen: false) - .addItem(specificationData), + .addItem(specificationData); + Navigator.of(context).pop(); }, ), ], diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 158d8afb..d8c3ff7b 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1398,6 +1398,8 @@ class TranslationBase { String get addToCart => localizedValues['addToCart'][locale.languageCode]; String get addToWishlist => localizedValues['addToWishlist'][locale.languageCode]; + String get removeFromWishlist => + localizedValues['removeFromWishlist'][locale.languageCode]; String get buyNow => localizedValues['buyNow'][locale.languageCode]; String get quantityShortcut => localizedValues['quantityShortcut'][locale.languageCode]; From eb19daa98f85c2623fd8a07c35d3266d3590072f Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Thu, 7 Oct 2021 10:18:05 +0300 Subject: [PATCH 49/67] fix car count --- .../pharmacies/ShoppingCartResponse.dart | 18 +- .../pharmacyModule/OrderPreviewViewModel.dart | 1 - lib/locator.dart | 2 +- lib/main.dart | 3 + .../pharmacies/screens/cart-order-page.dart | 682 +++++++++--------- .../screens/cart-order-preview.dart | 449 ++++++------ .../screens/pharmacy_module_page.dart | 3 + lib/widgets/buttons/GestureIconButton.dart | 17 +- .../pharmacy/bottom_nav_pharmacy_item.dart | 122 ++-- 9 files changed, 672 insertions(+), 625 deletions(-) diff --git a/lib/core/model/pharmacies/ShoppingCartResponse.dart b/lib/core/model/pharmacies/ShoppingCartResponse.dart index 96b751ae..332f63b6 100644 --- a/lib/core/model/pharmacies/ShoppingCartResponse.dart +++ b/lib/core/model/pharmacies/ShoppingCartResponse.dart @@ -1,7 +1,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCart.dart'; import 'package:flutter/material.dart'; -class ShoppingCartResponse with ChangeNotifier { +class ShoppingCartResponse { int itemCount; int quantityCount; double subtotal; @@ -11,17 +11,15 @@ class ShoppingCartResponse with ChangeNotifier { List shoppingCarts; ShoppingCartResponse( - {this.itemCount, - this.quantityCount, - this.subtotal, - this.subtotalWithVat, - this.subtotalVatAmount, - this.subtotalVatRate, + {this.itemCount =0, + this.quantityCount =0, + this.subtotal=0.0, + this.subtotalWithVat = 0.0, + this.subtotalVatAmount = 0.0, + this.subtotalVatRate = 0.0 , this.shoppingCarts}); - void updateShoppingCard() { - notifyListeners(); - } + ShoppingCartResponse.fromJson(Map json) { itemCount = json['item_count']; diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index 104dec05..9bcfd490 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -114,7 +114,6 @@ class OrderPreviewViewModel extends BaseViewModel { cartResponse.shoppingCarts.add(shoppingCart); totalAdditionalShippingCharge += shoppingCart.product.additionalShippingCharge; }); - cartResponse.updateShoppingCard(); return cartResponse; } diff --git a/lib/locator.dart b/lib/locator.dart index b855e5a7..08e0a2ea 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -294,7 +294,7 @@ void setupLocator() { locator.registerFactory(() => ProductDetailViewModel()); locator.registerFactory(() => WeatherViewModel()); - locator.registerFactory(() => OrderPreviewViewModel()); + // locator.registerFactory(() => OrderPreviewViewModel()); locator.registerFactory(() => LacumViewModel()); locator.registerFactory(() => LacumTranferViewModel()); locator.registerFactory(() => LacumRegistrationViewModel()); diff --git a/lib/main.dart b/lib/main.dart index dda4d57a..87120231 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -13,6 +13,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:provider/provider.dart'; import 'config/size_config.dart'; +import 'core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'core/viewModels/project_view_model.dart'; import 'locator.dart'; import 'pages/pharmacies/compare-list.dart'; @@ -79,6 +80,8 @@ class _MyApp extends State { ), ChangeNotifierProvider( create: (context) => CompareList()), + ChangeNotifierProvider( + create: (context) => OrderPreviewViewModel()), ], child: Consumer( builder: (context, projectProvider, child) => MaterialApp( diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index c2ebf4b2..6a086721 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -12,229 +12,235 @@ import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/GestureIconButton.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'; import 'package:provider/provider.dart'; -class CartOrderPage extends StatelessWidget { +class CartOrderPage extends StatefulWidget { + const CartOrderPage({Key key}) : super(key: key); + @override + _CartOrderPageState createState() => _CartOrderPageState(); +} + +class _CartOrderPageState extends State { + + + @override + void initState() { + super.initState(); + Provider.of(context, listen: false).getShoppingCart(); + } + @override Widget build(BuildContext context) { final mediaQuery = MediaQuery.of(context); + OrderPreviewViewModel model = Provider.of(context); final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; AppScaffold appScaffold; - return BaseView( - onModelReady: (model) { - model.getShoppingCart().then((value) { - appScaffold.appBar - .badgeUpdater('${model.cartResponse.quantityCount ?? 0}'); - }); - }, - builder: (_, model, wi) => ChangeNotifierProvider.value( - value: model.cartResponse, - child: appScaffold = AppScaffold( - appBarTitle: TranslationBase.of(context).shoppingCart, - isShowAppBar: true, - isPharmacy: true, - baseViewModel: model, - backgroundColor: Colors.white, - body: !(model.cartResponse.shoppingCarts == null || - model.cartResponse.shoppingCarts.length == 0) - ? Container( - height: height * 0.85, - width: double.infinity, - child: Consumer( - builder: (ctx, cart, _) => Container( - 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( - children: [ - ...List.generate( - cart.shoppingCarts != null - ? cart.shoppingCarts.length - : 0, - (index) => ProductOrderItem( - cart.shoppingCarts[index], () { - print(cart.shoppingCarts[index] - .quantity); - model - .changeProductQuantity( - cart.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( - cart.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} ${(cart.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} ${(cart.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} ${(cart.subtotal).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_image.png", - width: mediaQuery.size.width - 20, - height: 30.0, - fit: BoxFit.scaleDown, - ) - ], - ), - ), - ), + return NetworkBaseView( + baseViewModel: model, + child: AppScaffold( + appBarTitle: TranslationBase.of(context).shoppingCart, + isShowAppBar: true, + isPharmacy: true, + showHomeAppBarIcon: false, + baseViewModel: model, + backgroundColor: Colors.white, + body: !(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), + 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}'); + } + }); + })) + ], ), ), - ) - : Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 2, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, 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).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.subtotal).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_image.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), + ), + 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), + ), ), ); } @@ -256,154 +262,150 @@ class _OrderBottomWidgetState extends State { @override Widget build(BuildContext context) { ProjectViewModel projectProvider = Provider.of(context); - - return Container( - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0), - child: Consumer( - builder: (ctx, cart, _) => !(cart.shoppingCarts == null || - cart.shoppingCarts.length == 0) - ? Column( + OrderPreviewViewModel cart = Provider.of(context); + return !(cart.cartResponse.shoppingCarts == null || + cart.cartResponse.shoppingCarts.length == 0) + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Divider( + color: Color(0xFFD6D6D6), + height: 1, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Container( + height: widget.height * 0.070, + color: Color(0xffe6ffe0), + padding: EdgeInsets.symmetric(horizontal: 4), + child: Row( + children: [ + InkWell( + onTap: () { + setState(() { + isAgree = !isAgree; + }); + }, + child: Container( + width: 25.0, + height: widget.height * 0.070, + decoration: new BoxDecoration( + color: + !isAgree ? Color(0xffeeeeee) : Colors.green, + shape: BoxShape.circle, + ), + child: !isAgree + ? null + : Padding( + padding: const EdgeInsets.all(0.0), + child: Icon( + Icons.check, + color: Colors.white, + size: 25, + ), + ), + ), + ), + Expanded( + child: Container( + padding: EdgeInsets.symmetric(horizontal: 4), + margin: const EdgeInsets.symmetric(vertical: 4), + child: Texts( + TranslationBase.of(context) + .pharmacyServiceTermsCondition, + fontSize: 13, + color: Colors.grey.shade800, + fontWeight: FontWeight.normal, + ), + ), + ), + InkWell( + onTap: () => { + Navigator.push(context, + FadePage(page: PharmacyTermsConditions())) + }, + child: Container( + child: Icon( + Icons.info, + size: 25, + color: Color(0xff005aff), + ), + ), + ), + ], + ), + ), + Container( + height: widget.height * 0.065, + margin: EdgeInsets.symmetric(vertical: 2), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, children: [ - const Divider( - color: Color(0xFFD6D6D6), - height: 1, - thickness: 1, - indent: 0, - endIndent: 0, - ), Container( - height: widget.height * 0.070, - color: Color(0xffe6ffe0), - padding: EdgeInsets.symmetric(horizontal: 4), + margin: EdgeInsets.symmetric( + horizontal: 0, vertical: 0), child: Row( children: [ - InkWell( - onTap: () { - setState(() { - isAgree = !isAgree; - }); - }, - child: Container( - width: 25.0, - height: widget.height * 0.070, - decoration: new BoxDecoration( - color: - !isAgree ? Color(0xffeeeeee) : Colors.green, - shape: BoxShape.circle, - ), - child: !isAgree - ? null - : Padding( - padding: const EdgeInsets.all(0.0), - child: Icon( - Icons.check, - color: Colors.white, - size: 25, - ), - ), - ), - ), - Expanded( - child: Container( - padding: EdgeInsets.symmetric(horizontal: 4), - margin: const EdgeInsets.symmetric(vertical: 4), - child: Texts( - TranslationBase.of(context) - .pharmacyServiceTermsCondition, - fontSize: 13, - color: Colors.grey.shade800, - fontWeight: FontWeight.normal, - ), - ), + Texts( + "${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: + projectProvider.isArabic ? 12 : 14, + fontWeight: FontWeight.bold, ), - InkWell( - onTap: () => { - Navigator.push(context, - FadePage(page: PharmacyTermsConditions())) - }, - child: Container( - child: Icon( - Icons.info, - size: 25, - color: Color(0xff005aff), - ), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 4), + child: Texts( + "${TranslationBase.of(context).inclusiveVat}", + fontSize: 8, + color: Colors.grey, + fontWeight: FontWeight.bold, ), ), ], ), ), - Container( - height: widget.height * 0.065, - margin: EdgeInsets.symmetric(vertical: 2), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - margin: EdgeInsets.symmetric( - horizontal: 0, vertical: 0), - child: Row( - children: [ - Texts( - "${TranslationBase.of(context).sar} ${(cart.subtotal).toStringAsFixed(2)}", - fontSize: - projectProvider.isArabic ? 12 : 14, - fontWeight: FontWeight.bold, - ), - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 4), - child: Texts( - "${TranslationBase.of(context).inclusiveVat}", - fontSize: 8, - color: Colors.grey, - fontWeight: FontWeight.bold, - ), - ), - ], - ), - ), - Texts( - "${cart.quantityCount} ${TranslationBase.of(context).items}", - fontSize: 10, - color: Colors.grey, - fontWeight: FontWeight.bold, - ), - ], - ), - ), - RaisedButton( - onPressed: isAgree - ? () => { - 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), - ), - ], - ), + Texts( + "${cart.cartResponse.quantityCount} ${TranslationBase.of(context).items}", + fontSize: 10, + color: Colors.grey, + fontWeight: FontWeight.bold, ), ], - ) - : Container(), - )); + ), + ), + RaisedButton( + onPressed: isAgree + ? () => { + 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), + ), + ], + ), + ), + ], + ) + : Container(); } } diff --git a/lib/pages/pharmacies/screens/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-order-preview.dart index 5d271a1a..2c7e6f42 100644 --- a/lib/pages/pharmacies/screens/cart-order-preview.dart +++ b/lib/pages/pharmacies/screens/cart-order-preview.dart @@ -15,244 +15,253 @@ 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'; -class OrderPreviewPage extends StatelessWidget { +class OrderPreviewPage extends StatefulWidget { final List addresses; OrderPreviewPage(this.addresses); + @override + _OrderPreviewPageState createState() => _OrderPreviewPageState(); +} + +class _OrderPreviewPageState extends State { MyInAppBrowser browser; + @override + void initState() { + super.initState(); + Provider.of(context, listen: false).getShoppingCart(); + } @override Widget build(BuildContext context) { final mediaQuery = MediaQuery.of(context); final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; - - return BaseView( - onModelReady: (model) => model.getShoppingCart(), - builder: (_, model, wi) => ChangeNotifierProvider.value( - value: model.paymentCheckoutData, - child: AppScaffold( - appBarTitle: "${TranslationBase.of(context).checkOut}", - isShowAppBar: true, - isPharmacy: true, - isShowDecPage: false, - backgroundColor: Colors.white, - baseViewModel: model, - body: Container( - height: height * 0.90, - child: SingleChildScrollView( - child: Container( - color: Color(0xFFF1F1F1), - child: Column( - children: [ - SelectAddressWidget(model, addresses), - SizedBox( - height: 10, - ), - SelectPaymentOptionWidget(model), - SizedBox( - height: 10, - ), - Consumer( - builder: (ctx, paymentData, _) => - paymentData.lacumInformation != null - ? Container( - child: Column( - children: [ - LakumWidget(model), - SizedBox( - height: 10, - ), - ], - ), - ) - : Container()), - Container( - color: Colors.white, - width: double.infinity, - padding: EdgeInsets.all(8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - TranslationBase - .of(context) - .reviewOrder, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ...List.generate( - model.cartResponse.shoppingCarts != null - ? model.cartResponse.shoppingCarts.length - : 0, - (index) => - ProductOrderPreviewItem( - model.cartResponse - .shoppingCarts[index]), - ), - ], + OrderPreviewViewModel model = Provider.of(context); + return NetworkBaseView( + child: AppScaffold( + appBarTitle: "${TranslationBase.of(context).checkOut}", + isShowAppBar: true, + isPharmacy: true, + isShowDecPage: false, + backgroundColor: Colors.white, + baseViewModel: model, + body: Container( + height: height * 0.90, + child: SingleChildScrollView( + child: Container( + color: Color(0xFFF1F1F1), + child: Column( + children: [ + SelectAddressWidget(model,widget.addresses), + SizedBox( + height: 10, + ), + SelectPaymentOptionWidget(model), + SizedBox( + height: 10, + ), + Consumer( + builder: (ctx, paymentData, _) => + paymentData.lacumInformation != null + ? Container( + child: Column( + children: [ + LakumWidget(model), + SizedBox( + height: 10, ), - ), - Container( - width: double.infinity, - padding: EdgeInsets.all(8), - child: model.cartResponse.subtotal != null - ? Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Texts( - TranslationBase - .of(context) - .orderSummary, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - SizedBox( - height: 20, - ), - 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) - .shipping}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase - .of(context) - .sar} ${(model - .totalAdditionalShippingCharge) - .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.subtotal) - .toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - ], - ), - SizedBox( - height: 10, - ), - ], - ) - : Container(), - ) - ], - ), + ], + ), + ) + : Container()), + Container( + color: Colors.white, + width: double.infinity, + padding: EdgeInsets.all(8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + TranslationBase + .of(context) + .reviewOrder, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ...List.generate( + model.cartResponse.shoppingCarts != null + ? model.cartResponse.shoppingCarts.length + : 0, + (index) => + ProductOrderPreviewItem( + model.cartResponse + .shoppingCarts[index]), + ), + ], ), ), - ), - bottomSheet: Container( - height: model.cartResponse.shoppingCarts != null - ? height * 0.10 - : 0, - color: Colors.white, - child: PaymentBottomWidget(model), - ), + Container( + width: double.infinity, + padding: EdgeInsets.all(8), + child: model.cartResponse.subtotal != null + ? Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Texts( + TranslationBase + .of(context) + .orderSummary, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + SizedBox( + height: 20, + ), + 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) + .shipping}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase + .of(context) + .sar} ${(model + .totalAdditionalShippingCharge) + .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.subtotal) + .toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ], + ), + SizedBox( + height: 10, + ), + ], + ) + : Container(), + ) + ], ), - )); + ), + ), + ), + bottomSheet: Container( + height: model.cartResponse.shoppingCarts != null + ? height * 0.10 + : 0, + color: Colors.white, + child: PaymentBottomWidget(model), + ), + ), + baseViewModel: model, + ); } } diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index c158341d..c33af1b0 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/service/parmacyModule/order-preview-service.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BestSellerViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BrandViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/LastVisitedViewModel.dart'; @@ -35,6 +36,7 @@ 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 '../../../locator.dart'; import '../../final_products_page.dart'; class PharmacyPage extends StatefulWidget { @@ -50,6 +52,7 @@ class _PharmacyPageState extends State { onModelReady: (model) async { await model.getSavedLanguage(); await model.getBannerList(); + await locator().getShoppingCart(); }, allowAny: true, builder: (_, model, wi) => AppScaffold( diff --git a/lib/widgets/buttons/GestureIconButton.dart b/lib/widgets/buttons/GestureIconButton.dart index 329755f6..0f035b71 100644 --- a/lib/widgets/buttons/GestureIconButton.dart +++ b/lib/widgets/buttons/GestureIconButton.dart @@ -25,10 +25,17 @@ class _GestureIconButtonState extends State { @override Widget build(BuildContext context) { return GestureDetector( - onLongPressStart: (_) => - setState(() => _buttonLongPress = !_buttonLongPress), - onLongPressEnd: (_) => - setState(() => _buttonLongPress = !_buttonLongPress), + onTap: (){ + setState(() { + _buttonLongPress = !_buttonLongPress; + }); + widget.onTap(); + + }, + // onLongPressStart: (_) => + // setState(() => _buttonLongPress = !_buttonLongPress), + // onLongPressEnd: (_) => + // setState(() => _buttonLongPress = !_buttonLongPress), child: Container( decoration: BoxDecoration( border: Border.all( @@ -52,6 +59,8 @@ class _GestureIconButtonState extends State { ), Texts( widget.label, + fontWeight: FontWeight.bold, + fontSize: 13.6, color: _buttonLongPress ? Colors.white : Colors.black, ), ], diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart index 76a829cd..94e260d0 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart @@ -1,4 +1,7 @@ import 'package:diplomaticquarterapp/Constants.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCartResponse.dart'; +import 'package:diplomaticquarterapp/core/service/parmacyModule/order-preview-service.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/login/welcome.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; @@ -6,6 +9,8 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import '../../locator.dart'; + class BottomNavPharmacyItem extends StatelessWidget { final String title; final IconData icon; @@ -32,62 +37,81 @@ class BottomNavPharmacyItem extends StatelessWidget { return Expanded( child: SizedBox( // height: 72.0, - child: Material( - type: MaterialType.transparency, - child: InkWell( - highlightColor: Colors.transparent, - splashColor: Colors.transparent, - onTap: () { - if (!Provider.of(context, listen: false) + child: Stack( + clipBehavior: Clip.none, + children: [ + Material( + type: MaterialType.transparency, + child: InkWell( + highlightColor: Colors.transparent, + splashColor: Colors.transparent, + onTap: () { + if (!Provider.of(context, listen: false) .isLogin && - (currentIndex == 2 || currentIndex == 3)) - Navigator.push( - context, - FadePage(page: WelcomeLogin()), - ); - else - changeIndex(currentIndex); - }, - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - height: 15, - ), - currentIndex == index - ? Divider( - color: Color(0xff5AB145), - thickness: 3.5, - ) - : Divider( - thickness: 0, - ), - Container( - child: Icon(currentIndex == index ? activeIcon : icon, - color: isHome - ? Color(0xff5AB145) - : currentIndex == index + (currentIndex == 2 || currentIndex == 3)) + Navigator.push( + context, + FadePage(page: WelcomeLogin()), + ); + else + changeIndex(currentIndex); + }, + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + height: 15, + ), + currentIndex == index + ? Divider( + color: Color(0xff5AB145), + thickness: 3.5, + ) + : Divider( + thickness: 0, + ), + Container( + child: Icon(currentIndex == index ? activeIcon : icon, + color: isHome + ? Color(0xff5AB145) + : currentIndex == index ? Colors.grey : Colors.grey, - size: 22.0), - ), - SizedBox( - height: 11, - ), + size: 22.0), + ), + SizedBox( + height: 11, + ), - // Added TextAlign Property - Texts( - title, - textAlign: TextAlign.center, - color: currentIndex == index ? Colors.grey : Colors.grey, - fontWeight: + // Added TextAlign Property + Texts( + title, + textAlign: TextAlign.center, + color: currentIndex == index ? Colors.grey : Colors.grey, + fontWeight: currentIndex == index ? FontWeight.bold : FontWeight.w400, - fontSize: currentIndex == index ? 13 : 11, + fontSize: currentIndex == index ? 13 : 11, + ), + ], ), - ], + ), ), - ), + if(currentIndex == 3 &&Provider.of(context, listen: false).cartResponse.quantityCount !=0) + Positioned( + top: 5, right: -3.5, + child: Container( + decoration: BoxDecoration( + color: Colors.red, + 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,)), + ), + ) + ], ), ), ); From acdd19eeed08bc0040593615fbb22e9cd8dbaa83 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Thu, 7 Oct 2021 10:30:20 +0300 Subject: [PATCH 50/67] calling cart from pharmacy home and add provider to it --- lib/pages/login/login.dart | 4 ++-- lib/pages/pharmacies/screens/pharmacy_module_page.dart | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index 2fc2100c..ac41dab1 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -68,11 +68,11 @@ class _Login extends State { if(BASE_URL.contains("uat.")){ nationalIDorFile.text = "2001273"; mobileNumberController.text = mobileNo = "0555416043"; - } else { + }/* else { // TODO Mousa Sheeeloh nationalIDorFile.text = "3376044"; mobileNumberController.text = mobileNo = "0555416575"; - } + }*/ } getDeviceToken() async { diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 02a1a89a..7bf7b03b 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/core/service/parmacyModule/order-preview-se import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BestSellerViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BrandViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/LastVisitedViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PrescriptionViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; @@ -47,7 +48,7 @@ class PharmacyPage extends StatefulWidget { class _PharmacyPageState extends State { @override Widget build(BuildContext context) { - + OrderPreviewViewModel orderPreviewViewModel = Provider.of(context); return WillPopScope( onWillPop: ()async{ return false; @@ -56,7 +57,7 @@ class _PharmacyPageState extends State { onModelReady: (model) async { await model.getSavedLanguage(); await model.getBannerList(); - await locator().getShoppingCart(); + await orderPreviewViewModel.getShoppingCart(); }, allowAny: true, builder: (_, model, wi) => AppScaffold( From bfbd04e35de7bc61dcee284a6c12a7d3c78329da Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 7 Oct 2021 10:36:36 +0300 Subject: [PATCH 51/67] add count to cart --- .../shared/product_details_app_bar.dart | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) 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 367e0d35..3eb58852 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 @@ -1,9 +1,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/pharmacies/screens/product-details/product-detail.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:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; @@ -63,16 +65,34 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { if (authenticatedUserObject.isLogin) Row( children: [ - IconWithBg( - icon: Icons.shopping_cart, - color: Colors.grey[800], - onPress: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => CartOrderPage()), - ); - }), + Stack( + children: [ + IconWithBg( + icon: Icons.shopping_cart, + color: Colors.grey[800], + onPress: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => CartOrderPage()), + ); + }), + + if(Provider.of(context, listen: false).cartResponse.quantityCount !=0) + Positioned( + child: Container( + decoration: BoxDecoration( + color: Colors.red, + 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,)), + ), + ) + ], + ), SizedBox( width: 10, ), From 944bbce1bfa3b72efb630de6b4a5f9dfaa8ac11c Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 7 Oct 2021 10:37:25 +0300 Subject: [PATCH 52/67] add count to cart --- .../screens/product-details/shared/product_details_app_bar.dart | 1 + 1 file changed, 1 insertion(+) 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 3eb58852..8069d0ed 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 @@ -80,6 +80,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { if(Provider.of(context, listen: false).cartResponse.quantityCount !=0) Positioned( + top:0, right: -1.0, child: Container( decoration: BoxDecoration( color: Colors.red, From c1f3d3cc1c5f30a37e5a12d1e5246342f30cfa77 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Thu, 7 Oct 2021 11:43:12 +0300 Subject: [PATCH 53/67] fixes --- .../parmacyModule/order-preview-service.dart | 37 +- .../pharmacyModule/OrderPreviewViewModel.dart | 40 +- lib/pages/login/login.dart | 1 - .../pharmacies/screens/cart-order-page.dart | 20 +- .../screens/cart-order-preview.dart | 1087 ++++++++--------- .../screens/pharmacy_module_page.dart | 1 + lib/widgets/others/app_scaffold_widget.dart | 15 +- lib/widgets/others/network_base_view.dart | 12 +- 8 files changed, 605 insertions(+), 608 deletions(-) diff --git a/lib/core/service/parmacyModule/order-preview-service.dart b/lib/core/service/parmacyModule/order-preview-service.dart index 0ada84e7..0364d64f 100644 --- a/lib/core/service/parmacyModule/order-preview-service.dart +++ b/lib/core/service/parmacyModule/order-preview-service.dart @@ -62,6 +62,8 @@ class OrderPreviewService extends BaseService { Future getShoppingCart() async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); + if (customerId == null) return null; + Map queryParams = {'shopping_cart_type': '1'}; dynamic localRes; hasError = false; @@ -94,8 +96,8 @@ 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; @@ -112,8 +114,8 @@ 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; @@ -225,8 +227,9 @@ 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)); @@ -263,24 +266,22 @@ class OrderPreviewService extends BaseService { } } - Future getDriverLocation(dynamic driverId) async{ + Future getDriverLocation(dynamic driverId) async { Map jsonBody = Map(); jsonBody['DriverID'] = driverId; LatLng coordinates; await baseAppClient.post(DRIVER_LOCATION, onSuccess: (response, statusCode) async { - if(statusCode == 200){ - dynamic locationObject = response['PatientER_GetDriverLocationList'][0]; - double lat = locationObject['Latitude']; - double lon = locationObject['Longitude']; - if(lat != null && lon != null){ - coordinates = LatLng(lat,lon); - } - } - }, onFailure: (String error, int statusCode) { - - }, body: jsonBody); + if (statusCode == 200) { + dynamic locationObject = response['PatientER_GetDriverLocationList'][0]; + double lat = locationObject['Latitude']; + double lon = locationObject['Longitude']; + if (lat != null && lon != null) { + coordinates = LatLng(lat, lon); + } + } + }, onFailure: (String error, int statusCode) {}, body: jsonBody); return coordinates; } diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index 9bcfd490..801f6fb7 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -9,6 +9,8 @@ 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'; @@ -17,12 +19,14 @@ class OrderPreviewViewModel extends BaseViewModel { OrderPreviewService _orderService = locator(); List get addresses => _orderService.addresses; + LacumAccountInformation get lacumInformation => _orderService.lacumInformation; + List get orderListModel => _orderService.orderList; PharmacyModuleViewModel pharmacyModuleViewModel = - locator(); + locator(); ShoppingCartResponse cartResponse = ShoppingCartResponse(); PaymentCheckoutData paymentCheckoutData = PaymentCheckoutData(); @@ -38,24 +42,31 @@ class OrderPreviewViewModel extends BaseViewModel { getShoppingCart(); } } - + void update(){ + notifyListeners(); + } Future getShoppingCart() async { - setState(ViewState.Busy); + // setState(ViewState.Busy); + // GifLoaderDialogUtils.showMyDialog( + // locator().navigatorKey.currentContext); await _orderService.getShoppingCart().then((res) { - _handleGetShoppingCartResponse(res); + if (res != null) _handleGetShoppingCartResponse(res); }); if (_orderService.hasError) { error = _orderService.error; - setState(ViewState.Error); + // setState(ViewState.Error); } else { if (paymentCheckoutData != null) { paymentCheckoutData.cartDataVisible = true; } - setState(ViewState.Idle); + // GifLoaderDialogUtils.hideDialog( + // locator().navigatorKey.currentContext); + setState(ViewState.Idle); } } - 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); @@ -112,7 +123,8 @@ class OrderPreviewViewModel extends BaseViewModel { res["shopping_carts"].forEach((item) { ShoppingCart shoppingCart = ShoppingCart.fromJson(item); cartResponse.shoppingCarts.add(shoppingCart); - totalAdditionalShippingCharge += shoppingCart.product.additionalShippingCharge; + totalAdditionalShippingCharge += + shoppingCart.product.additionalShippingCharge; }); return cartResponse; } @@ -164,7 +176,8 @@ class OrderPreviewViewModel extends BaseViewModel { setState(ViewState.Busy); await _orderService.getLacumGroupInformation(); 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); @@ -175,8 +188,10 @@ class OrderPreviewViewModel extends BaseViewModel { getShippingOption() async { setState(ViewState.Busy); - await _orderService.getShippingOption(paymentCheckoutData.address).then((res) { - paymentCheckoutData.shippingOption = ShippingOption.fromJson(res); + await _orderService + .getShippingOption(paymentCheckoutData.address) + .then((res) { + paymentCheckoutData.shippingOption = ShippingOption.fromJson(res); paymentCheckoutData.updateData(); }); if (_orderService.hasError) { @@ -191,7 +206,8 @@ 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/pages/login/login.dart b/lib/pages/login/login.dart index ac41dab1..a77aaa1c 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -69,7 +69,6 @@ class _Login extends State { nationalIDorFile.text = "2001273"; mobileNumberController.text = mobileNo = "0555416043"; }/* else { - // TODO Mousa Sheeeloh nationalIDorFile.text = "3376044"; mobileNumberController.text = mobileNo = "0555416575"; }*/ diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index e53175b8..6f63927d 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -7,6 +7,7 @@ import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-preview.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy-terms-conditions-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderItem.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/GestureIconButton.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:http/http.dart'; import 'package:provider/provider.dart'; class CartOrderPage extends StatefulWidget { @@ -25,13 +27,14 @@ class CartOrderPage extends StatefulWidget { class _CartOrderPageState extends State { - + bool isLoading = true; @override void initState() { super.initState(); - Provider.of(context, listen: false).getShoppingCart(); + getData(); } + @override Widget build(BuildContext context) { final mediaQuery = MediaQuery.of(context); @@ -40,7 +43,9 @@ class _CartOrderPageState extends State { final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; AppScaffold appScaffold; return NetworkBaseView( - baseViewModel: model, + // baseViewModel: model, + isLoading: isLoading, + isLocalLoader: true, child: AppScaffold( appBarTitle: TranslationBase.of(context).shoppingCart, isShowAppBar: true, @@ -245,6 +250,15 @@ class _CartOrderPageState extends State { ), ); } + + void getData()async { + + await Provider.of(context, listen: false).getShoppingCart(); + setState(() { + isLoading= false; + }); + + } } class OrderBottomWidget extends StatefulWidget { diff --git a/lib/pages/pharmacies/screens/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-order-preview.dart index 2c7e6f42..f6e1d392 100644 --- a/lib/pages/pharmacies/screens/cart-order-preview.dart +++ b/lib/pages/pharmacies/screens/cart-order-preview.dart @@ -31,236 +31,213 @@ class OrderPreviewPage extends StatefulWidget { class _OrderPreviewPageState extends State { MyInAppBrowser browser; + bool isLoading = true; @override void initState() { super.initState(); - Provider.of(context, listen: false).getShoppingCart(); + getData(); } + + void getData() async { + if (isLoading) + await Provider.of(context, listen: false) + .getShoppingCart(); + setState(() { + isLoading = false; + }); + } + @override Widget build(BuildContext context) { + final mediaQuery = MediaQuery.of(context); final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; - OrderPreviewViewModel model = Provider.of(context); - return NetworkBaseView( - child: AppScaffold( - appBarTitle: "${TranslationBase.of(context).checkOut}", - isShowAppBar: true, - isPharmacy: true, - isShowDecPage: false, - backgroundColor: Colors.white, - baseViewModel: model, - body: Container( - height: height * 0.90, - child: SingleChildScrollView( - child: Container( - color: Color(0xFFF1F1F1), - child: Column( - children: [ - SelectAddressWidget(model,widget.addresses), - SizedBox( - height: 10, - ), - SelectPaymentOptionWidget(model), - SizedBox( - height: 10, - ), - Consumer( - builder: (ctx, paymentData, _) => - paymentData.lacumInformation != null - ? Container( - child: Column( - children: [ - LakumWidget(model), - SizedBox( - height: 10, - ), - ], - ), - ) - : Container()), - Container( - color: Colors.white, - width: double.infinity, - padding: EdgeInsets.all(8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - TranslationBase - .of(context) - .reviewOrder, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ...List.generate( - model.cartResponse.shoppingCarts != null - ? model.cartResponse.shoppingCarts.length - : 0, - (index) => - ProductOrderPreviewItem( - model.cartResponse - .shoppingCarts[index]), - ), - ], - ), + OrderPreviewViewModel model = Provider.of(context); + return AppScaffold( + appBarTitle: "${TranslationBase.of(context).checkOut}", + isShowAppBar: true, + isPharmacy: true, + isShowDecPage: false, + isLoading: isLoading, + isLocalLoader: true, + backgroundColor: Colors.white, + // baseViewModel: model, + body: Container( + color: Color(0xFFF1F1F1), + height: height * 0.90, + child: SingleChildScrollView( + child: Container( + color: Color(0xFFF1F1F1), + child: Column( + children: [ + SelectAddressWidget(model, widget.addresses), + SizedBox( + height: 10, + ), + SelectPaymentOptionWidget(model), + SizedBox( + height: 10, + ), + Consumer( + builder: (ctx, paymentData, _) => + paymentData.lacumInformation != null + ? Container( + child: Column( + children: [ + LakumWidget(model), + SizedBox( + height: 10, + ), + ], + ), + ) + : Container()), + Container( + color: Colors.white, + width: double.infinity, + padding: EdgeInsets.all(8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + TranslationBase.of(context).reviewOrder, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ...List.generate( + model.cartResponse.shoppingCarts != null + ? model.cartResponse.shoppingCarts.length + : 0, + (index) => ProductOrderPreviewItem( + model.cartResponse.shoppingCarts[index]), + ), + ], ), - Container( - width: double.infinity, - padding: EdgeInsets.all(8), - child: model.cartResponse.subtotal != null - ? Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Texts( - TranslationBase - .of(context) - .orderSummary, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - SizedBox( - height: 20, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + ), + Container( + width: double.infinity, + padding: EdgeInsets.all(8), + child: model.cartResponse.subtotal != null + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - "${TranslationBase - .of(context) - .subtotal}", + TranslationBase.of(context).orderSummary, fontSize: 14, + fontWeight: FontWeight.bold, color: Colors.black, - fontWeight: FontWeight.w500, ), - Texts( - "${TranslationBase - .of(context) - .sar} ${(model.cartResponse.subtotal) - .toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, + SizedBox( + height: 20, ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Texts( - "${TranslationBase - .of(context) - .shipping}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, + 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, + ), + ], ), - Texts( - "${TranslationBase - .of(context) - .sar} ${(model - .totalAdditionalShippingCharge) - .toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, ), - ], - ), - 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, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + "${TranslationBase.of(context).shipping}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.totalAdditionalShippingCharge).toStringAsFixed(2)}", + 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, ), - ], - ), - 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, + 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, + ), + ], ), - Texts( - "${TranslationBase - .of(context) - .sar} ${(model.cartResponse.subtotal) - .toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.bold, + 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.subtotal).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ], + ), + SizedBox( + height: 10, ), ], - ), - SizedBox( - height: 10, - ), - ], - ) - : Container(), - ) - ], - ), + ) + : Container(), + ) + ], ), ), ), - bottomSheet: Container( - height: model.cartResponse.shoppingCarts != null - ? height * 0.10 - : 0, - color: Colors.white, - child: PaymentBottomWidget(model), - ), ), - baseViewModel: model, + bottomSheet: Container( + height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, + color: Colors.white, + child: PaymentBottomWidget(model), + ), ); } } @@ -308,172 +285,161 @@ class _SelectAddressWidgetState extends State { @override Widget build(BuildContext context) { return Consumer( - builder: (ctx, paymentData, _) => - Container( - color: Colors.white, - child: address == null - ? InkWell( - onTap: () => {_navigateToAddressPage()}, - child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_address.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Expanded( - child: Container( - padding: - EdgeInsets.symmetric(vertical: 0, horizontal: 6), - child: Texts( - TranslationBase - .of(context) - .selectAddress, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff0000ff), - ), + builder: (ctx, paymentData, _) => Container( + color: Colors.white, + child: address == null + ? InkWell( + onTap: () => {_navigateToAddressPage()}, + child: Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_address.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, ), - ), - Icon( - Icons.arrow_forward_ios, - size: 20, - color: Colors.grey.shade400, - ), - ], - ), - ), - ) - : Container( - child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_mark.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Expanded( - child: Container( - padding: EdgeInsets.symmetric( - vertical: 0, horizontal: 6), - child: Texts( - TranslationBase - .of(context) - .shippingAddress, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - ), - InkWell( - onTap: () => {_navigateToAddressPage()}, + Expanded( + child: Container( + padding: + EdgeInsets.symmetric(vertical: 0, horizontal: 6), child: Texts( - TranslationBase - .of(context) - .changeAddress, - fontSize: 12, - fontWeight: FontWeight.normal, + TranslationBase.of(context).selectAddress, + fontSize: 14, + fontWeight: FontWeight.bold, color: Color(0xff0000ff), ), ), - ], - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Texts( - "${address.firstName} ${address.lastName}", - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, ), - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Texts( - "${address.address1} ${address.address2} ${address - .address2},, ${address.city}, ${address - .country} ${address.zipPostalCode}", - fontSize: 12, - fontWeight: FontWeight.normal, - color: Colors.grey.shade500, + Icon( + Icons.arrow_forward_ios, + size: 20, + color: Colors.grey.shade400, ), - ), - Row( - children: [ - Container( - margin: const EdgeInsets.only(right: 8), - child: Icon( - Icons.phone, - size: 20, - color: Colors.black, + ], + ), + ), + ) + : Container( + child: Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_mark.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, ), - ), - Texts( - "${address.phoneNumber}", + Expanded( + child: Container( + padding: EdgeInsets.symmetric( + vertical: 0, horizontal: 6), + child: Texts( + TranslationBase.of(context).shippingAddress, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + ), + InkWell( + onTap: () => {_navigateToAddressPage()}, + child: Texts( + TranslationBase.of(context).changeAddress, + fontSize: 12, + fontWeight: FontWeight.normal, + color: Color(0xff0000ff), + ), + ), + ], + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Texts( + "${address.firstName} ${address.lastName}", fontSize: 14, fontWeight: FontWeight.bold, - color: Colors.grey, - ), - ], - ), - Container( - margin: EdgeInsets.symmetric(vertical: 8), - child: SizedBox( - height: 2, - width: double.infinity, - child: Container( - color: Color(0xffefefef), + color: Colors.black, ), ), - ), - Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_truck.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Texts( + "${address.address1} ${address.address2} ${address.address2},, ${address.city}, ${address.country} ${address.zipPostalCode}", + fontSize: 12, + fontWeight: FontWeight.normal, + color: Colors.grey.shade500, ), - Container( - padding: EdgeInsets.symmetric( - vertical: 0, horizontal: 6), - child: Texts( - "${TranslationBase - .of(context) - .shipBy}", - fontSize: 12, + ), + Row( + children: [ + Container( + margin: const EdgeInsets.only(right: 8), + child: Icon( + Icons.phone, + size: 20, + color: Colors.black, + ), + ), + Texts( + "${address.phoneNumber}", + fontSize: 14, fontWeight: FontWeight.bold, - color: Colors.black, + color: Colors.grey, ), - ), - Container( - child: Image.asset( - paymentData.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, + ], + ), + Container( + margin: EdgeInsets.symmetric(vertical: 8), + child: SizedBox( + height: 2, + width: double.infinity, + child: Container( + color: Color(0xffefefef), ), - margin: EdgeInsets.symmetric(horizontal: 8), ), - ], - ), - ], + ), + Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_truck.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Container( + padding: EdgeInsets.symmetric( + vertical: 0, horizontal: 6), + child: Texts( + "${TranslationBase.of(context).shipBy}", + fontSize: 12, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + Container( + child: Image.asset( + paymentData.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, + ), + margin: EdgeInsets.symmetric(horizontal: 8), + ), + ], + ), + ], + ), ), - ), - ), // ic_shipping_mark.png - ), + ), // ic_shipping_mark.png + ), ); } } @@ -493,17 +459,16 @@ class _SelectPaymentOptionWidgetState extends State { _navigateToPaymentOption() { Navigator.push(context, FadePage(page: PaymentMethodSelectPage())) - .then((result) => - { - setState(() { - if (result != null) { - paymentOption = result; - widget.model.paymentCheckoutData.paymentOption = - paymentOption; - widget.model.paymentCheckoutData.updateData(); - } - }) - }); + .then((result) => { + setState(() { + if (result != null) { + paymentOption = result; + widget.model.paymentCheckoutData.paymentOption = + paymentOption; + widget.model.paymentCheckoutData.updateData(); + } + }) + }); } @override @@ -520,89 +485,85 @@ class _SelectPaymentOptionWidgetState extends State { color: Colors.white, child: paymentOption == null ? InkWell( - onTap: () => {_navigateToPaymentOption()}, - child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_payment_option.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Expanded( - child: Container( - padding: - EdgeInsets.symmetric(vertical: 0, horizontal: 6), - child: Texts( - TranslationBase - .of(context) - .selectPaymentOption, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff0000ff), - ), - ), - ), - Icon( - Icons.arrow_forward_ios, - size: 20, - color: Colors.grey.shade400, - ), - ], - ), - ), - ) - : Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_payment_option.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Container( - margin: EdgeInsets.symmetric(horizontal: 8), - padding: EdgeInsets.symmetric(horizontal: 4, vertical: 0), - decoration: new BoxDecoration( - color: Colors.grey.shade100, - shape: BoxShape.rectangle, - ), - child: Image.asset( - widget.model.getPaymentOptionImage(paymentOption), - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - ), - Expanded( + onTap: () => {_navigateToPaymentOption()}, child: Container( - padding: EdgeInsets.symmetric(vertical: 0, horizontal: 6), - child: Texts( - widget.model.getPaymentOptionName(paymentOption), - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_payment_option.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Expanded( + child: Container( + padding: + EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + TranslationBase.of(context).selectPaymentOption, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff0000ff), + ), + ), + ), + Icon( + Icons.arrow_forward_ios, + size: 20, + color: Colors.grey.shade400, + ), + ], ), ), - ), - InkWell( - onTap: () => {_navigateToPaymentOption()}, - child: Texts( - TranslationBase - .of(context) - .changeMethod, - fontSize: 12, - fontWeight: FontWeight.normal, - color: Color(0xff0000ff), + ) + : Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_payment_option.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Container( + margin: EdgeInsets.symmetric(horizontal: 8), + padding: EdgeInsets.symmetric(horizontal: 4, vertical: 0), + decoration: new BoxDecoration( + color: Colors.grey.shade100, + shape: BoxShape.rectangle, + ), + child: Image.asset( + widget.model.getPaymentOptionImage(paymentOption), + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + ), + Expanded( + child: Container( + padding: EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + widget.model.getPaymentOptionName(paymentOption), + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + ), + InkWell( + onTap: () => {_navigateToPaymentOption()}, + child: Texts( + TranslationBase.of(context).changeMethod, + fontSize: 12, + fontWeight: FontWeight.normal, + color: Color(0xff0000ff), + ), + ), + ], ), ), - ], - ), - ), ); } } @@ -640,15 +601,12 @@ class _LakumWidgetState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - "${TranslationBase - .of(context) - .lakumPoints}", + "${TranslationBase.of(context).lakumPoints}", fontSize: 12, fontWeight: FontWeight.bold, ), Texts( - "${widget.model.paymentCheckoutData.lacumInformation - .lakumInquiryInformationObjVersion.pointsBalanceAmount}", + "${widget.model.paymentCheckoutData.lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount}", fontSize: 12, fontWeight: FontWeight.normal, ), @@ -663,9 +621,7 @@ class _LakumWidgetState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ Texts( - "${TranslationBase - .of(context) - .riyal}", + "${TranslationBase.of(context).riyal}", fontSize: 12, fontWeight: FontWeight.bold, ), @@ -679,19 +635,19 @@ class _LakumWidgetState extends State { decoration: InputDecoration( border: OutlineInputBorder( borderSide: - BorderSide(color: Colors.black, width: 0.2), + BorderSide(color: Colors.black, width: 0.2), gapPadding: 0, borderRadius: projectProvider.isArabic ? BorderRadius.only( - topRight: Radius.circular(8), - bottomRight: Radius.circular(8)) + topRight: Radius.circular(8), + bottomRight: Radius.circular(8)) : BorderRadius.only( - topLeft: Radius.circular(8), - bottomLeft: Radius.circular(8)), + topLeft: Radius.circular(8), + bottomLeft: Radius.circular(8)), ), disabledBorder: OutlineInputBorder( borderSide: - BorderSide(color: Colors.black, width: 0.4), + BorderSide(color: Colors.black, width: 0.4), gapPadding: 0, borderRadius: BorderRadius.only( topLeft: Radius.circular(8), @@ -703,22 +659,22 @@ class _LakumWidgetState extends State { style: TextStyle( fontSize: 14, color: widget - .model - .paymentCheckoutData - .lacumInformation - .lakumInquiryInformationObjVersion - .pointsBalanceAmount > - 0 + .model + .paymentCheckoutData + .lacumInformation + .lakumInquiryInformationObjVersion + .pointsBalanceAmount > + 0 ? Colors.black : Colors.grey, ), enabled: widget - .model - .paymentCheckoutData - .lacumInformation - .lakumInquiryInformationObjVersion - .pointsBalanceAmount == - 0 + .model + .paymentCheckoutData + .lacumInformation + .lakumInquiryInformationObjVersion + .pointsBalanceAmount == + 0 ? false : true, onChanged: (val) { @@ -737,7 +693,7 @@ class _LakumWidgetState extends State { widget.model.paymentCheckoutData.usedLakumPoints = 0; } _pointsController.text = - "${widget.model.paymentCheckoutData.usedLakumPoints}"; + "${widget.model.paymentCheckoutData.usedLakumPoints}"; }, ), ), @@ -749,20 +705,18 @@ class _LakumWidgetState extends State { shape: BoxShape.rectangle, borderRadius: projectProvider.isArabic ? BorderRadius.only( - topLeft: Radius.circular(6), - bottomLeft: Radius.circular(6)) + topLeft: Radius.circular(6), + bottomLeft: Radius.circular(6)) : BorderRadius.only( - topRight: Radius.circular(6), - bottomRight: Radius.circular(6)), + topRight: Radius.circular(6), + bottomRight: Radius.circular(6)), border: Border.fromBorderSide(BorderSide( color: Color(0xff3666E0), width: 0.8, )), ), child: Texts( - "${TranslationBase - .of(context) - .use}", + "${TranslationBase.of(context).use}", fontSize: 12, color: Colors.white, fontWeight: FontWeight.bold, @@ -794,114 +748,108 @@ class PaymentBottomWidget extends StatelessWidget { return Container( margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0), child: Consumer( - builder: (ctx, paymentData, _) => - paymentData.cartDataVisible + builder: (ctx, paymentData, _) => paymentData.cartDataVisible ? Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container( - margin: - EdgeInsets.symmetric(horizontal: 0, vertical: 4), - child: Row( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ + Container( + margin: + EdgeInsets.symmetric(horizontal: 0, vertical: 4), + child: Row( + children: [ + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff929295), + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4), + child: Texts( + "${TranslationBase.of(context).inclusiveVat}", + fontSize: 8, + color: Color(0xff929295), + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), Texts( - "${TranslationBase - .of(context) - .sar} ${(model.cartResponse.subtotal) - .toStringAsFixed(2)}", - fontSize: 14, + "${model.cartResponse.quantityCount} ${TranslationBase.of(context).items}", + fontSize: 10, + color: Colors.grey, fontWeight: FontWeight.bold, - color: Color(0xff929295), ), - Padding( - padding: - const EdgeInsets.symmetric(horizontal: 4), - child: Texts( - "${TranslationBase - .of(context) - .inclusiveVat}", - fontSize: 8, + ], + ), + Container( + child: RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + side: BorderSide( color: Color(0xff929295), - fontWeight: FontWeight.w600, + width: 1, ), ), - ], - ), - ), - Texts( - "${model.cartResponse.quantityCount} ${TranslationBase - .of(context) - .items}", - fontSize: 10, - color: Colors.grey, - fontWeight: FontWeight.bold, - ), - ], - ), - Container( - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - side: BorderSide( - color: Color(0xff929295), - width: 1, - ), - ), - onPressed: (paymentData.address != null && - paymentData.paymentOption != null) - ? () async { - await model.makeOrder(); - if (model.state == ViewState.Idle) { - AppToast.showSuccessToast( - message: "Order has been placed successfully!!"); - openPayment(model.orderListModel[0], model.user); - } else { - AppToast.showErrorToast(message: model.error); - } - Navigator.pop(context); - Navigator.pop(context); - } - : null, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 16), - child: new Text( - "${TranslationBase - .of(context) - .proceedPay}", - style: new TextStyle( - color: (paymentData.address != null && - paymentData.paymentOption != null) - ? Colors.white - : Colors.grey.shade400, - fontWeight: FontWeight.bold, - fontSize: 12), + onPressed: (paymentData.address != null && + paymentData.paymentOption != null) + ? () async { + await model.makeOrder(); + if (model.state == ViewState.Idle) { + AppToast.showSuccessToast( + message: + "Order has been placed successfully!!"); + openPayment( + model.orderListModel[0], model.user); + } else { + AppToast.showErrorToast(message: model.error); + } + Navigator.pop(context); + Navigator.pop(context); + } + : null, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 16), + child: new Text( + "${TranslationBase.of(context).proceedPay}", + style: new TextStyle( + color: (paymentData.address != null && + paymentData.paymentOption != null) + ? Colors.white + : Colors.grey.shade400, + fontWeight: FontWeight.bold, + fontSize: 12), + ), + ), + color: (paymentData.address != null && + paymentData.paymentOption != null) + ? Colors.green + : Color(0xff929295), + disabledColor: (paymentData.address != null && + paymentData.paymentOption != null) + ? Colors.green + : Color(0xff929295), + ), ), - ), - color: (paymentData.address != null && - paymentData.paymentOption != null) - ? Colors.green - : Color(0xff929295), - disabledColor: (paymentData.address != null && - paymentData.paymentOption != null) - ? Colors.green - : Color(0xff929295), + ], ), - ), - ], - ), - ) + ) : Container(), ), ); } - openPayment(OrderDetailModel order, - AuthenticatedUser authenticatedUser,) { + openPayment( + OrderDetailModel order, + AuthenticatedUser authenticatedUser, + ) { browser = new MyInAppBrowser( onExitCallback: onBrowserExit, onLoadStartCallback: onBrowserLoadStart); @@ -912,8 +860,7 @@ class PaymentBottomWidget extends StatelessWidget { order.id, order.billingAddress.email, order.customValuesXml, - "${authenticatedUser.firstName} ${authenticatedUser - .middleName} ${authenticatedUser.lastName}", + "${authenticatedUser.firstName} ${authenticatedUser.middleName} ${authenticatedUser.lastName}", authenticatedUser.patientID, authenticatedUser, browser); @@ -950,7 +897,7 @@ class PaymentBottomWidget extends StatelessWidget { } else { AppToast.showErrorToast( message: - "Transaction Failed!\Your transaction is field to some reason please try again or contact to the administration"); + "Transaction Failed!\Your transaction is field to some reason please try again or contact to the administration"); } } } diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 7bf7b03b..2e71a0c3 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -57,6 +57,7 @@ class _PharmacyPageState extends State { onModelReady: (model) async { await model.getSavedLanguage(); await model.getBannerList(); + if(model.isLogin) await orderPreviewViewModel.getShoppingCart(); }, allowAny: true, diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 93bccbd2..b3cc63d7 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -58,6 +58,7 @@ class AppScaffold extends StatelessWidget { final List appBarIcons; final List imagesInfo; final bool isHelp; + final bool isLocalLoader; AuthenticatedUserObject authenticatedUserObject = locator(); @@ -89,7 +90,7 @@ class AppScaffold extends StatelessWidget { this.showHomeAppBarIcon = true, this.imagesInfo, appBar, - this.customAppBar}); + this.customAppBar, this.isLocalLoader= false}); AppScaffold setOnAppBarCartClick(VoidCallback onClick) { _onCartClick = onClick; @@ -146,7 +147,17 @@ class AppScaffold extends StatelessWidget { buildBodyWidget(context) { return Stack( - children: [body, isHelp == true ? RobotIcon() : Container()]); + children: [ + Center( + child:isLoading? CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ):body), + + + isHelp == true ? RobotIcon() : Container()]); } } diff --git a/lib/widgets/others/network_base_view.dart b/lib/widgets/others/network_base_view.dart index 10b4da12..4ce75527 100644 --- a/lib/widgets/others/network_base_view.dart +++ b/lib/widgets/others/network_base_view.dart @@ -10,8 +10,9 @@ class NetworkBaseView extends StatefulWidget { final BaseViewModel baseViewModel; final Widget child; final bool isLocalLoader; + final bool isLoading; - NetworkBaseView({Key key, this.baseViewModel, this.child, this.isLocalLoader = false}); + NetworkBaseView({Key key, this.baseViewModel, this.child, this.isLocalLoader = false, this.isLoading}); @override _NetworkBaseViewState createState() => _NetworkBaseViewState(); @@ -31,7 +32,14 @@ class _NetworkBaseViewState extends State{ @override Widget build(BuildContext context) { return Container( - child: buildBaseViewWidget(), + child: (widget.baseViewModel!=null ) ?buildBaseViewWidget():Center( + child:widget.isLoading? CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ):widget.child, + ) , ); } From 74929f76e56505525a652cd4b0294342ae342d06 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Thu, 7 Oct 2021 12:37:16 +0300 Subject: [PATCH 54/67] edit home page --- .../screens/pharmacy_module_page.dart | 291 +----------------- 1 file changed, 1 insertion(+), 290 deletions(-) diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 9b91b77a..0842f5e5 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -63,9 +63,6 @@ class _PharmacyPageState extends State { String id = ""; @override void initState() { - checkWishlist(); - // userInfo(widget.product.id, widget.product); - userInfo(id, product); getLanguageID(); } @@ -333,238 +330,7 @@ class _PharmacyPageState extends State { : Container(), ), ), -// Container( -// margin: EdgeInsets.fromLTRB(10, 10, 10, 10), -// child: Row( -// mainAxisAlignment: MainAxisAlignment.spaceBetween, -// children: [ -// Texts( -// TranslationBase.of(context).recommended, -// bold: true, -// ), -// BorderedButton( -// TranslationBase.of(context).viewAll, -// hasBorder: true, -// borderColor: Colors.green, -// textColor: Colors.green, -// vPadding: 6, -// hPadding: 4, -// handler: () { -// Navigator.push( -// context, -// MaterialPageRoute( -// builder: (context) => -// RecommendedProductPage(productId : "2316"))); -// }, -// ), -// ], -// ), -// ), -// Container( -// height: model.recommendedProductList.length > 0 -// ? MediaQuery.of(context).size.height * 0.32 -// : 0, -// margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4), -//// padding: EdgeInsets.symmetric(horizontal: 5.0, vertical: 22.0), -//// margin: EdgeInsets.only(left: 10), -// child: BaseView( -// onModelReady: (model) => -// model.getRecommendedProducts(productId), -// builder: (_, model, wi) => model -// .recommendedProductList.length != -// null -// ? ListView.builder( -// scrollDirection: Axis.horizontal, -// shrinkWrap: true, -// physics: ScrollPhysics(), -// // physics: NeverScrollableScrollPhysics(), -// itemCount: model.recommendedProductList.length, -// itemBuilder: (context, index) { -// return Card( -// elevation: 2, -// shape: RoundedRectangleBorder( -// side: BorderSide( -// color: Colors.grey[300], width: 2), -// borderRadius: BorderRadius.circular(10)), -// margin: EdgeInsets.symmetric( -// horizontal: 8, -// vertical: 0, -// ), -// child: Container( -// decoration: BoxDecoration( -// borderRadius: BorderRadius.all( -// Radius.circular(15), -// ), -// ), -// padding: EdgeInsets.symmetric(horizontal: 4), -// width: MediaQuery.of(context).size.width / 3, -// child: Column( -// crossAxisAlignment: -// CrossAxisAlignment.start, -// children: [ -// Stack(children: [ -// Container( -// child: Align( -// alignment: Alignment.topRight, -// child: //true -// itemID.contains(model.recommendedProductList[index].id) -// // !isInWishlist -// ? IconButton( -// icon: Icon(Icons -// .favorite_border), -// color: Colors.grey, -// iconSize: 30, -// onPressed: () { -// setState(() { -// addToWishlistFunction( -// itemID); -// }); -// }, -// ) -// : IconButton( -// icon: Icon( -// Icons.favorite), -// color: Colors.red, -// iconSize: 30, -// onPressed: () { -// setState(() { -// deleteFromWishlistFunction( -// itemID); -// }); -// }, -// ) -//// -// ), -// ), -// Container( -// margin: EdgeInsets.fromLTRB( -// 0, 16, 10, 16), -// alignment: Alignment.center, -//// padding: EdgeInsets.only(left: 25, bottom: 20), -// child: (model.recommendedProductList[index].images != null && -// model.recommendedProductList[index].images.length > 0) -// ? Image.network( -// model.recommendedProductList[index].images[0].src.toString(), -//// item.images[0].src, -// fit: BoxFit.cover, -// height: 60, -// ) -// : Image.asset( -// "assets/images/no_image.png", -// fit: BoxFit.cover, -// height: 60, -// ), -// ), -// Container( -// width: model -// .recommendedProductList[ -// 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.recommendedProductList[index] -// .rxMessage != -// null -// ? model -// .recommendedProductList[ -// 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: [ -// Text( -// languageID == "ar" -// ? model.recommendedProductList[index].namen -// : model.recommendedProductList[index].name, -// style: TextStyle( -// color: Colors.black, -// fontSize: 13.0, -//// fontWeight: FontWeight.bold, -// ), -// ), -// Padding( -//// padding: const EdgeInsets.only(top: 15, bottom: 10), -// padding: const EdgeInsets.only( -// top: 10, bottom: 5), -// child: Texts( -// "SAR ${model.recommendedProductList[index].price}", -// bold: true, -// fontSize: 14, -// ), -// ), -// ], -// ), -// ), -// Row( -// crossAxisAlignment: -// CrossAxisAlignment.start, -// children: [ -// Container( -// padding: -// EdgeInsets.only(right: 10), -//// margin: EdgeInsets.only(left: 5), -// child: Align( -// alignment: Alignment.topLeft, -// child: RatingBar.readOnly( -// initialRating: model -// .recommendedProductList[ -// index] -// .approvedRatingSum -// .toDouble(), -//// initialRating: productRate, -// size: 13.0, -// filledColor: -// Colors.yellow[700], -// emptyColor: Colors.grey[500], -// isHalfAllowed: true, -// halfFilledIcon: -// Icons.star_half, -// filledIcon: Icons.star, -// emptyIcon: Icons.star, -// ), -// ), -// ), -// Texts( -// "(${model.recommendedProductList[index].approvedTotalReviews.toString()})", -//// bold: true, -// fontSize: 12, -// ), -// ]), -// ], -// ), -// ), -// ); -// }) -// : Container( -//// child: Text("NO DATA"), -// ), -// ), -// ), + Container( margin: EdgeInsets.fromLTRB(10, 10, 10, 0), child: Row( @@ -688,48 +454,6 @@ class _PharmacyPageState extends State { ); } - addToWishlistFunction(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - isInWishlist = true; - await x.addToWishlistData(itemID); - } - - deleteFromWishlistFunction(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - isInWishlist = false; - await x.addToWishlistData(itemID); - } - - checkWishlist() async { - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.checkWishlistData(); - for (int i = 0; i < x.wishListItems.length; i++) { - // itemID = x.wishListItems[i].id; - print("-------------wishlist---------------"); - print(itemID); -// print(product.id); - print(x.wishListItems[i].productId); - if (itemID == x.wishListItems[i].productId) { - isInWishlist = true; -// print('in wishlist'); - break; - } else { - isInWishlist = false; -// print('not in wishlist'); - } - } - } - - Future userInfo(id, product) async { - customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); - if (customerId != null) { - itemID = id; - product = product; - checkWishlist(); - } - print("customerId:$customerId"); - return customerId; - } } class GridViewButtons extends StatelessWidget { @@ -887,17 +611,4 @@ class _testState extends State { return Container(); } } -//addWishlistData() async { -// ProductDetailViewModel x = new ProductDetailViewModel(); -// await wishlistData.add(x.checkWishlistData()); -// print("-------------testWishlist---------------"); -// -//} -// checkWishlist() async { -// ProductDetailViewModel x = new ProductDetailViewModel(); -// wishlistVar = await x.checkWishlistData(); -// print("wishlistVar>>>>>>>>>>>>>>>"); -// print(wishlistVar); -// -// } From 8fac62bcb103201c1e4bb79c7bef59d65a04df9e Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 7 Oct 2021 14:42:01 +0300 Subject: [PATCH 55/67] fix bottom sheet functions --- .../product_detail_view_model.dart | 4 +- .../product-details/footor/footer-widget.dart | 80 ++++++++++--------- .../product-details/product-detail.dart | 22 ++--- .../shared/product_details_app_bar.dart | 7 +- lib/widgets/buttons/secondary_button.dart | 14 ++-- 5 files changed, 70 insertions(+), 57 deletions(-) diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index 968fe029..014ba7fb 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -49,7 +49,7 @@ class ProductDetailViewModel extends BaseViewModel{ Future notifyMe(customerId, itemID) async { hasError = false; - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _productDetailService.notifyMe(customerId, itemID); if (_productDetailService.hasError) { error = _productDetailService.error; @@ -60,7 +60,7 @@ class ProductDetailViewModel extends BaseViewModel{ Future addToCartData(quantity, itemID) async { hasError = false; - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _productDetailService.addToCart(quantity, itemID); if (_productDetailService.hasError) { error = _productDetailService.error; 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 854f5d4c..583c904f 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/footor/quantity_box.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; @@ -10,6 +11,7 @@ import 'package:hexcolor/hexcolor.dart'; import '../../../../../locator.dart'; import '../../../../../routes.dart'; import '../../cart-order-page.dart'; +import '../product-detail.dart'; class FooterWidget extends StatefulWidget { final bool isAvailable; @@ -18,13 +20,17 @@ class FooterWidget extends StatefulWidget { final int quantityLimit; final PharmacyProduct item; final Function addToCartFunction; + final ProductDetailViewModel model; int quantity; bool isOverQuantity; FooterWidget(this.isAvailable, this.maxQuantity, this.minQuantity, this.quantityLimit, this.item, - {this.quantity, this.isOverQuantity = false, this.addToCartFunction}); + {this.quantity, + this.isOverQuantity = false, + this.addToCartFunction, + this.model}); @override _FooterWidgetState createState() => _FooterWidgetState(); @@ -98,38 +104,31 @@ class _FooterWidgetState extends State { label: i, onTapFunc: onChangeValue, isSelected: widget.quantity == i), - Column( - children: [ - Container( - width: 100, - decoration: BoxDecoration( - border: - Border.all(color: Colors.grey[300]), - color: Colors.white, - ), - child: TextField( - decoration: InputDecoration( - labelText: 'quantity #'), - onChanged: (text) { - print(widget.quantity); - print(widget.quantityLimit); - if (int.tryParse(text) == null) { - text = ''; + Container( + width: 100, + decoration: BoxDecoration( + border: Border.all(color: Colors.grey[300]), + color: Colors.white, + ), + child: TextField( + decoration: InputDecoration( + labelText: ' Quantity # '), + onChanged: (text) { + if (int.tryParse(text) == null) { + text = ''; + } else { + setState(() { + widget.quantity = int.parse(text); + if (widget.quantity >= + widget.quantityLimit) { + widget.isOverQuantity = true; } else { - setState(() { - widget.quantity = int.parse(text); - if (widget.quantity >= - widget.quantityLimit) { - widget.isOverQuantity = true; - } else { - widget.isOverQuantity = false; - } - }); + widget.isOverQuantity = false; } - }, - ), - ), - ], + }); + } + }, + ), ), ], ), @@ -175,7 +174,7 @@ class _FooterWidgetState extends State { quantityUI = 80; showUI = false; } else { - quantityUI = 150; + quantityUI = 160; showUI = true; } }); @@ -197,10 +196,13 @@ class _FooterWidgetState extends State { ); } else await widget.addToCartFunction( - widget.quantity, widget.item.id, context); + quantity: widget.quantity, + itemID: widget.item.id, + model: widget.model); }, + fontWeight: FontWeight.w600, borderColor: Color(0xFF4CAF50), - borderRadius: 5, + borderRadius: 3, color: Color(0xFF4CAF50), ), ), @@ -215,14 +217,18 @@ class _FooterWidgetState extends State { widget.quantity > widget.quantityLimit || widget.item.rxMessage != null, onTap: () async { - await widget.addToCartFunction( - widget.quantity, widget.item.id, context); + await widget.addToCartFunction( + quantity: widget.quantity, + itemID: widget.item.id, + model: widget.model); Navigator.push( context, FadePage(page: CartOrderPage()), ); }, - borderRadius: 5, + fontWeight: FontWeight.w600, + borderColor: Colors.grey[800], + borderRadius: 3, disableColor: Colors.grey[700], color: !widget.isAvailable && widget.quantity > 0 || widget.quantity > widget.quantityLimit || diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 6ac5ec25..db43e6da 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -103,7 +103,8 @@ class __ProductDetailPageState extends State { deleteFromWishlistFunction: () async { await deleteFromWishlistFunction(itemID: itemID, model: model); }, - isInWishList:isInWishList + isInWishList:isInWishList, + addToCartFunction:addToCartFunction , ), body: SingleChildScrollView( child: Column( @@ -323,6 +324,7 @@ class __ProductDetailPageState extends State { quantity: quantity, isOverQuantity: isOverQuantity, addToCartFunction: addToCartFunction, + model: model, ), )); } @@ -338,17 +340,17 @@ class __ProductDetailPageState extends State { await model.deleteWishlistData(itemID); setState(() {}); } + addToCartFunction( + {quantity, + itemID, + ProductDetailViewModel model}) async { + GifLoaderDialogUtils.showMyDialog(context); + await model.addToCartData(quantity, itemID); + GifLoaderDialogUtils.hideDialog(context); + } } -addToCartFunction( - {quantity, - itemID, - BuildContext context, - ProductDetailViewModel model}) async { - GifLoaderDialogUtils.showMyDialog(context); - await model.addToCartData(quantity, itemID); - GifLoaderDialogUtils.hideDialog(context); -} + notifyMeWhenAvailable( {itemId, customerId, 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 8069d0ed..ee1bcd60 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 @@ -23,6 +23,8 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { final Function deleteFromWishlistFunction; final int quantity; final bool isInWishList; + final Function addToCartFunction; + ProductAppBar( {Key key, @@ -31,7 +33,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { this.addToWishlistFunction, this.quantity, this.deleteFromWishlistFunction, - this.isInWishList}) + this.isInWishList, this.addToCartFunction}) : super(key: key); AuthenticatedUserObject authenticatedUserObject = @@ -83,7 +85,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { top:0, right: -1.0, child: Container( decoration: BoxDecoration( - color: Colors.red, + color: Colors.red[800], borderRadius: BorderRadius.circular(15), ), @@ -136,7 +138,6 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { await addToCartFunction( quantity: quantity, itemID: itemID, - context: context, model: model); Navigator.of(context).pop(); diff --git a/lib/widgets/buttons/secondary_button.dart b/lib/widgets/buttons/secondary_button.dart index 4b2f23a9..4ada4d86 100644 --- a/lib/widgets/buttons/secondary_button.dart +++ b/lib/widgets/buttons/secondary_button.dart @@ -29,7 +29,10 @@ class SecondaryButton extends StatefulWidget { this.small = false, this.disabled = false, this.borderColor, - this.noBorderRadius = false, this.borderRadius, this.disableColor}) + this.noBorderRadius = false, + this.borderRadius, + this.disableColor, + this.fontWeight}) : super(key: key); final String label; @@ -45,7 +48,7 @@ class SecondaryButton extends StatefulWidget { final bool noBorderRadius; final double borderRadius; final Color disableColor; - + final FontWeight fontWeight; @override @@ -173,7 +176,8 @@ class _SecondaryButtonState extends State child: ClipRRect( borderRadius: widget.noBorderRadius ? BorderRadius.all(Radius.circular(0.0)) - : BorderRadius.all(Radius.circular(widget.borderRadius??10.0)), + : BorderRadius.all( + Radius.circular(widget.borderRadius ?? 10.0), ), child: Stack( children: [ Positioned( @@ -184,7 +188,7 @@ class _SecondaryButtonState extends State height: 100, decoration: BoxDecoration( color: widget.disabled - ? widget.disableColor??Colors.grey + ? widget.disableColor ?? Colors.grey : widget.color ?? Theme.of(context).buttonColor), ), ), @@ -246,7 +250,7 @@ class _SecondaryButtonState extends State style: TextStyle( color: widget.textColor, fontSize: widget.small ? 12.0 : 14.0, - // fontWeight: FontWeight.w800, + fontWeight: widget.fontWeight, fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans'), From ac63f0963356b143901c027810601971d91320f6 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Thu, 7 Oct 2021 15:40:34 +0300 Subject: [PATCH 56/67] edit arabic version --- lib/pages/parent_categorise_page.dart | 34 +++++++++------------------ 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 6862bcd7..ff1fc5b7 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -334,15 +334,13 @@ class _ParentCategorisePageState extends State { width: 10.0, ), Texts( -<<<<<<< HEAD + TranslationBase.of(context).refine, // 'Refine', - fontWeight: FontWeight.w600, -======= - 'Refine', + fontWeight: FontWeight.w600, ->>>>>>> bcd99555e3e980ea8ec5f30a74c9e167c8520d9f + ), SizedBox( width: 250.0, @@ -371,14 +369,10 @@ class _ParentCategorisePageState extends State { Column( children: [ ExpansionTile( -<<<<<<< HEAD + title: Texts( TranslationBase.of( context) .categorise), -======= - title: - Texts('Categorise'), ->>>>>>> bcd99555e3e980ea8ec5f30a74c9e167c8520d9f children: [ ProcedureListWidget( model: model, @@ -550,16 +544,14 @@ class _ParentCategorisePageState extends State { Container( width: 100, child: Button( -<<<<<<< HEAD + label: TranslationBase.of( context) .reset, backgroundColor: Colors.red, -======= - label: 'Reset', - backgroundColor: - Colors.red, ->>>>>>> bcd99555e3e980ea8ec5f30a74c9e167c8520d9f + + + ), ), SizedBox( @@ -623,17 +615,13 @@ class _ParentCategorisePageState extends State { Navigator.pop( context); }, -<<<<<<< HEAD + label: TranslationBase.of( context) .apply, backgroundColor: Colors.green, -======= - label: 'Apply', - backgroundColor: - Colors - .green, ->>>>>>> bcd99555e3e980ea8ec5f30a74c9e167c8520d9f + + ), ), ], From be21cb352bc8ee1d78929e30765efcf019ce4580 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Sun, 10 Oct 2021 11:15:43 +0300 Subject: [PATCH 57/67] return recommended products --- .../product-details/product-detail.dart | 6 +- .../product-details/recommended_products.dart | 377 ++++++++++++++++++ .../product_detail_service.dart | 3 + 3 files changed, 384 insertions(+), 2 deletions(-) create mode 100644 lib/pages/pharmacies/screens/product-details/recommended_products.dart diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index db43e6da..ef3b7d8a 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_deta import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.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'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/shared/custom-divider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; @@ -310,8 +311,9 @@ class __ProductDetailPageState extends State { ), ), SizedBox( - height: 80, - ) + height: 10, + ), + RecommendedProducts(product: widget.product) ], ), ), diff --git a/lib/pages/pharmacies/screens/product-details/recommended_products.dart b/lib/pages/pharmacies/screens/product-details/recommended_products.dart new file mode 100644 index 00000000..2070a29e --- /dev/null +++ b/lib/pages/pharmacies/screens/product-details/recommended_products.dart @@ -0,0 +1,377 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.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-detail.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/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'; + +class RecommendedProducts extends StatefulWidget { + final PharmacyProduct product; + final String customerId; + final ProductDetailViewModel productDetailViewModel; + final bool isOverQuantity; + final bool isInWishList; + final Function addToWishlistFunction; + final Function deleteFromWishlistFunction; + + RecommendedProducts( + {Key key, + this.product, + this.productDetailViewModel, + this.customerId, + this.isOverQuantity = false, + this.isInWishList = false, + this.addToWishlistFunction, + this.deleteFromWishlistFunction}) + : super(key: key); + + @override + _RecommendedProductsState createState() => _RecommendedProductsState(); +} + +class _RecommendedProductsState extends State { + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return SingleChildScrollView( + child: Container( + width: 410, + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(top: 9), + width: 410, + color: Colors.white, + child: Texts( + TranslationBase.of(context).recommended, + fontWeight: FontWeight.bold, fontSize: 16 + ), + ), + Container( + color: Colors.white, + height: 210, + margin: EdgeInsets.only(bottom: 75), + padding: EdgeInsets.only(bottom: 5), + // margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4), + child: BaseView( + onModelReady: (model) => + model.getRecommendedProducts(widget.product.id), + builder: (_, model, wi) => NetworkBaseView( + isLocalLoader: true, + baseViewModel: model, + child: Container( + child: model.state== ViewState.BusyLocal?Container( + height: 80, + child: Center( + child: CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ), + ), + ):model.recommendedProductList.length != null + ? ListView.builder( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + physics: ScrollPhysics(), + // physics: NeverScrollableScrollPhysics(), + itemCount: model.recommendedProductList.length, + itemBuilder: (context, index) { + return InkWell( + onTap: () async { + GifLoaderDialogUtils.showMyDialog(context); + RecommendedProductModel data = + model.recommendedProductList[index]; + var json = data.toJson(); + PharmacyProduct product = + new PharmacyProduct.fromJson(json); + await Navigator.pushReplacement( + context, + FadePage( + page: ProductDetailPage(product), + ), + ); + GifLoaderDialogUtils.hideDialog(context); + }, + child: Card( + elevation: 2, + shape: RoundedRectangleBorder( + side: BorderSide( + color: Colors.grey[300], width: 2), + borderRadius: BorderRadius.circular(10), + ), + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 0, + ), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(15), + ), + ), + padding: EdgeInsets.symmetric(horizontal: 4), + width: MediaQuery.of(context).size.width / 3, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Stack(children: [ + Container( + child: Align( + alignment: Alignment.topRight, + child: IconButton( + icon: Icon(model + .recommendedProductList[ + index] + .isinwishlist != + true + ? Icons.favorite_border + : Icons.favorite), + color: model + .recommendedProductList[ + index] + .isinwishlist != + true + ? Colors.grey + : Colors.red, + onPressed: () async { + if (widget.customerId != null) { + if (!widget.isInWishList && + model + .recommendedProductList[ + index] + .isinwishlist != + true) { + GifLoaderDialogUtils + .showMyDialog(context); + await widget.addToWishlistFunction( + itemID: model + .recommendedProductList[ + index] + .id, + model: widget + .productDetailViewModel); +// checkWishlist(); + GifLoaderDialogUtils + .hideDialog(context); + setState(() { + model + .recommendedProductList[ + index] + .isinwishlist = true; + }); + } else { + GifLoaderDialogUtils + .showMyDialog(context); + await widget.deleteFromWishlistFunction( + itemID: model + .recommendedProductList[ + index] + .id, + model: widget + .productDetailViewModel); + GifLoaderDialogUtils + .hideDialog(context); + setState(() { + model + .recommendedProductList[ + index] + .isinwishlist = false; + }); + } + } else { + return; + } + setState(() { + // checkWishlist(); + }); + }, + ), + ), + ), + Container( + margin: EdgeInsets.fromLTRB( + 0, 16, 10, 16), + alignment: Alignment.center, + child: (model + .recommendedProductList[ + index] + .images != + null && + model + .recommendedProductList[ + index] + .images + .length > + 0) + ? Image.network( + model + .recommendedProductList[ + index] + .images[0] + .src + .toString(), + fit: BoxFit.cover, + height: 60, + ) + : Image.asset( + "assets/images/no_image.png", + fit: BoxFit.cover, + height: 60, + ), + ), + Container( + width: model + .recommendedProductList[ + 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 + .recommendedProductList[ + index] + .rxMessage != + null + ? Texts( + projectViewModel.isArabic + ? model + .recommendedProductList[ + index] + .rxMessagen + : model + .recommendedProductList[ + index] + .rxMessage, + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ) + : Texts(""), + ), + ]), + Container( + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + projectViewModel.isArabic + ? model + .recommendedProductList[ + index] + .namen + : model + .recommendedProductList[ + index] + .name, + style: TextStyle( + color: Colors.black, + fontSize: 13.0, +// fontWeight: FontWeight.bold, + ), + ), + Padding( +// padding: const EdgeInsets.only(top: 15, bottom: 10), + padding: const EdgeInsets.only( + top: 10, bottom: 5), + child: Texts( + "SAR ${model.recommendedProductList[index].price}", + bold: true, + fontSize: 14, + ), + ), + ], + ), + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + padding: + EdgeInsets.only(right: 10), + child: Align( + alignment: Alignment.topLeft, + child: RatingBar.readOnly( + initialRating: model + .recommendedProductList[ + index] + .approvedRatingSum + .toDouble(), + size: 13.0, + filledColor: + Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: + Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), + ), + ), + Texts( + "(${model.recommendedProductList[index].notApprovedTotalReviews.toString()})", +// bold: true, + fontSize: 12, + ), + ]), + ], + ), + ), + ), + ); + }) + : Container( + // color: Colors.white, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + // crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Texts( + TranslationBase.of(context).nonRecommended, + color: Colors.black, + ), + ], + ), + ), + ), + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 990b5f23..4f457cad 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -89,6 +89,9 @@ class ProductDetailService extends BaseService { "language_id": 1 } }; + + + await baseAppClient.pharmacyPost(GET_SHOPPING_CART, isExternal: false, onSuccess: (dynamic response, int statusCode) { _addToCartModel.clear(); From 10f75191c64bca0302e654378d2c63ee978e9594 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Mon, 11 Oct 2021 11:14:36 +0300 Subject: [PATCH 58/67] added shopping cart to categories --- lib/pages/parent_categorise_page.dart | 30 +++++++++++++++++++----- lib/pages/sub_categories_modalsheet.dart | 1 + 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index ff1fc5b7..0be70de5 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.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/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -15,6 +16,7 @@ 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'; @@ -1117,12 +1119,28 @@ class _ParentCategorisePageState extends State { padding: const EdgeInsets .only( - top: 4, - bottom: 4), - child: Texts( - "SAR ${model.parentProducts[index].price}", - bold: true, - fontSize: 14, + top: 1, + bottom: 1), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Texts( + "SAR ${model.parentProducts[index].price}", + bold: true, + fontSize: 14, + ), + Container( + child: IconButton( + icon: Icon(FontAwesomeIcons.shoppingCart, size: 15), + onPressed: () async { + Navigator.push( + context, + FadePage(page: CartOrderPage()), + ); + }, + ), + ), + ], ), ), Row( diff --git a/lib/pages/sub_categories_modalsheet.dart b/lib/pages/sub_categories_modalsheet.dart index f1ff0e08..d6499c8e 100644 --- a/lib/pages/sub_categories_modalsheet.dart +++ b/lib/pages/sub_categories_modalsheet.dart @@ -42,6 +42,7 @@ class _SubCategoriseModalsheetState extends State { appBarTitle: TranslationBase.of(context).categorise, isBottomBar: false, isShowAppBar: true, + isPharmacy: true, backgroundColor: Colors.white, isShowDecPage: false, baseViewModel: model, From 9a1dc3c678532f567753c681b9e356255c9de973 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Mon, 11 Oct 2021 12:34:10 +0300 Subject: [PATCH 59/67] pharmacy cart and wishlist fixes --- lib/core/service/client/base_app_client.dart | 3 +- lib/pages/landing/landing_page_pharmcy.dart | 2 +- .../pharmacies/screens/cart-order-page.dart | 611 +++++++++--------- .../screens/pharmacy_module_page.dart | 29 - .../product_detail_service.dart | 3 + lib/widgets/others/app_scaffold_widget.dart | 49 +- 6 files changed, 337 insertions(+), 360 deletions(-) diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index d5e5a207..cf204e6a 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -494,8 +494,7 @@ class BaseAppClient { if (statusCode < 200 || statusCode >= 400 || json == null) { if (statusCode == 401) { - AppToast.showErrorToast( - message: TranslationBase.of(AppGlobal.context).pharmacyRelogin); + onFailure(TranslationBase.of(AppGlobal.context).pharmacyRelogin, statusCode); Navigator.of(AppGlobal.context).pushNamed(HOME); } else { onFailure('Error While Fetching data', statusCode); diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 41c4b694..5094db04 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -129,7 +129,7 @@ class _LandingPagePharmacyState extends State { PharmacyPage(), PharmacyCategorisePage(), PharmacyProfilePage(), - CartOrderPage(), + CartOrderPage(changeTab: _changeCurrentTab), ], ), bottomNavigationBar: BottomNavPharmacyBar( diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index 6f63927d..fe469b32 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -20,21 +20,23 @@ import 'package:http/http.dart'; import 'package:provider/provider.dart'; class CartOrderPage extends StatefulWidget { - const CartOrderPage({Key key}) : super(key: key); + final Function(int) changeTab; + + const CartOrderPage({Key key, this.changeTab}) : super(key: key); + @override _CartOrderPageState createState() => _CartOrderPageState(); } class _CartOrderPageState extends State { - bool isLoading = true; + @override void initState() { super.initState(); getData(); } - @override Widget build(BuildContext context) { final mediaQuery = MediaQuery.of(context); @@ -53,195 +55,194 @@ class _CartOrderPageState extends State { showHomeAppBarIcon: false, isShowDecPage: true, baseViewModel: model, + backButtonTab: widget.changeTab != null ? () => widget.changeTab(0) : null, backgroundColor: Colors.white, body: !(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.subtotal).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_image.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.subtotal).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_image.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, @@ -251,13 +252,12 @@ class _CartOrderPageState extends State { ); } - void getData()async { - - await Provider.of(context, listen: false).getShoppingCart(); + void getData() async { + await Provider.of(context, listen: false) + .getShoppingCart(); setState(() { - isLoading= false; + isLoading = false; }); - } } @@ -279,148 +279,145 @@ class _OrderBottomWidgetState extends State { ProjectViewModel projectProvider = Provider.of(context); OrderPreviewViewModel cart = Provider.of(context); return !(cart.cartResponse.shoppingCarts == null || - cart.cartResponse.shoppingCarts.length == 0) + cart.cartResponse.shoppingCarts.length == 0) ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Divider( - color: Color(0xFFD6D6D6), - height: 1, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Container( - height: widget.height * 0.070, - color: Color(0xffe6ffe0), - padding: EdgeInsets.symmetric(horizontal: 4), - child: Row( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - InkWell( - onTap: () { - setState(() { - isAgree = !isAgree; - }); - }, - child: Container( - width: 25.0, - height: widget.height * 0.070, - decoration: new BoxDecoration( - color: - !isAgree ? Color(0xffeeeeee) : Colors.green, - shape: BoxShape.circle, - ), - child: !isAgree - ? null - : Padding( - padding: const EdgeInsets.all(0.0), - child: Icon( - Icons.check, - color: Colors.white, - size: 25, - ), - ), - ), - ), - Expanded( - child: Container( - padding: EdgeInsets.symmetric(horizontal: 4), - margin: const EdgeInsets.symmetric(vertical: 4), - child: Texts( - TranslationBase.of(context) - .pharmacyServiceTermsCondition, - fontSize: 13, - color: Colors.grey.shade800, - fontWeight: FontWeight.normal, - ), - ), + const Divider( + color: Color(0xFFD6D6D6), + height: 1, + thickness: 1, + indent: 0, + endIndent: 0, ), - InkWell( - onTap: () => { - Navigator.push(context, - FadePage(page: PharmacyTermsConditions())) - }, - child: Container( - child: Icon( - Icons.info, - size: 25, - color: Color(0xff005aff), - ), + Container( + height: widget.height * 0.070, + color: Color(0xffe6ffe0), + padding: EdgeInsets.symmetric(horizontal: 4), + child: Row( + children: [ + InkWell( + onTap: () { + setState(() { + isAgree = !isAgree; + }); + }, + child: Container( + width: 25.0, + height: widget.height * 0.070, + decoration: new BoxDecoration( + color: !isAgree ? Color(0xffeeeeee) : Colors.green, + shape: BoxShape.circle, + ), + child: !isAgree + ? null + : Padding( + padding: const EdgeInsets.all(0.0), + child: Icon( + Icons.check, + color: Colors.white, + size: 25, + ), + ), + ), + ), + Expanded( + child: Container( + padding: EdgeInsets.symmetric(horizontal: 4), + margin: const EdgeInsets.symmetric(vertical: 4), + child: Texts( + TranslationBase.of(context) + .pharmacyServiceTermsCondition, + fontSize: 13, + color: Colors.grey.shade800, + fontWeight: FontWeight.normal, + ), + ), + ), + InkWell( + onTap: () => { + Navigator.push( + context, FadePage(page: PharmacyTermsConditions())) + }, + child: Container( + child: Icon( + Icons.info, + size: 25, + color: Color(0xff005aff), + ), + ), + ), + ], ), ), - ], - ), - ), - Container( - height: widget.height * 0.065, - margin: EdgeInsets.symmetric(vertical: 2), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, + Container( + height: widget.height * 0.065, + margin: EdgeInsets.symmetric(vertical: 2), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Container( - margin: EdgeInsets.symmetric( - horizontal: 0, vertical: 0), - child: Row( + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, children: [ + Container( + margin: EdgeInsets.symmetric( + horizontal: 0, vertical: 0), + child: Row( + children: [ + Texts( + "${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: projectProvider.isArabic ? 12 : 14, + fontWeight: FontWeight.bold, + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4), + child: Texts( + "${TranslationBase.of(context).inclusiveVat}", + fontSize: 8, + color: Colors.grey, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), Texts( - "${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotal).toStringAsFixed(2)}", - fontSize: - projectProvider.isArabic ? 12 : 14, + "${cart.cartResponse.quantityCount} ${TranslationBase.of(context).items}", + fontSize: 10, + color: Colors.grey, fontWeight: FontWeight.bold, ), - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 4), - child: Texts( - "${TranslationBase.of(context).inclusiveVat}", - fontSize: 8, - color: Colors.grey, - fontWeight: FontWeight.bold, - ), - ), ], ), ), - Texts( - "${cart.cartResponse.quantityCount} ${TranslationBase.of(context).items}", - fontSize: 10, - color: Colors.grey, - fontWeight: FontWeight.bold, + RaisedButton( + onPressed: isAgree + ? () => { + 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), ), ], ), ), - RaisedButton( - onPressed: isAgree - ? () => { - 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), - ), ], - ), - ), - ], - ) + ) : Container(); } } diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 2e71a0c3..5ffe875c 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -1,44 +1,15 @@ -import 'package:diplomaticquarterapp/config/size_config.dart'; -import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; -import 'package:diplomaticquarterapp/core/service/parmacyModule/order-preview-service.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BestSellerViewModel.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BrandViewModel.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/LastVisitedViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PrescriptionViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.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/landing/home_page.dart'; -import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; -import 'package:diplomaticquarterapp/pages/offers_categorise_page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product-brands.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/lacum-activitaion-vida-page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/lakum-main-page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/recommended-product-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/BannerPager.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductTileItem.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/PrescriptionsWidget.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/ShopByBrandWidget.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/widgets/manufacturerItem.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/borderedButton.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'; import 'package:provider/provider.dart'; -import 'package:rating_bar/rating_bar.dart'; -import '../../../locator.dart'; -import '../../final_products_page.dart'; class PharmacyPage extends StatefulWidget { @override diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 4f457cad..8bad3e69 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -154,6 +154,7 @@ class ProductDetailService extends BaseService { super.error = error; }); } + Future deleteItemFromWishlist(itemID) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; @@ -163,9 +164,11 @@ 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'); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; + AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage()); }); } diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index b3cc63d7..6a40b935 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -29,8 +29,6 @@ import '../progress_indicator/app_loader_widget.dart'; import 'arrow_back.dart'; import 'network_base_view.dart'; import 'not_auh_page.dart'; -import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; -import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; VoidCallback _onCartClick; @@ -59,6 +57,8 @@ class AppScaffold extends StatelessWidget { final List imagesInfo; final bool isHelp; final bool isLocalLoader; + final Function backButtonTab; + AuthenticatedUserObject authenticatedUserObject = locator(); @@ -90,7 +90,9 @@ class AppScaffold extends StatelessWidget { this.showHomeAppBarIcon = true, this.imagesInfo, appBar, - this.customAppBar, this.isLocalLoader= false}); + this.customAppBar, + this.isLocalLoader = false, + this.backButtonTab}); AppScaffold setOnAppBarCartClick(VoidCallback onClick) { _onCartClick = onClick; @@ -115,6 +117,7 @@ class AppScaffold extends StatelessWidget { isOfferPackages: isOfferPackages, showOfferPackagesCart: showOfferPackagesCart, isShowDecPage: isShowDecPage, + backButtonTab: backButtonTab, ) : null, bottomSheet: bottomSheet, @@ -146,18 +149,18 @@ class AppScaffold extends StatelessWidget { } buildBodyWidget(context) { - return Stack( - children: [ - Center( - child:isLoading? CircularProgressIndicator( - backgroundColor: Colors.white, - valueColor: AlwaysStoppedAnimation( - Colors.grey[500], - ), - ):body), - - - isHelp == true ? RobotIcon() : Container()]); + return Stack(children: [ + Center( + child: isLoading + ? CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ) + : body), + isHelp == true ? RobotIcon() : Container() + ]); } } @@ -174,6 +177,7 @@ class AppBarWidget extends StatefulWidget with PreferredSizeWidget { final bool showOfferPackagesCart; final bool isShowDecPage; + final Function backButtonTab; Function(String) badgeUpdater; AppBarWidget( @@ -184,6 +188,7 @@ class AppBarWidget extends StatefulWidget with PreferredSizeWidget { this.showPharmacyCart = true, this.isOfferPackages = false, this.showOfferPackagesCart = false, + this.backButtonTab, this.isShowDecPage = true}); @override @@ -230,7 +235,9 @@ class AppBarWidgetState extends State { fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans')), leading: Builder( builder: (BuildContext context) { - return ArrowBack(); + return ArrowBack( + onTap: widget.backButtonTab, + ); }, ), centerTitle: true, @@ -385,10 +392,10 @@ class _RobotIcon extends State { bottom: -15); } - // setAnimation() async { - // /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || - // // var animation = - // // IS_TEXT_COMPLETED == ? true : false; +// setAnimation() async { +// /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || +// // var animation = +// // IS_TEXT_COMPLETED == ? true : false; - // } +// } } From b779c250a487219b46db52935d510ed672772d5f Mon Sep 17 00:00:00 2001 From: mosazaid Date: Mon, 11 Oct 2021 14:49:49 +0300 Subject: [PATCH 60/67] pharmacy cart and wishlist fixes --- lib/widgets/others/app_scaffold_widget.dart | 5 ++++- lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 6a40b935..f5ce682a 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.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'; @@ -215,6 +216,8 @@ class AppBarWidgetState extends State { Widget buildAppBar(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); + OrderPreviewViewModel orderPreviewViewModel = Provider.of(context); + return AppBar( elevation: 0, backgroundColor: widget.isPharmacy @@ -260,7 +263,7 @@ class AppBarWidgetState extends State { icon: Badge( position: BadgePosition.topStart(top: -15, start: -10), badgeContent: Text( - _badgeText, + orderPreviewViewModel.cartResponse.quantityCount.toString() /*_badgeText*/, style: TextStyle( fontSize: 9, color: Colors.white, diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart index 94e260d0..1b8eaefa 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart @@ -34,6 +34,9 @@ class BottomNavPharmacyItem extends StatelessWidget { @override Widget build(BuildContext context) { + OrderPreviewViewModel orderPreviewViewModel = Provider.of(context); + ProjectViewModel projectViewModel = Provider.of(context); + return Expanded( child: SizedBox( // height: 72.0, @@ -97,7 +100,7 @@ class BottomNavPharmacyItem extends StatelessWidget { ), ), ), - if(currentIndex == 3 &&Provider.of(context, listen: false).cartResponse.quantityCount !=0) + if(projectViewModel.isLogin && currentIndex == 3 && orderPreviewViewModel.cartResponse.quantityCount !=0) Positioned( top: 5, right: -3.5, child: Container( @@ -108,7 +111,7 @@ class BottomNavPharmacyItem extends StatelessWidget { ), 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,)), + child: Center(child: Texts(orderPreviewViewModel.cartResponse.quantityCount.toString(), style: "caption", medium: true, color: Colors.white,)), ), ) ], From 2526d6bc6fa0f17c99f664e7da1d8ed9f9ad1965 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 12 Oct 2021 10:29:49 +0300 Subject: [PATCH 61/67] fix issue in cart page --- .../pharmacies/payment-checkout-data.dart | 6 +- .../pharmacyModule/OrderPreviewViewModel.dart | 2 +- .../screens/cart-order-preview.dart | 516 +++++++++--------- .../pharmacyAddresses/PharmacyAddresses.dart | 2 + 4 files changed, 261 insertions(+), 265 deletions(-) diff --git a/lib/core/model/pharmacies/payment-checkout-data.dart b/lib/core/model/pharmacies/payment-checkout-data.dart index dd9e0e54..5d91c829 100644 --- a/lib/core/model/pharmacies/payment-checkout-data.dart +++ b/lib/core/model/pharmacies/payment-checkout-data.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; import 'ShippingOption.dart'; -class PaymentCheckoutData with ChangeNotifier{ +class PaymentCheckoutData { Addresses address; PaymentOption paymentOption; LacumAccountInformation lacumInformation; @@ -15,7 +15,5 @@ class PaymentCheckoutData with ChangeNotifier{ PaymentCheckoutData({this.address, this.paymentOption, this.lacumInformation, this.cartDataVisible = false, this.shippingOption, this.usedLakumPoints = 0}); - void updateData() { - notifyListeners(); - } + } diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index 801f6fb7..7c86f6b7 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -192,7 +192,7 @@ class OrderPreviewViewModel extends BaseViewModel { .getShippingOption(paymentCheckoutData.address) .then((res) { paymentCheckoutData.shippingOption = ShippingOption.fromJson(res); - paymentCheckoutData.updateData(); + setState(ViewState.Idle); }); if (_orderService.hasError) { error = _orderService.error; diff --git a/lib/pages/pharmacies/screens/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-order-preview.dart index f6e1d392..ec2828ce 100644 --- a/lib/pages/pharmacies/screens/cart-order-preview.dart +++ b/lib/pages/pharmacies/screens/cart-order-preview.dart @@ -3,6 +3,7 @@ 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/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'; @@ -79,20 +80,18 @@ class _OrderPreviewPageState extends State { SizedBox( height: 10, ), - Consumer( - builder: (ctx, paymentData, _) => - paymentData.lacumInformation != null - ? Container( - child: Column( - children: [ - LakumWidget(model), - SizedBox( - height: 10, - ), - ], - ), - ) - : Container()), + model.paymentCheckoutData.lacumInformation != null + ? Container( + child: Column( + children: [ + LakumWidget(model), + SizedBox( + height: 10, + ), + ], + ), + ) + : Container(), Container( color: Colors.white, width: double.infinity, @@ -227,7 +226,8 @@ class _OrderPreviewPageState extends State { ], ) : Container(), - ) + ), + SizedBox(height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0,) ], ), ), @@ -284,162 +284,161 @@ class _SelectAddressWidgetState extends State { @override Widget build(BuildContext context) { - return Consumer( - builder: (ctx, paymentData, _) => Container( - color: Colors.white, - child: address == null - ? InkWell( - onTap: () => {_navigateToAddressPage()}, + OrderPreviewViewModel model = Provider.of(context); + return Container( + color: Colors.white, + child: address == null + ? InkWell( + onTap: () => {_navigateToAddressPage()}, + child: Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_address.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Expanded( child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_address.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Expanded( - child: Container( - padding: - EdgeInsets.symmetric(vertical: 0, horizontal: 6), - child: Texts( - TranslationBase.of(context).selectAddress, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff0000ff), - ), - ), - ), - Icon( - Icons.arrow_forward_ios, - size: 20, - color: Colors.grey.shade400, - ), - ], + padding: + EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + TranslationBase.of(context).selectAddress, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff0000ff), ), ), - ) - : Container( - child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_mark.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Expanded( - child: Container( - padding: EdgeInsets.symmetric( - vertical: 0, horizontal: 6), - child: Texts( - TranslationBase.of(context).shippingAddress, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - ), - InkWell( - onTap: () => {_navigateToAddressPage()}, - child: Texts( - TranslationBase.of(context).changeAddress, - fontSize: 12, - fontWeight: FontWeight.normal, - color: Color(0xff0000ff), - ), - ), - ], - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Texts( - "${address.firstName} ${address.lastName}", - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Texts( - "${address.address1} ${address.address2} ${address.address2},, ${address.city}, ${address.country} ${address.zipPostalCode}", - fontSize: 12, - fontWeight: FontWeight.normal, - color: Colors.grey.shade500, - ), - ), - Row( - children: [ - Container( - margin: const EdgeInsets.only(right: 8), - child: Icon( - Icons.phone, - size: 20, - color: Colors.black, - ), - ), - Texts( - "${address.phoneNumber}", - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.grey, - ), - ], - ), - Container( - margin: EdgeInsets.symmetric(vertical: 8), - child: SizedBox( - height: 2, - width: double.infinity, - child: Container( - color: Color(0xffefefef), - ), - ), - ), - Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_truck.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Container( - padding: EdgeInsets.symmetric( - vertical: 0, horizontal: 6), - child: Texts( - "${TranslationBase.of(context).shipBy}", - fontSize: 12, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - Container( - child: Image.asset( - paymentData.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, - ), - margin: EdgeInsets.symmetric(horizontal: 8), - ), - ], + ), + Icon( + Icons.arrow_forward_ios, + size: 20, + color: Colors.grey.shade400, + ), + ], + ), + ), + ) + : Container( + child: Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_mark.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Expanded( + child: Container( + padding: EdgeInsets.symmetric( + vertical: 0, horizontal: 6), + child: Texts( + TranslationBase.of(context).shippingAddress, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, ), - ], + ), + ), + InkWell( + onTap: () => {_navigateToAddressPage()}, + child: Texts( + TranslationBase.of(context).changeAddress, + fontSize: 12, + fontWeight: FontWeight.normal, + color: Color(0xff0000ff), + ), ), + ], + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Texts( + "${address.firstName} ${address.lastName}", + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, ), - ), // ic_shipping_mark.png - ), + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Texts( + "${address.address1} ${address.address2} ${address.address2},, ${address.city}, ${address.country} ${address.zipPostalCode}", + fontSize: 12, + fontWeight: FontWeight.normal, + color: Colors.grey.shade500, + ), + ), + Row( + children: [ + Container( + margin: const EdgeInsets.only(right: 8), + child: Icon( + Icons.phone, + size: 20, + color: Colors.black, + ), + ), + Texts( + "${address.phoneNumber}", + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.grey, + ), + ], + ), + Container( + margin: EdgeInsets.symmetric(vertical: 8), + child: SizedBox( + height: 2, + width: double.infinity, + child: Container( + color: Color(0xffefefef), + ), + ), + ), + Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_truck.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Container( + padding: EdgeInsets.symmetric( + vertical: 0, horizontal: 6), + child: Texts( + "${TranslationBase.of(context).shipBy}", + fontSize: 12, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + Container( + child: Image.asset( + model.paymentCheckoutData.shippingOption==null?"": 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, + ), + margin: EdgeInsets.symmetric(horizontal: 8), + ), + ], + ), + ], + ), + ), + ), // ic_shipping_mark.png ); } } @@ -465,7 +464,6 @@ class _SelectPaymentOptionWidgetState extends State { paymentOption = result; widget.model.paymentCheckoutData.paymentOption = paymentOption; - widget.model.paymentCheckoutData.updateData(); } }) }); @@ -744,105 +742,103 @@ class PaymentBottomWidget extends StatelessWidget { Widget build(BuildContext context) { final scaffold = Scaffold.of(context); this.context = context; - + OrderPreviewViewModel orderPreviewViewModel = Provider.of(context); return Container( margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0), - child: Consumer( - builder: (ctx, paymentData, _) => paymentData.cartDataVisible - ? Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container( - margin: - EdgeInsets.symmetric(horizontal: 0, vertical: 4), - child: Row( - children: [ - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff929295), - ), - Padding( - padding: - const EdgeInsets.symmetric(horizontal: 4), - child: Texts( - "${TranslationBase.of(context).inclusiveVat}", - fontSize: 8, - color: Color(0xff929295), - fontWeight: FontWeight.w600, - ), - ), - ], - ), - ), - Texts( - "${model.cartResponse.quantityCount} ${TranslationBase.of(context).items}", - fontSize: 10, - color: Colors.grey, - fontWeight: FontWeight.bold, - ), - ], - ), - Container( - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - side: BorderSide( - color: Color(0xff929295), - width: 1, - ), - ), - onPressed: (paymentData.address != null && - paymentData.paymentOption != null) - ? () async { - await model.makeOrder(); - if (model.state == ViewState.Idle) { - AppToast.showSuccessToast( - message: - "Order has been placed successfully!!"); - openPayment( - model.orderListModel[0], model.user); - } else { - AppToast.showErrorToast(message: model.error); - } - Navigator.pop(context); - Navigator.pop(context); - } - : null, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 16), - child: new Text( - "${TranslationBase.of(context).proceedPay}", - style: new TextStyle( - color: (paymentData.address != null && - paymentData.paymentOption != null) - ? Colors.white - : Colors.grey.shade400, - fontWeight: FontWeight.bold, - fontSize: 12), - ), + child: orderPreviewViewModel.paymentCheckoutData.cartDataVisible + ? Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + margin: + EdgeInsets.symmetric(horizontal: 0, vertical: 4), + child: Row( + children: [ + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff929295), + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4), + child: Texts( + "${TranslationBase.of(context).inclusiveVat}", + fontSize: 8, + color: Color(0xff929295), + fontWeight: FontWeight.w600, ), - color: (paymentData.address != null && - paymentData.paymentOption != null) - ? Colors.green - : Color(0xff929295), - disabledColor: (paymentData.address != null && - paymentData.paymentOption != null) - ? Colors.green - : Color(0xff929295), ), - ), - ], + ], + ), ), - ) - : Container(), - ), + Texts( + "${model.cartResponse.quantityCount} ${TranslationBase.of(context).items}", + fontSize: 10, + color: Colors.grey, + fontWeight: FontWeight.bold, + ), + ], + ), + Container( + child: RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + side: BorderSide( + color: Color(0xff929295), + width: 1, + ), + ), + onPressed: (orderPreviewViewModel.paymentCheckoutData.address != null && + orderPreviewViewModel.paymentCheckoutData.paymentOption != null) + ? () async { + await model.makeOrder(); + if (model.state == ViewState.Idle) { + AppToast.showSuccessToast( + message: + "Order has been placed successfully!!"); + openPayment( + model.orderListModel[0], model.user); + } else { + AppToast.showErrorToast(message: model.error); + } + Navigator.pop(context); + Navigator.pop(context); + } + : null, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 16), + child: new Text( + "${TranslationBase.of(context).proceedPay}", + style: new TextStyle( + color: (orderPreviewViewModel.paymentCheckoutData.address != null && + orderPreviewViewModel.paymentCheckoutData.paymentOption != null) + ? Colors.white + : Colors.grey.shade400, + fontWeight: FontWeight.bold, + fontSize: 12), + ), + ), + color: (orderPreviewViewModel.paymentCheckoutData.address != null && + orderPreviewViewModel.paymentCheckoutData.paymentOption != null) + ? Colors.green + : Color(0xff929295), + disabledColor: (orderPreviewViewModel.paymentCheckoutData.address != null && + orderPreviewViewModel.paymentCheckoutData.paymentOption != null) + ? Colors.green + : Color(0xff929295), + ), + ), + ], + ), + ) + : Container(), ); } diff --git a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart index 51256e11..8670f0d2 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart @@ -78,6 +78,8 @@ class _PharmacyAddressesState extends State { }, ), ), + SizedBox(height: height * 0.10,) + ], ), ), From 75fdadafbd160eb7f3695d1515351fe2242008c6 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 12 Oct 2021 10:39:33 +0300 Subject: [PATCH 62/67] refactor widget in the cart preview --- lib/pages/landing/landing_page_pharmcy.dart | 2 +- .../screens/cart-order-preview.dart | 899 ------------------ .../{ => cart-page}/cart-order-page.dart | 9 +- .../screens/cart-page/cart-order-preview.dart | 238 +++++ .../screens/cart-page/lakum_widget.dart | 187 ++++ .../cart-page/payment_bottom_widget.dart | 195 ++++ .../cart-page/select_address_widget.dart | 226 +++++ .../select_payment_option_widget.dart | 146 +++ .../product-details/footor/footer-widget.dart | 2 +- .../shared/product_details_app_bar.dart | 2 +- lib/widgets/others/app_scaffold_widget.dart | 2 +- lib/widgets/pharmacy/product_tile.dart | 2 +- 12 files changed, 1000 insertions(+), 910 deletions(-) delete mode 100644 lib/pages/pharmacies/screens/cart-order-preview.dart rename lib/pages/pharmacies/screens/{ => cart-page}/cart-order-page.dart (97%) create mode 100644 lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart create mode 100644 lib/pages/pharmacies/screens/cart-page/lakum_widget.dart create mode 100644 lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart create mode 100644 lib/pages/pharmacies/screens/cart-page/select_address_widget.dart create mode 100644 lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 5094db04..8b2204f4 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -5,7 +5,7 @@ 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/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-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/wishlist.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/profile/profile.dart'; diff --git a/lib/pages/pharmacies/screens/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-order-preview.dart deleted file mode 100644 index ec2828ce..00000000 --- a/lib/pages/pharmacies/screens/cart-order-preview.dart +++ /dev/null @@ -1,899 +0,0 @@ -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/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/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/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'; - -class OrderPreviewPage extends StatefulWidget { - final List addresses; - - OrderPreviewPage(this.addresses); - - @override - _OrderPreviewPageState createState() => _OrderPreviewPageState(); -} - -class _OrderPreviewPageState extends State { - MyInAppBrowser browser; - bool isLoading = true; - - @override - void initState() { - super.initState(); - getData(); - } - - void getData() async { - if (isLoading) - await Provider.of(context, listen: false) - .getShoppingCart(); - setState(() { - isLoading = false; - }); - } - - @override - Widget build(BuildContext context) { - - final mediaQuery = MediaQuery.of(context); - final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; - OrderPreviewViewModel model = Provider.of(context); - return AppScaffold( - appBarTitle: "${TranslationBase.of(context).checkOut}", - isShowAppBar: true, - isPharmacy: true, - isShowDecPage: false, - isLoading: isLoading, - isLocalLoader: true, - backgroundColor: Colors.white, - // baseViewModel: model, - body: Container( - color: Color(0xFFF1F1F1), - height: height * 0.90, - child: SingleChildScrollView( - child: Container( - color: Color(0xFFF1F1F1), - child: Column( - children: [ - SelectAddressWidget(model, widget.addresses), - SizedBox( - height: 10, - ), - SelectPaymentOptionWidget(model), - SizedBox( - height: 10, - ), - model.paymentCheckoutData.lacumInformation != null - ? Container( - child: Column( - children: [ - LakumWidget(model), - SizedBox( - height: 10, - ), - ], - ), - ) - : Container(), - Container( - color: Colors.white, - width: double.infinity, - padding: EdgeInsets.all(8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - TranslationBase.of(context).reviewOrder, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ...List.generate( - model.cartResponse.shoppingCarts != null - ? model.cartResponse.shoppingCarts.length - : 0, - (index) => ProductOrderPreviewItem( - model.cartResponse.shoppingCarts[index]), - ), - ], - ), - ), - Container( - width: double.infinity, - padding: EdgeInsets.all(8), - child: model.cartResponse.subtotal != null - ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - TranslationBase.of(context).orderSummary, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - SizedBox( - height: 20, - ), - 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).shipping}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase.of(context).sar} ${(model.totalAdditionalShippingCharge).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.subtotal).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - ], - ), - SizedBox( - height: 10, - ), - ], - ) - : Container(), - ), - SizedBox(height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0,) - ], - ), - ), - ), - ), - bottomSheet: Container( - height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, - color: Colors.white, - child: PaymentBottomWidget(model), - ), - ); - } -} - -class SelectAddressWidget extends StatefulWidget { - final OrderPreviewViewModel model; - final List addresses; - - SelectAddressWidget(this.model, this.addresses); - - @override - _SelectAddressWidgetState createState() => _SelectAddressWidgetState(); -} - -class _SelectAddressWidgetState extends State { - Addresses address; - - _navigateToAddressPage() { - Navigator.push(context, FadePage(page: PharmacyAddressesPage())) - .then((result) { - if (result != null) { - address = result; - widget.model.paymentCheckoutData.address = address; - widget.model.getInformationsByAddress(); - } - - /* setState(() { - if (result != null) { - address = result; - widget.model.paymentCheckoutData.address = address; - widget.model.getInformationsByAddress(); - } - })*/ - }); - } - - @override - void initState() { - if (widget.model.paymentCheckoutData.address != null) { - address = widget.model.paymentCheckoutData.address; - } - super.initState(); - } - - @override - Widget build(BuildContext context) { - OrderPreviewViewModel model = Provider.of(context); - return Container( - color: Colors.white, - child: address == null - ? InkWell( - onTap: () => {_navigateToAddressPage()}, - child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_address.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Expanded( - child: Container( - padding: - EdgeInsets.symmetric(vertical: 0, horizontal: 6), - child: Texts( - TranslationBase.of(context).selectAddress, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff0000ff), - ), - ), - ), - Icon( - Icons.arrow_forward_ios, - size: 20, - color: Colors.grey.shade400, - ), - ], - ), - ), - ) - : Container( - child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_mark.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Expanded( - child: Container( - padding: EdgeInsets.symmetric( - vertical: 0, horizontal: 6), - child: Texts( - TranslationBase.of(context).shippingAddress, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - ), - InkWell( - onTap: () => {_navigateToAddressPage()}, - child: Texts( - TranslationBase.of(context).changeAddress, - fontSize: 12, - fontWeight: FontWeight.normal, - color: Color(0xff0000ff), - ), - ), - ], - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Texts( - "${address.firstName} ${address.lastName}", - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Texts( - "${address.address1} ${address.address2} ${address.address2},, ${address.city}, ${address.country} ${address.zipPostalCode}", - fontSize: 12, - fontWeight: FontWeight.normal, - color: Colors.grey.shade500, - ), - ), - Row( - children: [ - Container( - margin: const EdgeInsets.only(right: 8), - child: Icon( - Icons.phone, - size: 20, - color: Colors.black, - ), - ), - Texts( - "${address.phoneNumber}", - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.grey, - ), - ], - ), - Container( - margin: EdgeInsets.symmetric(vertical: 8), - child: SizedBox( - height: 2, - width: double.infinity, - child: Container( - color: Color(0xffefefef), - ), - ), - ), - Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_truck.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Container( - padding: EdgeInsets.symmetric( - vertical: 0, horizontal: 6), - child: Texts( - "${TranslationBase.of(context).shipBy}", - fontSize: 12, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - Container( - child: Image.asset( - model.paymentCheckoutData.shippingOption==null?"": 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, - ), - margin: EdgeInsets.symmetric(horizontal: 8), - ), - ], - ), - ], - ), - ), - ), // ic_shipping_mark.png - ); - } -} - -class SelectPaymentOptionWidget extends StatefulWidget { - final OrderPreviewViewModel model; - - SelectPaymentOptionWidget(this.model); - - @override - _SelectPaymentOptionWidgetState createState() => - _SelectPaymentOptionWidgetState(); -} - -class _SelectPaymentOptionWidgetState extends State { - PaymentOption paymentOption; - - _navigateToPaymentOption() { - Navigator.push(context, FadePage(page: PaymentMethodSelectPage())) - .then((result) => { - setState(() { - if (result != null) { - paymentOption = result; - widget.model.paymentCheckoutData.paymentOption = - paymentOption; - } - }) - }); - } - - @override - void initState() { - if (widget.model.paymentCheckoutData.paymentOption != null) { - paymentOption = widget.model.paymentCheckoutData.paymentOption; - } - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Container( - color: Colors.white, - child: paymentOption == null - ? InkWell( - onTap: () => {_navigateToPaymentOption()}, - child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_payment_option.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Expanded( - child: Container( - padding: - EdgeInsets.symmetric(vertical: 0, horizontal: 6), - child: Texts( - TranslationBase.of(context).selectPaymentOption, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff0000ff), - ), - ), - ), - Icon( - Icons.arrow_forward_ios, - size: 20, - color: Colors.grey.shade400, - ), - ], - ), - ), - ) - : Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_payment_option.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Container( - margin: EdgeInsets.symmetric(horizontal: 8), - padding: EdgeInsets.symmetric(horizontal: 4, vertical: 0), - decoration: new BoxDecoration( - color: Colors.grey.shade100, - shape: BoxShape.rectangle, - ), - child: Image.asset( - widget.model.getPaymentOptionImage(paymentOption), - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - ), - Expanded( - child: Container( - padding: EdgeInsets.symmetric(vertical: 0, horizontal: 6), - child: Texts( - widget.model.getPaymentOptionName(paymentOption), - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - ), - InkWell( - onTap: () => {_navigateToPaymentOption()}, - child: Texts( - TranslationBase.of(context).changeMethod, - fontSize: 12, - fontWeight: FontWeight.normal, - color: Color(0xff0000ff), - ), - ), - ], - ), - ), - ); - } -} - -class LakumWidget extends StatefulWidget { - final OrderPreviewViewModel model; - - LakumWidget(this.model); - - @override - _LakumWidgetState createState() => _LakumWidgetState(); -} - -class _LakumWidgetState extends State { - TextEditingController _pointsController = new TextEditingController(); - - @override - Widget build(BuildContext context) { - ProjectViewModel projectProvider = Provider.of(context); - - return Container( - color: Colors.white, - padding: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/lakum/lakum_checkout.png", - width: 30.0, - fit: BoxFit.scaleDown, - ), - Container( - decoration: BoxDecoration(color: Color(0x99ffffff)), - padding: const EdgeInsets.symmetric(horizontal: 8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - "${TranslationBase.of(context).lakumPoints}", - fontSize: 12, - fontWeight: FontWeight.bold, - ), - Texts( - "${widget.model.paymentCheckoutData.lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount}", - fontSize: 12, - fontWeight: FontWeight.normal, - ), - ], - ), - ), - Expanded( - child: Container( - decoration: BoxDecoration(color: Color(0x99ffffff)), - padding: const EdgeInsets.symmetric(horizontal: 8), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Texts( - "${TranslationBase.of(context).riyal}", - fontSize: 12, - fontWeight: FontWeight.bold, - ), - Container( - margin: projectProvider.isArabic - ? EdgeInsets.only(right: 4) - : EdgeInsets.only(left: 4), - width: 60, - height: 50, - child: TextField( - decoration: InputDecoration( - border: OutlineInputBorder( - borderSide: - BorderSide(color: Colors.black, width: 0.2), - gapPadding: 0, - borderRadius: projectProvider.isArabic - ? BorderRadius.only( - topRight: Radius.circular(8), - bottomRight: Radius.circular(8)) - : BorderRadius.only( - topLeft: Radius.circular(8), - bottomLeft: Radius.circular(8)), - ), - disabledBorder: OutlineInputBorder( - borderSide: - BorderSide(color: Colors.black, width: 0.4), - gapPadding: 0, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - bottomLeft: Radius.circular(8)), - ), - ), - controller: _pointsController, - keyboardType: TextInputType.number, - style: TextStyle( - fontSize: 14, - color: widget - .model - .paymentCheckoutData - .lacumInformation - .lakumInquiryInformationObjVersion - .pointsBalanceAmount > - 0 - ? Colors.black - : Colors.grey, - ), - enabled: widget - .model - .paymentCheckoutData - .lacumInformation - .lakumInquiryInformationObjVersion - .pointsBalanceAmount == - 0 - ? false - : true, - onChanged: (val) { - var value = int.tryParse(val); - if (value != null && - value <= - widget - .model - .paymentCheckoutData - .lacumInformation - .lakumInquiryInformationObjVersion - .pointsBalanceAmount) { - widget.model.paymentCheckoutData.usedLakumPoints = - value; - } else { - widget.model.paymentCheckoutData.usedLakumPoints = 0; - } - _pointsController.text = - "${widget.model.paymentCheckoutData.usedLakumPoints}"; - }, - ), - ), - Container( - height: 50, - padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12), - decoration: new BoxDecoration( - color: Color(0xff3666E0), - shape: BoxShape.rectangle, - borderRadius: projectProvider.isArabic - ? BorderRadius.only( - topLeft: Radius.circular(6), - bottomLeft: Radius.circular(6)) - : BorderRadius.only( - topRight: Radius.circular(6), - bottomRight: Radius.circular(6)), - border: Border.fromBorderSide(BorderSide( - color: Color(0xff3666E0), - width: 0.8, - )), - ), - child: Texts( - "${TranslationBase.of(context).use}", - fontSize: 12, - color: Colors.white, - fontWeight: FontWeight.bold, - ), - ), - ], - ), - ), - ), - ], - ), - ); - } -} - -class PaymentBottomWidget extends StatelessWidget { - final OrderPreviewViewModel model; - - BuildContext context; - MyInAppBrowser browser; - - PaymentBottomWidget(this.model); - - @override - Widget build(BuildContext context) { - final scaffold = Scaffold.of(context); - this.context = context; - OrderPreviewViewModel orderPreviewViewModel = Provider.of(context); - return Container( - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0), - child: orderPreviewViewModel.paymentCheckoutData.cartDataVisible - ? Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container( - margin: - EdgeInsets.symmetric(horizontal: 0, vertical: 4), - child: Row( - children: [ - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff929295), - ), - Padding( - padding: - const EdgeInsets.symmetric(horizontal: 4), - child: Texts( - "${TranslationBase.of(context).inclusiveVat}", - fontSize: 8, - color: Color(0xff929295), - fontWeight: FontWeight.w600, - ), - ), - ], - ), - ), - Texts( - "${model.cartResponse.quantityCount} ${TranslationBase.of(context).items}", - fontSize: 10, - color: Colors.grey, - fontWeight: FontWeight.bold, - ), - ], - ), - Container( - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - side: BorderSide( - color: Color(0xff929295), - width: 1, - ), - ), - onPressed: (orderPreviewViewModel.paymentCheckoutData.address != null && - orderPreviewViewModel.paymentCheckoutData.paymentOption != null) - ? () async { - await model.makeOrder(); - if (model.state == ViewState.Idle) { - AppToast.showSuccessToast( - message: - "Order has been placed successfully!!"); - openPayment( - model.orderListModel[0], model.user); - } else { - AppToast.showErrorToast(message: model.error); - } - Navigator.pop(context); - Navigator.pop(context); - } - : null, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 16), - child: new Text( - "${TranslationBase.of(context).proceedPay}", - style: new TextStyle( - color: (orderPreviewViewModel.paymentCheckoutData.address != null && - orderPreviewViewModel.paymentCheckoutData.paymentOption != null) - ? Colors.white - : Colors.grey.shade400, - fontWeight: FontWeight.bold, - fontSize: 12), - ), - ), - color: (orderPreviewViewModel.paymentCheckoutData.address != null && - orderPreviewViewModel.paymentCheckoutData.paymentOption != null) - ? Colors.green - : Color(0xff929295), - disabledColor: (orderPreviewViewModel.paymentCheckoutData.address != null && - orderPreviewViewModel.paymentCheckoutData.paymentOption != null) - ? Colors.green - : Color(0xff929295), - ), - ), - ], - ), - ) - : Container(), - ); - } - - openPayment( - OrderDetailModel order, - AuthenticatedUser authenticatedUser, - ) { - 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); - } - - onBrowserLoadStart(String url) { - print("onBrowserLoadStart"); - print(url); - - MyInAppBrowser.successURLS.forEach((element) { - if (url.contains(element)) { - if (browser.isOpened()) browser.close(); - MyInAppBrowser.isPaymentDone = true; - return; - } - }); - - MyInAppBrowser.errorURLS.forEach((element) { - if (url.contains(element)) { - if (browser.isOpened()) browser.close(); - MyInAppBrowser.isPaymentDone = false; - return; - } - }); - } - - onBrowserExit(AppoitmentAllHistoryResultList appo, bool isPaymentMade) { - print("onBrowserExit Called!!!!"); - if (isPaymentMade) { - AppToast.showSuccessToast( - message: "شكراً\nPayment status for your order is Paid"); - Navigator.pop(context); - Navigator.pop(context); - } else { - 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/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart similarity index 97% rename from lib/pages/pharmacies/screens/cart-order-page.dart rename to lib/pages/pharmacies/screens/cart-page/cart-order-page.dart index fe469b32..ef4904b2 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -1,13 +1,10 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCartResponse.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.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-order-preview.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-preview.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy-terms-conditions-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderItem.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/GestureIconButton.dart'; @@ -16,7 +13,6 @@ 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:http/http.dart'; import 'package:provider/provider.dart'; class CartOrderPage extends StatefulWidget { @@ -55,7 +51,8 @@ class _CartOrderPageState extends State { showHomeAppBarIcon: false, isShowDecPage: true, baseViewModel: model, - backButtonTab: widget.changeTab != null ? () => widget.changeTab(0) : null, + backButtonTab: + widget.changeTab != null ? () => widget.changeTab(0) : null, backgroundColor: Colors.white, body: !(model.cartResponse.shoppingCarts == null || model.cartResponse.shoppingCarts.length == 0) diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart new file mode 100644 index 00000000..25c02dd0 --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart @@ -0,0 +1,238 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/select_address_widget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.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:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import 'lakum_widget.dart'; + +class OrderPreviewPage extends StatefulWidget { + final List addresses; + + OrderPreviewPage(this.addresses); + + @override + _OrderPreviewPageState createState() => _OrderPreviewPageState(); +} + +class _OrderPreviewPageState extends State { + MyInAppBrowser browser; + bool isLoading = true; + + @override + void initState() { + super.initState(); + getData(); + } + + void getData() async { + if (isLoading) + await Provider.of(context, listen: false) + .getShoppingCart(); + setState(() { + isLoading = false; + }); + } + + @override + Widget build(BuildContext context) { + final mediaQuery = MediaQuery.of(context); + final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; + OrderPreviewViewModel model = Provider.of(context); + return AppScaffold( + appBarTitle: "${TranslationBase.of(context).checkOut}", + isShowAppBar: true, + isPharmacy: true, + isShowDecPage: false, + isLoading: isLoading, + isLocalLoader: true, + backgroundColor: Colors.white, + // baseViewModel: model, + body: Container( + color: Color(0xFFF1F1F1), + height: height * 0.90, + child: SingleChildScrollView( + child: Container( + color: Color(0xFFF1F1F1), + child: Column( + children: [ + SelectAddressWidget(model, widget.addresses), + SizedBox( + height: 10, + ), + SelectPaymentOptionWidget(model), + SizedBox( + height: 10, + ), + model.paymentCheckoutData.lacumInformation != null + ? Container( + child: Column( + children: [ + LakumWidget(model), + SizedBox( + height: 10, + ), + ], + ), + ) + : Container(), + Container( + color: Colors.white, + width: double.infinity, + padding: EdgeInsets.all(8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + TranslationBase.of(context).reviewOrder, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ...List.generate( + model.cartResponse.shoppingCarts != null + ? model.cartResponse.shoppingCarts.length + : 0, + (index) => ProductOrderPreviewItem( + model.cartResponse.shoppingCarts[index]), + ), + ], + ), + ), + Container( + width: double.infinity, + padding: EdgeInsets.all(8), + child: model.cartResponse.subtotal != null + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + TranslationBase.of(context).orderSummary, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + SizedBox( + height: 20, + ), + 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).shipping}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.totalAdditionalShippingCharge).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.subtotal).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ], + ), + SizedBox( + height: 10, + ), + ], + ) + : Container(), + ), + SizedBox( + height: model.cartResponse.shoppingCarts != null + ? height * 0.10 + : 0, + ) + ], + ), + ), + ), + ), + bottomSheet: Container( + height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, + color: Colors.white, + child: PaymentBottomWidget(model), + ), + ); + } +} diff --git a/lib/pages/pharmacies/screens/cart-page/lakum_widget.dart b/lib/pages/pharmacies/screens/cart-page/lakum_widget.dart new file mode 100644 index 00000000..cdd26ddc --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/lakum_widget.dart @@ -0,0 +1,187 @@ +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/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/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'; + +class LakumWidget extends StatefulWidget { + final OrderPreviewViewModel model; + + LakumWidget(this.model); + + @override + _LakumWidgetState createState() => _LakumWidgetState(); +} + +class _LakumWidgetState extends State { + TextEditingController _pointsController = new TextEditingController(); + + @override + Widget build(BuildContext context) { + ProjectViewModel projectProvider = Provider.of(context); + + return Container( + color: Colors.white, + padding: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/lakum/lakum_checkout.png", + width: 30.0, + fit: BoxFit.scaleDown, + ), + Container( + decoration: BoxDecoration(color: Color(0x99ffffff)), + padding: const EdgeInsets.symmetric(horizontal: 8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + "${TranslationBase.of(context).lakumPoints}", + fontSize: 12, + fontWeight: FontWeight.bold, + ), + Texts( + "${widget.model.paymentCheckoutData.lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount}", + fontSize: 12, + fontWeight: FontWeight.normal, + ), + ], + ), + ), + Expanded( + child: Container( + decoration: BoxDecoration(color: Color(0x99ffffff)), + padding: const EdgeInsets.symmetric(horizontal: 8), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Texts( + "${TranslationBase.of(context).riyal}", + fontSize: 12, + fontWeight: FontWeight.bold, + ), + Container( + margin: projectProvider.isArabic + ? EdgeInsets.only(right: 4) + : EdgeInsets.only(left: 4), + width: 60, + height: 50, + child: TextField( + decoration: InputDecoration( + border: OutlineInputBorder( + borderSide: + BorderSide(color: Colors.black, width: 0.2), + gapPadding: 0, + borderRadius: projectProvider.isArabic + ? BorderRadius.only( + topRight: Radius.circular(8), + bottomRight: Radius.circular(8)) + : BorderRadius.only( + topLeft: Radius.circular(8), + bottomLeft: Radius.circular(8)), + ), + disabledBorder: OutlineInputBorder( + borderSide: + BorderSide(color: Colors.black, width: 0.4), + gapPadding: 0, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + bottomLeft: Radius.circular(8)), + ), + ), + controller: _pointsController, + keyboardType: TextInputType.number, + style: TextStyle( + fontSize: 14, + color: widget + .model + .paymentCheckoutData + .lacumInformation + .lakumInquiryInformationObjVersion + .pointsBalanceAmount > + 0 + ? Colors.black + : Colors.grey, + ), + enabled: widget + .model + .paymentCheckoutData + .lacumInformation + .lakumInquiryInformationObjVersion + .pointsBalanceAmount == + 0 + ? false + : true, + onChanged: (val) { + var value = int.tryParse(val); + if (value != null && + value <= + widget + .model + .paymentCheckoutData + .lacumInformation + .lakumInquiryInformationObjVersion + .pointsBalanceAmount) { + widget.model.paymentCheckoutData.usedLakumPoints = + value; + } else { + widget.model.paymentCheckoutData.usedLakumPoints = 0; + } + _pointsController.text = + "${widget.model.paymentCheckoutData.usedLakumPoints}"; + }, + ), + ), + Container( + height: 50, + padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12), + decoration: new BoxDecoration( + color: Color(0xff3666E0), + shape: BoxShape.rectangle, + borderRadius: projectProvider.isArabic + ? BorderRadius.only( + topLeft: Radius.circular(6), + bottomLeft: Radius.circular(6)) + : BorderRadius.only( + topRight: Radius.circular(6), + bottomRight: Radius.circular(6)), + border: Border.fromBorderSide(BorderSide( + color: Color(0xff3666E0), + width: 0.8, + )), + ), + child: Texts( + "${TranslationBase.of(context).use}", + fontSize: 12, + color: Colors.white, + 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 new file mode 100644 index 00000000..e0063878 --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart @@ -0,0 +1,195 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; +import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.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/in_app_browser/InAppBrowser.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class PaymentBottomWidget extends StatelessWidget { + final OrderPreviewViewModel model; + + BuildContext context; + MyInAppBrowser browser; + + PaymentBottomWidget(this.model); + + @override + Widget build(BuildContext context) { + final scaffold = Scaffold.of(context); + this.context = context; + OrderPreviewViewModel orderPreviewViewModel = Provider.of(context); + return Container( + margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0), + child: orderPreviewViewModel.paymentCheckoutData.cartDataVisible + ? Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + margin: + EdgeInsets.symmetric(horizontal: 0, vertical: 4), + child: Row( + children: [ + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff929295), + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4), + child: Texts( + "${TranslationBase.of(context).inclusiveVat}", + fontSize: 8, + color: Color(0xff929295), + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + Texts( + "${model.cartResponse.quantityCount} ${TranslationBase.of(context).items}", + fontSize: 10, + color: Colors.grey, + fontWeight: FontWeight.bold, + ), + ], + ), + Container( + child: RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + side: BorderSide( + color: Color(0xff929295), + width: 1, + ), + ), + onPressed: (orderPreviewViewModel + .paymentCheckoutData.address != + null && + orderPreviewViewModel + .paymentCheckoutData.paymentOption != + null) + ? () async { + await model.makeOrder(); + if (model.state == ViewState.Idle) { + AppToast.showSuccessToast( + message: + "Order has been placed successfully!!"); + openPayment( + model.orderListModel[0], model.user); + } else { + AppToast.showErrorToast(message: model.error); + } + Navigator.pop(context); + Navigator.pop(context); + } + : null, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 16), + child: new Text( + "${TranslationBase.of(context).proceedPay}", + style: new TextStyle( + color: (orderPreviewViewModel + .paymentCheckoutData.address != + null && + orderPreviewViewModel.paymentCheckoutData + .paymentOption != + null) + ? Colors.white + : Colors.grey.shade400, + fontWeight: FontWeight.bold, + fontSize: 12), + ), + ), + color: + (orderPreviewViewModel.paymentCheckoutData.address != + null && + orderPreviewViewModel + .paymentCheckoutData.paymentOption != + null) + ? Colors.green + : Color(0xff929295), + disabledColor: + (orderPreviewViewModel.paymentCheckoutData.address != + null && + orderPreviewViewModel + .paymentCheckoutData.paymentOption != + null) + ? Colors.green + : Color(0xff929295), + ), + ), + ], + ), + ) + : Container(), + ); + } + + openPayment( + OrderDetailModel order, + AuthenticatedUser authenticatedUser, + ) { + 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); + } + + onBrowserLoadStart(String url) { + print("onBrowserLoadStart"); + print(url); + + MyInAppBrowser.successURLS.forEach((element) { + if (url.contains(element)) { + if (browser.isOpened()) browser.close(); + MyInAppBrowser.isPaymentDone = true; + return; + } + }); + + MyInAppBrowser.errorURLS.forEach((element) { + if (url.contains(element)) { + if (browser.isOpened()) browser.close(); + MyInAppBrowser.isPaymentDone = false; + return; + } + }); + } + + onBrowserExit(AppoitmentAllHistoryResultList appo, bool isPaymentMade) { + print("onBrowserExit Called!!!!"); + if (isPaymentMade) { + AppToast.showSuccessToast( + message: "شكراً\nPayment status for your order is Paid"); + Navigator.pop(context); + Navigator.pop(context); + } else { + 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/pharmacies/screens/cart-page/select_address_widget.dart b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart new file mode 100644 index 00000000..bf958a36 --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart @@ -0,0 +1,226 @@ +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/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/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'; + +class SelectAddressWidget extends StatefulWidget { + final OrderPreviewViewModel model; + final List addresses; + + SelectAddressWidget(this.model, this.addresses); + + @override + _SelectAddressWidgetState createState() => _SelectAddressWidgetState(); +} + +class _SelectAddressWidgetState extends State { + Addresses address; + + _navigateToAddressPage() { + Navigator.push(context, FadePage(page: PharmacyAddressesPage())) + .then((result) { + if (result != null) { + address = result; + widget.model.paymentCheckoutData.address = address; + widget.model.getInformationsByAddress(); + } + + /* setState(() { + if (result != null) { + address = result; + widget.model.paymentCheckoutData.address = address; + widget.model.getInformationsByAddress(); + } + })*/ + }); + } + + @override + void initState() { + if (widget.model.paymentCheckoutData.address != null) { + address = widget.model.paymentCheckoutData.address; + } + super.initState(); + } + + @override + Widget build(BuildContext context) { + OrderPreviewViewModel model = Provider.of(context); + return Container( + color: Colors.white, + child: address == null + ? InkWell( + onTap: () => {_navigateToAddressPage()}, + child: Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_address.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Expanded( + child: Container( + padding: + EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + TranslationBase.of(context).selectAddress, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff0000ff), + ), + ), + ), + Icon( + Icons.arrow_forward_ios, + size: 20, + color: Colors.grey.shade400, + ), + ], + ), + ), + ) + : Container( + child: Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_mark.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Expanded( + child: Container( + padding: EdgeInsets.symmetric( + vertical: 0, horizontal: 6), + child: Texts( + TranslationBase.of(context).shippingAddress, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + ), + InkWell( + onTap: () => {_navigateToAddressPage()}, + child: Texts( + TranslationBase.of(context).changeAddress, + fontSize: 12, + fontWeight: FontWeight.normal, + color: Color(0xff0000ff), + ), + ), + ], + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Texts( + "${address.firstName} ${address.lastName}", + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Texts( + "${address.address1} ${address.address2} ${address.address2},, ${address.city}, ${address.country} ${address.zipPostalCode}", + fontSize: 12, + fontWeight: FontWeight.normal, + color: Colors.grey.shade500, + ), + ), + Row( + children: [ + Container( + margin: const EdgeInsets.only(right: 8), + child: Icon( + Icons.phone, + size: 20, + color: Colors.black, + ), + ), + Texts( + "${address.phoneNumber}", + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.grey, + ), + ], + ), + Container( + margin: EdgeInsets.symmetric(vertical: 8), + child: SizedBox( + height: 2, + width: double.infinity, + child: Container( + color: Color(0xffefefef), + ), + ), + ), + Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_truck.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Container( + padding: + EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + "${TranslationBase.of(context).shipBy}", + fontSize: 12, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + Container( + child: Image.asset( + model.paymentCheckoutData.shippingOption == null + ? "" + : 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, + ), + margin: EdgeInsets.symmetric(horizontal: 8), + ), + ], + ), + ], + ), + ), + ), // ic_shipping_mark.png + ); + } +} 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 new file mode 100644 index 00000000..9234bb38 --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart @@ -0,0 +1,146 @@ +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/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/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'; + +class SelectPaymentOptionWidget extends StatefulWidget { + final OrderPreviewViewModel model; + + SelectPaymentOptionWidget(this.model); + + @override + _SelectPaymentOptionWidgetState createState() => + _SelectPaymentOptionWidgetState(); +} + +class _SelectPaymentOptionWidgetState extends State { + PaymentOption paymentOption; + + _navigateToPaymentOption() { + Navigator.push(context, FadePage(page: PaymentMethodSelectPage())) + .then((result) => { + setState(() { + if (result != null) { + paymentOption = result; + widget.model.paymentCheckoutData.paymentOption = + paymentOption; + } + }) + }); + } + + @override + void initState() { + if (widget.model.paymentCheckoutData.paymentOption != null) { + paymentOption = widget.model.paymentCheckoutData.paymentOption; + } + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Container( + color: Colors.white, + child: paymentOption == null + ? InkWell( + onTap: () => {_navigateToPaymentOption()}, + child: Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_payment_option.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Expanded( + child: Container( + padding: + EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + TranslationBase.of(context).selectPaymentOption, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff0000ff), + ), + ), + ), + Icon( + Icons.arrow_forward_ios, + size: 20, + color: Colors.grey.shade400, + ), + ], + ), + ), + ) + : Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_payment_option.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Container( + margin: EdgeInsets.symmetric(horizontal: 8), + padding: EdgeInsets.symmetric(horizontal: 4, vertical: 0), + decoration: new BoxDecoration( + color: Colors.grey.shade100, + shape: BoxShape.rectangle, + ), + child: Image.asset( + widget.model.getPaymentOptionImage(paymentOption), + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + ), + Expanded( + child: Container( + padding: EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + widget.model.getPaymentOptionName(paymentOption), + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + ), + InkWell( + onTap: () => {_navigateToPaymentOption()}, + child: Texts( + TranslationBase.of(context).changeMethod, + fontSize: 12, + fontWeight: FontWeight.normal, + color: Color(0xff0000ff), + ), + ), + ], + ), + ), + ); + } +} 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 583c904f..d936b51c 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -10,7 +10,7 @@ import 'package:hexcolor/hexcolor.dart'; import '../../../../../locator.dart'; import '../../../../../routes.dart'; -import '../../cart-order-page.dart'; +import '../../cart-page/cart-order-page.dart'; import '../product-detail.dart'; class FooterWidget extends StatefulWidget { 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..b9612925 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 @@ -12,7 +12,7 @@ import 'package:provider/provider.dart'; import '../../../../../locator.dart'; import '../../../compare-list.dart'; -import '../../cart-order-page.dart'; +import '../../cart-page/cart-order-page.dart'; import 'icon_with_bg.dart'; class ProductAppBar extends StatelessWidget with PreferredSizeWidget { diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index f5ce682a..f80acf75 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -9,7 +9,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/pharmacies/screens/cart-order-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index b6f73823..78ea12b0 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -1,6 +1,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/order/ProductReview.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; From 66acda38a341824f08734ccd3edac2c59c369a66 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 12 Oct 2021 11:22:39 +0300 Subject: [PATCH 63/67] add to cart fix --- .../product-details/footor/footer-widget.dart | 8 ++-- .../pharmacy/bottom_nav_pharmacy_item.dart | 48 ++++++++++++------- 2 files changed, 35 insertions(+), 21 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 583c904f..b941fd33 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -185,7 +185,7 @@ class _FooterWidgetState extends State { width: MediaQuery.of(context).size.width * 0.45, child: SecondaryButton( label: TranslationBase.of(context).addToCart.toUpperCase(), - disabled: !widget.isAvailable && widget.quantity > 0 || + disabled: !widget.isAvailable && widget.quantity == 0 || widget.quantity > widget.quantityLimit || widget.item.rxMessage != null, disableColor: Color(0xFF4CAF50), @@ -196,9 +196,9 @@ class _FooterWidgetState extends State { ); } else await widget.addToCartFunction( - quantity: widget.quantity, - itemID: widget.item.id, - model: widget.model); + quantity: widget.quantity, + itemID: widget.item.id, + model: widget.model); }, fontWeight: FontWeight.w600, borderColor: Color(0xFF4CAF50), diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart index 94e260d0..880615a4 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart @@ -47,7 +47,7 @@ class BottomNavPharmacyItem extends StatelessWidget { splashColor: Colors.transparent, onTap: () { if (!Provider.of(context, listen: false) - .isLogin && + .isLogin && (currentIndex == 2 || currentIndex == 3)) Navigator.push( context, @@ -65,19 +65,19 @@ class BottomNavPharmacyItem extends StatelessWidget { ), currentIndex == index ? Divider( - color: Color(0xff5AB145), - thickness: 3.5, - ) + color: Color(0xff5AB145), + thickness: 3.5, + ) : Divider( - thickness: 0, - ), + thickness: 0, + ), Container( child: Icon(currentIndex == index ? activeIcon : icon, color: isHome ? Color(0xff5AB145) : currentIndex == index - ? Colors.grey - : Colors.grey, + ? Colors.grey + : Colors.grey, size: 22.0), ), SizedBox( @@ -89,26 +89,40 @@ class BottomNavPharmacyItem extends StatelessWidget { title, textAlign: TextAlign.center, color: currentIndex == index ? Colors.grey : Colors.grey, - fontWeight: - currentIndex == index ? FontWeight.bold : FontWeight.w400, + fontWeight: currentIndex == index + ? FontWeight.bold + : FontWeight.w400, fontSize: currentIndex == index ? 13 : 11, ), ], ), ), ), - if(currentIndex == 3 &&Provider.of(context, listen: false).cartResponse.quantityCount !=0) + if (currentIndex == 3 && + Provider.of(context, listen: false) + .cartResponse + .quantityCount != + 0) Positioned( - top: 5, right: -3.5, + top: 11.5, + right: -4.5, child: Container( decoration: BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.circular(15), - + color: Colors.red, + borderRadius: BorderRadius.circular(15), ), - padding: EdgeInsets.only(left: 5, right: 4.5), + padding: EdgeInsets.only(left: 7, right: 6.5), height: 18, - child: Center(child: Texts(Provider.of(context, listen: false).cartResponse.quantityCount.toString(), style: "caption", medium: true, color: Colors.white,)), + child: Center( + child: Texts( + Provider.of(context, listen: false) + .cartResponse + .quantityCount + .toString(), + style: "caption", + medium: true, + color: Colors.white, + )), ), ) ], From a8fb7152b174c99e441010a76815f86afadbe48c Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 12 Oct 2021 11:27:47 +0300 Subject: [PATCH 64/67] add to cart fix --- .../pharmacy/bottom_nav_pharmacy_item.dart | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart index acfaa63a..ff0cac32 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart @@ -50,7 +50,7 @@ class BottomNavPharmacyItem extends StatelessWidget { splashColor: Colors.transparent, onTap: () { if (!Provider.of(context, listen: false) - .isLogin && + .isLogin && (currentIndex == 2 || currentIndex == 3)) Navigator.push( context, @@ -68,19 +68,19 @@ class BottomNavPharmacyItem extends StatelessWidget { ), currentIndex == index ? Divider( - color: Color(0xff5AB145), - thickness: 3.5, - ) + color: Color(0xff5AB145), + thickness: 3.5, + ) : Divider( - thickness: 0, - ), + thickness: 0, + ), Container( child: Icon(currentIndex == index ? activeIcon : icon, color: isHome ? Color(0xff5AB145) : currentIndex == index - ? Colors.grey - : Colors.grey, + ? Colors.grey + : Colors.grey, size: 22.0), ), SizedBox( @@ -92,8 +92,9 @@ class BottomNavPharmacyItem extends StatelessWidget { title, textAlign: TextAlign.center, color: currentIndex == index ? Colors.grey : Colors.grey, - fontWeight: - currentIndex == index ? FontWeight.bold : FontWeight.w400, + fontWeight: currentIndex == index + ? FontWeight.bold + : FontWeight.w400, fontSize: currentIndex == index ? 13 : 11, ), ], @@ -110,13 +111,18 @@ class BottomNavPharmacyItem extends StatelessWidget { right: -4.5, child: Container( decoration: BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.circular(15), - + color: Colors.red, + borderRadius: BorderRadius.circular(15), ), padding: EdgeInsets.only(left: 7, right: 6.5), height: 18, - child: Center(child: Texts(orderPreviewViewModel.cartResponse.quantityCount.toString(), style: "caption", medium: true, color: Colors.white,)), + child: Center( + child: Texts( + orderPreviewViewModel.cartResponse.quantityCount.toString(), + style: "caption", + medium: true, + color: Colors.white, + )), ), ) ], From 30a1353be637374a2d2fee81d3c39e6e2b4e6cbf Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Wed, 13 Oct 2021 11:19:42 +0300 Subject: [PATCH 65/67] fixed brands design and recommended products issues --- lib/pages/final_products_page.dart | 14 ++++ lib/pages/landing/landing_page_pharmcy.dart | 1 + lib/pages/parent_categorise_page.dart | 52 +++++++------ lib/pages/pharmacies/product-brands.dart | 2 +- .../pharmacies/screens/cart-order-page.dart | 4 +- .../product-details/product-detail.dart | 7 +- .../product-details/recommended_products.dart | 75 ++++++------------- lib/pages/sub_categorise_page.dart | 14 ++++ 8 files changed, 89 insertions(+), 80 deletions(-) diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index fff272b3..b4dc51bc 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; @@ -605,6 +606,19 @@ class _FinalProductsPageState extends State { ], ), ), + Container( + child: IconButton( + icon: Icon(Icons.shopping_cart, + size: 15, + color: Colors.blue,), + onPressed: () async { + Navigator.push( + context, + FadePage(page: CartOrderPage()), + ); + }, + ), + ), ], ), ), diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 41c4b694..cbc7fc01 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -130,6 +130,7 @@ class _LandingPagePharmacyState extends State { PharmacyCategorisePage(), PharmacyProfilePage(), CartOrderPage(), + ], ), bottomNavigationBar: BottomNavPharmacyBar( diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 0be70de5..07bd20fa 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; @@ -35,8 +36,9 @@ class ParentCategorisePage extends StatefulWidget { class _ParentCategorisePageState extends State { String id; String titleName; + final dynamic productID; - _ParentCategorisePageState({this.id, this.titleName}); + _ParentCategorisePageState({this.id, this.titleName, this.productID}); Map values = {'huusam': false, 'ali': false, 'noor': false}; bool checkedBrands = false; @@ -1119,28 +1121,11 @@ class _ParentCategorisePageState extends State { padding: const EdgeInsets .only( - top: 1, - bottom: 1), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Texts( - "SAR ${model.parentProducts[index].price}", - bold: true, - fontSize: 14, - ), - Container( - child: IconButton( - icon: Icon(FontAwesomeIcons.shoppingCart, size: 15), - onPressed: () async { - Navigator.push( - context, - FadePage(page: CartOrderPage()), - ); - }, - ), - ), - ], + top: 4, bottom: 4), + child: Texts( + "SAR ${model.parentProducts[index].price}", + bold: true, + fontSize: 14, ), ), Row( @@ -1172,6 +1157,22 @@ class _ParentCategorisePageState extends State { ], ), ), + Container( + child: IconButton( + icon: Icon(Icons.shopping_cart, + size: 15, + color: Colors.blue,), + onPressed: () async { + GifLoaderDialogUtils.showMyDialog(context); + await addToCartFunction(1, productID); + GifLoaderDialogUtils.hideDialog(context); + Navigator.push( + context, + FadePage(page: CartOrderPage()), + ); + }, + ), + ), ], ), ), @@ -1238,4 +1239,9 @@ class _ParentCategorisePageState extends State { } return false; } + + addToCartFunction(quantity, itemID) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.addToCartData(quantity, itemID); + } } diff --git a/lib/pages/pharmacies/product-brands.dart b/lib/pages/pharmacies/product-brands.dart index 42a78d5c..fb3e38e4 100644 --- a/lib/pages/pharmacies/product-brands.dart +++ b/lib/pages/pharmacies/product-brands.dart @@ -97,7 +97,7 @@ class _ProductBrandsPageState extends State { height: 10, ), Container( - height: 290, + height: 420, width: double.infinity, color: Colors.white, child: ListView.builder( diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index 6f63927d..19acc5c5 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -189,7 +189,7 @@ class _CartOrderPageState extends State { fontWeight: FontWeight.bold, ), Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.bold, @@ -368,7 +368,7 @@ class _OrderBottomWidgetState extends State { child: Row( children: [ Texts( - "${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotal).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotalWithVat).toStringAsFixed(2)}", fontSize: projectProvider.isArabic ? 12 : 14, fontWeight: FontWeight.bold, diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index ef3b7d8a..83a76a19 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -313,7 +313,12 @@ class __ProductDetailPageState extends State { SizedBox( height: 10, ), - RecommendedProducts(product: widget.product) + RecommendedProducts(product: widget.product,productDetailViewModel: model, + addToWishlistFunction: (itemID) async { + await addToWishlistFunction(itemID: itemID, model: model); + }, deleteFromWishlistFunction: (itemID) async { + await deleteFromWishlistFunction(itemID: itemID, model: model); + },) ], ), ), diff --git a/lib/pages/pharmacies/screens/product-details/recommended_products.dart b/lib/pages/pharmacies/screens/product-details/recommended_products.dart index 2070a29e..6e0fbba9 100644 --- a/lib/pages/pharmacies/screens/product-details/recommended_products.dart +++ b/lib/pages/pharmacies/screens/product-details/recommended_products.dart @@ -1,9 +1,11 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; 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/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; @@ -24,6 +26,9 @@ class RecommendedProducts extends StatefulWidget { final Function addToWishlistFunction; final Function deleteFromWishlistFunction; + AuthenticatedUserObject authenticatedUserObject = + locator(); + RecommendedProducts( {Key key, this.product, @@ -134,63 +139,27 @@ class _RecommendedProductsState extends State { child: Align( alignment: Alignment.topRight, child: IconButton( - icon: Icon(model - .recommendedProductList[ - index] - .isinwishlist != - true - ? Icons.favorite_border - : Icons.favorite), - color: model - .recommendedProductList[ - index] - .isinwishlist != - true - ? Colors.grey - : Colors.red, + icon: Icon(model.recommendedProductList[index].isinwishlist != true + ? Icons.favorite_border : Icons.favorite), + color: model.recommendedProductList[index].isinwishlist != true + ? Colors.grey : Colors.red, onPressed: () async { - if (widget.customerId != null) { - if (!widget.isInWishList && - model - .recommendedProductList[ - index] - .isinwishlist != - true) { - GifLoaderDialogUtils - .showMyDialog(context); - await widget.addToWishlistFunction( - itemID: model - .recommendedProductList[ - index] - .id, - model: widget - .productDetailViewModel); -// checkWishlist(); - GifLoaderDialogUtils - .hideDialog(context); + if (widget.authenticatedUserObject.isLogin + ) { + if (!widget.isInWishList && model.recommendedProductList[index].isinwishlist != true) { + GifLoaderDialogUtils.showMyDialog(context); + await widget.addToWishlistFunction(model.recommendedProductList[index].id, + ); + GifLoaderDialogUtils.hideDialog(context); setState(() { - model - .recommendedProductList[ - index] - .isinwishlist = true; - }); + model.recommendedProductList[index].isinwishlist = true;}); } else { - GifLoaderDialogUtils - .showMyDialog(context); - await widget.deleteFromWishlistFunction( - itemID: model - .recommendedProductList[ - index] - .id, - model: widget - .productDetailViewModel); - GifLoaderDialogUtils - .hideDialog(context); + GifLoaderDialogUtils.showMyDialog(context); + await widget.deleteFromWishlistFunction(model.recommendedProductList[index].id, + ); + GifLoaderDialogUtils.hideDialog(context); setState(() { - model - .recommendedProductList[ - index] - .isinwishlist = false; + model.recommendedProductList[index].isinwishlist = false; }); } } else { diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index bfa7e343..92115cd3 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; @@ -860,6 +861,19 @@ class _SubCategorisePageState extends State { ], ), ), + Container( + child: IconButton( + icon: Icon(Icons.shopping_cart, + size: 15, + color: Colors.blue,), + onPressed: () async { + Navigator.push( + context, + FadePage(page: CartOrderPage()), + ); + }, + ), + ), ], ), ), From e2763a5bd592a40d64aa5e4d1741b2412a278ebb Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Sun, 17 Oct 2021 09:37:24 +0300 Subject: [PATCH 66/67] fixed cart shopping issues --- .../pharmacyModule/OrderPreviewViewModel.dart | 11 +++++++ lib/pages/final_products_page.dart | 18 ++++++++++- lib/pages/parent_categorise_page.dart | 32 ++++++++++++++----- .../pharmacies/screens/cart-order-page.dart | 14 ++++++-- .../pharmacies/widgets/ProductOrderItem.dart | 17 ++++++++-- lib/pages/sub_categorise_page.dart | 17 +++++++++- 6 files changed, 94 insertions(+), 15 deletions(-) diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index 7c86f6b7..48241bf3 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -215,6 +215,17 @@ class OrderPreviewViewModel extends BaseViewModel { setState(ViewState.Idle); } } + + // bool outOfStock = false; + bool checkCardQuantity(){ + bool outOfStock = false; + for (int i = 0; i (); FinalProductsPage({this.id, this.productType = 1}); @@ -606,19 +612,24 @@ class _FinalProductsPageState extends State { ], ), ), + + widget.authenticatedUserObject.isLogin? Container( child: IconButton( icon: Icon(Icons.shopping_cart, size: 15, color: Colors.blue,), onPressed: () async { + GifLoaderDialogUtils.showMyDialog(context); + await addToCartFunction(1, model.finalProducts[index].id); + GifLoaderDialogUtils.hideDialog(context); Navigator.push( context, FadePage(page: CartOrderPage()), ); }, ), - ), + ):Container(), ], ), ), @@ -665,4 +676,9 @@ class _FinalProductsPageState extends State { ), )); } + + addToCartFunction(quantity, itemID) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.addToCartData(quantity, itemID); + } } diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 07bd20fa..5c37c837 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -1,8 +1,11 @@ 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'; 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-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart'; @@ -22,10 +25,14 @@ import 'package:provider/provider.dart'; import 'package:diplomaticquarterapp/pages/sub_categories_modalsheet.dart'; import 'base/base_view.dart'; + class ParentCategorisePage extends StatefulWidget { String id; String titleName; + AuthenticatedUserObject authenticatedUserObject = + locator(); + ParentCategorisePage({this.id, this.titleName}); @override @@ -38,7 +45,9 @@ 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; @@ -1157,6 +1166,8 @@ class _ParentCategorisePageState extends State { ], ), ), + + widget.authenticatedUserObject.isLogin ? Container( child: IconButton( icon: Icon(Icons.shopping_cart, @@ -1164,15 +1175,15 @@ class _ParentCategorisePageState extends State { color: Colors.blue,), onPressed: () async { GifLoaderDialogUtils.showMyDialog(context); - await addToCartFunction(1, productID); + await addToCartFunction(1, model.parentProducts[index].id); GifLoaderDialogUtils.hideDialog(context); Navigator.push( context, FadePage(page: CartOrderPage()), ); }, - ), - ), + ) + ): Container(), ], ), ), @@ -1220,6 +1231,13 @@ class _ParentCategorisePageState extends State { ), ), )); + + + } + + addToCartFunction(quantity, itemID) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.addToCartData(quantity, itemID); } bool isEntityListSelected(CategoriseParentModel masterKey) { @@ -1240,8 +1258,6 @@ class _ParentCategorisePageState extends State { return false; } - addToCartFunction(quantity, itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID); - } + + } diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index 6fde76ae..63b72511 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -21,17 +21,24 @@ import 'package:provider/provider.dart'; import 'cart-page/cart-order-preview.dart'; class CartOrderPage extends StatefulWidget { - const CartOrderPage({Key key}) : super(key: key); + + + const CartOrderPage({ Key key}) + : super(key: key); + + @override _CartOrderPageState createState() => _CartOrderPageState(); } class _CartOrderPageState extends State { bool isLoading = true; + @override void initState() { super.initState(); getData(); + } @override @@ -269,7 +276,7 @@ class OrderBottomWidget extends StatefulWidget { class _OrderBottomWidgetState extends State { bool isAgree = false; - + bool outOfStock = false; @override Widget build(BuildContext context) { ProjectViewModel projectProvider = Provider.of(context); @@ -391,6 +398,7 @@ class _OrderBottomWidgetState extends State { ), RaisedButton( onPressed: isAgree +// && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0 ? () => { Navigator.push( context, @@ -398,7 +406,7 @@ class _OrderBottomWidgetState extends State { page: OrderPreviewPage(widget.addresses))) } - : null, + : Text("remove item " ), child: new Text( "${TranslationBase.of(context).checkOut}", style: new TextStyle( diff --git a/lib/pages/pharmacies/widgets/ProductOrderItem.dart b/lib/pages/pharmacies/widgets/ProductOrderItem.dart index d7a82cc6..cb7c59fd 100644 --- a/lib/pages/pharmacies/widgets/ProductOrderItem.dart +++ b/lib/pages/pharmacies/widgets/ProductOrderItem.dart @@ -45,6 +45,7 @@ class _ProductOrderItemState extends State { ), title: Container( child: Row( +// widget.item.product.stock_quantity===0 crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ @@ -166,10 +167,22 @@ class _ProductOrderItemState extends State { "$_totalPrice ${projectProvider.isArabic ? widget.item.currencyn : widget.item.currency}", fontSize: 12, fontWeight: FontWeight.bold, - ) + ), + widget.item.product.stockQuantity == 0 ? + Texts( + projectProvider.isArabic + ? widget.item.product.stockAvailabilityn + : widget.item.product.stockAvailability, + fontWeight: FontWeight.normal, + fontSize: 13, + color:Colors.red, + + ): Texts(""), ], ), - ) + ), + + ], ), ) diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 92115cd3..cc8db925 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -1,5 +1,8 @@ import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; +import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -21,6 +24,9 @@ class SubCategorisePage extends StatefulWidget { String title; String parentId; + AuthenticatedUserObject authenticatedUserObject = + locator(); + SubCategorisePage({this.id, this.parentId, this.title}); @override @@ -861,19 +867,24 @@ class _SubCategorisePageState extends State { ], ), ), + + widget.authenticatedUserObject.isLogin? Container( child: IconButton( icon: Icon(Icons.shopping_cart, size: 15, color: Colors.blue,), onPressed: () async { + GifLoaderDialogUtils.showMyDialog(context); + await addToCartFunction(1, model.subProducts[index].id); + GifLoaderDialogUtils.hideDialog(context); Navigator.push( context, FadePage(page: CartOrderPage()), ); }, ), - ), + ):Container(), ], ), ), @@ -1137,4 +1148,8 @@ class _SubCategorisePageState extends State { } return false; } + addToCartFunction(quantity, itemID) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.addToCartData(quantity, itemID); + } } From 9cf0794cf6d30f4a7eab2fdac530df8714b40ca3 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Mon, 18 Oct 2021 09:42:08 +0300 Subject: [PATCH 67/67] Fixed out of stuck items issues --- lib/config/localized_values.dart | 2 + .../pharmacyModule/OrderPreviewViewModel.dart | 18 +++---- lib/pages/final_products_page.dart | 20 +++++--- lib/pages/parent_categorise_page.dart | 37 +++++++++------ .../pharmacies/screens/cart-order-page.dart | 47 +++++++++++++++---- lib/pages/sub_categorise_page.dart | 44 +++++++++-------- lib/uitl/translations_delegate_base.dart | 2 + 7 files changed, 112 insertions(+), 58 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 3979e982..ee86ca74 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1091,6 +1091,8 @@ const Map localizedValues = { "camera-permission": {"en": "Camera", "ar": "الكاميرا"}, "location-permission": {"en": "Location", "ar": "تحديد المواقع"}, + "needPrescription": {"en": "This product requires a prescription", "ar": " هذا المنتج يتطلب وصفة طبية"}, + "outOfStockMsg": {"en": "You have added product which is out of stock now, Please remove that!", "ar": "لقد قمت بإضافة المنتج الذي نفذ من المخزون الآن. يرجى إزالة ذلك"}, "accessibility": {"en": "Accessibility Mode", "ar": "وضع امكانية الوصول"}, "orderStatus": {"en": "Order Status", "ar": "حالة الطلب"}, "CancelOrder": {"en": "Cancel Order", "ar": "الغاء الطلب"}, diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index 48241bf3..0a03b2ca 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -42,9 +42,11 @@ class OrderPreviewViewModel extends BaseViewModel { getShoppingCart(); } } - void update(){ + + void update() { notifyListeners(); } + Future getShoppingCart() async { // setState(ViewState.Busy); // GifLoaderDialogUtils.showMyDialog( @@ -61,7 +63,7 @@ class OrderPreviewViewModel extends BaseViewModel { } // GifLoaderDialogUtils.hideDialog( // locator().navigatorKey.currentContext); - setState(ViewState.Idle); + setState(ViewState.Idle); } } @@ -216,15 +218,15 @@ class OrderPreviewViewModel extends BaseViewModel { } } - // bool outOfStock = false; - bool checkCardQuantity(){ - bool outOfStock = false; - for (int i = 0; i { context) .size .width / - 3.5 + 5.3 : 0, padding: EdgeInsets.all( @@ -613,21 +614,28 @@ class _FinalProductsPageState extends State { ), ), - widget.authenticatedUserObject.isLogin? - Container( + widget.authenticatedUserObject.isLogin + ? Container( child: IconButton( icon: Icon(Icons.shopping_cart, - size: 15, + size: 18, color: Colors.blue,), onPressed: () async { GifLoaderDialogUtils.showMyDialog(context); + if(model.finalProducts[index].rxMessage == null){ await addToCartFunction(1, model.finalProducts[index].id); - GifLoaderDialogUtils.hideDialog(context); +// GifLoaderDialogUtils.hideDialog(context); Navigator.push( context, FadePage(page: CartOrderPage()), ); - }, + } + else{ + AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); + } + GifLoaderDialogUtils.hideDialog(context); + } + ), ):Container(), ], diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 5c37c837..1ac20946 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -9,6 +9,7 @@ import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/sub_categorise_page.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/widgets/buttons/button.dart'; @@ -1047,7 +1048,7 @@ class _ParentCategorisePageState extends State { context) .size .width / - 5 + 5.3 : 0, padding: EdgeInsets.all(4), @@ -1169,20 +1170,26 @@ class _ParentCategorisePageState extends State { widget.authenticatedUserObject.isLogin ? Container( - child: IconButton( - icon: Icon(Icons.shopping_cart, - size: 15, - color: Colors.blue,), - onPressed: () async { - GifLoaderDialogUtils.showMyDialog(context); - await addToCartFunction(1, model.parentProducts[index].id); - GifLoaderDialogUtils.hideDialog(context); - Navigator.push( - context, - FadePage(page: CartOrderPage()), - ); - }, - ) + child: IconButton( + icon: Icon(Icons.shopping_cart, + size: 18, + color: Colors.blue,), + onPressed: () async { + GifLoaderDialogUtils.showMyDialog(context); + if(model.parentProducts[index].rxMessage == null){ + await addToCartFunction(1, model.parentProducts[index].id); + Navigator.push( + context, + FadePage(page: CartOrderPage()), + ); + } + else{ + AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); + } + GifLoaderDialogUtils.hideDialog(context); + } + + ), ): Container(), ], ), diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index 63b72511..f9c928eb 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/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/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'; @@ -276,7 +277,7 @@ class OrderBottomWidget extends StatefulWidget { class _OrderBottomWidgetState extends State { bool isAgree = false; - bool outOfStock = false; + @override Widget build(BuildContext context) { ProjectViewModel projectProvider = Provider.of(context); @@ -400,23 +401,49 @@ class _OrderBottomWidgetState extends State { onPressed: isAgree // && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0 ? () => { - Navigator.push( - context, - FadePage( - page: - OrderPreviewPage(widget.addresses))) - } - : Text("remove item " ), + 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(0xff005aff), disabledColor: Color(0xff005aff), - ), + ) +// 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), +// ) ], ), ), diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index cc8db925..3fb1574f 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_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-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/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; @@ -867,24 +868,6 @@ class _SubCategorisePageState extends State { ], ), ), - - widget.authenticatedUserObject.isLogin? - Container( - child: IconButton( - icon: Icon(Icons.shopping_cart, - size: 15, - color: Colors.blue,), - onPressed: () async { - GifLoaderDialogUtils.showMyDialog(context); - await addToCartFunction(1, model.subProducts[index].id); - GifLoaderDialogUtils.hideDialog(context); - Navigator.push( - context, - FadePage(page: CartOrderPage()), - ); - }, - ), - ):Container(), ], ), ), @@ -967,7 +950,7 @@ class _SubCategorisePageState extends State { context) .size .width / - 5 + 5.3 : 0, padding: EdgeInsets.all(4), @@ -1082,6 +1065,29 @@ class _SubCategorisePageState extends State { ], ), ), + widget.authenticatedUserObject.isLogin? + Container( + child: IconButton( + icon: Icon(Icons.shopping_cart, + size: 18, + color: Colors.blue,), + onPressed: () async { + GifLoaderDialogUtils.showMyDialog(context); + if(model.subProducts[index].rxMessage == null){ + await addToCartFunction(1, model.subProducts[index].id); +// GifLoaderDialogUtils.hideDialog(context); + Navigator.push( + context, + FadePage(page: CartOrderPage()), + );} + else{ + AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); + } + GifLoaderDialogUtils.hideDialog(context); + } + + ), + ):Container(), ], ), ), diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index d8c3ff7b..6a131d09 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1365,6 +1365,8 @@ class TranslationBase { String get referralNumber => localizedValues['referralNumber'][locale.languageCode]; + String get needPrescription => localizedValues['needPrescription'][locale.languageCode]; + String get outOfStockMsg => localizedValues['outOfStockMsg'][locale.languageCode]; String get requestID => localizedValues['requestID'][locale.languageCode]; String get OrderStatus => localizedValues['OrderStatus'][locale.languageCode]; String get pickupDate => localizedValues['pickupDate'][locale.languageCode];