diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index 7b22836..fed6081 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -92,7 +92,6 @@ class AppState { final PostParamsModel _postParamsInitConfig = PostParamsModel(channel: 31, versionID: 8.2, mobileType: Platform.isAndroid ? "android" : "ios"); - void setPostParamsInitConfig() { isAuthenticated = false; isLogged = false; @@ -194,4 +193,8 @@ class AppState { } bool cancelRequestTrancsection = true; + + bool isDisclosureEnabled = true; + + set setIsDisclosureEnabled(v) => isDisclosureEnabled = v; } diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index f9c756d..4bd447e 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -471,6 +471,8 @@ class _DashboardScreenState extends State with WidgetsBindingOb ? const OffersShimmerWidget() : InkWell( onTap: () { + if (AppState().isDisclosureEnabled) return; + navigateToDetails(data.getOffersList[index]); }, child: SizedBox( @@ -488,18 +490,33 @@ class _DashboardScreenState extends State with WidgetsBindingOb ), border: Border.all(color: MyColors.lightGreyE3Color, width: 1), ), - child: ClipRRect( - borderRadius: const BorderRadius.all( - Radius.circular(50), - ), - child: Hero( - tag: "ItemImage" + data.getOffersList[index].offersDiscountId.toString()!, - transitionOnUserGestures: true, - child: Image.network( - data.getOffersList[index].logo ?? "", - fit: BoxFit.contain, + child: Stack( + fit: StackFit.expand, + children: [ + ClipRRect( + borderRadius: const BorderRadius.all(Radius.circular(50)), + child: Hero( + tag: "ItemImage" + data.getOffersList[index].offersDiscountId.toString()!, + transitionOnUserGestures: true, + child: Image.network( + data.getOffersList[index].logo ?? "", + fit: BoxFit.contain, + ), + ), ), - ), + if (AppState().isDisclosureEnabled) ...[ + Container( + width: double.infinity, + height: double.infinity, + decoration: BoxDecoration(borderRadius: BorderRadius.circular(100), color: Colors.grey.withOpacity(0.6)), + child: const Icon( + Icons.lock_outline, + color: MyColors.grey57Color, + size: 40, + ), + ), + ] + ], ), ), 4.height, @@ -601,7 +618,7 @@ class _DashboardScreenState extends State with WidgetsBindingOb BottomNavigationBarItem( icon: SvgPicture.asset( "assets/icons/create_req.svg", - color: currentIndex == 1 ? MyColors.grey3AColor : MyColors.grey98Color, + color: AppState().isDisclosureEnabled ? MyColors.greyC4Color : (currentIndex == 1 ? MyColors.grey3AColor : MyColors.grey98Color), ).paddingAll(4), label: LocaleKeys.mowadhafhiRequest.tr(), ), @@ -611,7 +628,7 @@ class _DashboardScreenState extends State with WidgetsBindingOb children: [ SvgPicture.asset( "assets/icons/work_list.svg", - color: currentIndex == 2 ? MyColors.grey3AColor : MyColors.grey98Color, + color: AppState().isDisclosureEnabled ? MyColors.greyC4Color : (currentIndex == 2 ? MyColors.grey3AColor : MyColors.grey98Color), ).paddingAll(4), Consumer( builder: (BuildContext cxt, DashboardProviderModel data, Widget? child) { @@ -637,7 +654,7 @@ class _DashboardScreenState extends State with WidgetsBindingOb BottomNavigationBarItem( icon: SvgPicture.asset( "assets/icons/item_for_sale.svg", - color: currentIndex == 3 ? MyColors.grey3AColor : MyColors.grey98Color, + color: AppState().isDisclosureEnabled ? MyColors.greyC4Color : (currentIndex == 3 ? MyColors.grey3AColor : MyColors.grey98Color), ).paddingAll(4), label: LocaleKeys.itemsForSale.tr(), ), @@ -647,13 +664,15 @@ class _DashboardScreenState extends State with WidgetsBindingOb children: [ SvgPicture.asset( "assets/icons/chat/chat.svg", - color: !checkIfPrivilegedForChat() - ? MyColors.lightGreyE3Color - : currentIndex == 4 - ? MyColors.grey3AColor - : cProvider.disbaleChatForThisUser - ? MyColors.lightGreyE3Color - : MyColors.grey98Color, + color: AppState().isDisclosureEnabled + ? MyColors.greyC4Color + : (!checkIfPrivilegedForChat() + ? MyColors.lightGreyE3Color + : currentIndex == 4 + ? MyColors.grey3AColor + : cProvider.disbaleChatForThisUser + ? MyColors.lightGreyE3Color + : MyColors.grey98Color), ).paddingAll(4), Consumer( builder: (BuildContext cxt, ChatProviderModel data, Widget? child) { @@ -681,10 +700,14 @@ class _DashboardScreenState extends State with WidgetsBindingOb unselectedLabelStyle: const TextStyle(fontSize: 10, color: MyColors.grey98Color, fontWeight: FontWeight.w600), type: BottomNavigationBarType.fixed, selectedItemColor: MyColors.grey3AColor, + unselectedItemColor: AppState().isDisclosureEnabled ? MyColors.greyC4Color : null, backgroundColor: MyColors.backgroundColor, selectedIconTheme: const IconThemeData(color: MyColors.grey3AColor, size: 28), unselectedIconTheme: const IconThemeData(color: MyColors.grey98Color, size: 28), onTap: (int index) { + if (AppState().isDisclosureEnabled) { + return; + } if (index == 1) { Navigator.pushNamed(context, AppRoutes.mowadhafhi); } else if (index == 2) { diff --git a/lib/ui/landing/widget/menus_widget.dart b/lib/ui/landing/widget/menus_widget.dart index 64855ee..2f26205 100644 --- a/lib/ui/landing/widget/menus_widget.dart +++ b/lib/ui/landing/widget/menus_widget.dart @@ -2,6 +2,7 @@ import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; @@ -14,6 +15,16 @@ import 'package:provider/provider.dart'; class MenusWidget extends StatelessWidget { @override Widget build(BuildContext context) { + Widget disabledWidget = Container( + width: double.infinity, + height: double.infinity, + decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: Colors.grey.withOpacity(0.6)), + child: const Icon( + Icons.lock_outline, + color: MyColors.grey57Color, + size: 40, + ), + ); List namesColor = [0xff125765, 0xff239D8F, 0xff2BB8A8, 0xff1D92AA]; return Consumer( @@ -29,109 +40,141 @@ class MenusWidget extends StatelessWidget { ? MenuShimmer().onPress(() { data.fetchWorkListCounter(context, showLoading: true); }) - : Container( - decoration: BoxDecoration( - color: Color(namesColor[0]), - borderRadius: BorderRadius.circular(10), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - LocaleKeys.workList.tr().toText12(color: Colors.white), - Row( + : Stack( + children: [ + Container( + decoration: BoxDecoration( + color: Color(namesColor[0]), + borderRadius: BorderRadius.circular(10), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: data.workListCounter.toString().toText16(color: Colors.white, isBold: true, maxlines: 1), - ), - RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)), + LocaleKeys.workList.tr().toText12(color: Colors.white), + Row( + children: [ + Expanded( + child: data.workListCounter.toString().toText16(color: Colors.white, isBold: true, maxlines: 1), + ), + RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)), + ], + ) ], - ) - ], - ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ), + if (AppState().isDisclosureEnabled) ...[disabledWidget] + ], ).onPress(() { + if (AppState().isDisclosureEnabled) { + return; + } Navigator.pushNamed(context, AppRoutes.workList); }), data.isMissingSwipeLoading ? MenuShimmer().onPress(() { data.fetchWorkListCounter(context); }) - : Container( - decoration: BoxDecoration( - color: Color(namesColor[1]), - borderRadius: BorderRadius.circular(10), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - LocaleKeys.missingSwipes.tr().toText12(color: Colors.white), - Row( + : Stack( + children: [ + Container( + decoration: BoxDecoration( + color: Color(namesColor[1]), + borderRadius: BorderRadius.circular(10), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: data.missingSwipeCounter.toString().toText16(color: Colors.white, isBold: true, maxlines: 1), - ), - RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)), + LocaleKeys.missingSwipes.tr().toText12(color: Colors.white), + Row( + children: [ + Expanded( + child: data.missingSwipeCounter.toString().toText16(color: Colors.white, isBold: true, maxlines: 1), + ), + RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)), + ], + ) ], - ) - ], - ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ), + if (AppState().isDisclosureEnabled) ...[disabledWidget] + ], ).onPress(() { + if (AppState().isDisclosureEnabled) { + return; + } Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(LocaleKeys.missingSwipes.tr(), "HMG_OTL_MISSING_SWIPE_EIT_SS")); }), data.isLeaveTicketBalanceLoading ? MenuShimmer().onPress(() { data.fetchWorkListCounter(context); }) - : Container( - decoration: BoxDecoration( - color: Color(namesColor[2]), - borderRadius: BorderRadius.circular(10), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - LocaleKeys.leaveBalance.tr().toText12(color: Colors.white), - Row( + : Stack( + children: [ + Container( + decoration: BoxDecoration( + color: Color(namesColor[2]), + borderRadius: BorderRadius.circular(10), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: data.leaveBalance.toStringAsFixed(2).toText16(color: Colors.white, isBold: true, maxlines: 1), - ), - RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)), + LocaleKeys.leaveBalance.tr().toText12(color: Colors.white), + Row( + children: [ + Expanded( + child: data.leaveBalance.toStringAsFixed(2).toText16(color: Colors.white, isBold: true, maxlines: 1), + ), + RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)), + ], + ) ], - ) - ], - ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ), + if (AppState().isDisclosureEnabled) ...[disabledWidget] + ], ).onPress(() { + if (AppState().isDisclosureEnabled) { + return; + } Navigator.pushNamed(context, AppRoutes.leaveBalance); }), data.isLeaveTicketBalanceLoading ? MenuShimmer().onPress(() { data.fetchWorkListCounter(context); }) - : Container( - decoration: BoxDecoration( - color: Color(namesColor[3]), - borderRadius: BorderRadius.circular(10), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - LocaleKeys.ticketBalance.tr().toText12(color: Colors.white), - Row( + : Stack( + children: [ + Container( + decoration: BoxDecoration( + color: Color(namesColor[3]), + borderRadius: BorderRadius.circular(10), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: data.ticketBalance.toStringAsFixed(2).toText16(color: Colors.white, isBold: true, maxlines: 1), - ), - RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)), + LocaleKeys.ticketBalance.tr().toText12(color: Colors.white), + Row( + children: [ + Expanded( + child: data.ticketBalance.toStringAsFixed(2).toText16(color: Colors.white, isBold: true, maxlines: 1), + ), + RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg", color: Colors.white)), + ], + ) ], - ) - ], - ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ).paddingOnly(left: 10, right: 10, bottom: 6, top: 6), + ), + if (AppState().isDisclosureEnabled) ...[disabledWidget] + ], ).onPress( () { + if (AppState().isDisclosureEnabled) { + return; + } Navigator.pushNamed(context, AppRoutes.dynamicScreen, arguments: DynamicListViewParams(LocaleKeys.ticketBalance.tr(), "HMG_TKT_NEW_EIT_SS")); }, ) diff --git a/lib/ui/landing/widget/services_widget.dart b/lib/ui/landing/widget/services_widget.dart index 7c19b58..fd991b1 100644 --- a/lib/ui/landing/widget/services_widget.dart +++ b/lib/ui/landing/widget/services_widget.dart @@ -1,7 +1,10 @@ +import 'dart:developer'; + import 'package:easy_localization/src/public_ext.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; +import 'package:mohem_flutter_app/classes/colors.dart'; import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; @@ -49,41 +52,59 @@ class ServicesWidget extends StatelessWidget { padding: const EdgeInsets.only(left: 21, right: 21, top: 13, bottom: 13), scrollDirection: Axis.horizontal, itemBuilder: (cxt, index) { + log("data.homeMenus![parentIndex].menuEntiesList[index].prompt: ${data.homeMenus![parentIndex].menuEntiesList[index].prompt}"); return AspectRatio( aspectRatio: 105 / 105, child: data.isServicesMenusLoading ? ServicesMenuShimmer() - : Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(15), - boxShadow: [ - BoxShadow( - color: const Color(0xff000000).withOpacity(.05), - blurRadius: 26, - offset: const Offset(0, -3), + : Stack( + children: [ + Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(15), + boxShadow: [ + BoxShadow( + color: const Color(0xff000000).withOpacity(.05), + blurRadius: 26, + offset: const Offset(0, -3), + ), + ], ), - ], - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SvgPicture.asset(AppState().isArabic(context) - ? getMenuIconAr(data.homeMenus![parentIndex].menuEntiesList[index].prompt!) - : getMenuIconEn(data.homeMenus![parentIndex].menuEntiesList[index].prompt!)), - Row( - crossAxisAlignment: CrossAxisAlignment.end, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - child: data.homeMenus![parentIndex].menuEntiesList[index].prompt!.toText11(isBold: true), - ), - RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4)), + SvgPicture.asset(AppState().isArabic(context) ? getMenuIconAr(data.homeMenus![parentIndex].menuEntiesList[index].prompt!) : getMenuIconEn(data.homeMenus![parentIndex].menuEntiesList[index].prompt!)), + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: data.homeMenus![parentIndex].menuEntiesList[index].prompt!.toText11(isBold: true), + ), + RotatedBox(quarterTurns: AppState().isArabic(context) ? 2 : 4, child: SvgPicture.asset("assets/images/arrow_next.svg").paddingOnly(bottom: 4)), + ], + ) ], - ) - ], - ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), + ).paddingOnly(left: 10, right: 10, bottom: 10, top: 12), + ), + if (AppState().isDisclosureEnabled && (parentIndex == 0 && index != 0) || (parentIndex > 0)) ...[ + Container( + width: double.infinity, + height: double.infinity, + decoration: BoxDecoration(borderRadius: BorderRadius.circular(15), color: Colors.grey.withOpacity(0.6)), + child: const Icon( + Icons.lock_outline, + color: MyColors.grey57Color, + size: 40, + ), + ), + ] + ], ).onPress(() { + if (AppState().isDisclosureEnabled && (parentIndex == 0 && index != 0) || (parentIndex > 0)) { + return; + } handleOnPress(context, data.homeMenus![parentIndex].menuEntiesList[index]); }), ); @@ -220,8 +241,7 @@ class ServicesWidget extends StatelessWidget { Navigator.pushNamed(context, AppRoutes.monthlyPaySlip); } } else { - List _menuList = - pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION" || element.menuEntryType == "MENU")).toList() ?? []; + List _menuList = pro.getMenuEntriesList?.where((element) => element.parentMenuName == menuEntry.menuName && (element.menuEntryType == "FUNCTION" || element.menuEntryType == "MENU")).toList() ?? []; Navigator.pushNamed(context, AppRoutes.servicesMenuListScreen, arguments: ServicesMenuListScreenParams(menuEntry.prompt!, _menuList.isEmpty ? menuList : _menuList)); } return;