-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
525 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
enum ViewState { Idle, Busy } | ||
enum ViewState { Idle, Busy, Intermediate } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class Address { | ||
String recipent; | ||
String address_id; | ||
String city; | ||
String contact; | ||
String country; | ||
String is_primary; | ||
String locality; | ||
String state; | ||
String user_id; | ||
String zip; | ||
|
||
Address({this.recipent, this.address_id, this.city, this.contact, this.country, this.is_primary, this.locality, this.state, this.user_id, this.zip}); | ||
|
||
factory Address.fromJson(Map<String, dynamic> json) { | ||
return Address( | ||
recipent: json['recipent'], | ||
address_id: json['address_id'], | ||
city: json['city'], | ||
contact: json['contact'], | ||
country: json['country'], | ||
is_primary: json['is_primary'], | ||
locality: json['locality'], | ||
state: json['state'], | ||
user_id: json['user_id'], | ||
zip: json['zip'], | ||
); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
final Map<String, dynamic> data = new Map<String, dynamic>(); | ||
data['recipent'] = this.recipent; | ||
data['address_id'] = this.address_id; | ||
data['city'] = this.city; | ||
data['contact'] = this.contact; | ||
data['country'] = this.country; | ||
data['is_primary'] = this.is_primary; | ||
data['locality'] = this.locality; | ||
data['state'] = this.state; | ||
data['user_id'] = this.user_id; | ||
data['zip'] = this.zip; | ||
return data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class CartEdit { | ||
String message; | ||
bool success; | ||
|
||
CartEdit({this.message, this.success}); | ||
|
||
factory CartEdit.fromJson(Map<String, dynamic> json) { | ||
return CartEdit( | ||
message: json['message'], | ||
success: json['success'], | ||
); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
final Map<String, dynamic> data = new Map<String, dynamic>(); | ||
data['message'] = this.message; | ||
data['success'] = this.success; | ||
return data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
typedef void CheckoutButtonPressed(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,137 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:gogrocy/ui/views/cart/cart_header.dart'; | ||
import 'package:gogrocy/core/enums/viewstate.dart'; | ||
import 'package:gogrocy/core/viewModels/cart_view_model.dart'; | ||
import 'package:gogrocy/ui/views/base_view.dart'; | ||
import 'package:gogrocy/ui/views/cart/cart_bill.dart'; | ||
import 'package:gogrocy/ui/views/cart/cart_list.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:gogrocy/core/enums/viewstate.dart'; | ||
import 'package:gogrocy/core/models/cart_list.dart'; | ||
import 'package:gogrocy/core/services/checkout_button_callback.dart'; | ||
import 'package:gogrocy/core/viewModels/cart_view_model.dart'; | ||
import 'package:gogrocy/ui/shared/colors.dart' as colors; | ||
import 'package:gogrocy/ui/shared/constants.dart' as constants; | ||
|
||
typedef void CheckoutButtonPressed(); | ||
|
||
class Cart extends StatelessWidget { | ||
ScrollController scrollController=new ScrollController(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: ListView( | ||
children: <Widget>[ | ||
CartHeader(), | ||
CartList() | ||
], | ||
body: BaseView<CartViewModel>( | ||
onModelReady: (model) { | ||
model.getCartList(product_id: null, quantity: null); | ||
}, | ||
builder: (context, model, child) { | ||
if (model.state == ViewState.Busy) | ||
return Center(child: CircularProgressIndicator()); | ||
else if (model.state == ViewState.Intermediate) { | ||
return ListView( | ||
shrinkWrap: true, | ||
controller: scrollController, | ||
children: <Widget>[ | ||
CartHeader(model: model.cartList,checkoutButtonPressed: (){scrollController.animateTo(scrollController.position.maxScrollExtent, duration: Duration(milliseconds: 500), curve: Curves.easeIn);print("Callback succeeds");},), | ||
CartList(model, model.intermediateCartList), | ||
CartBill(model.cartList,), | ||
SizedBox(height: 50,), | ||
|
||
], | ||
); | ||
} else | ||
return ListView( | ||
shrinkWrap: true, | ||
controller: scrollController, | ||
children: <Widget>[ | ||
CartHeader(model:model.cartList,checkoutButtonPressed:(){scrollController.animateTo(scrollController.position.maxScrollExtent, duration: Duration(milliseconds: 500), curve: Curves.easeIn);print("Callback succeeds");}), | ||
CartList(model, model.cartList), | ||
CartBill(model.cartList), | ||
SizedBox(height: 50,), | ||
|
||
], | ||
); | ||
}, | ||
), | ||
); | ||
} | ||
} | ||
|
||
class CartHeader extends StatelessWidget { | ||
|
||
cart_list model; | ||
CheckoutButtonPressed checkoutButtonPressed; | ||
|
||
CartHeader({this.model,this.checkoutButtonPressed}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Stack( | ||
children: <Widget>[ | ||
Image(image: AssetImage('assets/images/cart_background.png')), | ||
Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: <Widget>[ | ||
IntrinsicHeight( | ||
child: Padding( | ||
padding: const EdgeInsets.only(top: 8.0), | ||
child: Row( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: <Widget>[ | ||
Container( | ||
width: 20.0, | ||
color: colors.CART_HEADER_COLOR, | ||
), | ||
Padding( | ||
padding: const EdgeInsets.only(left: 8.0), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
mainAxisSize: MainAxisSize.min, | ||
children: <Widget>[ | ||
Text("Your Cart", | ||
style: TextStyle(fontFamily: 'Gilroy',fontSize: 32.0,fontWeight: FontWeight.bold, color: colors.CART_HEADER_COLOR),), | ||
Text("Grand Total Rs"+model.sum.toString(), | ||
style: TextStyle(fontFamily: 'Gilroy',fontSize: 14.0,fontWeight: FontWeight.w600, color: colors.CART_HEADER_COLOR),), | ||
|
||
], | ||
), | ||
) | ||
], | ||
), | ||
), | ||
), | ||
Padding( | ||
padding: const EdgeInsets.only(left: 28.0,top: 12), | ||
child: RawMaterialButton( | ||
elevation: 0.0, | ||
focusElevation: 1, | ||
focusColor: colors.CART_BUTTON_BACKGROUND, | ||
onPressed: () { | ||
checkoutButtonPressed(); | ||
}, | ||
fillColor: colors.CART_BUTTON_BACKGROUND, | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(3), | ||
), | ||
child: SizedBox( | ||
width: constants.CartConfig.checkoutButtonWidth, | ||
height: constants.CartConfig.checkoutButtonHeight, | ||
child: Center( | ||
child: Text( | ||
'Checkout Now', | ||
style: TextStyle( | ||
color: colors.CART_BUTTON_TEXT, | ||
fontSize: 13.0, | ||
fontWeight: FontWeight.bold), | ||
), | ||
), | ||
), | ||
), | ||
) | ||
], | ||
) | ||
], | ||
); | ||
} | ||
} | ||
|
Oops, something went wrong.