Skip to content

Commit

Permalink
fix: editing home widget settings
Browse files Browse the repository at this point in the history
Fixes #613
  • Loading branch information
lollipopkit committed Oct 29, 2024
1 parent 71a8210 commit b1b4edf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/view/page/setting/platform/android.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class AndroidSettingsPage extends StatefulWidget {
State<AndroidSettingsPage> createState() => _AndroidSettingsPageState();
}

const _homeWidgetPrefPrefix = 'widget_';

class _AndroidSettingsPageState extends State<AndroidSettingsPage> {
@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -39,11 +41,13 @@ class _AndroidSettingsPageState extends State<AndroidSettingsPage> {
try {
final keysDel = old.keys.toSet().difference(map.keys.toSet());
for (final key in keysDel) {
if (!key.startsWith(_homeWidgetPrefPrefix)) continue;
PrefStore.remove(key);
}
map.forEach((key, value) {
PrefStore.set(key, value);
});
for (final entry in map.entries) {
if (!entry.key.startsWith(_homeWidgetPrefPrefix)) continue;
PrefStore.set(entry.key, entry.value);
}
context.showSnackBar(libL10n.success);
} catch (e) {
context.showSnackBar(e.toString());
Expand All @@ -64,7 +68,7 @@ class _AndroidSettingsPageState extends State<AndroidSettingsPage> {
}
final result = await KvEditor.route.go(
context,
KvEditorArgs(data: data, prefix: 'widget_'),
KvEditorArgs(data: data, prefix: _homeWidgetPrefPrefix),
);
if (result != null) {
_saveWidgetSP(result, data);
Expand Down

0 comments on commit b1b4edf

Please sign in to comment.