|
|
|
|
|
|
|
|
} else if (state is NotiSuccess) { |
|
|
} else if (state is NotiSuccess) { |
|
|
updateCountNotiBloc.getNotifications((data) {}, (err) {}); |
|
|
updateCountNotiBloc.getNotifications((data) {}, (err) {}); |
|
|
if (state.items.isEmpty) { |
|
|
if (state.items.isEmpty) { |
|
|
return Column( |
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
|
children: [ |
|
|
|
|
|
SizedBox( |
|
|
|
|
|
height: 8, |
|
|
|
|
|
), |
|
|
|
|
|
Padding( |
|
|
|
|
|
padding: const EdgeInsets.all(8.0), |
|
|
|
|
|
child: Text('Thông báo', |
|
|
|
|
|
style: |
|
|
|
|
|
TextStyle(fontWeight: FontWeight.w500, fontSize: 22)), |
|
|
|
|
|
), |
|
|
|
|
|
Expanded( |
|
|
|
|
|
child: Center(child: Text("Không có thông báo")), |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
|
|
|
return SafeArea( |
|
|
|
|
|
child: Column( |
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
|
children: [ |
|
|
|
|
|
SizedBox( |
|
|
|
|
|
height: 8, |
|
|
|
|
|
), |
|
|
|
|
|
Padding( |
|
|
|
|
|
padding: const EdgeInsets.all(8.0), |
|
|
|
|
|
child: Text('Thông báo', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontWeight: FontWeight.w500, fontSize: 22)), |
|
|
|
|
|
), |
|
|
|
|
|
Expanded( |
|
|
|
|
|
child: Center(child: Text("Không có thông báo")), |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
currentItems = List<NotificationDTO>.from(state.items); |
|
|
currentItems = List<NotificationDTO>.from(state.items); |
|
|
currentPage = state.page; |
|
|
currentPage = state.page; |
|
|
currentHasReachedMax = state.hasReachedMax; |
|
|
currentHasReachedMax = state.hasReachedMax; |
|
|
|
|
|
|
|
|
return Column( |
|
|
|
|
|
children: <Widget>[ |
|
|
|
|
|
Container( |
|
|
|
|
|
padding: EdgeInsets.all(8), |
|
|
|
|
|
color: Colors.white, |
|
|
|
|
|
child: Row( |
|
|
|
|
|
children: [ |
|
|
|
|
|
SizedBox( |
|
|
|
|
|
height: 8, |
|
|
|
|
|
), |
|
|
|
|
|
Expanded( |
|
|
|
|
|
child: Text( |
|
|
|
|
|
'Thông báo', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontWeight: FontWeight.w500, fontSize: 22), |
|
|
|
|
|
)), |
|
|
|
|
|
FlatButton( |
|
|
|
|
|
onPressed: () { |
|
|
|
|
|
notiBloc |
|
|
|
|
|
.add(MarkAllNotificationUpdate(status: "1")); |
|
|
|
|
|
|
|
|
return SafeArea( |
|
|
|
|
|
child: Column( |
|
|
|
|
|
children: <Widget>[ |
|
|
|
|
|
Container( |
|
|
|
|
|
padding: EdgeInsets.all(8), |
|
|
|
|
|
color: Colors.white, |
|
|
|
|
|
child: Row( |
|
|
|
|
|
children: [ |
|
|
|
|
|
SizedBox( |
|
|
|
|
|
height: 8, |
|
|
|
|
|
), |
|
|
|
|
|
Expanded( |
|
|
|
|
|
child: Text( |
|
|
|
|
|
'Thông báo', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontWeight: FontWeight.w500, fontSize: 22), |
|
|
|
|
|
)), |
|
|
|
|
|
FlatButton( |
|
|
|
|
|
onPressed: () { |
|
|
|
|
|
notiBloc |
|
|
|
|
|
.add(MarkAllNotificationUpdate(status: "1")); |
|
|
|
|
|
}, |
|
|
|
|
|
child: Text('Đánh dấu đã đọc tất cả', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontWeight: FontWeight.normal, |
|
|
|
|
|
fontSize: 14, |
|
|
|
|
|
color: Colors.blue))) |
|
|
|
|
|
], |
|
|
|
|
|
)), |
|
|
|
|
|
Expanded( |
|
|
|
|
|
child: RefreshIndicator( |
|
|
|
|
|
child: ListView.builder( |
|
|
|
|
|
physics: AlwaysScrollableScrollPhysics(), |
|
|
|
|
|
itemBuilder: (BuildContext context, int index) { |
|
|
|
|
|
return index >= state.items.length |
|
|
|
|
|
? BottomLoader() |
|
|
|
|
|
: ItemInfinityWidget( |
|
|
|
|
|
notiBloc: notiBloc, |
|
|
|
|
|
unread: state.unread, |
|
|
|
|
|
read: state.read, |
|
|
|
|
|
currentItems: currentItems, |
|
|
|
|
|
item: state.items[index], |
|
|
|
|
|
currentPage: state.page, |
|
|
|
|
|
currentReachedMax: state.hasReachedMax, |
|
|
|
|
|
); |
|
|
}, |
|
|
}, |
|
|
child: Text('Đánh dấu đã đọc tất cả', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontWeight: FontWeight.normal, |
|
|
|
|
|
fontSize: 14, |
|
|
|
|
|
color: Colors.blue))) |
|
|
|
|
|
], |
|
|
|
|
|
)), |
|
|
|
|
|
Expanded( |
|
|
|
|
|
child: RefreshIndicator( |
|
|
|
|
|
child: ListView.builder( |
|
|
|
|
|
physics: AlwaysScrollableScrollPhysics(), |
|
|
|
|
|
itemBuilder: (BuildContext context, int index) { |
|
|
|
|
|
return index >= state.items.length |
|
|
|
|
|
? BottomLoader() |
|
|
|
|
|
: ItemInfinityWidget( |
|
|
|
|
|
notiBloc: notiBloc, |
|
|
|
|
|
unread: state.unread, |
|
|
|
|
|
read: state.read, |
|
|
|
|
|
currentItems: currentItems, |
|
|
|
|
|
item: state.items[index], |
|
|
|
|
|
currentPage: state.page, |
|
|
|
|
|
currentReachedMax: state.hasReachedMax, |
|
|
|
|
|
); |
|
|
|
|
|
}, |
|
|
|
|
|
itemCount: state.hasReachedMax |
|
|
|
|
|
? state.items.length |
|
|
|
|
|
: state.items.length + 1, |
|
|
|
|
|
controller: _scrollController, |
|
|
|
|
|
), |
|
|
|
|
|
onRefresh: () async { |
|
|
|
|
|
notiBloc.add(OnRefresh()); |
|
|
|
|
|
})) |
|
|
|
|
|
], |
|
|
|
|
|
|
|
|
itemCount: state.hasReachedMax |
|
|
|
|
|
? state.items.length |
|
|
|
|
|
: state.items.length + 1, |
|
|
|
|
|
controller: _scrollController, |
|
|
|
|
|
), |
|
|
|
|
|
onRefresh: () async { |
|
|
|
|
|
notiBloc.add(OnRefresh()); |
|
|
|
|
|
})) |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
); |
|
|
); |
|
|
} else if (state is NotiLoadding) { |
|
|
} else if (state is NotiLoadding) { |
|
|
return Center( |
|
|
return Center( |