Skip to content

Commit 53583d9

Browse files
committed
Empty cart handled, snackbars in order placing and add to cart. Product page ui improved
1 parent 1c802b1 commit 53583d9

File tree

6 files changed

+386
-147
lines changed

6 files changed

+386
-147
lines changed

gogrocy/assets/images/empty-cart.png

7.2 KB
Loading

gogrocy/lib/ui/views/cart/cart.dart

Lines changed: 95 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import 'package:gogrocy/ui/shared/constants.dart' as constants;
1616
typedef void CheckoutButtonPressed();
1717

1818
class Cart extends StatelessWidget {
19-
ScrollController scrollController=new ScrollController();
19+
ScrollController scrollController = new ScrollController();
2020

2121
@override
2222
Widget build(BuildContext context) {
@@ -29,44 +29,94 @@ class Cart extends StatelessWidget {
2929
if (model.state == ViewState.Busy)
3030
return Center(child: CircularProgressIndicator());
3131
else if (model.state == ViewState.Intermediate) {
32-
return ListView(
33-
shrinkWrap: true,
34-
controller: scrollController,
35-
children: <Widget>[
36-
CartHeader(model: model.cartList,checkoutButtonPressed: (){scrollController.animateTo(scrollController.position.maxScrollExtent, duration: Duration(milliseconds: 500), curve: Curves.easeIn);print("Callback succeeds");},),
37-
CartList(model, model.intermediateCartList),
38-
CartBill(model.cartList,),
39-
CartFooter(model),
40-
SizedBox(height: 50,),
41-
42-
43-
],
44-
);
45-
} else
46-
return ListView(
47-
shrinkWrap: true,
48-
controller: scrollController,
49-
children: <Widget>[
50-
CartHeader(model:model.cartList,checkoutButtonPressed:(){scrollController.animateTo(scrollController.position.maxScrollExtent, duration: Duration(milliseconds: 500), curve: Curves.easeIn);print("Callback succeeds");}),
51-
CartList(model, model.cartList),
52-
CartBill(model.cartList),
53-
CartFooter(model),
54-
SizedBox(height: 50,),
32+
if (model.cartList.sum == 0) {
33+
return ListView(
34+
shrinkWrap: true,
35+
controller: scrollController,
36+
children: <Widget>[
37+
CartHeader(
38+
model: model.cartList,
39+
checkoutButtonPressed: () {
40+
scrollController.animateTo(
41+
scrollController.position.maxScrollExtent,
42+
duration: Duration(milliseconds: 500),
43+
curve: Curves.easeIn);
44+
print("Callback succeeds");
45+
},
46+
),
47+
CartList(model, model.intermediateCartList),
48+
CartBill(
49+
model.cartList,
50+
),
51+
CartFooter(model),
52+
SizedBox(
53+
height: 50,
54+
),
55+
],
56+
);
57+
} else return emptyCart();
5558

56-
],
57-
);
59+
} else {
60+
if (model.cartList.sum == 0) {
61+
return emptyCart();
62+
} else
63+
return ListView(
64+
shrinkWrap: true,
65+
controller: scrollController,
66+
children: <Widget>[
67+
CartHeader(
68+
model: model.cartList,
69+
checkoutButtonPressed: () {
70+
scrollController.animateTo(
71+
scrollController.position.maxScrollExtent,
72+
duration: Duration(milliseconds: 500),
73+
curve: Curves.easeIn);
74+
print("Callback succeeds");
75+
}),
76+
CartList(model, model.cartList),
77+
CartBill(model.cartList),
78+
CartFooter(model),
79+
SizedBox(
80+
height: 50,
81+
),
82+
],
83+
);
84+
}
5885
},
5986
),
6087
);
6188
}
89+
90+
Widget emptyCart() {
91+
return Center(
92+
child: Column(
93+
mainAxisSize: MainAxisSize.max,
94+
mainAxisAlignment: MainAxisAlignment.center,
95+
children: <Widget>[
96+
SizedBox(
97+
width: 60.0,
98+
height: 60.0,
99+
child: Image(
100+
image: AssetImage("assets/images/empty-cart.png"),
101+
)),
102+
Text(
103+
"Your cart is Empty!",
104+
style: TextStyle(
105+
fontSize: 24.0,
106+
fontFamily: 'Gilroy',
107+
fontWeight: FontWeight.w500),
108+
)
109+
],
110+
),
111+
);
112+
}
62113
}
63114

64115
class CartHeader extends StatelessWidget {
65-
66116
cart_list model;
67117
CheckoutButtonPressed checkoutButtonPressed;
68118

69-
CartHeader({this.model,this.checkoutButtonPressed});
119+
CartHeader({this.model, this.checkoutButtonPressed});
70120

71121
@override
72122
Widget build(BuildContext context) {
@@ -92,11 +142,22 @@ class CartHeader extends StatelessWidget {
92142
crossAxisAlignment: CrossAxisAlignment.start,
93143
mainAxisSize: MainAxisSize.min,
94144
children: <Widget>[
95-
Text("Your Cart",
96-
style: TextStyle(fontFamily: 'Gilroy',fontSize: 32.0,fontWeight: FontWeight.bold, color: colors.CART_HEADER_COLOR),),
97-
Text("Grand Total Rs"+model.sum.toString(),
98-
style: TextStyle(fontFamily: 'Gilroy',fontSize: 14.0,fontWeight: FontWeight.w600, color: colors.CART_HEADER_COLOR),),
99-
145+
Text(
146+
"Your Cart",
147+
style: TextStyle(
148+
fontFamily: 'Gilroy',
149+
fontSize: 32.0,
150+
fontWeight: FontWeight.bold,
151+
color: colors.CART_HEADER_COLOR),
152+
),
153+
Text(
154+
"Grand Total Rs" + model.sum.toString(),
155+
style: TextStyle(
156+
fontFamily: 'Gilroy',
157+
fontSize: 14.0,
158+
fontWeight: FontWeight.w600,
159+
color: colors.CART_HEADER_COLOR),
160+
),
100161
],
101162
),
102163
)
@@ -105,7 +166,7 @@ class CartHeader extends StatelessWidget {
105166
),
106167
),
107168
Padding(
108-
padding: const EdgeInsets.only(left: 28.0,top: 12),
169+
padding: const EdgeInsets.only(left: 28.0, top: 12),
109170
child: RawMaterialButton(
110171
elevation: 0.0,
111172
focusElevation: 1,
@@ -138,4 +199,3 @@ class CartHeader extends StatelessWidget {
138199
);
139200
}
140201
}
141-

0 commit comments

Comments
 (0)