1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-26 06:49:22 +00:00

Expose AppBarCustomDropDownWidget state to programmatically close dropdown

This commit is contained in:
Pierre HUBERT 2020-05-07 18:12:11 +02:00
parent 1750d6079e
commit 24e08d63f8
2 changed files with 15 additions and 4 deletions

View File

@ -24,11 +24,11 @@ class AppBarCustomDropDownWidget extends StatefulWidget {
super(key: key); super(key: key);
@override @override
_AppBarCustomDropDownWidgetState createState() => AppBarCustomDropDownWidgetState createState() =>
_AppBarCustomDropDownWidgetState(); AppBarCustomDropDownWidgetState();
} }
class _AppBarCustomDropDownWidgetState class AppBarCustomDropDownWidgetState
extends State<AppBarCustomDropDownWidget> { extends State<AppBarCustomDropDownWidget> {
bool _visible = false; bool _visible = false;

View File

@ -22,6 +22,9 @@ class ComunicTabletAppBarWidget extends StatefulWidget
class _ComunicTabletAppBarWidgetState class _ComunicTabletAppBarWidgetState
extends SafeState<ComunicTabletAppBarWidget> { extends SafeState<ComunicTabletAppBarWidget> {
final notificationsDropdownKey = GlobalKey<AppBarCustomDropDownWidgetState>();
final conversationsDropdownKey = GlobalKey<AppBarCustomDropDownWidgetState>();
var _unreadNotifications = var _unreadNotifications =
CountUnreadNotifications(notifications: 0, conversations: 0); CountUnreadNotifications(notifications: 0, conversations: 0);
@ -56,14 +59,22 @@ class _ComunicTabletAppBarWidgetState
title: Text("Comunic"), title: Text("Comunic"),
actions: <Widget>[ actions: <Widget>[
AppBarCustomDropDownWidget( AppBarCustomDropDownWidget(
key: notificationsDropdownKey,
icon: Icon(Icons.notifications), icon: Icon(Icons.notifications),
notificationsBadge: _unreadNotifications.notifications, notificationsBadge: _unreadNotifications.notifications,
onBuildOverlay: (c) => buildCenteredProgressBar(), onBuildOverlay: (c) => buildCenteredProgressBar(),
), ),
AppBarCustomDropDownWidget( AppBarCustomDropDownWidget(
key: conversationsDropdownKey,
icon: Icon(Icons.message), icon: Icon(Icons.message),
notificationsBadge: _unreadNotifications.conversations, notificationsBadge: _unreadNotifications.conversations,
onBuildOverlay: (c) => Text("hello world"), onBuildOverlay: (c) => Center(
child: RaisedButton(
child: Text("Close"),
onPressed: () =>
conversationsDropdownKey.currentState.toggleOverlay(),
),
),
), ),
PopupMenuButton(itemBuilder: (c) => []), PopupMenuButton(itemBuilder: (c) => []),
], ],