From 47801ecb36321ff03f297a62b3ff9b59e1a565a8 Mon Sep 17 00:00:00 2001 From: devamirsaleemahmad Date: Wed, 25 Oct 2023 16:21:23 +0300 Subject: [PATCH] changes --- lib/pages/TestPage.dart | 2 +- lib/pages/final_products_page.dart | 82 +- lib/pages/livecare/incoming_call.dart | 4 +- lib/pages/offers_categorise_page.dart | 1092 ++++++++----------- lib/pages/parent_categorise_page.dart | 100 +- lib/pages/pharmacy_categorise.dart | 62 +- lib/pages/search_products_page.dart | 110 +- lib/pages/sub_categories_modalsheet.dart | 8 +- lib/pages/sub_categorise_page.dart | 859 ++++++--------- lib/uitl/CalendarUtils.dart | 5 +- lib/widgets/others/app_scaffold_widget.dart | 3 +- 11 files changed, 946 insertions(+), 1381 deletions(-) diff --git a/lib/pages/TestPage.dart b/lib/pages/TestPage.dart index 6aacc345..5c787014 100644 --- a/lib/pages/TestPage.dart +++ b/lib/pages/TestPage.dart @@ -26,7 +26,7 @@ class TestPageState extends State{ } void location(){ - LocationUtils().getCurrentLocation(callBack: (latLng){ + LocationUtils(context: context,isShowConfirmDialog: false).getCurrentLocation(callBack: (latLng){ print(latLng.toString()); }); } diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 6eea4537..745b8394 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -17,8 +17,8 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:provider/provider.dart'; -import 'package:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; @@ -26,7 +26,7 @@ import 'base/base_view.dart'; dynamic languageID; class FinalProductsPage extends StatefulWidget { - final String id; + final String? id; final int productType; // 1 : default, 2 : manufacturer , 3 : recently viewed AuthenticatedUserObject authenticatedUserObject = locator(); @@ -37,7 +37,7 @@ class FinalProductsPage extends StatefulWidget { } class _FinalProductsPageState extends State { - String id; + String? id; _FinalProductsPageState({this.id}); @@ -70,7 +70,7 @@ class _FinalProductsPageState extends State { model.getFinalProducts(i: id); appBarTitle = TranslationBase.of(context).products; } else if (widget.productType == 2) { - model.getManufacturerProducts(id); + model.getManufacturerProducts(id!); } else if (widget.productType == 3) { model.getLastVisitedProducts(); appBarTitle = TranslationBase.of(context).recentlyViewed; @@ -86,7 +86,7 @@ class _FinalProductsPageState extends State { } }, allowAny: true, - builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => AppScaffold( + builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget? child) => AppScaffold( isPharmacy: true, appBarTitle: appBarTitle, isBottomBar: true, @@ -217,9 +217,9 @@ class _FinalProductsPageState extends State { margin: EdgeInsets.fromLTRB(0, 16, 0, 0), alignment: Alignment.center, child: (model.finalProducts[index].images != null && - model.finalProducts[index].images.length > 0) + model.finalProducts[index].images!.length > 0) ? Image.network( - model.finalProducts[index].images[0].src, + model.finalProducts[index].images![0].src!, fit: BoxFit.cover, height: 80, width: 80, @@ -305,16 +305,30 @@ class _FinalProductsPageState extends State { // ? (model.finalProducts[index].approvedRatingSum.toDouble() / model.finalProducts[index].approvedRatingSum.toDouble()).toDouble() // : 0, // forceStars: true), - RatingBar.readOnly( - initialRating: model.finalProducts[index].approvedRatingSum.toDouble(), - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + + RatingBar( + initialRating: model.finalProducts[index].approvedRatingSum!.toDouble(), + ratingWidget: RatingWidget( + full: Icon( + Icons.star, + color: Colors.yellow[700], + ), + half: Icon( + Icons.star_half, + color: Colors.yellow[700], + ), + empty: Icon( + Icons.star_border, + color: Colors.grey[500], + ), + ), + onRatingUpdate: (double value) {}, + unratedColor: Colors.grey[500], + updateOnDrag: false, + tapOnlyMode: false, ), + + Texts( "(${model.finalProducts[index].approvedTotalReviews})", regular: true, @@ -394,9 +408,9 @@ class _FinalProductsPageState extends State { margin: EdgeInsets.fromLTRB(0, 0, 0, 8), alignment: Alignment.center, child:(model.finalProducts[index].images != null && - model.finalProducts[index].images.length > 0) + model.finalProducts[index].images!.length > 0) ? Image.network( - model.finalProducts[index].images[0].src, + model.finalProducts[index].images![0].src!, fit: BoxFit.cover, height: 80, width: 80, @@ -489,16 +503,30 @@ class _FinalProductsPageState extends State { // ? (model.finalProducts[index].approvedRatingSum.toDouble() / model.finalProducts[index].approvedRatingSum.toDouble()).toDouble() // : 0, // forceStars: true), - RatingBar.readOnly( - initialRating: model.finalProducts[index].approvedRatingSum.toDouble(), - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + RatingBar( + initialRating: model.finalProducts[index].approvedRatingSum!.toDouble(), + ratingWidget: RatingWidget( + full: Icon( + Icons.star, + color: Colors.yellow[700], + ), + half: Icon( + Icons.star_half, + color: Colors.yellow[700], + ), + empty: Icon( + Icons.star_border, + color: Colors.grey[500], + ), + ), + onRatingUpdate: (double value) {}, + unratedColor: Colors.grey[500], + updateOnDrag: false, + tapOnlyMode: false, ), + + + Texts( "(${model.finalProducts[index].approvedTotalReviews})", regular: true, diff --git a/lib/pages/livecare/incoming_call.dart b/lib/pages/livecare/incoming_call.dart index 7983e529..286969da 100644 --- a/lib/pages/livecare/incoming_call.dart +++ b/lib/pages/livecare/incoming_call.dart @@ -18,9 +18,9 @@ import '../../config/config.dart'; class IncomingCall extends StatefulWidget { - IncomingCallData incomingCallData; + IncomingCallData? incomingCallData; - IncomingCall({required this.incomingCallData}); + IncomingCall({ this.incomingCallData}); @override _IncomingCallState createState() => _IncomingCallState(); diff --git a/lib/pages/offers_categorise_page.dart b/lib/pages/offers_categorise_page.dart index a4708830..d4e57a9a 100644 --- a/lib/pages/offers_categorise_page.dart +++ b/lib/pages/offers_categorise_page.dart @@ -6,8 +6,8 @@ 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:flutter/material.dart'; +import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:provider/provider.dart'; -import 'package:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; @@ -32,322 +32,246 @@ class _OffersCategorisePageState extends State { ProjectViewModel projectProvider = Provider.of(context); return BaseView( onModelReady: (model) => model.getOffersCategorise(), - builder: (BuildContext context, OffersCategoriseViewModel model, - Widget child) => - PharmacyAppScaffold( - appBarTitle: TranslationBase.of(context).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: [ - Padding( - padding: EdgeInsets.all(10.0), - child: Container( - child: Texts( - 'Categories', - fontWeight: FontWeight.w800, - ), - ), + builder: (BuildContext context, OffersCategoriseViewModel model, Widget? child) => PharmacyAppScaffold( + appBarTitle: TranslationBase.of(context).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: [ + 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(projectViewModel.isArabic ? model.categorise[index].namen : model.categorise[index].name, + ), + ), + 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( + projectViewModel.isArabic ? model.categorise[index].namen : model.categorise[index].name, // model.categorise[index].name, - fontWeight: - FontWeight.w600, - fontSize: 13.8, - ), - ), + fontWeight: FontWeight.w600, + fontSize: 13.8, ), - ], + ), ), - onTap: () { - model.getOffersProducts( - i: model - .categorise[index].id); - String ids = - model.categorise[index].id; + ], + ), + onTap: () { + model.getOffersProducts(i: model.categorise[index].id); + String ids = model.categorise[index].id!; - categoriseName = projectViewModel.isArabic ? model.categorise[index].namen : model.categorise[index].name; - //model.categorise[index].name; - }), - ], - ), - ); - }), - ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, + categoriseName = projectViewModel.isArabic ? model.categorise[index].namen! : model.categorise[index].name!; + //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( - mainAxisAlignment: MainAxisAlignment.spaceBetween, 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: Texts( - categoriseName, - fontWeight: FontWeight.w800, + 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, + ); + } + }); + }, ), ), - 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: 8, - vertical: 4, + ], + ), + 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), ), - 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, + color: Colors.white, + ), + padding: EdgeInsets.symmetric(horizontal: 0), + width: MediaQuery.of(context).size.width / 3, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( 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( - TranslationBase.of(context).offers - .toUpperCase(), - color: Colors - .red, - fontSize: - 13.0, - fontWeight: - FontWeight - .w900, - ), - ), - transform: new Matrix4 - .rotationZ( - 5.837200), + 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( + TranslationBase.of(context).offers.toUpperCase(), + color: Colors.red, + fontSize: 13.0, + fontWeight: FontWeight.w900, ), ), - 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, - ), + transform: new Matrix4.rotationZ(5.837200), ), - 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: model.products[index].rxMessage != null - ? Texts( - projectProvider.isArabic - ? model.products[index].rxMessagen - : model.products[index].rxMessage, - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ): Texts("") + ), + 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: model.products[index].rxMessage != null + ? Texts( + projectProvider.isArabic ? model.products[index].rxMessagen : model.products[index].rxMessage, + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ) + : Texts("") // Texts( // model.products[index].rxMessage != null ? // model.products[index].rxMessage @@ -361,74 +285,50 @@ class _OffersCategorisePageState extends State { // .w400, // ), ), - ], - ), - Container( - margin: EdgeInsets - .symmetric( - horizontal: 6, - vertical: 0, - ), - 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( projectViewModel.isArabic ? model.products[index].namen : model.products[index].name, - // model.products[index].name, - regular: true, - fontSize: 12.58, - fontWeight: - FontWeight - .w600, + ], + ), + Container( + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (model.products[index].discountName != null) + Container( + width: double.infinity, + height: 22.0, + decoration: BoxDecoration( + color: Color(0xff5AB145), ), - Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: - 4), + child: Center( child: Texts( - "SAR ${model.products[index].price}", - bold: true, - fontSize: 14, + model.products[index].discountName, + regular: true, + color: Colors.white, + fontSize: 12.0, + fontWeight: FontWeight.w700, ), ), - Row( - children: [ + ), + Texts( + projectViewModel.isArabic ? model.products[index].namen : model.products[index].name, + // 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 @@ -437,158 +337,121 @@ class _OffersCategorisePageState extends State { // : 0, // forceStars: // true), - RatingBar.readOnly( - initialRating: model.products[index].approvedRatingSum.toDouble(), - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + + RatingBar( + initialRating: model.products[index].approvedRatingSum!.toDouble(), + ratingWidget: RatingWidget( + full: Icon( + Icons.star, + color: Colors.yellow[700], ), - Texts( - "(${model.products[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: - FontWeight - .w400, - ) - ], + half: Icon( + Icons.star_half, + color: Colors.yellow[700], + ), + empty: Icon( + Icons.star_border, + color: Colors.grey[500], + ), + ), + onRatingUpdate: (double value) {}, + unratedColor: Colors.grey[500], + updateOnDrag: false, + tapOnlyMode: false, ), + + 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( + ], + ), + ), + )); + }, + ), + ), + ) + : 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: [ - Stack( + Column( 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( - TranslationBase.of(context).offers - .toUpperCase(), - color: Colors - .red, - fontSize: - 13.0, - fontWeight: - FontWeight - .w900, - ), - ), + 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( + TranslationBase.of(context).offers.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, ), ), - ], + 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)), - ), - child: model.products[index].rxMessage != null - ? Texts( - projectProvider.isArabic - ? model.products[index].rxMessagen - : model.products[index].rxMessage, - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ): Texts("") + ], + ), + 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)), + ), + child: model.products[index].rxMessage != null + ? Texts( + projectProvider.isArabic ? model.products[index].rxMessagen : model.products[index].rxMessage, + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ) + : Texts("") // Texts( // model.products[index].rxMessage != null // ? model.products[index].rxMessage @@ -602,80 +465,61 @@ class _OffersCategorisePageState extends State { // .w400, // ), ), - ], - ), ], ), - 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( projectViewModel.isArabic ? model.products[index].namen : model.products[index].name, - // model.products[index].name, - regular: true, - fontSize: 14.0, - fontWeight: - FontWeight.w600, - ), - SizedBox( - height: 8.0, + ], + ), + 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), ), - Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), + child: Padding( + padding: EdgeInsets.symmetric( + horizontal: 5.5, + ), child: Texts( - "SAR ${model.products[index].price}", - bold: true, - fontSize: 14, + model.products[index].discountName, + regular: true, + color: Colors.white, + fontSize: 12.0, + fontWeight: FontWeight.w700, ), ), - Row( - children: [ + ), + SizedBox( + height: 4.0, + ), + Texts( + projectViewModel.isArabic ? model.products[index].namen : model.products[index].name, + // 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[ @@ -689,64 +533,76 @@ class _OffersCategorisePageState extends State { // : 0, // forceStars: // true), - RatingBar.readOnly( - initialRating: model.products[index].approvedRatingSum.toDouble(), - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + + RatingBar( + initialRating: model.products[index].approvedRatingSum!.toDouble(), + ratingWidget: RatingWidget( + full: Icon( + Icons.star, + color: Colors.yellow[700], ), - Texts( - "(${model.products[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: - FontWeight - .w500, - ) - ], + half: Icon( + Icons.star_half, + color: Colors.yellow[700], + ), + empty: Icon( + Icons.star_border, + color: Colors.grey[500], + ), + ), + onRatingUpdate: (double value) {}, + unratedColor: Colors.grey[500], + updateOnDrag: false, + tapOnlyMode: false, ), + + Texts( + "(${model.products[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: FontWeight.w500, + ) ], ), - ), - ], + ], + ), ), - ); - }), - ), - ) - ], - ), - ) - : Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Image.asset( - 'assets/images/new-design/empty_box.png', - width: 100, - height: 100, - fit: BoxFit.cover, + ], + ), + ); + }), + ), + ) + ], + ), + ) + : Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Image.asset( + 'assets/images/new-design/empty_box.png', + width: 100, + height: 100, + fit: BoxFit.cover, + ), ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Text(TranslationBase.of(context).noOffersAvailable, + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + TranslationBase.of(context).noOffersAvailable, // 'There is no data', - style: TextStyle(fontSize: 30), - ), - ) - ], - ), + style: TextStyle(fontSize: 30), + ), + ) + ], + ), // 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 37b05404..1815436a 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -21,15 +21,15 @@ import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:provider/provider.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; -import 'package:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; class ParentCategorisePage extends StatefulWidget { - String id; - String titleName; + String? id; + String? titleName; AuthenticatedUserObject authenticatedUserObject = locator(); @@ -40,8 +40,8 @@ class ParentCategorisePage extends StatefulWidget { } class _ParentCategorisePageState extends State { - String id; - String titleName; + String? id; + String? titleName; final dynamic productID; _ParentCategorisePageState({ @@ -63,8 +63,8 @@ class _ParentCategorisePageState extends State { int pageIndex = 1; - List entityList =[]; - List entityListBrands =[]; + List entityList = []; + List entityListBrands = []; RefreshController controller = RefreshController(); @@ -77,9 +77,9 @@ class _ParentCategorisePageState extends State { return BaseView( onModelReady: (model) => model.getCategoriseParent(i: id, pageIndex: pageIndex, isLoading: false, context: context), allowAny: true, - builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => AppScaffold( + builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget? child) => AppScaffold( isPharmacy: true, - appBarTitle: titleName, + appBarTitle: titleName!, isBottomBar: true, isShowAppBar: true, backgroundColor: Colors.white, @@ -338,10 +338,6 @@ class _ParentCategorisePageState extends State { entityList.add(history); }); }, - addSelectedHistories: () { - //TODO build your fun herr - // widget.addSelectedHistories(); - }, isEntityListSelected: (master) => isEntityListSelected(master), ) ], @@ -366,10 +362,6 @@ class _ParentCategorisePageState extends State { entityListBrands.add(history); }); }, - addSelectedHistories: () { - //TODO build your fun herr - // widget.addSelectedHistories(); - }, isEntityListSelected: (master) => isEntityListSelectedBrands(master), ) ], @@ -462,7 +454,7 @@ class _ParentCategorisePageState extends State { String categoriesId = ""; for (CategoriseParentModel category in entityList) { if (categoriesId == "") { - categoriesId = category.id; + categoriesId = category.id!; } else { categoriesId = "$categoriesId,${category.id}"; } @@ -470,7 +462,7 @@ class _ParentCategorisePageState extends State { String brandIds = ""; for (CategoriseParentModel brand in entityListBrands) { if (brandIds == "") { - brandIds = brand.id; + brandIds = brand.id!; } else { brandIds = "$brandIds,${brand.id}"; } @@ -633,8 +625,8 @@ class _ParentCategorisePageState extends State { 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, @@ -736,16 +728,29 @@ class _ParentCategorisePageState extends State { // ? (model.parentProducts[index].approvedRatingSum.toDouble() / model.parentProducts[index].approvedRatingSum.toDouble()).toDouble() // : 0, // forceStars: true), - RatingBar.readOnly( - initialRating: model.parentProducts[index].approvedRatingSum.toDouble(), - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + + RatingBar( + initialRating: model.parentProducts[index].approvedRatingSum!.toDouble(), + ratingWidget: RatingWidget( + full: Icon( + Icons.star, + color: Colors.yellow[700], + ), + half: Icon( + Icons.star_half, + color: Colors.yellow[700], + ), + empty: Icon( + Icons.star_border, + color: Colors.grey[500], + ), + ), + onRatingUpdate: (double value) {}, + unratedColor: Colors.grey[500], + updateOnDrag: false, + tapOnlyMode: false, ), + Texts( "(${model.parentProducts[index].approvedTotalReviews})", regular: true, @@ -799,9 +804,9 @@ class _ParentCategorisePageState extends State { Container( margin: EdgeInsets.fromLTRB(0, 0, 0, 0), alignment: Alignment.center, - child: model.parentProducts[index].images.isNotEmpty + child: model.parentProducts[index].images!.isNotEmpty ? Image.network( - model.parentProducts[index].images[0].thumb, + model.parentProducts[index].images![0].thumb!, fit: BoxFit.contain, height: 70, ) @@ -879,16 +884,29 @@ class _ParentCategorisePageState extends State { // ? (model.parentProducts[index].approvedRatingSum.toDouble() / model.parentProducts[index].approvedRatingSum.toDouble()).toDouble() // : 0, // forceStars: true), - RatingBar.readOnly( - initialRating: model.parentProducts[index].approvedRatingSum.toDouble(), - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + + RatingBar( + initialRating: model.parentProducts[index].approvedRatingSum!.toDouble(), + ratingWidget: RatingWidget( + full: Icon( + Icons.star, + color: Colors.yellow[700], + ), + half: Icon( + Icons.star_half, + color: Colors.yellow[700], + ), + empty: Icon( + Icons.star_border, + color: Colors.grey[500], + ), + ), + onRatingUpdate: (double value) {}, + unratedColor: Colors.grey[500], + updateOnDrag: false, + tapOnlyMode: false, ), + Texts( "(${model.parentProducts[index].approvedTotalReviews})", regular: true, diff --git a/lib/pages/pharmacy_categorise.dart b/lib/pages/pharmacy_categorise.dart index 9a364cf4..a748ed90 100644 --- a/lib/pages/pharmacy_categorise.dart +++ b/lib/pages/pharmacy_categorise.dart @@ -23,7 +23,7 @@ class PharmacyCategorisePage extends StatefulWidget { } class _PharmacyCategorisePageState extends State { - String idCategorise; + String? idCategorise; @override Widget build(BuildContext context) { @@ -31,9 +31,7 @@ class _PharmacyCategorisePageState extends State { return BaseView( onModelReady: (model) => model.getCategorise(), allowAny: true, - builder: (BuildContext context, PharmacyCategoriseViewModel model, - Widget child) => - AppScaffold( + builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget? child) => AppScaffold( isShowDecPage: false, isShowAppBar: false, isMainPharmacyPages: true, @@ -66,9 +64,7 @@ class _PharmacyCategorisePageState extends State { child: Padding( padding: EdgeInsets.symmetric(horizontal: 10.0), child: Texts( - projectViewModel.isArabic - ? model.categorise[index].namen - : model.categorise[index].name, + projectViewModel.isArabic ? model.categorise[index].namen : model.categorise[index].name, fontWeight: FontWeight.w600, ), ), @@ -80,8 +76,8 @@ class _PharmacyCategorisePageState extends State { page: model.categorise[index].id != '12' ? ParentCategorisePage( id: model.categorise[index].id, - titleName: projectViewModel.isArabic ? model.categorise[index].namen : model.categorise[index].name, - // titleName: model.categorise[index].name, + titleName: projectViewModel.isArabic ? model.categorise[index].namen : model.categorise[index].name, + // titleName: model.categorise[index].name, ) : FinalProductsPage( id: model.categorise[index].id, @@ -99,10 +95,7 @@ class _PharmacyCategorisePageState extends State { height: 140, child: Column( children: [ - Divider( - height: 2.0, - thickness: 1.0, - color: Colors.black12.withOpacity(0.14)), + Divider(height: 2.0, thickness: 1.0, color: Colors.black12.withOpacity(0.14)), SizedBox( height: 10.0, ), @@ -128,16 +121,12 @@ class _PharmacyCategorisePageState extends State { width: 55.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(5.0), - color: - Colors.green.shade300.withOpacity(0.34), + color: Colors.green.shade300.withOpacity(0.34), ), child: Padding( - padding: - EdgeInsets.symmetric(horizontal: 10.0), + padding: EdgeInsets.symmetric(horizontal: 10.0), child: Texts( - projectViewModel.isArabic - ? 'الاكثر مبيعا' - : 'Best Sellers', + projectViewModel.isArabic ? 'الاكثر مبيعا' : 'Best Sellers', fontWeight: FontWeight.w600, ), ), @@ -164,17 +153,13 @@ class _PharmacyCategorisePageState extends State { height: 50.0, width: 55.0, decoration: BoxDecoration( - color: Colors.orangeAccent.shade200 - .withOpacity(0.34), + color: Colors.orangeAccent.shade200.withOpacity(0.34), borderRadius: BorderRadius.circular(5.0), ), child: Padding( - padding: - EdgeInsets.symmetric(horizontal: 10.0), + padding: EdgeInsets.symmetric(horizontal: 10.0), child: Texts( - projectViewModel.isArabic - ? 'الاكثر مشاهدة' - : 'Most Viewed', + projectViewModel.isArabic ? 'الاكثر مشاهدة' : 'Most Viewed', fontWeight: FontWeight.w600, ), ), @@ -209,12 +194,9 @@ class _PharmacyCategorisePageState extends State { borderRadius: BorderRadius.circular(5.0), ), child: Padding( - padding: - EdgeInsets.symmetric(horizontal: 10.0), + padding: EdgeInsets.symmetric(horizontal: 10.0), child: Texts( - projectViewModel.isArabic - ? 'منتجات جديدة' - : 'New Products', + projectViewModel.isArabic ? 'منتجات جديدة' : 'New Products', fontWeight: FontWeight.w600, ), ), @@ -241,17 +223,13 @@ class _PharmacyCategorisePageState extends State { height: 50.0, width: 55.0, decoration: BoxDecoration( - color: - Colors.purple.shade200.withOpacity(0.34), + color: Colors.purple.shade200.withOpacity(0.34), borderRadius: BorderRadius.circular(5.0), ), child: Padding( - padding: - EdgeInsets.symmetric(horizontal: 10.0), + padding: EdgeInsets.symmetric(horizontal: 10.0), child: Texts( - projectViewModel.isArabic - ? 'شوهد مؤخرا' - : 'Recently Viewed', + projectViewModel.isArabic ? 'شوهد مؤخرا' : 'Recently Viewed', fontWeight: FontWeight.w600, ), ), @@ -277,7 +255,9 @@ class _PharmacyCategorisePageState extends State { /// When give qr we will change this method to get data /// var result = await BarcodeScanner.scan(); /// int patientID = get from qr result - String result = (await BarcodeScanner.scan())?.rawContent; + String result = await BarcodeScanner.scan().then((value) { + return value.rawContent; + }); var data = json.decode(result); if (data != null) { var qRParkingID = data['QRParkingID']; @@ -285,7 +265,7 @@ class _PharmacyCategorisePageState extends State { if (model.state == ViewState.ErrorLocal) { Utils.showErrorToast(model.error); } else { - AppToast.showSuccessToast(message: model.scanList[0].id); + AppToast.showSuccessToast(message: model.scanList[0].id!); { Navigator.push( context, diff --git a/lib/pages/search_products_page.dart b/lib/pages/search_products_page.dart index 022dde75..6f428e4b 100644 --- a/lib/pages/search_products_page.dart +++ b/lib/pages/search_products_page.dart @@ -2,6 +2,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/screens/product-details/product-detail.dart'; + // import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -37,9 +38,7 @@ class _SearchProductsPageState extends State { ProjectViewModel projectProvider = Provider.of(context); return BaseView( onModelReady: (model) => model.clearSearchList(), - builder: (BuildContext context, PharmacyCategoriseViewModel model, - Widget child) => - PharmacyAppScaffold( + builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget? child) => PharmacyAppScaffold( appBarTitle: TranslationBase.of(context).search, isBottomBar: false, isShowAppBar: true, @@ -122,8 +121,7 @@ class _SearchProductsPageState extends State { height: MediaQuery.of(context).size.height * 0.80, child: GridView.builder( //physics: NeverScrollableScrollPhysics(), - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 0.5, mainAxisSpacing: 2.0, @@ -133,11 +131,7 @@ class _SearchProductsPageState extends State { itemBuilder: (BuildContext context, int index) { return InkWell( child: Card( - color: model.searchList[index] - .discountName != - null - ? Color(0xffFFFF00) - : Colors.white, + color: model.searchList[index].discountName != null ? Color(0xffFFFF00) : Colors.white, elevation: 0, shape: Border( right: BorderSide( @@ -168,70 +162,38 @@ class _SearchProductsPageState extends State { ), color: Colors.white, ), - padding: - EdgeInsets.symmetric(horizontal: 0), - width: - MediaQuery.of(context).size.width / - 3, + padding: EdgeInsets.symmetric(horizontal: 0), + width: MediaQuery.of(context).size.width / 3, child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ Container( - margin: EdgeInsets.fromLTRB( - 0, 16, 0, 0), + margin: EdgeInsets.fromLTRB(0, 16, 0, 0), alignment: Alignment.center, child: Image.network( - model.searchList[index] - .images.isNotEmpty - ? model - .searchList[index] - .images[0] - .thumb + 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 / - 3 - : 0, + width: model.searchList[index].rxMessage != null ? MediaQuery.of(context).size.width / 3 : 0, padding: EdgeInsets.all(4), decoration: BoxDecoration( color: Color(0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: - Radius.circular( - 6)), + borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: model.searchList[index] - .rxMessage != - null + child: model.searchList[index].rxMessage != null ? Texts( - projectProvider - .isArabic - ? model - .searchList[ - index] - .rxMessagen - : model - .searchList[ - index] - .rxMessage, + projectProvider.isArabic ? model.searchList[index].rxMessagen : model.searchList[index].rxMessage, color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ) : Texts(""), // Texts( @@ -256,17 +218,10 @@ class _SearchProductsPageState extends State { vertical: 0, ), child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - projectProvider.isArabic - ? model - .searchList[index] - .namen - : model - .searchList[index] - .name, + projectProvider.isArabic ? model.searchList[index].namen : model.searchList[index].name, // model.searchList[index].name, regular: true, @@ -274,9 +229,7 @@ class _SearchProductsPageState extends State { fontWeight: FontWeight.w400, ), Padding( - padding: - const EdgeInsets.only( - top: 4, bottom: 4), + padding: const EdgeInsets.only(top: 4, bottom: 4), child: Texts( "SAR ${model.searchList[index].price}", bold: true, @@ -286,30 +239,15 @@ class _SearchProductsPageState extends State { Row( children: [ StarRating( - totalAverage: model - .searchList[ - index] - .approvedRatingSum > - 0 - ? (model - .searchList[ - index] - .approvedRatingSum - .toDouble() / - model - .searchList[ - index] - .approvedRatingSum - .toDouble()) - .toDouble() + 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, + fontWeight: FontWeight.w400, ) ], ), @@ -324,8 +262,7 @@ class _SearchProductsPageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage( - model.searchList[index]), + page: ProductDetailPage(model.searchList[index]), )), }, ); @@ -350,7 +287,6 @@ class _SearchProductsPageState extends State { searchMedicine(PharmacyCategoriseViewModel model, BuildContext context) { Utils.hideKeyboard(context); - if (_formKey.currentState.validate()) - model.searchProducts(productName: textController.text); + if (_formKey.currentState!.validate()) model.searchProducts(productName: textController.text); } } diff --git a/lib/pages/sub_categories_modalsheet.dart b/lib/pages/sub_categories_modalsheet.dart index ed2403db..64b48fd1 100644 --- a/lib/pages/sub_categories_modalsheet.dart +++ b/lib/pages/sub_categories_modalsheet.dart @@ -17,8 +17,8 @@ import 'package:provider/provider.dart'; class SubCategoriseModalsheet extends StatefulWidget { - String id; - String titleName; + String? id; + String? titleName; SubCategoriseModalsheet({this.id, this.titleName}); @override @@ -27,8 +27,8 @@ class SubCategoriseModalsheet extends StatefulWidget { } class _SubCategoriseModalsheetState extends State { - String id; - String titleName; + String? id; + String? titleName; // List categoriesList = []; _SubCategoriseModalsheetState({this.id, this.titleName}); diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index c1542331..dc0663f1 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -19,35 +19,33 @@ import 'package:diplomaticquarterapp/widgets/others/entity_checkbox_list.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:provider/provider.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; -import 'package:rating_bar/rating_bar.dart'; -import 'package:diplomaticquarterapp/uitl/utils.dart' as utils ; +import 'package:diplomaticquarterapp/uitl/utils.dart' as utils; import 'base/base_view.dart'; import 'final_products_page.dart'; class SubCategorisePage extends StatefulWidget { - String id; - String title; - String parentId; + String? id; + String? title; + String? parentId; - AuthenticatedUserObject authenticatedUserObject = - locator(); + AuthenticatedUserObject authenticatedUserObject = locator(); SubCategorisePage({this.id, this.parentId, this.title}); @override - _SubCategorisePageState createState() => - _SubCategorisePageState(id: id, title: title, parentId: parentId); + _SubCategorisePageState createState() => _SubCategorisePageState(id: id, title: title, parentId: parentId); } class _SubCategorisePageState extends State { bool checkedBrands = false; bool checkedCategorise = false; - String id; - String title; - String parentId; + String? id; + String? title; + String? parentId; _SubCategorisePageState({this.title, this.parentId, this.id}); @@ -63,8 +61,8 @@ class _SubCategorisePageState extends State { int pageIndex = 1; RefreshController controller = RefreshController(); - List entityList =[]; - List entityListBrands =[]; + List entityList = []; + List entityListBrands = []; @override Widget build(BuildContext context) { @@ -73,14 +71,11 @@ class _SubCategorisePageState extends State { ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectProvider = Provider.of(context); return BaseView( - onModelReady: (model) => model.getSubCategorise( - i: id, pageIndex: pageIndex, isLoading: false, context: context), + onModelReady: (model) => model.getSubCategorise(i: id, pageIndex: pageIndex, isLoading: false, context: context), allowAny: true, - builder: (BuildContext context, PharmacyCategoriseViewModel model, - Widget child) => - AppScaffold( + builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget? child) => AppScaffold( isPharmacy: true, - appBarTitle: title, + appBarTitle: title!, isBottomBar: true, isShowAppBar: true, backgroundColor: Colors.white, @@ -96,11 +91,7 @@ class _SubCategorisePageState extends State { setState(() { ++pageIndex; }); - await model.getSubProducts( - pageIndex: pageIndex, - i: id, - isLoading: true, - context: context); + await model.getSubProducts(pageIndex: pageIndex, i: id, isLoading: true, context: context); if (model.state != ViewState.BusyLocal && pageIndex < 5) { controller.loadComplete(); } else { @@ -132,8 +123,7 @@ class _SubCategorisePageState extends State { ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' : parentId == '9' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' - : parentId == - '10' + : parentId == '10' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' : '', fit: BoxFit.fill, @@ -145,14 +135,12 @@ class _SubCategorisePageState extends State { children: [ InkWell( child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: EdgeInsets.all(10.0), child: Container( - child: Texts(TranslationBase.of(context) - .viewSubCategorise), + child: Texts(TranslationBase.of(context).viewSubCategorise), ), ), Icon(Icons.arrow_forward) @@ -164,45 +152,27 @@ class _SubCategorisePageState extends State { context: context, builder: (BuildContext context) { return Container( - height: - MediaQuery.of(context).size.height * - 0.89, + height: MediaQuery.of(context).size.height * 0.89, color: Colors.white, child: Center( child: ListView.builder( scrollDirection: Axis.vertical, - itemCount: - model.subCategorise.length, - itemBuilder: - (BuildContext context, - int index) { + itemCount: model.subCategorise.length, + itemBuilder: (BuildContext context, int index) { return Container( child: Padding( - padding: - EdgeInsets.all(8.0), + padding: EdgeInsets.all(8.0), child: InkWell( child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - projectViewModel - .isArabic - ? model - .subCategorise[ - index] - .namen - : model - .subCategorise[ - index] - .name, + projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, // model.subCategorise[index].name ), Divider( thickness: 0.6, - color: - Colors.black12, + color: Colors.black12, ) ], ), @@ -210,12 +180,8 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: - FinalProductsPage( - id: model - .subCategorise[ - index] - .id, + page: FinalProductsPage( + id: model.subCategorise[index].id!, ), ), ); @@ -246,26 +212,21 @@ class _SubCategorisePageState extends State { child: ListView.builder( scrollDirection: Axis.horizontal, itemCount: model.subCategorise.length, - itemBuilder: - (BuildContext context, int index) { + 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( @@ -276,23 +237,11 @@ class _SubCategorisePageState extends State { ), ), Container( - width: MediaQuery.of(context) - .size - .width * - 0.17, - height: MediaQuery.of(context) - .size - .height * - 0.10, + width: MediaQuery.of(context).size.width * 0.17, + height: MediaQuery.of(context).size.height * 0.10, child: Center( child: Texts( - projectViewModel.isArabic - ? model - .subCategorise[index] - .namen - : model - .subCategorise[index] - .name, + projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, // model.subCategorise[index].name, fontSize: 14, fontWeight: FontWeight.w600, @@ -307,8 +256,7 @@ class _SubCategorisePageState extends State { context, FadePage( page: FinalProductsPage( - id: model - .subCategorise[index].id, + id: model.subCategorise[index].id!, ), ), ); @@ -352,22 +300,16 @@ class _SubCategorisePageState extends State { initialChildSize: 0.95, maxChildSize: 0.95, minChildSize: 0.9, - builder: (BuildContext context, - ScrollController - scrollController) { + builder: (BuildContext context, ScrollController scrollController) { return SingleChildScrollView( controller: scrollController, child: Container( color: Colors.white, - height: MediaQuery.of(context) - .size - .height * - 1.95, + height: MediaQuery.of(context).size.height * 1.95, child: Column( children: [ Padding( - padding: - EdgeInsets.all(8.0), + padding: EdgeInsets.all(8.0), child: Row( children: [ Icon( @@ -377,31 +319,23 @@ class _SubCategorisePageState extends State { width: 10.0, ), Texts( - TranslationBase.of( - context) - .refine, + TranslationBase.of(context).refine, // 'Refine', - fontWeight: - FontWeight.w600, + fontWeight: FontWeight.w600, ), SizedBox( width: 250.0, ), InkWell( child: Texts( - TranslationBase.of( - context) - .closeIt, + TranslationBase.of(context).closeIt, // 'Close', color: Colors.red, - fontWeight: - FontWeight - .w600, + fontWeight: FontWeight.w600, fontSize: 15.0, ), onTap: () { - Navigator.pop( - context); + Navigator.pop(context); }, ), ], @@ -414,39 +348,22 @@ class _SubCategorisePageState extends State { Column( children: [ ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .subGroup), + title: Texts(TranslationBase.of(context).subGroup), children: [ ProcedureListWidget( model: model, - masterList: model - .subCategorise, - removeHistory: - (item) { + masterList: model.subCategorise, + removeHistory: (item) { setState(() { - entityList - .remove( - item); + entityList.remove(item); }); }, - addHistory: - (history) { + addHistory: (history) { setState(() { - entityList.add( - history); + entityList.add(history); }); }, - addSelectedHistories: - () { - //TODO build your fun herr - // widget.addSelectedHistories(); - }, - isEntityListSelected: - (master) => - isEntityListSelected( - master), + isEntityListSelected: (master) => isEntityListSelected(master), ) ], ), @@ -455,40 +372,22 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .brands), + title: Texts(TranslationBase.of(context).brands), children: [ ProcedureListWidget( model: model, - masterList: model - .brandsList, - removeHistory: - (item) { + masterList: model.brandsList, + removeHistory: (item) { setState(() { - entityListBrands - .remove( - item); + entityListBrands.remove(item); }); }, - addHistory: - (history) { + addHistory: (history) { setState(() { - entityListBrands - .add( - history); + entityListBrands.add(history); }); }, - addSelectedHistories: - () { - //TODO build your fun herr - // widget.addSelectedHistories(); - }, - isEntityListSelected: - (master) => - isEntityListSelectedBrands( - master), + isEntityListSelected: (master) => isEntityListSelectedBrands(master), ) ], ), @@ -497,71 +396,43 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .price), + title: Texts(TranslationBase.of(context).price), children: [ Container( - color: Color( - 0xffEEEEEE), + color: Color(0xffEEEEEE), child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column( - mainAxisAlignment: - MainAxisAlignment - .start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts(TranslationBase.of( - context) - .min), + Texts(TranslationBase.of(context).min), Container( - color: Colors - .white, - width: - 200, - height: - 40, - child: - TextFormField( - decoration: - InputDecoration( - border: - OutlineInputBorder(), + color: Colors.white, + width: 200, + height: 40, + child: TextFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), ), - controller: - minField, + controller: minField, ), ), ], ), Column( - mainAxisAlignment: - MainAxisAlignment - .start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts(TranslationBase.of( - context) - .max), + Texts(TranslationBase.of(context).max), Container( - color: Colors - .white, - width: - 200, - height: - 40, - child: - TextFormField( - decoration: - InputDecoration( - border: - OutlineInputBorder(), + color: Colors.white, + width: 200, + height: 40, + child: TextFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), ), - controller: - maxField, + controller: maxField, ), ), ], @@ -576,33 +447,20 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), SizedBox( - height: MediaQuery.of( - context) - .size - .height * - 0.4, + height: MediaQuery.of(context).size.height * 0.4, ), Padding( - padding: - EdgeInsets.all( - 8.0), + padding: EdgeInsets.all(8.0), child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceEvenly, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Expanded( - child: - Container( + child: Container( width: 100, child: Button( - label: TranslationBase.of( - context) - .reset, + label: TranslationBase.of(context).reset, // 'Reset', - backgroundColor: - Colors - .red, + backgroundColor: Colors.red, ), ), ), @@ -612,69 +470,37 @@ class _SubCategorisePageState extends State { Container( width: 200, child: Button( - onTap: - () async { - String - categoriesId = - ""; - for (CategoriseParentModel category - in entityList) { - if (categoriesId == - "") { - categoriesId = - category.id; + onTap: () async { + String categoriesId = ""; + for (CategoriseParentModel category in entityList) { + if (categoriesId == "") { + categoriesId = category.id!; } else { - categoriesId = - "$categoriesId,${category.id}"; + categoriesId = "$categoriesId,${category.id}"; } } - String - brandIds = - ""; + String brandIds = ""; - for (CategoriseParentModel brand - in entityListBrands) { - if (brandIds == - "") { - brandIds = - brand.id; + for (CategoriseParentModel brand in entityListBrands) { + if (brandIds == "") { + brandIds = brand.id!; } else { - brandIds = - "$brandIds,${brand.id}"; + brandIds = "$brandIds,${brand.id}"; } } - GifLoaderDialogUtils - .showMyDialog( - context); + GifLoaderDialogUtils.showMyDialog(context); await model.getFilteredSubProducts( - min: minField.text.isEmpty - ? "" - : minField.text - .toString(), - max: maxField.text.isEmpty - ? "" - : maxField.text - .toString(), - categoryId: - categoriesId, - brandId: brandIds.isEmpty - ? "" - : "&manufacturerids=" + - brandIds); - GifLoaderDialogUtils - .hideDialog( - context); - Navigator.pop( - context); + min: minField.text.isEmpty ? "" : minField.text.toString(), + max: maxField.text.isEmpty ? "" : maxField.text.toString(), + categoryId: categoriesId, + brandId: brandIds.isEmpty ? "" : "&manufacturerids=" + brandIds); + GifLoaderDialogUtils.hideDialog(context); + Navigator.pop(context); }, - label: TranslationBase.of( - context) - .apply, + label: TranslationBase.of(context).apply, // 'Apply', - backgroundColor: - Colors - .green, + backgroundColor: Colors.green, ), ), ], @@ -741,28 +567,20 @@ class _SubCategorisePageState extends State { model.subProducts.isNotEmpty ? styleOne == true ? Container( - height: model.subProducts.length * - MediaQuery.of(context).size.height * - 0.15, + height: model.subProducts.length * MediaQuery.of(context).size.height * 0.15, child: GridView.builder( physics: NeverScrollableScrollPhysics(), - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 0.5, mainAxisSpacing: 2.0, childAspectRatio: 0.9, ), itemCount: model.subProducts.length, - itemBuilder: - (BuildContext context, int index) { + itemBuilder: (BuildContext context, int index) { return InkWell( child: Card( - color: model.subProducts[index] - .discountName != - null - ? Color(0xffFFFF00) - : Colors.white, + color: model.subProducts[index].discountName != null ? Color(0xffFFFF00) : Colors.white, elevation: 0, shape: Border( right: BorderSide( @@ -789,92 +607,42 @@ class _SubCategorisePageState extends State { child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.only( - topLeft: - Radius.circular(110.0), + topLeft: Radius.circular(110.0), ), color: Colors.white, ), - padding: EdgeInsets.symmetric( - horizontal: 0), - width: MediaQuery.of(context) - .size - .width / - 3, + padding: EdgeInsets.symmetric(horizontal: 0), + width: MediaQuery.of(context).size.width / 3, child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ Container( - margin: - EdgeInsets.fromLTRB( - 0, 16, 0, 0), - alignment: - Alignment.center, + margin: EdgeInsets.fromLTRB(0, 16, 0, 0), + alignment: Alignment.center, child: Image.network( - model - .subProducts[ - index] - .images - .isNotEmpty - ? model - .subProducts[ - index] - .images[0] - .thumb + model.subProducts[index].images!.isNotEmpty + ? model.subProducts[index].images![0].thumb! : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', fit: BoxFit.cover, height: 80, ), ), Container( - width: model - .subProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 3 - : 0, - padding: - EdgeInsets.all(4), - decoration: - BoxDecoration( - color: - Color(0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), + width: model.subProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 3 : 0, + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + color: Color(0xffb23838), + borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: model - .subProducts[ - index] - .rxMessage != - null + child: model.subProducts[index].rxMessage != null ? Texts( - projectProvider - .isArabic - ? model - .subProducts[ - index] - .rxMessagen - : model - .subProducts[ - index] - .rxMessage, - color: Colors - .white, + projectProvider.isArabic ? model.subProducts[index].rxMessagen : model.subProducts[index].rxMessage, + color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight - .w400, + fontWeight: FontWeight.w400, ) : Texts(""), // Texts( @@ -888,39 +656,22 @@ class _SubCategorisePageState extends State { ], ), Container( - margin: - EdgeInsets.symmetric( + margin: EdgeInsets.symmetric( horizontal: 6, vertical: 0, ), child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - projectViewModel - .isArabic - ? model - .subProducts[ - index] - .namen - : model - .subProducts[ - index] - .name, + projectViewModel.isArabic ? model.subProducts[index].namen : model.subProducts[index].name, // model.subProducts[index].name, regular: true, fontSize: 12, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ), Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), + padding: const EdgeInsets.only(top: 4, bottom: 4), child: Texts( "SAR ${model.subProducts[index].price}", bold: true, @@ -934,35 +685,32 @@ class _SubCategorisePageState extends State { // ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() // : 0, // forceStars: true), - RatingBar.readOnly( - initialRating: model - .subProducts[ - index] - .approvedRatingSum - .toDouble(), - size: 15.0, - filledColor: - Colors.yellow[ - 700], - emptyColor: Colors - .grey[500], - isHalfAllowed: - true, - halfFilledIcon: - Icons - .star_half, - filledIcon: - Icons.star, - emptyIcon: + RatingBar( + initialRating: model.subProducts[index].approvedRatingSum!.toDouble(), + ratingWidget: RatingWidget( + full: Icon( Icons.star, + color: Colors.yellow[700], + ), + half: Icon( + Icons.star_half, + color: Colors.yellow[700], + ), + empty: Icon( + Icons.star_border, + color: Colors.grey[500], + ), + ), + onRatingUpdate: (double value) {}, + unratedColor: Colors.grey[500], + updateOnDrag: false, + tapOnlyMode: false, ), Texts( "(${model.subProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: - FontWeight - .w400, + fontWeight: FontWeight.w400, ) ], ), @@ -977,8 +725,7 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage( - model.subProducts[index]), + page: ProductDetailPage(model.subProducts[index]), )), }, ); @@ -986,166 +733,171 @@ class _SubCategorisePageState extends State { ), ) : Container( - height: model.subProducts.length * - MediaQuery.of(context).size.height * - 0.122, + height: model.subProducts.length * MediaQuery.of(context).size.height * 0.122, child: ListView.builder( physics: NeverScrollableScrollPhysics(), itemCount: model.subProducts.length, - itemBuilder: - (BuildContext context, int index) { - return InkWell( - child: Card( - child: Row( + itemBuilder: (BuildContext context, int index) { + return InkWell( + child: Card( + child: Row( + children: [ + Stack( children: [ - Stack( + Column( 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, 8), - alignment: Alignment.center, - child:(model.subProducts[index].images != null && - model.subProducts[index].images.length > 0) - ? Image.network( - model.subProducts[index].images[0].src, - fit: BoxFit.cover, - height: 80, - width: 80, - - ) - : Image.asset( - "assets/images/no_image.png", - fit: BoxFit.cover, - height: 80, - width: 80, - ), + Container( + decoration: BoxDecoration(), + child: Padding( + padding: EdgeInsets.only( + left: 9.0, + top: 8.0, + right: 10.0, ), - ], + ), ), - Column( - children: [ - Container( - width: model.subProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 3.70 : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), - //borderRadius: BorderRadius.only(topLeft: Radius.circular(5)), - ), - child:model.subProducts[index].rxMessage != null - ? Texts( - projectProvider.isArabic ? model.subProducts[index].rxMessagen : model.subProducts[index].rxMessage, - color: Colors.white, - regular: true, - fontSize: 8, - fontWeight: FontWeight.w600, - ) - : Texts(""), - ), - ], + Container( + margin: EdgeInsets.fromLTRB(0, 0, 0, 8), + alignment: Alignment.center, + child: (model.subProducts[index].images != null && model.subProducts[index].images!.length > 0) + ? Image.network( + model.subProducts[index].images![0].src!, + fit: BoxFit.cover, + height: 80, + width: 80, + ) + : Image.asset( + "assets/images/no_image.png", + fit: BoxFit.cover, + height: 80, + width: 80, + ), ), ], ), - Container( - height: 100.0, - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, + Column( + children: [ + Container( + width: model.subProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 3.70 : 0, + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + color: Color(0xffb23838), + //borderRadius: BorderRadius.only(topLeft: Radius.circular(5)), + ), + child: model.subProducts[index].rxMessage != null + ? Texts( + projectProvider.isArabic ? model.subProducts[index].rxMessagen : model.subProducts[index].rxMessage, + color: Colors.white, + regular: true, + fontSize: 8, + fontWeight: FontWeight.w600, + ) + : Texts(""), + ), + ], + ), + ], + ), + Container( + height: 100.0, + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 4.0, + ), + Container( + width: MediaQuery.of(context).size.width * 0.55, + child: Texts( + projectViewModel.isArabic ? model.subProducts[index].namen : model.subProducts[index].name, + regular: true, + fontSize: 13.2, + fontWeight: FontWeight.w500, + maxLines: 5, + ), ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, + SizedBox( + height: 8.0, + ), + Padding( + padding: const EdgeInsets.only(top: 4, bottom: 4), + child: Texts( + "SAR ${model.subProducts[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( children: [ - SizedBox( - height: 4.0, - ), - Container( - width: MediaQuery.of(context).size.width * 0.55, - child: Texts(projectViewModel.isArabic ? model.subProducts[index].namen : model.subProducts[index].name, - regular: true, - fontSize: 13.2, - fontWeight: FontWeight.w500, - maxLines: 5, - ), - ), - SizedBox( - height: 8.0, - ), - Padding( - padding: const EdgeInsets.only(top: 4, bottom: 4), - child: Texts( - "SAR ${model.subProducts[index].price}", - bold: true, - fontSize: 14, - ), - ), - Row( - children: [ - RatingBar.readOnly( - initialRating: model.subProducts[index].approvedRatingSum.toDouble(), - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + RatingBar( + initialRating: model.subProducts[index].approvedRatingSum!.toDouble(), + ratingWidget: RatingWidget( + full: Icon( + Icons.star, + color: Colors.yellow[700], + ), + half: Icon( + Icons.star_half, + color: Colors.yellow[700], + ), + empty: Icon( + Icons.star_border, + color: Colors.grey[500], ), - Texts( - "(${model.subProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ) - ], + ), + onRatingUpdate: (double value) {}, + unratedColor: Colors.grey[500], + updateOnDrag: false, + tapOnlyMode: false, ), + Texts( + "(${model.subProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ) ], ), - ), - widget.authenticatedUserObject.isLogin - ? Container( - child: IconButton( - icon: Icon( - Icons.shopping_cart, - size: 18, - color: CustomColors.green, - ), - onPressed: () async { - if (model.subProducts[index].isRx == false) { - GifLoaderDialogUtils.showMyDialog(context); - await addToCartFunction(1, model.subProducts[index].id); - GifLoaderDialogUtils.hideDialog(context); - utils.Utils.navigateToCartPage(); - - - } else { - AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); - } -// - }), - ) - : Container(), - ], + ], + ), ), - ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage(model.subProducts[index]), - )), - }, - ); + widget.authenticatedUserObject.isLogin + ? Container( + child: IconButton( + icon: Icon( + Icons.shopping_cart, + size: 18, + color: CustomColors.green, + ), + onPressed: () async { + if (model.subProducts[index].isRx == false) { + GifLoaderDialogUtils.showMyDialog(context); + await addToCartFunction(1, model.subProducts[index].id); + GifLoaderDialogUtils.hideDialog(context); + utils.Utils.navigateToCartPage(); + } else { + AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); + } +// + }), + ) + : Container(), + ], + ), + ), + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage(model.subProducts[index]), + )), + }, + ); // return InkWell( // child: Card( // child: Row( @@ -1420,8 +1172,7 @@ class _SubCategorisePageState extends State { child: Container( child: Center( child: Column( - mainAxisAlignment: - MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( padding: const EdgeInsets.all(8.0), @@ -1453,8 +1204,7 @@ class _SubCategorisePageState extends State { } bool isEntityListSelected(CategoriseParentModel masterKey) { - Iterable history = - entityList.where((element) => masterKey.id == element.id); + Iterable history = entityList.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } @@ -1462,8 +1212,7 @@ class _SubCategorisePageState extends State { } bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { - Iterable history = - entityListBrands.where((element) => masterKey.id == element.id); + Iterable history = entityListBrands.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } diff --git a/lib/uitl/CalendarUtils.dart b/lib/uitl/CalendarUtils.dart index 50a291d4..add65f64 100644 --- a/lib/uitl/CalendarUtils.dart +++ b/lib/uitl/CalendarUtils.dart @@ -37,10 +37,7 @@ class CalendarUtils { _currentLocation = getLocation('Asia/Dubai'); else _currentLocation = getLocation('Asia/Riyadh'); - - scheduleDateTime!.forEach((element) { - Future createOrUpdateEvents({List? scheduleList, String? title, String? description, List? scheduleDateTime, List? daysOfWeek}) async { - List events =[]; + scheduleDateTime!.forEach((element) { RecurrenceRule recurrenceRule = RecurrenceRule( RecurrenceFrequency.Daily, diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index d3e5b69d..75eb257a 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -29,6 +29,7 @@ import 'package:diplomaticquarterapp/widgets/pharmacy/bottom_nav_pharmacy_bar.da import 'package:diplomaticquarterapp/widgets/progress_indicator/app_loader_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; @@ -75,7 +76,7 @@ class AppScaffold extends StatefulWidget { final int? dropdownIndexValue; List? dropDownList; final void Function(int?)? dropDownIndexChange; - VoidCallbackAction()? onTap; + VoidCallbackAction? onTap; final bool isMainPharmacyPages; final bool extendBody; final ValueChanged? changeCurrentTab;