feat: Add advanced configuration page
This commit is contained in:
parent
b94893be18
commit
730fb22be3
5 changed files with 177 additions and 9 deletions
|
|
@ -31,6 +31,7 @@ import 'package:fluffychat/pages/settings_notifications/settings_notifications.d
|
|||
import 'package:fluffychat/pages/settings_password/settings_password.dart';
|
||||
import 'package:fluffychat/pages/settings_security/settings_security.dart';
|
||||
import 'package:fluffychat/pages/settings_style/settings_style.dart';
|
||||
import 'package:fluffychat/widgets/config_viewer.dart';
|
||||
import 'package:fluffychat/widgets/layouts/empty_page.dart';
|
||||
import 'package:fluffychat/widgets/layouts/two_column_layout.dart';
|
||||
import 'package:fluffychat/widgets/log_view.dart';
|
||||
|
|
@ -86,6 +87,14 @@ abstract class AppRoutes {
|
|||
const LogViewer(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/configs',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
state,
|
||||
const ConfigViewer(),
|
||||
),
|
||||
),
|
||||
ShellRoute(
|
||||
// Never use a transition on the shell route. Changing the PageBuilder
|
||||
// here based on a MediaQuery causes the child to briefly be rendered
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
abstract class SettingKeys {
|
||||
static const String renderHtml = 'chat.fluffy.renderHtml';
|
||||
static const String hideRedactedEvents = 'chat.fluffy.hideRedactedEvents';
|
||||
|
|
@ -36,3 +38,43 @@ abstract class SettingKeys {
|
|||
'chat.fluffy.no_encryption_warning_shown';
|
||||
static const String shareKeysWith = 'chat.fluffy.share_keys_with';
|
||||
}
|
||||
|
||||
enum AppSettings<T> {
|
||||
audioRecordingNumChannels<int>('audioRecordingNumChannels', 1),
|
||||
audioRecordingAutoGain<bool>('audioRecordingAutoGain', true),
|
||||
audioRecordingEchoCancel<bool>('audioRecordingEchoCancel', true),
|
||||
audioRecordingNoiseSuppress<bool>('audioRecordingNoiseSuppress', true),
|
||||
audioRecordingBitRate<int>('audioRecordingBitRate', 64000),
|
||||
audioRecordingSamplingRate<int>('audioRecordingSamplingRate', 44100);
|
||||
|
||||
final String key;
|
||||
final T defaultValue;
|
||||
|
||||
const AppSettings(this.key, this.defaultValue);
|
||||
}
|
||||
|
||||
extension AppSettingsBoolExtension on AppSettings<bool> {
|
||||
bool getItem(SharedPreferences store) => store.getBool(key) ?? defaultValue;
|
||||
Future<void> setItem(SharedPreferences store, bool value) =>
|
||||
store.setBool(key, value);
|
||||
}
|
||||
|
||||
extension AppSettingsStringExtension on AppSettings<String> {
|
||||
String getItem(SharedPreferences store) =>
|
||||
store.getString(key) ?? defaultValue;
|
||||
Future<void> setItem(SharedPreferences store, String value) =>
|
||||
store.setString(key, value);
|
||||
}
|
||||
|
||||
extension AppSettingsIntExtension on AppSettings<int> {
|
||||
int getItem(SharedPreferences store) => store.getInt(key) ?? defaultValue;
|
||||
Future<void> setItem(SharedPreferences store, int value) =>
|
||||
store.setInt(key, value);
|
||||
}
|
||||
|
||||
extension AppSettingsDoubleExtension on AppSettings<double> {
|
||||
double getItem(SharedPreferences store) =>
|
||||
store.getDouble(key) ?? defaultValue;
|
||||
Future<void> setItem(SharedPreferences store, double value) =>
|
||||
store.setDouble(key, value);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue