mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-25 22:39:22 +00:00
Added the "My Page" button to the new app bar
This commit is contained in:
parent
c3f230efc3
commit
73a94f5358
@ -3,7 +3,9 @@ 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/widgets/navbar_widget.dart';
|
||||
import 'package:comunic/utils/account_utils.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:comunic/utils/navigation_utils.dart';
|
||||
import 'package:comunic/utils/ui_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@ -42,6 +44,13 @@ class _HomeRouteState extends State<HomeRoute> {
|
||||
void _onTap(BarCallbackActions action) {
|
||||
/// Check more quick actions
|
||||
switch (action) {
|
||||
|
||||
/// Open current user page
|
||||
case BarCallbackActions.OPEN_MY_PAGE:
|
||||
_openCurrentUserPage();
|
||||
break;
|
||||
|
||||
/// Logout user
|
||||
case BarCallbackActions.ACTION_LOGOUT:
|
||||
_logoutRequested();
|
||||
break;
|
||||
@ -97,6 +106,11 @@ class _HomeRouteState extends State<HomeRoute> {
|
||||
);
|
||||
}
|
||||
|
||||
/// Open current user page
|
||||
Future<void> _openCurrentUserPage() async {
|
||||
openUserPage(context: context, userID: userID());
|
||||
}
|
||||
|
||||
/// Handle logout requests from user
|
||||
Future<void> _logoutRequested() async {
|
||||
if (!await showConfirmDialog(
|
||||
@ -106,7 +120,7 @@ class _HomeRouteState extends State<HomeRoute> {
|
||||
|
||||
await AccountHelper().signOut();
|
||||
|
||||
Navigator.pushReplacement(context, MaterialPageRoute(builder: (c){
|
||||
Navigator.pushReplacement(context, MaterialPageRoute(builder: (c) {
|
||||
return LoginRoute();
|
||||
}));
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ enum BarCallbackActions {
|
||||
OPEN_CONVERSATIONS,
|
||||
OPEN_NEWEST_POSTS,
|
||||
OPEN_FRIENDS,
|
||||
OPEN_MY_PAGE,
|
||||
NONE,
|
||||
ACTION_LOGOUT
|
||||
}
|
||||
@ -37,6 +38,16 @@ class _MenuItem {
|
||||
assert(isMenu != null);
|
||||
}
|
||||
|
||||
/// Item of action menu
|
||||
class _ActionMenuItem {
|
||||
final String label;
|
||||
final BarCallbackActions action;
|
||||
|
||||
const _ActionMenuItem({@required this.label, @required this.action})
|
||||
: assert(label != null),
|
||||
assert(action != null);
|
||||
}
|
||||
|
||||
/// List of menu items to show
|
||||
final _menuItems = <_MenuItem>[
|
||||
_MenuItem(
|
||||
@ -58,6 +69,14 @@ final _menuItems = <_MenuItem>[
|
||||
action: BarCallbackActions.NONE)
|
||||
];
|
||||
|
||||
/// List of menu actions items
|
||||
final _menuActionsItem = <_ActionMenuItem>[
|
||||
_ActionMenuItem(
|
||||
label: tr("My Page"), action: BarCallbackActions.OPEN_MY_PAGE),
|
||||
_ActionMenuItem(
|
||||
label: tr("Sign out"), action: BarCallbackActions.ACTION_LOGOUT),
|
||||
];
|
||||
|
||||
/// Public widget
|
||||
class ComunicAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final OnSelectMenuAction onTap;
|
||||
@ -140,12 +159,12 @@ class _MenuItemWidget extends StatelessWidget {
|
||||
Widget _buildContextMenuPopupButton() {
|
||||
return PopupMenuButton<BarCallbackActions>(
|
||||
child: _buildIconContainer(),
|
||||
itemBuilder: (i) => [
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Logout")),
|
||||
value: BarCallbackActions.ACTION_LOGOUT,
|
||||
)
|
||||
],
|
||||
itemBuilder: (i) => _menuActionsItem
|
||||
.map((f) => PopupMenuItem(
|
||||
child: Text(f.label),
|
||||
value: f.action,
|
||||
))
|
||||
.toList(),
|
||||
onSelected: onTap,
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user