|
|
|
@ -46,11 +46,7 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
OrderPreviewViewModel model = Provider.of(context);
|
|
|
|
OrderPreviewViewModel model = Provider.of(context);
|
|
|
|
|
|
|
|
|
|
|
|
final height = mediaQuery.size.height - 60 - mediaQuery.padding.top;
|
|
|
|
final height = mediaQuery.size.height - 60 - mediaQuery.padding.top;
|
|
|
|
AppScaffold appScaffold;
|
|
|
|
return AppScaffold(
|
|
|
|
return NetworkBaseView(
|
|
|
|
|
|
|
|
isLoading: isLoading,
|
|
|
|
|
|
|
|
isLocalLoader: true,
|
|
|
|
|
|
|
|
child: appScaffold = AppScaffold(
|
|
|
|
|
|
|
|
appBarTitle: TranslationBase.of(context).shoppingCart,
|
|
|
|
appBarTitle: TranslationBase.of(context).shoppingCart,
|
|
|
|
isShowAppBar: true,
|
|
|
|
isShowAppBar: true,
|
|
|
|
isPharmacy: true,
|
|
|
|
isPharmacy: true,
|
|
|
|
@ -60,7 +56,10 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
showPharmacyCart: false,
|
|
|
|
showPharmacyCart: false,
|
|
|
|
baseViewModel: model,
|
|
|
|
baseViewModel: model,
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
body: !(model.cartResponse.shoppingCarts == null ||
|
|
|
|
body: NetworkBaseView(
|
|
|
|
|
|
|
|
isLoading: isLoading,
|
|
|
|
|
|
|
|
isLocalLoader: true,
|
|
|
|
|
|
|
|
child: !(model.cartResponse.shoppingCarts == null ||
|
|
|
|
model.cartResponse.shoppingCarts.length == 0)
|
|
|
|
model.cartResponse.shoppingCarts.length == 0)
|
|
|
|
? Container(
|
|
|
|
? Container(
|
|
|
|
height: height * 0.85,
|
|
|
|
height: height * 0.85,
|
|
|
|
@ -91,7 +90,8 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
...List.generate(
|
|
|
|
...List.generate(
|
|
|
|
model.cartResponse.shoppingCarts != null
|
|
|
|
model.cartResponse.shoppingCarts != null
|
|
|
|
? model.cartResponse.shoppingCarts.length
|
|
|
|
? model
|
|
|
|
|
|
|
|
.cartResponse.shoppingCarts.length
|
|
|
|
: 0,
|
|
|
|
: 0,
|
|
|
|
(index) => ProductOrderItem(
|
|
|
|
(index) => ProductOrderItem(
|
|
|
|
model.cartResponse
|
|
|
|
model.cartResponse
|
|
|
|
@ -103,21 +103,25 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
.cartResponse
|
|
|
|
.cartResponse
|
|
|
|
.shoppingCarts[index])
|
|
|
|
.shoppingCarts[index])
|
|
|
|
.then((value) {
|
|
|
|
.then((value) {
|
|
|
|
if (model.state != ViewState.Error) {
|
|
|
|
if (model.state !=
|
|
|
|
|
|
|
|
ViewState.Error) {
|
|
|
|
// appScaffold.appBar.badgeUpdater(
|
|
|
|
// appScaffold.appBar.badgeUpdater(
|
|
|
|
// '${value.quantityCount ?? 0}');
|
|
|
|
// '${value.quantityCount ?? 0}');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (model.state ==
|
|
|
|
if (model.state ==
|
|
|
|
ViewState.ErrorLocal) {
|
|
|
|
ViewState.ErrorLocal) {
|
|
|
|
Utils.showErrorToast(model.error);
|
|
|
|
Utils.showErrorToast(
|
|
|
|
|
|
|
|
model.error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}, () {
|
|
|
|
}, () {
|
|
|
|
model
|
|
|
|
model
|
|
|
|
.deleteProduct(model.cartResponse
|
|
|
|
.deleteProduct(model
|
|
|
|
|
|
|
|
.cartResponse
|
|
|
|
.shoppingCarts[index])
|
|
|
|
.shoppingCarts[index])
|
|
|
|
.then((value) {
|
|
|
|
.then((value) {
|
|
|
|
if (model.state != ViewState.Error) {
|
|
|
|
if (model.state !=
|
|
|
|
|
|
|
|
ViewState.Error) {
|
|
|
|
// appScaffold.appBar.badgeUpdater(
|
|
|
|
// appScaffold.appBar.badgeUpdater(
|
|
|
|
// '${value.quantityCount ?? 0}');
|
|
|
|
// '${value.quantityCount ?? 0}');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -243,6 +247,7 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
bottomSheet: Container(
|
|
|
|
bottomSheet: Container(
|
|
|
|
height: !(model.cartResponse.shoppingCarts == null ||
|
|
|
|
height: !(model.cartResponse.shoppingCarts == null ||
|
|
|
|
model.cartResponse.shoppingCarts.length == 0)
|
|
|
|
model.cartResponse.shoppingCarts.length == 0)
|
|
|
|
@ -251,7 +256,6 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
color: Colors.white,
|
|
|
|
color: Colors.white,
|
|
|
|
child: OrderBottomWidget(model.addresses, height, model),
|
|
|
|
child: OrderBottomWidget(model.addresses, height, model),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -403,8 +407,7 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
onPressed: isAgree
|
|
|
|
onPressed: isAgree
|
|
|
|
// && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0
|
|
|
|
// && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0
|
|
|
|
? () => {
|
|
|
|
? () => {
|
|
|
|
if (widget.model
|
|
|
|
if (widget.model.isCartItemsOutOfStock())
|
|
|
|
.isCartItemsOutOfStock())
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Toast msg
|
|
|
|
// Toast msg
|
|
|
|
AppToast.showErrorToast(
|
|
|
|
AppToast.showErrorToast(
|
|
|
|
@ -413,8 +416,8 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_navigateToAddressPage(widget.model
|
|
|
|
_navigateToAddressPage(widget
|
|
|
|
.user.patientIdentificationNo)
|
|
|
|
.model.user.patientIdentificationNo)
|
|
|
|
// Navigator.push(
|
|
|
|
// Navigator.push(
|
|
|
|
// context,
|
|
|
|
// context,
|
|
|
|
// FadePage(
|
|
|
|
// FadePage(
|
|
|
|
@ -442,12 +445,17 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_navigateToAddressPage(String identificationNo) {
|
|
|
|
_navigateToAddressPage(String identificationNo) {
|
|
|
|
Navigator.push(context, FadePage(page: PharmacyAddressesPage(orderPreviewViewModel: widget.model,)))
|
|
|
|
Navigator.push(
|
|
|
|
.then((result) async {
|
|
|
|
context,
|
|
|
|
|
|
|
|
FadePage(
|
|
|
|
|
|
|
|
page: PharmacyAddressesPage(
|
|
|
|
|
|
|
|
orderPreviewViewModel: widget.model,
|
|
|
|
|
|
|
|
))).then((result) async {
|
|
|
|
if (result != null) {
|
|
|
|
if (result != null) {
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
var address = result;
|
|
|
|
var address = result;
|
|
|
|
widget.model.paymentCheckoutData.address = Addresses.fromJson(address.toJson());
|
|
|
|
widget.model.paymentCheckoutData.address =
|
|
|
|
|
|
|
|
Addresses.fromJson(address.toJson());
|
|
|
|
await widget.model.getInformationsByAddress(identificationNo);
|
|
|
|
await widget.model.getInformationsByAddress(identificationNo);
|
|
|
|
await widget.model.getShoppingCart();
|
|
|
|
await widget.model.getShoppingCart();
|
|
|
|
// widget.changeMainState();
|
|
|
|
// widget.changeMainState();
|
|
|
|
|