Skip to content

Commit 715cbbd

Browse files
Add Order details Screen
1 parent 7c140a9 commit 715cbbd

File tree

5 files changed

+254
-3
lines changed

5 files changed

+254
-3
lines changed

lib/consts/list.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ const itemDetailsButtonsList = [
4343
supportPolicy
4444
];
4545

46-
const profileButtonList = [wishlist, orders, messages];
47-
const profileButtonIconsList = [icOrder, icOrder, icMessages];
46+
const profileButtonList = [orders, wishlist, messages];
47+
const profileButtonIconsList = [icOrders, icHeart, icMessages];
4848

4949
const paymentMethodsImgList = [imgCod, imgStripe, imgPaypal];
5050
const paymentMethhodsList = [cod, stripe, paypal];
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import 'package:emart/consts/consts.dart';
2+
3+
Widget orderStatus({icon, color, String? title, showDone}) => ListTile(
4+
leading: Icon(
5+
icon,
6+
color: color,
7+
size: 30,
8+
)
9+
.box
10+
.border(color: color)
11+
.roundedSM
12+
.padding(const EdgeInsets.all(4))
13+
.make(),
14+
trailing: SizedBox(
15+
height: 100,
16+
width: 120,
17+
child: Row(
18+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
19+
children: [
20+
title!.text.color(darkFontGrey).size(16).make(),
21+
showDone
22+
? const Icon(
23+
Icons.done,
24+
color: redColor,
25+
)
26+
: const SizedBox.shrink(),
27+
],
28+
),
29+
),
30+
);
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
import 'package:emart/consts/consts.dart';
2+
import 'package:emart/views/orders_screen_view/components/order_status.dart';
3+
import 'package:emart/views/orders_screen_view/order_placed_details.dart';
4+
import 'package:intl/intl.dart' as intl;
5+
6+
class OrderDetailsScreen extends StatelessWidget {
7+
final dynamic data;
8+
const OrderDetailsScreen({
9+
super.key,
10+
this.data,
11+
});
12+
13+
@override
14+
Widget build(BuildContext context) {
15+
return Scaffold(
16+
backgroundColor: whiteColor,
17+
appBar: AppBar(
18+
title: "Order Details"
19+
.text
20+
.fontFamily(semibold)
21+
.color(darkFontGrey)
22+
.make(),
23+
),
24+
body: Padding(
25+
padding: const EdgeInsets.all(12),
26+
child: SingleChildScrollView(
27+
child: Column(
28+
children: [
29+
orderStatus(
30+
color: redColor,
31+
icon: Icons.done,
32+
title: "Placed",
33+
showDone: data['order_placed'],
34+
),
35+
orderStatus(
36+
color: Colors.blue,
37+
icon: Icons.thumb_up_alt,
38+
title: "Confirmed",
39+
showDone: data['order_confirmed'],
40+
),
41+
orderStatus(
42+
color: Colors.yellow,
43+
icon: Icons.delivery_dining_outlined,
44+
title: "On Delivery",
45+
showDone: data['order_on_delivery'],
46+
),
47+
orderStatus(
48+
color: Colors.purple,
49+
icon: Icons.done_all,
50+
title: "Delivered",
51+
showDone: data['order_delivered'],
52+
),
53+
const Divider(color: Colors.black54),
54+
10.heightBox,
55+
Column(
56+
children: [
57+
orderPlacedDetails(
58+
title1: "Order code",
59+
details1: data['order_code'],
60+
title2: "Shipping Method",
61+
details2: data['shipping_method'],
62+
),
63+
orderPlacedDetails(
64+
title1: "Order date",
65+
details1: intl.DateFormat()
66+
.add_yMd()
67+
.format(data['order_date'].toDate()),
68+
title2: "Payment Method",
69+
details2: data['payment_method'],
70+
),
71+
orderPlacedDetails(
72+
title1: "Payment status",
73+
details1: "Unpaid",
74+
title2: "Delivery status",
75+
details2: "Order placed",
76+
),
77+
Padding(
78+
padding: const EdgeInsets.symmetric(
79+
horizontal: 16.0, vertical: 8),
80+
child: Row(
81+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
82+
children: [
83+
Column(
84+
crossAxisAlignment: CrossAxisAlignment.start,
85+
children: [
86+
"Shipping Address".text.fontFamily(semibold).make(),
87+
"${data['order_by_name']}"
88+
.text
89+
.color(darkFontGrey)
90+
.make(),
91+
"${data['order_by_email']}"
92+
.text
93+
.color(darkFontGrey)
94+
.make(),
95+
"${data['order_by_address']}"
96+
.text
97+
.color(darkFontGrey)
98+
.make(),
99+
"${data['order_by_city']}"
100+
.text
101+
.color(darkFontGrey)
102+
.make(),
103+
"${data['order_by_phone']}"
104+
.text
105+
.color(darkFontGrey)
106+
.make(),
107+
"${data['order_by_postal_code']}"
108+
.text
109+
.color(darkFontGrey)
110+
.make(),
111+
],
112+
),
113+
SizedBox(
114+
width: 130,
115+
child: Column(
116+
mainAxisAlignment: MainAxisAlignment.start,
117+
crossAxisAlignment: CrossAxisAlignment.start,
118+
children: [
119+
"Total Amount".text.fontFamily(semibold).make(),
120+
const SizedBox(height: 20),
121+
"${data['total_amount']}"
122+
.text
123+
.fontFamily(bold)
124+
.color(redColor)
125+
.make(),
126+
],
127+
),
128+
),
129+
],
130+
),
131+
),
132+
],
133+
).box.outerShadowMd.white.make(),
134+
const Divider(),
135+
10.heightBox,
136+
"Ordered Product"
137+
.text
138+
.size(16)
139+
.color(darkFontGrey)
140+
.fontFamily(semibold)
141+
.make(),
142+
10.heightBox,
143+
ListView(
144+
physics: const NeverScrollableScrollPhysics(),
145+
shrinkWrap: true,
146+
children: List.generate(
147+
data['orders'].length,
148+
(index) => orderPlacedDetails(
149+
title1: data['orders'][index]['title'],
150+
title2:
151+
data['orders'][index]['total_price'].toString(),
152+
details1:
153+
data['orders'][index]['quantity'].toString(),
154+
details2: "Refundable",
155+
)).toList(),
156+
),
157+
],
158+
),
159+
),
160+
),
161+
);
162+
}
163+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import 'package:emart/consts/consts.dart';
2+
3+
Widget orderPlacedDetails({
4+
String? title1,
5+
String? details1,
6+
String? title2,
7+
String? details2,
8+
}) =>
9+
Padding(
10+
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8),
11+
child: Row(
12+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
13+
children: [
14+
Column(
15+
crossAxisAlignment: CrossAxisAlignment.start,
16+
children: [
17+
title1!.text.fontFamily(semibold).make(),
18+
details1!.text.fontFamily(semibold).color(redColor).make(),
19+
],
20+
),
21+
SizedBox(
22+
width: 130,
23+
child: Column(
24+
crossAxisAlignment: CrossAxisAlignment.start,
25+
children: [
26+
title2!.text.fontFamily(semibold).make(),
27+
details2!.text.color(fontGrey).make(),
28+
],
29+
),
30+
),
31+
],
32+
),
33+
);

