first step from update design

merge-update-with-lab-changes
Elham Rababh 4 years ago
parent f8883f5439
commit df9e58402d

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

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

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

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

Loading…
Cancel
Save