Skip to content

Commit 251bcb3

Browse files
committed
chore: Simpler changing config variables
Signed-off-by: Krille <[email protected]>
1 parent 4c37811 commit 251bcb3

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/widgets/config_viewer.dart

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import 'package:flutter/material.dart';
2-
3-
import 'package:go_router/go_router.dart';
4-
import 'package:shared_preferences/shared_preferences.dart';
5-
61
import 'package:fluffychat/config/setting_keys.dart';
72
import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart';
83
import 'package:fluffychat/widgets/matrix.dart';
4+
import 'package:flutter/material.dart';
5+
import 'package:go_router/go_router.dart';
6+
import 'package:shared_preferences/shared_preferences.dart';
97

108
class ConfigViewer extends StatelessWidget {
119
const ConfigViewer({super.key});
@@ -15,20 +13,23 @@ class ConfigViewer extends StatelessWidget {
1513
AppSettings appSetting,
1614
SharedPreferences store,
1715
Function setState,
16+
String initialValue,
1817
) async {
18+
if (appSetting is AppSettings<bool>) {
19+
appSetting.setItem(store, !(initialValue == 'true'));
20+
}
21+
1922
final value = await showTextInputDialog(
2023
context: context,
2124
title: appSetting.name,
22-
initialText: appSetting.defaultValue.toString(),
25+
hintText: appSetting.defaultValue.toString(),
26+
initialText: initialValue,
2327
);
2428
if (value == null) return;
2529

2630
if (appSetting is AppSettings<String>) {
2731
appSetting.setItem(store, value);
2832
}
29-
if (appSetting is AppSettings<bool>) {
30-
appSetting.setItem(store, value == 'true');
31-
}
3233
if (appSetting is AppSettings<int>) {
3334
appSetting.setItem(store, int.parse(value));
3435
}
@@ -91,6 +92,7 @@ class ConfigViewer extends StatelessWidget {
9192
appSetting,
9293
store,
9394
setState,
95+
value,
9496
),
9597
);
9698
},

0 commit comments

Comments
 (0)