mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
fix(adaptive-list-tile): dialog content not updating when content has changed
This commit is contained in:
parent
307a8e21df
commit
a1d423090c
@ -66,7 +66,7 @@ class Settings extends HookConsumerWidget {
|
||||
AdaptiveListTile(
|
||||
leading: const Icon(Icons.dark_mode_outlined),
|
||||
title: const Text("Theme"),
|
||||
trailing: DropdownButton<ThemeMode>(
|
||||
trailing: (context, update) => DropdownButton<ThemeMode>(
|
||||
value: preferences.themeMode,
|
||||
items: const [
|
||||
DropdownMenuItem(
|
||||
@ -89,6 +89,7 @@ class Settings extends HookConsumerWidget {
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
preferences.setThemeMode(value);
|
||||
update?.call(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
@ -131,7 +132,7 @@ class Settings extends HookConsumerWidget {
|
||||
"Recommendation Country",
|
||||
style: Theme.of(context).textTheme.caption,
|
||||
),
|
||||
trailing: ConstrainedBox(
|
||||
trailing: (context, update) => ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 250),
|
||||
child: DropdownButton(
|
||||
isExpanded: true,
|
||||
@ -149,6 +150,7 @@ class Settings extends HookConsumerWidget {
|
||||
preferences.setRecommendationMarket(
|
||||
value as String,
|
||||
);
|
||||
update?.call(() {});
|
||||
},
|
||||
),
|
||||
),
|
||||
@ -171,7 +173,7 @@ class Settings extends HookConsumerWidget {
|
||||
),
|
||||
subtitle: const Text("(Case sensitive)"),
|
||||
breakOn: Breakpoints.lg,
|
||||
trailing: ConstrainedBox(
|
||||
trailing: (context, update) => ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 450),
|
||||
child: TextField(
|
||||
controller: ytSearchFormatController,
|
||||
@ -188,6 +190,7 @@ class Settings extends HookConsumerWidget {
|
||||
),
|
||||
onSubmitted: (value) {
|
||||
preferences.setYtSearchFormat(value);
|
||||
update?.call(() {});
|
||||
},
|
||||
),
|
||||
),
|
||||
@ -228,7 +231,7 @@ class Settings extends HookConsumerWidget {
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
),
|
||||
trailing: ElevatedButton(
|
||||
trailing: (context, update) => ElevatedButton(
|
||||
child: Text("Connect with Spotify".toUpperCase()),
|
||||
onPressed: () {
|
||||
GoRouter.of(context).push("/login");
|
||||
@ -258,7 +261,8 @@ class Settings extends HookConsumerWidget {
|
||||
"Track Match Algorithm",
|
||||
maxLines: 1,
|
||||
),
|
||||
trailing: DropdownButton<SpotubeTrackMatchAlgorithm>(
|
||||
trailing: (context, update) =>
|
||||
DropdownButton<SpotubeTrackMatchAlgorithm>(
|
||||
value: preferences.trackMatchAlgorithm,
|
||||
items: const [
|
||||
DropdownMenuItem(
|
||||
@ -281,6 +285,7 @@ class Settings extends HookConsumerWidget {
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
preferences.setTrackMatchAlgorithm(value);
|
||||
update?.call(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
@ -288,7 +293,8 @@ class Settings extends HookConsumerWidget {
|
||||
AdaptiveListTile(
|
||||
leading: const Icon(Icons.multitrack_audio_rounded),
|
||||
title: const Text("Audio Quality"),
|
||||
trailing: DropdownButton<AudioQuality>(
|
||||
trailing: (context, update) =>
|
||||
DropdownButton<AudioQuality>(
|
||||
value: preferences.audioQuality,
|
||||
items: const [
|
||||
DropdownMenuItem(
|
||||
@ -305,6 +311,7 @@ class Settings extends HookConsumerWidget {
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
preferences.setAudioQuality(value);
|
||||
update?.call(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
@ -346,7 +353,7 @@ class Settings extends HookConsumerWidget {
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
trailing: ElevatedButton.icon(
|
||||
trailing: (context, update) => ElevatedButton.icon(
|
||||
icon: const Icon(Icons.favorite_outline_rounded),
|
||||
label: const Text("Please Sponsor/Donate"),
|
||||
style: ElevatedButton.styleFrom(
|
||||
@ -355,8 +362,10 @@ class Settings extends HookConsumerWidget {
|
||||
padding: const EdgeInsets.all(15),
|
||||
),
|
||||
onPressed: () {
|
||||
launchUrlString("https://opencollective.com/spotube",
|
||||
mode: LaunchMode.externalApplication);
|
||||
launchUrlString(
|
||||
"https://opencollective.com/spotube",
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -3,7 +3,7 @@ import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:spotube/hooks/useBreakpoints.dart';
|
||||
|
||||
class AdaptiveListTile extends HookWidget {
|
||||
final Widget? trailing;
|
||||
final Widget Function(BuildContext, StateSetter?)? trailing;
|
||||
final Widget? title;
|
||||
final Widget? subtitle;
|
||||
final Widget? leading;
|
||||
@ -27,7 +27,8 @@ class AdaptiveListTile extends HookWidget {
|
||||
return ListTile(
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
trailing: breakpoint.isLessThan(breakOn) ? null : trailing,
|
||||
trailing:
|
||||
breakpoint.isLessThan(breakOn) ? null : trailing?.call(context, null),
|
||||
leading: leading,
|
||||
onTap: breakpoint.isLessThan(breakOn)
|
||||
? () {
|
||||
@ -35,20 +36,22 @@ class AdaptiveListTile extends HookWidget {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: title != null
|
||||
? Row(
|
||||
children: [
|
||||
if (leading != null) ...[
|
||||
leading!,
|
||||
const SizedBox(width: 5)
|
||||
return StatefulBuilder(builder: (context, update) {
|
||||
return AlertDialog(
|
||||
title: title != null
|
||||
? Row(
|
||||
children: [
|
||||
if (leading != null) ...[
|
||||
leading!,
|
||||
const SizedBox(width: 5)
|
||||
],
|
||||
Flexible(child: title!),
|
||||
],
|
||||
Flexible(child: title!),
|
||||
],
|
||||
)
|
||||
: null,
|
||||
content: trailing,
|
||||
);
|
||||
)
|
||||
: null,
|
||||
content: trailing?.call(context, update),
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user