Fix bug on read notifications_page.dart

merge-update-with-lab-changes
Elham Rababah 5 years ago
parent 5bd3c7d9ce
commit 41b919183f

@ -35,5 +35,6 @@ class NotificationService extends BaseService {
updateNotification(id) { updateNotification(id) {
int index = notificationsList.indexWhere((element) => element.id == id); int index = notificationsList.indexWhere((element) => element.id == id);
notificationsList[index].isRead = true; 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/get_notifications_response_model.dart';
import 'package:diplomaticquarterapp/core/model/notifications/mark_message_as_read_request_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/core/service/notifications_service.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:flutter/material.dart';
import '../../locator.dart'; import '../../locator.dart';
import 'base_view_model.dart'; import 'base_view_model.dart';
@ -14,15 +16,18 @@ class NotificationViewModel extends BaseViewModel {
_notificationService.notificationsList; _notificationService.notificationsList;
Future getNotifications( Future getNotifications(
GetNotificationsRequestModel getNotificationsRequestModel) async { GetNotificationsRequestModel getNotificationsRequestModel, BuildContext context) async {
setState(ViewState.Busy); if(getNotificationsRequestModel.currentPage == 0)
setState(ViewState.Busy);
await _notificationService await _notificationService
.getAllNotifications(getNotificationsRequestModel); .getAllNotifications(getNotificationsRequestModel);
if (_notificationService.hasError) { if (_notificationService.hasError) {
error = _notificationService.error; error = _notificationService.error;
setState(ViewState.Error); setState(ViewState.Error);
} else } else {
setState(ViewState.Idle); setState(ViewState.Idle);
}
} }
Future markAsRead(id) async { Future markAsRead(id) async {
@ -30,10 +35,6 @@ class NotificationViewModel extends BaseViewModel {
MarkMessageAsReadRequestModel markMessageAsReadRequestModel = MarkMessageAsReadRequestModel markMessageAsReadRequestModel =
new MarkMessageAsReadRequestModel(notificationPoolID: id); new MarkMessageAsReadRequestModel(notificationPoolID: id);
await _notificationService.markAsRead(markMessageAsReadRequestModel); await _notificationService.markAsRead(markMessageAsReadRequestModel);
// if (_notificationService.hasError) { setState(ViewState.Idle);
// error = _notificationService.error;
// setState(ViewState.Error);
// } else
// 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/DrawerPages/notifications/notification_details_page.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.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/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
@ -45,7 +46,7 @@ class NotificationsPage extends StatelessWidget {
pagingSize: 14, pagingSize: 14,
notificationStatusID: 2); notificationStatusID: 2);
model.getNotifications(getNotificationsRequestModel); model.getNotifications(getNotificationsRequestModel, context);
}, },
builder: (_, model, widget) => AppScaffold( builder: (_, model, widget) => AppScaffold(
isShowAppBar: true, isShowAppBar: true,
@ -57,7 +58,7 @@ class NotificationsPage extends StatelessWidget {
(notification) => InkWell( (notification) => InkWell(
onTap: () async { onTap: () async {
if(!notification.isRead) if(!notification.isRead)
await model.markAsRead(notification.id); model.markAsRead(notification.id);
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
@ -120,7 +121,9 @@ class NotificationsPage extends StatelessWidget {
.toList() .toList()
..add( ..add(
InkWell( InkWell(
onTap: () { onTap: () async {
GifLoaderDialogUtils.showMyDialog(
context);
currentIndex++; currentIndex++;
GetNotificationsRequestModel GetNotificationsRequestModel
getNotificationsRequestModel = getNotificationsRequestModel =
@ -129,7 +132,10 @@ class NotificationsPage extends StatelessWidget {
pagingSize: 14, pagingSize: 14,
notificationStatusID: 2); notificationStatusID: 2);
model.getNotifications(getNotificationsRequestModel); await model.getNotifications(getNotificationsRequestModel,context);
GifLoaderDialogUtils.hideDialog(
context);
}, },
child: Center( child: Center(
child: Image.asset('assets/images/notf.png'), child: Image.asset('assets/images/notf.png'),

Loading…
Cancel
Save