Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
request_card.dart
Go to the documentation of this file.
1import 'package:flutter/material.dart';
2import 'package:flutter_screenutil/flutter_screenutil.dart';
3
4import '../../../../core/UI/widgets/custom_card.dart';
5import '../../../../core/UI/theme/color_palette.dart';
6import '../../../models/driver_request.dart';
7
8class RequestCard extends StatefulWidget {
10 final VoidCallback onViewMore;
11
13 super.key,
14 required this.request,
15 required this.onViewMore,
16 });
17
18 @override
19 State<RequestCard> createState() => _RequestCardState();
20}
21
22class _RequestCardState extends State<RequestCard>
23 with TickerProviderStateMixin {
24 late AnimationController _animationController;
25 late AnimationController _tapAnimationController;
26 late Animation<double> _scaleAnimation;
27 late Animation<double> _tapScaleAnimation;
28 bool _isPressed = false;
29
30 @override
31 void initState() {
32 super.initState();
33 _animationController = AnimationController(
34 duration: const Duration(milliseconds: 300),
35 vsync: this,
36 );
37 _tapAnimationController = AnimationController(
38 duration: const Duration(milliseconds: 150),
39 vsync: this,
40 );
41
42 _scaleAnimation = Tween<double>(
43 begin: 0.8,
44 end: 1.0,
45 ).animate(CurvedAnimation(
47 curve: Curves.easeOutBack,
48 ));
49
50 _tapScaleAnimation = Tween<double>(
51 begin: 1.0,
52 end: 0.95,
53 ).animate(CurvedAnimation(
55 curve: Curves.easeInOut,
56 ));
57
58 _animationController.forward();
59 }
60
61 @override
62 void dispose() {
63 _animationController.dispose();
65 super.dispose();
66 }
67
68 @override
69 Widget build(BuildContext context) {
70 return AnimatedBuilder(
71 animation:
73 builder: (context, child) {
74 return Transform.scale(
75 scale: _scaleAnimation.value * _tapScaleAnimation.value,
76 child: CustomCard(
77 bgColor: ColorPalette.white,
78 child: Material(
79 color: Colors.transparent,
80 child: InkWell(
81 borderRadius: BorderRadius.circular(10),
82 onTap: () {
83 _handleCardTap();
84 },
85 child: Container(
86 decoration: BoxDecoration(
87 borderRadius: BorderRadius.circular(10),
88 border: Border.all(
90 ? ColorPalette.lightGreen.withValues(alpha: 0.3)
91 : Colors.transparent,
92 width: 2,
93 ),
94 ),
95 padding: EdgeInsets.all(7.sp),
97 crossAxisAlignment: CrossAxisAlignment.start,
98 children: [
100 SizedBox(height: 10.h),
102 ],
103 ),
104 ),
105 ),
106 ),
107 ),
108 );
109 },
110 );
111 }
112
114 setState(() => _isPressed = true);
115 _tapAnimationController.forward().then((_) {
116 _tapAnimationController.reverse();
117 });
118
119 Future.delayed(const Duration(milliseconds: 150), () {
120 if (mounted) {
121 setState(() => _isPressed = false);
122 widget.onViewMore();
123 }
124 });
125 }
126
127 Widget _buildHeader() {
128 return Row(
129 mainAxisAlignment: MainAxisAlignment.spaceBetween,
130 children: [
131 Text(
132 widget.request.id,
133 style: TextStyle(
134 fontSize: 14.sp,
135 fontWeight: FontWeight.bold,
137 ),
138 ),
139 Container(
140 padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 4.h),
141 decoration: BoxDecoration(
142 color: ColorPalette.lightGreen.withValues(alpha: 0.1),
143 borderRadius: BorderRadius.circular(12.r),
144 ),
145 child: Row(
146 mainAxisSize: MainAxisSize.min,
147 children: [
148 Text(
149 'Tap to view',
150 style: TextStyle(
151 fontSize: 8.5.sp,
153 fontWeight: FontWeight.w500,
154 ),
155 ),
156 SizedBox(width: 4.w),
157 Icon(
158 Icons.touch_app,
159 size: 12.sp,
161 ),
162 ],
163 ),
164 ),
165 ],
166 );
167 }
168
169 Widget _buildDetails() {
170 return Wrap(
171 spacing: 12.w,
172 runSpacing: 12.h,
173 children: [
175 icon: Icons.person,
176 label: 'Driver',
177 value: widget.request.driverName,
178 ),
180 icon: Icons.person,
181 label: 'Stations: ',
182 value: ' ${widget.request.numberOfStations} stations',
183 ),
185 icon: Icons.calendar_today,
186 label: 'Created at:',
187 value:
188 '${widget.request.creationDate.hour.toString().padLeft(2, '0')}:${widget.request.creationDate.minute.toString().padLeft(2, '0')}',
189 ),
190 ],
191 );
192 }
193
195 required IconData icon,
196 required String label,
197 required String value,
198 }) {
199 return Row(
200 mainAxisSize: MainAxisSize.min,
201 children: [
202 Row(
203 mainAxisSize: MainAxisSize.min,
204 children: [
205 Text(
206 '$label: ',
207 style: TextStyle(
208 fontSize: 12.sp,
210 fontWeight: FontWeight.w500,
211 ),
212 ),
213 Text(
214 value,
215 style: TextStyle(
216 fontSize: 12.sp,
217 fontWeight: FontWeight.w500,
219 ),
220 overflow: TextOverflow.ellipsis,
221 ),
222 ],
223 ),
224 ],
225 );
226 }
227}
override void initState()
override void dispose()
class App extends StatefulWidget build(BuildContext context)
Definition app.dart:31
AuthGuard _()
static const darkGrey
static const lightGreen
static const grey
const RequestCard({ super.key, required this.request, required this.onViewMore, })
final DriverRequest request
override State< RequestCard > createState()
final VoidCallback onViewMore
late AnimationController _animationController
final Widget child
final EdgeInsets padding
late Animation< double > _scaleAnimation
bool _isPressed
class Partner String
Widget _buildHeader()
DriverRequest({ required this.id, required this.driverName, required this.creationDate, required this.stations, required this.startPoint, required this.endPoint, })
final Color color
Definition failures.dart:1
void _handleCardTap()
late AnimationController _tapAnimationController
Widget _buildHeader()
late Animation< double > _tapScaleAnimation
Widget _buildDetailRow({ required IconData icon, required String label, required String value, })
Widget _buildDetails()
final String label
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,),),),],)