feat: extensive settings for media controls through notification (#28)

* feat: add notification settings customisation options

* feat: add notification settings page and update routing
This commit is contained in:
Dr.Blank 2024-09-25 03:13:42 -04:00 committed by GitHub
parent 721b0a87fc
commit 3cf0a0b124
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 1391 additions and 376 deletions

View file

@ -11,25 +11,29 @@ final _box = AvailableHiveBoxes.userPrefsBox;
final _logger = Logger('AppSettingsProvider');
model.AppSettings readFromBoxOrCreate() {
model.AppSettings loadOrCreateAppSettings() {
// see if the settings are already in the box
model.AppSettings? settings;
if (_box.isNotEmpty) {
final foundSettings = _box.getAt(0);
_logger.fine('found settings in box: $foundSettings');
return foundSettings;
try {
settings = _box.getAt(0);
_logger.fine('found settings in box: $settings');
} catch (e) {
_logger.warning('error reading settings from box: $e'
'\nclearing box');
_box.clear();
}
} else {
// create a new settings object
const settings = model.AppSettings();
_logger.fine('created new settings: $settings');
return settings;
_logger.fine('no settings found in box, creating new settings');
}
return settings ?? const model.AppSettings();
}
@Riverpod(keepAlive: true)
class AppSettings extends _$AppSettings {
@override
model.AppSettings build() {
state = readFromBoxOrCreate();
state = loadOrCreateAppSettings();
ref.listenSelf((_, __) {
writeToBox();
});