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/herald/app_locale.dart';
6 : import 'package:app_finance/_classes/structure/navigation/app_route.dart';
7 : import 'package:app_finance/_configs/custom_text_theme.dart';
8 : import 'package:app_finance/_configs/theme_helper.dart';
9 : import 'package:app_finance/_ext/build_context_ext.dart';
10 : import 'package:app_finance/design/wrapper/row_widget.dart';
11 : import 'package:app_finance/design/wrapper/tap_widget.dart';
12 : import 'package:app_finance/design/wrapper/text_wrapper.dart';
13 : import 'package:material_ui/material_ui.dart';
14 :
15 : class BillLineWidget extends StatelessWidget {
16 : final String uuid;
17 : final String title;
18 : final String details;
19 : final String description;
20 : final Color descriptionColor;
21 : final double progress;
22 : final Color color;
23 : final IconData icon;
24 : final String iconTooltip;
25 : final String route;
26 : final bool hidden;
27 : final double width;
28 : final int count;
29 :
30 1 : const BillLineWidget({
31 : super.key,
32 : required this.uuid,
33 : required this.title,
34 : required this.details,
35 : required this.description,
36 : required this.descriptionColor,
37 : required this.color,
38 : required this.icon,
39 : required this.iconTooltip,
40 : required this.width,
41 : this.count = 1,
42 : this.hidden = false,
43 : this.progress = 1,
44 : this.route = '',
45 : });
46 :
47 1 : @override
48 : Widget build(BuildContext context) {
49 1 : if (hidden) {
50 : return ThemeHelper.emptyBox;
51 : }
52 1 : final indent = ThemeHelper.getIndent(0.5);
53 1 : final textTheme = context.textTheme;
54 :
55 1 : return Padding(
56 2 : padding: EdgeInsets.fromLTRB(indent, indent, indent * 2, indent),
57 1 : child: TapWidget(
58 : tooltip: '',
59 4 : route: RouteSettings(name: route, arguments: {routeArguments.uuid: uuid}),
60 2 : child: count > 2
61 0 : ? RowWidget(
62 0 : maxWidth: width,
63 : indent: indent,
64 : chunk: const [24, null, 0.2, 0.2, 0.1],
65 0 : children: [
66 0 : [
67 0 : Padding(
68 0 : padding: EdgeInsets.only(top: indent, left: indent),
69 0 : child: Icon(icon, color: color, size: 20),
70 : ),
71 : ],
72 0 : [
73 0 : Padding(
74 0 : padding: EdgeInsets.only(top: indent),
75 0 : child: TextWrapper(title, style: textTheme.headlineMedium),
76 : ),
77 : ],
78 0 : [
79 0 : TextWrapper(AppLocale.labels.account, style: textTheme.bodySmall),
80 0 : TextWrapper(
81 0 : description,
82 0 : style: textTheme.headlineMedium?.copyWith(
83 0 : color: Color.alphaBlend(descriptionColor.withValues(alpha: 0.4), context.colorScheme.secondary),
84 : ),
85 : ),
86 : ],
87 0 : [
88 0 : TextWrapper(AppLocale.labels.budget, style: textTheme.bodySmall),
89 0 : TextWrapper(
90 0 : iconTooltip,
91 0 : style: textTheme.headlineMedium?.copyWith(
92 0 : color: Color.alphaBlend(color.withValues(alpha: 0.4), context.colorScheme.secondary),
93 : ),
94 : ),
95 : ],
96 0 : [
97 0 : Container(
98 : alignment: Alignment.centerRight,
99 0 : padding: EdgeInsets.only(top: indent, right: indent),
100 0 : child: TextWrapper(details, style: textTheme.numberMedium),
101 : ),
102 : ]
103 : ],
104 : )
105 1 : : RowWidget(
106 1 : chunk: [
107 : 20,
108 : null,
109 2 : ThemeHelper.getTextWidth(Text(
110 1 : details,
111 : maxLines: 1,
112 1 : style: textTheme.numberMedium,
113 : overflow: TextOverflow.ellipsis,
114 : )),
115 : ],
116 1 : indent: indent * 2,
117 1 : maxWidth: width,
118 1 : children: [
119 1 : [
120 1 : Tooltip(
121 1 : message: iconTooltip,
122 3 : child: Icon(icon, color: color, size: 20),
123 : ),
124 : ],
125 1 : [
126 1 : Column(
127 1 : crossAxisAlignment: AppDesign.getAlignment(),
128 1 : children: [
129 3 : TextWrapper(title, style: textTheme.headlineMedium),
130 1 : TextWrapper(
131 1 : description,
132 2 : style: textTheme.numberSmall.copyWith(
133 1 : color: Color.alphaBlend(
134 4 : descriptionColor.withValues(alpha: 0.4), context.colorScheme.secondary),
135 : ),
136 : ),
137 : ],
138 : ),
139 : ],
140 1 : [
141 3 : TextWrapper(details, style: textTheme.numberMedium),
142 : ]
143 : ],
144 : ),
145 : ),
146 : );
147 : }
148 : }
|