mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-09-18 21:38:48 +00:00
Ready to implement the list of notifications
This commit is contained in:
46
lib/ui/screens/notifications_screen.dart
Normal file
46
lib/ui/screens/notifications_screen.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:comunic/lists/notifications_list.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:comunic/utils/ui_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Notifications screen
|
||||
///
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
enum _Status { LOADING, ERROR, NONE }
|
||||
|
||||
class NotificationsScreen extends StatefulWidget {
|
||||
@override
|
||||
_NotificationsScreenState createState() => _NotificationsScreenState();
|
||||
}
|
||||
|
||||
class _NotificationsScreenState extends State<NotificationsScreen> {
|
||||
NotificationsList _list;
|
||||
_Status _status = _Status.LOADING;
|
||||
|
||||
void setStatus(_Status s) => setState(() => _status = s);
|
||||
|
||||
Future<void> _loadList() async {
|
||||
setStatus(_Status.LOADING);
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// In case of error
|
||||
if (_status == _Status.ERROR)
|
||||
return buildErrorCard(tr("Could not get the list of notifications!"),
|
||||
actions: [
|
||||
MaterialButton(
|
||||
onPressed: () => _loadList(),
|
||||
child: Text(tr("Try again".toUpperCase())),
|
||||
)
|
||||
]);
|
||||
|
||||
// Loading status
|
||||
if (_list == null || _status == _Status.LOADING)
|
||||
return Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user