|
|
|
|
@ -9,6 +9,7 @@ import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderItem.d
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/navigation_service.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/buttons/GestureIconButton.dart';
|
|
|
|
|
@ -20,6 +21,7 @@ import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:http/http.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../../locator.dart';
|
|
|
|
|
import 'cart-order-preview.dart';
|
|
|
|
|
|
|
|
|
|
class CartOrderPage extends StatefulWidget {
|
|
|
|
|
@ -55,6 +57,9 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
|
isMainPharmacyPages: true,
|
|
|
|
|
showPharmacyCart: false,
|
|
|
|
|
baseViewModel: model,
|
|
|
|
|
backButtonTab: () {
|
|
|
|
|
widget.changeTab(0);
|
|
|
|
|
},
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
body: NetworkBaseView(
|
|
|
|
|
isLoading: isLoading,
|
|
|
|
|
@ -94,32 +99,34 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
|
: 0,
|
|
|
|
|
(index) => ProductOrderItem(
|
|
|
|
|
model.cartResponse
|
|
|
|
|
.shoppingCarts[index], () {
|
|
|
|
|
print(model.cartResponse
|
|
|
|
|
.shoppingCarts[index].quantity);
|
|
|
|
|
model
|
|
|
|
|
.changeProductQuantity(model
|
|
|
|
|
.cartResponse
|
|
|
|
|
.shoppingCarts[index], () async {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(
|
|
|
|
|
context);
|
|
|
|
|
await model.changeProductQuantity(model
|
|
|
|
|
.cartResponse.shoppingCarts[index]);
|
|
|
|
|
if (model.state != ViewState.Error) {
|
|
|
|
|
// appScaffold.appBar.badgeUpdater(
|
|
|
|
|
// '${value.quantityCount ?? 0}');
|
|
|
|
|
}
|
|
|
|
|
if (model.state ==
|
|
|
|
|
ViewState.ErrorLocal) {
|
|
|
|
|
Utils.showErrorToast(model.error);
|
|
|
|
|
}
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(
|
|
|
|
|
context);
|
|
|
|
|
}, () async {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(
|
|
|
|
|
context);
|
|
|
|
|
await model
|
|
|
|
|
.deleteProduct(model.cartResponse
|
|
|
|
|
.shoppingCarts[index])
|
|
|
|
|
.then((value) {
|
|
|
|
|
if (model.state != ViewState.Error) {
|
|
|
|
|
// appScaffold.appBar.badgeUpdater(
|
|
|
|
|
// '${value.quantityCount ?? 0}');
|
|
|
|
|
}
|
|
|
|
|
if (model.state ==
|
|
|
|
|
ViewState.ErrorLocal) {
|
|
|
|
|
Utils.showErrorToast(model.error);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, () {
|
|
|
|
|
model
|
|
|
|
|
.deleteProduct(model.cartResponse
|
|
|
|
|
.shoppingCarts[index])
|
|
|
|
|
.then((value) {
|
|
|
|
|
if (model.state != ViewState.Error) {
|
|
|
|
|
// appScaffold.appBar.badgeUpdater(
|
|
|
|
|
// '${value.quantityCount ?? 0}');
|
|
|
|
|
}
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(
|
|
|
|
|
context);
|
|
|
|
|
});
|
|
|
|
|
}))
|
|
|
|
|
],
|
|
|
|
|
@ -249,7 +256,7 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
|
? height * 0.15
|
|
|
|
|
: 0,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: OrderBottomWidget(model.addresses, height, model),
|
|
|
|
|
child: OrderBottomWidget(model.addresses, height, model, isLoading),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
@ -267,8 +274,9 @@ class OrderBottomWidget extends StatefulWidget {
|
|
|
|
|
final List<Addresses> addresses;
|
|
|
|
|
final double height;
|
|
|
|
|
final OrderPreviewViewModel model;
|
|
|
|
|
final bool isLoading;
|
|
|
|
|
|
|
|
|
|
OrderBottomWidget(this.addresses, this.height, this.model);
|
|
|
|
|
OrderBottomWidget(this.addresses, this.height, this.model, this.isLoading);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_OrderBottomWidgetState createState() => _OrderBottomWidgetState();
|
|
|
|
|
@ -281,7 +289,7 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
ProjectViewModel projectProvider = Provider.of(context);
|
|
|
|
|
|
|
|
|
|
return !(widget.model.cartResponse.shoppingCarts == null ||
|
|
|
|
|
return ! widget.isLoading && !(widget.model.cartResponse.shoppingCarts == null ||
|
|
|
|
|
widget.model.cartResponse.shoppingCarts.length == 0)
|
|
|
|
|
? Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|