diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index a09efff5..8f047535 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -2054,5 +2054,7 @@ "importantNotice": "تنبيه هام", "appDecommissionedText": "تم إيقاف هذا الإصدار من تطبيق الحبيب الطبي.\nللاستمرار في الاستفادة من الخدمات الصحية والسجلات الطبية، يرجى تحميل التطبيق الجديد.", "appDecommissionedSubText": "نعتذر بشدة عن الإزعاج الناتج عن هذا الانتقال.", - "downloadApp": "حمل التطبيق" + "downloadApp": "حمل التطبيق", + "unread": "غير مقروء", + "read": "مقروءة" } diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index d7cd2411..184fb93e 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -2044,7 +2044,9 @@ "importantNotice": "Important Notice", "appDecommissionedText": "This version of our healthcare application has been officially discontinued. To ensure uninterrupted access to your clinical records, we are transitioning all patients back to our main platform.", "appDecommissionedSubText": "We sincerely apologize for the inconvenience of this transition.", - "downloadApp": "Download App" + "downloadApp": "Download App", + "unread": "Unread", + "read": "Read" } diff --git a/lib/features/notifications/notifications_view_model.dart b/lib/features/notifications/notifications_view_model.dart index 85049ec9..0f3cc160 100644 --- a/lib/features/notifications/notifications_view_model.dart +++ b/lib/features/notifications/notifications_view_model.dart @@ -13,11 +13,16 @@ class NotificationsViewModel extends ChangeNotifier { ErrorHandlerService errorHandlerService; List notificationsList = []; + List readdNotificationsList = []; + List unreadNotificationsList = []; + List allNotificationsList = []; int currentPage = 0; int pagingSize = 50; int notificationStatusID = 2; // Default to status 2 (e.g., unread) + int selectedNotificationsTabIndex = 0; + NotificationsViewModel({ required this.notificationsRepo, required this.errorHandlerService, @@ -35,6 +40,18 @@ class NotificationsViewModel extends ChangeNotifier { notifyListeners(); } + void onNotificationTabChange(int index) { + selectedNotificationsTabIndex = index; + if (index == 0) { + notificationsList = allNotificationsList; + } else if (index == 1) { + notificationsList = unreadNotificationsList; + } else if (index == 2) { + notificationsList = readdNotificationsList; + } + notifyListeners(); + } + setNotificationStatusID(int statusID) { notificationStatusID = statusID; notificationsList.clear(); @@ -49,6 +66,9 @@ class NotificationsViewModel extends ChangeNotifier { }) async { isNotificationsLoading = true; unreadNotificationsCount = 0; + + notificationsList.clear(); + notifyListeners(); final result = await notificationsRepo.getAllNotifications( @@ -80,17 +100,37 @@ class NotificationsViewModel extends ChangeNotifier { hasMoreNotifications = false; } - notificationsList.addAll(newNotifications); - for (var notification in notificationsList) { - if (notification.isRead == false) { - unreadNotificationsCount++; + try { + notificationsList.addAll(newNotifications); + + // allNotificationsList.clear(); + // readdNotificationsList.clear(); + // unreadNotificationsList.clear(); + + // for (var notification in notificationsList) { + // if (notification.isRead == false) { + // unreadNotificationsCount++; + // unreadNotificationsList.add(notification); + // } else { + // readdNotificationsList.add(notification); + // } + // } + + // Filter out the items directly without a loop + unreadNotificationsList = notificationsList.where((n) => n.isRead == false).toList(); + readdNotificationsList = notificationsList.where((n) => n.isRead == true).toList(); + + // Calculate count based on the new list length + unreadNotificationsCount = unreadNotificationsList.length; + + currentPage++; + allNotificationsList = notificationsList; + notifyListeners(); + if (onSuccess != null) { + onSuccess(apiResponse); } - } - currentPage++; - - notifyListeners(); - if (onSuccess != null) { - onSuccess(apiResponse); + } catch (ex) { + print(ex.toString()); } } }, diff --git a/lib/features/occasion_theme/occasion_config_model.dart b/lib/features/occasion_theme/occasion_config_model.dart index 03bf9392..de8d14ef 100644 --- a/lib/features/occasion_theme/occasion_config_model.dart +++ b/lib/features/occasion_theme/occasion_config_model.dart @@ -68,6 +68,11 @@ class OccasionConfigModel { enabled: (json['enabled'] as bool?) ?? false, startDate: _parseDate(json['start_date']), endDate: _parseDate(json['end_date']), + + // enabled: true, + // startDate: _parseDate("2026-09-30T00:00:00Z"), + // endDate: _parseDate("2026-10-05T00:00:00Z"), + primaryColorHex: json['primary_color'] as String?, backgroundOpacityImage: json['background_opacity_image'] as String?, backgroundImageOpacity: (json['background_image_opacity'] as num?)?.toDouble() ?? 1.0, diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 67aacc0e..9de9ce9f 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -2036,5 +2036,7 @@ abstract class LocaleKeys { static const appDecommissionedText = 'appDecommissionedText'; static const appDecommissionedSubText = 'appDecommissionedSubText'; static const downloadApp = 'downloadApp'; + static const unread = 'unread'; + static const read = 'read'; } diff --git a/lib/presentation/hmg_services/services_page.dart b/lib/presentation/hmg_services/services_page.dart index 582fd6fc..34fc268f 100644 --- a/lib/presentation/hmg_services/services_page.dart +++ b/lib/presentation/hmg_services/services_page.dart @@ -72,7 +72,7 @@ class _ServicesPageState extends State { LocaleKeys.emergencyServices.tr(), "", AppAssets.emergency_services_icon, - bgColor: AppColors.primaryRedColor, + bgColor: AppColors.primaryRedColorBase, true, route: null, onTap: () async { // if (getIt.get().isAuthenticated) { diff --git a/lib/presentation/home/landing_page.dart b/lib/presentation/home/landing_page.dart index 8644655d..9d401fac 100644 --- a/lib/presentation/home/landing_page.dart +++ b/lib/presentation/home/landing_page.dart @@ -437,6 +437,7 @@ class _LandingPageState extends State { : SizedBox.shrink(), ]).onPress(() async { if (appState.isAuthenticated) { + notificationsViewModel.onNotificationTabChange(0); notificationsViewModel.setNotificationStatusID(2); notificationsViewModel.getAllNotifications(); Navigator.of(context).push( diff --git a/lib/presentation/medical_file/widgets/medical_report_card.dart b/lib/presentation/medical_file/widgets/medical_report_card.dart index 1a43b83b..905823b4 100644 --- a/lib/presentation/medical_file/widgets/medical_report_card.dart +++ b/lib/presentation/medical_file/widgets/medical_report_card.dart @@ -84,15 +84,15 @@ class MedicalReportCard extends StatelessWidget { ), ); }, - backgroundColor: AppColors.lightRedButtonColor, - borderColor: AppColors.lightRedButtonColor, + backgroundColor: AppColors.secondaryLightRedColor, + borderColor: AppColors.secondaryLightRedColor, textColor: AppColors.primaryRedColor, iconColor: AppColors.primaryRedColor, fontSize: 14.f, - // fontWeight: FontWeight.w600, isBold: true, borderRadius: 12.r, height: 40.h, + iconSize: 18.f, ).toShimmer2(isShow: isLoading), ], ), diff --git a/lib/presentation/medical_file/widgets/patient_sick_leave_card.dart b/lib/presentation/medical_file/widgets/patient_sick_leave_card.dart index f06e6a0e..2bb879b5 100644 --- a/lib/presentation/medical_file/widgets/patient_sick_leave_card.dart +++ b/lib/presentation/medical_file/widgets/patient_sick_leave_card.dart @@ -122,7 +122,7 @@ class PatientSickLeaveCard extends StatelessWidget { }); }, backgroundColor: AppColors.secondaryLightRedColor, - borderColor: AppColors.secondaryLightRedColor, + borderColor: AppColors.transparent, textColor: AppColors.primaryRedColor, fontSize: 14.f, isBold: true, diff --git a/lib/presentation/medical_report/medical_reports_page.dart b/lib/presentation/medical_report/medical_reports_page.dart index e1ac3969..64939629 100644 --- a/lib/presentation/medical_report/medical_reports_page.dart +++ b/lib/presentation/medical_report/medical_reports_page.dart @@ -50,42 +50,7 @@ class _MedicalReportsPageState extends State { child: Consumer(builder: (context, medicalFileVM, child) { return Column( children: [ - SizedBox(height: 16.h), - // Status filter tabs - // Row( - // children: [ - // CustomButton( - // text: LocaleKeys.byClinic.tr(context: context), - // onPressed: () { - // medicalFileVM.setIsMedicalReportsSortByClinic(true); - // }, - // backgroundColor: medicalFileVM.isMedicalReportsSortByClinic ? AppColors.bgRedLightColor : AppColors.whiteColor, - // borderColor: medicalFileVM.isMedicalReportsSortByClinic ? AppColors.primaryRedColor : AppColors.textColor.withValues(alpha: 0.2), - // textColor: medicalFileVM.isMedicalReportsSortByClinic ? AppColors.primaryRedColor : AppColors.blackColor, - // fontSize: 12, - // isBold: true, - // borderRadius: 10, - // padding: EdgeInsets.fromLTRB(10, 0, 10, 0), - // height: 40.h, - // ), - // SizedBox(width: 8.h), - // CustomButton( - // text: LocaleKeys.byHospital.tr(context: context), - // onPressed: () { - // medicalFileVM.setIsMedicalReportsSortByClinic(false); - // }, - // backgroundColor: medicalFileVM.isMedicalReportsSortByClinic ? AppColors.whiteColor : AppColors.bgRedLightColor, - // borderColor: medicalFileVM.isMedicalReportsSortByClinic ? AppColors.textColor.withValues(alpha: 0.2) : AppColors.primaryRedColor, - // textColor: medicalFileVM.isMedicalReportsSortByClinic ? AppColors.blackColor : AppColors.primaryRedColor, - // fontSize: 12, - // isBold: true, - // borderRadius: 10, - // padding: EdgeInsets.fromLTRB(10, 0, 10, 0), - // height: 40.h, - // ), - // ], - // ).paddingSymmetrical(24.h, 0.h), - SizedBox(height: 8.h), + SizedBox(height: 24.h), Row( children: [ CustomButton( diff --git a/lib/presentation/notifications/notifications_list_page.dart b/lib/presentation/notifications/notifications_list_page.dart index 77f9a20a..eb1af696 100644 --- a/lib/presentation/notifications/notifications_list_page.dart +++ b/lib/presentation/notifications/notifications_list_page.dart @@ -17,6 +17,7 @@ import 'package:hmg_patient_app_new/presentation/lab/lab_result_item_view.dart'; import 'package:hmg_patient_app_new/presentation/notifications/notification_details_page.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart'; +import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; import 'package:provider/provider.dart'; import 'package:intl/intl.dart'; import 'dart:ui' as ui; @@ -51,6 +52,54 @@ class _NotificationsListPageState extends State { child: Consumer(builder: (context, notificationsVM, child) { return Column( children: [ + Row( + children: [ + CustomButton( + text: LocaleKeys.all.tr(context: context), + onPressed: () { + notificationsVM.onNotificationTabChange(0); + }, + backgroundColor: notificationsVM.selectedNotificationsTabIndex == 0 ? AppColors.bgRedLightColor : AppColors.whiteColor, + borderColor: notificationsVM.selectedNotificationsTabIndex == 0 ? AppColors.primaryRedColor : AppColors.textColor.withValues(alpha: 0.2), + textColor: notificationsVM.selectedNotificationsTabIndex == 0 ? AppColors.primaryRedColor : AppColors.blackColor, + fontSize: 12, + isBold: true, + borderRadius: 10, + padding: EdgeInsets.fromLTRB(10, 0, 10, 0), + height: 40.h, + ), + SizedBox(width: 8.h), + CustomButton( + text: LocaleKeys.unread.tr(context: context), + onPressed: () { + notificationsVM.onNotificationTabChange(1); + }, + backgroundColor: notificationsVM.selectedNotificationsTabIndex == 1 ? AppColors.bgRedLightColor : AppColors.whiteColor, + borderColor: notificationsVM.selectedNotificationsTabIndex == 1 ? AppColors.primaryRedColor : AppColors.textColor.withValues(alpha: 0.2), + textColor: notificationsVM.selectedNotificationsTabIndex == 1 ? AppColors.primaryRedColor : AppColors.blackColor, + fontSize: 12, + isBold: true, + borderRadius: 10, + padding: EdgeInsets.fromLTRB(10, 0, 10, 0), + height: 40.h, + ), + SizedBox(width: 8.h), + CustomButton( + text: LocaleKeys.read.tr(context: context), + onPressed: () { + notificationsVM.onNotificationTabChange(2); + }, + backgroundColor: notificationsVM.selectedNotificationsTabIndex == 2 ? AppColors.bgRedLightColor : AppColors.whiteColor, + borderColor: notificationsVM.selectedNotificationsTabIndex == 2 ? AppColors.primaryRedColor : AppColors.textColor.withValues(alpha: 0.2), + textColor: notificationsVM.selectedNotificationsTabIndex == 2 ? AppColors.primaryRedColor : AppColors.blackColor, + fontSize: 12, + isBold: true, + borderRadius: 10, + padding: EdgeInsets.fromLTRB(10, 0, 10, 0), + height: 40.h, + ), + ], + ).paddingSymmetrical(24.h, 0.h), Container( margin: EdgeInsets.symmetric(vertical: 24.h), decoration: RoundedRectangleBorder().toSmoothCornerDecoration(