master
Haroon Amjad 3 weeks ago
parent 33c11e6918
commit 3d13403bb9

@ -1,6 +1,7 @@
import 'dart:io';
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/theme/colors.dart';
import 'package:hmg_patient_app/uitl/date_uitl.dart';
@ -68,6 +69,8 @@ class _NotificationsDetailsPageState extends State<NotificationsDetailsPage> {
@override
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
NotificationViewModel notificationViewModel = Provider.of(context);
notificationViewModel.markAsRead(widget.notification.id);
return AppScaffold(
isShowAppBar: true,
showNewAppBar: true,

@ -15,18 +15,34 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
// ignore: must_be_immutable
class NotificationsPage extends StatelessWidget {
class NotificationsPage extends StatefulWidget {
@override
State<NotificationsPage> createState() => _NotificationsPageState();
}
class _NotificationsPageState extends State<NotificationsPage> {
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
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
AppGlobal.context = context;
return BaseView<NotificationViewModel>(
onModelReady: (model) {
GetNotificationsRequestModel getNotificationsRequestModel = new GetNotificationsRequestModel(currentPage: currentIndex, pagingSize: 14, notificationStatusID: 2);
model.getNotifications(getNotificationsRequestModel, context);
// GetNotificationsRequestModel getNotificationsRequestModel = new GetNotificationsRequestModel(currentPage: currentIndex, pagingSize: 14, notificationStatusID: 2);
// model.getNotifications(getNotificationsRequestModel, context);
_loadNotifications(model, context);
},
builder: (_, model, widget) => AppScaffold(
isShowAppBar: true,
@ -153,4 +169,15 @@ class NotificationsPage extends StatelessWidget {
),
);
}
void _loadNotifications(NotificationViewModel model, BuildContext context) {
GetNotificationsRequestModel getNotificationsRequestModel =
GetNotificationsRequestModel(
currentPage: currentIndex,
pagingSize: 14,
notificationStatusID: 2,
);
model.getNotifications(getNotificationsRequestModel, context);
}
}

Loading…
Cancel
Save