Moved config values to ConfigService

This commit is contained in:
2025-07-07 23:14:11 +02:00
parent a13a3ac0c9
commit ace157dc47
6 changed files with 21 additions and 21 deletions

View File

@@ -1,4 +1,3 @@
import 'package:cabo_counter/utility/globals.dart';
import 'package:shared_preferences/shared_preferences.dart';
/// This class handles the configuration settings for the app.
@@ -7,8 +6,12 @@ import 'package:shared_preferences/shared_preferences.dart';
class ConfigService {
static const String _keyPointLimit = 'pointLimit';
static const String _keyCaboPenalty = 'caboPenalty';
static const int _defaultPointLimit = 100; // Default Value
static const int _defaultCaboPenalty = 5; // Default Value
// Actual values used in the app
static int pointLimit = 100;
static int caboPenalty = 5;
// Default values
static const int _defaultPointLimit = 100;
static const int _defaultCaboPenalty = 5;
static Future<void> initConfig() async {
final prefs = await SharedPreferences.getInstance();
@@ -48,8 +51,8 @@ class ConfigService {
/// Resets the configuration to default values.
static Future<void> resetConfig() async {
Globals.pointLimit = _defaultPointLimit;
Globals.caboPenalty = _defaultCaboPenalty;
ConfigService.pointLimit = _defaultPointLimit;
ConfigService.caboPenalty = _defaultCaboPenalty;
final prefs = await SharedPreferences.getInstance();
await prefs.setInt(_keyPointLimit, _defaultPointLimit);
await prefs.setInt(_keyCaboPenalty, _defaultCaboPenalty);