Line data Source code
1 : // Copyright 2023 The terCAD team. All rights reserved. 2 : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file. 3 : 4 : import 'package:app_finance/_classes/herald/app_design.dart'; 5 : import 'package:app_finance/_classes/storage/app_data.dart'; 6 : import 'package:app_finance/_classes/herald/app_locale.dart'; 7 : import 'package:app_finance/charts/data/data_handler.dart'; 8 : import 'package:app_finance/_classes/structure/currency/exchange.dart'; 9 : import 'package:app_finance/_configs/theme_helper.dart'; 10 : import 'package:app_finance/_ext/build_context_ext.dart'; 11 : import 'package:app_finance/charts/bar_race_chart.dart'; 12 : import 'package:app_finance/components/widgets/bill_ytd_chart.dart'; 13 : import 'package:app_finance/design/wrapper/text_wrapper.dart'; 14 : import 'package:flutter/material.dart'; 15 : 16 : class BillTab extends StatelessWidget { 17 : final AppData store; 18 : final double? width; 19 : 20 0 : const BillTab({ 21 : super.key, 22 : required this.store, 23 : this.width, 24 : }); 25 : 26 0 : @override 27 : Widget build(BuildContext context) { 28 0 : final TextTheme textTheme = context.textTheme; 29 0 : double indent = ThemeHelper.getIndent(); 30 0 : final width = this.width ?? ThemeHelper.getWidth(context, 6); 31 0 : final budgets = store.getList(AppDataType.budgets); 32 0 : return SingleChildScrollView( 33 0 : child: Padding( 34 0 : padding: this.width != null ? EdgeInsets.zero : EdgeInsets.all(indent * 2), 35 0 : child: Column( 36 0 : crossAxisAlignment: AppDesign.getAlignment(), 37 0 : children: [ 38 : const BillYtdChart(), 39 : ThemeHelper.hIndent2x, 40 0 : TextWrapper( 41 0 : '${AppLocale.labels.chartBarRace}, ${Exchange.defaultCurrency?.code}', 42 0 : style: textTheme.bodyLarge, 43 : ), 44 0 : BarRaceChart( 45 : width: width, 46 : indent: indent, 47 0 : categories: budgets.cast(), 48 0 : data: DataHandler.getAmountGroupedByCategory( 49 0 : store.getActualList(AppDataType.bills).cast(), 50 0 : budgets.cast(), 51 0 : exchange: Exchange(store: store), 52 : ), 53 : ), 54 : ThemeHelper.formEndBox, 55 : ], 56 : ), 57 : ), 58 : ); 59 : } 60 : }