diff --git a/lib/providers/preferences_provider.dart b/lib/providers/preferences_provider.dart new file mode 100644 index 0000000..9723c3c --- /dev/null +++ b/lib/providers/preferences_provider.dart @@ -0,0 +1,26 @@ +/// App preferences beyond theme (Look ahead horizon, etc.). +library; + +import 'package:flutter/foundation.dart'; + +import '../services/storage_service.dart'; + +class PreferencesController extends ChangeNotifier { + PreferencesController(this._storage) { + _lookAheadMaxYears = _storage.lookAheadMaxYears; + } + + final StorageService _storage; + late int _lookAheadMaxYears; + + /// Years ahead Look ahead can navigate (1–30, default 5). + int get lookAheadMaxYears => _lookAheadMaxYears; + + Future setLookAheadMaxYears(int years) async { + final next = years.clamp(1, 30); + if (next == _lookAheadMaxYears) return; + _lookAheadMaxYears = next; + notifyListeners(); + await _storage.setLookAheadMaxYears(next); + } +}