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/_classes/structure/goal_app_data.dart';
8 : import 'package:app_finance/_configs/custom_text_theme.dart';
9 : import 'package:app_finance/_ext/build_context_ext.dart';
10 : import 'package:app_finance/design/wrapper/tap_widget.dart';
11 : import 'package:app_finance/_configs/theme_helper.dart';
12 : import 'package:app_finance/design/wrapper/text_wrapper.dart';
13 : import 'package:flutter/material.dart';
14 : import 'package:flutter_grid_layout/flutter_grid_layout.dart';
15 :
16 : class GoalLineWidget extends StatelessWidget {
17 : final GoalAppData goal;
18 : final double? width;
19 :
20 0 : const GoalLineWidget({
21 : super.key,
22 : required this.goal,
23 : this.width,
24 : });
25 :
26 0 : @override
27 : Widget build(context) {
28 0 : final indent = ThemeHelper.getIndent();
29 0 : final ColorScheme colorScheme = context.colorScheme;
30 0 : final TextTheme textTheme = context.textTheme;
31 0 : double screenWidth = (width ?? ThemeHelper.getWidth(context, 2)) - indent * 1.5;
32 0 : return TapWidget(
33 0 : tooltip: AppLocale.labels.goalTooltip,
34 : route: const RouteSettings(name: AppRoute.goalRoute),
35 0 : child: Container(
36 0 : color: colorScheme.inversePrimary,
37 : height: 20,
38 0 : child: GridContainer(
39 0 : alignment: AppDesign.getAlignment<MainAxisAlignment>(),
40 0 : rows: [indent, null, null, indent],
41 0 : columns: [indent, 18, 24, indent, indent, indent / 2],
42 0 : children: [
43 0 : if (goal.progress == 1)
44 0 : GridItem(
45 : start: const Size(2, 0),
46 : end: const Size(4, 4),
47 : order: 3,
48 0 : child: Banner(
49 0 : message: AppLocale.labels.processIsFinished,
50 0 : location: AppDesign.isRightToLeft() ? BannerLocation.topStart : BannerLocation.topEnd,
51 0 : textStyle: textTheme.numberSmall,
52 : ),
53 : ),
54 0 : GridItem(
55 : start: const Size(1, 1),
56 : end: const Size(2, 2),
57 0 : child: TextWrapper(
58 0 : AppLocale.labels.goalHeadline,
59 0 : style: textTheme.headlineSmall,
60 : ),
61 : ),
62 0 : GridItem(
63 : start: const Size(1, 2),
64 : end: const Size(3, 3),
65 0 : child: TextWrapper(
66 0 : goal.title,
67 0 : style: textTheme.headlineMedium,
68 : ),
69 : ),
70 0 : GridItem(
71 : start: const Size(2, 2),
72 : end: const Size(3, 3),
73 0 : child: Padding(
74 0 : padding: EdgeInsets.only(top: ThemeHelper.getIndent(0.7)),
75 0 : child: Text(
76 0 : goal.closedAtFormatted,
77 0 : style: textTheme.headlineSmall,
78 0 : textAlign: AppDesign.isRightToLeft() ? TextAlign.left : TextAlign.right,
79 : overflow: TextOverflow.ellipsis,
80 : ),
81 : ),
82 : ),
83 0 : GridItem(
84 : start: const Size(1, 3),
85 : end: const Size(3, 4),
86 0 : child: LinearProgressIndicator(
87 0 : value: goal.progress,
88 0 : backgroundColor: colorScheme.primary.withOpacity(0.3),
89 0 : valueColor: AlwaysStoppedAnimation<Color>(colorScheme.onPrimaryContainer),
90 : ),
91 : ),
92 0 : GridItem(
93 : start: const Size(1, 3),
94 : end: const Size(3, 4),
95 : order: 2,
96 0 : child: Container(
97 : alignment: Alignment.topLeft,
98 0 : margin: EdgeInsets.only(left: screenWidth * goal.state),
99 : height: 5.0,
100 0 : child: Tooltip(
101 0 : message: AppLocale.labels.currentDate,
102 0 : child: Container(
103 : width: 5.0,
104 0 : decoration: BoxDecoration(
105 0 : color: colorScheme.inversePrimary,
106 : shape: BoxShape.circle,
107 : ),
108 : ),
109 : ),
110 : ),
111 : ),
112 : ],
113 : ),
114 : ),
115 : );
116 : }
117 : }
|