1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-25 22:39:22 +00:00

Show a notification when the user has no notification to show

This commit is contained in:
Pierre HUBERT 2019-11-01 15:48:02 +01:00
parent 0b204afff9
commit 32c15ae915

View File

@ -42,6 +42,8 @@ class _NotificationsScreenState extends State<NotificationsScreen> {
_users = users;
_groups = groups;
});
setStatus(_Status.NONE);
} on Exception catch (e) {
print("Exception while getting the list of notifications!");
print(e);
@ -59,6 +61,28 @@ class _NotificationsScreenState extends State<NotificationsScreen> {
@override
Widget build(BuildContext context) {
// Loading status
if (_list == null || _status == _Status.LOADING)
return Center(
child: CircularProgressIndicator(),
);
return Column(
children: [
Expanded(
child: RefreshIndicator(
child: SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
child: _buildBody(),
),
onRefresh: _loadList),
)
],
);
}
/// Build body
Widget _buildBody() {
// In case of error
if (_status == _Status.ERROR)
return buildErrorCard(tr("Could not get the list of notifications!"),
@ -69,10 +93,13 @@ class _NotificationsScreenState extends State<NotificationsScreen> {
)
]);
// Loading status
if (_list == null || _status == _Status.LOADING)
return Center(
child: CircularProgressIndicator(),
// When there is no notification
if (_list.length == 0)
return Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Text(tr("You do not have any notification now.")),
),
);
}
}