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