fix issue in cart page

merge-update-with-lab-changes
Elham Rababh 5 years ago
parent 26c83cd93d
commit 2526d6bc6f

@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import 'ShippingOption.dart'; import 'ShippingOption.dart';
class PaymentCheckoutData with ChangeNotifier{ class PaymentCheckoutData {
Addresses address; Addresses address;
PaymentOption paymentOption; PaymentOption paymentOption;
LacumAccountInformation lacumInformation; LacumAccountInformation lacumInformation;
@ -15,7 +15,5 @@ class PaymentCheckoutData with ChangeNotifier{
PaymentCheckoutData({this.address, this.paymentOption, this.lacumInformation, this.cartDataVisible = false, this.shippingOption, this.usedLakumPoints = 0}); PaymentCheckoutData({this.address, this.paymentOption, this.lacumInformation, this.cartDataVisible = false, this.shippingOption, this.usedLakumPoints = 0});
void updateData() {
notifyListeners();
}
} }

@ -192,7 +192,7 @@ class OrderPreviewViewModel extends BaseViewModel {
.getShippingOption(paymentCheckoutData.address) .getShippingOption(paymentCheckoutData.address)
.then((res) { .then((res) {
paymentCheckoutData.shippingOption = ShippingOption.fromJson(res); paymentCheckoutData.shippingOption = ShippingOption.fromJson(res);
paymentCheckoutData.updateData(); setState(ViewState.Idle);
}); });
if (_orderService.hasError) { if (_orderService.hasError) {
error = _orderService.error; error = _orderService.error;

@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
@ -79,9 +80,7 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
SizedBox( SizedBox(
height: 10, height: 10,
), ),
Consumer<PaymentCheckoutData>( model.paymentCheckoutData.lacumInformation != null
builder: (ctx, paymentData, _) =>
paymentData.lacumInformation != null
? Container( ? Container(
child: Column( child: Column(
children: [ children: [
@ -92,7 +91,7 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
], ],
), ),
) )
: Container()), : Container(),
Container( Container(
color: Colors.white, color: Colors.white,
width: double.infinity, width: double.infinity,
@ -227,7 +226,8 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
], ],
) )
: Container(), : Container(),
) ),
SizedBox(height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0,)
], ],
), ),
), ),
@ -284,8 +284,8 @@ class _SelectAddressWidgetState extends State<SelectAddressWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Consumer<PaymentCheckoutData>( OrderPreviewViewModel model = Provider.of(context);
builder: (ctx, paymentData, _) => Container( return Container(
color: Colors.white, color: Colors.white,
child: address == null child: address == null
? InkWell( ? InkWell(
@ -424,7 +424,7 @@ class _SelectAddressWidgetState extends State<SelectAddressWidget> {
), ),
Container( Container(
child: Image.asset( child: Image.asset(
paymentData.shippingOption model.paymentCheckoutData.shippingOption==null?"": model.paymentCheckoutData.shippingOption
.shippingRateComputationMethodSystemName == .shippingRateComputationMethodSystemName ==
"Shipping.FixedOrByWeight" "Shipping.FixedOrByWeight"
? "assets/images/pharmacy_module/payment/hmg_shipping_logo.png" ? "assets/images/pharmacy_module/payment/hmg_shipping_logo.png"
@ -439,7 +439,6 @@ class _SelectAddressWidgetState extends State<SelectAddressWidget> {
), ),
), ),
), // ic_shipping_mark.png ), // ic_shipping_mark.png
),
); );
} }
} }
@ -465,7 +464,6 @@ class _SelectPaymentOptionWidgetState extends State<SelectPaymentOptionWidget> {
paymentOption = result; paymentOption = result;
widget.model.paymentCheckoutData.paymentOption = widget.model.paymentCheckoutData.paymentOption =
paymentOption; paymentOption;
widget.model.paymentCheckoutData.updateData();
} }
}) })
}); });
@ -744,11 +742,10 @@ class PaymentBottomWidget extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final scaffold = Scaffold.of(context); final scaffold = Scaffold.of(context);
this.context = context; this.context = context;
OrderPreviewViewModel orderPreviewViewModel = Provider.of(context);
return Container( return Container(
margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0), margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
child: Consumer<PaymentCheckoutData>( child: orderPreviewViewModel.paymentCheckoutData.cartDataVisible
builder: (ctx, paymentData, _) => paymentData.cartDataVisible
? Container( ? Container(
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -798,8 +795,8 @@ class PaymentBottomWidget extends StatelessWidget {
width: 1, width: 1,
), ),
), ),
onPressed: (paymentData.address != null && onPressed: (orderPreviewViewModel.paymentCheckoutData.address != null &&
paymentData.paymentOption != null) orderPreviewViewModel.paymentCheckoutData.paymentOption != null)
? () async { ? () async {
await model.makeOrder(); await model.makeOrder();
if (model.state == ViewState.Idle) { if (model.state == ViewState.Idle) {
@ -820,20 +817,20 @@ class PaymentBottomWidget extends StatelessWidget {
child: new Text( child: new Text(
"${TranslationBase.of(context).proceedPay}", "${TranslationBase.of(context).proceedPay}",
style: new TextStyle( style: new TextStyle(
color: (paymentData.address != null && color: (orderPreviewViewModel.paymentCheckoutData.address != null &&
paymentData.paymentOption != null) orderPreviewViewModel.paymentCheckoutData.paymentOption != null)
? Colors.white ? Colors.white
: Colors.grey.shade400, : Colors.grey.shade400,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 12), fontSize: 12),
), ),
), ),
color: (paymentData.address != null && color: (orderPreviewViewModel.paymentCheckoutData.address != null &&
paymentData.paymentOption != null) orderPreviewViewModel.paymentCheckoutData.paymentOption != null)
? Colors.green ? Colors.green
: Color(0xff929295), : Color(0xff929295),
disabledColor: (paymentData.address != null && disabledColor: (orderPreviewViewModel.paymentCheckoutData.address != null &&
paymentData.paymentOption != null) orderPreviewViewModel.paymentCheckoutData.paymentOption != null)
? Colors.green ? Colors.green
: Color(0xff929295), : Color(0xff929295),
), ),
@ -842,7 +839,6 @@ class PaymentBottomWidget extends StatelessWidget {
), ),
) )
: Container(), : Container(),
),
); );
} }

@ -78,6 +78,8 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
}, },
), ),
), ),
SizedBox(height: height * 0.10,)
], ],
), ),
), ),

Loading…
Cancel
Save