refactor(settings): use dropdown button instead of dropdown menu for smaller selections

This commit is contained in:
Kingkor Roy Tirtho 2023-04-07 10:07:31 +06:00
parent 54d5907f14
commit 80959aa0ca
3 changed files with 51 additions and 28 deletions

View File

@ -133,23 +133,23 @@ class SettingsPage extends HookConsumerWidget {
subtitle: const Text(
"Override responsive layout mode settings",
),
trailing: (context, update) => DropdownMenu<LayoutMode>(
dropdownMenuEntries: const [
DropdownMenuEntry(
trailing: (context, update) => DropdownButton<LayoutMode>(
items: const [
DropdownMenuItem(
value: LayoutMode.adaptive,
label: "Adaptive",
child: Text("Adaptive"),
),
DropdownMenuEntry(
DropdownMenuItem(
value: LayoutMode.compact,
label: "Compact",
child: Text("Compact"),
),
DropdownMenuEntry(
DropdownMenuItem(
value: LayoutMode.extended,
label: "Extended",
child: Text("Extended"),
),
],
initialSelection: preferences.layoutMode,
onSelected: (value) {
value: preferences.layoutMode,
onChanged: (value) {
if (value != null) {
preferences.setLayoutMode(value);
update?.call(() {});
@ -160,23 +160,23 @@ class SettingsPage extends HookConsumerWidget {
AdaptiveListTile(
leading: const Icon(SpotubeIcons.darkMode),
title: const Text("Theme"),
trailing: (context, update) => DropdownMenu<ThemeMode>(
initialSelection: preferences.themeMode,
dropdownMenuEntries: const [
DropdownMenuEntry(
trailing: (context, update) => DropdownButton<ThemeMode>(
value: preferences.themeMode,
items: const [
DropdownMenuItem(
value: ThemeMode.dark,
label: "Dark",
child: Text("Dark"),
),
DropdownMenuEntry(
DropdownMenuItem(
value: ThemeMode.light,
label: "Light",
child: Text("Light"),
),
DropdownMenuEntry(
DropdownMenuItem(
value: ThemeMode.system,
label: "System",
child: Text("System"),
),
],
onSelected: (value) {
onChanged: (value) {
if (value != null) {
preferences.setThemeMode(value);
update?.call(() {});
@ -214,19 +214,20 @@ class SettingsPage extends HookConsumerWidget {
AdaptiveListTile(
leading: const Icon(SpotubeIcons.audioQuality),
title: const Text("Audio Quality"),
trailing: (context, update) => DropdownMenu<AudioQuality>(
initialSelection: preferences.audioQuality,
dropdownMenuEntries: const [
DropdownMenuEntry(
trailing: (context, update) =>
DropdownButton<AudioQuality>(
value: preferences.audioQuality,
items: const [
DropdownMenuItem(
value: AudioQuality.high,
label: "High",
child: Text("High"),
),
DropdownMenuEntry(
DropdownMenuItem(
value: AudioQuality.low,
label: "Low",
child: Text("Low"),
),
],
onSelected: (value) {
onChanged: (value) {
if (value != null) {
preferences.setAudioQuality(value);
update?.call(() {});

View File

@ -17,6 +17,23 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.4.0"
animate_gradient:
dependency: "direct main"
description:
path: "."
ref: "2e02ab5d1cb60fc172a5f15f6e91bd34a050af23"
resolved-ref: "2e02ab5d1cb60fc172a5f15f6e91bd34a050af23"
url: "https://github.com/Vikaskumar75/Animated-Gradient"
source: git
version: "0.0.2"
animated_gradient:
dependency: "direct main"
description:
name: animated_gradient
sha256: "9c0c52a093817ae42550e3affec6973a7bae7186d1d5d58749ca9689da3ba245"
url: "https://pub.dev"
source: hosted
version: "0.0.2"
app_package_maker:
dependency: transitive
description:

View File

@ -9,6 +9,11 @@ environment:
sdk: ">=2.17.0 <3.0.0"
dependencies:
animate_gradient:
git:
url: https://github.com/Vikaskumar75/Animated-Gradient
ref: 2e02ab5d1cb60fc172a5f15f6e91bd34a050af23
animated_gradient: ^0.0.2
args: ^2.3.2
async: ^2.9.0
audio_service: ^0.18.9