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_locale.dart';
5 : import 'package:app_finance/_configs/screen_helper.dart';
6 : import 'package:app_finance/_configs/theme_helper.dart';
7 : import 'package:app_finance/pages/_interfaces/abstract_page_state.dart';
8 : import 'package:app_finance/design/wrapper/tab_widget.dart';
9 : import 'package:app_finance/pages/metrics/widgets/account_tab.dart';
10 : import 'package:app_finance/pages/metrics/widgets/bill_tab.dart';
11 : import 'package:app_finance/pages/metrics/widgets/budget_tab.dart';
12 : import 'package:material_ui/material_ui.dart';
13 :
14 : class MetricsPage extends StatefulWidget {
15 : final String? search;
16 :
17 2 : const MetricsPage({
18 : super.key,
19 : this.search,
20 : });
21 :
22 0 : @override
23 0 : MetricsPageState createState() => MetricsPageState();
24 : }
25 :
26 : class MetricsPageState extends AbstractPageState<MetricsPage> {
27 : late int tab = int.tryParse(widget.search ?? '') ?? 0;
28 :
29 0 : @override
30 0 : String getTitle() => AppLocale.labels.metricsTooltip;
31 :
32 0 : @override
33 : Widget buildButton(BuildContext context, BoxConstraints constraints) => ThemeHelper.emptyBox;
34 :
35 0 : @override
36 : String getButtonName() => '';
37 :
38 0 : @override
39 0 : String? getHelperName() => switch (tab) {
40 0 : 0 => 'help_metrics_budget',
41 0 : 1 => 'help_metrics_account',
42 0 : 2 => 'help_metrics_bill',
43 : _ => null,
44 : };
45 :
46 0 : @override
47 : Widget buildContent(BuildContext context, BoxConstraints constraints) {
48 0 : final isLeft = ScreenHelper.state().isLeftBar;
49 0 : return TabWidget(
50 0 : focus: tab,
51 : type: TabType.secondary,
52 : isLeft: isLeft,
53 0 : callback: (idx) => setState(() => tab = idx),
54 0 : tabs: [
55 0 : Tab(
56 : icon: const Icon(Icons.graphic_eq),
57 0 : text: AppLocale.labels.budgetHeadline,
58 : ),
59 0 : Tab(
60 : icon: const Icon(Icons.incomplete_circle),
61 0 : text: AppLocale.labels.accountHeadline,
62 : ),
63 0 : Tab(
64 : icon: const Icon(Icons.bar_chart),
65 0 : text: AppLocale.labels.billHeadline,
66 : ),
67 : ],
68 0 : children: [
69 0 : BudgetTab(store: super.state),
70 0 : AccountTab(store: super.state),
71 0 : BillTab(store: super.state),
72 : ],
73 : );
74 : }
75 : }
|