From e21738cf5f8f220c653ddeadb2e2265f18b9477f Mon Sep 17 00:00:00 2001 From: Sultan khan Date: Sun, 18 Oct 2026 10:12:13 +0300 Subject: [PATCH] no message --- assets/langs/ar-SA.json | 2 +- assets/langs/en-US.json | 2 +- lib/app_state/app_state.dart | 2 +- lib/classes/utils.dart | 10 ++++- lib/generated/codegen_loader.g.dart | 4 +- .../wala_plus_category_model.dart | 9 +++++ .../wala_plus_retailer_model.dart | 16 +++++++- .../dashboard_screen_for_dependet.dart | 39 ++++++++++++++++++- lib/ui/login/login_screen.dart | 4 +- .../profile/mazaya_access_result_screen.dart | 16 +++++--- 10 files changed, 87 insertions(+), 17 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 0aa8afe0..a57ff0eb 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -704,7 +704,7 @@ "done": "تم", "linkCopied": "تم نسخ الرابط بنجاح", "mazayaAccessRevoked": "تم إلغاء الوصول لمزايا", - "mazayaAccessRevokedDesc": "قام الكفيل بإلغاء وصول التابع. لم يعد بالإمكان فتح العروض أو تسجيل الدخول بالبصمة.", + "mazayaAccessRevokedDesc": "أنت غير مصرح لك بالوصول إلى برنامج مزايا.", "contactYourSponsor": "تواصل مع الكفيل", "contactYourSponsorDesc": "اطلب من كفيلك السماح بالوصول لمزايا مرة أخرى من تفاصيل التابعين. يمكن للكفيل فقط استعادة الوصول.", "dependentAccessBlocked": "تم حظر وصول التابع", diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index f1284269..03edc14e 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -704,7 +704,7 @@ "done": "Done", "linkCopied": "Link copied to clipboard", "mazayaAccessRevoked": "Mazaya access revoked", - "mazayaAccessRevokedDesc": "Your sponsor has revoked your dependent access. You can no longer open offers or sign in with biometrics.", + "mazayaAccessRevokedDesc": "You are not authorized to access the Mazaya Program.", "contactYourSponsor": "Contact your sponsor", "contactYourSponsorDesc": "Ask your sponsor to allow Mazaya access again from Dependent Details. Only the sponsor can restore access.", "dependentAccessBlocked": "Dependent access blocked", diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index af5722d8..c194d5b0 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -112,7 +112,7 @@ class AppState { String? _dependentName; - String? get dependentName => _dependentName ?? _walaplusDepInfoModel?.pDependentName; + String? get dependentName => _dependentName; set setDependentName(String? name) => _dependentName = name; diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index 9d49f2fa..42e208aa 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -107,12 +107,20 @@ class Utils { lower.contains("grant request") || lower.contains("grant was found") || lower.contains("grant_request") || + lower.contains("authorized to access") || + lower.contains("not authorized") || lower.contains("e4:") || lower.contains("e4 -") || lower.contains("e4 :")) { return true; } - if (str.contains("طلب منح") || str.contains("منح نشط") || str.contains("لا يوجد طلب منح") || str.contains("تم إلغاء وصول مزايا") || str.contains("إلغاء مزايا")) { + if (str.contains("طلب منح") || + str.contains("منح نشط") || + str.contains("لا يوجد طلب منح") || + str.contains("تم إلغاء وصول مزايا") || + str.contains("إلغاء مزايا") || + str.contains("غير مصرح لك بالوصول") || + str.contains("غير مصرح")) { return true; } return false; diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 178192a8..5b30deb1 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -716,7 +716,7 @@ class CodegenLoader extends AssetLoader{ "done": "تم", "linkCopied": "تم نسخ الرابط بنجاح", "mazayaAccessRevoked": "تم إلغاء الوصول لمزايا", - "mazayaAccessRevokedDesc": "قام الكفيل بإلغاء وصول التابع. لم يعد بالإمكان فتح العروض أو تسجيل الدخول بالبصمة.", + "mazayaAccessRevokedDesc": "أنت غير مصرح لك بالوصول إلى برنامج مزايا.", "contactYourSponsor": "تواصل مع الكفيل", "contactYourSponsorDesc": "اطلب من كفيلك السماح بالوصول لمزايا مرة أخرى من تفاصيل التابعين. يمكن للكفيل فقط استعادة الوصول.", "dependentAccessBlocked": "تم حظر وصول التابع", @@ -1525,7 +1525,7 @@ static const Map _en_US = { "done": "Done", "linkCopied": "Link copied to clipboard", "mazayaAccessRevoked": "Mazaya access revoked", - "mazayaAccessRevokedDesc": "Your sponsor has revoked your dependent access. You can no longer open offers or sign in with biometrics.", + "mazayaAccessRevokedDesc": "You are not authorized to access the Mazaya Program.", "contactYourSponsor": "Contact your sponsor", "contactYourSponsorDesc": "Ask your sponsor to allow Mazaya access again from Dependent Details. Only the sponsor can restore access.", "dependentAccessBlocked": "Dependent access blocked", diff --git a/lib/models/offers_and_discounts/wala_plus_category_model.dart b/lib/models/offers_and_discounts/wala_plus_category_model.dart index aac2752b..c0995277 100644 --- a/lib/models/offers_and_discounts/wala_plus_category_model.dart +++ b/lib/models/offers_and_discounts/wala_plus_category_model.dart @@ -5,12 +5,17 @@ class WalaPlusCategoryModel { String? name; String? parentId; + String? countryNameAr; + String? countryNameEn; + WalaPlusCategoryModel({ this.id, this.image, this.imageThumb, this.name, this.parentId, + this.countryNameAr, + this.countryNameEn, }) { if ((image == null || image!.isEmpty) && id != null && id!.trim().isNotEmpty && id != "all" && id != "0") { String cleanId = id!.trim(); @@ -26,6 +31,8 @@ class WalaPlusCategoryModel { name = (json['name'] ?? json['Name'])?.toString(); parentId = (json['parent_id'] ?? json['Parent_Id'] ?? json['parentId'])?.toString(); imageThumb = (json['image_thumb'] ?? json['Image_Thumb'] ?? json['imageThumb'])?.toString(); + countryNameAr = (json['country_name_ar'] ?? json['countryNameAr'] ?? json['category_name_ar'])?.toString(); + countryNameEn = (json['country_name_en'] ?? json['countryNameEn'] ?? json['category_name_en'])?.toString(); // Use category image URL from HMG middleware using ID from WalaPlus_Categories API: // https://epharmacy.hmg.com/middleware/images/category/{id}.png @@ -47,6 +54,8 @@ class WalaPlusCategoryModel { data['image_thumb'] = imageThumb; data['name'] = name; data['parent_id'] = parentId; + data['country_name_ar'] = countryNameAr; + data['country_name_en'] = countryNameEn; return data; } diff --git a/lib/models/offers_and_discounts/wala_plus_retailer_model.dart b/lib/models/offers_and_discounts/wala_plus_retailer_model.dart index 16c11045..d2186b8d 100644 --- a/lib/models/offers_and_discounts/wala_plus_retailer_model.dart +++ b/lib/models/offers_and_discounts/wala_plus_retailer_model.dart @@ -9,8 +9,10 @@ class WalaPlusRetailersResponse { int? pagesCount; int? perPage; List? retailers; + String? countryNameAr; + String? countryNameEn; - WalaPlusRetailersResponse({this.page, this.pagesCount, this.perPage, this.retailers}); + WalaPlusRetailersResponse({this.page, this.pagesCount, this.perPage, this.retailers, this.countryNameAr, this.countryNameEn}); factory WalaPlusRetailersResponse.fromJson(Map json) { List retailersList = []; @@ -35,6 +37,8 @@ class WalaPlusRetailersResponse { pagesCount: json['pages_count'] is int ? json['pages_count'] : int.tryParse(json['pages_count']?.toString() ?? json['pagesCount']?.toString() ?? json['totalPages']?.toString() ?? '1'), perPage: json['per_page'] is int ? json['per_page'] : int.tryParse(json['per_page']?.toString() ?? json['perPage']?.toString() ?? json['WP_Per_page']?.toString() ?? '10'), retailers: retailersList, + countryNameAr: WalaPlusRetailerModel.decodeUnicodeString(json['country_name_ar'] ?? json['countryNameAr'] ?? json['country_ar']), + countryNameEn: WalaPlusRetailerModel.decodeUnicodeString(json['country_name_en'] ?? json['countryNameEn'] ?? json['country_en']), ); } @@ -43,6 +47,8 @@ class WalaPlusRetailersResponse { data['page'] = page; data['pages_count'] = pagesCount; data['per_page'] = perPage; + data['country_name_ar'] = countryNameAr; + data['country_name_en'] = countryNameEn; if (retailers != null) { data['retailers'] = retailers!.map((v) => v.toJson()).toList(); } @@ -156,6 +162,8 @@ class WalaPlusRetailerModel { String? duration; String? email; String? phone; + String? countryNameAr; + String? countryNameEn; WalaPlusRetailerModel({ this.id, @@ -191,6 +199,8 @@ class WalaPlusRetailerModel { this.duration, this.email, this.phone, + this.countryNameAr, + this.countryNameEn, }); static List parseOffersList(data) { @@ -343,6 +353,8 @@ class WalaPlusRetailerModel { duration: targetJson['duration']?.toString(), email: targetJson['email']?.toString() ?? targetJson['contact_email']?.toString() ?? contactObj?.primaryEmail, phone: targetJson['phone']?.toString() ?? targetJson['contact_phone']?.toString() ?? targetJson['mobile']?.toString() ?? contactObj?.primaryPhone, + countryNameAr: decodeUnicodeString(targetJson['country_name_ar'] ?? targetJson['countryNameAr'] ?? targetJson['country_ar']), + countryNameEn: decodeUnicodeString(targetJson['country_name_en'] ?? targetJson['countryNameEn'] ?? targetJson['country_en']), ); } @@ -424,6 +436,8 @@ class WalaPlusRetailerModel { data['duration'] = duration; data['email'] = email; data['phone'] = phone; + data['country_name_ar'] = countryNameAr; + data['country_name_en'] = countryNameEn; if (offers != null) { data['offers'] = offers!.map((v) => v.toJson()).toList(); } diff --git a/lib/ui/landing/dashboard_screen_for_dependet.dart b/lib/ui/landing/dashboard_screen_for_dependet.dart index f3a09439..37f838c8 100644 --- a/lib/ui/landing/dashboard_screen_for_dependet.dart +++ b/lib/ui/landing/dashboard_screen_for_dependet.dart @@ -16,6 +16,7 @@ import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; import 'package:mohem_flutter_app/main.dart'; import 'package:mohem_flutter_app/models/offers_and_discounts/wala_plus_category_model.dart'; import 'package:mohem_flutter_app/models/offers_and_discounts/wala_plus_retailer_model.dart'; +import 'package:mohem_flutter_app/models/post_params_model.dart'; import 'package:mohem_flutter_app/widgets/bottom_sheets/confirm_bottom_sheet.dart'; import 'package:mohem_flutter_app/widgets/info_chip_widget.dart'; import 'package:shimmer/shimmer.dart'; @@ -426,6 +427,35 @@ class _DashboardScreenForDependetState extends State ); } + Future _changeLanguage(Locale newLocale) async { + if (context.locale == newLocale) return; + await context.setLocale(newLocale); + PostParamsModel? obj = AppState().postParamsObject; + if (obj != null) { + obj.languageID = (newLocale.languageCode == "ar" ? 1 : 2); + AppState().setPostParamsModel(obj); + } + if (mounted) { + setState(() {}); + await fetchCategories(); + await fetchOffers(categoryId: currentCategoryId.isEmpty ? "all" : currentCategoryId); + } + } + + Widget _buildLanguageIconButton(bool isAr) { + return IconButton( + icon: const Icon(Icons.language_rounded, size: 24, color: Color(0xFF1E293B)), + tooltip: isAr ? 'English' : 'العربية', + onPressed: () { + if (isAr) { + _changeLanguage(const Locale("en", "US")); + } else { + _changeLanguage(const Locale("ar", "SA")); + } + }, + ); + } + @override Widget build(BuildContext context) { bool isAr = AppState().isArabic(context); @@ -444,6 +474,7 @@ class _DashboardScreenForDependetState extends State mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( + mainAxisSize: MainAxisSize.min, children: [ if (!ApiConsts.isDependetLogin) ...[ InkWell( @@ -462,12 +493,13 @@ class _DashboardScreenForDependetState extends State ), const SizedBox(width: 8), ], - SvgPicture.asset("assets/icons/mazaya_brand.svg", height: 48, fit: BoxFit.contain), + SvgPicture.asset("assets/icons/mazaya_brand.svg", height: 40, fit: BoxFit.contain), ], ), Row( mainAxisSize: MainAxisSize.min, children: [ + _buildLanguageIconButton(isAr), if (!ApiConsts.isDependetLogin) ...[ IconButton( icon: Image.asset( @@ -495,7 +527,10 @@ class _DashboardScreenForDependetState extends State } }, ), - if (ApiConsts.isDependetLogin) InkWell(onTap: _performLogout, child: SvgPicture.asset('assets/images/drawer/logout.svg', height: 20, width: 20)), + if (ApiConsts.isDependetLogin) ...[ + const SizedBox(width: 4), + InkWell(onTap: _performLogout, child: SvgPicture.asset('assets/images/drawer/logout.svg', height: 20, width: 20)), + ], ], ), ], diff --git a/lib/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart index e373bbe5..5d5dc765 100644 --- a/lib/ui/login/login_screen.dart +++ b/lib/ui/login/login_screen.dart @@ -594,7 +594,7 @@ class _LoginScreenState extends State { return ""; } - void _navigateToMazayaAccessRevoked([String? depName]) async { + void _navigateToMazayaAccessRevoked([String? depName, String? message]) async { await Utils.removeStringFromPrefs("P_DEP_IS_LOGGED_IN"); await Utils.removeStringFromPrefs("P_DEP_NATIONAL_ID"); @@ -618,7 +618,7 @@ class _LoginScreenState extends State { name = await Utils.getStringFromPrefs("P_DEPENDENT_NAME"); } if (!mounted) return; - Navigator.push(context, MaterialPageRoute(builder: (_) => MazayaAccessResultScreen(isGranted: false, dependentName: name))); + Navigator.push(context, MaterialPageRoute(builder: (_) => MazayaAccessResultScreen(isGranted: false, dependentName: name, message: message))); } void performDependentLogin() async { diff --git a/lib/ui/profile/mazaya_access_result_screen.dart b/lib/ui/profile/mazaya_access_result_screen.dart index 5029e658..5b9a2331 100644 --- a/lib/ui/profile/mazaya_access_result_screen.dart +++ b/lib/ui/profile/mazaya_access_result_screen.dart @@ -1,4 +1,3 @@ -import 'dart:developer'; import 'dart:io'; import 'package:easy_localization/easy_localization.dart'; @@ -20,8 +19,9 @@ class MazayaAccessResultParams { final String? downloadUrl; final String? nationalId; final String? dateOfBirth; + final String? message; - const MazayaAccessResultParams({required this.isGranted, required this.dependentName, this.dependentInitials, this.downloadUrl, this.nationalId, this.dateOfBirth}); + const MazayaAccessResultParams({required this.isGranted, required this.dependentName, this.dependentInitials, this.downloadUrl, this.nationalId, this.dateOfBirth, this.message}); } class _ShieldPainter extends CustomPainter { @@ -79,8 +79,9 @@ class MazayaAccessResultScreen extends StatelessWidget { final String? downloadUrl; final String? nationalId; final String? dateOfBirth; + final String? message; - const MazayaAccessResultScreen({Key? key, this.isGranted = true, this.dependentName = "", this.dependentInitials, this.downloadUrl, this.nationalId, this.dateOfBirth}) : super(key: key); + const MazayaAccessResultScreen({Key? key, this.isGranted = true, this.dependentName = "", this.dependentInitials, this.downloadUrl, this.nationalId, this.dateOfBirth, this.message}) : super(key: key); static String getDownloadLink() { int channel = AppState().postParamsObject?.channel ?? 31; @@ -119,6 +120,7 @@ class MazayaAccessResultScreen extends StatelessWidget { String? effectiveUrl = downloadUrl; String? effectiveNationalId = nationalId; String? effectiveDateOfBirth = dateOfBirth; + String? effectiveMessage = message; if (routeArgs is MazayaAccessResultParams) { effectiveGranted = routeArgs.isGranted; @@ -127,6 +129,7 @@ class MazayaAccessResultScreen extends StatelessWidget { effectiveUrl = routeArgs.downloadUrl; effectiveNationalId = routeArgs.nationalId; effectiveDateOfBirth = routeArgs.dateOfBirth; + effectiveMessage = routeArgs.message ?? message; } else if (routeArgs is Map) { effectiveGranted = routeArgs['isGranted'] ?? isGranted; effectiveName = routeArgs['dependentName'] ?? dependentName; @@ -134,6 +137,7 @@ class MazayaAccessResultScreen extends StatelessWidget { effectiveUrl = routeArgs['downloadUrl'] ?? downloadUrl; effectiveNationalId = routeArgs['nationalId'] ?? nationalId; effectiveDateOfBirth = routeArgs['dateOfBirth'] ?? dateOfBirth; + effectiveMessage = routeArgs['message'] ?? message; } effectiveName = isAr ? "التابع" : "Dependent"; // if (effectiveName.trim().isEmpty) { @@ -183,7 +187,7 @@ class MazayaAccessResultScreen extends StatelessWidget { child: SingleChildScrollView( padding: const EdgeInsets.fromLTRB(20, 16, 20, 20), child: - effectiveGranted ? _buildGrantedContent(context, isAr, fontFamily, effectiveName, initials, linkToShare) : _buildRevokedContent(context, isAr, fontFamily, effectiveName, initials), + effectiveGranted ? _buildGrantedContent(context, isAr, fontFamily, effectiveName, initials, linkToShare) : _buildRevokedContent(context, isAr, fontFamily, effectiveName, initials, effectiveMessage), ), ), _buildBottomButtons(context, isAr, fontFamily, effectiveGranted, linkToShare, effectiveNationalId ?? "", effectiveDateOfBirth ?? ""), @@ -332,7 +336,7 @@ class MazayaAccessResultScreen extends StatelessWidget { ); } - Widget _buildRevokedContent(BuildContext context, bool isAr, String fontFamily, String name, String initials) { + Widget _buildRevokedContent(BuildContext context, bool isAr, String fontFamily, String name, String initials, [String? message]) { return Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -354,7 +358,7 @@ class MazayaAccessResultScreen extends StatelessWidget { const SizedBox(height: 8), // Description - LocaleKeys.mazayaAccessRevokedDesc.tr().toText14(isCenter: true, color: const Color(0xFF64748B)), + (message != null && message.trim().isNotEmpty ? message.trim() : LocaleKeys.mazayaAccessRevokedDesc.tr()).toText14(isCenter: true, color: const Color(0xFF64748B)), const SizedBox(height: 22),