mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Ready to implement the list of notifications
This commit is contained in:
@ -3,6 +3,7 @@ import 'package:comunic/ui/routes/app_settings_route.dart';
|
||||
import 'package:comunic/ui/screens/conversations_list_screen.dart';
|
||||
import 'package:comunic/ui/screens/friends_list_screen.dart';
|
||||
import 'package:comunic/ui/screens/newest_posts.dart';
|
||||
import 'package:comunic/ui/screens/notifications_screen.dart';
|
||||
import 'package:comunic/ui/widgets/navbar_widget.dart';
|
||||
import 'package:comunic/utils/account_utils.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
@ -76,6 +77,9 @@ class _HomeRouteState extends State<HomeRoute> {
|
||||
/// Build the body of the application
|
||||
Widget _buildBody(BuildContext context) {
|
||||
switch (_currTab) {
|
||||
case BarCallbackActions.OPEN_NOTIFICATIONS:
|
||||
return NotificationsScreen();
|
||||
|
||||
case BarCallbackActions.OPEN_CONVERSATIONS:
|
||||
return ConversationsListScreen();
|
||||
|
||||
|
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(),
|
||||
);
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ typedef OnSelectMenuAction = void Function(BarCallbackActions);
|
||||
|
||||
/// Callback actions
|
||||
enum BarCallbackActions {
|
||||
OPEN_NOTIFICATIONS,
|
||||
OPEN_CONVERSATIONS,
|
||||
OPEN_NEWEST_POSTS,
|
||||
OPEN_FRIENDS,
|
||||
@ -20,6 +21,7 @@ enum BarCallbackActions {
|
||||
}
|
||||
|
||||
Color _primaryColor() => darkTheme() ? Colors.black : Colors.blue;
|
||||
|
||||
Color _secondaryColor() => darkTheme() ? darkAccentColor : Colors.white;
|
||||
|
||||
/// Menu item information
|
||||
@ -52,6 +54,10 @@ class _ActionMenuItem {
|
||||
|
||||
/// List of menu items to show
|
||||
final _menuItems = <_MenuItem>[
|
||||
_MenuItem(
|
||||
label: tr("Notifications"),
|
||||
icon: Icon(Icons.notifications),
|
||||
action: BarCallbackActions.OPEN_NOTIFICATIONS),
|
||||
_MenuItem(
|
||||
label: tr("Conversations"),
|
||||
icon: Icon(Icons.comment),
|
||||
|
Reference in New Issue
Block a user