mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2025-12-09 20:49:29 +00:00
downloads and offline playback
This commit is contained in:
parent
1c95d1e4bb
commit
c24541f1cd
38 changed files with 1590 additions and 109 deletions
|
|
@ -11,6 +11,20 @@ final _box = AvailableHiveBoxes.userPrefsBox;
|
|||
|
||||
final _logger = Logger('AppSettingsProvider');
|
||||
|
||||
model.AppSettings readFromBoxOrCreate() {
|
||||
// see if the settings are already in the box
|
||||
if (_box.isNotEmpty) {
|
||||
final foundSettings = _box.getAt(0);
|
||||
_logger.fine('found settings in box: $foundSettings');
|
||||
return foundSettings;
|
||||
} else {
|
||||
// create a new settings object
|
||||
const settings = model.AppSettings();
|
||||
_logger.fine('created new settings: $settings');
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
class AppSettings extends _$AppSettings {
|
||||
@override
|
||||
|
|
@ -22,20 +36,6 @@ class AppSettings extends _$AppSettings {
|
|||
return state;
|
||||
}
|
||||
|
||||
model.AppSettings readFromBoxOrCreate() {
|
||||
// see if the settings are already in the box
|
||||
if (_box.isNotEmpty) {
|
||||
final foundSettings = _box.getAt(0);
|
||||
_logger.fine('found settings in box: $foundSettings');
|
||||
return foundSettings;
|
||||
} else {
|
||||
// create a new settings object
|
||||
const settings = model.AppSettings();
|
||||
_logger.fine('created new settings: $settings');
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
|
||||
// write the settings to the box
|
||||
void writeToBox() {
|
||||
_box.clear();
|
||||
|
|
@ -50,4 +50,8 @@ class AppSettings extends _$AppSettings {
|
|||
void updateState(model.AppSettings newSettings) {
|
||||
state = newSettings;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
state = const model.AppSettings();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue