diff options
| -rw-r--r-- | lib/components/AppContextMenu.dart | 29 | ||||
| -rw-r--r-- | lib/components/Option.dart | 30 | ||||
| -rw-r--r-- | lib/data/config.dart | 2 | ||||
| -rw-r--r-- | lib/pages/Home.dart | 69 |
4 files changed, 87 insertions, 43 deletions
diff --git a/lib/components/AppContextMenu.dart b/lib/components/AppContextMenu.dart index 72d67aa..d648d0c 100644 --- a/lib/components/AppContextMenu.dart +++ b/lib/components/AppContextMenu.dart @@ -5,34 +5,7 @@ import 'package:android_intent/flag.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../data/favorites.dart'; - -class Option extends StatelessWidget { - void Function() onTap; - Widget icon; - Widget child; - - Option({ this.child, this.icon, this.onTap }): super(); - - @override - build(BuildContext ctx) { - return Column( - children: [ - ListTile( - contentPadding: const EdgeInsets.symmetric(vertical: 0.0, horizontal: 16.0), - title: Row(children: [ - Container(width: 36.0, padding: EdgeInsets.only(right: 16.0), child: icon), - child, - ]), - onTap: () { - onTap(); - Navigator.pop(ctx); - }, - ), - Divider(height: 1.0), - ], - ); - } -} +import 'Option.dart'; class AppContextMenu extends StatelessWidget { final Application app; diff --git a/lib/components/Option.dart b/lib/components/Option.dart new file mode 100644 index 0000000..3460c8a --- /dev/null +++ b/lib/components/Option.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; + +class Option extends StatelessWidget { + void Function() onTap; + Widget icon; + Widget child; + + Option({ this.child, this.icon, this.onTap }): super(); + + @override + build(BuildContext ctx) { + return Column( + children: [ + ListTile( + contentPadding: const EdgeInsets.symmetric(vertical: 0.0, horizontal: 16.0), + title: Row(children: [ + Container(width: 36.0, padding: EdgeInsets.only(right: 16.0), child: icon), + child, + ]), + onTap: () { + onTap(); + Navigator.pop(ctx); + }, + ), + Divider(height: 1.0), + ], + ); + } +} + diff --git a/lib/data/config.dart b/lib/data/config.dart index 6bfd57f..01625d2 100644 --- a/lib/data/config.dart +++ b/lib/data/config.dart @@ -8,7 +8,7 @@ class Config { Config({ this.isDark }) {} bool isDarkMode() { - return isDark; + return isDark == null ? defaultDarkMode : isDark; } } diff --git a/lib/pages/Home.dart b/lib/pages/Home.dart index b812288..1ce6d01 100644 --- a/lib/pages/Home.dart +++ b/lib/pages/Home.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:device_apps/device_apps.dart'; +import '../components/Option.dart'; import '../components/AppList.dart'; import '../components/FixedContainer.dart'; import '../data/config.dart'; @@ -15,6 +16,47 @@ class StatusInfoCard extends StatelessWidget { final timeFormat = DateFormat('h:mm a'); // H fr 24 hrs final dateFormat = DateFormat('EEEE, d MMM'); + Widget buildOptionsMenu(BuildContext ctx) { + var theme = Theme.of(ctx); + + return Dialog( + child: Container( + decoration: BoxDecoration( + color: theme.backgroundColor, + ), + height: 120.0, + child: ListView( + children: [ + Option( + icon: Icon( + Icons.brightness_4, + color: theme.primaryColor, + size: 16.0, + semanticLabel: 'Toggle dark mode', + ), + child: Text('Toggle dark mode'), + onTap: toggleTheme, + ), + Option( + icon: Icon( + Icons.refresh, + color: theme.primaryColor, + size: 16.0, + semanticLabel: 'Refresh', + ), + child: Text('Refresh'), + onTap: () {}, + ), + ], + ), + ), + ); + } + + void showOptions(BuildContext ctx) { + showDialog(context: ctx, builder: buildOptionsMenu); + } + @override Widget build(BuildContext ctx) { ThemeData theme = Theme.of(ctx); @@ -53,20 +95,19 @@ class StatusInfoCard extends StatelessWidget { Container( width: 40, height: 30, - child: Text(''), - //child: IconButton( - //padding: const EdgeInsets.all(0.0), - //visualDensity: const VisualDensity(vertical: 0.0, horizontal: 0.0), - //icon: Icon( - //Icons.brightness_4, - //color: theme.primaryColor, - //size: 16.0, - //semanticLabel: 'Toggle dark mode', - //), - //tooltip: 'Toggle dark mode', - //enableFeedback: true, - //onPressed: () { toggleTheme(); } - //), + child: IconButton( + padding: const EdgeInsets.all(0.0), + visualDensity: const VisualDensity(vertical: 0.0, horizontal: 0.0), + icon: Icon( + Icons.more_vert, + color: theme.primaryColor, + size: 20.0, + semanticLabel: 'Options', + ), + tooltip: 'Options', + enableFeedback: true, + onPressed: () => showOptions(ctx), + ), ), ], ), |
