mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Create application preferences route
This commit is contained in:
parent
a998ce13a3
commit
c367939ab6
31
lib/ui/routes/app_settings_route.dart
Normal file
31
lib/ui/routes/app_settings_route.dart
Normal file
@ -0,0 +1,31 @@
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Application settings route
|
||||
///
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
class AppSettingsRoute extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(tr("App settings")),
|
||||
),
|
||||
body: _AppSettingsBody(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _AppSettingsBody extends StatefulWidget {
|
||||
@override
|
||||
__AppSettingsBodyState createState() => __AppSettingsBodyState();
|
||||
}
|
||||
|
||||
class __AppSettingsBodyState extends State<_AppSettingsBody> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView(children: <Widget>[],);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:comunic/helpers/account_helper.dart';
|
||||
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';
|
||||
@ -50,6 +51,11 @@ class _HomeRouteState extends State<HomeRoute> {
|
||||
_openCurrentUserPage();
|
||||
break;
|
||||
|
||||
/// Open app settings page
|
||||
case BarCallbackActions.OPEN_APP_SETTINGS:
|
||||
_openAppSettings();
|
||||
break;
|
||||
|
||||
/// Logout user
|
||||
case BarCallbackActions.ACTION_LOGOUT:
|
||||
_logoutRequested();
|
||||
@ -111,6 +117,11 @@ class _HomeRouteState extends State<HomeRoute> {
|
||||
openUserPage(context: context, userID: userID());
|
||||
}
|
||||
|
||||
void _openAppSettings() {
|
||||
Navigator.of(context)
|
||||
.push(MaterialPageRoute(builder: (c) => AppSettingsRoute()));
|
||||
}
|
||||
|
||||
/// Handle logout requests from user
|
||||
Future<void> _logoutRequested() async {
|
||||
if (!await showConfirmDialog(
|
||||
|
@ -13,6 +13,7 @@ enum BarCallbackActions {
|
||||
OPEN_NEWEST_POSTS,
|
||||
OPEN_FRIENDS,
|
||||
OPEN_MY_PAGE,
|
||||
OPEN_APP_SETTINGS,
|
||||
NONE,
|
||||
ACTION_LOGOUT
|
||||
}
|
||||
@ -27,12 +28,12 @@ class _MenuItem {
|
||||
final BarCallbackActions action;
|
||||
final bool isMenu;
|
||||
|
||||
const _MenuItem(
|
||||
{@required this.label,
|
||||
@required this.icon,
|
||||
@required this.action,
|
||||
this.isMenu = false})
|
||||
: assert(label != null),
|
||||
const _MenuItem({
|
||||
@required this.label,
|
||||
@required this.icon,
|
||||
@required this.action,
|
||||
this.isMenu = false,
|
||||
}) : assert(label != null),
|
||||
assert(icon != null || isMenu),
|
||||
assert(action != null),
|
||||
assert(isMenu != null);
|
||||
@ -73,6 +74,8 @@ final _menuItems = <_MenuItem>[
|
||||
final _menuActionsItem = <_ActionMenuItem>[
|
||||
_ActionMenuItem(
|
||||
label: tr("My Page"), action: BarCallbackActions.OPEN_MY_PAGE),
|
||||
_ActionMenuItem(
|
||||
label: tr("App settings"), action: BarCallbackActions.OPEN_APP_SETTINGS),
|
||||
_ActionMenuItem(
|
||||
label: tr("Sign out"), action: BarCallbackActions.ACTION_LOGOUT),
|
||||
];
|
||||
@ -96,10 +99,10 @@ class ComunicAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
children: List.generate(
|
||||
_menuItems.length,
|
||||
(i) => _MenuItemWidget(
|
||||
item: _menuItems[i],
|
||||
onTap: onTap,
|
||||
isSelected: _menuItems[i].action == selectedAction,
|
||||
),
|
||||
item: _menuItems[i],
|
||||
onTap: onTap,
|
||||
isSelected: _menuItems[i].action == selectedAction,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user