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:
@@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../core/cache/cached.dart';
|
||||
import '../../core/widgets/scope_selector.dart';
|
||||
import '../../core/widgets/stale_banner.dart';
|
||||
import 'calendar_tab.dart';
|
||||
import 'forecast_tab.dart';
|
||||
import 'history_tab.dart';
|
||||
@@ -9,11 +11,21 @@ import 'providers.dart';
|
||||
|
||||
/// Доходы: the dividend/coupon calendar, the paid history and the forecast — three views of
|
||||
/// one question, so three tabs of one screen rather than three navigation destinations.
|
||||
///
|
||||
/// One offline banner covers all three tabs (`docs/ai/offline-cache.md`): they share a
|
||||
/// scope and `TabBarView` builds all of them eagerly anyway, so watching all three
|
||||
/// providers here to compute it costs nothing extra.
|
||||
class IncomePage extends ConsumerWidget {
|
||||
const IncomePage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final stale = oldestFetch([
|
||||
ref.watch(incomeCalendarProvider).valueOrNull?.fetchedAt,
|
||||
ref.watch(incomeHistoryProvider).valueOrNull?.fetchedAt,
|
||||
ref.watch(incomeForecastProvider).valueOrNull?.fetchedAt,
|
||||
]);
|
||||
|
||||
return DefaultTabController(
|
||||
length: 3,
|
||||
child: Scaffold(
|
||||
@@ -31,8 +43,19 @@ class IncomePage extends ConsumerWidget {
|
||||
tabs: [Tab(text: 'Календарь'), Tab(text: 'История'), Tab(text: 'Прогноз')],
|
||||
),
|
||||
),
|
||||
body: const TabBarView(
|
||||
children: [IncomeCalendarTab(), IncomeHistoryTab(), IncomeForecastTab()],
|
||||
body: Column(
|
||||
children: [
|
||||
if (stale != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
child: StaleBanner(fetchedAt: stale),
|
||||
),
|
||||
const Expanded(
|
||||
child: TabBarView(
|
||||
children: [IncomeCalendarTab(), IncomeHistoryTab(), IncomeForecastTab()],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user