From fdd5d4cf6d202fe3b8ad29c45d247c0b64ef2589 Mon Sep 17 00:00:00 2001 From: Sultan khan Date: Tue, 16 Sep 2025 11:27:13 +0300 Subject: [PATCH] fixes --- assets/langs/ar-SA.json | 3 +- assets/langs/en-US.json | 3 +- lib/core/app_assets.dart | 4 +- lib/core/cache_consts.dart | 1 + .../authentication_view_model.dart | 33 ++++++++------ lib/generated/locale_keys.g.dart | 2 +- lib/presentation/home/landing_page.dart | 5 +++ lib/presentation/home/navigation_screen.dart | 8 +++- .../bottom_navigation/bottom_navigation.dart | 7 ++- lib/widgets/my_family/my_Family.dart | 44 +++++++++++++++++++ lib/widgets/my_family/my_family_sheet.dart | 15 +++++++ 11 files changed, 103 insertions(+), 22 deletions(-) create mode 100644 lib/widgets/my_family/my_Family.dart create mode 100644 lib/widgets/my_family/my_family_sheet.dart diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index bbfa68c..60ed09b 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -814,5 +814,6 @@ "notNow": "ليس الآن", "pendingActivation": "في انتظار التنشيط", "awaitingApproval": "انتظر القبول", - "ready": "جاهز" + "ready": "جاهز", + "news": "أخبار" } \ No newline at end of file diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index e054238..b795ddc 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -810,5 +810,6 @@ "notNow": "Not Now", "pendingActivation": "Pending Activation", "awaitingApproval": "Awaiting Approval", - "ready": "Ready" + "ready": "Ready", + "news": "News" } \ No newline at end of file diff --git a/lib/core/app_assets.dart b/lib/core/app_assets.dart index 9518fd9..e59c93c 100644 --- a/lib/core/app_assets.dart +++ b/lib/core/app_assets.dart @@ -116,7 +116,8 @@ class AppAssets { static const String toDoBottom = '$svgBasePath/todo_bottom.svg'; static const String servicesBottom = '$svgBasePath/services_bottom.svg'; static const String closeBottomNav = '$svgBasePath/close_bottom_nav.svg'; - + static const String feedback = '$svgBasePath/feedback.svg'; + static const String news = '$svgBasePath/news.svg'; // PNGS // static const String hmg_logo = '$pngBasePath/hmg_logo.png'; static const String livecare_service = '$pngBasePath/livecare_service.png'; @@ -137,4 +138,5 @@ class AppAnimations { static const String checkmark = '$lottieBasePath/checkmark.json'; static const String loadingAnimation = '$lottieBasePath/Loader.json'; static const String errorAnimation = '$lottieBasePath/ErrorAnimation.json'; + } diff --git a/lib/core/cache_consts.dart b/lib/core/cache_consts.dart index b793f02..bbf5402 100644 --- a/lib/core/cache_consts.dart +++ b/lib/core/cache_consts.dart @@ -72,4 +72,5 @@ class CacheConst { static const String isLastAppointmentRateShown = 'is-last-appointment-rate-shown'; static const String patientOccupationList = 'patient-occupation-list'; static const String hasEnabledQuickLogin = 'has-enabled-quick-login'; + static const String quickLoginEnabled = 'quick-login-enabled'; } diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index e17d576..cdb2e3d 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -3,6 +3,7 @@ import 'dart:developer'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/services.dart' show rootBundle; import 'package:flutter/material.dart'; +import 'package:get_it/get_it.dart'; import 'package:hijri_gregorian_calendar/hijri_gregorian_calendar.dart'; import 'package:hmg_patient_app_new/core/app_state.dart'; import 'package:hmg_patient_app_new/core/cache_consts.dart'; @@ -47,7 +48,6 @@ class AuthenticationViewModel extends ChangeNotifier { final DialogService _dialogService; final NavigationService _navigationService; final LocalAuthService _localAuthService; - AuthenticationViewModel({ required AppState appState, required AuthenticationRepo authenticationRepo, @@ -62,7 +62,6 @@ class AuthenticationViewModel extends ChangeNotifier { _appState = appState, _authenticationRepo = authenticationRepo, _localAuthService = localAuthService; - final TextEditingController nationalIdController = TextEditingController(), phoneNumberController = TextEditingController(), dobController = TextEditingController(), @@ -74,6 +73,7 @@ class AuthenticationViewModel extends ChangeNotifier { bool isTermsAccepted = false; List? countriesList; String? dob = ""; + final CacheService cacheService = GetIt.instance(); NationalityCountries? pickedCountryByUAEUser; CalenderEnum calenderType = CalenderEnum.gregorian; @@ -106,6 +106,7 @@ class AuthenticationViewModel extends ChangeNotifier { } Future clearDefaultInputValues() async { + nationalIdController.clear(); phoneNumberController.clear(); dobController.clear(); @@ -600,19 +601,23 @@ class AuthenticationViewModel extends ChangeNotifier { } checkLastLoginStatus(Function() onSuccess) async { + + cacheService.getBool(key: CacheConst.quickLoginEnabled); Future.delayed(Duration(seconds: 1), () { - if (_appState.getSelectDeviceByImeiRespModelElement != null && - (_appState.getSelectDeviceByImeiRespModelElement!.logInType == 1 || _appState.getSelectDeviceByImeiRespModelElement!.logInType == 4)) { - phoneNumberController.text = - (_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0") ? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "") : _appState.getAuthenticatedUser()!.mobileNumber)!; - nationalIdController.text = _appState.getAuthenticatedUser()!.nationalityId!; - onSuccess(); - } else if ((loginTypeEnum == LoginTypeEnum.sms || loginTypeEnum == LoginTypeEnum.whatsapp && _appState.getSelectDeviceByImeiRespModelElement == null) && - _appState.getAuthenticatedUser() != null) { - phoneNumberController.text = - (_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0") ? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "") : _appState.getAuthenticatedUser()!.mobileNumber)!; - nationalIdController.text = _appState.getAuthenticatedUser()!.nationalityId!; - onSuccess(); + if(cacheService.getBool(key: CacheConst.quickLoginEnabled) == false) { + if (_appState.getSelectDeviceByImeiRespModelElement != null && + (_appState.getSelectDeviceByImeiRespModelElement!.logInType == 1 || _appState.getSelectDeviceByImeiRespModelElement!.logInType == 4)) { + phoneNumberController.text = + (_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0") ? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "") : _appState.getAuthenticatedUser()!.mobileNumber)!; + nationalIdController.text = _appState.getAuthenticatedUser()!.nationalityId!; + onSuccess(); + } else if ((loginTypeEnum == LoginTypeEnum.sms || loginTypeEnum == LoginTypeEnum.whatsapp && _appState.getSelectDeviceByImeiRespModelElement == null) && + _appState.getAuthenticatedUser() != null) { + phoneNumberController.text = + (_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0") ? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "") : _appState.getAuthenticatedUser()!.mobileNumber)!; + nationalIdController.text = _appState.getAuthenticatedUser()!.nationalityId!; + onSuccess(); + } } }); } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 8b7f021..22eb696 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -813,5 +813,5 @@ abstract class LocaleKeys { static const pendingActivation = 'pendingActivation'; static const awaitingApproval = 'awaitingApproval'; static const ready = 'ready'; - + static const news = 'news'; } diff --git a/lib/presentation/home/landing_page.dart b/lib/presentation/home/landing_page.dart index 26e5147..04885cb 100644 --- a/lib/presentation/home/landing_page.dart +++ b/lib/presentation/home/landing_page.dart @@ -3,8 +3,10 @@ import 'dart:async'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; +import 'package:get_it/get_it.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/cache_consts.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'; @@ -23,6 +25,7 @@ import 'package:hmg_patient_app_new/presentation/home/widgets/large_service_card import 'package:hmg_patient_app_new/presentation/home/widgets/small_service_card.dart'; import 'package:hmg_patient_app_new/presentation/home/widgets/welcome_widget.dart'; import 'package:hmg_patient_app_new/presentation/medical_file/medical_file_page.dart'; +import 'package:hmg_patient_app_new/services/cache_service.dart'; import 'package:hmg_patient_app_new/services/navigation_service.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; @@ -47,6 +50,7 @@ class _LandingPageState extends State { late AppState appState; late MyAppointmentsViewModel myAppointmentsViewModel; late PrescriptionsViewModel prescriptionsViewModel; + final CacheService cacheService = GetIt.instance(); @override void initState() { @@ -357,6 +361,7 @@ class _LandingPageState extends State { // sharedPref.setBool(HAS_ENABLED_QUICK_LOGIN, true); authVM.loginWithFingerPrintFace(() { isDone = true; + cacheService.saveBool(key: CacheConst.quickLoginEnabled,value: true); setState(() {}); }); }, diff --git a/lib/presentation/home/navigation_screen.dart b/lib/presentation/home/navigation_screen.dart index bdce393..e0ca003 100644 --- a/lib/presentation/home/navigation_screen.dart +++ b/lib/presentation/home/navigation_screen.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.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/presentation/book_appointment/book_appointment_page.dart'; import 'package:hmg_patient_app_new/presentation/home/landing_page.dart'; import 'package:hmg_patient_app_new/presentation/medical_file/medical_file_page.dart'; @@ -13,20 +15,22 @@ class LandingNavigation extends StatefulWidget { class _LandingNavigationState extends State { int _currentIndex = 0; + late AppState appState; final PageController _pageController = PageController(); @override Widget build(BuildContext context) { + appState = getIt.get(); return Scaffold( body: PageView( controller: _pageController, physics: const NeverScrollableScrollPhysics(), children: [ const LandingPage(), - MedicalFilePage(), + appState.isAuthenticated ? MedicalFilePage() :/* need add feedback page */ const LandingPage(), const BookAppointmentPage(), const LandingPage(), - const LandingPage(), + appState.isAuthenticated ? /* need add news page */ LandingPage() : const LandingPage(), ], ), bottomNavigationBar: BottomNavigation( diff --git a/lib/widgets/bottom_navigation/bottom_navigation.dart b/lib/widgets/bottom_navigation/bottom_navigation.dart index 7f45464..da289c1 100644 --- a/lib/widgets/bottom_navigation/bottom_navigation.dart +++ b/lib/widgets/bottom_navigation/bottom_navigation.dart @@ -1,6 +1,8 @@ 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'; @@ -19,16 +21,17 @@ class BottomNavigation extends StatelessWidget { @override Widget build(BuildContext context) { + AppState appState = getIt.get(); final items = [ BottomNavItem(icon: AppAssets.homeBottom, label: LocaleKeys.home.tr()), - BottomNavItem(icon: AppAssets.myFilesBottom, label: LocaleKeys.myFiles.tr()), + appState.isAuthenticated ? BottomNavItem(icon: AppAssets.myFilesBottom, label: LocaleKeys.myFiles.tr()) : BottomNavItem(icon: AppAssets.feedback, label: LocaleKeys.feedback.tr()), BottomNavItem( icon: AppAssets.bookAppoBottom, label: LocaleKeys.appointment.tr(), iconSize: 27, isSpecial: true, ), - BottomNavItem(icon: AppAssets.toDoBottom, label: LocaleKeys.todoList.tr()), + appState.isAuthenticated ? BottomNavItem(icon: AppAssets.toDoBottom, label: LocaleKeys.todoList.tr()) : BottomNavItem(icon: AppAssets.news, label: LocaleKeys.news.tr()) , BottomNavItem(icon: AppAssets.servicesBottom, label: LocaleKeys.services2.tr()), ]; diff --git a/lib/widgets/my_family/my_Family.dart b/lib/widgets/my_family/my_Family.dart new file mode 100644 index 0000000..912ae0b --- /dev/null +++ b/lib/widgets/my_family/my_Family.dart @@ -0,0 +1,44 @@ +import 'package:flutter/material.dart'; + +class ProfileSelector extends StatelessWidget { + final List> profiles; + final Function(Map) onSelect; + + const ProfileSelector({ + Key? key, + required this.profiles, + required this.onSelect, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Column( + mainAxisSize: MainAxisSize.min, + children: profiles.map((profile) { + return ListTile( + leading: CircleAvatar( + radius: 22, + backgroundImage: profile["GenderImage"] != null && + profile["GenderImage"].toString().isNotEmpty + ? NetworkImage(profile["GenderImage"]) + : AssetImage( + profile["Gender"] == 1 + ? "assets/images/male.png" + : "assets/images/female.png") + as ImageProvider, + ), + title: Text( + profile["PatientName"] ?? "Unknown", + style: const TextStyle(fontWeight: FontWeight.w600), + ), + subtitle: Text( + profile["Relationship"] ?? "Self", + style: const TextStyle(color: Colors.grey), + ), + trailing: const Icon(Icons.arrow_forward_ios, size: 16), + onTap: () => onSelect(profile), + ); + }).toList(), + ); + } +} diff --git a/lib/widgets/my_family/my_family_sheet.dart b/lib/widgets/my_family/my_family_sheet.dart new file mode 100644 index 0000000..2e0ae15 --- /dev/null +++ b/lib/widgets/my_family/my_family_sheet.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; +import '../common_bottom_sheet.dart'; +import 'my_Family.dart'; + class MyFamilySheet { + static void show(BuildContext context, List> profiles, Function(Map) onSelect) { + showCommonBottomSheetWithoutHeight( + context, + title: 'Select Profile', + child: ProfileSelector(profiles: profiles, onSelect: (profile) { + Navigator.of(context).pop(); // Close the bottom sheet + onSelect(profile); // Call the onSelect callback + }), callBackFunc: () {}, + ); + } + } \ No newline at end of file