This commit is contained in:
2026-06-28 15:10:17 +03:00
parent 2b89545248
commit f2d444cb16
5 changed files with 114 additions and 15 deletions
+25
View File
@@ -103,6 +103,31 @@ final exchangeRateServiceProvider = Provider<ExchangeRateService>((ref) {
return ExchangeRateService(prefs);
});
final cardHeightProvider = NotifierProvider<CardHeightNotifier, double>(
CardHeightNotifier.new,
);
class CardHeightNotifier extends Notifier<double> {
static const _key = 'card_height';
static const _minHeight = 160.0;
static const _maxHeight = 280.0;
static const _defaultHeight = 200.0;
@override
double build() {
final prefs = ref.watch(sharedPreferencesProvider);
final saved = prefs.getDouble(_key);
if (saved == null) return _defaultHeight;
return saved.clamp(_minHeight, _maxHeight);
}
void set(double height) {
final clamped = height.clamp(_minHeight, _maxHeight);
state = clamped;
ref.read(sharedPreferencesProvider).setDouble(_key, clamped);
}
}
final ratesInitProvider = FutureProvider<void>((ref) async {
await ref.read(exchangeRateServiceProvider).fetchRates();
});