From 24e08d63f80fbb2598f668ab773f62e58e8d0450 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 7 May 2020 18:12:11 +0200 Subject: [PATCH] Expose AppBarCustomDropDownWidget state to programmatically close dropdown --- .../tablet_mode/appbar_custom_dropdown_widget.dart | 6 +++--- .../widgets/tablet_mode/tablet_appbar_widget.dart | 13 ++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/ui/widgets/tablet_mode/appbar_custom_dropdown_widget.dart b/lib/ui/widgets/tablet_mode/appbar_custom_dropdown_widget.dart index 77923ee..80c3b4e 100644 --- a/lib/ui/widgets/tablet_mode/appbar_custom_dropdown_widget.dart +++ b/lib/ui/widgets/tablet_mode/appbar_custom_dropdown_widget.dart @@ -24,11 +24,11 @@ class AppBarCustomDropDownWidget extends StatefulWidget { super(key: key); @override - _AppBarCustomDropDownWidgetState createState() => - _AppBarCustomDropDownWidgetState(); + AppBarCustomDropDownWidgetState createState() => + AppBarCustomDropDownWidgetState(); } -class _AppBarCustomDropDownWidgetState +class AppBarCustomDropDownWidgetState extends State { bool _visible = false; diff --git a/lib/ui/widgets/tablet_mode/tablet_appbar_widget.dart b/lib/ui/widgets/tablet_mode/tablet_appbar_widget.dart index f176b96..7cdc5c6 100644 --- a/lib/ui/widgets/tablet_mode/tablet_appbar_widget.dart +++ b/lib/ui/widgets/tablet_mode/tablet_appbar_widget.dart @@ -22,6 +22,9 @@ class ComunicTabletAppBarWidget extends StatefulWidget class _ComunicTabletAppBarWidgetState extends SafeState { + final notificationsDropdownKey = GlobalKey(); + final conversationsDropdownKey = GlobalKey(); + var _unreadNotifications = CountUnreadNotifications(notifications: 0, conversations: 0); @@ -56,14 +59,22 @@ class _ComunicTabletAppBarWidgetState title: Text("Comunic"), actions: [ AppBarCustomDropDownWidget( + key: notificationsDropdownKey, icon: Icon(Icons.notifications), notificationsBadge: _unreadNotifications.notifications, onBuildOverlay: (c) => buildCenteredProgressBar(), ), AppBarCustomDropDownWidget( + key: conversationsDropdownKey, icon: Icon(Icons.message), notificationsBadge: _unreadNotifications.conversations, - onBuildOverlay: (c) => Text("hello world"), + onBuildOverlay: (c) => Center( + child: RaisedButton( + child: Text("Close"), + onPressed: () => + conversationsDropdownKey.currentState.toggleOverlay(), + ), + ), ), PopupMenuButton(itemBuilder: (c) => []), ],