lib/views/orders_screen_view/orders_screen.dart

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import 'package:cloud_firestore/cloud_firestore.dart';
33
import 'package:emart/common_widgets/loading_indicator.dart';
44
import 'package:emart/consts/consts.dart';
55
import 'package:emart/services/firestore_service.dart';
6+
import 'package:emart/views/orders_screen_view/order_details_screen.dart';
7+
import 'package:get/get.dart';
8+
import 'package:get/get_core/src/get_main.dart';
69

710
class OrdersScreen extends StatelessWidget {
811
const OrdersScreen({super.key});
@@ -24,9 +27,18 @@ class OrdersScreen extends StatelessWidget {
2427

2528
var data = snapshot.data!.docs;
2629

27-
return ListView.builder(
30+
return ListView.separated(
31+
separatorBuilder: (BuildContext context, int index) =>
32+
const Divider(color: Colors.black54),
2833
itemCount: data.length,
2934
itemBuilder: (BuildContext context, int index) => ListTile(
35+
leading: "${index + 1}"
36+
.text
37+
.color(darkFontGrey)
38+
.fontFamily(semibold)
39+
.xl3
40+
.make(),
41+
tileColor: lightGrey,
3042
title: data[index]['order_code']
3143
.toString()
3244
.text
@@ -39,6 +51,19 @@ class OrdersScreen extends StatelessWidget {
3951
.text
4052
.fontFamily(bold)
4153
.make(),
54+
trailing: IconButton(
55+
onPressed: () {
56+
Get.to(
57+
() => OrderDetailsScreen(
58+
data: data[index],
59+
),
60+
);
61+
},
62+
icon: const Icon(
63+
Icons.arrow_forward_ios,
64+
color: darkFontGrey,
65+
),
66+
),
4267
),
4368
);
4469
},

0 commit comments

Comments
 (0)