From 5d0a122689bc4a58fb604f0d4a52de83b0cc2687 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Mon, 22 Feb 2021 13:06:32 +0200 Subject: [PATCH 1/4] fix bugs --- .../service/pharmacy_categorise_service.dart | 45 ++- .../pharmacy_categorise_view_model.dart | 22 ++ lib/pages/final_products_page.dart | 17 +- lib/pages/landing/landing_page_pharmcy.dart | 138 ++++--- .../pharmacies/screens/cart-order-page.dart | 2 +- .../screens/pharmacy_module_page.dart | 336 ++++++++++-------- 6 files changed, 329 insertions(+), 231 deletions(-) diff --git a/lib/core/service/pharmacy_categorise_service.dart b/lib/core/service/pharmacy_categorise_service.dart index d7dc0429..02d0e0d3 100644 --- a/lib/core/service/pharmacy_categorise_service.dart +++ b/lib/core/service/pharmacy_categorise_service.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/brands_model.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/final_products_model.dart'; @@ -229,12 +230,12 @@ class PharmacyCategoriseService extends BaseService { hasError = false; Map queryParams = {'ManufacturerId': id}; - manufacturerProducts.clear(); + _finalProducts.clear(); await baseAppClient.getPharmacy( GET_BRAND_ITEMS, onSuccess: (dynamic response, int statusCode) { response['products'].forEach((item) { - manufacturerProducts.add(FinalProductsModel.fromJson(item)); + _finalProducts.add(FinalProductsModel.fromJson(item)); }); }, onFailure: (String error, int statusCode) { @@ -243,4 +244,44 @@ class PharmacyCategoriseService extends BaseService { }, queryParams: queryParams, ); } + + Future getLastVisitedProducts() async { + String lastVisited = ""; + 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) { + _finalProducts.clear(); + response['products'].forEach((item) { + _finalProducts.add(FinalProductsModel.fromJson(item)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }); + } catch (error) { + throw error; + } + } + } + + Future getBestSellerProducts() async { + 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', + }; + try { + await baseAppClient.getPharmacy(GET_PHARMACY_BEST_SELLER_PRODUCT, onSuccess: (dynamic response, int statusCode) { + _finalProducts.clear(); + response['products'].forEach((item) { + _finalProducts.add(FinalProductsModel.fromJson(item)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, queryParams: queryParams); + } catch (error) { + throw error; + } + } } diff --git a/lib/core/viewModels/pharmacy_categorise_view_model.dart b/lib/core/viewModels/pharmacy_categorise_view_model.dart index 6d036777..a593a385 100644 --- a/lib/core/viewModels/pharmacy_categorise_view_model.dart +++ b/lib/core/viewModels/pharmacy_categorise_view_model.dart @@ -158,4 +158,26 @@ class PharmacyCategoriseViewModel extends BaseViewModel { setState(ViewState.Idle); } } + + Future getLastVisitedProducts() async { + setState(ViewState.Busy); + await _pharmacyCategoriseService.getLastVisitedProducts(); + if (_pharmacyCategoriseService.hasError) { + error = _pharmacyCategoriseService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } + + Future getBestSellerProducts() async { + setState(ViewState.Busy); + await _pharmacyCategoriseService.getBestSellerProducts(); + if (_pharmacyCategoriseService.hasError) { + error = _pharmacyCategoriseService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } } diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 5e71f745..4d744264 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -10,7 +10,7 @@ import 'base/base_view.dart'; class FinalProductsPage extends StatefulWidget { final String id; - final int productType; + final int productType; // 1 : default, 2 : manufacturer , 3 : recently viewed FinalProductsPage({this.id, this.productType = 1}); @@ -35,9 +35,18 @@ class _FinalProductsPageState extends State { @override Widget build(BuildContext context) { return BaseView( - onModelReady: (model) => widget.productType == 1 - ? model.getFinalProducts(i: id) - : model.getManufacturerProducts(id), + onModelReady: (model) { + if (widget.productType == 1) { + model.getFinalProducts(i: id); + } else if (widget.productType == 2) { + model.getManufacturerProducts(id); + } else if (widget.productType == 3) { + model.getLastVisitedProducts(); + } else { + model.getBestSellerProducts(); + } + }, + allowAny: true, builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 3a46f45c..f9d8250c 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -49,78 +49,74 @@ class _LandingPagePharmacyState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: - - // currentTab == 0 || currentTab == 1 || currentTab == 2 - // ? - - 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(8.0), - child: Row( - //crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Icon(Icons.search, size: 25.0), - SizedBox( - width: 15.0, + appBar: currentTab != 4 + ? 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(8.0), + child: Row( + //crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Icon(Icons.search, size: 25.0), + SizedBox( + width: 15.0, + ), + Texts( + TranslationBase.of(context).searchProductHere, + fontSize: 13, + ) + ], + ), ), - Texts( - TranslationBase.of(context).searchProductHere, - fontSize: 13, - ) - ], - ), - ), - onTap: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => 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', + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => SearchProductsPage()), + ); + }, ), ), - ); - }, - ), - actions: [ - IconButton( - // iconSize: 70, - icon: Image.asset( - 'assets/images/new-design/qr-code.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', + ), + ), + ); + }, ), - onPressed: _scanQrAndGetProduct //do something, - ) - ], - centerTitle: true, - ), - // : currentTab == 4 - // ? null:null, + actions: [ + IconButton( + // iconSize: 70, + icon: Image.asset( + 'assets/images/new-design/qr-code.png', + ), + onPressed: _scanQrAndGetProduct //do something, + ) + ], + centerTitle: true, + ) + : null, // : AppBar( // backgroundColor: Color(0xff5AB145), // elevation: 0, @@ -155,7 +151,6 @@ class _LandingPagePharmacyState extends State { physics: NeverScrollableScrollPhysics(), controller: pageController, children: [ - // TODO mosa_comeback PharmacyPage(), PharmacyCategorisePage(), // OffersCategorisePage(), @@ -180,8 +175,9 @@ class _LandingPagePharmacyState extends State { try { String barcode = result; GifLoaderDialogUtils.showMyDialog(context); - await BaseAppClient().getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode", - onSuccess: (dynamic response, int statusCode) { + await BaseAppClient() + .getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode", + onSuccess: (dynamic response, int statusCode) { print(response); var product = PharmacyProduct.fromJson(response["products"][0]); GifLoaderDialogUtils.hideDialog(context); diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index 6926f9f4..cca6c1df 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -27,7 +27,7 @@ class CartOrderPage extends StatelessWidget { value: model.cartResponse, child: AppScaffold( appBarTitle: TranslationBase.of(context).shoppingCart, - isShowAppBar: false, + isShowAppBar: true, isPharmacy: true, baseViewModel: model, backgroundColor: Colors.white, diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index d4e5eb72..a0996522 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -20,6 +20,7 @@ import 'package:flutter_svg/svg.dart'; import 'package:rating_bar/rating_bar.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product-brands.dart'; +import '../../final_products_page.dart'; import 'lacum-activitaion-vida-page.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/doctor_card.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart'; @@ -48,8 +49,8 @@ class PharmacyPage extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - BannerPager(model), - // GridViewButtons(model), + BannerPager(model), + GridViewButtons(model), Container( margin: EdgeInsets.fromLTRB(10, 10, 10, 10), child: Row( @@ -77,181 +78,193 @@ class PharmacyPage extends StatelessWidget { ], ), ), - Container( - padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 24.0), + padding: + EdgeInsets.symmetric(horizontal: 16.0, vertical: 24.0), height: MediaQuery.of(context).size.height * 0.30, // 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 + 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: 4, - itemCount: model.prescriptionsList.length, - itemBuilder: (context, index) { - return Container( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + physics: ScrollPhysics(), + // physics: NeverScrollableScrollPhysics(), + // itemCount: 4, + itemCount: model.prescriptionsList.length, + itemBuilder: (context, index) { + return Container( // width: 160.0, - height: MediaQuery.of(context).size.height * 0.6, - padding: EdgeInsets.only(bottom: 5.0, left: 5.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( + height: + MediaQuery.of(context).size.height * 0.6, + padding: + EdgeInsets.only(bottom: 5.0, left: 5.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: [ - Column(children: [ - Container( - 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), + Row( + children: [ + Column(children: [ + Container( padding: EdgeInsets.only( - left: 15.0, right: 15.0), - decoration: BoxDecoration( - border: Border.all( - color: Colors.green, - style: BorderStyle.solid, - width: 4.0, + 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 + .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( + model.prescriptionsList[index] + .appointmentDate + .toString(), + style: TextStyle( + color: Colors.black, + fontSize: 15.0, +// fontWeight: FontWeight.bold, ), - color: Colors.green, - borderRadius: - BorderRadius.circular( - 30.0)), - child: Text( + ) + ]), + ], + ), + ], + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(left: 5), + child: Row(children: [ + Text( model.prescriptionsList[index] - .isInOutPatientDescription + .doctorTitle .toString(), style: TextStyle( - color: Colors.white, + color: Colors.black, fontSize: 15.0, -// fontWeight: FontWeight.bold, + fontWeight: FontWeight.bold, ), - )), - Row(children: [ - Image.asset( - 'assets/images/Icon-awesome-calendar.png', - width: 30, - height: 30, - ), - Text( + ), + 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] - .appointmentDate + .clinicDescription .toString(), style: TextStyle( - color: Colors.black, + color: Colors.green, fontSize: 15.0, -// fontWeight: FontWeight.bold, +// 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: 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( + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(left: 5), + child: Align( + alignment: Alignment.topLeft, + child: RatingBar.readOnly( // 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(), + ), ), Container( margin: EdgeInsets.fromLTRB(10, 10, 10, 10), @@ -333,7 +346,17 @@ class PharmacyPage extends StatelessWidget { hPadding: 4, borderColor: Colors.green, textColor: Colors.green, - handler: () {}, + handler: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => FinalProductsPage( + id: "", + productType: 3, + ), + ), + ); + }, ), ], ), @@ -367,7 +390,14 @@ class PharmacyPage extends StatelessWidget { hPadding: 4, handler: () => { Navigator.push( - context, FadePage(page: ProductBrandsPage())), + context, + MaterialPageRoute( + builder: (context) => FinalProductsPage( + id: "", + productType: 4, + ), + ), + ), }, ), ], From 1b76d9c192769519698c27078493a960fe0349ac Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 22 Feb 2021 15:13:37 +0200 Subject: [PATCH 2/4] pharmacy bugs fixed --- .../service/pharmacy_categorise_service.dart | 25 +- .../pharmacy_categorise_view_model.dart | 24 +- lib/pages/final_products_page.dart | 665 +++++----- lib/pages/offers_categorise_page.dart | 1178 +++++++++-------- lib/pages/parent_categorise_page.dart | 781 +++++------ lib/pages/pharmacies/product_detail.dart | 675 +++++++--- lib/pages/search_products_page.dart | 331 ++--- lib/pages/sub_categorise_page.dart | 611 +++++---- 8 files changed, 2409 insertions(+), 1881 deletions(-) diff --git a/lib/core/service/pharmacy_categorise_service.dart b/lib/core/service/pharmacy_categorise_service.dart index 0082cc49..c9abf20c 100644 --- a/lib/core/service/pharmacy_categorise_service.dart +++ b/lib/core/service/pharmacy_categorise_service.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/brands_model.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/final_products_model.dart'; @@ -21,20 +22,20 @@ class PharmacyCategoriseService extends BaseService { List get parentCategoriseList => _parentCategoriseList; //service three - List _parentProductsList = List(); - List get parentProductsList => _parentProductsList; + List _parentProductsList = List(); + List get parentProductsList => _parentProductsList; //service four List _subCategoriseList = List(); List get subCategoriseList => _subCategoriseList; //service five - List _subProductsList = List(); - List get subProductsList => _subProductsList; + List _subProductsList = List(); + List get subProductsList => _subProductsList; //service six - List _finalProducts = List(); - List get finalProducts => _finalProducts; + List _finalProducts = List(); + List get finalProducts => _finalProducts; //service 7 @@ -43,8 +44,8 @@ class PharmacyCategoriseService extends BaseService { // service 8 - List _searchList = List(); - List get searchList => _searchList; + List _searchList = List(); + List get searchList => _searchList; List _scanList = List(); List get scanList => _scanList; @@ -98,7 +99,7 @@ class PharmacyCategoriseService extends BaseService { endPoint, onSuccess: (dynamic response, int statusCode) { response['products'].forEach((item) { - _searchList.add(SearchProductsModel.fromJson(item)); + _searchList.add(PharmacyProduct.fromJson(item)); }); }, onFailure: (String error, int statusCode) { @@ -154,7 +155,7 @@ class PharmacyCategoriseService extends BaseService { endPoint, onSuccess: (dynamic response, int statusCode) { response['products'].forEach((item) { - _parentProductsList.add(ParentProductsModel.fromJson(item)); + _parentProductsList.add(PharmacyProduct.fromJson(item)); }); }, onFailure: (String error, int statusCode) { @@ -194,7 +195,7 @@ class PharmacyCategoriseService extends BaseService { endPoint, onSuccess: (dynamic response, int statusCode) { response['products'].forEach((item) { - _subProductsList.add(SubProductsModel.fromJson(item)); + _subProductsList.add(PharmacyProduct.fromJson(item)); }); }, onFailure: (String error, int statusCode) { @@ -213,7 +214,7 @@ class PharmacyCategoriseService extends BaseService { endPoint, onSuccess: (dynamic response, int statusCode) { response['products'].forEach((item) { - _finalProducts.add(FinalProductsModel.fromJson(item)); + _finalProducts.add(PharmacyProduct.fromJson(item)); }); }, onFailure: (String error, int statusCode) { diff --git a/lib/core/viewModels/pharmacy_categorise_view_model.dart b/lib/core/viewModels/pharmacy_categorise_view_model.dart index d26d860d..acc805f1 100644 --- a/lib/core/viewModels/pharmacy_categorise_view_model.dart +++ b/lib/core/viewModels/pharmacy_categorise_view_model.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/brands_model.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/final_products_model.dart'; @@ -16,22 +17,29 @@ import 'base_view_model.dart'; class PharmacyCategoriseViewModel extends BaseViewModel { bool hasError = false; - PharmacyCategoriseService _pharmacyCategoriseService = locator(); + PharmacyCategoriseService _pharmacyCategoriseService = + locator(); - List get categorise => _pharmacyCategoriseService.categoriseList; + List get categorise => + _pharmacyCategoriseService.categoriseList; - List get categoriseParent => _pharmacyCategoriseService.parentCategoriseList; + List get categoriseParent => + _pharmacyCategoriseService.parentCategoriseList; - List get parentProducts => _pharmacyCategoriseService.parentProductsList; + List get parentProducts => + _pharmacyCategoriseService.parentProductsList; - List get subCategorise => _pharmacyCategoriseService.subCategoriseList; + List get subCategorise => + _pharmacyCategoriseService.subCategoriseList; - List get subProducts => _pharmacyCategoriseService.subProductsList; + List get subProducts => + _pharmacyCategoriseService.subProductsList; - List get finalProducts => _pharmacyCategoriseService.finalProducts; + List get finalProducts => + _pharmacyCategoriseService.finalProducts; List get brandsList => _pharmacyCategoriseService.brandsList; - List get searchList => _pharmacyCategoriseService.searchList; + List get searchList => _pharmacyCategoriseService.searchList; List get scanList => _pharmacyCategoriseService.scanList; diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 03adee97..483e50df 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -1,8 +1,10 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'base/base_view.dart'; @@ -117,193 +119,220 @@ class _FinalProductsPageState extends State { itemBuilder: (BuildContext context, int index) { return NetworkBaseView( baseViewModel: model, - 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, + 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, + ), ), - top: BorderSide( - color: Colors.grey.shade300, - width: 1, + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, ), - ), - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(110.0), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(110.0), + ), + color: Colors.white, ), - 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 + 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] - .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)), + .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: Texts( - model.finalProducts[index] + Container( + width: model + .finalProducts[ + index] .rxMessage != null - ? model - .finalProducts[ - index] - .rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w600, + ? 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: Texts( + model + .finalProducts[ + index] + .rxMessage != + null + ? model + .finalProducts[ + index] + .rxMessage + : "", + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: + FontWeight.w600, + ), ), - ), - ], - ), - Container( - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, + ], ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - if (model + 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 != - 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, - ), + .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, ), ), - 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, + 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]), + )), + }, )); }, ), @@ -316,158 +345,186 @@ class _FinalProductsPageState extends State { itemCount: model.finalProducts.length, itemBuilder: (BuildContext context, int index) { - return 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, + 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( + child: Column( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ + SizedBox( + height: 4.0, + ), Container( - width: model - .finalProducts[ - index] - .rxMessage != - null - ? MediaQuery.of(context) + 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)), - ), + .width * + 0.65, child: Texts( model.finalProducts[index] - .rxMessage != - null - ? model - .finalProducts[ - index] - .rxMessage - : "", - color: Colors.white, + .name, regular: true, - fontSize: 10, + fontSize: 13.2, fontWeight: - FontWeight.w600, + FontWeight.w500, + maxLines: 5, ), ), - ], - ), - ], - ), - 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( - height: 35.0, - width: 250.0, - child: Texts( - model.finalProducts[index] - .name, - regular: true, - fontSize: 13.2, - fontWeight: FontWeight.w500, - maxLines: 2, + SizedBox( + height: 8.0, ), - ), - SizedBox( - height: 8.0, - ), - 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]), + )), + }, ); }), ), diff --git a/lib/pages/offers_categorise_page.dart b/lib/pages/offers_categorise_page.dart index 782ea018..f3875d1a 100644 --- a/lib/pages/offers_categorise_page.dart +++ b/lib/pages/offers_categorise_page.dart @@ -34,587 +34,675 @@ class _OffersCategorisePageState extends State { builder: (BuildContext context, OffersCategoriseViewModel model, Widget child) => PharmacyAppScaffold( - appBarTitle: 'Offers', - isShowAppBar: true, - backgroundColor: Colors.white, - isShowDecPage: false, - baseViewModel: model, - body: Container( - //height: MediaQuery.of(context).size.height * 0.57, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.all(10.0), - child: Container( - child: Texts( - 'Categories', - fontWeight: FontWeight.w800, - ), - ), - ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, - ), - //Expanded widget heree if nassery - Container( - height: MediaQuery.of(context).size.height * 0.20, - child: ListView.builder( - scrollDirection: Axis.horizontal, - itemCount: model.categorise.length, - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: EdgeInsets.all(8.0), - child: Row( - children: [ - InkWell( - child: Column( - children: [ - Container( - height: 60.0, - width: 65.0, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.orange.shade200 - .withOpacity(0.45), - ), - child: Icon( - Icons.apps_sharp, - size: 32.0, - ), - ), - Container( - width: MediaQuery.of(context) - .size - .width * - 0.2, - height: MediaQuery.of(context) - .size - .height * - 0.09, - child: Center( - child: Texts( - model.categorise[index].name, - fontWeight: FontWeight.w600, - fontSize: 13.8, - ), - ), - ), - ], - ), - onTap: () { - model.getOffersProducts( - i: model.categorise[index].id); - String ids = model.categorise[index].id; - - categoriseName = - model.categorise[index].name; - }), - ], - ), - ); - }), - ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: EdgeInsets.all(8.0), - child: Texts( - categoriseName, - fontWeight: FontWeight.w800, - ), - ), - Row( + appBarTitle: 'Offers', + isShowAppBar: true, + backgroundColor: Colors.white, + isShowDecPage: false, + baseViewModel: model, + body: model.categorise.length != 0 + ? Container( + //height: MediaQuery.of(context).size.height * 0.57, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - height: 44.0, - child: VerticalDivider( - color: Colors.black45, - thickness: 0.7, - //width: 0.3, - // indent: 0.0, - ), - ), Padding( - padding: EdgeInsets.all(8.0), - child: InkWell( - child: styleIcon, - onTap: () { - setState(() { - if (styleOne == true) { - styleOne = false; - styleTwo = true; - styleIcon = Icon( - Icons.auto_awesome_mosaic, - color: Colors.blue, - size: 29.0, - ); - } else { - styleOne = true; - styleTwo = false; - styleIcon = Icon( - Icons.widgets_sharp, - color: Colors.blue, - size: 29.0, - ); - } - }); - }, + padding: EdgeInsets.all(10.0), + child: Container( + child: Texts( + 'Categories', + fontWeight: FontWeight.w800, + ), ), ), - ], - ), - ], - ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, - ), - styleOne == true - ? Expanded( - child: Container( - height: MediaQuery.of(context).size.height * 0.50, - child: GridView.builder( - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 0.5, - mainAxisSpacing: 2.0, - childAspectRatio: 0.85, - ), - itemCount: model.products.length, - itemBuilder: (BuildContext context, int index) { - return NetworkBaseView( - baseViewModel: model, - child: Card( - color: model.products[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( - height: 250.0, - 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( + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + //Expanded widget heree if nassery + Container( + height: MediaQuery.of(context).size.height * 0.20, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: model.categorise.length, + itemBuilder: + (BuildContext context, int index) { + return Padding( + padding: EdgeInsets.all(8.0), + child: Row( + children: [ + InkWell( + child: Column( children: [ - if (model.products[index] - .discountName != - null) - RotatedBox( - quarterTurns: 4, - child: Container( - decoration: - BoxDecoration(), - child: Padding( - padding: - EdgeInsets.only( - right: 5.0, - top: 20.0, - bottom: 5.0, - ), - child: Texts( - 'offer' - .toUpperCase(), - color: Colors.red, - fontSize: 13.0, - fontWeight: - FontWeight.w900, - ), - ), - transform: new Matrix4 - .rotationZ( - 5.837200), - ), - ), Container( - margin: EdgeInsets.fromLTRB( - 0, 16, 0, 0), - alignment: Alignment.center, - child: Image.network( - model.products[index] - .images.isNotEmpty - ? model - .products[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, + height: 60.0, + width: 65.0, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors + .orange.shade200 + .withOpacity(0.45), + ), + child: Icon( + Icons.apps_sharp, + size: 32.0, ), ), Container( - width: model.products[index] - .rxMessage != - null - ? MediaQuery.of(context) + width: + 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.products[index] - .rxMessage != - null - ? model - .products[index] - .rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w400, + .width * + 0.2, + height: + MediaQuery.of(context) + .size + .height * + 0.09, + child: Center( + child: Texts( + model.categorise[index] + .name, + fontWeight: + FontWeight.w600, + fontSize: 13.8, + ), ), ), ], ), - Container( + onTap: () { + model.getOffersProducts( + i: model + .categorise[index].id); + String ids = + model.categorise[index].id; + + categoriseName = model + .categorise[index].name; + }), + ], + ), + ); + }), + ), + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: EdgeInsets.all(8.0), + child: Texts( + categoriseName, + fontWeight: FontWeight.w800, + ), + ), + Row( + children: [ + Container( + height: 44.0, + child: VerticalDivider( + color: Colors.black45, + thickness: 0.7, + //width: 0.3, + // indent: 0.0, + ), + ), + Padding( + padding: EdgeInsets.all(8.0), + child: InkWell( + child: styleIcon, + onTap: () { + setState(() { + if (styleOne == true) { + styleOne = false; + styleTwo = true; + styleIcon = Icon( + Icons.auto_awesome_mosaic, + color: Colors.blue, + size: 29.0, + ); + } else { + styleOne = true; + styleTwo = false; + styleIcon = Icon( + Icons.widgets_sharp, + color: Colors.blue, + size: 29.0, + ); + } + }); + }, + ), + ), + ], + ), + ], + ), + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + styleOne == true + ? Expanded( + child: Container( + height: + MediaQuery.of(context).size.height * + 0.50, + child: GridView.builder( + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + crossAxisSpacing: 0.5, + mainAxisSpacing: 2.0, + childAspectRatio: 0.85, + ), + itemCount: model.products.length, + itemBuilder: + (BuildContext context, int index) { + return NetworkBaseView( + baseViewModel: model, + child: Card( + color: model.products[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: 6, - vertical: 0, + horizontal: 8, + vertical: 4, ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - if (model.products[index] - .discountName != - null) + child: Container( + height: 250.0, + 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: [ + if (model + .products[ + index] + .discountName != + null) + RotatedBox( + quarterTurns: 4, + child: Container( + decoration: + BoxDecoration(), + child: Padding( + padding: + EdgeInsets + .only( + right: 5.0, + top: 20.0, + bottom: 5.0, + ), + child: Texts( + 'offer' + .toUpperCase(), + color: Colors + .red, + fontSize: + 13.0, + fontWeight: + FontWeight + .w900, + ), + ), + transform: new Matrix4 + .rotationZ( + 5.837200), + ), + ), + Container( + margin: EdgeInsets + .fromLTRB(0, 16, + 0, 0), + alignment: Alignment + .center, + child: + Image.network( + model + .products[ + index] + .images + .isNotEmpty + ? model + .products[ + 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 + .products[ + 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 + .products[ + index] + .rxMessage != + null + ? model + .products[ + index] + .rxMessage + : "", + color: + Colors.white, + regular: true, + fontSize: 10, + fontWeight: + FontWeight + .w400, + ), + ), + ], + ), Container( - width: double.infinity, - height: 22.0, - decoration: - BoxDecoration( - color: - Color(0xff5AB145), + margin: EdgeInsets + .symmetric( + horizontal: 6, + vertical: 0, ), - child: Center( - child: Texts( - model - .products[index] - .discountName, - regular: true, - color: Colors.white, - fontSize: 12.0, - fontWeight: - FontWeight.w700, - ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + if (model + .products[ + index] + .discountName != + null) + Container( + width: double + .infinity, + height: 22.0, + decoration: + BoxDecoration( + color: Color( + 0xff5AB145), + ), + child: Center( + child: Texts( + model + .products[ + index] + .discountName, + regular: + true, + color: Colors + .white, + fontSize: + 12.0, + fontWeight: + FontWeight + .w700, + ), + ), + ), + Texts( + model + .products[ + index] + .name, + regular: true, + fontSize: 12.58, + fontWeight: + FontWeight + .w600, + ), + Padding( + padding: + const EdgeInsets + .only( + top: 4, + bottom: + 4), + child: Texts( + "SAR ${model.products[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ + StarRating( + totalAverage: model.products[index].approvedRatingSum > + 0 + ? (model.products[index].approvedRatingSum.toDouble() / model.products[index].approvedRatingSum.toDouble()) + .toDouble() + : 0, + forceStars: + true), + Texts( + "(${model.products[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: + FontWeight + .w400, + ) + ], + ), + ], ), ), - Texts( - model - .products[index].name, - regular: true, - fontSize: 12.58, - fontWeight: - FontWeight.w600, - ), - Padding( - padding: - const EdgeInsets.only( - top: 4, - bottom: 4), - child: Texts( - "SAR ${model.products[index].price}", - bold: true, - fontSize: 14, + ], + ), + ), + )); + }, + ), + ), + ) + : Expanded( + child: Container( + child: ListView.builder( + itemCount: model.products.length, + itemBuilder: (BuildContext context, + int index) { + return Card( + // color: + // model.products[index].discountName != + // null + // ? Color(0xffFFFF00) + // : Colors.white, + child: Row( + children: [ + Stack( + children: [ + Column( + children: [ + if (model + .products[ + index] + .discountName != + null) + Container( + decoration: + BoxDecoration(), + child: Padding( + padding: + EdgeInsets + .only( + left: 9.0, + top: 8.0, + right: 10.0, + ), + child: + Container( + color: Colors + .yellow, + height: 25.0, + width: 70.0, + child: Center( + child: + Texts( + 'offer' + .toUpperCase(), + color: Colors + .red, + fontSize: + 13.0, + fontWeight: + FontWeight + .w900, + ), + ), + ), + ), + transform: new Matrix4 + .rotationZ( + 6.15099), + ), + Container( + margin: EdgeInsets + .fromLTRB( + 0, 0, 0, 0), + alignment: Alignment + .center, + child: + Image.network( + model + .products[ + index] + .images + .isNotEmpty + ? model + .products[ + 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, + ), + ), + ], ), - ), - Row( - children: [ - StarRating( - totalAverage: model + Column( + children: [ + Container( + width: model .products[ index] - .approvedRatingSum > - 0 - ? (model.products[index].approvedRatingSum - .toDouble() / - model - .products[index] - .approvedRatingSum - .toDouble()) - .toDouble() + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5 : 0, - forceStars: true), - Texts( - "(${model.products[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w400, - ) - ], - ), - ], - ), - ), - ], - ), - ), - )); - }, - ), - ), - ) - : Expanded( - child: Container( - child: ListView.builder( - itemCount: model.products.length, - itemBuilder: - (BuildContext context, int index) { - return Card( - // color: - // model.products[index].discountName != - // null - // ? Color(0xffFFFF00) - // : Colors.white, - child: Row( - children: [ - Stack( - children: [ - Column( - children: [ - if (model.products[index] - .discountName != - null) - Container( - decoration: - BoxDecoration(), - child: Padding( - padding: - EdgeInsets.only( - left: 9.0, - top: 8.0, - right: 10.0, - ), - child: Container( - color: Colors.yellow, - height: 25.0, - width: 70.0, - child: Center( + padding: + EdgeInsets.all( + 4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), + borderRadius: BorderRadius.only( + topLeft: Radius + .circular( + 6)), + ), child: Texts( - 'offer' - .toUpperCase(), - color: Colors.red, - fontSize: 13.0, + model + .products[ + index] + .rxMessage != + null + ? model + .products[ + index] + .rxMessage + : "", + color: + Colors.white, + regular: true, + fontSize: 10, fontWeight: FontWeight - .w900, + .w400, ), ), - ), + ], ), - transform: - new Matrix4.rotationZ( - 6.15099), - ), - Container( - margin: EdgeInsets.fromLTRB( - 0, 0, 0, 0), - alignment: Alignment.center, - child: Image.network( - model.products[index] - .images.isNotEmpty - ? model - .products[index] - .images[0] - .thumb - : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', - fit: BoxFit.cover, - height: 80, - ), + ], ), - ], - ), - Column( - children: [ Container( - width: model.products[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)), + margin: + EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, ), - child: Texts( - model.products[index] - .rxMessage != - null - ? model - .products[index] - .rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w400, + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + if (model + .products[index] + .discountName != + null) + Container( + width: 250.0, + height: 22.5, + decoration: + BoxDecoration( + color: Color( + 0xff5AB145), + ), + child: Padding( + padding: EdgeInsets + .symmetric( + horizontal: 5.5, + ), + child: Texts( + model + .products[ + index] + .discountName, + regular: true, + color: Colors + .white, + fontSize: 12.0, + fontWeight: + FontWeight + .w700, + ), + ), + ), + SizedBox( + height: 4.0, + ), + Texts( + model.products[index] + .name, + regular: true, + fontSize: 14.0, + fontWeight: + FontWeight.w600, + ), + SizedBox( + height: 8.0, + ), + Padding( + padding: + const EdgeInsets + .only( + top: 4, + bottom: 4), + child: Texts( + "SAR ${model.products[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ + StarRating( + totalAverage: model + .products[ + index] + .approvedRatingSum > + 0 + ? (model.products[index].approvedRatingSum.toDouble() / + model.products[index].approvedRatingSum + .toDouble()) + .toDouble() + : 0, + forceStars: + true), + Texts( + "(${model.products[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: + FontWeight + .w500, + ) + ], + ), + ], ), ), ], ), - ], - ), - Container( - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, - ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - if (model.products[index] - .discountName != - null) - Container( - width: 250.0, - height: 22.5, - decoration: BoxDecoration( - color: Color(0xff5AB145), - ), - child: Padding( - padding: - EdgeInsets.symmetric( - horizontal: 5.5, - ), - child: Texts( - model.products[index] - .discountName, - regular: true, - color: Colors.white, - fontSize: 12.0, - fontWeight: - FontWeight.w700, - ), - ), - ), - SizedBox( - height: 4.0, - ), - Texts( - model.products[index].name, - regular: true, - fontSize: 14.0, - fontWeight: FontWeight.w600, - ), - SizedBox( - height: 8.0, - ), - Padding( - padding: - const EdgeInsets.only( - top: 4, bottom: 4), - child: Texts( - "SAR ${model.products[index].price}", - bold: true, - fontSize: 14, - ), - ), - Row( - children: [ - StarRating( - totalAverage: model - .products[ - index] - .approvedRatingSum > - 0 - ? (model - .products[ - index] - .approvedRatingSum - .toDouble() / - model - .products[ - index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: true), - Texts( - "(${model.products[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w500, - ) - ], - ), - ], - ), - ), - ], - ), - ); - }), - ), - ) - ], - ), - ), - )); + ); + }), + ), + ) + ], + ), + ) + : Center( + child: Texts( + "SORRY , there's no listed offers now :(", + color: Colors.green, + )))); } } diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 414106b1..3f33b611 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -1,6 +1,7 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; @@ -8,6 +9,7 @@ import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:giffy_dialog/giffy_dialog.dart'; @@ -111,10 +113,10 @@ class _ParentCategorisePageState extends State { context: context, builder: (BuildContext context) { return Container( - height: MediaQuery.of(context) - .size - .height * - 0.89, + // height: MediaQuery.of(context) + // .size + // .height * + // 0.89, color: Colors.white, child: Center( child: ListView.builder( @@ -130,7 +132,7 @@ class _ParentCategorisePageState extends State { child: Padding( padding: EdgeInsets.all( - 8.0), + 4.0), child: InkWell( child: Column( crossAxisAlignment: @@ -229,10 +231,10 @@ class _ParentCategorisePageState extends State { .size .width * 0.197, - height: MediaQuery.of(context) - .size - .height * - 0.08, + // height: MediaQuery.of(context) + // .size + // .height * + // 0.08, child: Center( child: Texts( projectViewModel.isArabic @@ -646,246 +648,260 @@ class _ParentCategorisePageState extends State { (BuildContext context, int index) { return NetworkBaseView( baseViewModel: model, - child: Card( - color: model.parentProducts[index] - .discountName != - null - ? Color(0xffFFFF00) - : Colors.white, - elevation: 0, - shape: Border( - right: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - left: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - bottom: BorderSide( - color: Colors.grey.shade300, - width: 1, + child: InkWell( + child: Card( + color: model.parentProducts[index] + .discountName != + null + ? Color(0xffFFFF00) + : Colors.white, + elevation: 0, + shape: Border( + right: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + left: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + bottom: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + top: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), ), - top: BorderSide( - color: Colors.grey.shade300, - width: 1, + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, ), - ), - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - topLeft: - Radius.circular(110.0), + child: Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.only( + topLeft: + Radius.circular(110.0), + ), + color: Colors.white, ), - color: Colors.white, - ), - padding: EdgeInsets.symmetric( - horizontal: 0), - width: MediaQuery.of(context) - .size - .width / - 3, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Stack( - children: [ - if (model - .parentProducts[ - index] - .discountName != - null) - RotatedBox( - quarterTurns: 4, - child: Container( - decoration: - BoxDecoration(), - child: Padding( - padding: - EdgeInsets - .only( - right: 5.0, - top: 20.0, - bottom: 5.0, - ), - child: Texts( - 'offer' - .toUpperCase(), - color: - Colors.red, - fontSize: 13.0, - fontWeight: - FontWeight - .w900, + padding: EdgeInsets.symmetric( + horizontal: 0), + width: MediaQuery.of(context) + .size + .width / + 3, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Stack( + children: [ + if (model + .parentProducts[ + index] + .discountName != + null) + RotatedBox( + quarterTurns: 4, + child: Container( + decoration: + BoxDecoration(), + child: Padding( + padding: + EdgeInsets + .only( + right: 5.0, + top: 20.0, + bottom: 5.0, + ), + child: Texts( + 'offer' + .toUpperCase(), + color: Colors + .red, + fontSize: + 13.0, + fontWeight: + FontWeight + .w900, + ), ), + transform: new Matrix4 + .rotationZ( + 5.837200), ), - transform: new Matrix4 - .rotationZ( - 5.837200), ), - ), - Container( - margin: - EdgeInsets.fromLTRB( - 0, 16, 0, 0), - alignment: - Alignment.center, - child: Image.network( - model - .parentProducts[ - index] - .images - .isNotEmpty - ? model - .parentProducts[ - index] - .images[0] - .thumb - : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', - fit: BoxFit.cover, - height: 80, - ), - ), - Container( - width: model + Container( + margin: EdgeInsets + .fromLTRB( + 0, 16, 0, 0), + alignment: + Alignment.center, + child: Image.network( + model .parentProducts[ index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 5 - : 0, - padding: - EdgeInsets.all(4), - decoration: - BoxDecoration( - color: - Color(0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), + .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, + ), ), - child: Texts( - model + Container( + width: model .parentProducts[ index] .rxMessage != null - ? model - .parentProducts[ - index] - .rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w400, + ? MediaQuery.of( + context) + .size + .width / + 5 + : 0, + padding: + EdgeInsets.all(4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), + borderRadius: + BorderRadius.only( + topLeft: Radius + .circular( + 6)), + ), + child: Texts( + model + .parentProducts[ + index] + .rxMessage != + null + ? model + .parentProducts[ + index] + .rxMessage + : "", + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: + FontWeight.w400, + ), ), - ), - ], - ), - Container( - margin: - EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, + ], ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - if (model + Container( + margin: + EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + if (model + .parentProducts[ + index] + .discountName != + null) + Container( + width: double + .infinity, + height: 13.0, + decoration: + BoxDecoration( + color: Color( + 0xff5AB145), + ), + child: Center( + child: Texts( + model + .parentProducts[ + index] + .discountName, + regular: true, + color: Colors + .white, + fontSize: + 10.4, + ), + ), + ), + Texts( + model .parentProducts[ index] - .discountName != - null) - Container( - width: - double.infinity, - height: 13.0, - decoration: - BoxDecoration( - color: Color( - 0xff5AB145), - ), - child: Center( - child: Texts( - model - .parentProducts[ - index] - .discountName, - regular: true, - color: Colors - .white, - fontSize: 10.4, - ), + .name, + regular: true, + fontSize: 12, + fontWeight: + FontWeight.w700, + ), + Padding( + padding: + const EdgeInsets + .only( + top: 4, + bottom: 4), + child: Texts( + "SAR ${model.parentProducts[index].price}", + bold: true, + fontSize: 14, ), ), - Texts( - model - .parentProducts[ - index] - .name, - regular: true, - fontSize: 12, - fontWeight: - FontWeight.w700, - ), - Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), - child: Texts( - "SAR ${model.parentProducts[index].price}", - bold: true, - fontSize: 14, + Row( + children: [ + StarRating( + totalAverage: model + .parentProducts[ + index] + .approvedRatingSum > + 0 + ? (model.parentProducts[index].approvedRatingSum.toDouble() / + model.parentProducts[index].approvedRatingSum + .toDouble()) + .toDouble() + : 0, + forceStars: + true), + Texts( + "(${model.parentProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: + FontWeight + .w400, + ) + ], ), - ), - Row( - children: [ - StarRating( - 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, - ) - ], - ), - ], + ], + ), ), - ), - ], + ], + ), ), ), + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage( + model.parentProducts[ + index]), + )), + }, )); }, ), @@ -898,168 +914,191 @@ class _ParentCategorisePageState extends State { itemCount: model.parentProducts.length, itemBuilder: (BuildContext context, int index) { - return 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, + 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 - .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, - ), - ), - ], - ), - Column( - children: [ - Container( - width: model + Container( + margin: EdgeInsets + .fromLTRB( + 0, 0, 0, 0), + alignment: + Alignment.center, + child: Image.network( + model .parentProducts[ index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 5 - : 0, - padding: - EdgeInsets.all(4), - decoration: - BoxDecoration( - color: - Color(0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), + .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, + ), ), - child: Texts( - model + ], + ), + Column( + children: [ + Container( + width: model .parentProducts[ index] .rxMessage != null - ? model - .parentProducts[ - index] - .rxMessage - : "", - color: Colors.white, + ? MediaQuery.of( + context) + .size + .width / + 5 + : 0, + padding: + EdgeInsets.all(4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), + borderRadius: + BorderRadius.only( + topLeft: Radius + .circular( + 6)), + ), + child: Expanded( + child: Texts( + model + .parentProducts[ + index] + .rxMessage != + null + ? model + .parentProducts[ + index] + .rxMessage + : "", + color: + Colors.white, + regular: true, + fontSize: 10, + fontWeight: + FontWeight + .w400, + ), + ), + ), + ], + ), + ], + ), + Container( + margin: EdgeInsets.symmetric( + horizontal: 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 + .parentProducts[ + index] + .name, regular: true, - fontSize: 10, + fontSize: 13.2, fontWeight: - FontWeight.w400, + FontWeight.w500, + maxLines: 5, + ), + ), + SizedBox( + height: 8.0, + ), + Padding( + padding: + const EdgeInsets + .only( + top: 4, + bottom: 4), + child: Texts( + "SAR ${model.parentProducts[index].price}", + bold: true, + fontSize: 14, ), ), + Row( + children: [ + StarRating( + totalAverage: model + .parentProducts[ + index] + .approvedRatingSum > + 0 + ? (model.parentProducts[index].approvedRatingSum + .toDouble() / + model + .parentProducts[index] + .approvedRatingSum + .toDouble()) + .toDouble() + : 0, + forceStars: true), + Texts( + "(${model.parentProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: + FontWeight.w400, + ) + ], + ), ], ), - ], - ), - Container( - height: 100.0, - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, - ), - child: Column( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - SizedBox( - height: 4.0, - ), - Texts( - model - .parentProducts[index] - .name, - regular: true, - fontSize: 13.2, - fontWeight: - FontWeight.w500, - maxLines: 5, - ), - SizedBox( - height: 8.0, - ), - Padding( - padding: - const EdgeInsets.only( - top: 4, - bottom: 4), - child: Texts( - "SAR ${model.parentProducts[index].price}", - bold: true, - fontSize: 14, - ), - ), - Row( - children: [ - StarRating( - totalAverage: model - .parentProducts[ - index] - .approvedRatingSum > - 0 - ? (model.parentProducts[index].approvedRatingSum - .toDouble() / - model - .parentProducts[index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: true), - Texts( - "(${model.parentProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w400, - ) - ], - ), - ], ), - ), - ], + ], + ), ), + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage(model + .parentProducts[index]), + )), + }, ); }), ) diff --git a/lib/pages/pharmacies/product_detail.dart b/lib/pages/pharmacies/product_detail.dart index 6cd3a7d1..8388926e 100644 --- a/lib/pages/pharmacies/product_detail.dart +++ b/lib/pages/pharmacies/product_detail.dart @@ -80,12 +80,18 @@ class __ProductDetailPageState extends State { alignment: Alignment.centerRight, child: languageID == 'ar' ? Text( - widget.product.discountDescriptionn, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17), + widget.product + .discountDescriptionn, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 17), ) : Text( - widget.product.discountDescription, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17), + widget.product + .discountDescription, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 17), ), ), ), @@ -96,7 +102,8 @@ class __ProductDetailPageState extends State { flex: 0, child: Container( child: Image( - image: AssetImage('assets/images/offer.png'), + image: AssetImage( + 'assets/images/offer.png'), ), ), ), @@ -174,7 +181,9 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).details, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -202,7 +211,9 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).reviews, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -230,7 +241,9 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).availability, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -258,7 +271,10 @@ class __ProductDetailPageState extends State { Container( child: Text( TranslationBase.of(context).description, - style: TextStyle(fontSize: 17, color: Colors.grey, fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 17, + color: Colors.grey, + fontWeight: FontWeight.w600), ), ), SizedBox( @@ -266,8 +282,13 @@ class __ProductDetailPageState extends State { ), Container( child: Text( - languageID == 'ar' ? widget.product.shortDescriptionn : widget.product.shortDescription ?? "", - style: TextStyle(fontSize: 16, fontFamily: 'WorkSans-Regular'), + languageID == 'ar' + ? widget.product.shortDescriptionn + : widget.product.shortDescription ?? + "", + style: TextStyle( + fontSize: 16, + fontFamily: 'WorkSans-Regular'), ), ), SizedBox( @@ -276,7 +297,10 @@ class __ProductDetailPageState extends State { Container( child: Text( TranslationBase.of(context).howToUse, - style: TextStyle(fontSize: 17, color: Colors.grey, fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 17, + color: Colors.grey, + fontWeight: FontWeight.w600), ), ), SizedBox( @@ -284,8 +308,12 @@ class __ProductDetailPageState extends State { ), Container( child: Text( - languageID == 'ar' ? widget.product.fullDescriptionn : widget.product.fullDescription, - style: TextStyle(fontSize: 16, fontFamily: 'WorkSans-Regular'), + languageID == 'ar' + ? widget.product.fullDescriptionn + : widget.product.fullDescription, + style: TextStyle( + fontSize: 16, + fontFamily: 'WorkSans-Regular'), ), ), ], @@ -293,98 +321,162 @@ class __ProductDetailPageState extends State { ) : 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, - ), - ), - ], + 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), + ), ), - ), - SizedBox( - height: 10, - ), - Container( - child: Text( - model.productDetailService[0].reviews[index].reviewText, - style: TextStyle(fontSize: 20), + 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: 50, - ), - Divider(height: 1, color: Colors.grey), - ], + ], + ), ), - ); - }, - ) - : Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text('No Reviews Available'), - ), + 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('No Reviews Available'), + ), ) : isAvailabilty ? BaseView( - onModelReady: (model) => model.getProductLocationData(), - builder: (_, model, wi) => model.productLocationService.length == 0 + onModelReady: (model) => + model.getProductLocationData(), + builder: (_, model, wi) => model + .productLocationService + .length == + 0 ? Container( padding: EdgeInsets.all(15), alignment: Alignment.center, - child: Text('No location Available'), + child: Text( + 'No location Available'), ) : ListView.builder( physics: ScrollPhysics(), scrollDirection: Axis.vertical, shrinkWrap: true, - itemCount: model.productLocationService.length, - itemBuilder: (BuildContext context, int index) { + itemCount: model + .productLocationService + .length, + itemBuilder: + (BuildContext context, + int index) { return Padding( - padding: EdgeInsets.all(8.0), + padding: + EdgeInsets.all(8.0), child: Column( // crossAxisAlignment: CrossAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.start, children: [ Row( // crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .start, children: [ Expanded( flex: 1, - child: Image.network(model.productLocationService[index].projectImageUrl), + child: Image.network(model + .productLocationService[ + index] + .projectImageUrl), ), SizedBox( width: 10, @@ -392,31 +484,48 @@ class __ProductDetailPageState extends State { Expanded( flex: 4, child: Text( - model.productLocationService[index].locationDescription + + model + .productLocationService[ + index] + .locationDescription + "\n" + - fixingString(model.productLocationService[0].cityName.toString()), - style: TextStyle(fontSize: 12), + fixingString(model + .productLocationService[ + 0] + .cityName + .toString()), + style: TextStyle( + fontSize: + 12), ), ), Expanded( flex: 1, child: IconButton( - icon: Icon(Icons.location_on), - color: Colors.red, - onPressed: () {}, + icon: Icon(Icons + .location_on), + color: + Colors.red, + onPressed: + () {}, ), ), Expanded( flex: 1, child: IconButton( - icon: Icon(Icons.phone), - color: Colors.red, - onPressed: () {}, + icon: Icon(Icons + .phone), + color: + Colors.red, + onPressed: + () {}, ), ), ], ), - Divider(height: 1.2, color: Colors.grey) + Divider( + height: 1.2, + color: Colors.grey) ], ), ); @@ -431,8 +540,12 @@ class __ProductDetailPageState extends State { ], ), ), - bottomSheet: footerWidget(widget.product.stockAvailability != 'Out of stock', widget.product.orderMaximumQuantity, - widget.product.orderMinimumQuantity, widget.product.stockQuantity, widget.product), + bottomSheet: footerWidget( + widget.product.stockAvailability != 'Out of stock', + widget.product.orderMaximumQuantity, + widget.product.orderMinimumQuantity, + widget.product.stockQuantity, + widget.product), ) : AppScaffold( appBarTitle: 'product detail page', @@ -465,12 +578,18 @@ class __ProductDetailPageState extends State { alignment: Alignment.centerRight, child: languageID == 'ar' ? Text( - widget.product.discountDescriptionn, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17), + widget.product + .discountDescriptionn, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 17), ) : Text( - widget.product.discountDescription, - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17), + widget.product + .discountDescription, + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 17), ), ), ), @@ -481,7 +600,8 @@ class __ProductDetailPageState extends State { flex: 0, child: Container( child: Image( - image: AssetImage('assets/images/offer.png'), + image: AssetImage( + 'assets/images/offer.png'), ), ), ), @@ -551,7 +671,9 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).details, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -579,7 +701,9 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).reviews, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -607,7 +731,9 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).availability, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.bold), ), color: Colors.white, ), @@ -635,7 +761,10 @@ class __ProductDetailPageState extends State { Container( child: Text( TranslationBase.of(context).description, - style: TextStyle(fontSize: 17, color: Colors.grey, fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 17, + color: Colors.grey, + fontWeight: FontWeight.w600), ), ), SizedBox( @@ -643,8 +772,12 @@ class __ProductDetailPageState extends State { ), Container( child: Text( - languageID == 'ar' ? widget.product.fullDescriptionn : widget.product.fullDescription, - style: TextStyle(fontSize: 16, fontFamily: 'WorkSans-Regular'), + languageID == 'ar' + ? widget.product.fullDescriptionn + : widget.product.fullDescription, + style: TextStyle( + fontSize: 16, + fontFamily: 'WorkSans-Regular'), ), ), ], @@ -652,79 +785,132 @@ class __ProductDetailPageState extends State { ) : 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, - ), - ), - ], + 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), + ), ), - ), - SizedBox( - height: 10, - ), - Container( - child: Text( - model.productDetailService[0].reviews[index].reviewText, - style: TextStyle(fontSize: 20), + 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: 50, - ), - Divider(height: 1, color: Colors.grey), - ], + ], + ), ), - ); - }, - ) - : Container( - padding: EdgeInsets.all(15), - alignment: Alignment.center, - child: Text('No Reviews Available'), - ), + 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('No Reviews Available'), + ), ) : isAvailabilty ? BaseView( - onModelReady: (model) => model.getProductLocationData(), - builder: (_, model, wi) => ListView.builder( + 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) { + itemCount: model + .productLocationService.length, + itemBuilder: (BuildContext context, + int index) { return Padding( padding: EdgeInsets.all(8.0), child: Column( @@ -733,11 +919,15 @@ class __ProductDetailPageState extends State { children: [ Row( // crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, children: [ Expanded( flex: 1, - child: Image.network(model.productLocationService[index].projectImageUrl), + child: Image.network(model + .productLocationService[ + index] + .projectImageUrl), ), SizedBox( width: 10, @@ -745,16 +935,25 @@ class __ProductDetailPageState extends State { Expanded( flex: 4, child: Text( - model.productLocationService[index].locationDescription + + model + .productLocationService[ + index] + .locationDescription + "\n" + - fixingString(model.productLocationService[0].cityName.toString()), - style: TextStyle(fontSize: 12), + fixingString(model + .productLocationService[ + 0] + .cityName + .toString()), + style: TextStyle( + fontSize: 12), ), ), Expanded( flex: 1, child: IconButton( - icon: Icon(Icons.location_on), + icon: Icon(Icons + .location_on), color: Colors.red, onPressed: () {}, ), @@ -762,14 +961,17 @@ class __ProductDetailPageState extends State { Expanded( flex: 1, child: IconButton( - icon: Icon(Icons.phone), + icon: + Icon(Icons.phone), color: Colors.red, onPressed: () {}, ), ), ], ), - Divider(height: 1.2, color: Colors.grey) + Divider( + height: 1.2, + color: Colors.grey) ], ), ); @@ -784,8 +986,12 @@ class __ProductDetailPageState extends State { ], ), ), - bottomSheet: footerWidget(widget.product.stockAvailability != 'Out of stock', widget.product.orderMaximumQuantity, - widget.product.orderMinimumQuantity, widget.product.stockQuantity, widget.product), + bottomSheet: footerWidget( + widget.product.stockAvailability != 'Out of stock', + widget.product.orderMaximumQuantity, + widget.product.orderMinimumQuantity, + widget.product.stockQuantity, + widget.product), ); } } @@ -796,7 +1002,8 @@ class footerWidget extends StatefulWidget { final int minQuantity; final int quantityLimit; final PharmacyProduct item; - footerWidget(this.isAvailble, this.maxQuantity, this.minQuantity, this.quantityLimit, this.item); + footerWidget(this.isAvailble, this.maxQuantity, this.minQuantity, + this.quantityLimit, this.item); @override _footerWidgetState createState() => _footerWidgetState(); } @@ -826,7 +1033,8 @@ class _footerWidgetState extends State { padding: const EdgeInsets.all(8.0), child: Text( TranslationBase.of(context).quantity, - style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 15, fontWeight: FontWeight.bold), ), ), // ListView( @@ -848,7 +1056,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '1', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -873,7 +1083,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '2', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -898,7 +1110,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '3', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -923,7 +1137,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '4', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -948,7 +1164,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '5', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -973,7 +1191,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '6', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -998,7 +1218,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '7', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -1023,7 +1245,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '8', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -1048,7 +1272,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '9', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -1073,7 +1299,9 @@ class _footerWidgetState extends State { color: Colors.white, child: Text( '10', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 20), ), ), onTap: () { @@ -1094,7 +1322,8 @@ class _footerWidgetState extends State { Container( width: 50.0, child: TextField( - decoration: InputDecoration(labelText: 'quantity #'), + decoration: + InputDecoration(labelText: 'quantity #'), onChanged: (text) { print(price); print(widget.quantityLimit); @@ -1173,7 +1402,10 @@ class _footerWidgetState extends State { alignment: Alignment.center, child: Text( TranslationBase.of(context).addToCart, - style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 15), ), ), ) @@ -1188,7 +1420,10 @@ class _footerWidgetState extends State { color: Colors.green, child: Text( TranslationBase.of(context).addToCart, - style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 15), ), ), ), @@ -1204,7 +1439,10 @@ class _footerWidgetState extends State { alignment: Alignment.center, child: Text( TranslationBase.of(context).buyNow, - style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 15), ), ), ) @@ -1214,7 +1452,8 @@ class _footerWidgetState extends State { addToCartFunction(price, widget.item.id); Navigator.push( context, - MaterialPageRoute(builder: (context) => CartOrderPage()), + MaterialPageRoute( + builder: (context) => CartOrderPage()), ); }, child: Container( @@ -1224,7 +1463,10 @@ class _footerWidgetState extends State { color: Colors.blue, child: Text( TranslationBase.of(context).buyNow, - style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 15), ), ), ), @@ -1265,12 +1507,15 @@ class _productNameAndPriceState extends State { widget.item.stockAvailability, style: widget.item.stockAvailability == 'Out of stock' ? TextStyle(fontWeight: FontWeight.bold, color: Colors.red) - : TextStyle(fontWeight: FontWeight.bold, color: Colors.green), + : TextStyle( + fontWeight: FontWeight.bold, color: Colors.green), ), SizedBox(width: 20), - widget.item.stockAvailability == 'Out of stock' && customerId != null + widget.item.stockAvailability == 'Out of stock' && + customerId != null ? InkWell( - onTap: () => notifyMeWhenAvailable(context, widget.item.id), + onTap: () => + notifyMeWhenAvailable(context, widget.item.id), child: Row(children: [ Text( TranslationBase.of(context).notifyMe, @@ -1288,7 +1533,9 @@ class _productNameAndPriceState extends State { ]), ) : Container( - margin: languageID == 'ar' ? EdgeInsets.only(right: 25) : EdgeInsets.only(left: 25), + margin: languageID == 'ar' + ? EdgeInsets.only(right: 25) + : EdgeInsets.only(left: 25), width: 40, height: 40, decoration: BoxDecoration( @@ -1324,9 +1571,12 @@ class _productNameAndPriceState extends State { child: Container( margin: EdgeInsets.only(left: 5), child: Align( - alignment: languageID == 'ar' ? Alignment.topRight : Alignment.topLeft, + alignment: + languageID == 'ar' ? Alignment.topRight : Alignment.topLeft, child: Text( - languageID == 'ar' ? widget.item.fullDescriptionn : widget.item.fullDescription, + languageID == 'ar' + ? widget.item.fullDescriptionn + : widget.item.fullDescription, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15), ), ), @@ -1358,7 +1608,9 @@ class _productNameAndPriceState extends State { child: Container( child: widget.item.rxMessage != null ? Text( - languageID == 'ar' ? widget.item.rxMessagen.toString() : widget.item.rxMessage.toString(), + languageID == 'ar' + ? widget.item.rxMessagen.toString() + : widget.item.rxMessage.toString(), style: TextStyle(color: Colors.red, fontSize: 10), ) : Container()), @@ -1524,7 +1776,9 @@ slideDetail() { ), color: Colors.white, ), - child: const Text('1', textAlign: TextAlign.center, style: TextStyle(color: Color(0xFF000000))), + child: const Text('1', + textAlign: TextAlign.center, + style: TextStyle(color: Color(0xFF000000))), ), ) ], @@ -1606,7 +1860,13 @@ settingModalBottomSheet(context) { leading: new Icon(Icons.shopping_cart), title: new Text('Add to cart'), onTap: () => { - if (price > 0) {addToCartFunction(price, itemID)} else {AppToast.showErrorToast(message: "you should add quantity")} + if (price > 0) + {addToCartFunction(price, itemID)} + else + { + AppToast.showErrorToast( + message: "you should add quantity") + } }), new ListTile( leading: new Icon(Icons.favorite_border), @@ -1617,7 +1877,8 @@ settingModalBottomSheet(context) { leading: new Icon(Icons.compare), title: new Text('Compare'), onTap: () => { - Provider.of(context, listen: false).addItem(specificationData), + Provider.of(context, listen: false) + .addItem(specificationData), }, ), ], diff --git a/lib/pages/search_products_page.dart b/lib/pages/search_products_page.dart index 45cafd35..73b17558 100644 --- a/lib/pages/search_products_page.dart +++ b/lib/pages/search_products_page.dart @@ -1,6 +1,8 @@ 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/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; @@ -8,6 +10,7 @@ import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_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 'base/base_view.dart'; @@ -45,13 +48,13 @@ class _SearchProductsPageState extends State { child: Row( children: [ Container( - width: MediaQuery.of(context).size.width * 0.79, + width: MediaQuery.of(context).size.width * 0.70, child: Form( key: _formKey, child: TextFields( autoFocus: true, hintText: 'Search', - fontSize: 19.0, + fontSize: 14.5, prefixIcon: Icon(Icons.search), inputAction: TextInputAction.search, onSaved: (value) { @@ -102,170 +105,192 @@ class _SearchProductsPageState extends State { child: NetworkBaseView( baseViewModel: model, child: model.searchList.isNotEmpty - ? Container( - height: MediaQuery.of(context).size.height * 0.80, - child: GridView.builder( - //physics: NeverScrollableScrollPhysics(), - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 0.5, - mainAxisSpacing: 2.0, - childAspectRatio: 1.0, - ), - itemCount: model.searchList.length, - itemBuilder: (BuildContext context, int index) { - return Card( - color: model.searchList[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), + ? InkWell( + child: Container( + height: MediaQuery.of(context).size.height * 0.80, + child: GridView.builder( + //physics: NeverScrollableScrollPhysics(), + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + crossAxisSpacing: 0.5, + mainAxisSpacing: 2.0, + childAspectRatio: 1.0, + ), + itemCount: model.searchList.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + child: Card( + color: model.searchList[index] + .discountName != + null + ? Color(0xffFFFF00) + : Colors.white, + elevation: 0, + shape: Border( + right: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + left: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + bottom: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + top: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), ), - color: Colors.white, - ), - padding: - EdgeInsets.symmetric(horizontal: 0), - width: - MediaQuery.of(context).size.width / 3, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Stack( + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(110.0), + ), + color: Colors.white, + ), + padding: + EdgeInsets.symmetric(horizontal: 0), + width: + MediaQuery.of(context).size.width / + 3, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - Container( - margin: EdgeInsets.fromLTRB( - 0, 16, 0, 0), - alignment: Alignment.center, - child: Image.network( - model.searchList[index].images - .isNotEmpty - ? model.searchList[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, - ), + Stack( + children: [ + Container( + margin: EdgeInsets.fromLTRB( + 0, 16, 0, 0), + alignment: Alignment.center, + child: Image.network( + model.searchList[index] + .images.isNotEmpty + ? model + .searchList[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.searchList[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.searchList[index] + .rxMessage != + null + ? model + .searchList[index] + .rxMessage + : "", + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ), + ), + ], ), Container( - width: model.searchList[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)), + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, ), - child: Texts( - model.searchList[index] - .rxMessage != - null - ? model.searchList[index] - .rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ), - ), - ], - ), - Container( - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, - ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Texts( - model.searchList[index].name, - regular: true, - fontSize: 12, - fontWeight: FontWeight.w400, - ), - Padding( - padding: const EdgeInsets.only( - top: 4, bottom: 4), - child: Texts( - "SAR ${model.searchList[index].price}", - bold: true, - fontSize: 14, - ), - ), - Row( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - StarRating( - totalAverage: model - .searchList[ - index] - .approvedRatingSum > - 0 - ? (model - .searchList[ - index] - .approvedRatingSum - .toDouble() / - model - .searchList[ - index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: true), Texts( - "(${model.searchList[index].approvedTotalReviews})", + model + .searchList[index].name, regular: true, - fontSize: 10, + fontSize: 12, fontWeight: FontWeight.w400, - ) + ), + Padding( + padding: + const EdgeInsets.only( + top: 4, bottom: 4), + child: Texts( + "SAR ${model.searchList[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ + StarRating( + totalAverage: model + .searchList[ + index] + .approvedRatingSum > + 0 + ? (model + .searchList[ + index] + .approvedRatingSum + .toDouble() / + model + .searchList[ + index] + .approvedRatingSum + .toDouble()) + .toDouble() + : 0, + forceStars: true), + Texts( + "(${model.searchList[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: + FontWeight.w400, + ) + ], + ), ], ), - ], - ), + ), + ], ), - ], + ), ), - ), - ); - }, + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage( + model.searchList[index]), + )), + }, + ); + }, + ), ), ) : Texts(msg), diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 45c9fd6c..502df3d9 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -1,10 +1,12 @@ 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/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -607,168 +609,189 @@ class _SubCategorisePageState extends State { itemBuilder: (BuildContext context, int index) { return NetworkBaseView( baseViewModel: model, - child: Card( - color: model.subProducts[index] - .discountName != - null - ? Color(0xffFFFF00) - : Colors.white, - elevation: 0, - shape: Border( - right: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - left: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - bottom: BorderSide( - color: Colors.grey.shade300, - width: 1, + child: InkWell( + child: Card( + color: model.subProducts[index] + .discountName != + null + ? Color(0xffFFFF00) + : Colors.white, + elevation: 0, + shape: Border( + right: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + left: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + bottom: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + top: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), ), - top: BorderSide( - color: Colors.grey.shade300, - width: 1, + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, ), - ), - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(110.0), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(110.0), + ), + color: Colors.white, ), - color: Colors.white, - ), - padding: EdgeInsets.symmetric( - horizontal: 0), - width: MediaQuery.of(context) - .size - .width / - 3, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Stack( - children: [ - Container( - margin: EdgeInsets.fromLTRB( - 0, 16, 0, 0), - alignment: Alignment.center, - child: Image.network( - model.subProducts[index] - .images.isNotEmpty - ? model - .subProducts[ - index] - .images[0] - .thumb - : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', - fit: BoxFit.cover, - height: 80, - ), - ), - Container( - width: model + padding: EdgeInsets.symmetric( + horizontal: 0), + width: MediaQuery.of(context) + .size + .width / + 3, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Stack( + children: [ + Container( + margin: + EdgeInsets.fromLTRB( + 0, 16, 0, 0), + alignment: + Alignment.center, + child: Image.network( + model .subProducts[ index] - .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)), + .images + .isNotEmpty + ? model + .subProducts[ + index] + .images[0] + .thumb + : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', + fit: BoxFit.cover, + height: 80, + ), ), - child: Texts( - model.subProducts[index] + Container( + width: model + .subProducts[ + index] .rxMessage != null - ? model - .subProducts[ - index] - .rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w400, - ), - ), - ], - ), - Container( - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, - ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Texts( - model.subProducts[index] - .name, - regular: true, - fontSize: 12, - fontWeight: - FontWeight.w400, - ), - Padding( + ? MediaQuery.of( + context) + .size + .width / + 5 + : 0, padding: - const EdgeInsets.only( - top: 4, - bottom: 4), + EdgeInsets.all(4), + decoration: BoxDecoration( + color: + Color(0xffb23838), + borderRadius: + BorderRadius.only( + topLeft: Radius + .circular( + 6)), + ), child: Texts( - "SAR ${model.subProducts[index].price}", - bold: true, - fontSize: 14, + model.subProducts[index] + .rxMessage != + null + ? model + .subProducts[ + index] + .rxMessage + : "", + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: + FontWeight.w400, ), ), - Row( - children: [ - StarRating( - totalAverage: model - .subProducts[ - index] - .approvedRatingSum > - 0 - ? (model.subProducts[index].approvedRatingSum - .toDouble() / - model - .subProducts[index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: true), - Texts( - "(${model.subProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w400, - ) - ], - ), ], ), - ), - ], + Container( + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Texts( + model.subProducts[index] + .name, + regular: true, + fontSize: 12, + fontWeight: + FontWeight.w400, + ), + Padding( + padding: + const EdgeInsets + .only( + top: 4, + bottom: 4), + child: Texts( + "SAR ${model.subProducts[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ + StarRating( + totalAverage: model + .subProducts[ + index] + .approvedRatingSum > + 0 + ? (model.subProducts[index].approvedRatingSum + .toDouble() / + model + .subProducts[index] + .approvedRatingSum + .toDouble()) + .toDouble() + : 0, + forceStars: true), + Texts( + "(${model.subProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: + FontWeight.w400, + ) + ], + ), + ], + ), + ), + ], + ), ), ), + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage( + model.subProducts[index]), + )), + }, )); }, ), @@ -780,158 +803,184 @@ class _SubCategorisePageState extends State { itemCount: model.subProducts.length, itemBuilder: (BuildContext context, int index) { - return 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, + 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.subProducts[index] - .images.isNotEmpty - ? model - .subProducts[ - index] - .images[0] - .thumb - : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', - fit: BoxFit.contain, - height: 80, + Container( + margin: + EdgeInsets.fromLTRB( + 0, 0, 0, 0), + alignment: + Alignment.center, + child: Image.network( + model + .subProducts[ + index] + .images + .isNotEmpty + ? model + .subProducts[ + index] + .images[0] + .thumb + : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', + fit: BoxFit.contain, + height: 80, + ), ), - ), - ], + ], + ), + Column( + children: [ + Container( + width: model + .subProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5 + : 0, + padding: + EdgeInsets.all(4), + decoration: BoxDecoration( + color: + Color(0xffb23838), + borderRadius: + BorderRadius.only( + topLeft: Radius + .circular( + 6)), + ), + child: Texts( + model.subProducts[index] + .rxMessage != + null + ? model + .subProducts[ + index] + .rxMessage + : "", + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: + FontWeight.w400, + ), + ), + ], + ), + ], + ), + Container( + height: 100.0, + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, ), - Column( + child: Column( + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ + SizedBox( + height: 4.0, + ), Container( - width: model - .subProducts[ - index] - .rxMessage != - null - ? MediaQuery.of(context) + width: + MediaQuery.of(context) .size - .width / - 5 - : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular(6)), - ), + .width * + 0.65, child: Texts( model.subProducts[index] - .rxMessage != - null - ? model - .subProducts[ - index] - .rxMessage - : "", - color: Colors.white, + .name, regular: true, - fontSize: 10, + fontSize: 13.2, fontWeight: - FontWeight.w400, + FontWeight.w500, + maxLines: 5, ), ), - ], - ), - ], - ), - 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( - height: 35.0, - width: 250.0, - child: Texts( - model.subProducts[index] - .name, - regular: true, - fontSize: 13.2, - fontWeight: FontWeight.w500, - maxLines: 2, + SizedBox( + height: 8.0, ), - ), - SizedBox( - height: 8.0, - ), - Padding( - padding: - const EdgeInsets.only( - top: 4, bottom: 4), - child: Texts( - "SAR ${model.subProducts[index].price}", - bold: true, - fontSize: 14, + Padding( + padding: + const EdgeInsets.only( + top: 4, bottom: 4), + child: Texts( + "SAR ${model.subProducts[index].price}", + bold: true, + fontSize: 14, + ), ), - ), - Row( - children: [ - StarRating( - totalAverage: model - .subProducts[ - index] - .approvedRatingSum > - 0 - ? (model - .subProducts[ - index] - .approvedRatingSum - .toDouble() / - model - .parentProducts[ - index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: true), - Texts( - "(${model.subProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: - FontWeight.w400, - ) - ], - ), - ], + Row( + children: [ + StarRating( + totalAverage: model + .subProducts[ + index] + .approvedRatingSum > + 0 + ? (model + .subProducts[ + index] + .approvedRatingSum + .toDouble() / + model + .parentProducts[ + index] + .approvedRatingSum + .toDouble()) + .toDouble() + : 0, + forceStars: true), + Texts( + "(${model.subProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: + FontWeight.w400, + ) + ], + ), + ], + ), ), - ), - ], + ], + ), ), + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage( + model.subProducts[index]), + )), + }, ); }), ) From e050f87a64bdef4bb01ed23990a3d007c8313347 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Tue, 23 Feb 2021 10:24:10 +0200 Subject: [PATCH 3/4] pharmacy bugs --- .../service/pharmacy_categorise_service.dart | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/core/service/pharmacy_categorise_service.dart b/lib/core/service/pharmacy_categorise_service.dart index 67bcb206..479fd25f 100644 --- a/lib/core/service/pharmacy_categorise_service.dart +++ b/lib/core/service/pharmacy_categorise_service.dart @@ -236,25 +236,30 @@ class PharmacyCategoriseService extends BaseService { GET_BRAND_ITEMS, onSuccess: (dynamic response, int statusCode) { response['products'].forEach((item) { - _finalProducts.add(FinalProductsModel.fromJson(item)); + _finalProducts.add(PharmacyProduct.fromJson(item)); }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, queryParams: queryParams, + }, + queryParams: queryParams, ); } Future getLastVisitedProducts() async { String lastVisited = ""; - if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != null) { - lastVisited = await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS); + if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != + null) { + lastVisited = + await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS); 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(FinalProductsModel.fromJson(item)); + _finalProducts.add(PharmacyProduct.fromJson(item)); }); }, onFailure: (String error, int statusCode) { hasError = true; @@ -269,13 +274,14 @@ class PharmacyCategoriseService extends BaseService { Future getBestSellerProducts() async { 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', + '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(FinalProductsModel.fromJson(item)); + _finalProducts.add(PharmacyProduct.fromJson(item)); }); }, onFailure: (String error, int statusCode) { hasError = true; From f3cdd08857ef12d19cc5ab280604f284dd5ffd77 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Mon, 1 Mar 2021 10:46:39 +0200 Subject: [PATCH 4/4] adding fharmacy payment feature --- lib/core/model/pharmacies/BillingAddress.dart | 17 + lib/core/model/pharmacies/Customer.dart | 6 +- lib/core/model/pharmacies/ShoppingCart.dart | 73 +- lib/core/model/pharmacies/order_detail.dart | 297 ++++++ lib/core/model/pharmacies/order_model.dart | 134 ++- .../pharmacyModule/OrderPreviewViewModel.dart | 2 +- .../order_model_view_model.dart | 11 +- .../screens/cart-order-preview.dart | 30 +- lib/pages/pharmacy/order/OrderDetails.dart | 981 ++++++++++-------- lib/pages/pharmacy/order/ProductReview.dart | 3 +- lib/pages/pharmacy/order/TrackDriver.dart | 5 +- .../cancelOrder_service.dart | 5 +- .../orderDetails_service.dart | 13 +- lib/widgets/in_app_browser/InAppBrowser.dart | 78 +- lib/widgets/pharmacy/product_tile.dart | 5 +- 15 files changed, 1075 insertions(+), 585 deletions(-) create mode 100644 lib/core/model/pharmacies/order_detail.dart diff --git a/lib/core/model/pharmacies/BillingAddress.dart b/lib/core/model/pharmacies/BillingAddress.dart index 765ac54d..418b28a7 100644 --- a/lib/core/model/pharmacies/BillingAddress.dart +++ b/lib/core/model/pharmacies/BillingAddress.dart @@ -1,3 +1,5 @@ +import 'package:google_maps_flutter/google_maps_flutter.dart'; + class BillingAddress { String id; String firstName; @@ -81,4 +83,19 @@ class BillingAddress { data['lat_long'] = this.latLong; return data; } + + LatLng getLocation(){ + if(latLong.contains(',')){ + var parts = latLong.trim().split(','); + if(parts.length == 2){ + var lat = double.tryParse(parts.first); + var lng = double.tryParse(parts.last); + if(lat != null || lng != null) { + var location = LatLng(lat, lng); + return location; + } + } + } + return null; + } } diff --git a/lib/core/model/pharmacies/Customer.dart b/lib/core/model/pharmacies/Customer.dart index e3defbbe..0462c0c2 100644 --- a/lib/core/model/pharmacies/Customer.dart +++ b/lib/core/model/pharmacies/Customer.dart @@ -32,6 +32,7 @@ class Customer { String lastLoginDateUtc; String lastActivityDateUtc; int registeredInStoreId; + List roleIds; Customer( {this.billingAddress, @@ -63,7 +64,8 @@ class Customer { this.createdOnUtc, this.lastLoginDateUtc, this.lastActivityDateUtc, - this.registeredInStoreId}); + this.registeredInStoreId, + this.roleIds}); Customer.fromJson(Map json) { billingAddress = json['billing_address'] != null @@ -105,6 +107,7 @@ class Customer { lastLoginDateUtc = json['last_login_date_utc']; lastActivityDateUtc = json['last_activity_date_utc']; registeredInStoreId = json['registered_in_store_id']; + roleIds = json['role_ids'].cast(); } Map toJson() { @@ -145,6 +148,7 @@ class Customer { data['last_login_date_utc'] = this.lastLoginDateUtc; data['last_activity_date_utc'] = this.lastActivityDateUtc; data['registered_in_store_id'] = this.registeredInStoreId; + data['role_ids'] = this.roleIds; return data; } } diff --git a/lib/core/model/pharmacies/ShoppingCart.dart b/lib/core/model/pharmacies/ShoppingCart.dart index f965203a..4bd460aa 100644 --- a/lib/core/model/pharmacies/ShoppingCart.dart +++ b/lib/core/model/pharmacies/ShoppingCart.dart @@ -7,22 +7,33 @@ class ShoppingCart { // List productAttributes; double customerEnteredPrice; int quantity; - String discountAmountInclTax; - String subtotal; - String subtotalWithVat; - String subtotalVatAmount; - String subtotalVatRate; - String currency; - String currencyn; - String rentalStartDateUtc; - String rentalEndDateUtc; - String createdOnUtc; - String updatedOnUtc; - String shoppingCartType; + dynamic discountAmountInclTax; + dynamic subtotal; + dynamic subtotalWithVat; + dynamic subtotalVatAmount; + dynamic subtotalVatRate; + dynamic currency; + dynamic currencyn; + dynamic rentalStartDateUtc; + dynamic rentalEndDateUtc; + dynamic createdOnUtc; + dynamic updatedOnUtc; + dynamic shoppingCartType; int productId; PharmacyProduct product; int customerId; Customer customer; + double unitPriceInclTax; + double unitPriceExclTax; + double priceInclTax; + double priceExclTax; + dynamic discountAmountExclTax; + double originalProductCost; + String attributeDescription; + int downloadCount; + bool isDownloadActivated; + int licenseDownloadId; + double itemWeight; ShoppingCart( {this.languageId, @@ -45,7 +56,19 @@ class ShoppingCart { this.productId, this.product, this.customerId, - this.customer}); + this.customer, + this.unitPriceInclTax, + this.unitPriceExclTax, + this.priceInclTax, + this.priceExclTax, + this.discountAmountExclTax, + this.originalProductCost, + this.attributeDescription, + this.downloadCount, + this.isDownloadActivated, + this.licenseDownloadId, + this.itemWeight, + }); ShoppingCart.fromJson(Map json) { languageId = json['language_id']; @@ -78,6 +101,18 @@ class ShoppingCart { customer = json['customer'] != null ? new Customer.fromJson(json['customer']) : null; + + unitPriceInclTax = json['unit_price_incl_tax']; + unitPriceExclTax = json['unit_price_excl_tax']; + priceInclTax = json['price_incl_tax']; + priceExclTax = json['price_excl_tax']; + discountAmountExclTax = json['discount_amount_excl_tax']; + originalProductCost = json['original_product_cost']; + attributeDescription = json['attribute_description']; + downloadCount = json['download_count']; + isDownloadActivated = json['isDownload_activated']; + licenseDownloadId = json['license_download_id']; + itemWeight = json['item_weight']; } Map toJson() { @@ -110,6 +145,18 @@ class ShoppingCart { if (this.customer != null) { data['customer'] = this.customer.toJson(); } + data['unit_price_incl_tax'] = this.unitPriceInclTax; + data['unit_price_excl_tax'] = this.unitPriceExclTax; + data['price_incl_tax'] = this.priceInclTax; + data['price_excl_tax'] = this.priceExclTax; + data['discount_amount_excl_tax'] = this.discountAmountExclTax; + data['original_product_cost'] = this.originalProductCost; + data['attribute_description'] = this.attributeDescription; + data['download_count'] = this.downloadCount; + data['isDownload_activated'] = this.isDownloadActivated; + data['license_download_id'] = this.licenseDownloadId; + data['item_weight'] = this.itemWeight; + return data; } } diff --git a/lib/core/model/pharmacies/order_detail.dart b/lib/core/model/pharmacies/order_detail.dart new file mode 100644 index 00000000..cd53af92 --- /dev/null +++ b/lib/core/model/pharmacies/order_detail.dart @@ -0,0 +1,297 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/BillingAddress.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/Customer.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCart.dart'; + +class OrderDetailModel { + String id; + int storeId; + String orderGuid; + bool pickUpInStore; + String paymentMethodSystemName; + String paymentName; + String paymentNamen; + String customerCurrencyCode; + dynamic currencyRate; + dynamic customerTaxDisplayTypeId; + dynamic vatNumber; + double orderSubtotalInclTax; + double orderSubtotalExclTax; + dynamic orderSubTotalDiscountInclTax; + dynamic orderSubTotalDiscountExclTax; + double orderShippingInclTax; + dynamic orderShippingExclTax; + dynamic paymentMethodAdditionalFeeInclTax; + dynamic paymentMethodAdditionalFeeExclTax; + String taxRates; + double orderTax; + dynamic orderDiscount; + dynamic productCount; + dynamic orderTotal; + dynamic refundedAmount; + dynamic rewardPointsWereAdded; + dynamic rxAttachments; + String checkoutAttributeDescription; + int customerLanguageId; + int affiliateId; + String customerIp; + dynamic authorizationTransactionId; + dynamic authorizationTransactionCode; + dynamic authorizationTransactionResult; + dynamic captureTransactionId; + dynamic captureTransactionResult; + dynamic subscriptionTransactionId; + dynamic paidDateUtc; + String shippingMethod; + String shippingRateComputationMethodSystemName; + String customValuesXml; + bool deleted; + String createdOnUtc; + Customer customer; + int customerId; + BillingAddress billingAddress; + BillingAddress shippingAddress; + List orderItems; + int orderStatusId; + String orderStatus; + String orderStatusn; + int paymentStatusId; + String paymentStatus; + String paymentStatusn; + String shippingStatus; + String shippingStatusn; + String customerTaxDisplayType; + bool canCancel; + bool canRefund; + dynamic lakumAmount; + String preferDeliveryDate; + String preferDeliveryTime; + String preferDeliveryTimen; + + OrderDetailModel( + {this.id, + this.storeId, + this.orderGuid, + this.pickUpInStore, + this.paymentMethodSystemName, + this.paymentName, + this.paymentNamen, + this.customerCurrencyCode, + this.currencyRate, + this.customerTaxDisplayTypeId, + this.vatNumber, + this.orderSubtotalInclTax, + this.orderSubtotalExclTax, + this.orderSubTotalDiscountInclTax, + this.orderSubTotalDiscountExclTax, + this.orderShippingInclTax, + this.orderShippingExclTax, + this.paymentMethodAdditionalFeeInclTax, + this.paymentMethodAdditionalFeeExclTax, + this.taxRates, + this.orderTax, + this.orderDiscount, + this.productCount, + this.orderTotal, + this.refundedAmount, + this.rewardPointsWereAdded, + this.rxAttachments, + this.checkoutAttributeDescription, + this.customerLanguageId, + this.affiliateId, + this.customerIp, + this.authorizationTransactionId, + this.authorizationTransactionCode, + this.authorizationTransactionResult, + this.captureTransactionId, + this.captureTransactionResult, + this.subscriptionTransactionId, + this.paidDateUtc, + this.shippingMethod, + this.shippingRateComputationMethodSystemName, + this.customValuesXml, + this.deleted, + this.createdOnUtc, + this.customer, + this.customerId, + this.billingAddress, + this.shippingAddress, + this.orderItems, + this.orderStatusId, + this.orderStatus, + this.orderStatusn, + this.paymentStatusId, + this.paymentStatus, + this.paymentStatusn, + this.shippingStatus, + this.shippingStatusn, + this.customerTaxDisplayType, + this.canCancel, + this.canRefund, + this.lakumAmount, + this.preferDeliveryDate, + this.preferDeliveryTime, + this.preferDeliveryTimen}); + + OrderDetailModel.fromJson(Map json) { + id = json['id']; + storeId = json['store_id']; + orderGuid = json['order_guid']; + pickUpInStore = json['pick_up_in_store']; + paymentMethodSystemName = json['payment_method_system_name']; + paymentName = json['payment_name']; + paymentNamen = json['payment_namen']; + customerCurrencyCode = json['customer_currency_code']; + currencyRate = json['currency_rate']; + customerTaxDisplayTypeId = json['customer_tax_display_type_id']; + vatNumber = json['vat_number']; + orderSubtotalInclTax = json['order_subtotal_incl_tax']; + orderSubtotalExclTax = json['order_subtotal_excl_tax']; + orderSubTotalDiscountInclTax = json['order_sub_total_discount_incl_tax']; + orderSubTotalDiscountExclTax = json['order_sub_total_discount_excl_tax']; + orderShippingInclTax = json['order_shipping_incl_tax']; + orderShippingExclTax = json['order_shipping_excl_tax']; + paymentMethodAdditionalFeeInclTax = + json['payment_method_additional_fee_incl_tax']; + paymentMethodAdditionalFeeExclTax = + json['payment_method_additional_fee_excl_tax']; + taxRates = json['tax_rates']; + orderTax = json['order_tax']; + orderDiscount = json['order_discount']; + productCount = json['product_count']; + orderTotal = json['order_total']; + refundedAmount = json['refunded_amount']; + rewardPointsWereAdded = json['reward_points_were_added']; + rxAttachments = json['rx_attachments']; + checkoutAttributeDescription = json['checkout_attribute_description']; + customerLanguageId = json['customer_language_id']; + affiliateId = json['affiliate_id']; + customerIp = json['customer_ip']; + authorizationTransactionId = json['authorization_transaction_id']; + authorizationTransactionCode = json['authorization_transaction_code']; + authorizationTransactionResult = json['authorization_transaction_result']; + captureTransactionId = json['capture_transaction_id']; + captureTransactionResult = json['capture_transaction_result']; + subscriptionTransactionId = json['subscription_transaction_id']; + paidDateUtc = json['paid_date_utc']; + shippingMethod = json['shipping_method']; + shippingRateComputationMethodSystemName = + json['shipping_rate_computation_method_system_name']; + customValuesXml = json['custom_values_xml']; + deleted = json['deleted']; + createdOnUtc = json['created_on_utc']; + customer = json['customer'] != null + ? new Customer.fromJson(json['customer']) + : null; + customerId = json['customer_id']; + billingAddress = json['billing_address'] != null + ? new BillingAddress.fromJson(json['billing_address']) + : null; + shippingAddress = json['shipping_address'] != null + ? new BillingAddress.fromJson(json['shipping_address']) + : null; + if (json['order_items'] != null) { + orderItems = new List(); + json['order_items'].forEach((v) { + orderItems.add(new ShoppingCart.fromJson(v)); + }); + } + orderStatusId = json['order_status_id']; + orderStatus = json['order_status']; + orderStatusn = json['order_statusn']; + paymentStatusId = json['payment_status_id']; + paymentStatus = json['payment_status']; + paymentStatusn = json['payment_statusn']; + shippingStatus = json['shipping_status']; + shippingStatusn = json['shipping_statusn']; + customerTaxDisplayType = json['customer_tax_display_type']; + canCancel = json['can_cancel']; + canRefund = json['can_refund']; + lakumAmount = json['lakum_amount']; + preferDeliveryDate = json['prefer_delivery_date']; + preferDeliveryTime = json['prefer_delivery_time']; + preferDeliveryTimen = json['prefer_delivery_timen']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['store_id'] = this.storeId; + data['order_guid'] = this.orderGuid; + data['pick_up_in_store'] = this.pickUpInStore; + data['payment_method_system_name'] = this.paymentMethodSystemName; + data['payment_name'] = this.paymentName; + data['payment_namen'] = this.paymentNamen; + data['customer_currency_code'] = this.customerCurrencyCode; + data['currency_rate'] = this.currencyRate; + data['customer_tax_display_type_id'] = this.customerTaxDisplayTypeId; + data['vat_number'] = this.vatNumber; + data['order_subtotal_incl_tax'] = this.orderSubtotalInclTax; + data['order_subtotal_excl_tax'] = this.orderSubtotalExclTax; + data['order_sub_total_discount_incl_tax'] = + this.orderSubTotalDiscountInclTax; + data['order_sub_total_discount_excl_tax'] = + this.orderSubTotalDiscountExclTax; + data['order_shipping_incl_tax'] = this.orderShippingInclTax; + data['order_shipping_excl_tax'] = this.orderShippingExclTax; + data['payment_method_additional_fee_incl_tax'] = + this.paymentMethodAdditionalFeeInclTax; + data['payment_method_additional_fee_excl_tax'] = + this.paymentMethodAdditionalFeeExclTax; + data['tax_rates'] = this.taxRates; + data['order_tax'] = this.orderTax; + data['order_discount'] = this.orderDiscount; + data['product_count'] = this.productCount; + data['order_total'] = this.orderTotal; + data['refunded_amount'] = this.refundedAmount; + data['reward_points_were_added'] = this.rewardPointsWereAdded; + data['rx_attachments'] = this.rxAttachments; + data['checkout_attribute_description'] = this.checkoutAttributeDescription; + data['customer_language_id'] = this.customerLanguageId; + data['affiliate_id'] = this.affiliateId; + data['customer_ip'] = this.customerIp; + data['authorization_transaction_id'] = this.authorizationTransactionId; + data['authorization_transaction_code'] = this.authorizationTransactionCode; + data['authorization_transaction_result'] = + this.authorizationTransactionResult; + data['capture_transaction_id'] = this.captureTransactionId; + data['capture_transaction_result'] = this.captureTransactionResult; + data['subscription_transaction_id'] = this.subscriptionTransactionId; + data['paid_date_utc'] = this.paidDateUtc; + data['shipping_method'] = this.shippingMethod; + data['shipping_rate_computation_method_system_name'] = + this.shippingRateComputationMethodSystemName; + data['custom_values_xml'] = this.customValuesXml; + data['deleted'] = this.deleted; + data['created_on_utc'] = this.createdOnUtc; + if (this.customer != null) { + data['customer'] = this.customer.toJson(); + } + data['customer_id'] = this.customerId; + if (this.billingAddress != null) { + data['billing_address'] = this.billingAddress.toJson(); + } + if (this.shippingAddress != null) { + data['shipping_address'] = this.shippingAddress.toJson(); + } + if (this.orderItems != null) { + data['order_items'] = this.orderItems.map((v) => v.toJson()).toList(); + } + data['order_status_id'] = this.orderStatusId; + data['order_status'] = this.orderStatus; + data['order_statusn'] = this.orderStatusn; + data['payment_status_id'] = this.paymentStatusId; + data['payment_status'] = this.paymentStatus; + data['payment_statusn'] = this.paymentStatusn; + data['shipping_status'] = this.shippingStatus; + data['shipping_statusn'] = this.shippingStatusn; + data['customer_tax_display_type'] = this.customerTaxDisplayType; + data['can_cancel'] = this.canCancel; + data['can_refund'] = this.canRefund; + data['lakum_amount'] = this.lakumAmount; + data['prefer_delivery_date'] = this.preferDeliveryDate; + data['prefer_delivery_time'] = this.preferDeliveryTime; + data['prefer_delivery_timen'] = this.preferDeliveryTimen; + return data; + } + +} \ No newline at end of file diff --git a/lib/core/model/pharmacies/order_model.dart b/lib/core/model/pharmacies/order_model.dart index 8872aaf8..42fc824d 100644 --- a/lib/core/model/pharmacies/order_model.dart +++ b/lib/core/model/pharmacies/order_model.dart @@ -9,6 +9,71 @@ List orderModelFromJson(String str) => List.from(json.de String orderModelToJson(List data) => json.encode(List.from(data.map((x) => x.toJson()))); class OrderModel { + + String id; + dynamic storeId; + String orderGuid; + bool pickUpInStore; + PaymentMethodSystemName paymentMethodSystemName; + PaymentName paymentName; + PaymentName paymentNamen; + CustomerCurrencyCode customerCurrencyCode; + dynamic currencyRate; + dynamic customerTaxDisplayTypeId; + dynamic vatNumber; + double orderSubtotalInclTax; + double orderSubtotalExclTax; + dynamic orderSubTotalDiscountInclTax; + dynamic orderSubTotalDiscountExclTax; + double orderShippingInclTax; + dynamic orderShippingExclTax; + dynamic paymentMethodAdditionalFeeInclTax; + dynamic paymentMethodAdditionalFeeExclTax; + String taxRates; + double orderTax; + dynamic orderDiscount; + dynamic productCount; + double orderTotal; + dynamic refundedAmount; + dynamic rewardPointsWereAdded; + String rxAttachments; + CheckoutAttributeDescription checkoutAttributeDescription; + dynamic customerLanguageId; + dynamic affiliateId; + CustomerIp customerIp; + String authorizationTransactionId; + dynamic authorizationTransactionCode; + dynamic authorizationTransactionResult; + dynamic captureTransactionId; + dynamic captureTransactionResult; + dynamic subscriptionTransactionId; + DateTime paidDateUtc; + ShippingMethod shippingMethod; + ShippingRateComputationMethodSystemName shippingRateComputationMethodSystemName; + String customValuesXml; + bool deleted; + DateTime createdOnUtc; + OrderModelCustomer customer; + dynamic customerId; + IngAddress billingAddress; + IngAddress shippingAddress; + List orderItems; + dynamic orderStatusId; + OrderStatus orderStatus; + OrderStatusn orderStatusn; + dynamic paymentStatusId; + PaymentStatus paymentStatus; + PaymentStatusn paymentStatusn; + ShippingStatus shippingStatus; + ShippingStatusn shippingStatusn; + CustomerTaxDisplayType customerTaxDisplayType; + bool canCancel; + bool canRefund; + dynamic lakumAmount; + DateTime preferDeliveryDate; + PreferDeliveryTime preferDeliveryTime; + PreferDeliveryTimen preferDeliveryTimen; + OrderModel({ this.id, this.storeId, @@ -75,70 +140,6 @@ class OrderModel { this.preferDeliveryTimen, }); - String id; - dynamic storeId; - String orderGuid; - bool pickUpInStore; - PaymentMethodSystemName paymentMethodSystemName; - PaymentName paymentName; - PaymentName paymentNamen; - CustomerCurrencyCode customerCurrencyCode; - dynamic currencyRate; - dynamic customerTaxDisplayTypeId; - dynamic vatNumber; - double orderSubtotalInclTax; - double orderSubtotalExclTax; - dynamic orderSubTotalDiscountInclTax; - dynamic orderSubTotalDiscountExclTax; - double orderShippingInclTax; - dynamic orderShippingExclTax; - dynamic paymentMethodAdditionalFeeInclTax; - dynamic paymentMethodAdditionalFeeExclTax; - String taxRates; - double orderTax; - dynamic orderDiscount; - dynamic productCount; - double orderTotal; - dynamic refundedAmount; - dynamic rewardPointsWereAdded; - String rxAttachments; - CheckoutAttributeDescription checkoutAttributeDescription; - dynamic customerLanguageId; - dynamic affiliateId; - CustomerIp customerIp; - String authorizationTransactionId; - dynamic authorizationTransactionCode; - dynamic authorizationTransactionResult; - dynamic captureTransactionId; - dynamic captureTransactionResult; - dynamic subscriptionTransactionId; - DateTime paidDateUtc; - ShippingMethod shippingMethod; - ShippingRateComputationMethodSystemName shippingRateComputationMethodSystemName; - String customValuesXml; - bool deleted; - DateTime createdOnUtc; - OrderModelCustomer customer; - dynamic customerId; - IngAddress billingAddress; - IngAddress shippingAddress; - List orderItems; - dynamic orderStatusId; - OrderStatus orderStatus; - OrderStatusn orderStatusn; - dynamic paymentStatusId; - PaymentStatus paymentStatus; - PaymentStatusn paymentStatusn; - ShippingStatus shippingStatus; - ShippingStatusn shippingStatusn; - CustomerTaxDisplayType customerTaxDisplayType; - bool canCancel; - bool canRefund; - dynamic lakumAmount; - DateTime preferDeliveryDate; - PreferDeliveryTime preferDeliveryTime; - PreferDeliveryTimen preferDeliveryTimen; - factory OrderModel.fromJson(Map json) => OrderModel( id: json["id"], storeId: json["store_id"], @@ -1469,7 +1470,4 @@ class EnumValues { } return reverseMap; } -} - - - +} \ No newline at end of file diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index 06295188..7272969b 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -185,7 +185,7 @@ class OrderPreviewViewModel extends BaseViewModel { await _orderService.makeOrder(paymentCheckoutData, cartResponse.shoppingCarts); if (_orderService.hasError) { error = _orderService.error; - setState(ViewState.Error); + setState(ViewState.ErrorLocal); } else { setState(ViewState.Idle); } diff --git a/lib/core/viewModels/pharmacyModule/order_model_view_model.dart b/lib/core/viewModels/pharmacyModule/order_model_view_model.dart index f434db54..62bf00f4 100644 --- a/lib/core/viewModels/pharmacyModule/order_model_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/order_model_view_model.dart @@ -1,18 +1,17 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/LacumAccountInformation.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCartResponse.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; import 'package:diplomaticquarterapp/core/service/parmacyModule/order-preview-service.dart'; -import 'package:diplomaticquarterapp/pages/pharmacy/order/Order.dart'; -import 'package:diplomaticquarterapp/pages/pharmacy/order/OrderDetails.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/cancelOrder_service.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/orderDetails_service.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/order_service.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/order_model.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/orders_model.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; -import 'package:flutter/material.dart'; import '../../../locator.dart'; import '../base_view_model.dart'; @@ -21,10 +20,10 @@ class OrderModelViewModel extends BaseViewModel { List get orders => _orderService.orderList; OrderDetailsService _orderDetailsService = locator(); - List get orderListModel => _orderDetailsService.orderList; + List get orderListModel => _orderDetailsService.orderList; CancelOrderService _cancelOrderService = locator(); - List get cancelOrder => _cancelOrderService.cancelOrderList; + List get cancelOrder => _cancelOrderService.cancelOrderList; OrderPreviewService _orderServices = locator(); @@ -98,7 +97,7 @@ class OrderModelViewModel extends BaseViewModel { return res; } - Future makeReview(Product product, double rating, String reviewText) async { + Future makeReview(PharmacyProduct product, double rating, String reviewText) async { setState(ViewState.Busy); await _orderDetailsService.makeReview(product, rating, reviewText); if (_orderDetailsService.hasError) { diff --git a/lib/pages/pharmacies/screens/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-order-preview.dart index 9d819c1c..e0c062fa 100644 --- a/lib/pages/pharmacies/screens/cart-order-preview.dart +++ b/lib/pages/pharmacies/screens/cart-order-preview.dart @@ -9,6 +9,7 @@ import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-sel import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_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/others/app_scaffold_widget.dart'; @@ -25,9 +26,7 @@ class OrderPreviewPage extends StatelessWidget { @override Widget build(BuildContext context) { final mediaQuery = MediaQuery.of(context); - final height = mediaQuery.size.height - - 60 - - mediaQuery.padding.top; + final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; return BaseView( onModelReady: (model) => model.getShoppingCart(), @@ -781,23 +780,16 @@ class PaymentBottomWidget extends StatelessWidget { ), onPressed: (paymentData.address != null && paymentData.paymentOption != null) - ? () => { - model.makeOrder().then((_) { - if (model.state != ViewState.Idle) { - SnackBar snackBar = SnackBar( - content: Text( - 'Order has been placed successfully!!')); - scaffold.showSnackBar(snackBar); - } - - // Navigator.pushAndRemoveUntil( - // context, - // MaterialPageRoute( - // builder: (context) => - // PharmacyPage()), - // (Route r) => false); - }) + ? () async { + await model.makeOrder(); + if (model.state != ViewState.Idle) { + AppToast.showSuccessToast(message: "Order has been placed successfully!!"); + } else { + AppToast.showErrorToast(message: model.error); } + Navigator.pop(context); + Navigator.pop(context); + } : null, child: Padding( padding: const EdgeInsets.symmetric(vertical: 16), diff --git a/lib/pages/pharmacy/order/OrderDetails.dart b/lib/pages/pharmacy/order/OrderDetails.dart index 670cb951..0c71bb38 100644 --- a/lib/pages/pharmacy/order/OrderDetails.dart +++ b/lib/pages/pharmacy/order/OrderDetails.dart @@ -1,28 +1,24 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/orders_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; +import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/order/Order.dart'; -import 'package:diplomaticquarterapp/pages/pharmacy/order/TrackDriver.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; +import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:diplomaticquarterapp/widgets//pharmacy/product_tile.dart'; -import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/order_model.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:flutter/src/widgets/image.dart' as flutterImage; -import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; -import 'package:diplomaticquarterapp/uitl/app_toast.dart'; -import 'package:provider/provider.dart'; - dynamic languageID; class OrderDetailsPage extends StatefulWidget { Orders orderModel; + OrderDetailsPage({@required this.orderModel}); // Orders orderModel; @@ -40,9 +36,9 @@ class _OrderDetailsPageState extends State { // AppSharedPreferences sharedPref = AppSharedPreferences(); String customerId; - List ordersList = []; + List ordersList = []; - List cancelledOrderList = []; + List cancelledOrderList = []; // String orderId="3516"; var model; @@ -52,6 +48,8 @@ class _OrderDetailsPageState extends State { var dataIsCancel; var dataIsRefund; + MyInAppBrowser browser; + @override void initState() { getLanguageID(); @@ -71,183 +69,179 @@ class _OrderDetailsPageState extends State { appBarTitle: TranslationBase.of(context).orderDetail, isShowAppBar: true, isPharmacy: true, - body: Container( - color: Colors.white, - child: SingleChildScrollView( - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - margin: EdgeInsets.fromLTRB(10.0, 15.0, 1.0, 5.0), - child: Row( + baseViewModel: model, + body: model.orderListModel.length > 0 + ? Container( + color: Colors.white, + child: SingleChildScrollView( + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - SvgPicture.asset( - 'assets/images/pharmacy/shipping_mark_icon.svg', - width: 28, - height: 28, + Container( + margin: EdgeInsets.fromLTRB(10.0, 15.0, 1.0, 5.0), + child: Row( + children: [ + SvgPicture.asset( + 'assets/images/pharmacy/shipping_mark_icon.svg', + width: 28, + height: 28, + ), + Text( + TranslationBase.of(context).shippingAddress, + style: TextStyle( + fontSize: 13.0, + fontWeight: FontWeight.bold, + ), + ), + ], + ), ), - Text( - TranslationBase.of(context).shippingAddress, - style: TextStyle( - fontSize: 13.0, - fontWeight: FontWeight.bold, + Container( + margin: EdgeInsets.only(top: 15.0, right: 10.0), + padding: EdgeInsets.only(left: 11.0, right: 11.0), + decoration: BoxDecoration( + border: Border.all( + color: getStatusBackgroundColor(), + style: BorderStyle.solid, + width: 5.0, + ), + color: getStatusBackgroundColor(), + borderRadius: BorderRadius.circular(30.0)), + child: 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, + ), ), ), ], ), - ), - Container( - margin: EdgeInsets.only(top: 15.0, right: 10.0), - padding: EdgeInsets.only(left: 11.0, right: 11.0), - decoration: BoxDecoration( - border: Border.all( - color: getStatusBackgroundColor(), - style: BorderStyle.solid, - width: 5.0, - ), - color: getStatusBackgroundColor(), - borderRadius: BorderRadius.circular(30.0)), - child: Text( - languageID == "ar" - ? model.orderListModel[0].orderStatusn.toString() - : model.orderListModel[0].orderStatus - .toString() - .substring(12), -// TranslationBase.of(context).delivered, - style: TextStyle( - color: Colors.white, - fontSize: 13.0, - fontWeight: FontWeight.bold, - ), + Container( + margin: EdgeInsets.only(left: 10.0, top: 13.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "${model.orderListModel[0].shippingAddress.firstName} ${model.orderListModel[0].shippingAddress.lastName}", + style: TextStyle( + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ), + ]), ), - ), - ], - ), - Container( - margin: EdgeInsets.only(left: 10.0, top: 13.0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - model.orderListModel[0].shippingAddress.firstName - .toString() - .substring(10) + - ' ' + - model.orderListModel[0].shippingAddress.lastName - .toString() - .substring(9), - style: TextStyle( - fontSize: 15.0, - fontWeight: FontWeight.bold, - ), - ), - ]), - ), - Container( - margin: EdgeInsets.fromLTRB(10.0, 5.0, 1.0, 5.0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - model.orderListModel[0].shippingAddress.address1 - .toString() - .substring(9), - style: TextStyle( - fontSize: 10.0, - fontWeight: FontWeight.bold, - color: Colors.grey, - ), - ), - ]), - ), - Container( - margin: EdgeInsets.fromLTRB(10.0, 5.0, 1.0, 5.0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - model.orderListModel[0].shippingAddress.address2 - .toString() - .substring(9) + - ' ' + - model.orderListModel[0].shippingAddress.country - .toString() + - ' ' + - model.orderListModel[0].shippingAddress - .zipPostalCode - .toString(), - style: TextStyle( - fontSize: 10.0, - fontWeight: FontWeight.bold, - color: Colors.grey, - ), - ), - ]), - ), - Container( - child: Row( - children: [ Container( - margin: EdgeInsets.fromLTRB(10.0, 5.0, 8.0, 5.0), - child: SvgPicture.asset( - 'assets/images/pharmacy/mobile_number_icon.svg', - height: 13, - ), + margin: EdgeInsets.fromLTRB(10.0, 5.0, 1.0, 5.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + model.orderListModel[0].shippingAddress.address1 + .toString() + .substring(9), + style: TextStyle( + fontSize: 10.0, + fontWeight: FontWeight.bold, + color: Colors.grey, + ), + ), + ]), ), Container( - margin: EdgeInsets.only(top: 5.0, bottom: 5.0), - child: Text( - model.orderListModel[0].shippingAddress.phoneNumber - .toString(), - style: TextStyle( - fontSize: 15.0, - ), + margin: EdgeInsets.fromLTRB(10.0, 5.0, 1.0, 5.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + model.orderListModel[0].shippingAddress.address2 + .toString() + .substring(9) + + ' ' + + model.orderListModel[0].shippingAddress + .country + .toString() + + ' ' + + model.orderListModel[0].shippingAddress + .zipPostalCode + .toString(), + style: TextStyle( + fontSize: 10.0, + fontWeight: FontWeight.bold, + color: Colors.grey, + ), + ), + ]), + ), + Container( + child: Row( + children: [ + Container( + margin: EdgeInsets.fromLTRB(10.0, 5.0, 8.0, 5.0), + child: SvgPicture.asset( + 'assets/images/pharmacy/mobile_number_icon.svg', + height: 13, + ), + ), + Container( + margin: EdgeInsets.only(top: 5.0, bottom: 5.0), + child: Text( + model.orderListModel[0].shippingAddress + .phoneNumber + .toString(), + style: TextStyle( + fontSize: 15.0, + ), + ), + ), + ], ), ), - ], - ), - ), - Divider( - color: Colors.grey[350], - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - children: [ - Container( - margin: EdgeInsets.fromLTRB(10.0, 10.0, 5.0, 10.0), - child: SvgPicture.asset( - 'assets/images/pharmacy/shipping_truck_icon.svg', + Divider( + color: Colors.grey[350], height: 20, - width: 20, + thickness: 1, + indent: 0, + endIndent: 0, ), - ), - Container( - margin: EdgeInsets.all(10.0), - child: Text( - TranslationBase.of(context).shippedMethod, - style: TextStyle( - fontSize: 13.0, - fontWeight: FontWeight.bold, - ), - ), - ), - Container( - child: flutterImage.Image.asset( - model.orderListModel[0] - .shippingRateComputationMethodSystemName != - "Shipping.Aramex" - ? "assets/images/pharmacy_module/payment/LogoParmacyGreen.png" - : "assets/images/pharmacy_module/payment/aramex_shipping_logo.png", - fit: BoxFit.contain, + Row( + children: [ + Container( + margin: EdgeInsets.fromLTRB(10.0, 10.0, 5.0, 10.0), + child: SvgPicture.asset( + 'assets/images/pharmacy/shipping_truck_icon.svg', + height: 20, + width: 20, + ), + ), + Container( + margin: EdgeInsets.all(10.0), + child: Text( + TranslationBase.of(context).shippedMethod, + style: TextStyle( + fontSize: 13.0, + fontWeight: FontWeight.bold, + ), + ), + ), + Container( + child: flutterImage.Image.asset( + model.orderListModel[0] + .shippingRateComputationMethodSystemName != + "Shipping.Aramex" + ? "assets/images/pharmacy_module/payment/LogoParmacyGreen.png" + : "assets/images/pharmacy_module/payment/aramex_shipping_logo.png", + fit: BoxFit.contain, // height: 100, - width: 100, - ), - ), + width: 100, + ), + ), // Container( // child: widget.orderModel // .shippingRateComputationMethodSystemName == @@ -269,357 +263,373 @@ class _OrderDetailsPageState extends State { // ), // ), // ), - ], - ), - Divider( - color: Colors.grey[350], - height: 20, - thickness: 8, - indent: 0, - endIndent: 0, - ), - Row( - children: [ - Container( - margin: EdgeInsets.all(10.0), - child: SvgPicture.asset( - 'assets/images/pharmacy/credit_card_icon.svg', + ], + ), + Divider( + color: Colors.grey[350], height: 20, - width: 20, + thickness: 8, + indent: 0, + endIndent: 0, ), - ), - Container( - margin: EdgeInsets.only(bottom: 10.0, top: 10.0), - child: Text( - model.orderListModel[0].paymentName - .toString() - .substring(12), - style: TextStyle( - fontSize: 13.0, - fontWeight: FontWeight.bold, - ), + Row( + children: [ + Container( + margin: EdgeInsets.all(10.0), + child: SvgPicture.asset( + 'assets/images/pharmacy/credit_card_icon.svg', + height: 20, + width: 20, + ), + ), + Container( + margin: EdgeInsets.only(bottom: 10.0, top: 10.0), + child: Text( + model.orderListModel[0].paymentName + .toString() + .substring(12), + style: TextStyle( + fontSize: 13.0, + fontWeight: FontWeight.bold, + ), + ), + ), + ], ), - ), - ], - ), - Divider( - color: Colors.grey[350], - height: 20, - thickness: 8, - indent: 0, - endIndent: 0, - ), - Container( - padding: EdgeInsets.only(bottom: 15.0), - margin: EdgeInsets.only(left: 10.0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).orderDetail, - style: TextStyle( - fontSize: 15.0, - fontWeight: FontWeight.bold, - ), + Divider( + color: Colors.grey[350], + height: 20, + thickness: 8, + indent: 0, + endIndent: 0, ), - ], - ), - ), - ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: ScrollPhysics(), - itemCount: model.orderListModel[0].orderItems.length, - itemBuilder: (context, index) { - return Container( - child: productTile( - productName: model - .orderListModel[0].orderItems[index].product.name - .toString(), - productPrice: model - .orderListModel[0].orderItems[index].product.price - .toString(), - productRate: model.orderListModel[0].orderItems[index] - .product.approvedRatingSum - .toDouble(), - productReviews: model.orderListModel[0] - .orderItems[index].product.approvedTotalReviews, - totalPrice: - "${(model.orderListModel[0].orderItems[index].product.price * model.orderListModel[0].orderItems[index].quantity).toStringAsFixed(2)}", - qyt: model - .orderListModel[0].orderItems[index].quantity - .toString(), - isOrderDetails: true, - imgs: model.orderListModel[0].orderItems[index] - .product.images != - null && - model.orderListModel[0].orderItems[index] - .product.images.length != - 0 - ? model.orderListModel[0].orderItems[index] - .product.images[0].src - .toString() - : null, - status: model.orderListModel[0].orderStatusId, - product: - model.orderListModel[0].orderItems[index].product, - ), - ); - }), - - Container( - padding: EdgeInsets.only(bottom: 10.0), - margin: EdgeInsets.only(left: 10.0, top: 5.0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - TranslationBase.of(context).orderSummary, - style: TextStyle( - fontSize: 15.0, - fontWeight: FontWeight.bold, + Container( + padding: EdgeInsets.only(bottom: 15.0), + margin: EdgeInsets.only(left: 10.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).orderDetail, + style: TextStyle( + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ), + ], ), ), - ], - ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - padding: EdgeInsets.only(bottom: 10.0), - margin: EdgeInsets.only(top: 5.0, left: 10.0), - child: Text( - TranslationBase.of(context).subtotal, - style: TextStyle( - fontSize: 13.0, + ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: ScrollPhysics(), + itemCount: model.orderListModel[0].orderItems.length, + itemBuilder: (context, index) { + return Container( + child: productTile( + productName: model.orderListModel[0] + .orderItems[index].product.name + .toString(), + productPrice: model.orderListModel[0] + .orderItems[index].product.price + .toString(), + productRate: model.orderListModel[0] + .orderItems[index].product.approvedRatingSum + .toDouble(), + productReviews: model + .orderListModel[0] + .orderItems[index] + .product + .approvedTotalReviews, + totalPrice: + "${(model.orderListModel[0].orderItems[index].product.price * model.orderListModel[0].orderItems[index].quantity).toStringAsFixed(2)}", + qyt: model.orderListModel[0].orderItems[index] + .quantity + .toString(), + isOrderDetails: true, + imgs: model.orderListModel[0].orderItems[index] + .product.images != + null && + model + .orderListModel[0] + .orderItems[index] + .product + .images + .length != + 0 + ? model.orderListModel[0].orderItems[index] + .product.images[0].src + .toString() + : null, + status: model.orderListModel[0].orderStatusId, + product: model.orderListModel[0] + .orderItems[index].product, + ), + ); + }), + + Container( + padding: EdgeInsets.only(bottom: 10.0), + margin: EdgeInsets.only(left: 10.0, top: 5.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).orderSummary, + style: TextStyle( + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ), + ], ), ), - ), - Container( - padding: EdgeInsets.only(bottom: 10.0), - margin: EdgeInsets.fromLTRB(10.0, 5.0, 5.0, 5.0), - child: Row( + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( - margin: EdgeInsets.only(right: 5.0), + padding: EdgeInsets.only(bottom: 10.0), + margin: EdgeInsets.only(top: 5.0, left: 10.0), child: Text( - TranslationBase.of(context).sar, + TranslationBase.of(context).subtotal, style: TextStyle( fontSize: 13.0, ), ), ), - Text( - model.orderListModel[0].orderSubtotalExclTax - .toString(), - style: TextStyle( - fontSize: 13.0, + Container( + padding: EdgeInsets.only(bottom: 10.0), + margin: EdgeInsets.fromLTRB(10.0, 5.0, 5.0, 5.0), + child: Row( + children: [ + Container( + margin: EdgeInsets.only(right: 5.0), + child: Text( + TranslationBase.of(context).sar, + style: TextStyle( + fontSize: 13.0, + ), + ), + ), + Text( + model.orderListModel[0].orderSubtotalExclTax + .toString(), + style: TextStyle( + fontSize: 13.0, + ), + ), + ], ), ), ], ), - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - padding: EdgeInsets.only(bottom: 10.0), - margin: EdgeInsets.only(top: 5.0, left: 10.0), - child: Text( - TranslationBase.of(context).shipping, - style: TextStyle( - fontSize: 13.0, - ), - ), - ), - Container( - padding: EdgeInsets.only(bottom: 10.0), - margin: EdgeInsets.fromLTRB(10.0, 5.0, 5.0, 5.0), - child: Row( + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( - margin: EdgeInsets.only(right: 5.0), + padding: EdgeInsets.only(bottom: 10.0), + margin: EdgeInsets.only(top: 5.0, left: 10.0), child: Text( - TranslationBase.of(context).sar, + TranslationBase.of(context).shipping, style: TextStyle( fontSize: 13.0, ), ), ), - Text( - model.orderListModel[0].orderShippingExclTax - .toString(), - style: TextStyle( - fontSize: 13.0, + Container( + padding: EdgeInsets.only(bottom: 10.0), + margin: EdgeInsets.fromLTRB(10.0, 5.0, 5.0, 5.0), + child: Row( + children: [ + Container( + margin: EdgeInsets.only(right: 5.0), + child: Text( + TranslationBase.of(context).sar, + style: TextStyle( + fontSize: 13.0, + ), + ), + ), + Text( + model.orderListModel[0].orderShippingExclTax + .toString(), + style: TextStyle( + fontSize: 13.0, + ), + ), + ], ), ), ], ), - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - padding: EdgeInsets.only(bottom: 10.0), - margin: EdgeInsets.only(top: 5.0, left: 10.0), - child: Text( - TranslationBase.of(context).vat, - style: TextStyle( - fontSize: 13.0, - ), - ), - ), - Container( - padding: EdgeInsets.only(bottom: 10.0), - margin: EdgeInsets.fromLTRB(10.0, 5.0, 5.0, 5.0), - child: Row( + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( - margin: EdgeInsets.only(right: 5.0), + padding: EdgeInsets.only(bottom: 10.0), + margin: EdgeInsets.only(top: 5.0, left: 10.0), child: Text( - TranslationBase.of(context).sar, + TranslationBase.of(context).vat, style: TextStyle( fontSize: 13.0, ), ), ), - Text( - model.orderListModel[0].orderTax.toString(), - style: TextStyle( - fontSize: 13.0, + Container( + padding: EdgeInsets.only(bottom: 10.0), + margin: EdgeInsets.fromLTRB(10.0, 5.0, 5.0, 5.0), + child: Row( + children: [ + Container( + margin: EdgeInsets.only(right: 5.0), + child: Text( + TranslationBase.of(context).sar, + style: TextStyle( + fontSize: 13.0, + ), + ), + ), + Text( + model.orderListModel[0].orderTax.toString(), + style: TextStyle( + fontSize: 13.0, + ), + ), + ], ), ), ], ), - ), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - margin: EdgeInsets.only(top: 5.0, left: 10.0), - child: Text( - TranslationBase.of(context).total, - style: TextStyle( - fontSize: 15.0, - fontWeight: FontWeight.bold, - ), - ), - ), - Container( - margin: EdgeInsets.fromLTRB(10.0, 5.0, 5.0, 5.0), - child: Row( + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( - margin: EdgeInsets.only(right: 5.0), + margin: EdgeInsets.only(top: 5.0, left: 10.0), child: Text( - TranslationBase.of(context).sar, + TranslationBase.of(context).total, style: TextStyle( fontSize: 15.0, fontWeight: FontWeight.bold, ), ), ), - Text( - model.orderListModel[0].orderTotal.toString(), - style: TextStyle( - fontSize: 15.0, - fontWeight: FontWeight.bold, + Container( + margin: EdgeInsets.fromLTRB(10.0, 5.0, 5.0, 5.0), + child: Row( + children: [ + Container( + margin: EdgeInsets.only(right: 5.0), + child: Text( + TranslationBase.of(context).sar, + style: TextStyle( + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ), + ), + Text( + model.orderListModel[0].orderTotal.toString(), + style: TextStyle( + fontSize: 15.0, + fontWeight: FontWeight.bold, + ), + ), + ], ), ), ], ), - ), - ], - ), - model.orderListModel[0].orderStatusId == 10 - ? InkWell( - onTap: () { - model.makeOrder(); - }, - child: Container( + model.orderListModel[0].orderStatusId == 10 + ? InkWell( + onTap: () { + print(widget.orderModel.toString()); + print(model.orderListModel.toString()); + print("calc = ${5.9 * 3}"); + // TODO MOSA + openPayment( + model.orderListModel[0], model.user); + }, + child: Container( // margin: EdgeInsets.only(top: 20.0), - height: 50.0, - color: Colors.transparent, - child: Container( - padding: EdgeInsets.only(left: 130.0, right: 130.0), - decoration: BoxDecoration( - border: Border.all( - color: Colors.green, - style: BorderStyle.solid, - width: 4.0), - color: Colors.green, - borderRadius: BorderRadius.circular(5.0)), - child: Center( - child: Text( - TranslationBase.of(context).payOnline, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, + height: 50.0, + color: Colors.transparent, + child: Container( + padding: EdgeInsets.only( + left: 130.0, right: 130.0), + decoration: BoxDecoration( + border: Border.all( + color: Colors.green, + style: BorderStyle.solid, + width: 4.0), + color: Colors.green, + borderRadius: BorderRadius.circular(5.0)), + child: Center( + child: Text( + TranslationBase.of(context).payOnline, + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + ), ), ), - ), - ), - ), - ) - : Container(), + ) + : Container(), // getCancelOrder(canCancel, canRefund), - isCancel - ? InkWell( - onTap: () { - presentConfirmDialog(model, widget.orderModel.id); - // model.orderListModel[0].id//(widget.orderModel.id)); + isCancel + ? InkWell( + onTap: () { + presentConfirmDialog( + model, widget.orderModel.id); + // model.orderListModel[0].id//(widget.orderModel.id)); // - }, - child: Container( + }, + child: Container( // padding: EdgeInsets.only(left: 13.0, right: 13.0, top: 5.0), - height: 50.0, - color: Colors.transparent, - child: Center( - child: Text( - TranslationBase.of(context).cancelOrder, - style: TextStyle( - color: Colors.red[900], - fontWeight: FontWeight.bold, - decoration: TextDecoration.underline), - ), - ), - ), - ) - : Container(), - isActiveDelivery - ? InkWell( - onTap: () { - // Navigator.push( - // context, - // MaterialPageRoute(builder: (context) => TrackDriver(order: widget.orderModel), - // )); - }, - child: Container( - height: 50.0, - color: Colors.transparent, - child: Center( - child: Text( - TranslationBase.of(context).trackDeliveryDriver, - style: TextStyle( - color: Colors.green[900], - fontWeight: FontWeight.normal, - decoration: TextDecoration.none), - ), - ), - ), - ) - : Container(), - ], - ), - ), - ), + height: 50.0, + color: Colors.transparent, + child: Center( + child: Text( + TranslationBase.of(context).cancelOrder, + style: TextStyle( + color: Colors.red[900], + fontWeight: FontWeight.bold, + decoration: TextDecoration.underline), + ), + ), + ), + ) + : Container(), + isActiveDelivery + ? InkWell( + onTap: () { + // Navigator.push( + // context, + // MaterialPageRoute(builder: (context) => TrackDriver(order: widget.orderModel), + // )); + }, + child: Container( + height: 50.0, + color: Colors.transparent, + child: Center( + child: Text( + TranslationBase.of(context) + .trackDeliveryDriver, + style: TextStyle( + color: Colors.green[900], + fontWeight: FontWeight.normal, + decoration: TextDecoration.none), + ), + ), + ), + ) + : Container(), + ], + ), + ), + ) + : Container(), ), ); } @@ -701,4 +711,55 @@ class _OrderDetailsPageState extends State { } } + + /*** + * + * Online payment methods + */ + + 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(bool isPaymentMade) { + print("onBrowserExit Called!!!!"); + // if (isPaymentMade) checkPaymentStatus(appo); + } } diff --git a/lib/pages/pharmacy/order/ProductReview.dart b/lib/pages/pharmacy/order/ProductReview.dart index 4d09191c..7f58fa21 100644 --- a/lib/pages/pharmacy/order/ProductReview.dart +++ b/lib/pages/pharmacy/order/ProductReview.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/profile/profile.dart'; @@ -12,7 +13,7 @@ import 'package:rating_bar/rating_bar.dart'; import 'package:flutter/src/widgets/image.dart' as flutterImage; class ProductReviewPage extends StatefulWidget { - final Product product; + final PharmacyProduct product; ProductReviewPage(this.product); diff --git a/lib/pages/pharmacy/order/TrackDriver.dart b/lib/pages/pharmacy/order/TrackDriver.dart index b9a8056f..63dc0ace 100644 --- a/lib/pages/pharmacy/order/TrackDriver.dart +++ b/lib/pages/pharmacy/order/TrackDriver.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/order_model.dart'; import 'package:flutter/material.dart'; import 'package:flutter_polyline_points/flutter_polyline_points.dart'; @@ -9,7 +10,7 @@ import 'package:location/location.dart'; class TrackDriver extends StatefulWidget { - final OrderModel order; + final OrderDetailModel order; TrackDriver({this.order}); @override @@ -17,7 +18,7 @@ class TrackDriver extends StatefulWidget { } class _TrackDriverState extends State { - OrderModel _order; + OrderDetailModel _order; Completer _controller = Completer(); diff --git a/lib/services/pharmacy_services/cancelOrder_service.dart b/lib/services/pharmacy_services/cancelOrder_service.dart index f848c2ff..3804b19b 100644 --- a/lib/services/pharmacy_services/cancelOrder_service.dart +++ b/lib/services/pharmacy_services/cancelOrder_service.dart @@ -1,6 +1,7 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/order_model.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; @@ -16,8 +17,8 @@ class CancelOrderService extends BaseService{ AuthenticatedUser authUser = new AuthenticatedUser(); AuthProvider authProvider = new AuthProvider(); - List _cancelOrderList = List(); - List get cancelOrderList => _cancelOrderList; + List _cancelOrderList = List(); + List get cancelOrderList => _cancelOrderList; String url =""; diff --git a/lib/services/pharmacy_services/orderDetails_service.dart b/lib/services/pharmacy_services/orderDetails_service.dart index b8ea8214..4178c50a 100644 --- a/lib/services/pharmacy_services/orderDetails_service.dart +++ b/lib/services/pharmacy_services/orderDetails_service.dart @@ -1,12 +1,13 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/order_model.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; -import 'package:flutter/material.dart'; class OrderDetailsService extends BaseService{ @@ -16,10 +17,8 @@ class OrderDetailsService extends BaseService{ AuthenticatedUser authUser = new AuthenticatedUser(); AuthProvider authProvider = new AuthProvider(); -// String url =""; -// List get orderDetails => ordeDetails; - List _orderList = List(); - List get orderList => _orderList; + List _orderList = List(); + List get orderList => _orderList; Future getOrderDetails(OrderId) async { @@ -28,7 +27,7 @@ class OrderDetailsService extends BaseService{ onSuccess: (dynamic response, int statusCode) { _orderList.clear(); response['orders'].forEach((item) { - _orderList.add(OrderModel.fromJson(item)); + _orderList.add(OrderDetailModel.fromJson(item)); print(response); }); }, onFailure: (String error, int statusCode) { @@ -37,7 +36,7 @@ class OrderDetailsService extends BaseService{ }); } - Future makeReview(Product product, double rating, String reviewText) async { + Future makeReview(PharmacyProduct product, double rating, String reviewText) async { hasError = false; super.error = ""; diff --git a/lib/widgets/in_app_browser/InAppBrowser.dart b/lib/widgets/in_app_browser/InAppBrowser.dart index 603c5108..0dc8a09c 100644 --- a/lib/widgets/in_app_browser/InAppBrowser.dart +++ b/lib/widgets/in_app_browser/InAppBrowser.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; @@ -20,13 +21,17 @@ class MyInAppBrowser extends InAppBrowser { // static String PREAUTH_SERVICE_URL = // 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort PreAuth Payment Gateway URL Live Store + static String PRESCRIPTION_PAYMENT_WITH_ORDERID = + 'https://uat.hmgwebservices.com/epharmacy/checkout/OpcCompleteRedirectionPaymentClientbyOrder?orderID='; + static List successURLS = [ 'success', 'PayFortResponse', - 'PayFortSucess' + 'PayFortSucess', + 'mobilepaymentcomplete' ]; - static List errorURLS = ['PayfortCancel']; + static List errorURLS = ['PayfortCancel', 'errorpage', 'Failed']; final Function onExitCallback; final Function onLoadStartCallback; @@ -146,6 +151,26 @@ class MyInAppBrowser extends InAppBrowser { }); } + openPharmacyPaymentBrowser( + OrderDetailModel order, + double amount, + String orderDesc, + String transactionID, + String emailId, + String paymentMethod, + String patientName, + dynamic patientID, + AuthenticatedUser authenticatedUser, + InAppBrowser browser) { + this.browser = browser; + getPatientData(); + generatePharmacyURL(order, amount, orderDesc, transactionID, emailId, + paymentMethod, patientName, patientID, authenticatedUser) + .then((value) { + this.browser.openUrl(url: value); + }); + } + openBrowser(String url) { this.browser = browser; this.browser.openUrl(url: url); @@ -225,6 +250,25 @@ class MyInAppBrowser extends InAppBrowser { return 'data:text/html;base64,' + base64Str; } + Future generatePharmacyURL( + OrderDetailModel order, + double amount, + String orderDesc, + String transactionID, + String emailId, + String paymentMethod, + String patientName, + dynamic patientID, + AuthenticatedUser authUser) async { + + String pharmacyURL = PRESCRIPTION_PAYMENT_WITH_ORDERID + + order.orderGuid + + '&&CustomerId=' + + "${order.customerId}"; + print(pharmacyURL); + return pharmacyURL; + } + String getForm() { return ' ' + '' + @@ -292,6 +336,36 @@ class MyInAppBrowser extends InAppBrowser { '' + ''; } + + String getPharmacyForm() { + return ' ' + + '' + + '' + + '
' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
' + + '' + + '' + + ''; + } } class MyChromeSafariBrowser extends ChromeSafariBrowser { diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index 169decb0..1caffefe 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -1,10 +1,9 @@ -import 'package:diplomaticquarterapp/core/model/pharmacies/order_model.dart'; +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/pharmacy/order/ProductReview.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/src/widgets/image.dart' as flutterImage; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:rating_bar/rating_bar.dart'; @@ -21,7 +20,7 @@ class productTile extends StatelessWidget { final String img; final String imgs; final int status; - final Product product; + final PharmacyProduct product; final dynamic productID; productTile(