Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
collection_item.dart
Go to the documentation of this file.
1import 'package:easy_localization/easy_localization.dart';
2import 'package:fluentui_system_icons/fluentui_system_icons.dart';
3import 'package:flutter/material.dart';
4import 'package:flutter_screenutil/flutter_screenutil.dart';
5import '../../../common/enums/collection_priority.dart';
6import '../../theme/color_palette.dart';
7import '../../../common/enums/collection_status.dart';
8import '../../../common/entities/collection_entity.dart';
9import '../collection_badges/collection_status_badge.dart';
10import '../collection_badges/collection_priority_badge.dart';
11import 'collection_info_row.dart';
12
13class CollectionItem extends StatelessWidget {
16 final bool showNumber;
17 final bool isCompleted;
18 final bool isPending;
19 final bool hidePriority;
20 final bool hideStatus;
21 final bool isHistory;
22
24 super.key,
25 required this.collection,
26 required this.number,
27 required this.showNumber,
28 this.isCompleted = false,
29 this.isPending = false,
30 this.hidePriority = false,
31 this.hideStatus = false,
32 this.isHistory = false,
33 });
34
35 @override
36 Widget build(BuildContext context) {
37 return Container(
38 margin: EdgeInsets.fromLTRB(16.sp, 8.sp, 16.sp, 8.sp),
39 decoration: BoxDecoration(
41 borderRadius: BorderRadius.circular(20),
42 boxShadow: [
43 BoxShadow(
44 color: ColorPalette.black.withValues(alpha:0.04),
45 blurRadius: 15,
46 offset: const Offset(0, 5),
47 ),
48 ],
49 ),
51 children: [
52 Padding(
53 padding: EdgeInsets.all(16.sp),
54 child: Row(
55 children: [
56 showNumber ? Container(
57 width: 40,
58 height: 40,
59 decoration: BoxDecoration(
60 shape: BoxShape.circle,
61 gradient: LinearGradient(
62 colors: collection.status == CollectionStatus.onTheWay
65 ),
66 ),
67 child: Center(
68 child: Text(
69 number,
70 style: Theme.of(context).textTheme.titleSmall!.copyWith(
72 fontWeight: FontWeight.w600,
73 ),
74 ),
75 ),
76 ) : const SizedBox.shrink(),
77 showNumber ? SizedBox(width: 16.sp) : const SizedBox.shrink(),
78 Expanded(
80 crossAxisAlignment: CrossAxisAlignment.start,
81 children: [
82 Text(
83 collection.restaurant ?? "--",
84 style: Theme.of(context).textTheme.titleMedium!.copyWith(
86 fontWeight: FontWeight.w500,
87 ),
88 ),
89 SizedBox(height: 4.sp),
90 Text(
91 "CV Reference: ${collection.reference ?? "--"}",
92 style: Theme.of(context).textTheme.titleSmall!.copyWith(
94 ),
95 ),
96 SizedBox(height: 4.sp),
97 Text(
99 style: Theme.of(context).textTheme.titleSmall!.copyWith(
101 ),
102 ),
103 // SizedBox(height: 4.sp),
104 // (isHistory || isPending) ? Text(
105 // "Ref: ${collection.reference ?? "--"}",
106 // style: Theme.of(context).textTheme.titleSmall!.copyWith(
107 // color: ColorPalette.grey,
108 // ),
109 // ) : const SizedBox.shrink(),
110 ],
111 ),
112 ),
113 Column(
114 crossAxisAlignment: CrossAxisAlignment.end,
115 children: [
116 hideStatus ? const SizedBox.shrink() : CollectionStatusBadge(
117 status: collection.status ?? CollectionStatus.defaultStatus,
118 ),
119 SizedBox(height: 8.sp),
121 priority: collection.priority ?? CollectionPriority.defaultPriority,
122 ),
123 ],
124 ),
125 ],
126 ),
127 ),
128 Divider(height: 1.sp),
129 Padding(
130 padding: EdgeInsets.all(16.sp),
131 child: Column(
132 children: [
134 label: 'collection_card.address'.tr(),
135 value: collection.address ?? "--",
136 icon: FluentIcons.location_12_regular,
137 ),
138 SizedBox(height: 12.sp),
140 label: isHistory ? 'collection_card.declared_quantity'.tr() : 'collection_card.quantity'.tr(),
142 icon: FluentIcons.drop_12_regular,
143 ),
144 SizedBox(height: 12.sp),
146 label: 'collection_card.collected_quantity'.tr(),
147 value: formatVolume(collection.volumeCollected),
148 icon: FluentIcons.drop_12_regular,
150 label: 'collection_card.time_slot'.tr(),
151 value: "${collection.startTime ?? 'N/A'} - ${collection.endTime ?? 'N/A'}",
152 icon: FluentIcons.clock_12_regular,
153 ),
154 ],
155 ),
156 ),
157 ],
158 ),
159 );
160 }
161
163 if (volume == null) return "--";
164 double volumeValue = volume is double ? volume : double.tryParse(volume.toString()) ?? 0.0;
165 if (volumeValue > 999) {
166 return '${(volumeValue / 1000).toStringAsFixed(2)} MT';
167 } else {
168 return '$volumeValue KG';
169 }
170 }
171
173 if (isCompleted) return "${'collection_card.done_on'.tr()} ${collection.datePlanned}";
174 if (isPending) return "${'collection_card.scheduled_for'.tr()} ${collection.datePlanned}";
175 return '${collection.datePlanned} | ${collection.slot}';
176 }
177}
static const darkGrey
static const lightGreen
static const black
static const white
static const darkGreen
static const grey
String formatVolume(dynamic volume)
final Widget child
final LinearGradient gradient
const CollectionStatusBadge({ super.key, required this.status, })
final CollectionPriority priority
const CollectionItem({ super.key, required this.collection, required this.number, required this.showNumber, this.isCompleted=false, this.isPending=false, this.hidePriority=false, this.hideStatus=false, this.isHistory=false, })
override Widget build(BuildContext context)
final CollectionEntity collection
const CollectionPriorityBadge({ super.key, required this.priority, })
final CollectionStatus status
const CollectionInfoRow({ super.key, required this.label, required this.value, required this.icon, })
final EdgeInsets padding
CollectionStatus
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,),),),],)