mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 16:25:17 +00:00
Added the "My Page" button to the new app bar
This commit is contained in:
@ -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,
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user