mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-26 06:49:22 +00:00
Can logout in tablet mode
This commit is contained in:
parent
4c749ec6ac
commit
39f4e8c78c
@ -6,6 +6,7 @@ import 'package:comunic/ui/screens/notifications_screen.dart';
|
||||
import 'package:comunic/ui/screens/unread_conversations_screen.dart';
|
||||
import 'package:comunic/ui/widgets/safe_state.dart';
|
||||
import 'package:comunic/ui/widgets/tablet_mode/appbar_custom_dropdown_widget.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Comunic tablet AppBar widget
|
||||
@ -80,8 +81,53 @@ class _ComunicTabletAppBarWidgetState
|
||||
child: UnreadConversationsScreen(),
|
||||
),
|
||||
),
|
||||
PopupMenuButton(itemBuilder: (c) => []),
|
||||
PopupMenuButton<_MenuItemCallback>(
|
||||
offset: Offset(0, 50),
|
||||
itemBuilder: (c) => [
|
||||
_MainMenuItem(
|
||||
label: tr("Sign out"),
|
||||
icon: Icons.power_settings_new,
|
||||
onTap: () => MainController.of(context).requestLogout()),
|
||||
],
|
||||
onSelected: (v) => v(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
typedef _MenuItemCallback = void Function();
|
||||
|
||||
class _MainMenuItem extends PopupMenuEntry<_MenuItemCallback> {
|
||||
final String label;
|
||||
final IconData icon;
|
||||
final _MenuItemCallback onTap;
|
||||
|
||||
const _MainMenuItem({
|
||||
@required this.label,
|
||||
@required this.icon,
|
||||
@required this.onTap,
|
||||
}) : assert(label != null),
|
||||
assert(icon != null),
|
||||
assert(onTap != null);
|
||||
|
||||
@override
|
||||
__MainMenuItemState createState() => __MainMenuItemState();
|
||||
|
||||
@override
|
||||
double get height => kMinInteractiveDimension;
|
||||
|
||||
@override
|
||||
bool represents(_MenuItemCallback value) => onTap == value;
|
||||
}
|
||||
|
||||
class __MainMenuItemState extends State<_MainMenuItem> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
leading: Icon(widget.icon),
|
||||
title: Text(widget.label),
|
||||
onTap: () => Navigator.of(context).pop(widget.onTap),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user