Merge branch 'development_new_design_2.0' into haroon-new-design

# Conflicts:
#	lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart
merge-update-with-lab-changes
haroon amjad 4 years ago
commit c29aee46dd

@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart';
import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/AddAddress.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
@ -22,14 +23,17 @@ class PharmacyAddressesPage extends StatefulWidget {
final bool isUpdate;
const PharmacyAddressesPage({Key key, this.orderPreviewViewModel, this.isUpdate = false, this.changeMainState}) : super(key: key);
const PharmacyAddressesPage(
{Key key, this.orderPreviewViewModel, this.isUpdate = false, this.changeMainState})
: 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(
@ -45,7 +49,7 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
return BaseView<PharmacyAddressesViewModel>(
onModelReady: (model) => model.getAddressesList(),
builder: (_, model, wi) => AppScaffold(
appBarTitle: widget.isUpdate ? TranslationBase.of(context).changeAddress : "Add Address",
appBarTitle: widget.isUpdate?TranslationBase.of(context).changeAddress:"Add Address",
isShowAppBar: true,
isPharmacy: true,
baseViewModel: model,
@ -118,10 +122,22 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
backgroundColor: Color(0xFF5AB145),
fontSize: 14,
vPadding: 8,
handler: () {
handler: () async {
//TODO Elham*
widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[model.selectedAddressIndex].toJson());
model.saveSelectedAddressLocally(model.addresses[model.selectedAddressIndex]);
widget.orderPreviewViewModel.paymentCheckoutData
.address =
Addresses.fromJson(
model.addresses[model.selectedAddressIndex].toJson());
GifLoaderDialogUtils.showMyDialog(context);
await widget.orderPreviewViewModel.getInformationsByAddress(widget.orderPreviewViewModel.user.patientIdentificationNo);
await widget.orderPreviewViewModel.getShoppingCart();
// widget.changeMainState();
GifLoaderDialogUtils.hideDialog(context);
model.saveSelectedAddressLocally(
model.addresses[model.selectedAddressIndex]);
_navigateToPaymentOption(model);
},
),
@ -134,13 +150,15 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
}
_navigateToPaymentOption(model) {
if (widget.isUpdate) {
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(
@ -150,7 +168,8 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
setState(() {
if (result != null) {
var paymentOption = result;
widget.orderPreviewViewModel.paymentCheckoutData.paymentOption = paymentOption;
widget.orderPreviewViewModel.paymentCheckoutData.paymentOption =
paymentOption;
}
// widget.changeMainState();
})
@ -165,7 +184,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) {
@ -191,13 +211,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,
),
),
@ -210,7 +235,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: [
@ -273,7 +299,8 @@ class AddressItemWidget extends StatelessWidget {
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
padding:
const EdgeInsets.symmetric(horizontal: 8),
child: SizedBox(
child: Container(
width: 1,
@ -291,13 +318,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