1
- import 'package:flutter/material.dart' ;
2
-
3
- import 'package:go_router/go_router.dart' ;
4
- import 'package:shared_preferences/shared_preferences.dart' ;
5
-
6
1
import 'package:fluffychat/config/setting_keys.dart' ;
7
2
import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart' ;
8
3
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' ;
9
7
10
8
class ConfigViewer extends StatelessWidget {
11
9
const ConfigViewer ({super .key});
@@ -15,20 +13,23 @@ class ConfigViewer extends StatelessWidget {
15
13
AppSettings appSetting,
16
14
SharedPreferences store,
17
15
Function setState,
16
+ String initialValue,
18
17
) async {
18
+ if (appSetting is AppSettings <bool >) {
19
+ appSetting.setItem (store, ! (initialValue == 'true' ));
20
+ }
21
+
19
22
final value = await showTextInputDialog (
20
23
context: context,
21
24
title: appSetting.name,
22
- initialText: appSetting.defaultValue.toString (),
25
+ hintText: appSetting.defaultValue.toString (),
26
+ initialText: initialValue,
23
27
);
24
28
if (value == null ) return ;
25
29
26
30
if (appSetting is AppSettings <String >) {
27
31
appSetting.setItem (store, value);
28
32
}
29
- if (appSetting is AppSettings <bool >) {
30
- appSetting.setItem (store, value == 'true' );
31
- }
32
33
if (appSetting is AppSettings <int >) {
33
34
appSetting.setItem (store, int .parse (value));
34
35
}
@@ -91,6 +92,7 @@ class ConfigViewer extends StatelessWidget {
91
92
appSetting,
92
93
store,
93
94
setState,
95
+ value,
94
96
),
95
97
);
96
98
},
0 commit comments