|
|
|
|
@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy-terms-conditions-page.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderItem.dart';
|
|
|
|
|
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/translations_delegate_base.dart';
|
|
|
|
|
@ -22,7 +23,6 @@ import 'package:provider/provider.dart';
|
|
|
|
|
import 'cart-order-preview.dart';
|
|
|
|
|
|
|
|
|
|
class CartOrderPage extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
final Function(int) changeTab;
|
|
|
|
|
|
|
|
|
|
const CartOrderPage({Key key, this.changeTab}) : super(key: key);
|
|
|
|
|
@ -38,7 +38,6 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
getData();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -105,8 +104,8 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
|
.shoppingCarts[index])
|
|
|
|
|
.then((value) {
|
|
|
|
|
if (model.state != ViewState.Error) {
|
|
|
|
|
// appScaffold.appBar.badgeUpdater(
|
|
|
|
|
// '${value.quantityCount ?? 0}');
|
|
|
|
|
// appScaffold.appBar.badgeUpdater(
|
|
|
|
|
// '${value.quantityCount ?? 0}');
|
|
|
|
|
}
|
|
|
|
|
if (model.state ==
|
|
|
|
|
ViewState.ErrorLocal) {
|
|
|
|
|
@ -250,7 +249,7 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
|
? height * 0.15
|
|
|
|
|
: 0,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: OrderBottomWidget(model.addresses, height),
|
|
|
|
|
child: OrderBottomWidget(model.addresses, height, model),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
@ -268,8 +267,9 @@ class _CartOrderPageState extends State<CartOrderPage> {
|
|
|
|
|
class OrderBottomWidget extends StatefulWidget {
|
|
|
|
|
final List<Addresses> addresses;
|
|
|
|
|
final double height;
|
|
|
|
|
final OrderPreviewViewModel model;
|
|
|
|
|
|
|
|
|
|
OrderBottomWidget(this.addresses, this.height);
|
|
|
|
|
OrderBottomWidget(this.addresses, this.height, this.model);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_OrderBottomWidgetState createState() => _OrderBottomWidgetState();
|
|
|
|
|
@ -281,9 +281,10 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
ProjectViewModel projectProvider = Provider.of(context);
|
|
|
|
|
OrderPreviewViewModel cart = Provider.of(context);
|
|
|
|
|
return !(cart.cartResponse.shoppingCarts == null ||
|
|
|
|
|
cart.cartResponse.shoppingCarts.length == 0)
|
|
|
|
|
OrderPreviewViewModel model = Provider.of(context);
|
|
|
|
|
|
|
|
|
|
return !(model.cartResponse.shoppingCarts == null ||
|
|
|
|
|
model.cartResponse.shoppingCarts.length == 0)
|
|
|
|
|
? Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
@ -373,7 +374,7 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Texts(
|
|
|
|
|
"${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotalWithVat).toStringAsFixed(2)}",
|
|
|
|
|
"${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}",
|
|
|
|
|
fontSize: projectProvider.isArabic ? 12 : 14,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
@ -391,7 +392,7 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Texts(
|
|
|
|
|
"${cart.cartResponse.quantityCount} ${TranslationBase.of(context).items}",
|
|
|
|
|
"${model.cartResponse.quantityCount} ${TranslationBase.of(context).items}",
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
@ -403,50 +404,36 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
|
onPressed: isAgree
|
|
|
|
|
// && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0
|
|
|
|
|
? () => {
|
|
|
|
|
if(cart.isCartItemsOutOfStock()){
|
|
|
|
|
// Toast msg
|
|
|
|
|
AppToast.showErrorToast(message: TranslationBase.of(context).outOfStockMsg)
|
|
|
|
|
}else {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
FadePage(
|
|
|
|
|
page:
|
|
|
|
|
OrderPreviewPage(widget.addresses)))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (model
|
|
|
|
|
.isCartItemsOutOfStock())
|
|
|
|
|
{
|
|
|
|
|
// Toast msg
|
|
|
|
|
AppToast.showErrorToast(
|
|
|
|
|
message: TranslationBase.of(context)
|
|
|
|
|
.outOfStockMsg)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_navigateToAddressPage(model
|
|
|
|
|
.user.patientIdentificationNo)
|
|
|
|
|
// Navigator.push(
|
|
|
|
|
// context,
|
|
|
|
|
// FadePage(
|
|
|
|
|
// page:
|
|
|
|
|
// OrderPreviewPage(widget.addresses)))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
child: new Text(
|
|
|
|
|
"${TranslationBase.of(context).checkOut}",
|
|
|
|
|
style: new TextStyle(
|
|
|
|
|
color:
|
|
|
|
|
isAgree ? Colors.white : Colors.grey.shade300,
|
|
|
|
|
isAgree ? Colors.white : Colors.grey.shade300,
|
|
|
|
|
fontSize: 14),
|
|
|
|
|
),
|
|
|
|
|
color: Color(0xFF4CAF50),
|
|
|
|
|
disabledColor:Color(0xFF848484),
|
|
|
|
|
// disabledColor: Color(0xff005aff),
|
|
|
|
|
disabledColor: Color(0xFF848484),
|
|
|
|
|
)
|
|
|
|
|
// RaisedButton(
|
|
|
|
|
// onPressed: isAgree
|
|
|
|
|
//// && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0
|
|
|
|
|
// ? () => {
|
|
|
|
|
// Navigator.push(
|
|
|
|
|
// context,
|
|
|
|
|
// FadePage(
|
|
|
|
|
// page:
|
|
|
|
|
// OrderPreviewPage(widget.addresses)))
|
|
|
|
|
// }
|
|
|
|
|
// : null,
|
|
|
|
|
// child: new Text(
|
|
|
|
|
// "${TranslationBase.of(context).checkOut}",
|
|
|
|
|
// style: new TextStyle(
|
|
|
|
|
// color:
|
|
|
|
|
// isAgree ? Colors.white : Colors.grey.shade300,
|
|
|
|
|
// fontSize: 14),
|
|
|
|
|
// ),
|
|
|
|
|
// color: Color(0xff005aff),
|
|
|
|
|
// disabledColor: Color(0xff005aff),
|
|
|
|
|
// )
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -454,4 +441,19 @@ class _OrderBottomWidgetState extends State<OrderBottomWidget> {
|
|
|
|
|
)
|
|
|
|
|
: Container();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_navigateToAddressPage(String identificationNo) {
|
|
|
|
|
Navigator.push(context, FadePage(page: PharmacyAddressesPage(orderPreviewViewModel: widget.model,)))
|
|
|
|
|
.then((result) async {
|
|
|
|
|
if (result != null) {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
var address = result;
|
|
|
|
|
widget.model.paymentCheckoutData.address = Addresses.fromJson(address.toJson());
|
|
|
|
|
await widget.model.getInformationsByAddress(identificationNo);
|
|
|
|
|
await widget.model.getShoppingCart();
|
|
|
|
|
// widget.changeMainState();
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|