Added settings config

This commit is contained in:
Juan Gilsanz Polo 2023-10-21 21:17:28 +02:00
parent 161628a72a
commit 8c0a5bc98b
6 changed files with 86 additions and 6 deletions

View file

@ -52,6 +52,8 @@ class AppConfigProvider with ChangeNotifier {
int _combinedChartHome = 0;
int _showTopItemsChart = 0;
String? _doNotRememberVersion;
GitHubRelease? _appUpdatesAvailable;
@ -168,6 +170,10 @@ class AppConfigProvider with ChangeNotifier {
return _hideServerAddress == 1 ? true : false;
}
bool get showTopItemsChart {
return _showTopItemsChart == 1 ? true : false;
}
void setDbInstance(Database db) {
_dbInstance = db;
}
@ -402,6 +408,22 @@ class AppConfigProvider with ChangeNotifier {
}
}
Future<bool> setShowTopItemsChart(bool value) async {
final updated = await updateConfigQuery(
db: _dbInstance!,
column: 'showTopItemsChart',
value: value == true ? 1 : 0
);
if (updated == true) {
_showTopItemsChart = value == true ? 1 : 0;
notifyListeners();
return true;
}
else {
return false;
}
}
Future<bool> setDoNotRememberVersion(String value) async {
final updated = await updateConfigQuery(
@ -424,6 +446,7 @@ class AppConfigProvider with ChangeNotifier {
_showIpLogs = dbData['showIpLogs'] ?? 0;
_combinedChartHome = dbData['combinedChart'] ?? 0;
_hideServerAddress = dbData['hideServerAddress'];
_showTopItemsChart = dbData['showTopItemsChart'];
if (dbData['homeTopItemsOrder'] != null) {
try {
_homeTopItemsOrder = List<HomeTopItems>.from(