1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class RideOrder {
final String orderID;
final String driverName;
final String carModel;
final Color? carColor;
final String plateNumber;
final String status;
final DateTime orderTime;
RideOrder({
required this.orderID,
required this.driverName,
required this.carModel,
required this.carColor,
required this.plateNumber,
required this.status,
required this.orderTime,
});
}
class OrderHistoryPage extends StatelessWidget {
final List<RideOrder> orders = [
RideOrder(
orderID: '001',
driverName: 'John Doe',
carModel: 'Toyota Corolla',
carColor: Colors.black,
plateNumber: 'ABC-123',
status: 'Completed',
orderTime: DateTime.now().subtract(const Duration(days: 5)),
),
RideOrder(
orderID: '002',
driverName: 'Alice Smith',
carModel: 'Honda Civic',
carColor: Colors.blue,
plateNumber: 'XYZ-789',
status: 'Cancelled',
orderTime: DateTime.now().subtract(const Duration(days: 2)),
),
RideOrder(
orderID: '004',
driverName: 'Emily Johnson',
carModel: 'Chevrolet Malibu',
carColor: Colors.green,
plateNumber: 'GHI-789',
status: 'Completed',
orderTime: DateTime.now().subtract(const Duration(days: 7)),
),
RideOrder(
orderID: '005',
driverName: 'David Wilson',
carModel: 'Tesla Model 3',
carColor: Colors.grey,
plateNumber: 'JKL-012',
status: 'Pending',
orderTime: DateTime.now().subtract(const Duration(days: 2)),
),
RideOrder(
orderID: '006',
driverName: 'Sophia Brown',
carModel: 'BMW X5',
carColor: Colors.black,
plateNumber: 'MNO-345',
status: 'Cancelled',
orderTime: DateTime.now().subtract(const Duration(days: 4)),
),
RideOrder(
orderID: '007',
driverName: 'James Davis',
carModel: 'Audi A4',
carColor: Colors.blueGrey,
plateNumber: 'PQR-678',
status: 'pending',
orderTime: DateTime.now().subtract(const Duration(days: 6)),
),
RideOrder(
orderID: '008',
driverName: 'Olivia Martinez',
carModel: 'Hyundai Elantra',
carColor: Colors.orange,
plateNumber: 'STU-901',
status: 'Completed',
orderTime: DateTime.now().subtract(const Duration(days: 9)),
),
];
Color _getStatusColor(String status) {
switch (status.toLowerCase()) {
case 'completed':
return Colors.green;
case 'pending':
return Colors.orange;
case 'cancelled':
return Colors.red;
// Add more cases for other statuses
default:
return Colors.grey;
}
}
String _formatDateTime(DateTime dateTime) {
return DateFormat('EEEE dd/MM/yyyy hh:mm a').format(dateTime);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Order History'),
),
body: ListView.builder(
itemCount: orders.length,
itemBuilder: (BuildContext context, int index) {
final RideOrder order = orders[index];
return Card(
elevation: 3,
margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
child: ListTile(
title: Row(
children: [
Expanded(
child: Text(
'${order.driverName} - ${order.carModel}',
style: const TextStyle(
fontWeight: FontWeight.bold,
),
overflow: TextOverflow.ellipsis,
),
),
],
),
subtitle: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_formatDateTime(order.orderTime),
style: const TextStyle(
fontSize: 12,
color: Colors.grey,
),
),
Text(
order.status,
style: TextStyle(
color: _getStatusColor(order.status),
),
),
],
),
Row(
children: [
Icon(Icons.time_to_leave, color: order.carColor), //
const SizedBox(width: 4),
Text(order.plateNumber),
],
),
],
),
leading: const Icon(Icons
.assignment), // Use an appropriate icon for order history
onTap: () {
// Handle tapping on a specific order (if needed)
print('Selected Order ID: ${order.orderID}');
},
),
);
},
),
);
}
}
|