mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-13 11:36:24 +00:00
Add settings to control sounds
This commit is contained in:
parent
194be50337
commit
989e0e81b3
4 changed files with 106 additions and 25 deletions
38
lib/app_settings.dart
Normal file
38
lib/app_settings.dart
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Class for managing app-level configuration options
|
||||
*/
|
||||
|
||||
import 'package:sembast/sembast.dart';
|
||||
import 'package:InvenTree/preferences.dart';
|
||||
|
||||
class InvenTreeSettingsManager {
|
||||
|
||||
final store = StoreRef("settings");
|
||||
|
||||
Future<Database> get _db async => await InvenTreePreferencesDB.instance.database;
|
||||
|
||||
Future<dynamic> getValue(String key, dynamic backup) async {
|
||||
|
||||
final value = await store.record(key).get(await _db);
|
||||
|
||||
if (value == null) {
|
||||
return backup;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
Future<void> setValue(String key, dynamic value) async {
|
||||
|
||||
await store.record(key).put(await _db, value);
|
||||
}
|
||||
|
||||
// Ensure we only ever create a single instance of this class
|
||||
static final InvenTreeSettingsManager _manager = new InvenTreeSettingsManager._internal();
|
||||
|
||||
factory InvenTreeSettingsManager() {
|
||||
return _manager;
|
||||
}
|
||||
|
||||
InvenTreeSettingsManager._internal();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue