Notification page changes

haroon_dev
haroon amjad 4 days ago
parent 11b28ff501
commit 5855145761

@ -2054,5 +2054,7 @@
"importantNotice": "تنبيه هام",
"appDecommissionedText": "تم إيقاف هذا الإصدار من تطبيق الحبيب الطبي.\nللاستمرار في الاستفادة من الخدمات الصحية والسجلات الطبية، يرجى تحميل التطبيق الجديد.",
"appDecommissionedSubText": "نعتذر بشدة عن الإزعاج الناتج عن هذا الانتقال.",
"downloadApp": "حمل التطبيق"
"downloadApp": "حمل التطبيق",
"unread": "غير مقروء",
"read": "مقروءة"
}

@ -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"
}

@ -13,11 +13,16 @@ class NotificationsViewModel extends ChangeNotifier {
ErrorHandlerService errorHandlerService;
List<NotificationResponseModel> notificationsList = [];
List<NotificationResponseModel> readdNotificationsList = [];
List<NotificationResponseModel> unreadNotificationsList = [];
List<NotificationResponseModel> 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());
}
}
},

@ -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,

@ -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';
}

@ -72,7 +72,7 @@ class _ServicesPageState extends State<ServicesPage> {
LocaleKeys.emergencyServices.tr(),
"",
AppAssets.emergency_services_icon,
bgColor: AppColors.primaryRedColor,
bgColor: AppColors.primaryRedColorBase,
true,
route: null, onTap: () async {
// if (getIt.get<AppState>().isAuthenticated) {

@ -437,6 +437,7 @@ class _LandingPageState extends State<LandingPage> {
: SizedBox.shrink(),
]).onPress(() async {
if (appState.isAuthenticated) {
notificationsViewModel.onNotificationTabChange(0);
notificationsViewModel.setNotificationStatusID(2);
notificationsViewModel.getAllNotifications();
Navigator.of(context).push(

@ -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),
],
),

@ -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,

@ -50,42 +50,7 @@ class _MedicalReportsPageState extends State<MedicalReportsPage> {
child: Consumer<MedicalFileViewModel>(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(

@ -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<NotificationsListPage> {
child: Consumer<NotificationsViewModel>(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(

Loading…
Cancel
Save