Skip to content

Commit

Permalink
Rebuild Cildren on some settings pages where resetting to default did…
Browse files Browse the repository at this point in the history
…nt update the ui
  • Loading branch information
flloschy committed Dec 30, 2024
1 parent 12fdcf9 commit 6ffad11
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
20 changes: 14 additions & 6 deletions lib/screens/audio_service_settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,31 @@ class AudioServiceSettingsScreen extends StatefulWidget {

class _AudioServiceSettingsScreenState
extends State<AudioServiceSettingsScreen> {
// Overwriting this value causes the childrens to update
// this is a required workaround because some input fields
// might not update when resetting to defaults
Key _updateChildren = UniqueKey();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context)!.audioService),
actions: [
FinampSettingsHelper.makeSettingsResetButtonWithDialog(
context, FinampSettingsHelper.resetAudioServiceSettings)
FinampSettingsHelper.makeSettingsResetButtonWithDialog(context, () {
setState(() {
FinampSettingsHelper.resetAudioServiceSettings();
_updateChildren = UniqueKey(); // Trigger rebuilding of Children
});
})
],
),
body: ListView(
children: [
if (Platform.isAndroid) const StopForegroundSelector(),
const SongShuffleItemCountEditor(),
const BufferDurationListTile(),
if (Platform.isAndroid) StopForegroundSelector(key: _updateChildren),
SongShuffleItemCountEditor(key: _updateChildren),
BufferDurationListTile(key: _updateChildren),
const LoadQueueOnStartupSelector(),
const PeriodicPlaybackSessionUpdateFrequencyEditor(),
PeriodicPlaybackSessionUpdateFrequencyEditor(key: _updateChildren),
const ReportQueueToServerToggle(),
],
),
Expand Down
15 changes: 12 additions & 3 deletions lib/screens/volume_normalization_settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,30 @@ class VolumeNormalizationSettingsScreen extends StatefulWidget {

class _VolumeNormalizationSettingsScreenState
extends State<VolumeNormalizationSettingsScreen> {
// Overwriting this value causes the childrens to update
// this is a required workaround because some input fields
// might not update when resetting to defaults
Key _updateChildren = UniqueKey();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
AppLocalizations.of(context)!.volumeNormalizationSettingsTitle),
actions: [
FinampSettingsHelper.makeSettingsResetButtonWithDialog(
context, FinampSettingsHelper.resetNormalizationSettings)
FinampSettingsHelper.makeSettingsResetButtonWithDialog(context, () {
setState(() {
FinampSettingsHelper.resetNormalizationSettings();
_updateChildren = UniqueKey(); // Trigger rebuilding of Children
});
})
],
),
body: ListView(
children: [
const VolumeNormalizationSwitch(),
if (!Platform.isAndroid) const VolumeNormalizationIOSBaseGainEditor(),
if (!Platform.isAndroid)
VolumeNormalizationIOSBaseGainEditor(key: _updateChildren),
const VolumeNormalizationModeSelector(),
],
),
Expand Down

0 comments on commit 6ffad11

Please sign in to comment.