Skip to content

Commit

Permalink
Order is broken
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinmay-KB committed Apr 28, 2020
1 parent 53583d9 commit 002f2d0
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 25 deletions.
186 changes: 178 additions & 8 deletions gogrocy/lib/core/models/Orders.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import 'package:gogrocy/core/models/Result.dart';

class Orders {
bool empty;
Result result;

Orders({this.empty, this.result});

factory Orders.fromJson(Map<String, dynamic> json) {
return Orders(
empty: json['empty'],
result: json['result'] != null ? Result.fromJson(json['result']) : null,
);
Orders.fromJson(Map<String, dynamic> json) {
empty = json['empty'];
result =
json['result'] != null ? new Result.fromJson(json['result']) : null;
}

Map<String, dynamic> toJson() {
Expand All @@ -21,4 +18,177 @@ class Orders {
}
return data;
}
}
}

class Result {
List<Bills> bills;
List<Address> address;

Result({this.bills, this.address});

Result.fromJson(Map<String, dynamic> json) {
if (json['bills'] != null) {
bills = new List<Bills>();
json['bills'].forEach((v) {
bills.add(new Bills.fromJson(v));
});
}
if (json['address'] != null) {
address = new List<Address>();
json['address'].forEach((v) {
address.add(new Address.fromJson(v));
});
}
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.bills != null) {
data['bills'] = this.bills.map((v) => v.toJson()).toList();
}
if (this.address != null) {
data['address'] = this.address.map((v) => v.toJson()).toList();
}
return data;
}
}

class Bills {
String billId;
List<Details> details;

Bills({this.billId, this.details});

Bills.fromJson(Map<String, dynamic> json) {
billId = json['bill_id'];
if (json['details'] != null) {
details = new List<Details>();
json['details'].forEach((v) {
details.add(new Details.fromJson(v));
});
}
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['bill_id'] = this.billId;
if (this.details != null) {
data['details'] = this.details.map((v) => v.toJson()).toList();
}
return data;
}
}

