chore: Simpler changing config variables
Signed-off-by: Krille <c.kussowski@famedly.com>
This commit is contained in:
parent
4c37811878
commit
251bcb3ebe
1 changed files with 11 additions and 9 deletions
|
|
@ -1,11 +1,9 @@
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
import 'package:fluffychat/config/setting_keys.dart';
|
import 'package:fluffychat/config/setting_keys.dart';
|
||||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart';
|
import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart';
|
||||||
import 'package:fluffychat/widgets/matrix.dart';
|
import 'package:fluffychat/widgets/matrix.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class ConfigViewer extends StatelessWidget {
|
class ConfigViewer extends StatelessWidget {
|
||||||
const ConfigViewer({super.key});
|
const ConfigViewer({super.key});
|
||||||
|
|
@ -15,20 +13,23 @@ class ConfigViewer extends StatelessWidget {
|
||||||
AppSettings appSetting,
|
AppSettings appSetting,
|
||||||
SharedPreferences store,
|
SharedPreferences store,
|
||||||
Function setState,
|
Function setState,
|
||||||
|
String initialValue,
|
||||||
) async {
|
) async {
|
||||||
|
if (appSetting is AppSettings<bool>) {
|
||||||
|
appSetting.setItem(store, !(initialValue == 'true'));
|
||||||
|
}
|
||||||
|
|
||||||
final value = await showTextInputDialog(
|
final value = await showTextInputDialog(
|
||||||
context: context,
|
context: context,
|
||||||
title: appSetting.name,
|
title: appSetting.name,
|
||||||
initialText: appSetting.defaultValue.toString(),
|
hintText: appSetting.defaultValue.toString(),
|
||||||
|
initialText: initialValue,
|
||||||
);
|
);
|
||||||
if (value == null) return;
|
if (value == null) return;
|
||||||
|
|
||||||
if (appSetting is AppSettings<String>) {
|
if (appSetting is AppSettings<String>) {
|
||||||
appSetting.setItem(store, value);
|
appSetting.setItem(store, value);
|
||||||
}
|
}
|
||||||
if (appSetting is AppSettings<bool>) {
|
|
||||||
appSetting.setItem(store, value == 'true');
|
|
||||||
}
|
|
||||||
if (appSetting is AppSettings<int>) {
|
if (appSetting is AppSettings<int>) {
|
||||||
appSetting.setItem(store, int.parse(value));
|
appSetting.setItem(store, int.parse(value));
|
||||||
}
|
}
|
||||||
|
|
@ -91,6 +92,7 @@ class ConfigViewer extends StatelessWidget {
|
||||||
appSetting,
|
appSetting,
|
||||||
store,
|
store,
|
||||||
setState,
|
setState,
|
||||||
|
value,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue