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/structure/navigation/app_route.dart';
6 : import 'package:app_finance/_configs/custom_text_theme.dart';
7 : import 'package:app_finance/_configs/theme_helper.dart';
8 : import 'package:app_finance/_ext/build_context_ext.dart';
9 : import 'package:app_finance/charts/bar_horizontal_single.dart';
10 : import 'package:app_finance/design/generic/base_swipe_widget.dart';
11 : import 'package:app_finance/design/wrapper/number_wrapper.dart';
12 : import 'package:app_finance/design/wrapper/row_widget.dart';
13 : import 'package:app_finance/design/wrapper/tap_widget.dart';
14 : import 'package:app_finance/design/wrapper/text_wrapper.dart';
15 : import 'package:material_ui/material_ui.dart';
16 :
17 : class BudgetLineWidget extends StatelessWidget {
18 : final String uuid;
19 : final String title;
20 : final String details;
21 : final String description;
22 : final double progress;
23 : final String amount;
24 : final Color color;
25 : final IconData icon;
26 : final double width;
27 : final String route;
28 : final bool hidden;
29 : final bool showDivider;
30 : final int count;
31 : final bool skip;
32 :
33 1 : const BudgetLineWidget({
34 : super.key,
35 : required this.uuid,
36 : required this.title,
37 : required this.details,
38 : required this.description,
39 : required this.color,
40 : required this.amount,
41 : required this.icon,
42 : required this.width,
43 : this.count = 1,
44 : this.hidden = false,
45 : this.skip = false,
46 : this.progress = 1,
47 : this.route = '',
48 : this.showDivider = true,
49 : });
50 :
51 1 : @override
52 : Widget build(BuildContext context) {
53 1 : if (hidden) {
54 : return ThemeHelper.emptyBox;
55 : }
56 1 : final indent = ThemeHelper.getIndent();
57 1 : final textTheme = context.textTheme;
58 : const iconSize = 18.0;
59 1 : return BaseSwipeWidget(
60 : routePath: AppRoute.budgetEditRoute,
61 1 : uuid: uuid,
62 1 : child: TapWidget(
63 : tooltip: '',
64 4 : route: RouteSettings(name: route, arguments: {routeArguments.uuid: uuid}),
65 1 : child: Column(
66 1 : crossAxisAlignment: AppDesign.getAlignment(),
67 1 : children: [
68 2 : count > 2
69 0 : ? Padding(
70 0 : padding: EdgeInsets.symmetric(vertical: indent),
71 0 : child: RowWidget(
72 : chunk: const [20, null, 0.3, 0.15, 0.1],
73 : indent: indent,
74 0 : maxWidth: width,
75 0 : children: [
76 0 : [
77 0 : Icon(icon, color: color, size: iconSize),
78 : ],
79 0 : [
80 0 : TextWrapper(
81 0 : title,
82 0 : style: textTheme.headlineMedium?.copyWith(
83 0 : fontStyle: skip ? FontStyle.italic : FontStyle.normal,
84 : ),
85 : ),
86 : ],
87 0 : [
88 0 : Align(
89 : alignment: Alignment.centerRight,
90 0 : child: TextWrapper(description, style: textTheme.numberMedium),
91 : ),
92 : ],
93 0 : [
94 0 : Align(
95 : alignment: Alignment.centerRight,
96 : child:
97 0 : NumberWidget(amount, colorScheme: context.colorScheme, style: textTheme.numberMedium),
98 : ),
99 : ],
100 0 : [
101 0 : Container(
102 : alignment: Alignment.centerRight,
103 0 : padding: EdgeInsets.only(right: indent * 2),
104 : child:
105 0 : NumberWidget(details, colorScheme: context.colorScheme, style: textTheme.numberMedium),
106 : ),
107 : ],
108 : ],
109 : ),
110 : )
111 1 : : RowWidget(
112 1 : chunk: [
113 : iconSize,
114 : null,
115 4 : ThemeHelper.getTextWidth(Text(details, style: textTheme.numberMedium)),
116 : ],
117 : indent: indent,
118 2 : maxWidth: width + indent,
119 1 : children: [
120 1 : [
121 3 : Icon(icon, color: color, size: iconSize),
122 : ],
123 2 : if (description != '')
124 1 : [
125 1 : Column(
126 1 : crossAxisAlignment: AppDesign.getAlignment(),
127 1 : children: [
128 1 : TextWrapper(
129 1 : title,
130 2 : style: textTheme.headlineMedium?.copyWith(
131 1 : fontStyle: skip ? FontStyle.italic : FontStyle.normal,
132 : ),
133 : ),
134 3 : TextWrapper(description, style: textTheme.numberSmall),
135 : ],
136 : ),
137 : ]
138 : else
139 1 : [
140 1 : Padding(
141 3 : padding: EdgeInsets.fromLTRB(0, indent - 1, 0, indent - 1),
142 3 : child: TextWrapper(title, style: textTheme.headlineMedium),
143 : ),
144 : ],
145 1 : [
146 4 : NumberWidget(details, colorScheme: context.colorScheme, style: textTheme.numberMedium),
147 : ]
148 : ],
149 : ),
150 2 : if (showDivider) ...[
151 : ThemeHelper.hIndent05,
152 4 : BarHorizontalSingle(value: progress, width: width, color: color),
153 : ThemeHelper.hIndent05,
154 : ],
155 : ],
156 : ),
157 : ),
158 : );
159 : }
160 : }
|