From 8309f311e61d2d8c2d9538f0f8d1f4bc21de6fdc Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Thu, 12 Feb 2026 14:12:54 +0300 Subject: [PATCH] App update page implemented --- assets/langs/ar-SA.json | 3 +- assets/langs/en-US.json | 3 +- lib/core/api/api_client.dart | 20 +++- lib/core/api_consts.dart | 2 +- .../authentication_view_model.dart | 5 +- lib/generated/locale_keys.g.dart | 1 + lib/presentation/home/app_update_page.dart | 96 +++++++++++++++++++ lib/routes/app_routes.dart | 5 + pubspec.yaml | 1 + 9 files changed, 127 insertions(+), 9 deletions(-) create mode 100644 lib/presentation/home/app_update_page.dart diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 9d5b1e9..97b0bf6 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -1575,5 +1575,6 @@ "loadingAIAnalysis": "جارٍ تحليل نتائج المختبر، يرجى التحلي بالصبر والسماح للذكاء الاصطناعي بالقيام بالمهمة، قد يستغرق هذا بعض الوقت.", "symptoms": "أعراض", "insuranceInActive": "التأمين غير نشط", - "insuranceInActiveContactSupport": "لديك تأمين ساري المفعول، ولكنه غير مُفعّل حاليًا في مجموعة حبيب الطبية. يُرجى التواصل مع خدمة عملاء مجموعة حبيب الطبية." + "insuranceInActiveContactSupport": "لديك تأمين ساري المفعول، ولكنه غير مُفعّل حاليًا في مجموعة حبيب الطبية. يُرجى التواصل مع خدمة عملاء مجموعة حبيب الطبية.", + "updateAppNow": "تحديث التطبيق الآن" } diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 4bd9ae9..68ea584 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -1566,5 +1566,6 @@ "loadingAIAnalysis": "Analysing your lab results, Please be patient and let the AI do the magic, This might take some time.", "symptoms": "Symptoms", "insuranceInActive": "Insurance Inactive", - "insuranceInActiveContactSupport": "You have a valid insurance but it is currently inactive in HMG. Please contact HMG customer support to activate it." + "insuranceInActiveContactSupport": "You have a valid insurance but it is currently inactive in HMG. Please contact HMG customer support to activate it.", + "updateAppNow": "Update App Now" } diff --git a/lib/core/api/api_client.dart b/lib/core/api/api_client.dart index 3dd2638..470a938 100644 --- a/lib/core/api/api_client.dart +++ b/lib/core/api/api_client.dart @@ -7,9 +7,11 @@ import 'package:hmg_patient_app_new/core/api_consts.dart'; import 'package:hmg_patient_app_new/core/app_state.dart'; import 'package:hmg_patient_app_new/core/dependencies.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart'; +import 'package:hmg_patient_app_new/presentation/home/app_update_page.dart'; import 'package:hmg_patient_app_new/routes/app_routes.dart'; import 'package:hmg_patient_app_new/services/analytics/analytics_service.dart'; import 'package:hmg_patient_app_new/services/navigation_service.dart'; +import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart'; import 'package:http/http.dart' as http; import '../exceptions/api_failure.dart'; @@ -198,9 +200,9 @@ class ApiClientImp implements ApiClient { // body['PatientOutSA'] = 0; // body['SessionID'] = "45786230487560q"; - body['IdentificationNo'] = "2235558844"; - body['MobileNo'] = "966533147722"; - body['PatientID'] = 809289; + // body['IdentificationNo'] = "2235558844"; + // body['MobileNo'] = "966533147722"; + // body['PatientID'] = 809289; } if(!url.contains("/paymentApi")) { @@ -251,8 +253,16 @@ class ApiClientImp implements ApiClient { } else { if (parsed['ErrorType'] == 4) { //TODO : handle app update - onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode, - failureType: AppUpdateFailure("parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']")); + // onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode, + // failureType: AppUpdateFailure("parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']")); + + ApiClient._navigationService.pushAndRemoveUntil( + CustomPageRoute( + page: AppUpdatePage( + appUpdateMessage: parsed['ErrorEndUserMessage'], + )), + ModalRoute.withName("/appUpdate") + ); logApiEndpointError(endPoint, parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); } if (parsed['ErrorType'] == 2) { diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart index c1981be..1ce748f 100644 --- a/lib/core/api_consts.dart +++ b/lib/core/api_consts.dart @@ -4,7 +4,7 @@ import 'package:hmg_patient_app_new/core/enums.dart'; class ApiConsts { static const maxSmallScreen = 660; - static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.preProd; + static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.prod; // static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index 509b7cc..3971b8d 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -1064,7 +1064,10 @@ class AuthenticationViewModel extends ChangeNotifier { List projectDetailListModel = []; resultEither.fold( - (failure) async => await _errorHandlerService.handleError(failure: failure), + // (failure) async => await _errorHandlerService.handleError(failure: failure), + (failure) async { + print(failure.message); + }, (apiResponse) async { if (apiResponse.messageStatus == 2) { await _dialogService.showErrorBottomSheet(message: apiResponse.errorMessage ?? "ErrorEmpty"); diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 46ae0ba..b3b4927 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -1567,5 +1567,6 @@ abstract class LocaleKeys { static const symptoms = 'symptoms'; static const insuranceInActive = 'insuranceInActive'; static const insuranceInActiveContactSupport = 'insuranceInActiveContactSupport'; + static const updateAppNow = 'updateAppNow'; } diff --git a/lib/presentation/home/app_update_page.dart b/lib/presentation/home/app_update_page.dart new file mode 100644 index 0000000..5e6481b --- /dev/null +++ b/lib/presentation/home/app_update_page.dart @@ -0,0 +1,96 @@ +import 'dart:io'; + +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:hmg_patient_app_new/core/app_assets.dart'; +import 'package:hmg_patient_app_new/core/app_state.dart'; +import 'package:hmg_patient_app_new/core/dependencies.dart'; +import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; +import 'package:hmg_patient_app_new/core/utils/utils.dart'; +import 'package:hmg_patient_app_new/extensions/string_extensions.dart'; +import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; +import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; +import 'package:hmg_patient_app_new/theme/colors.dart'; +import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; +import 'package:in_app_update/in_app_update.dart'; +import 'package:lottie/lottie.dart'; + +class AppUpdatePage extends StatelessWidget { + AppUpdatePage({super.key, required this.appUpdateMessage}); + + String appUpdateMessage; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.whiteColor, + body: Column( + children: [ + Expanded( + child: Padding( + padding: EdgeInsets.all(24.h), + child: Column( + children: [ + SizedBox(height: 120.h), + Align( + alignment: Alignment.topCenter, + child: Transform.flip( + flipX: getIt.get().isArabic() ? true : false, + child: Lottie.asset(AppAnimations.onboarding_1, + repeat: true, reverse: false, frameRate: FrameRate(60), width: MediaQuery.sizeOf(context).width - 50.w, height: MediaQuery.sizeOf(context).width - 50.w), + ), + ), + SizedBox(height: 50.h), + appUpdateMessage.toText16(weight: FontWeight.w500), + ], + ), + ), + ), + Container( + decoration: RoundedRectangleBorder().toSmoothCornerDecoration( + color: AppColors.whiteColor, + borderRadius: 24.r, + hasShadow: true, + ), + child: CustomButton( + text: LocaleKeys.updateAppNow.tr(context: context), + onPressed: () { + openAppUpdateLink(); + }, + backgroundColor: AppColors.primaryRedColor, + borderColor: AppColors.primaryRedColor, + textColor: AppColors.whiteColor, + borderRadius: 12.r, + padding: EdgeInsets.fromLTRB(10, 0, 10, 0), + height: 56.h, + ), + ).paddingAll(24.h), + ], + ), + ); + } + + openAppUpdateLink() { + if (Platform.isAndroid) { + // _launchURL("https://play.google.com/store/apps/details?id=com.ejada.hmg"); + InAppUpdate.checkForUpdate().then((info) { + print("checkForUpdate!!!"); + print(info.toString()); + if (info.immediateUpdateAllowed) { + print("Immediate Allowed!!!"); + InAppUpdate.performImmediateUpdate().then((value) {}).catchError((e) => print(e.toString())); + } + }).catchError((e) { + print(e.toString()); + Utils.openWebView( + url: "https://play.google.com/store/apps/details?id=com.ejada.hmg", + ); + }); + } + if (Platform.isIOS) { + Utils.openWebView( + url: "https://itunes.apple.com/app/id733503978", + ); + } + } +} diff --git a/lib/routes/app_routes.dart b/lib/routes/app_routes.dart index c09fab6..fd16a2d 100644 --- a/lib/routes/app_routes.dart +++ b/lib/routes/app_routes.dart @@ -14,6 +14,7 @@ import 'package:hmg_patient_app_new/presentation/health_calculators_and_converts import 'package:hmg_patient_app_new/presentation/health_trackers/add_health_tracker_entry_page.dart'; import 'package:hmg_patient_app_new/presentation/health_trackers/health_tracker_detail_page.dart'; import 'package:hmg_patient_app_new/presentation/health_trackers/health_trackers_page.dart'; +import 'package:hmg_patient_app_new/presentation/home/app_update_page.dart'; import 'package:hmg_patient_app_new/presentation/home/navigation_screen.dart'; import 'package:hmg_patient_app_new/presentation/home_health_care/hhc_procedures_page.dart'; import 'package:hmg_patient_app_new/presentation/medical_file/medical_file_page.dart'; @@ -61,6 +62,7 @@ class AppRoutes { static const String huaweiHealthExample = '/huaweiHealthExample'; static const String covid19Test = '/covid19Test'; static const String vitalSign = '/vitalSign'; + static const String appUpdate = '/appUpdate'; //appointments static const String bookAppointmentPage = '/bookAppointmentPage'; @@ -123,6 +125,9 @@ class AppRoutes { healthConvertersPage: (context) => HealthCalculatorsPage(type: HealthCalConEnum.converter), healthTrackersPage: (context) => HealthTrackersPage(), vitalSign: (context) => VitalSignPage(), + appUpdate: (context) => AppUpdatePage( + appUpdateMessage: '', + ), emergencyServicesPage: (context) => EmergencyServicesPage(), servicesPriceListPage: (context) => ServicesPriceListPage(), addHealthTrackerEntryPage: (context) { diff --git a/pubspec.yaml b/pubspec.yaml index bacc46f..81f982a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -83,6 +83,7 @@ dependencies: open_filex: ^4.7.0 flutter_swiper_view: ^1.1.8 flutter_callkit_incoming: ^3.0.0 + in_app_update: ^4.2.5 # device_preview: ^1.3.1 location: ^8.0.1