From fb4c12d1a5a29dc51f49496f543fd6676c327839 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Thu, 19 Sep 2019 20:50:47 +0800 Subject: [PATCH] feat: adapter picker for material theme --- lib/models/theme.dart | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/models/theme.dart b/lib/models/theme.dart index 2882519..a5a9c41 100644 --- a/lib/models/theme.dart +++ b/lib/models/theme.dart @@ -190,12 +190,12 @@ class ThemeModel with ChangeNotifier { static Timer _debounce; - Future showPicker( + showPicker( BuildContext context, { @required T initialValue, @required List> items, @required Function(T item) onChange, - }) { + }) async { switch (theme) { case AppThemeMap.cupertino: return showCupertinoModalPopup( @@ -220,12 +220,18 @@ class ThemeModel with ChangeNotifier { }, ); default: - return showModalBottomSheet( + final value = await showMenu( context: context, - builder: (context) { - return null; // TODO: - }, + initialValue: initialValue, + items: items + .map((item) => + PopupMenuItem(value: item.value, child: Text(item.text))) + .toList(), + position: RelativeRect.fill, ); + if (value != null) { + onChange(value); + } } } }