|
|
|
|
@ -20,21 +20,23 @@ import 'package:http/http.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
class CartOrderPage extends StatefulWidget {
|
|
|
|
|
const CartOrderPage({Key key}) : super(key: key);
|
|
|
|
|
final Function(int) changeTab;
|
|
|
|
|
|
|
|
|
|
const CartOrderPage({Key key, this.changeTab}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_CartOrderPageState createState() => _CartOrderPageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
|
|
|
|
|
|
bool isLoading = true;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
getData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final mediaQuery = MediaQuery.of(context);
|
|
|
|
|
@ -53,6 +55,7 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
|
showHomeAppBarIcon: false,
|
|
|
|
|
isShowDecPage: true,
|
|
|
|
|
baseViewModel: model,
|
|
|
|
|
backButtonTab: widget.changeTab != null ? () => widget.changeTab(0) : null,
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
body: !(model.cartResponse.shoppingCarts == null ||
|
|
|
|
|
model.cartResponse.shoppingCarts.length == 0)
|
|
|
|
|
@ -88,31 +91,30 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
|
? model.cartResponse.shoppingCarts.length
|
|
|
|
|
: 0,
|
|
|
|
|
(index) => ProductOrderItem(
|
|
|
|
|
model.cartResponse.shoppingCarts[index], () {
|
|
|
|
|
print(model.cartResponse.shoppingCarts[index]
|
|
|
|
|
.quantity);
|
|
|
|
|
model.cartResponse
|
|
|
|
|
.shoppingCarts[index], () {
|
|
|
|
|
print(model.cartResponse
|
|
|
|
|
.shoppingCarts[index].quantity);
|
|
|
|
|
model
|
|
|
|
|
.changeProductQuantity(
|
|
|
|
|
model.cartResponse.shoppingCarts[index])
|
|
|
|
|
.changeProductQuantity(model
|
|
|
|
|
.cartResponse
|
|
|
|
|
.shoppingCarts[index])
|
|
|
|
|
.then((value) {
|
|
|
|
|
if (model.state !=
|
|
|
|
|
ViewState.Error) {
|
|
|
|
|
if (model.state != ViewState.Error) {
|
|
|
|
|
appScaffold.appBar.badgeUpdater(
|
|
|
|
|
'${value.quantityCount ?? 0}');
|
|
|
|
|
}
|
|
|
|
|
if (model.state ==
|
|
|
|
|
ViewState.ErrorLocal) {
|
|
|
|
|
Utils.showErrorToast(
|
|
|
|
|
model.error);
|
|
|
|
|
Utils.showErrorToast(model.error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, () {
|
|
|
|
|
model
|
|
|
|
|
.deleteProduct(
|
|
|
|
|
model.cartResponse.shoppingCarts[index])
|
|
|
|
|
.deleteProduct(model.cartResponse
|
|
|
|
|
.shoppingCarts[index])
|
|
|
|
|
.then((value) {
|
|
|
|
|
if (model.state !=
|
|
|
|
|
ViewState.Error) {
|
|
|
|
|
if (model.state != ViewState.Error) {
|
|
|
|
|
appScaffold.appBar.badgeUpdater(
|
|
|
|
|
'${value.quantityCount ?? 0}');
|
|
|
|
|
}
|
|
|
|
|
@ -129,8 +131,7 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
|
endIndent: 0,
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment:
|
|
|
|
|
MainAxisAlignment.spaceBetween,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Texts(
|
|
|
|
|
TranslationBase.of(context).subtotal,
|
|
|
|
|
@ -154,8 +155,7 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
|
endIndent: 0,
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment:
|
|
|
|
|
MainAxisAlignment.spaceBetween,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Texts(
|
|
|
|
|
"${TranslationBase.of(context).vat}",
|
|
|
|
|
@ -179,8 +179,7 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
|
endIndent: 0,
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment:
|
|
|
|
|
MainAxisAlignment.spaceBetween,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Texts(
|
|
|
|
|
TranslationBase.of(context).total,
|
|
|
|
|
@ -209,7 +208,9 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
|
height: 30.0,
|
|
|
|
|
fit: BoxFit.scaleDown,
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 120,)
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 120,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -252,12 +253,11 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getData() async {
|
|
|
|
|
|
|
|
|
|
await Provider.of<OrderPreviewViewModel>(context, listen: false).getShoppingCart();
|
|
|
|
|
await Provider.of<OrderPreviewViewModel>(context, listen: false)
|
|
|
|
|
.getShoppingCart();
|
|
|
|
|
setState(() {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -306,8 +306,7 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
|
width: 25.0,
|
|
|
|
|
height: widget.height * 0.070,
|
|
|
|
|
decoration: new BoxDecoration(
|
|
|
|
|
color:
|
|
|
|
|
!isAgree ? Color(0xffeeeeee) : Colors.green,
|
|
|
|
|
color: !isAgree ? Color(0xffeeeeee) : Colors.green,
|
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
|
),
|
|
|
|
|
child: !isAgree
|
|
|
|
|
@ -337,8 +336,8 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
|
),
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () => {
|
|
|
|
|
Navigator.push(context,
|
|
|
|
|
FadePage(page: PharmacyTermsConditions()))
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context, FadePage(page: PharmacyTermsConditions()))
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
child: Icon(
|
|
|
|
|
@ -369,13 +368,12 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
|
children: [
|
|
|
|
|
Texts(
|
|
|
|
|
"${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotal).toStringAsFixed(2)}",
|
|
|
|
|
fontSize:
|
|
|
|
|
projectProvider.isArabic ? 12 : 14,
|
|
|
|
|
fontSize: projectProvider.isArabic ? 12 : 14,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: 4),
|
|
|
|
|
padding:
|
|
|
|
|
const EdgeInsets.symmetric(horizontal: 4),
|
|
|
|
|
child: Texts(
|
|
|
|
|
"${TranslationBase.of(context).inclusiveVat}",
|
|
|
|
|
fontSize: 8,
|
|
|
|
|
@ -401,16 +399,15 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
FadePage(
|
|
|
|
|
page: OrderPreviewPage(
|
|
|
|
|
widget.addresses)))
|
|
|
|
|
page:
|
|
|
|
|
OrderPreviewPage(widget.addresses)))
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
child: new Text(
|
|
|
|
|
"${TranslationBase.of(context).checkOut}",
|
|
|
|
|
style: new TextStyle(
|
|
|
|
|
color: isAgree
|
|
|
|
|
? Colors.white
|
|
|
|
|
: Colors.grey.shade300,
|
|
|
|
|
color:
|
|
|
|
|
isAgree ? Colors.white : Colors.grey.shade300,
|
|
|
|
|
fontSize: 14),
|
|
|
|
|
),
|
|
|
|
|
color: Color(0xff005aff),
|
|
|
|
|
|