class Details {
String productId;
String orderId;
String billId;
String image;
String name;
String price;
String orderQty;
String paymentStat;
String status;
String sellerNumber;
String sellerName;
String orderDate;

Details(
{this.productId,
this.orderId,
this.billId,
this.image,
this.name,
this.price,
this.orderQty,
this.paymentStat,
this.status,
this.sellerNumber,
this.sellerName,
this.orderDate});

Details.fromJson(Map<String, dynamic> json) {
productId = json['product_id'];
orderId = json['order_id'];
billId = json['bill_id'];
image = json['image'];
name = json['name'];
price = json['price'];
orderQty = json['order_qty'];
paymentStat = json['payment_stat'];
status = json['status'];
sellerNumber = json['seller_number'];
sellerName = json['seller_name'];
orderDate = json['order_date'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['product_id'] = this.productId;
data['order_id'] = this.orderId;
data['bill_id'] = this.billId;
data['image'] = this.image;
data['name'] = this.name;
data['price'] = this.price;
data['order_qty'] = this.orderQty;
data['payment_stat'] = this.paymentStat;
data['status'] = this.status;
data['seller_number'] = this.sellerNumber;
data['seller_name'] = this.sellerName;
data['order_date'] = this.orderDate;
return data;
}
}

class Address {
String addressId;
String receiver;
String userId;
String contact;
String locality;
String city;
String state;
String zip;
String country;
String isPrimary;

Address(
{this.addressId,
this.receiver,
this.userId,
this.contact,
this.locality,
this.city,
this.state,
this.zip,
this.country,
this.isPrimary});

Address.fromJson(Map<String, dynamic> json) {
addressId = json['address_id'];
receiver = json['receiver'];
userId = json['user_id'];
contact = json['contact'];
locality = json['locality'];
city = json['city'];
state = json['state'];
zip = json['zip'];
country = json['country'];
isPrimary = json['is_primary'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['address_id'] = this.addressId;
data['receiver'] = this.receiver;
data['user_id'] = this.userId;
data['contact'] = this.contact;
data['locality'] = this.locality;
data['city'] = this.city;
data['state'] = this.state;
data['zip'] = this.zip;
data['country'] = this.country;
data['is_primary'] = this.isPrimary;
return data;
}
}
5 changes: 3 additions & 2 deletions gogrocy/lib/ui/views/orders/orders.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:gogrocy/core/enums/viewstate.dart';
import 'package:gogrocy/core/models/Address.dart';
import 'package:gogrocy/core/models/Detail.dart';
import 'package:gogrocy/core/models/Orders.dart';
import 'package:gogrocy/core/viewModels/orderLis_model.dart';
import 'package:gogrocy/ui/views/base_view.dart';
import 'package:gogrocy/ui/widgets/appbar.dart';
Expand Down Expand Up @@ -29,10 +30,10 @@ class OrderView extends StatelessWidget {
ListView.separated(

itemBuilder: (context,index){
Detail details=model.orders.result.bills[0].details[index];
Orders details=model.orders;
return Column(
children: <Widget>[
Text(details.bill_id)
Text(details.result.bills[index].billId)
],
);
}, separatorBuilder: (context, index){
Expand Down
48 changes: 33 additions & 15 deletions gogrocy/lib/ui/views/product_detail_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class ProductDetailView extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
GestureDetector(
onTap: (){Navigator.pop(context);},
onTap: () {
Navigator.pop(context);
},
child: Padding(
padding: const EdgeInsets.only(right: 8, top: 4),
child: Icon(
Expand All @@ -50,7 +52,8 @@ class ProductDetailView extends StatelessWidget {
fontWeight: FontWeight.w500, fontSize: 24),
),
Text(
((product.quantity != "2")||(product.quantity!=null)
((product.quantity != "2") ||
(product.quantity != null)
? "In Stock"
: "Not in stock"),
style: TextStyle(
Expand All @@ -76,28 +79,41 @@ class ProductDetailView extends StatelessWidget {
borderRadius: BorderRadius.all(Radius.circular(8)),
child: SizedBox(
width: constants.screenWidth,
height: constants.screenHeight*0.4,
height: constants.screenHeight * 0.4,
child: Image(
image: NetworkImage(
'https://res.cloudinary.com/gogrocy/image/upload/v1/' +
product.image,),fit: BoxFit.fitWidth,
'https://res.cloudinary.com/gogrocy/image/upload/v1/' +
product.image,
),
fit: BoxFit.fitWidth,
),
),
),
SizedBox(
height: 20,
),
Text(product.name,style: TextStyle(fontSize: 20,fontWeight: FontWeight.w500),),
Text(product.description,style: TextStyle(),),
SizedBox(height: 20.0,),
Text(
product.name,
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500),
),
Text(
product.description,
style: TextStyle(),
),
SizedBox(
height: 20.0,
),
Center(
child: FlatButton.icon(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)),
color:colors.VIEW_ALL_BUTTON_BACKGROUND,
color: colors.VIEW_ALL_BUTTON_BACKGROUND,
icon: Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(Icons.shopping_cart,color: colors.PRIMARY_COLOR,),
child: Icon(
Icons.shopping_cart,
color: colors.PRIMARY_COLOR,
),
),
label: Padding(
padding: const EdgeInsets.all(8.0),
Expand All @@ -106,7 +122,7 @@ class ProductDetailView extends StatelessWidget {
style: TextStyle(
color: colors.PRIMARY_COLOR,
fontWeight: FontWeight.bold,
fontSize: 16),
fontSize: 16),
),
),
onPressed: () async {
Expand All @@ -115,8 +131,9 @@ class ProductDetailView extends StatelessWidget {
Flushbar(
messageText: Text(
"Added to cart",
style:
TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w500),
),
duration: Duration(seconds: 2),
flushbarStyle: FlushbarStyle.FLOATING,
Expand All @@ -140,8 +157,9 @@ class ProductDetailView extends StatelessWidget {
Flushbar(
messageText: Text(
"Unable to add to cart",
style:
TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w500),
),
duration: Duration(seconds: 2),
flushbarStyle: FlushbarStyle.FLOATING,
Expand Down

0 comments on commit 002f2d0

Please sign in to comment.