From 676e662967bf7c3d37b70d648a8c1a7534692cea Mon Sep 17 00:00:00 2001 From: aamir-csol Date: Thu, 23 Oct 2025 09:09:23 +0300 Subject: [PATCH] Survey title key fix --- lib/api/api_client.dart | 71 ++-- lib/classes/consts.dart | 17 +- lib/classes/utils.dart | 13 + lib/ui/landing/dashboard_screen.dart | 316 ++++++++++++------ lib/ui/landing/widget/app_drawer.dart | 124 +++---- .../offers_and_discounts_home.dart | 2 +- 6 files changed, 339 insertions(+), 204 deletions(-) diff --git a/lib/api/api_client.dart b/lib/api/api_client.dart index fb415d4..74a12c8 100644 --- a/lib/api/api_client.dart +++ b/lib/api/api_client.dart @@ -2,10 +2,13 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:http/http.dart'; import 'package:http/io_client.dart'; import 'package:mohem_flutter_app/app_state/app_state.dart'; +import 'package:mohem_flutter_app/classes/utils.dart'; +import 'package:mohem_flutter_app/config/routes.dart'; import 'package:mohem_flutter_app/exceptions/api_exception.dart'; import 'package:mohem_flutter_app/main.dart'; // ignore_for_file: avoid_annotating_with_dynamic @@ -13,18 +16,14 @@ import 'package:mohem_flutter_app/main.dart'; typedef FactoryConstructor = U Function(dynamic); class APIError { - int? errorCode; + dynamic errorCode; int? errorType; String? errorMessage; - int? errorStatusCode; + int? errorStatusCode; + APIError(this.errorCode, this.errorMessage, this.errorType, this.errorStatusCode); - Map toJson() => { - 'errorCode': errorCode, - 'errorMessage': errorMessage, - 'errorType': errorType, - 'ErrorStatusCode': errorStatusCode - }; + Map toJson() => {'errorCode': errorCode, 'errorMessage': errorMessage, 'errorType': errorType, 'ErrorStatusCode': errorStatusCode}; @override String toString() { @@ -46,22 +45,22 @@ APIException _throwAPIException(Response response) { APIError? apiError; if (response.body != null && response.body.isNotEmpty) { var jsonError = jsonDecode(response.body); - apiError = APIError(jsonError['ErrorCode'], jsonError['ErrorMessage'], jsonError['ErrorType'],jsonError['ErrorStatusCode']); + apiError = APIError(jsonError['ErrorCode'], jsonError['ErrorMessage'], jsonError['ErrorType'], jsonError['ErrorStatusCode']); } return APIException(APIException.BAD_REQUEST, error: apiError); case 401: - return APIException(APIException.UNAUTHORIZED); + return const APIException(APIException.UNAUTHORIZED); case 403: - return APIException(APIException.FORBIDDEN); + return const APIException(APIException.FORBIDDEN); case 404: - return APIException(APIException.NOT_FOUND); + return const APIException(APIException.NOT_FOUND); case 500: - return APIException(APIException.INTERNAL_SERVER_ERROR); + return const APIException(APIException.INTERNAL_SERVER_ERROR); case 444: var downloadUrl = response.headers["location"]; return APIException(APIException.UPGRADE_REQUIRED, arguments: downloadUrl); default: - return APIException(APIException.OTHER); + return const APIException(APIException.OTHER); } } @@ -72,8 +71,16 @@ class ApiClient { factory ApiClient() => _instance; - Future postJsonForObject(FactoryConstructor factoryConstructor, String url, T jsonObject, - {String? token, Map? queryParameters, Map? headers, int retryTimes = 0, bool isFormData = false}) async { + Future postJsonForObject( + FactoryConstructor factoryConstructor, + String url, + T jsonObject, { + String? token, + Map? queryParameters, + Map? headers, + int retryTimes = 0, + bool isFormData = false, + }) async { var _headers = {'Accept': 'application/json'}; if (headers != null && headers.isNotEmpty) { _headers.addAll(headers); @@ -102,6 +109,9 @@ class ApiClient { if (jsonData["ErrorMessage"] == null) { return factoryConstructor(jsonData); + } else if (jsonData["MessageStatus"] == 2 && jsonData["IsOTPMaxLimitExceed"] == true) { + await Utils.performLogout(AppRoutes.navigatorKey.currentContext, null); + throw const APIException(APIException.UNAUTHORIZED, error: null); } else { APIError? apiError; apiError = APIError(jsonData['ErrorCode'], jsonData['ErrorEndUserMessage'], jsonData['ErrorType'] ?? 0, jsonData['ErrorStatusCode']); @@ -116,8 +126,15 @@ class ApiClient { } } - Future postJsonForResponse(String url, T jsonObject, - {String? token, Map? queryParameters, Map? headers, int retryTimes = 0, bool isFormData = false}) async { + Future postJsonForResponse( + String url, + T jsonObject, { + String? token, + Map? queryParameters, + Map? headers, + int retryTimes = 0, + bool isFormData = false, + }) async { String? requestBody; late Map stringObj; if (jsonObject != null) { @@ -152,9 +169,9 @@ class ApiClient { var queryString = new Uri(queryParameters: queryParameters).query; url = url + '?' + queryString; } - var response = await _post(Uri.parse(url), body: requestBody, headers: _headers).timeout(Duration(seconds: 120)); + var response = await _post(Uri.parse(url), body: requestBody, headers: _headers).timeout(const Duration(seconds: 120)); - if (response. statusCode >= 200 && response.statusCode < 300) { + if (response.statusCode >= 200 && response.statusCode < 300) { return response; } else { throw _throwAPIException(response); @@ -162,7 +179,7 @@ class ApiClient { } on SocketException catch (e) { if (retryTimes > 0) { print('will retry after 3 seconds...'); - await Future.delayed(Duration(seconds: 3)); + await Future.delayed(const Duration(seconds: 3)); return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1); } else { throw APIException(APIException.OTHER, arguments: e); @@ -170,7 +187,7 @@ class ApiClient { } on HttpException catch (e) { if (retryTimes > 0) { print('will retry after 3 seconds...'); - await Future.delayed(Duration(seconds: 3)); + await Future.delayed(const Duration(seconds: 3)); return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1); } else { throw APIException(APIException.OTHER, arguments: e); @@ -180,7 +197,7 @@ class ApiClient { } on ClientException catch (e) { if (retryTimes > 0) { print('will retry after 3 seconds...'); - await Future.delayed(Duration(seconds: 3)); + await Future.delayed(const Duration(seconds: 3)); return await _postForResponse(url, requestBody, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1); } else { throw APIException(APIException.OTHER, arguments: e); @@ -219,7 +236,7 @@ class ApiClient { var queryString = new Uri(queryParameters: queryParameters).query; url = url + '?' + queryString; } - var response = await _get(Uri.parse(url), headers: _headers).timeout(Duration(seconds: 60)); + var response = await _get(Uri.parse(url), headers: _headers).timeout(const Duration(seconds: 60)); if (response.statusCode >= 200 && response.statusCode < 300) { return response; @@ -229,7 +246,7 @@ class ApiClient { } on SocketException catch (e) { if (retryTimes > 0) { print('will retry after 3 seconds...'); - await Future.delayed(Duration(seconds: 3)); + await Future.delayed(const Duration(seconds: 3)); return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1); } else { throw APIException(APIException.OTHER, arguments: e); @@ -237,7 +254,7 @@ class ApiClient { } on HttpException catch (e) { if (retryTimes > 0) { print('will retry after 3 seconds...'); - await Future.delayed(Duration(seconds: 3)); + await Future.delayed(const Duration(seconds: 3)); return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1); } else { throw APIException(APIException.OTHER, arguments: e); @@ -247,7 +264,7 @@ class ApiClient { } on ClientException catch (e) { if (retryTimes > 0) { print('will retry after 3 seconds...'); - await Future.delayed(Duration(seconds: 3)); + await Future.delayed(const Duration(seconds: 3)); return await _getForResponse(url, token: token, queryParameters: queryParameters, headers: headers, retryTimes: retryTimes - 1); } else { throw APIException(APIException.OTHER, arguments: e); diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index 6b43bbd..e1ad116 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -5,17 +5,17 @@ class ApiConsts { // static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver - // static String baseUrl = "http://10.201.204.101:2024"; - // static String baseUrl = "https://webservices.hmg.com"; // PreProd - // static String baseUrl = "https://hmgwebservices.com"; // Live server + // static String baseUrl = "http://10.201.204.101:2024"; + // static String baseUrl = "https://webservices.hmg.com"; // PreProd + // static String baseUrl = "https://hmgwebservices.com"; // Live server // static String baseUrl = "https://mohemm.hmg.com"; // New Live server // - // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver - // static String baseUrl = "http://10.20.200.111:1010/"; + static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver + // static String baseUrl = "http://10.20.200.111:1010/"; - // static String baseUrl = "https://webservices.hmg.com"; // PreProd - static String baseUrl = "https://mohemm.hmg.com"; + // static String baseUrl = "https://webservices.hmg.com"; // PreProd + // static String baseUrl = "https://mohemm.hmg.com"; // static String baseUrl = "https://hmgwebservices.com"; // Live server static String baseUrlServices = baseUrl + "/Services/"; // server @@ -55,6 +55,7 @@ class ApiConsts { static String marathonBaseUrlUAT = "https://marathoon.com/uatservice/api/"; static String marathonBaseUrl = marathonBaseUrlLive; + // static String marathonBaseUrl = marathonBaseUrlUAT; static String marathonBaseUrlServices = "https://marathoon.com/service/"; static String marathonParticipantLoginUrl = marathonBaseUrl + "auth/participantlogin"; @@ -86,5 +87,3 @@ class SharedPrefsConsts { static String mohemmWifiPassword = "mohemmWifiPassword"; static String editItemForSale = "editItemForSale"; } - - diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index 0245bbf..6a9b16b 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -16,6 +16,7 @@ import 'package:mohem_flutter_app/extensions/int_extensions.dart'; import 'package:mohem_flutter_app/extensions/string_extensions.dart'; import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; +import 'package:mohem_flutter_app/provider/chat_provider_model.dart'; import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart'; import 'package:mohem_flutter_app/widgets/loading_dialog.dart'; import 'package:nfc_manager/nfc_manager.dart'; @@ -386,4 +387,16 @@ class Utils { return false; } } + + static Future performLogout(BuildContext? context, ChatProviderModel? chatData) async { + AppState().isAuthenticated = false; + AppState().isLogged = false; + AppState().setPostParamsInitConfig(); + if (chatData != null) { + chatData.disposeData(); + } + // SharedPreferences prefs = await SharedPreferences.getInstance(); + // await prefs.clear(); + Navigator.pushNamedAndRemoveUntil(context!, AppRoutes.login, (Route route) => false, arguments: null); + } } diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index 1422fb2..a973aae 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -56,6 +56,8 @@ class _DashboardScreenState extends State with WidgetsBindingOb int currentIndex = 0; + bool isDisplayMazaya = false; + @override void initState() { WidgetsBinding.instance.addObserver(this); @@ -153,7 +155,7 @@ class _DashboardScreenState extends State with WidgetsBindingOb data.fetchLeaveTicketBalance(context, DateTime.now()); data.fetchMenuEntries(); data.fetchEventActivity(); - // data.getCategoryOffersListAPI(context); + data.getCategoryOffersListAPI(context); marathonProvider.getMarathonDetailsFromApi(); marathonProvider.getMarathonTutorial(); if (isFromInit) { @@ -421,116 +423,231 @@ class _DashboardScreenState extends State with WidgetsBindingOb ], ).paddingOnly(left: 21, right: 21, top: 7, bottom: 21), eventActivityWidget(context), + + if (isDisplayMazaya) ...[ + Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Directionality( + textDirection: AppState().isArabic(context) ? ui.TextDirection.rtl : ui.TextDirection.ltr, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + gradient: const LinearGradient(colors: [Color(0xFF91C481), Color(0xFF7CCED7)], begin: Alignment.centerLeft, end: Alignment.centerRight), + ), + child: Padding( + padding: const EdgeInsets.all(3.0), // This creates the border width + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(17), // Slightly less than outer radius + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 4, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + flex: 2, + child: RichText( + text: + AppState().isArabic(context) + ? TextSpan( + children: [ + TextSpan( + text: 'اطلع على مميزات', + style: TextStyle( + fontSize: 16, + letterSpacing: -0.2, + fontFamily: AppState().isArabic(context) ? 'Cairo' : 'Poppins', + fontWeight: FontWeight.w700, + height: 24 / 16, + color: Color(0xFF5D5E5E), + ), + ), + TextSpan( + text: ' مزايا', + style: TextStyle( + fontSize: 16, + fontFamily: AppState().isArabic(context) ? 'Cairo' : 'Poppins', + fontWeight: FontWeight.w700, + letterSpacing: -0.2, + height: 24 / 16, + color: MyColors.mazayaRedColor, // Use your MAZAYA red color here if defined, e.g. MyColors.mazayaRed + ), + ), + ], + ) + : TextSpan( + children: [ + TextSpan( + text: LocaleKeys.explore.tr() + ' ', + style: const TextStyle( + fontSize: 16, + letterSpacing: -0.2, + fontFamily: 'Poppins', + fontWeight: FontWeight.w700, + height: 24 / 16, + color: Color(0xFF5D5E5E), + ), + ), + TextSpan( + text: LocaleKeys.mazaya.tr(), + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w700, + fontFamily: 'Poppins', + letterSpacing: -0.2, + height: 24 / 16, + color: MyColors.mazayaRedColor, // Use your MAZAYA red color here if defined, e.g. MyColors.mazayaRed + ), + ), + TextSpan( + text: ' ' + LocaleKeys.benefits.tr(), + style: const TextStyle( + fontSize: 16, + letterSpacing: -0.2, + fontFamily: 'Poppins', + fontWeight: FontWeight.w700, + height: 24 / 16, + color: Color(0xFF5D5E5E), + ), + ), + ], + ), + ), + ), + const Expanded(flex: 1, child: SizedBox()), + ], + ), + const SizedBox(height: 8), + LocaleKeys.mazayaDesc.tr().toText11(color: const Color(0xFF5D5E5E)), + ], + ), + ), + Expanded( + flex: 2, + child: Column( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + SvgPicture.asset("assets/icons/mazaya_brand.svg", width: 90, height: 47), + const SizedBox(height: 28), + LocaleKeys.viewallofferMazaya.tr().toText12(isUnderLine: true, color: const Color(0xFF3B3D4A)).onPress(() { + Navigator.pushNamed(context, AppRoutes.offersAndDiscounts); + }), + ], + ), + ), + ], + ).paddingOnly(left: 21, right: 21, top: 14, bottom: 14), + ), + ), + ).paddingOnly(left: 21, right: 21, top: 0, bottom: 21), + ), + ], + ), + ], + Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Directionality( - textDirection: AppState().isArabic(context) ? ui.TextDirection.rtl : ui.TextDirection.ltr, - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20), - gradient: const LinearGradient(colors: [Color(0xFF91C481), Color(0xFF7CCED7)], begin: Alignment.centerLeft, end: Alignment.centerRight), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + LocaleKeys.offers.tr().toText12(), + Row( + children: [ + LocaleKeys.discounts.tr().toText24(isBold: true), + 6.width, + Container( + padding: const EdgeInsets.only(left: 8, right: 8), + decoration: BoxDecoration(color: MyColors.yellowColor, borderRadius: BorderRadius.circular(10)), + child: LocaleKeys.newString.tr().toText10(isBold: true), + ), + ], + ), + ], + ), ), - child: Padding( - padding: const EdgeInsets.all(3.0), // This creates the border width - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(17), // Slightly less than outer radius - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 4, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Row( + LocaleKeys.viewAllOffers.tr().toText12(isUnderLine: true).onPress(() { + Navigator.pushNamed(context, AppRoutes.offersAndDiscounts); + }), + ], + ).paddingOnly(left: 21, right: 21), + Consumer( + builder: (BuildContext context, DashboardProviderModel model, Widget? 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: (BuildContext cxt, int index) { + return model.isOffersLoading + ? const OffersShimmerWidget() + : InkWell( + onTap: () { + navigateToDetails(data.getOffersList[index]); + }, + child: SizedBox( + width: 73, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, children: [ - Expanded( - flex: 2, - child: RichText( - text: - AppState().isArabic(context) - ? TextSpan( - children: [ - TextSpan( - text: 'اطلع على مميزات', - style: TextStyle(fontSize: 16, letterSpacing: -0.2, fontFamily: AppState().isArabic(context) ? 'Cairo' : 'Poppins', fontWeight: FontWeight.w700, height: 24 / 16, color: Color(0xFF5D5E5E)), - ), - TextSpan( - text: ' مزايا', - style: TextStyle( - fontSize: 16, - fontFamily: AppState().isArabic(context) ? 'Cairo' : 'Poppins', - fontWeight: FontWeight.w700, - letterSpacing: -0.2, - height: 24 / 16, - color: MyColors.mazayaRedColor, // Use your MAZAYA red color here if defined, e.g. MyColors.mazayaRed - ), - ), - ], - ) - : TextSpan( - children: [ - TextSpan( - text: LocaleKeys.explore.tr() + ' ', - style: const TextStyle(fontSize: 16, letterSpacing: -0.2, fontFamily: 'Poppins', fontWeight: FontWeight.w700, height: 24 / 16, color: Color(0xFF5D5E5E)), - ), - TextSpan( - text: LocaleKeys.mazaya.tr(), - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.w700, - fontFamily: 'Poppins', - letterSpacing: -0.2, - height: 24 / 16, - color: MyColors.mazayaRedColor, // Use your MAZAYA red color here if defined, e.g. MyColors.mazayaRed - ), - ), - TextSpan( - text: ' ' + LocaleKeys.benefits.tr(), - style: const TextStyle(fontSize: 16, letterSpacing: -0.2, - fontFamily: 'Poppins',fontWeight: FontWeight.w700, height: 24 / 16, color: Color(0xFF5D5E5E)), - ), - ], - ), + Container( + width: 73, + height: 73, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: const BorderRadius.all(Radius.circular(100)), + 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), + ), + ), + ), + 4.height, + Expanded( + child: + AppState().isArabic(context) + ? data.getOffersList[index].titleAr!.toText12(isCenter: true, maxLine: 1) + : data.getOffersList[index].titleEn!.toText12(isCenter: true, maxLine: 1), ), - const Expanded(flex: 1, child: SizedBox()), ], ), - const SizedBox(height: 8), - LocaleKeys.mazayaDesc.tr().toText11(color: const Color(0xFF5D5E5E)), - ], - ), - ), - Expanded( - flex: 2, - child: Column( - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisAlignment: MainAxisAlignment.end, - children: [ - SvgPicture.asset("assets/icons/mazaya_brand.svg", width: 90, height: 47), - const SizedBox(height: 28), - LocaleKeys.viewallofferMazaya.tr().toText12(isUnderLine: true, color: const Color(0xFF3B3D4A)).onPress(() { - Navigator.pushNamed(context, AppRoutes.offersAndDiscounts); - }), - ], - ), - ), - ], - ).paddingOnly(left: 21, right: 21, top: 14, bottom: 14), + ), + ); + }, + separatorBuilder: (BuildContext cxt, int index) => 8.width, + itemCount: 9, ), - ), - ).paddingOnly(left: 21, right: 21, top: 0, bottom: 21), + ); + }, ), ], ), + Container( width: double.infinity, padding: const EdgeInsets.only(top: 31), @@ -602,7 +719,10 @@ class _DashboardScreenState extends State with WidgetsBindingOb height: Platform.isAndroid ? 70 : 100, child: BottomNavigationBar( items: [ - BottomNavigationBarItem(icon: SvgPicture.asset("assets/icons/home.svg", color: currentIndex == 0 ? MyColors.grey3AColor : MyColors.grey98Color).paddingAll(4), label: LocaleKeys.home.tr()), + BottomNavigationBarItem( + icon: SvgPicture.asset("assets/icons/home.svg", color: currentIndex == 0 ? MyColors.grey3AColor : MyColors.grey98Color).paddingAll(4), + label: LocaleKeys.home.tr(), + ), BottomNavigationBarItem( icon: SvgPicture.asset("assets/icons/create_req.svg", color: currentIndex == 1 ? MyColors.grey3AColor : MyColors.grey98Color).paddingAll(4), label: LocaleKeys.mowadhafhiRequest.tr(), diff --git a/lib/ui/landing/widget/app_drawer.dart b/lib/ui/landing/widget/app_drawer.dart index 4721470..0eb0e52 100644 --- a/lib/ui/landing/widget/app_drawer.dart +++ b/lib/ui/landing/widget/app_drawer.dart @@ -49,32 +49,18 @@ class _AppDrawerState extends State { children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Image.asset("assets/images/logos/main_mohemm_logo.png", width: 134, height: 24), - const Icon(Icons.clear).onPress(() => Navigator.pop(context)), - ], + children: [Image.asset("assets/images/logos/main_mohemm_logo.png", width: 134, height: 24), const Icon(Icons.clear).onPress(() => Navigator.pop(context))], ).paddingOnly(left: 4, right: 14), Row( children: [ AppState().memberInformationList!.eMPLOYEEIMAGE == null - ? SvgPicture.asset( - "assets/images/user.svg", - height: 52, - width: 52, - ) - : CircleAvatar( - radius: 52 / 2, - backgroundImage: MemoryImage(Utils.dataFromBase64String(AppState().memberInformationList!.eMPLOYEEIMAGE!)), - backgroundColor: Colors.black, - ), + ? SvgPicture.asset("assets/images/user.svg", height: 52, width: 52) + : CircleAvatar(radius: 52 / 2, backgroundImage: MemoryImage(Utils.dataFromBase64String(AppState().memberInformationList!.eMPLOYEEIMAGE!)), backgroundColor: Colors.black), 12.width, Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppState().memberInformationList!.eMPLOYEENAME!.toText18(isBold: true), - AppState().memberInformationList!.getPositionName().toText14(weight: FontWeight.w500), - ], - ).expanded + children: [AppState().memberInformationList!.eMPLOYEENAME!.toText18(isBold: true), AppState().memberInformationList!.getPositionName().toText14(weight: FontWeight.w500)], + ).expanded, ], ).paddingOnly(left: 14, right: 14, top: 21, bottom: 21), // Row( @@ -99,67 +85,77 @@ class _AppDrawerState extends State { // ), // ], // ).paddingOnly(left: 14, right: 14, bottom: 14), - const Divider( - height: 1, - thickness: 1, - color: MyColors.lightGreyEFColor, - ), + const Divider(height: 1, thickness: 1, color: MyColors.lightGreyEFColor), ListView( padding: const EdgeInsets.only(top: 21, bottom: 21), children: [ ListView.builder( - padding: EdgeInsets.zero, - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemCount: drawerMenuItemList.length, - itemBuilder: (cxt, index) { - return menuItem(drawerMenuItemList[index].icon, drawerMenuItemList[index].title, drawerMenuItemList[index].routeName, onPress: () { + padding: EdgeInsets.zero, + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: drawerMenuItemList.length, + itemBuilder: (cxt, index) { + return menuItem( + drawerMenuItemList[index].icon, + drawerMenuItemList[index].title, + drawerMenuItemList[index].routeName, + onPress: () { Navigator.pushNamed(context, drawerMenuItemList[index].routeName); - }); - }), + }, + ); + }, + ), menuItem("assets/images/drawer/employee_id.svg", LocaleKeys.employeeDigitalID.tr(), "", closeDrawer: false, onPress: () => showMDialog(context, child: EmployeeDigitialIdDialog())), if (AppState().businessCardPrivilege) - menuItem("assets/images/drawer/view_business_card.svg", LocaleKeys.viewBusinessCard.tr(), "", closeDrawer: false, onPress: () => showMDialog(context, child: BusinessCardDialog(), isBusniessCard: true)), - menuItem("assets/images/drawer/logout.svg", LocaleKeys.logout.tr(), "", color: MyColors.redA3Color, closeDrawer: false, onPress: performLogout), + menuItem( + "assets/images/drawer/view_business_card.svg", + LocaleKeys.viewBusinessCard.tr(), + "", + closeDrawer: false, + onPress: () => showMDialog(context, child: BusinessCardDialog(), isBusniessCard: true), + ), + menuItem( + "assets/images/drawer/logout.svg", + LocaleKeys.logout.tr(), + "", + color: MyColors.redA3Color, + closeDrawer: false, + onPress: () async { + await Utils.performLogout(context, chatData); + }, + ), // menuItem("assets/images/drawer/logout.svg", LocaleKeys.logout.tr(), "", color: MyColors.redA3Color, closeDrawer: false, onPress: () {Navigator.pushNamed(context, AppRoutes.survey,); ], ).expanded, - const Divider( - height: 1, - thickness: 1, - color: MyColors.lightGreyEFColor, - ), + const Divider(height: 1, thickness: 1, color: MyColors.lightGreyEFColor), Row( children: [ RichText( - text: TextSpan(text: LocaleKeys.poweredBy.tr() + " ", style: const TextStyle(color: MyColors.grey98Color, fontSize: 14, letterSpacing: -0.56, fontWeight: FontWeight.w600), children: [ - TextSpan( - text: LocaleKeys.cloudSolutions.tr(), - style: const TextStyle(color: MyColors.grey3AColor, fontSize: 14, letterSpacing: -0.56, fontWeight: FontWeight.w600), - ), - ]), + text: TextSpan( + text: LocaleKeys.poweredBy.tr() + " ", + style: const TextStyle(color: MyColors.grey98Color, fontSize: 14, letterSpacing: -0.56, fontWeight: FontWeight.w600), + children: [TextSpan(text: LocaleKeys.cloudSolutions.tr(), style: const TextStyle(color: MyColors.grey3AColor, fontSize: 14, letterSpacing: -0.56, fontWeight: FontWeight.w600))], + ), ).expanded, - Image.asset("assets/images/logos/bn_cloud_soloution.jpg", width: 40, height: 40) + Image.asset("assets/images/logos/bn_cloud_soloution.jpg", width: 40, height: 40), ], - ).paddingOnly(left: 21, right: 21, top: 21) + ).paddingOnly(left: 21, right: 21, top: 21), ], ).paddingOnly(top: 21, bottom: 21), ); } Widget menuItem(String icon, String title, String routeName, {Color? color, bool closeDrawer = true, VoidCallback? onPress}) { - return Row( - children: [ - SvgPicture.asset(icon, height: 20, width: 20), - 9.width, - title.toText14(color: color, textAlign: AppState().isArabic(context) ? TextAlign.right : null).expanded, - ], - ).paddingOnly(left: 21, top: 10, bottom: 10, right: 21).onPress(closeDrawer - ? () async { - Navigator.pop(context); - Future.delayed(const Duration(microseconds: 200), onPress); - } - : onPress!); + return Row(children: [SvgPicture.asset(icon, height: 20, width: 20), 9.width, title.toText14(color: color, textAlign: AppState().isArabic(context) ? TextAlign.right : null).expanded]) + .paddingOnly(left: 21, top: 10, bottom: 10, right: 21) + .onPress( + closeDrawer + ? () async { + Navigator.pop(context); + Future.delayed(const Duration(microseconds: 200), onPress); + } + : onPress!, + ); } void postLanguageChange(BuildContext context) { @@ -170,14 +166,4 @@ class _AppDrawerState extends State { widget.onLanguageChange(); setState(() {}); } - - void performLogout() async { - AppState().isAuthenticated = false; - AppState().isLogged = false; - AppState().setPostParamsInitConfig(); - chatData.disposeData(); - // SharedPreferences prefs = await SharedPreferences.getInstance(); - // await prefs.clear(); - Navigator.pushNamedAndRemoveUntil(context, AppRoutes.login, (Route route) => false, arguments: null); - } } diff --git a/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart b/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart index f67a835..dbc2366 100644 --- a/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart +++ b/lib/ui/screens/offers_and_discounts/offers_and_discounts_home.dart @@ -39,7 +39,7 @@ class _OffersAndDiscountsHomeState extends State { Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, - appBar: AppBarWidget(context, title: LocaleKeys.offerAndDiscounts.tr(), showHomeButton: true, showLogo: true, logoPath: "assets/icons/mazaya_brand.svg"), + appBar: AppBarWidget(context, title: LocaleKeys.offerAndDiscounts.tr(), showHomeButton: true, showLogo: false, logoPath: "assets/icons/mazaya_brand.svg"), body: SingleChildScrollView( child: Column( crossAxisAlignment: CrossAxisAlignment.start,