From 3076b8eb2650299bc47e88d3aa74bbfa743aef67 Mon Sep 17 00:00:00 2001 From: hackerhgl Date: Sun, 27 Sep 2020 13:14:28 +0500 Subject: [PATCH] Connected settings open in drawer --- .../HomeScreen/widgets/Drawer/HomeDrawer.dart | 12 +++++++++++ .../widgets/Drawer/HomeDrawerButton.dart | 8 ++++--- .../HomeScreen/widgets/Drawer/data.dart | 21 +++++++++++++------ 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/lib/screens/HomeScreen/widgets/Drawer/HomeDrawer.dart b/lib/screens/HomeScreen/widgets/Drawer/HomeDrawer.dart index c29dd23..d40ecad 100644 --- a/lib/screens/HomeScreen/widgets/Drawer/HomeDrawer.dart +++ b/lib/screens/HomeScreen/widgets/Drawer/HomeDrawer.dart @@ -69,6 +69,16 @@ class _HomeDrawerState extends State with AnimationMixin { } } + void buttonHandler(data.NavigationKey key) { + switch (key) { + case data.NavigationKey.settings: + Provider.of(context, listen: false) + .isSettingsOpen = true; + break; + default: + } + } + @override Widget build(BuildContext context) { final state = Provider.of(context, listen: false); @@ -135,6 +145,8 @@ class _HomeDrawerState extends State with AnimationMixin { .map( (entry) => HomeDrawerButton( entry: entry, + onPressed: () => this.buttonHandler( + entry.value["key"]), baseAnimation: this.animation.value, ), ) diff --git a/lib/screens/HomeScreen/widgets/Drawer/HomeDrawerButton.dart b/lib/screens/HomeScreen/widgets/Drawer/HomeDrawerButton.dart index 86b6813..a2d1d2e 100644 --- a/lib/screens/HomeScreen/widgets/Drawer/HomeDrawerButton.dart +++ b/lib/screens/HomeScreen/widgets/Drawer/HomeDrawerButton.dart @@ -8,12 +8,14 @@ enum AnimProp { opacity } class HomeDrawerButton extends StatelessWidget { HomeDrawerButton({ + @required this.entry, + @required this.onPressed, @required this.baseAnimation, - @required MapEntry> this.entry, }); final double baseAnimation; - final MapEntry> entry; + final VoidCallback onPressed; + final MapEntry> entry; @override Widget build(BuildContext context) { @@ -47,7 +49,7 @@ class HomeDrawerButton extends StatelessWidget { horizontal: AppDimensions.padding * 2, ), child: RaisedButton( - onPressed: () {}, + onPressed: this.onPressed, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(4.0), ), diff --git a/lib/screens/HomeScreen/widgets/Drawer/data.dart b/lib/screens/HomeScreen/widgets/Drawer/data.dart index c3e71e0..9c2251b 100644 --- a/lib/screens/HomeScreen/widgets/Drawer/data.dart +++ b/lib/screens/HomeScreen/widgets/Drawer/data.dart @@ -1,28 +1,37 @@ import '../../messages/keys.dart'; +enum NavigationKey { + home, + moies, + developer, + designer, + download, + settings, +} + final list = [ { "label": HomeScreenMessages.drawerHome, - "key": "home", + "key": NavigationKey.home, }, { "label": HomeScreenMessages.drawerMovies, - "key": "moies", + "key": NavigationKey.moies, }, { "label": HomeScreenMessages.drawerDeveloper, - "key": "developer", + "key": NavigationKey.developer, }, { "label": HomeScreenMessages.drawerDesigner, - "key": "developer", + "key": NavigationKey.designer, }, { "label": HomeScreenMessages.drawerDownload, - "key": "download", + "key": NavigationKey.download, }, { "label": HomeScreenMessages.drawerSettings, - "key": "settings", + "key": NavigationKey.settings, }, ];