From 8ecd4a24d87ed6823b8dbd4cb4f28cf726e54fd0 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Mon, 4 Oct 2021 11:04:36 +0300 Subject: [PATCH 1/5] fix product tile --- lib/config/config.dart | 12 +- .../screens/pharmacy_module_page.dart | 2 +- .../pharmacies/widgets/ProductTileItem.dart | 177 +++++++++--------- lib/widgets/others/StarRating.dart | 2 +- 4 files changed, 95 insertions(+), 98 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 5af95569..0d0a0413 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -13,16 +13,16 @@ const PACKAGES_CUSTOMER = '/api/customers'; const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; const PACKAGES_ORDERS = '/api/orders'; -const BASE_URL = 'https://uat.hmgwebservices.com/'; -// const BASE_URL = 'https://hmgwebservices.com/'; +// const BASE_URL = 'https://uat.hmgwebservices.com/'; +const BASE_URL = 'https://hmgwebservices.com/'; // Pharmacy UAT URLs -const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; -const PHARMACY_BASE_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; +// const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; +// const PHARMACY_BASE_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; // Pharmacy Production URLs -// const BASE_PHARMACY_URL = 'https://mdlaboratories.com/exacartapi/api/'; -// const PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapi/api/'; +const BASE_PHARMACY_URL = 'https://mdlaboratories.com/exacartapi/api/'; +const PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapi/api/'; const PING_SERVICE = 'Services/Weather.svc/REST/CheckConnectivity'; diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 9b91b77a..e3dbf3a4 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -672,7 +672,7 @@ class _PharmacyPageState extends State { ), ), Container( - height: MediaQuery.of(context).size.height / 4 + 20, + height: MediaQuery.of(context).size.height / 4 + 22, child: ListView.builder( itemBuilder: (ctx, i) => ProductTileItem(model.bestSellerProduct[i]), diff --git a/lib/pages/pharmacies/widgets/ProductTileItem.dart b/lib/pages/pharmacies/widgets/ProductTileItem.dart index a7e71fab..b7a061d5 100644 --- a/lib/pages/pharmacies/widgets/ProductTileItem.dart +++ b/lib/pages/pharmacies/widgets/ProductTileItem.dart @@ -52,102 +52,99 @@ class ProductTileItem extends StatelessWidget { return InkWell( onTap: () => productOnClick(context), splashColor: Theme.of(context).primaryColor, - child: Card( - elevation: 2, - shape: Border(right: BorderSide(color: Colors.grey.shade300, width: 1)), - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 0, + child: Container( + margin: EdgeInsets.all(7), + decoration: BoxDecoration( + border:Border.all(color: Colors.grey.shade300,width: 0.5), + borderRadius: BorderRadius.circular(8) ), - child: Container( - padding: EdgeInsets.symmetric(horizontal: 4), - width: MediaQuery.of(context).size.width / 3, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Stack( - children: [ - Container( - margin: EdgeInsets.fromLTRB(0, 16, 0, 0), - alignment: Alignment.center, - child: (item.images != null && item.images.length > 0) - ? Image.network( - item.images[0].src, - fit: BoxFit.cover, - height: 80, - ) - : Image.asset( - "assets/images/no_image.png", - fit: BoxFit.cover, - height: 80, - ), + padding: EdgeInsets.symmetric(horizontal: 4), + width: MediaQuery.of(context).size.width / 2.8, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + children: [ + Container( + margin: EdgeInsets.fromLTRB(0, 16, 0, 0), + alignment: Alignment.center, + child: (item.images != null && item.images.length > 0) + ? Image.network( + item.images[0].src, + fit: BoxFit.cover, + height: 80, + ) + : Image.asset( + "assets/images/no_image.png", + fit: BoxFit.cover, + height: 80, ), - Container( - width: item.rxMessage != null - ? MediaQuery.of(context).size.width / 5 - : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), - borderRadius: - BorderRadius.only(topLeft: Radius.circular(6)), - ), - child: item.rxMessage != null ? Texts( - projectProvider.isArabic ? item.rxMessagen : item.rxMessage, - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ): Texts(""), + ), + Container( + width: item.rxMessage != null + ? MediaQuery.of(context).size.width / 5 + : 0, + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + color: Color(0xffb23838), + borderRadius: + BorderRadius.only(topLeft: Radius.circular(6)), + ), + child: item.rxMessage != null + ? Texts( + projectProvider.isArabic + ? item.rxMessagen + : item.rxMessage, + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, ) - ], + : Texts(""), + ) + ], + ), + SizedBox(height: 8,), + Container( + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, ), - Container( - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - projectProvider.isArabic ? item.namen : item.name, - regular: true, - fontSize: 12, - fontWeight: FontWeight.w400, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + projectProvider.isArabic ? item.namen : item.name, + regular: true, + fontSize: 12, + fontWeight: FontWeight.w400, + ), + Padding( + padding: const EdgeInsets.only(top: 4, bottom: 4), + child: Texts( + "SAR ${item.price}", + fontWeight: FontWeight.w600, + fontSize: 14, ), - Padding( - padding: const EdgeInsets.only(top: 4, bottom: 4), - child: Texts( - "SAR ${item.price}", - bold: true, - fontSize: 14, + ), + Row( + children: [ + Expanded( + child: StarRating( + totalAverage: item.approvedTotalReviews > 0 + ? (item.approvedRatingSum.toDouble() / + item.approvedTotalReviews.toDouble()) + .toDouble() + : 0, + forceStars: true), ), - ), - Row( - children: [ - Expanded( - child: StarRating( - totalAverage: item.approvedTotalReviews > 0 - ? (item.approvedRatingSum.toDouble() / - item.approvedTotalReviews.toDouble()) - .toDouble() - : 0, - forceStars: true), - ), - /*Texts( - "(${item.approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ),*/ - ], - ), - ], - ), - ) - ], - ), + ], + ), + ], + ), + ), + SizedBox(height: 5,), + ], ), ), ); diff --git a/lib/widgets/others/StarRating.dart b/lib/widgets/others/StarRating.dart index 5620b21a..74bdbfe3 100644 --- a/lib/widgets/others/StarRating.dart +++ b/lib/widgets/others/StarRating.dart @@ -30,7 +30,7 @@ class StarRating extends StatelessWidget { ) ), if (totalCount!=null) - SizedBox(width: 9.0), + SizedBox(width: 5.0), if (totalCount!=null) Texts("("+totalCount.toString()+")", style: "overline", color: Colors.grey[400],) ] From 806e07e4e60340b49296e9fad81a665c959a0e51 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 4 Oct 2021 12:13:52 +0300 Subject: [PATCH 2/5] products categories page fix --- lib/pages/parent_categorise_page.dart | 656 ++++++++++++++++++-------- lib/pages/pharmacy_categorise.dart | 1 + 2 files changed, 472 insertions(+), 185 deletions(-) diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 40bf2dc7..c3acb0ba 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -26,7 +26,8 @@ class ParentCategorisePage extends StatefulWidget { ParentCategorisePage({this.id, this.titleName}); @override - _ParentCategorisePageState createState() => _ParentCategorisePageState(id: id, titleName: titleName); + _ParentCategorisePageState createState() => + _ParentCategorisePageState(id: id, titleName: titleName); } class _ParentCategorisePageState extends State { @@ -57,7 +58,10 @@ class _ParentCategorisePageState extends State { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getCategoriseParent(i: id), - builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( + allowAny: true, + builder: (BuildContext context, PharmacyCategoriseViewModel model, + Widget child) => + PharmacyAppScaffold( appBarTitle: titleName, isBottomBar: false, isShowAppBar: true, @@ -108,7 +112,8 @@ class _ParentCategorisePageState extends State { child: InkWell( child: Container( child: Texts( - TranslationBase.of(context).viewCategorise, + TranslationBase.of(context) + .viewCategorise, // 'View All Categories', fontWeight: FontWeight.w300, ), @@ -126,22 +131,37 @@ class _ParentCategorisePageState extends State { color: Colors.white, child: Center( child: ListView.builder( - scrollDirection: Axis.vertical, - itemCount: model.categoriseParent.length, - itemBuilder: (BuildContext context, int index) { + scrollDirection: + Axis.vertical, + itemCount: model + .categoriseParent.length, + itemBuilder: + (BuildContext context, + int index) { return Container( child: Padding( - padding: EdgeInsets.all(4.0), + padding: + EdgeInsets.all(4.0), child: InkWell( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ - Texts(projectViewModel.isArabic - ? model.categoriseParent[index].namen - : model.categoriseParent[index].name), + Texts(projectViewModel + .isArabic + ? model + .categoriseParent[ + index] + .namen + : model + .categoriseParent[ + index] + .name), Divider( thickness: 0.6, - color: Colors.black12, + color: Colors + .black12, ) ], ), @@ -149,9 +169,16 @@ class _ParentCategorisePageState extends State { Navigator.push( context, FadePage( - page: SubCategorisePage( - title: model.categoriseParent[index].name, - id: model.categoriseParent[index].id, + page: + SubCategorisePage( + title: model + .categoriseParent[ + index] + .name, + id: model + .categoriseParent[ + index] + .id, parentId: id, )), ); @@ -185,22 +212,28 @@ class _ParentCategorisePageState extends State { child: Center( child: ListView.builder( scrollDirection: Axis.horizontal, - itemCount: model.categoriseParent.length > 8 ? 8 : model.categoriseParent.length, + itemCount: model.categoriseParent.length > 8 + ? 8 + : model.categoriseParent.length, itemBuilder: (BuildContext context, int index) { return Padding( - padding: EdgeInsets.symmetric(horizontal: 8.0), + padding: + EdgeInsets.symmetric(horizontal: 8.0), child: InkWell( child: Column( - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, children: [ Padding( - padding: EdgeInsets.symmetric(horizontal: 13.0), + padding: EdgeInsets.symmetric( + horizontal: 13.0), child: Container( height: 60.0, width: 65.0, decoration: BoxDecoration( shape: BoxShape.circle, - color: Colors.orange.shade200.withOpacity(0.45), + color: Colors.orange.shade200 + .withOpacity(0.45), ), child: Center( child: Icon( @@ -211,7 +244,10 @@ class _ParentCategorisePageState extends State { ), ), Container( - width: MediaQuery.of(context).size.width * 0.197, + width: MediaQuery.of(context) + .size + .width * + 0.197, // height: MediaQuery.of(context) // .size // .height * @@ -219,8 +255,12 @@ class _ParentCategorisePageState extends State { child: Center( child: Texts( projectViewModel.isArabic - ? model.categoriseParent[index].namen - : model.categoriseParent[index].name, + ? model + .categoriseParent[index] + .namen + : model + .categoriseParent[index] + .name, fontSize: 13.4, fontWeight: FontWeight.w600, maxLines: 3, @@ -234,8 +274,10 @@ class _ParentCategorisePageState extends State { context, FadePage( page: SubCategorisePage( - title: model.categoriseParent[index].name, - id: model.categoriseParent[index].id, + title: model + .categoriseParent[index].name, + id: model + .categoriseParent[index].id, parentId: id, )), ); @@ -281,16 +323,21 @@ class _ParentCategorisePageState extends State { initialChildSize: 0.95, maxChildSize: 0.95, minChildSize: 0.9, - builder: (BuildContext context, ScrollController scrollController) { + builder: (BuildContext context, + ScrollController scrollController) { return SingleChildScrollView( controller: scrollController, child: Container( color: Colors.white, - height: MediaQuery.of(context).size.height * 1.95, + height: MediaQuery.of(context) + .size + .height * + 1.95, child: Column( children: [ Padding( - padding: EdgeInsets.all(8.0), + padding: + EdgeInsets.all(8.0), child: Row( children: [ Icon( @@ -301,7 +348,8 @@ class _ParentCategorisePageState extends State { ), Texts( 'Refine', - fontWeight: FontWeight.w600, + fontWeight: + FontWeight.w600, ), SizedBox( width: 250.0, @@ -310,11 +358,13 @@ class _ParentCategorisePageState extends State { child: Texts( 'Close', color: Colors.red, - fontWeight: FontWeight.w600, + fontWeight: + FontWeight.w600, fontSize: 15.0, ), onTap: () { - Navigator.pop(context); + Navigator.pop( + context); }, ), ], @@ -327,27 +377,37 @@ class _ParentCategorisePageState extends State { Column( children: [ ExpansionTile( - title: Texts('Categorise'), + title: + Texts('Categorise'), children: [ ProcedureListWidget( model: model, - masterList: model.categoriseParent, - removeHistory: (item) { + masterList: model + .categoriseParent, + removeHistory: + (item) { setState(() { - entityList.remove(item); + entityList + .remove( + item); }); }, - addHistory: (history) { + addHistory: + (history) { setState(() { - entityList.add(history); + entityList.add( + history); }); }, - addSelectedHistories: () { + addSelectedHistories: + () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: (master) => - isEntityListSelected(master), + isEntityListSelected: + (master) => + isEntityListSelected( + master), ) ], ), @@ -360,23 +420,33 @@ class _ParentCategorisePageState extends State { children: [ ProcedureListWidget( model: model, - masterList: model.brandsList, - removeHistory: (item) { + masterList: model + .brandsList, + removeHistory: + (item) { setState(() { - entityListBrands.remove(item); + entityListBrands + .remove( + item); }); }, - addHistory: (history) { + addHistory: + (history) { setState(() { - entityListBrands.add(history); + entityListBrands + .add( + history); }); }, - addSelectedHistories: () { + addSelectedHistories: + () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: (master) => - isEntityListSelectedBrands(master), + isEntityListSelected: + (master) => + isEntityListSelectedBrands( + master), ) ], ), @@ -388,40 +458,63 @@ class _ParentCategorisePageState extends State { title: Texts('Price'), children: [ Container( - color: Color(0xffEEEEEE), + color: Color( + 0xffEEEEEE), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + mainAxisAlignment: + MainAxisAlignment + .spaceAround, children: [ Column( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .start, children: [ - Texts('Min'), + Texts( + 'Min'), Container( - color: Colors.white, - width: 200, - height: 40, - child: TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), + color: Colors + .white, + width: + 200, + height: + 40, + child: + TextFormField( + decoration: + InputDecoration( + border: + OutlineInputBorder(), ), - controller: minField, + controller: + minField, ), ), ], ), Column( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .start, children: [ - Texts('Max'), + Texts( + 'Max'), Container( - color: Colors.white, - width: 200, - height: 40, - child: TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), + color: Colors + .white, + width: + 200, + height: + 40, + child: + TextFormField( + decoration: + InputDecoration( + border: + OutlineInputBorder(), ), - controller: maxField, + controller: + maxField, ), ), ], @@ -436,18 +529,26 @@ class _ParentCategorisePageState extends State { color: Colors.black12, ), SizedBox( - height: MediaQuery.of(context).size.height * 0.4, + height: MediaQuery.of( + context) + .size + .height * + 0.4, ), Padding( - padding: EdgeInsets.all(8.0), + padding: + EdgeInsets.all(8.0), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisAlignment: + MainAxisAlignment + .spaceEvenly, children: [ Container( width: 100, child: Button( label: 'Reset', - backgroundColor: Colors.red, + backgroundColor: + Colors.red, ), ), SizedBox( @@ -456,38 +557,65 @@ class _ParentCategorisePageState extends State { Container( width: 200, child: Button( - onTap: () async { - String categoriesId = ""; - for (CategoriseParentModel category in entityList) { - if (categoriesId == "") { - categoriesId = category.id; + onTap: + () async { + String + categoriesId = + ""; + for (CategoriseParentModel category + in entityList) { + if (categoriesId == + "") { + categoriesId = + category + .id; } else { - categoriesId = "$categoriesId,${category.id}"; + categoriesId = + "$categoriesId,${category.id}"; } } - String brandIds = ""; + String + brandIds = + ""; for (CategoriseParentModel brand in entityListBrands) { - if (brandIds == "") { - brandIds = brand.id; + if (brandIds == + "") { + brandIds = + brand + .id; } else { - brandIds = "$brandIds,${brand.id}"; + brandIds = + "$brandIds,${brand.id}"; } } - GifLoaderDialogUtils.showMyDialog(context); + GifLoaderDialogUtils + .showMyDialog( + context); await model.getFilteredProducts( - min: minField.text.toString(), - max: maxField.text.toString(), - categoryId: categoriesId, - brandId: brandIds); - GifLoaderDialogUtils.hideDialog(context); + min: minField + .text + .toString(), + max: maxField + .text + .toString(), + categoryId: + categoriesId, + brandId: + brandIds); + GifLoaderDialogUtils + .hideDialog( + context); - Navigator.pop(context); + Navigator.pop( + context); }, label: 'Apply', - backgroundColor: Colors.green, + backgroundColor: + Colors + .green, ), ), ], @@ -554,22 +682,28 @@ class _ParentCategorisePageState extends State { model.parentProducts.isNotEmpty ? styleOne == true ? Container( - height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.15, + height: model.parentProducts.length * + MediaQuery.of(context).size.height * + 0.15, child: GridView.builder( physics: NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + gridDelegate: + SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 0.5, mainAxisSpacing: 2.0, childAspectRatio: 0.9, ), itemCount: model.parentProducts.length, - itemBuilder: (BuildContext context, int index) { + itemBuilder: + (BuildContext context, int index) { return NetworkBaseView( baseViewModel: model, child: InkWell( child: Card( - color: model.parentProducts[index].discountName != null + color: model.parentProducts[index] + .discountName != + null ? Color(0xffFFFF00) : Colors.white, elevation: 0, @@ -597,106 +731,187 @@ class _ParentCategorisePageState extends State { ), child: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(110.0), + borderRadius: + BorderRadius.only( + topLeft: + Radius.circular(110.0), ), color: Colors.white, ), - padding: EdgeInsets.symmetric(horizontal: 0), - width: MediaQuery.of(context).size.width / 3, + padding: EdgeInsets.symmetric( + horizontal: 0), + width: MediaQuery.of(context) + .size + .width / + 3, child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Stack( children: [ - if (model.parentProducts[index].discountName != null) + if (model + .parentProducts[ + index] + .discountName != + null) RotatedBox( quarterTurns: 4, child: Container( - decoration: BoxDecoration(), + decoration: + BoxDecoration(), child: Padding( - padding: EdgeInsets.only( + padding: + EdgeInsets + .only( right: 5.0, top: 20.0, bottom: 5.0, ), child: Texts( - 'offer'.toUpperCase(), - color: Colors.red, - fontSize: 13.0, - fontWeight: FontWeight.w900, + 'offer' + .toUpperCase(), + color: Colors + .red, + fontSize: + 13.0, + fontWeight: + FontWeight + .w900, ), ), - transform: new Matrix4.rotationZ(5.837200), + transform: new Matrix4 + .rotationZ( + 5.837200), ), ), Container( - margin: EdgeInsets.fromLTRB(0, 16, 0, 0), - alignment: Alignment.center, + margin: EdgeInsets + .fromLTRB( + 0, 16, 0, 0), + alignment: + Alignment.center, child: Image.network( - model.parentProducts[index].images.isNotEmpty - ? model.parentProducts[index].images[0].thumb + model + .parentProducts[ + index] + .images + .isNotEmpty + ? model + .parentProducts[ + index] + .images[0] + .thumb : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', fit: BoxFit.cover, height: 80, ), ), Container( - width: model.parentProducts[index].rxMessage != null - ? MediaQuery.of(context).size.width / 5 + width: model + .parentProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5 : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), + padding: + EdgeInsets.all(4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), borderRadius: - BorderRadius.only(topLeft: Radius.circular(6)), + BorderRadius.only( + topLeft: Radius + .circular( + 6)), ), child: Texts( - model.parentProducts[index].rxMessage != null - ? model.parentProducts[index].rxMessage + model + .parentProducts[ + index] + .rxMessage != + null + ? model + .parentProducts[ + index] + .rxMessage : "", color: Colors.white, regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight.w400, ), ), ], ), Container( - margin: EdgeInsets.symmetric( + margin: + EdgeInsets.symmetric( horizontal: 6, vertical: 0, ), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ - if (model.parentProducts[index].discountName != null) + if (model + .parentProducts[ + index] + .discountName != + null) Container( - width: double.infinity, + width: double + .infinity, height: 13.0, - decoration: BoxDecoration( - color: Color(0xff5AB145), + decoration: + BoxDecoration( + color: Color( + 0xff5AB145), ), child: Center( child: Texts( - model.parentProducts[index].discountName, + model + .parentProducts[ + index] + .discountName, regular: true, - color: Colors.white, - fontSize: 10.4, + color: Colors + .white, + fontSize: + 10.4, ), ), ), Texts( - projectViewModel.isArabic - ? model.parentProducts[index].namen - : model.parentProducts[index].name, + projectViewModel + .isArabic + ? model + .parentProducts[ + index] + .namen + : model + .parentProducts[ + index] + .name, regular: true, fontSize: 12, - fontWeight: FontWeight.w700, + fontWeight: + FontWeight.w700, ), Padding( - padding: const EdgeInsets.only(top: 4, bottom: 4), + padding: + const EdgeInsets + .only( + top: 4, + bottom: 4), child: Texts( "SAR ${model.parentProducts[index].price}", bold: true, @@ -706,22 +921,25 @@ class _ParentCategorisePageState extends State { Row( children: [ StarRating( - totalAverage: - model.parentProducts[index].approvedRatingSum > 0 - ? (model.parentProducts[index] - .approvedRatingSum - .toDouble() / - model.parentProducts[index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: true), + totalAverage: model + .parentProducts[ + index] + .approvedRatingSum > + 0 + ? (model.parentProducts[index].approvedRatingSum.toDouble() / + model.parentProducts[index].approvedRatingSum + .toDouble()) + .toDouble() + : 0, + forceStars: + true), Texts( "(${model.parentProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight + .w400, ) ], ), @@ -736,7 +954,9 @@ class _ParentCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage(model.parentProducts[index]), + page: ProductDetailPage( + model.parentProducts[ + index]), )), }, )); @@ -744,11 +964,14 @@ class _ParentCategorisePageState extends State { ), ) : Container( - height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.122, + height: model.parentProducts.length * + MediaQuery.of(context).size.height * + 0.122, child: ListView.builder( physics: NeverScrollableScrollPhysics(), itemCount: model.parentProducts.length, - itemBuilder: (BuildContext context, int index) { + itemBuilder: + (BuildContext context, int index) { return InkWell( child: Card( child: Row( @@ -758,9 +981,11 @@ class _ParentCategorisePageState extends State { Column( children: [ Container( - decoration: BoxDecoration(), + decoration: + BoxDecoration(), child: Padding( - padding: EdgeInsets.only( + padding: + EdgeInsets.only( left: 9.0, top: 8.0, right: 10.0, @@ -768,11 +993,22 @@ class _ParentCategorisePageState extends State { ), ), Container( - margin: EdgeInsets.fromLTRB(0, 0, 0, 0), - alignment: Alignment.center, + margin: EdgeInsets + .fromLTRB( + 0, 0, 0, 0), + alignment: + Alignment.center, child: Image.network( - model.parentProducts[index].images.isNotEmpty - ? model.parentProducts[index].images[0].thumb + model + .parentProducts[ + index] + .images + .isNotEmpty + ? model + .parentProducts[ + index] + .images[0] + .thumb : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', fit: BoxFit.contain, height: 80, @@ -783,23 +1019,45 @@ class _ParentCategorisePageState extends State { Column( children: [ Container( - width: model.parentProducts[index].rxMessage != null - ? MediaQuery.of(context).size.width / 5 + width: model + .parentProducts[ + index] + .rxMessage != + null + ? MediaQuery.of( + context) + .size + .width / + 5 : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), + padding: + EdgeInsets.all(4), + decoration: + BoxDecoration( + color: Color( + 0xffb23838), borderRadius: - BorderRadius.only(topLeft: Radius.circular(6)), + BorderRadius.only( + topLeft: Radius + .circular( + 6)), ), child: Texts( - model.parentProducts[index].rxMessage != null - ? model.parentProducts[index].rxMessage + model + .parentProducts[ + index] + .rxMessage != + null + ? model + .parentProducts[ + index] + .rxMessage : "", color: Colors.white, regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight.w400, ), ), ], @@ -812,21 +1070,37 @@ class _ParentCategorisePageState extends State { vertical: 0, ), child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment + .spaceAround, + crossAxisAlignment: + CrossAxisAlignment + .start, children: [ SizedBox( height: 4.0, ), Container( - width: MediaQuery.of(context).size.width * 0.65, + width: MediaQuery.of( + context) + .size + .width * + 0.65, child: Texts( - projectViewModel.isArabic - ? model.parentProducts[index].namen - : model.parentProducts[index].name, + projectViewModel + .isArabic + ? model + .parentProducts[ + index] + .namen + : model + .parentProducts[ + index] + .name, regular: true, fontSize: 13.2, - fontWeight: FontWeight.w500, + fontWeight: + FontWeight.w500, maxLines: 5, ), ), @@ -834,7 +1108,11 @@ class _ParentCategorisePageState extends State { height: 8.0, ), Padding( - padding: const EdgeInsets.only(top: 4, bottom: 4), + padding: + const EdgeInsets + .only( + top: 4, + bottom: 4), child: Texts( "SAR ${model.parentProducts[index].price}", bold: true, @@ -844,21 +1122,26 @@ class _ParentCategorisePageState extends State { Row( children: [ StarRating( - totalAverage: - model.parentProducts[index].approvedRatingSum > 0 - ? (model.parentProducts[index].approvedRatingSum - .toDouble() / - model.parentProducts[index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, + totalAverage: model + .parentProducts[ + index] + .approvedRatingSum > + 0 + ? (model.parentProducts[index].approvedRatingSum + .toDouble() / + model + .parentProducts[index] + .approvedRatingSum + .toDouble()) + .toDouble() + : 0, forceStars: true), Texts( "(${model.parentProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: FontWeight.w400, + fontWeight: + FontWeight.w400, ) ], ), @@ -872,7 +1155,8 @@ class _ParentCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage(model.parentProducts[index]), + page: ProductDetailPage(model + .parentProducts[index]), )), }, ); @@ -914,7 +1198,8 @@ class _ParentCategorisePageState extends State { } bool isEntityListSelected(CategoriseParentModel masterKey) { - Iterable history = entityList.where((element) => masterKey.id == element.id); + Iterable history = + entityList.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } @@ -922,7 +1207,8 @@ class _ParentCategorisePageState extends State { } bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { - Iterable history = entityListBrands.where((element) => masterKey.id == element.id); + Iterable history = + entityListBrands.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } diff --git a/lib/pages/pharmacy_categorise.dart b/lib/pages/pharmacy_categorise.dart index ff1920dc..b71c28ce 100644 --- a/lib/pages/pharmacy_categorise.dart +++ b/lib/pages/pharmacy_categorise.dart @@ -30,6 +30,7 @@ class _PharmacyCategorisePageState extends State { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getCategorise(), + allowAny: true, builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => AppScaffold( From 2265487ccda97354eb367687e225c086cb39721d Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 4 Oct 2021 16:10:00 +0300 Subject: [PATCH 3/5] remove cart cout & icon from AppBar --- .../pharmacies/screens/cart-order-page.dart | 73 ++++++++++++------- lib/widgets/others/app_scaffold_widget.dart | 53 +++++++------- 2 files changed, 73 insertions(+), 53 deletions(-) diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index 6c760fcd..c2ebf4b2 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -24,9 +24,10 @@ class CartOrderPage extends StatelessWidget { final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; AppScaffold appScaffold; return BaseView( - onModelReady: (model){ - model.getShoppingCart().then((value){ - appScaffold.appBar.badgeUpdater('${model.cartResponse.quantityCount ?? 0}'); + onModelReady: (model) { + model.getShoppingCart().then((value) { + appScaffold.appBar + .badgeUpdater('${model.cartResponse.quantityCount ?? 0}'); }); }, builder: (_, model, wi) => ChangeNotifierProvider.value( @@ -69,24 +70,40 @@ class CartOrderPage extends StatelessWidget { child: Column( children: [ ...List.generate( - cart.shoppingCarts != null ? cart.shoppingCarts.length : 0, + cart.shoppingCarts != null + ? cart.shoppingCarts.length + : 0, (index) => ProductOrderItem( - cart.shoppingCarts[index], () {print(cart.shoppingCarts[index].quantity); - model.changeProductQuantity(cart.shoppingCarts[index]).then((value) { - if (model.state != ViewState.Error) { - appScaffold.appBar.badgeUpdater('${value.quantityCount ?? 0}'); + cart.shoppingCarts[index], () { + print(cart.shoppingCarts[index] + .quantity); + model + .changeProductQuantity( + cart.shoppingCarts[index]) + .then((value) { + if (model.state != + ViewState.Error) { + appScaffold.appBar.badgeUpdater( + '${value.quantityCount ?? 0}'); } if (model.state == - ViewState.ErrorLocal) {Utils.showErrorToast(model.error);} + ViewState.ErrorLocal) { + Utils.showErrorToast( + model.error); + } + }); + }, () { + model + .deleteProduct( + cart.shoppingCarts[index]) + .then((value) { + if (model.state != + ViewState.Error) { + appScaffold.appBar.badgeUpdater( + '${value.quantityCount ?? 0}'); + } }); - }, - () { - model.deleteProduct(cart.shoppingCarts[index]).then((value){ - if (model.state != ViewState.Error) { - appScaffold.appBar.badgeUpdater('${value.quantityCount ?? 0}'); - } - }); - })) + })) ], ), ), @@ -200,7 +217,8 @@ class CartOrderPage extends StatelessWidget { ), Padding( padding: const EdgeInsets.all(8.0), - child: Text(TranslationBase.of(context).noData, + child: Text( + TranslationBase.of(context).noData, // 'There is no data', style: TextStyle(fontSize: 30), ), @@ -270,21 +288,20 @@ class _OrderBottomWidgetState extends State { width: 25.0, height: widget.height * 0.070, decoration: new BoxDecoration( - color: !isAgree - ? Color(0xffeeeeee) - : Colors.green, + color: + !isAgree ? Color(0xffeeeeee) : Colors.green, shape: BoxShape.circle, ), child: !isAgree ? null : Padding( - padding: const EdgeInsets.all(0.0), - child: Icon( - Icons.check, - color: Colors.white, - size: 25, - ), - ), + padding: const EdgeInsets.all(0.0), + child: Icon( + Icons.check, + color: Colors.white, + size: 25, + ), + ), ), ), Expanded( diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index b99ac1dc..962d0506 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -177,6 +177,7 @@ class AppBarWidget extends StatefulWidget with PreferredSizeWidget { } String _badgeText = "0"; + class AppBarWidgetState extends State { @override Widget build(BuildContext context) { @@ -218,33 +219,35 @@ class AppBarWidgetState extends State { centerTitle: true, actions: [ (widget.isPharmacy && widget.showPharmacyCart) - ? IconButton( - icon: Badge( - shape: BadgeShape.circle, - badgeContent: Text(_badgeText, style: TextStyle(color: Colors.white)), - child: Icon(Icons.shopping_cart)), - color: Colors.white, - onPressed: () { - Navigator.of(context).popUntil(ModalRoute.withName('/')); - }) + ? Container() + // ? IconButton( + // icon: Badge( + // shape: BadgeShape.circle, + // badgeContent: Text(_badgeText, style: TextStyle(color: Colors.white)), + // child: Icon(Icons.shopping_cart)), + // color: Colors.white, + // onPressed: () { + // Navigator.of(context).popUntil(ModalRoute.withName('/')); + // }) : Container(), (widget.isOfferPackages && widget.showOfferPackagesCart) - ? IconButton( - icon: Badge( - position: BadgePosition.topStart(top: -15, start: -10), - badgeContent: Text( - _badgeText, - style: TextStyle( - fontSize: 9, - color: Colors.white, - fontWeight: FontWeight.normal), - ), - child: Icon(Icons.shopping_cart)), - color: Colors.white, - onPressed: () { - // Cart Click Event - if (_onCartClick != null) _onCartClick(); - }) + ? Container() + // ? IconButton( + // icon: Badge( + // position: BadgePosition.topStart(top: -15, start: -10), + // badgeContent: Text( + // _badgeText, + // style: TextStyle( + // fontSize: 9, + // color: Colors.white, + // fontWeight: FontWeight.normal), + // ), + // child: Icon(Icons.shopping_cart)), + // color: Colors.white, + // onPressed: () { + // // Cart Click Event + // if (_onCartClick != null) _onCartClick(); + // }) : Container(), if (widget.showHomeAppBarIcon) IconButton( From 43e7bb9ff3a261ad6535e43c0c196d10e4d2601d Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Mon, 4 Oct 2021 16:18:47 +0300 Subject: [PATCH 4/5] fix bottom navigation bar --- lib/pages/landing/landing_page_pharmcy.dart | 38 +------------------ lib/pages/pharmacy/profile/profile.dart | 2 +- .../pharmacy_services/wishList_service.dart | 5 ++- .../pharmacy/bottom_nav_pharmacy_bar.dart | 33 +--------------- .../pharmacy/bottom_nav_pharmacy_item.dart | 15 +++++++- 5 files changed, 22 insertions(+), 71 deletions(-) diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 5da853fb..cb886f2d 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -110,35 +110,6 @@ class _LandingPagePharmacyState extends State { centerTitle: true, ) : null, - // : AppBar( - // backgroundColor: Color(0xff5AB145), - // elevation: 0, - // textTheme: TextTheme( - // headline6: TextStyle( - // color: Colors.white, fontWeight: FontWeight.bold), - // ), - // title: Text(getText(currentTab).toUpperCase()), - // leading: Builder( - // builder: (BuildContext context) { - // return IconButton( - // icon: Icon(Icons.arrow_back), - // color: Colors.white, - // onPressed: () => Scaffold.of(context).openDrawer(), - // ); - // }, - // ), - // actions: [ - // // IconButton( - // // iconSize: 70, - // // icon: SvgPicture.asset('assets/images/svg/robort_svg.svg', - // // height: 100, width: 100, fit: BoxFit.cover), - // // onPressed: () { - // // triggerRobot(); - // // } //do something, - // // ) - // ], - // centerTitle: true, - // ), extendBody: false, body: PageView( physics: NeverScrollableScrollPhysics(), @@ -146,14 +117,9 @@ class _LandingPagePharmacyState extends State { children: [ PharmacyPage(), PharmacyCategorisePage(), -// OffersCategorisePage(), - WishlistPage(false), PharmacyProfilePage(), -// Container( -// child: Text('text'), -// ), CartOrderPage(), - ], // Please do not remove the BookingOptions from this array + ], ), bottomNavigationBar: BottomNavPharmacyBar( changeIndex: _changeCurrentTab, @@ -172,7 +138,7 @@ class _LandingPagePharmacyState extends State { .getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode", onSuccess: (dynamic response, int statusCode) { print(response); - product = PharmacyProduct.fromJson(response["products"][0]); + var product = PharmacyProduct.fromJson(response["products"][0]); GifLoaderDialogUtils.hideDialog(context); Navigator.push(context, FadePage(page: ProductDetailPage(product))); }, onFailure: (String error, int statusCode) { diff --git a/lib/pages/pharmacy/profile/profile.dart b/lib/pages/pharmacy/profile/profile.dart index 918e9668..3cf28592 100644 --- a/lib/pages/pharmacy/profile/profile.dart +++ b/lib/pages/pharmacy/profile/profile.dart @@ -93,7 +93,7 @@ class _ProfilePageState extends State { }, builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).myAccount, - isShowAppBar: true, + isShowAppBar: false, isShowDecPage: false, isPharmacy: true, body: user != null diff --git a/lib/services/pharmacy_services/wishList_service.dart b/lib/services/pharmacy_services/wishList_service.dart index 5404a2bd..fb99e038 100644 --- a/lib/services/pharmacy_services/wishList_service.dart +++ b/lib/services/pharmacy_services/wishList_service.dart @@ -55,9 +55,10 @@ class WishListService extends BaseService { // } Future getWishlist() async { - var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); + //TODO we need to check why the customer id comes null + String customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID)?? "0"; hasError = false; - await baseAppClient.getPharmacy(GET_WISHLIST+customerId+"?shopping_cart_type=2", + await baseAppClient.getPharmacy(GET_WISHLIST+customerId +"?shopping_cart_type=2", onSuccess: (dynamic response, int statusCode) { _wishListProducts.clear(); response['shopping_carts'].forEach((item) { diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart index 237b4cae..ef861c56 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart @@ -17,7 +17,6 @@ class BottomNavPharmacyBar extends StatefulWidget { } class _BottomNavPharmacyBarState extends State { - int _index = 0; _changeIndex(int index) { widget.changeIndex(index); @@ -43,19 +42,6 @@ class _BottomNavPharmacyBarState extends State { currentIndex: 0, title: TranslationBase.of(context).Alhabibapp, ), - - // Container( - // height: 65.0, - // child: Center( - // child: VerticalDivider( - // color: Colors.grey, - // thickness: 0.5, - // width: 0.3, - // indent: 25.5, - // ), - // ), - // ), - BottomNavPharmacyItem( icon: EvaIcons.list, activeIcon: EvaIcons.list, @@ -64,20 +50,6 @@ class _BottomNavPharmacyBarState extends State { currentIndex: 1, title: TranslationBase.of(context).categorise, ), -// Expanded( -// child: SizedBox( -// height: 50, -// child: Column( -// mainAxisSize: MainAxisSize.min, -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// SizedBox(height: 22), -// ], -// ), -// ), -// ), - - // Added Calendar Icon to access book appointment flow BottomNavPharmacyItem( icon: EvaIcons.home, activeIcon: EvaIcons.home, @@ -86,13 +58,12 @@ class _BottomNavPharmacyBarState extends State { currentIndex: 0, isHome: true, title: TranslationBase.of(context).home), - BottomNavPharmacyItem( icon: EvaIcons.person, activeIcon: EvaIcons.person, changeIndex: _changeIndex, index: widget.index, - currentIndex: 3, + currentIndex: 2, title: TranslationBase.of(context).myAccount, ), BottomNavPharmacyItem( @@ -100,7 +71,7 @@ class _BottomNavPharmacyBarState extends State { activeIcon: EvaIcons.shoppingCartOutline, changeIndex: _changeIndex, index: widget.index, - currentIndex: 4, + currentIndex: 3, title: TranslationBase.of(context).cart) ], ), diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart index bff756f1..f31fa588 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart @@ -1,6 +1,10 @@ import 'package:diplomaticquarterapp/Constants.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/pages/login/welcome.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; class BottomNavPharmacyItem extends StatelessWidget { final String title; @@ -33,7 +37,16 @@ class BottomNavPharmacyItem extends StatelessWidget { child: InkWell( highlightColor: Colors.transparent, splashColor: Colors.transparent, - onTap: () => changeIndex(currentIndex), + onTap: () { + if(!Provider.of(context, listen: false).isLogin && (currentIndex == 2|| currentIndex == 3)) + Navigator.push( + context, + FadePage(page: WelcomeLogin()), + ); + else + changeIndex(currentIndex); + + }, child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, From 9a2d52309cf747cc498f560198754a79667c3177 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 4 Oct 2021 16:50:31 +0300 Subject: [PATCH 5/5] products categories page fix --- lib/pages/final_products_page.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index f4bd8b77..c2dd64b9 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -49,7 +49,6 @@ class _FinalProductsPageState extends State { Widget build(BuildContext context) { return BaseView( onModelReady: (model) { - //TODO Elham* fix all services in order handel errors in better way in the service if (widget.productType == 1) { model.getFinalProducts(i: id); @@ -78,7 +77,7 @@ class _FinalProductsPageState extends State { isBottomBar: false, isShowAppBar: true, backgroundColor: Colors.white, - isShowDecPage: true, + isShowDecPage: false, baseViewModel: model, body: Container( height: MediaQuery.of(context).size.height * 5.87,