Notification updates

master
Haroon Amjad 3 weeks ago
parent bf32777ae1
commit 5445b67b34

@ -189,7 +189,7 @@ class BaseAppClient {
// body['IdentificationNo'] = 1023854217; // body['IdentificationNo'] = 1023854217;
// body['MobileNo'] = "531940021"; //0560717232 // body['MobileNo'] = "531940021"; //0560717232
// body['PatientID'] = 4773928; //4609100 //2904826 // body['PatientID'] = 1231755; //4609100 //2904826
// body['TokenID'] = "@dm!n"; // body['TokenID'] = "@dm!n";
// Patient ID: 3027574 // Patient ID: 3027574

@ -15,7 +15,7 @@ import 'base_view_model.dart';
class NotificationViewModel extends BaseViewModel { class NotificationViewModel extends BaseViewModel {
NotificationService _notificationService = locator<NotificationService>(); NotificationService _notificationService = locator<NotificationService>();
ToDoCountProviderModel model = Provider.of<ToDoCountProviderModel>(AppGlobal.context); // ToDoCountProviderModel model = Provider.of<ToDoCountProviderModel>(AppGlobal.context, listen: false);
List<GetNotificationsResponseModel> get notifications => _notificationService.notificationsList; List<GetNotificationsResponseModel> get notifications => _notificationService.notificationsList;
@ -39,7 +39,7 @@ class NotificationViewModel extends BaseViewModel {
await authService.getDashboard().then((value) { await authService.getDashboard().then((value) {
var notificationCount = ''; var notificationCount = '';
notificationCount = value['List_PatientDashboard'][0]['UnreadPatientNotificationCount'] > 99 ? '99+' : value['List_PatientDashboard'][0]['UnreadPatientNotificationCount'].toString(); 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); sharedPref.setString(NOTIFICATION_COUNT, notificationCount);
}); });

@ -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/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/notifications_view_model.dart';
import 'package:hmg_patient_app/core/viewModels/project_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/theme/colors.dart';
import 'package:hmg_patient_app/uitl/date_uitl.dart'; import 'package:hmg_patient_app/uitl/date_uitl.dart';
import 'package:hmg_patient_app/uitl/translations_delegate_base.dart'; import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
@ -62,7 +63,7 @@ class _NotificationsDetailsPageState extends State<NotificationsDetailsPage> {
videoId = YoutubePlayer.convertUrlToId(widget.notification.videoURL)!; videoId = YoutubePlayer.convertUrlToId(widget.notification.videoURL)!;
print(videoId); // BBAyRBTfsOU print(videoId); // BBAyRBTfsOU
return videoId; return videoId;
}else{ } else {
return ""; return "";
} }
} }
@ -70,8 +71,14 @@ class _NotificationsDetailsPageState extends State<NotificationsDetailsPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
NotificationViewModel notificationViewModel = Provider.of(context); // NotificationViewModel notificationViewModel = Provider.of(context);
notificationViewModel.markAsRead(widget.notification.id);
// notificationViewModel.markAsRead(widget.notification.id);
if (projectViewModel.isLogin) {
locator<NotificationViewModel>().markAsRead(widget.notification.id);
}
return ScreenshotBlockerWidget( return ScreenshotBlockerWidget(
blockScreenshots: true, // makes this widget appear black in screenshots blockScreenshots: true, // makes this widget appear black in screenshots
detectScreenshots: true, // listen for screenshot attempts detectScreenshots: true, // listen for screenshot attempts
@ -87,6 +94,9 @@ class _NotificationsDetailsPageState extends State<NotificationsDetailsPage> {
showNewAppBarTitle: true, showNewAppBarTitle: true,
isShowDecPage: false, isShowDecPage: false,
appBarTitle: TranslationBase.of(context).notificationDetails, appBarTitle: TranslationBase.of(context).notificationDetails,
onTap: () {
print("onTap");
},
body: ListView( body: ListView(
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
padding: EdgeInsets.all(21), padding: EdgeInsets.all(21),

@ -23,17 +23,6 @@ class NotificationsPage extends StatefulWidget {
class _NotificationsPageState extends State<NotificationsPage> { class _NotificationsPageState extends State<NotificationsPage> {
int currentIndex = 0; 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<NotificationViewModel>(context, listen: false);
currentIndex = 0; // Reset to first page
_loadNotifications(model, context);
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
@ -42,6 +31,7 @@ class _NotificationsPageState extends State<NotificationsPage> {
onModelReady: (model) { onModelReady: (model) {
// GetNotificationsRequestModel getNotificationsRequestModel = new GetNotificationsRequestModel(currentPage: currentIndex, pagingSize: 14, notificationStatusID: 2); // GetNotificationsRequestModel getNotificationsRequestModel = new GetNotificationsRequestModel(currentPage: currentIndex, pagingSize: 14, notificationStatusID: 2);
// model.getNotifications(getNotificationsRequestModel, context); // model.getNotifications(getNotificationsRequestModel, context);
_loadNotifications(model, context); _loadNotifications(model, context);
}, },
builder: (_, model, widget) => AppScaffold( builder: (_, model, widget) => AppScaffold(
@ -93,7 +83,9 @@ class _NotificationsPageState extends State<NotificationsPage> {
notification: model.notifications[index], notification: model.notifications[index],
), ),
), ),
); ).then((value) {
_loadNotifications(model, context);
});
}, },
child: Container( child: Container(
width: double.infinity, width: double.infinity,
@ -171,13 +163,11 @@ class _NotificationsPageState extends State<NotificationsPage> {
} }
void _loadNotifications(NotificationViewModel model, BuildContext context) { void _loadNotifications(NotificationViewModel model, BuildContext context) {
GetNotificationsRequestModel getNotificationsRequestModel = GetNotificationsRequestModel getNotificationsRequestModel = GetNotificationsRequestModel(
GetNotificationsRequestModel(
currentPage: currentIndex, currentPage: currentIndex,
pagingSize: 14, pagingSize: 14,
notificationStatusID: 2, notificationStatusID: 2,
); );
model.getNotifications(getNotificationsRequestModel, context); model.getNotifications(getNotificationsRequestModel, context);
} }
} }

@ -413,6 +413,7 @@ class PushNotificationHandler {
notification.externalRedirectURLIos = remoteMessage.data["externalRedirectURLIos"].toString(); notification.externalRedirectURLIos = remoteMessage.data["externalRedirectURLIos"].toString();
notification.redirectButtonTextEn = remoteMessage.data["redirectButtonTextEn"].toString(); notification.redirectButtonTextEn = remoteMessage.data["redirectButtonTextEn"].toString();
notification.redirectButtonTextAr = remoteMessage.data["redirectButtonTextAr"].toString(); notification.redirectButtonTextAr = remoteMessage.data["redirectButtonTextAr"].toString();
notification.id = int.parse(remoteMessage.data["msgID"].toString());
if (remoteMessage.data["NotificationType"] == "2") { if (remoteMessage.data["NotificationType"] == "2") {
notification.videoURL = remoteMessage.data["VideoUrl"]; notification.videoURL = remoteMessage.data["VideoUrl"];
} }

Loading…
Cancel
Save