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';
class PaymentCheckoutData with ChangeNotifier{
class PaymentCheckoutData {
Addresses address;
PaymentOption paymentOption;
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});
void updateData() {
notifyListeners();
}
}

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

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

Loading…
Cancel
Save