feat(app): offline-кэш на остальных экранах — фаза 5

accounts, cashflow, categories, goals, income, portfolio (+instrument),
rebalance, tax, rules переведены на Cached<T> по контракту
docs/ai/offline-cache.md. Общие/второстепенные селекторы (scopesProvider,
categoriesListProvider и т.п.) оставлены как есть — не основной контент
экрана. sync_page.dart и settings_page.dart не тронуты (первый — заменён
health-page отдельно, второй — чистые действия без списка для баннера).
This commit is contained in:
Dmitry
2026-09-19 14:00:13 +03:00
parent ffc5ed959a
commit 7b419f4188
39 changed files with 388 additions and 186 deletions
+8 -4
View File
@@ -11,6 +11,7 @@ library;
import 'package:dio/dio.dart';
import '../../../core/cache/cached.dart';
import '../../../core/utils/json.dart';
/// Per-account (or total) tax figures for a year. Every number is an **estimate**: the tax
@@ -153,19 +154,22 @@ class TaxApi {
static const _base = '/api/v1/tax';
Future<TaxSummary> summary({required int year, int? accountId}) async {
/// See `docs/ai/offline-cache.md`: this hand-written client returns `Cached<T>` directly
/// (there is no generated `Response<T>` for the screen to unwrap `r.cached` from).
Future<Cached<TaxSummary>> summary({required int year, int? accountId}) async {
final r = await _dio.get<Map<String, dynamic>>(
_base,
queryParameters: {'year': year, 'account_id': ?accountId},
);
return TaxSummary.fromJson(r.data ?? const {});
return Cached(TaxSummary.fromJson(r.data ?? const {}), fetchedAt: r.extra['fetchedAt'] as DateTime?);
}
Future<List<TaxLot>> lots({required int year, int? accountId}) async {
Future<Cached<List<TaxLot>>> lots({required int year, int? accountId}) async {
final r = await _dio.get<Map<String, dynamic>>(
'$_base/lots',
queryParameters: {'year': year, 'account_id': ?accountId},
);
return asObjects((r.data ?? const {})['lots']).map(TaxLot.fromJson).toList();
final lots = asObjects((r.data ?? const {})['lots']).map(TaxLot.fromJson).toList();
return Cached(lots, fetchedAt: r.extra['fetchedAt'] as DateTime?);
}
}