Fix bug on read notifications_page.dart

fix_issues
Elham Rababah 4 years ago
parent 5bd3c7d9ce
commit 41b919183f

@ -35,5 +35,6 @@ class NotificationService extends BaseService {
updateNotification(id) {
int index = notificationsList.indexWhere((element) => element.id == id);
notificationsList[index].isRead = true;
}
}

@ -3,6 +3,8 @@ import 'package:diplomaticquarterapp/core/model/notifications/get_notifications_
import 'package:diplomaticquarterapp/core/model/notifications/get_notifications_response_model.dart';
import 'package:diplomaticquarterapp/core/model/notifications/mark_message_as_read_request_model.dart';
import 'package:diplomaticquarterapp/core/service/notifications_service.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:flutter/material.dart';
import '../../locator.dart';
import 'base_view_model.dart';
@ -14,26 +16,25 @@ class NotificationViewModel extends BaseViewModel {
_notificationService.notificationsList;
Future getNotifications(
GetNotificationsRequestModel getNotificationsRequestModel) async {
GetNotificationsRequestModel getNotificationsRequestModel, BuildContext context) async {
if(getNotificationsRequestModel.currentPage == 0)
setState(ViewState.Busy);
await _notificationService
.getAllNotifications(getNotificationsRequestModel);
if (_notificationService.hasError) {
error = _notificationService.error;
setState(ViewState.Error);
} else
} else {
setState(ViewState.Idle);
}
}
Future markAsRead(id) async {
// setState(ViewState.Busy);
MarkMessageAsReadRequestModel markMessageAsReadRequestModel =
new MarkMessageAsReadRequestModel(notificationPoolID: id);
await _notificationService.markAsRead(markMessageAsReadRequestModel);
// if (_notificationService.hasError) {
// error = _notificationService.error;
// setState(ViewState.Error);
// } else
// setState(ViewState.Idle);
setState(ViewState.Idle);
}
}

@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/core/viewModels/notifications_view_model.da
import 'package:diplomaticquarterapp/pages/DrawerPages/notifications/notification_details_page.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
@ -45,7 +46,7 @@ class NotificationsPage extends StatelessWidget {
pagingSize: 14,
notificationStatusID: 2);
model.getNotifications(getNotificationsRequestModel);
model.getNotifications(getNotificationsRequestModel, context);
},
builder: (_, model, widget) => AppScaffold(
isShowAppBar: true,
@ -57,7 +58,7 @@ class NotificationsPage extends StatelessWidget {
(notification) => InkWell(
onTap: () async {
if(!notification.isRead)
await model.markAsRead(notification.id);
model.markAsRead(notification.id);
Navigator.push(
context,
MaterialPageRoute(
@ -120,7 +121,9 @@ class NotificationsPage extends StatelessWidget {
.toList()
..add(
InkWell(
onTap: () {
onTap: () async {
GifLoaderDialogUtils.showMyDialog(
context);
currentIndex++;
GetNotificationsRequestModel
getNotificationsRequestModel =
@ -129,7 +132,10 @@ class NotificationsPage extends StatelessWidget {
pagingSize: 14,
notificationStatusID: 2);
model.getNotifications(getNotificationsRequestModel);
await model.getNotifications(getNotificationsRequestModel,context);
GifLoaderDialogUtils.hideDialog(
context);
},
child: Center(
child: Image.asset('assets/images/notf.png'),

Loading…
Cancel
Save