mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2025-12-06 02:59:28 +00:00
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:
parent
721b0a87fc
commit
3cf0a0b124
21 changed files with 1391 additions and 376 deletions
|
|
@ -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();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue