first step from update design

merge-requests/502/head
Elham Rababh 3 years ago
parent f8883f5439
commit df9e58402d

@ -62,11 +62,11 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
color: Color(0xFFF1F1F1),
child: Column(
children: [
SelectAddressWidget(widget.model, widget.addresses, changeMainState),
SelectAddressWidget(widget.model, widget.addresses, changeMainState, isUpdating: true,),
SizedBox(
height: 10,
),
SelectPaymentOptionWidget(widget.model, changeMainState),
SelectPaymentOptionWidget(widget.model, changeMainState,isUpdating: true,),
SizedBox(
height: 10,
),

@ -13,8 +13,10 @@ class SelectAddressWidget extends StatefulWidget {
final OrderPreviewViewModel model;
final List<Addresses> addresses;
final Function changeMainState;
final bool isUpdating;
SelectAddressWidget(this.model, this.addresses, this.changeMainState);
SelectAddressWidget(this.model, this.addresses, this.changeMainState,
{this.isUpdating = false});
@override
_SelectAddressWidgetState createState() => _SelectAddressWidgetState();
@ -24,7 +26,7 @@ class _SelectAddressWidgetState extends State<SelectAddressWidget> {
AddressInfo address;
_navigateToAddressPage(String identificationNo) {
Navigator.push(context, FadePage(page: PharmacyAddressesPage(orderPreviewViewModel: widget.model,))).then((result) async {
Navigator.push(context, FadePage(page: PharmacyAddressesPage(orderPreviewViewModel: widget.model,isUpdate: widget.isUpdating,changeMainState: widget.changeMainState,))).then((result) async {
if (result != null) {
GifLoaderDialogUtils.showMyDialog(context);
address = result;
@ -39,15 +41,15 @@ class _SelectAddressWidgetState extends State<SelectAddressWidget> {
@override
void initState() {
if (widget.model.paymentCheckoutData.address != null) {
address = AddressInfo.fromJson(widget.model.paymentCheckoutData.address.toJson());
}
super.initState();
}
@override
Widget build(BuildContext context) {
OrderPreviewViewModel model = Provider.of(context);
if (widget.model.paymentCheckoutData.address != null) {
address = AddressInfo.fromJson(widget.model.paymentCheckoutData.address.toJson());
}
return Container(
color: Colors.white,
child: address == null

@ -9,8 +9,10 @@ import 'package:flutter/material.dart';
class SelectPaymentOptionWidget extends StatefulWidget {
final OrderPreviewViewModel model;
final Function changeMainState;
final bool isUpdating;
SelectPaymentOptionWidget(this.model, this.changeMainState);
SelectPaymentOptionWidget(this.model, this.changeMainState, {this.isUpdating = false});
@override
_SelectPaymentOptionWidgetState createState() => _SelectPaymentOptionWidgetState();
@ -20,7 +22,7 @@ class _SelectPaymentOptionWidgetState extends State<SelectPaymentOptionWidget> {
PaymentOption paymentOption;
_navigateToPaymentOption() {
Navigator.push(context, FadePage(page: PaymentMethodSelectPage(model: widget.model,)))
Navigator.push(context, FadePage(page: PaymentMethodSelectPage(model: widget.model,changeMainState:widget.changeMainState,isUpdating: widget.isUpdating,)))
.then((result) => {
setState(() {
if (result != null) {
@ -35,14 +37,14 @@ class _SelectPaymentOptionWidgetState extends State<SelectPaymentOptionWidget> {
@override
void initState() {
if (widget.model.paymentCheckoutData.paymentOption != null) {
paymentOption = widget.model.paymentCheckoutData.paymentOption;
}
super.initState();
}
@override
Widget build(BuildContext context) {
if (widget.model.paymentCheckoutData.paymentOption != null) {
paymentOption = widget.model.paymentCheckoutData.paymentOption;
}
return Container(
color: Colors.white,
child: paymentOption == null

@ -13,8 +13,12 @@ import 'cart-page/cart-order-preview.dart';
class PaymentMethodSelectPage extends StatefulWidget {
final OrderPreviewViewModel model;
final bool isUpdating;
final Function changeMainState;
const PaymentMethodSelectPage({Key key, this.model}) : super(key: key);
const PaymentMethodSelectPage(
{Key key, this.model, this.isUpdating = false, this.changeMainState})
: super(key: key);
@override
_PaymentMethodSelectPageState createState() =>
@ -114,17 +118,23 @@ class _PaymentMethodSelectPageState extends State<PaymentMethodSelectPage> {
TranslationBase.of(context).next,
selectedPaymentOption != null
? () {
widget.model.paymentCheckoutData.paymentOption =
selectedPaymentOption;
widget.model.paymentCheckoutData.paymentOption =
selectedPaymentOption;
if (widget.isUpdating) {
widget.changeMainState();
Navigator.pop(context);
return;
} else {
Navigator.push(
context,
FadePage(
page: OrderPreviewPage(
model: widget.model,
),
),
);
}
// Navigator.pop(context, selectedPaymentOption);
Navigator.push(
context,
FadePage(
page:
OrderPreviewPage(model: widget.model,),),);
}
: null,
color: Color(0xff5AB154),
@ -204,40 +214,6 @@ class PaymentMethodCard extends StatelessWidget {
),
),
),
// Container(
// margin: EdgeInsets.symmetric(horizontal: 2, vertical: 0),
// child: Stack(
// children: [
// Container(
// padding: EdgeInsets.symmetric(horizontal: 8, vertical: 8),
// margin: EdgeInsets.symmetric(horizontal: 14, vertical: 8),
// decoration: new BoxDecoration(
// color: Colors.grey.shade100,
// shape: BoxShape.rectangle,
// borderRadius: BorderRadius.circular(8),
// border: Border.fromBorderSide(BorderSide(
// color: isSelected ? Color(0xff20BC11) : Colors.grey.shade300,
// width: 0.8,
// )),
// ),
// width: cardWidth,
// child: Image.asset(
// getPaymentOptionImage(paymentOption),
// fit: BoxFit.cover,
// ),
// ),
// if (isSelected)
// Positioned(
// right: 1,
// child: Icon(
// Icons.check_circle,
// color: Color(0xff20BC11),
// size: 30,
// ),
// ),
// ],
// ),
// ),
),
);
}

@ -17,16 +17,22 @@ import 'package:flutter/material.dart';
///TODO Elham* split this to tow files
class PharmacyAddressesPage extends StatefulWidget {
final OrderPreviewViewModel orderPreviewViewModel;
final Function changeMainState;
final bool isUpdate;
const PharmacyAddressesPage(
{Key key, this.orderPreviewViewModel, this.isUpdate = false, this.changeMainState})
: super(key: key);
const PharmacyAddressesPage({Key key, this.orderPreviewViewModel}) : super(key: key);
@override
_PharmacyAddressesState createState() => _PharmacyAddressesState();
}
class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
void navigateToAddressPage(BuildContext ctx, PharmacyAddressesViewModel model, AddressInfo address) {
void navigateToAddressPage(
BuildContext ctx, PharmacyAddressesViewModel model, AddressInfo address) {
Navigator.push(
ctx,
FadePage(
@ -61,12 +67,14 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
setState(() {
model.setSelectedAddressIndex(index);
//TODO Elham*
widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[index].toJson());
widget.orderPreviewViewModel.paymentCheckoutData
.address =
Addresses.fromJson(
model.addresses[index].toJson());
});
},
model.selectedAddressIndex == index,
(address) {
navigateToAddressPage(context, model, address);
}),
),
@ -88,8 +96,9 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
},
),
),
SizedBox(height: height * 0.10,)
SizedBox(
height: height * 0.10,
)
],
),
),
@ -118,9 +127,10 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
fontSize: 14,
vPadding: 8,
handler: () {
model.saveSelectedAddressLocally(model.addresses[model.selectedAddressIndex]);
_navigateToPaymentOption();
},
model.saveSelectedAddressLocally(
model.addresses[model.selectedAddressIndex]);
_navigateToPaymentOption(model);
},
),
),
],
@ -130,18 +140,31 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
);
}
_navigateToPaymentOption() {
Navigator.push(context, FadePage(page: PaymentMethodSelectPage(model: widget.orderPreviewViewModel,)))
.then((result) => {
setState(() {
if (result != null) {
var paymentOption = result;
widget.orderPreviewViewModel.paymentCheckoutData.paymentOption =
paymentOption;
}
// widget.changeMainState();
})
});
_navigateToPaymentOption(model) {
if(widget.isUpdate) {
print("sfsf");
widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[model.selectedAddressIndex].toJson());
widget.changeMainState();
Navigator.pop(context);
return;
}
Navigator.push(
context,
FadePage(
page: PaymentMethodSelectPage(
model: widget.orderPreviewViewModel,
))).then((result) => {
setState(() {
if (result != null) {
var paymentOption = result;
widget.orderPreviewViewModel.paymentCheckoutData.paymentOption =
paymentOption;
}
// widget.changeMainState();
})
});
}
}
@ -152,7 +175,8 @@ class AddressItemWidget extends StatelessWidget {
final bool isSelected;
final Function(AddressInfo) onTabEditAddress;
AddressItemWidget(this.model, this.address, this.selectAddress, this.isSelected, this.onTabEditAddress);
AddressItemWidget(this.model, this.address, this.selectAddress,
this.isSelected, this.onTabEditAddress);
@override
Widget build(BuildContext context) {
@ -178,13 +202,18 @@ class AddressItemWidget extends StatelessWidget {
decoration: new BoxDecoration(
color: !isSelected ? Colors.white : Colors.green,
shape: BoxShape.circle,
border: Border.all(color: Colors.grey, style: BorderStyle.solid, width: 1.0),
border: Border.all(
color: Colors.grey,
style: BorderStyle.solid,
width: 1.0),
),
child: Padding(
padding: const EdgeInsets.all(0.0),
child: Icon(
Icons.check,
color: isSelected ? Colors.white : Colors.transparent,
color: isSelected
? Colors.white
: Colors.transparent,
size: 25,
),
),
@ -197,7 +226,8 @@ class AddressItemWidget extends StatelessWidget {
Expanded(
child: Container(
child: Container(
margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12),
margin:
EdgeInsets.symmetric(vertical: 12, horizontal: 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -260,7 +290,8 @@ class AddressItemWidget extends StatelessWidget {
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
padding:
const EdgeInsets.symmetric(horizontal: 8),
child: SizedBox(
child: Container(
width: 1,
@ -278,13 +309,21 @@ class AddressItemWidget extends StatelessWidget {
ConfirmDialog dialog = new ConfirmDialog(
context: context,
title: "Are you sure want to delete",
confirmMessage: "${address.address1} ${address.address2}",
okText: TranslationBase.of(context).delete,
cancelText: TranslationBase.of(context).cancel_nocaps,
confirmMessage:
"${address.address1} ${address.address2}",
okText:
TranslationBase.of(context).delete,
cancelText: TranslationBase.of(context)
.cancel_nocaps,
okFunction: () => {
model.deleteAddresses(address).then((_) {
ConfirmDialog.closeAlertDialog(context);
AppToast.showErrorToast(message: "Address has been deleted");
model
.deleteAddresses(address)
.then((_) {
ConfirmDialog.closeAlertDialog(
context);
AppToast.showErrorToast(
message:
"Address has been deleted");
})
},
cancelFunction: () => {});

Loading…
Cancel
Save