Files
Krezus/lib/pages/stats/stats_page.dart

65 lines
2.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:tunas/domains/charts/chart_bloc.dart';
import 'package:tunas/pages/stats/widgets/account_counters.dart';
import 'package:tunas/pages/stats/widgets/categories_totals_chart.dart';
import 'package:tunas/pages/stats/widgets/main_counter.dart';
import 'package:tunas/pages/stats/widgets/monthly_categories_total_chart.dart';
import 'package:tunas/pages/stats/widgets/monthly_total_chart.dart';
import 'package:tunas/pages/stats/widgets/profit_indicator.dart';
import 'package:tunas/pages/stats/widgets/year_selector.dart';
import 'package:tunas/repositories/account/account_repository.dart';
class StatsPage extends StatelessWidget {
const StatsPage({super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => ChartBloc(accountRepository: RepositoryProvider.of<AccountRepository>(context)),
child: BlocBuilder<ChartBloc, ChartState>(
builder: (context, state) => ListView(
children: [
Row(
children: [
Expanded(
flex: 2,
child: MainCounter(value: state.globalTotal)
),
Expanded(
flex: 1,
child: AccountCounter(accountsTotals: state.accountsTotals)
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const YearSelector(),
ProfitIndicator(monthlyTotals: state.scopedMonthlyTotals)
],
),
SizedBox(
height: 200,
child: GlobalTotalChart(monthlyTotals: state.scopedMonthlyTotals)
),
SizedBox(
height: 500,
child: MonthlyCategoriesTotalChart(categoriesMonthlyTotals: state.scopedCategoriesMonthlyTotals, categoriesColors: state.categoriesColors)
),
SizedBox(
height: 450,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CategoriesTotalsChart(categoriesTotals: state.scopedCategoriesPositiveTotals, categoriesTotalsPercents: state.scopedCategoriesPositiveTotalsPercents, categoriesColors: state.categoriesColors),
CategoriesTotalsChart(categoriesTotals: state.scopedCategoriesNegativeTotals, categoriesTotalsPercents: state.scopedSimplifiedCategoriesNegativeTotalsPercents, categoriesColors: state.categoriesColors),
],
)
),
],
)
),
);
}
}