Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
today_collections.dart
Go to the documentation of this file.
1import 'dart:ui';
2
3import 'package:easy_localization/easy_localization.dart';
4import 'package:fluentui_system_icons/fluentui_system_icons.dart';
5import 'package:flutter/material.dart';
6import 'package:percent_indicator/percent_indicator.dart';
7
8import '../../../../../core/ui/theme/color_palette.dart';
9
10class TodayCollections extends StatelessWidget {
14 final String done;
17 final bool isPeriodSection;
18
20 super.key,
21 required this.completedPercentage,
22 required this.totalCollections,
23 required this.collectionsVolume,
24 required this.done,
25 required this.canceled,
26 required this.pendingCollections,
27 this.isPeriodSection = false,
28
29 });
30
31 @override
32 Widget build(BuildContext context) {
33 return Container(
34 decoration: BoxDecoration(
35 gradient: LinearGradient(
36 begin: Alignment.topLeft,
37 end: Alignment.bottomRight,
38 colors: [
40 ColorPalette.antiFlashWhite.withValues(alpha: 0.5),
41 ],
42 ),
43 borderRadius: BorderRadius.circular(24),
44 boxShadow: [
45 BoxShadow(
46 color: ColorPalette.black.withValues(alpha: 0.05),
47 blurRadius: 20,
48 offset: const Offset(0, 10),
49 ),
50 ],
51 ),
52 child: ClipRRect(
53 borderRadius: BorderRadius.circular(24),
54 child: BackdropFilter(
55 filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
56 child: Container(
57 padding: const EdgeInsets.all(24),
58 decoration: BoxDecoration(
59 color: ColorPalette.white.withValues(alpha: 0.9),
60 borderRadius: BorderRadius.circular(24),
61 ),
63 crossAxisAlignment: CrossAxisAlignment.start,
64 children: [
65 !isPeriodSection ? Row(
66 mainAxisAlignment: MainAxisAlignment.spaceBetween,
67 children: [
68 Column(
69 crossAxisAlignment: CrossAxisAlignment.start,
70 children: [
71 Text(
72 "dashboard.today_collections".tr(),
73 style: Theme.of(context).textTheme.titleLarge?.copyWith(
75 fontWeight: FontWeight.bold,
76 ),
77 ),
78 const SizedBox(height: 4),
79 Container(
80 padding: const EdgeInsets.symmetric(
81 horizontal: 12,
82 vertical: 6,
83 ),
84 decoration: BoxDecoration(
85 color: ColorPalette.lightGreen.withValues(alpha: 0.1),
86 borderRadius: BorderRadius.circular(12),
87 ),
88 child: Text(
89 DateFormat('dd MMM yyyy').format(DateTime.now()),
90 style: const TextStyle(
92 fontWeight: FontWeight.w600,
93 fontSize: 14,
94 ),
95 ),
96 ),
97 ],
98 ),
99 ],
100 ) : SizedBox.shrink(),
101 !isPeriodSection ? const SizedBox(height: 32) : SizedBox.shrink(),
102 Row(
103 mainAxisAlignment: MainAxisAlignment.spaceBetween,
104 children: [
105 // _buildCollectionItem(
106 // "Collections",
107 // totalCollections,
108 // ColorPalette.lightGreen,
109 // FluentIcons.checkmark_circle_12_regular,
110 // ),
111 // const SizedBox(height: 20),
112 // _buildCollectionItem(
113 // "Volume",
114 // "$collectionsVolume KG",
115 // ColorPalette.blue,
116 // FluentIcons.drop_12_regular,
117 // ),
118 Container(
119 padding: const EdgeInsets.all(16),
120 child: CircularPercentIndicator(
121 radius: 55.0,
122 lineWidth: 10.0,
123 percent: double.parse(completedPercentage) / 100,
124 center: Column(
125 mainAxisAlignment: MainAxisAlignment.center,
126 children: [
127 Text(
128 "$completedPercentage%",
129 style: TextStyle(
130 fontSize: 19,
131 fontWeight: FontWeight.bold,
133 ),
134 ),
135 Text(
136 "dashboard.completed".tr(),
137 style: TextStyle(
138 fontSize: 12,
140 ),
141 ),
142 ],
143 ),
144 progressColor: ColorPalette.lightGreen,
145 backgroundColor: ColorPalette.lightGreen.withValues(alpha: 0.1),
146 circularStrokeCap: CircularStrokeCap.round,
147 ),
148 ),
149 const SizedBox(width: 24),
150 Expanded(
151 child: Column(
152 crossAxisAlignment: CrossAxisAlignment.start,
153 children: [
155 "dashboard.done".tr(),
156 done,
158 FluentIcons.checkmark_circle_12_regular,
159 ),
160 const SizedBox(height: 20),
162 "dashboard.volume".tr(),
165 FluentIcons.drop_12_regular,
166 ),
167 ],
168 ),
169 ),
170 ],
171 ),
172 const SizedBox(height: 24),
173 Container(
174 padding: const EdgeInsets.all(16),
175 decoration: BoxDecoration(
177 borderRadius: BorderRadius.circular(16),
178 ),
179 child: Column(
180 children: [
181 Row(
182 mainAxisAlignment: MainAxisAlignment.spaceBetween,
183 children: [
187 "dashboard.total".tr(),
188 ),
189 Container(
190 width: 1,
191 height: 40,
192 color: ColorPalette.grey.withValues(alpha: 0.2),
193 ),
196 canceled,
197 "dashboard.canceled".tr(),
198 ),
199 ],
200 ),
201 !isPeriodSection ? const SizedBox(height: 16) : SizedBox.shrink(),
202 !isPeriodSection ? Row(
203 children: [
204 Icon(
205 Icons.timer_outlined,
206 size: 20,
208 ),
209 SizedBox(width: 8),
210 Text(
211 // "Pending collections: ",
212 "dashboard.pending_collections".tr(),
213 style: TextStyle(
215 fontSize: 14,
216 ),
217 ),
218 Text(
220 style: TextStyle(
222 fontWeight: FontWeight.bold,
223 fontSize: 14,
224 ),
225 ),
226 ],
227 ) : SizedBox.shrink(),
228 ],
229 ),
230 ),
231 ],
232 ),
233 ),
234 ),
235 ),
236 );
237 }
238
242 Color valueColor,
243 IconData icon,
244 ) {
245 // Format the value if it's for Volume
246 if (label == "Volume") {
247 try {
248 // Extract the numeric part, handling cases where unit might or might not be present
249 double numericValue;
250 if (value.contains("KG")) {
251 numericValue = double.parse(value.replaceAll(" KG", ""));
252 } else if (value.contains("MT")) {
253 numericValue = double.parse(value.replaceAll(" MT", "")) * 1000;
254 } else {
255 // No unit present, assume it's a raw number
256 numericValue = double.parse(value);
257 }
258
259 // Format based on value
260 if (numericValue >= 1000) {
261 // Convert to metric tons
262 value = "${(numericValue / 1000).toStringAsFixed(2)} MT";
263 } else {
264 // Ensure values under 1000 show KG
265 value = "$numericValue KG";
266 }
267 } catch (e) {
268 // Keep original value if parsing fails
269 if (!value.contains("KG") && !value.contains("MT")) {
270 value = "$value KG"; // Add KG if no unit is present
271 }
272 }
273 }
274
275 return Container(
276 padding: const EdgeInsets.all(16),
277 decoration: BoxDecoration(
278 color: valueColor.withValues(alpha: 0.1),
279 borderRadius: BorderRadius.circular(16),
280 ),
281 child: Row(
282 children: [
283 Icon(icon, color: valueColor),
284 const SizedBox(width: 12),
285 Column(
286 crossAxisAlignment: CrossAxisAlignment.start,
287 children: [
288 Text(
289 label,
290 style: const TextStyle(
292 fontSize: 14,
293 ),
294 ),
295 Text(
296 value,
297 style: TextStyle(
298 color: valueColor,
299 fontWeight: FontWeight.bold,
300 fontSize: 17,
301 ),
302 ),
303 ],
304 ),
305 ],
306 ),
307 );
308 }
309
311 return Row(
312 children: [
313 Container(
314 width: 40,
315 height: 40,
316 decoration: BoxDecoration(
317 color: color.withValues(alpha: 0.1),
318 shape: BoxShape.circle,
319 ),
320 child: Center(
321 child: Text(
322 value,
323 style: TextStyle(
324 color: color,
325 fontWeight: FontWeight.bold,
326 fontSize: 16,
327 ),
328 ),
329 ),
330 ),
331 const SizedBox(width: 8),
332 Text(
333 label,
334 style: const TextStyle(
336 fontSize: 14,
337 ),
338 ),
339 ],
340 );
341 }
342}
static const darkGrey
static const lightGreen
static const black
static const white
static const antiFlashWhite
static const orange
static const blue
static const grey
final String completedPercentage
final String collectionsVolume
final Widget child
final LinearGradient gradient
override Widget build(BuildContext context)
const TodayCollections({ super.key, required this.completedPercentage, required this.totalCollections, required this.collectionsVolume, required this.done, required this.canceled, required this.pendingCollections, this.isPeriodSection=false, })
Widget _buildCollectionItem(String label, String value, Color valueColor, IconData icon,)
Widget _buildStatusItem(Color color, String value, String label)
final String pendingCollections
final EdgeInsets padding
final int totalCollections
class Partner String
style Text( '${ 'scheduling.reference'.tr()}:${collection.internalCode}', style:Theme.of(context).textTheme.bodySmall,)
style SizedBox(height:2.h)
style Column(crossAxisAlignment:CrossAxisAlignment.end, children:[Container(padding:EdgeInsets.symmetric(horizontal:8.w, vertical:4.h), decoration:BoxDecoration(color:ColorPalette.tiffanyBlue.withValues(alpha:0.1), borderRadius:BorderRadius.circular(12),), child:Text(collection.type ?? '', style:Theme.of(context).textTheme.bodySmall?.copyWith(color:ColorPalette.tiffanyBlue, fontWeight:FontWeight.bold,),),),],)