import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/select_address_widget.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'lakum_widget.dart'; class OrderPreviewPage extends StatefulWidget { final List addresses; OrderPreviewPage(this.addresses); @override _OrderPreviewPageState createState() => _OrderPreviewPageState(); } class _OrderPreviewPageState extends State { MyInAppBrowser browser; bool isLoading = true; @override void initState() { super.initState(); getData(); } void getData() async { if (isLoading) await Provider.of(context, listen: false) .getShoppingCart(); setState(() { isLoading = false; }); } @override Widget build(BuildContext context) { final mediaQuery = MediaQuery.of(context); final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; OrderPreviewViewModel model = Provider.of(context); return AppScaffold( appBarTitle: "${TranslationBase.of(context).checkOut}", isShowAppBar: true, isPharmacy: true, isShowDecPage: false, isLoading: isLoading, isLocalLoader: true, backgroundColor: Colors.white, // baseViewModel: model, body: Container( color: Color(0xFFF1F1F1), height: height * 0.90, child: SingleChildScrollView( child: Container( color: Color(0xFFF1F1F1), child: Column( children: [ SelectAddressWidget(model, widget.addresses), SizedBox( height: 10, ), SelectPaymentOptionWidget(model), SizedBox( height: 10, ), model.paymentCheckoutData.lacumInformation != null ? Container( child: Column( children: [ LakumWidget(model), SizedBox( height: 10, ), ], ), ) : Container(), Container( color: Colors.white, width: double.infinity, padding: EdgeInsets.all(8), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( TranslationBase.of(context).reviewOrder, fontSize: 14, fontWeight: FontWeight.bold, color: Colors.black, ), ...List.generate( model.cartResponse.shoppingCarts != null ? model.cartResponse.shoppingCarts.length : 0, (index) => ProductOrderPreviewItem( model.cartResponse.shoppingCarts[index]), ), ], ), ), Container( width: double.infinity, padding: EdgeInsets.all(8), child: model.cartResponse.subtotal != null ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( TranslationBase.of(context).orderSummary, fontSize: 14, fontWeight: FontWeight.bold, color: Colors.black, ), SizedBox( height: 20, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Texts( "${TranslationBase.of(context).subtotal}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, ), Texts( "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, ), ], ), const Divider( color: Color(0xFFD6D6D6), height: 20, thickness: 1, indent: 0, endIndent: 0, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Texts( "${TranslationBase.of(context).shipping}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, ), Texts( "${TranslationBase.of(context).sar} ${(model.totalAdditionalShippingCharge).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, ), ], ), const Divider( color: Color(0xFFD6D6D6), height: 20, thickness: 1, indent: 0, endIndent: 0, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Texts( "${TranslationBase.of(context).vat}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, ), Texts( "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, ), ], ), const Divider( color: Color(0xFFD6D6D6), height: 20, thickness: 1, indent: 0, endIndent: 0, ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Texts( TranslationBase.of(context).total, fontSize: 14, color: Colors.black, fontWeight: FontWeight.bold, ), Texts( "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.bold, ), ], ), SizedBox( height: 10, ), ], ) : Container(), ), SizedBox( height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, ) ], ), ), ), ), bottomSheet: Container( height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, color: Colors.white, child: PaymentBottomWidget(model), ), ); } }