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