diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 309604b1..f8d83026 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -189,7 +189,7 @@ class BaseAppClient { // body['IdentificationNo'] = 1023854217; // body['MobileNo'] = "531940021"; //0560717232 - // body['PatientID'] = 4773928; //4609100 //2904826 + // body['PatientID'] = 1231755; //4609100 //2904826 // body['TokenID'] = "@dm!n"; // Patient ID: 3027574 diff --git a/lib/core/viewModels/notifications_view_model.dart b/lib/core/viewModels/notifications_view_model.dart index 0f011702..f55c9aaf 100644 --- a/lib/core/viewModels/notifications_view_model.dart +++ b/lib/core/viewModels/notifications_view_model.dart @@ -15,7 +15,7 @@ import 'base_view_model.dart'; class NotificationViewModel extends BaseViewModel { NotificationService _notificationService = locator(); - ToDoCountProviderModel model = Provider.of(AppGlobal.context); + // ToDoCountProviderModel model = Provider.of(AppGlobal.context, listen: false); List get notifications => _notificationService.notificationsList; @@ -39,7 +39,7 @@ class NotificationViewModel extends BaseViewModel { await authService.getDashboard().then((value) { var notificationCount = ''; notificationCount = value['List_PatientDashboard'][0]['UnreadPatientNotificationCount'] > 99 ? '99+' : value['List_PatientDashboard'][0]['UnreadPatientNotificationCount'].toString(); - model.setState(model.count, 0, true, notificationCount); + // model.setState(model.count, 0, true, notificationCount); sharedPref.setString(NOTIFICATION_COUNT, notificationCount); }); diff --git a/lib/pages/DrawerPages/notifications/notification_details_page.dart b/lib/pages/DrawerPages/notifications/notification_details_page.dart index 9815dfc6..4f38286f 100644 --- a/lib/pages/DrawerPages/notifications/notification_details_page.dart +++ b/lib/pages/DrawerPages/notifications/notification_details_page.dart @@ -4,6 +4,7 @@ import 'package:flutter_screenshot_blocker/flutter_screenshot_blocker.dart'; import 'package:hmg_patient_app/core/model/notifications/get_notifications_response_model.dart'; import 'package:hmg_patient_app/core/viewModels/notifications_view_model.dart'; import 'package:hmg_patient_app/core/viewModels/project_view_model.dart'; +import 'package:hmg_patient_app/locator.dart'; import 'package:hmg_patient_app/theme/colors.dart'; import 'package:hmg_patient_app/uitl/date_uitl.dart'; import 'package:hmg_patient_app/uitl/translations_delegate_base.dart'; @@ -62,7 +63,7 @@ class _NotificationsDetailsPageState extends State { videoId = YoutubePlayer.convertUrlToId(widget.notification.videoURL)!; print(videoId); // BBAyRBTfsOU return videoId; - }else{ + } else { return ""; } } @@ -70,11 +71,17 @@ class _NotificationsDetailsPageState extends State { @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); - NotificationViewModel notificationViewModel = Provider.of(context); - notificationViewModel.markAsRead(widget.notification.id); + // NotificationViewModel notificationViewModel = Provider.of(context); + + // notificationViewModel.markAsRead(widget.notification.id); + + if (projectViewModel.isLogin) { + locator().markAsRead(widget.notification.id); + } + return ScreenshotBlockerWidget( - blockScreenshots: true, // makes this widget appear black in screenshots - detectScreenshots: true, // listen for screenshot attempts + blockScreenshots: true, // makes this widget appear black in screenshots + detectScreenshots: true, // listen for screenshot attempts onScreenshotDetected: (event) { // event.type → 'screenshot_taken' or 'screenshot_blocked' // ScaffoldMessenger.of(context).showSnackBar( @@ -87,6 +94,9 @@ class _NotificationsDetailsPageState extends State { showNewAppBarTitle: true, isShowDecPage: false, appBarTitle: TranslationBase.of(context).notificationDetails, + onTap: () { + print("onTap"); + }, body: ListView( physics: BouncingScrollPhysics(), padding: EdgeInsets.all(21), diff --git a/lib/pages/DrawerPages/notifications/notifications_page.dart b/lib/pages/DrawerPages/notifications/notifications_page.dart index 85ac31c4..3b923c0c 100644 --- a/lib/pages/DrawerPages/notifications/notifications_page.dart +++ b/lib/pages/DrawerPages/notifications/notifications_page.dart @@ -23,17 +23,6 @@ class NotificationsPage extends StatefulWidget { class _NotificationsPageState extends State { int currentIndex = 0; - @override - void didChangeDependencies() { - super.didChangeDependencies(); - // This will be called when navigating back to this page - WidgetsBinding.instance.addPostFrameCallback((_) { - final model = Provider.of(context, listen: false); - currentIndex = 0; // Reset to first page - _loadNotifications(model, context); - }); - } - @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); @@ -42,6 +31,7 @@ class _NotificationsPageState extends State { onModelReady: (model) { // GetNotificationsRequestModel getNotificationsRequestModel = new GetNotificationsRequestModel(currentPage: currentIndex, pagingSize: 14, notificationStatusID: 2); // model.getNotifications(getNotificationsRequestModel, context); + _loadNotifications(model, context); }, builder: (_, model, widget) => AppScaffold( @@ -93,7 +83,9 @@ class _NotificationsPageState extends State { notification: model.notifications[index], ), ), - ); + ).then((value) { + _loadNotifications(model, context); + }); }, child: Container( width: double.infinity, @@ -171,13 +163,11 @@ class _NotificationsPageState extends State { } void _loadNotifications(NotificationViewModel model, BuildContext context) { - GetNotificationsRequestModel getNotificationsRequestModel = - GetNotificationsRequestModel( + GetNotificationsRequestModel getNotificationsRequestModel = GetNotificationsRequestModel( currentPage: currentIndex, pagingSize: 14, notificationStatusID: 2, ); model.getNotifications(getNotificationsRequestModel, context); } - } diff --git a/lib/uitl/push-notification-handler.dart b/lib/uitl/push-notification-handler.dart index de97c817..d06b14e3 100644 --- a/lib/uitl/push-notification-handler.dart +++ b/lib/uitl/push-notification-handler.dart @@ -413,6 +413,7 @@ class PushNotificationHandler { notification.externalRedirectURLIos = remoteMessage.data["externalRedirectURLIos"].toString(); notification.redirectButtonTextEn = remoteMessage.data["redirectButtonTextEn"].toString(); notification.redirectButtonTextAr = remoteMessage.data["redirectButtonTextAr"].toString(); + notification.id = int.parse(remoteMessage.data["msgID"].toString()); if (remoteMessage.data["NotificationType"] == "2") { notification.videoURL = remoteMessage.data["VideoUrl"]; }