look aheead limit defined by user
This commit is contained in:
@@ -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<void> setLookAheadMaxYears(int years) async {
|
||||||
|
final next = years.clamp(1, 30);
|
||||||
|
if (next == _lookAheadMaxYears) return;
|
||||||
|
_lookAheadMaxYears = next;
|
||||||
|
notifyListeners();
|
||||||
|
await _storage.setLookAheadMaxYears(next);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user