downloads and offline playback

This commit is contained in:
Dr-Blank 2024-08-20 08:36:39 -04:00
parent 1c95d1e4bb
commit c24541f1cd
No known key found for this signature in database
GPG key ID: 7452CC63F210A266
38 changed files with 1590 additions and 109 deletions

View file

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