From 52438ce711821197727ea2c1bfa9cf43ae0f28da Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 29 Aug 2022 09:59:56 +0300 Subject: [PATCH] offers & discounts implemented --- lib/provider/dashboard_provider_model.dart | 2 + lib/ui/landing/dashboard_screen.dart | 108 +++++++++++---------- 2 files changed, 58 insertions(+), 52 deletions(-) diff --git a/lib/provider/dashboard_provider_model.dart b/lib/provider/dashboard_provider_model.dart index ddb245d..289ab33 100644 --- a/lib/provider/dashboard_provider_model.dart +++ b/lib/provider/dashboard_provider_model.dart @@ -44,6 +44,7 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { List? getMenuEntriesList; //Offers And Discounts + bool isOffersLoading = true; List getOffersList = []; //Attendance Tracking API's & Methods @@ -184,6 +185,7 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { try { // Utils.showLoading(context); getOffersList = await OffersAndDiscountsApiClient().getOffersList(0, 6); + isOffersLoading = false; notifyListeners(); } catch (ex) { // Utils.hideLoading(context); diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 4d2cc38..3630660 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -277,61 +277,65 @@ class _DashboardScreenState extends State { child: LocaleKeys.viewAllOffers.tr().toText12(isUnderLine: true)), ], ).paddingOnly(left: 21, right: 21), - SizedBox( - height: 103 + 33, - child: ListView.separated( - shrinkWrap: true, - physics: const BouncingScrollPhysics(), - padding: const EdgeInsets.only(left: 21, right: 21, top: 13), - scrollDirection: Axis.horizontal, - itemBuilder: (cxt, index) { - return data.getOffersList.isNotEmpty - ? InkWell( - onTap: () { - navigateToDetails(data.getOffersList[index]); - }, - child: SizedBox( - width: 73, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - width: 73, - height: 73, - decoration: BoxDecoration( - borderRadius: const BorderRadius.all( - Radius.circular(100), - ), - border: Border.all(color: MyColors.lightGreyEDColor, width: 1), - ), - child: ClipRRect( - borderRadius: const BorderRadius.all( - Radius.circular(50), - ), - child: Hero( - tag: "ItemImage" + data.getOffersList[index].rowID!, - transitionOnUserGestures: true, - child: Image.network( - data.getOffersList[index].bannerImage!, - fit: BoxFit.contain, + Consumer( + builder: (context, model, child) { + return SizedBox( + height: 103 + 33, + child: ListView.separated( + shrinkWrap: true, + physics: const BouncingScrollPhysics(), + padding: const EdgeInsets.only(left: 21, right: 21, top: 13), + scrollDirection: Axis.horizontal, + itemBuilder: (cxt, index) { + return model.isOffersLoading + ? const OffersShimmerWidget() + : InkWell( + onTap: () { + navigateToDetails(data.getOffersList[index]); + }, + child: SizedBox( + width: 73, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: 73, + height: 73, + decoration: BoxDecoration( + borderRadius: const BorderRadius.all( + Radius.circular(100), + ), + border: Border.all(color: MyColors.lightGreyEDColor, width: 1), + ), + child: ClipRRect( + borderRadius: const BorderRadius.all( + Radius.circular(50), + ), + child: Hero( + tag: "ItemImage" + data.getOffersList[index].rowID!, + transitionOnUserGestures: true, + child: Image.network( + data.getOffersList[index].bannerImage!, + fit: BoxFit.contain, + ), + ), ), ), - ), - ), - 4.height, - Expanded( - child: AppState().isArabic(context) - ? data.getOffersList[index].titleAR!.toText12(isCenter: true, maxLine: 1) - : data.getOffersList[index].title!.toText12(isCenter: true, maxLine: 1), + 4.height, + Expanded( + child: AppState().isArabic(context) + ? data.getOffersList[index].titleAR!.toText12(isCenter: true, maxLine: 1) + : data.getOffersList[index].title!.toText12(isCenter: true, maxLine: 1), + ), + ], ), - ], - ), - ), - ) - : const OffersShimmerWidget(); - }, - separatorBuilder: (cxt, index) => 8.width, - itemCount: 6), + ), + ); + }, + separatorBuilder: (cxt, index) => 8.width, + itemCount: 6), + ); + }, ), ], ),