From 41c8619739feb5a4d49d53661538a85a4b9ed2f0 Mon Sep 17 00:00:00 2001 From: Frederik Feichtmeier Date: Wed, 29 Jun 2022 13:02:50 +0200 Subject: [PATCH] Make color selection UI screen size adaptive (#187) --- example/lib/view/home_page.dart | 48 +++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/example/lib/view/home_page.dart b/example/lib/view/home_page.dart index 16a36e1c8..3ba083033 100644 --- a/example/lib/view/home_page.dart +++ b/example/lib/view/home_page.dart @@ -61,21 +61,41 @@ class _HomePageState extends State { ), ), actions: [ - ColorDisk( - color: theme.themeMode == ThemeMode.light - ? Colors.black - : Colors.white, - selected: theme.highContrast == true, - onPressed: () => AppTheme.apply(context, highContrast: true)), - for (final variant in YaruVariant.values.take(10)) // skip flavors - ColorDisk( - color: variant.color, - selected: variant == theme.variant && theme.highContrast != true, - onPressed: () => AppTheme.apply(context, - variant: variant, highContrast: false), + PopupMenuButton( + onSelected: (value) {}, + child: SizedBox( + width: 40, + child: Icon( + Icons.color_lens, + color: Theme.of(context).primaryColor, + ), ), - SizedBox( - width: 20, + itemBuilder: (context) { + return [ + PopupMenuItem( + onTap: () => AppTheme.apply(context, highContrast: true), + child: ColorDisk( + color: theme.themeMode == ThemeMode.light + ? Colors.black + : Colors.white, + selected: theme.highContrast == true, + onPressed: () {}, + ), + ), + for (final variant + in YaruVariant.values.take(10)) // skip flavors + PopupMenuItem( + onTap: () => AppTheme.apply(context, + variant: variant, highContrast: false), + child: ColorDisk( + color: variant.color, + selected: variant == theme.variant && + theme.highContrast != true, + onPressed: () {}, + ), + ) + ]; + }, ), ], ),