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
|
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: 'Omar Magdy',
carModel: 'Toyota Corolla',
carColor: Colors.black,
plateNumber: 'ABC-123',
status: 'Completed',
orderTime: DateTime.now(),
),
];
Color _getStatusColor(String status) {
switch (status.toLowerCase()) {
case 'completed':
return Colors.green;
case 'pending':
return Colors.orange;
case 'cancelled':
return Colors.red;
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}');
},
),
);
},
),
);
}
}
|