feat: Add advanced configuration page

This commit is contained in:
Krille 2025-03-05 19:01:34 +01:00
commit 730fb22be3
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652
5 changed files with 177 additions and 9 deletions

View file

@ -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);
}