You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
237 lines
9.8 KiB
Dart
237 lines
9.8 KiB
Dart
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> addresses;
|
|
final OrderPreviewViewModel model;
|
|
|
|
OrderPreviewPage({this.addresses, this.model});
|
|
|
|
@override
|
|
_OrderPreviewPageState createState() => _OrderPreviewPageState();
|
|
}
|
|
|
|
class _OrderPreviewPageState extends State<OrderPreviewPage> {
|
|
MyInAppBrowser browser;
|
|
bool isLoading = true;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
getData();
|
|
}
|
|
|
|
void getData() async {
|
|
if (isLoading) await Provider.of<OrderPreviewViewModel>(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 widget.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: widget.model,
|
|
body: Container(
|
|
color: Color(0xFFF1F1F1),
|
|
height: height * 0.90,
|
|
child: SingleChildScrollView(
|
|
child: Container(
|
|
color: Color(0xFFF1F1F1),
|
|
child: Column(
|
|
children: [
|
|
SelectAddressWidget(widget.model, widget.addresses, changeMainState, isUpdating: true,),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
SelectPaymentOptionWidget(widget.model, changeMainState,isUpdating: true,),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
widget.model.paymentCheckoutData.lacumInformation != null
|
|
? Container(
|
|
child: Column(
|
|
children: [
|
|
LakumWidget(widget.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(
|
|
widget.model.cartResponse.shoppingCarts != null ? widget.model.cartResponse.shoppingCarts.length : 0,
|
|
(index) => ProductOrderPreviewItem(widget.model.cartResponse.shoppingCarts[index]),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
width: double.infinity,
|
|
padding: EdgeInsets.all(8),
|
|
child: widget.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} ${(widget.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} ${(widget.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} ${(widget.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} ${(widget.model.cartResponse.subtotalWithVat).toStringAsFixed(2)}",
|
|
fontSize: 14,
|
|
color: Colors.black,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
],
|
|
)
|
|
: Container(),
|
|
),
|
|
SizedBox(
|
|
height: widget.model.cartResponse.shoppingCarts != null ? height * 0.10 : 0,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
bottomSheet: Container(
|
|
height: widget.model.cartResponse.shoppingCarts != null ? height * 0.10 : 0,
|
|
color: Colors.white,
|
|
child: PaymentBottomWidget(widget.model),
|
|
),
|
|
);
|
|
}
|
|
|
|
changeMainState() {
|
|
setState(() {});
|
|
}
|
|
}
|