27 lines
733 B
Dart
27 lines
733 B
Dart
/// 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<void> setLookAheadMaxYears(int years) async {
|
||
final next = years.clamp(1, 30);
|
||
if (next == _lookAheadMaxYears) return;
|
||
_lookAheadMaxYears = next;
|
||
notifyListeners();
|
||
await _storage.setLookAheadMaxYears(next);
|
||
}
|
||
}
|