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/pharmacies/screens/payment-method-select-page.dart';
import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/AddAddress.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/AddAddress.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.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/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart'; import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
@ -22,14 +23,17 @@ class PharmacyAddressesPage extends StatefulWidget {
final bool isUpdate; 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 @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(
@ -45,7 +49,7 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
return BaseView<PharmacyAddressesViewModel>( return BaseView<PharmacyAddressesViewModel>(
onModelReady: (model) => model.getAddressesList(), onModelReady: (model) => model.getAddressesList(),
builder: (_, model, wi) => AppScaffold( builder: (_, model, wi) => AppScaffold(
appBarTitle: widget.isUpdate ? TranslationBase.of(context).changeAddress : "Add Address", appBarTitle: widget.isUpdate?TranslationBase.of(context).changeAddress:"Add Address",
isShowAppBar: true, isShowAppBar: true,
isPharmacy: true, isPharmacy: true,
baseViewModel: model, baseViewModel: model,
@ -118,10 +122,22 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
backgroundColor: Color(0xFF5AB145), backgroundColor: Color(0xFF5AB145),
fontSize: 14, fontSize: 14,
vPadding: 8, vPadding: 8,
handler: () { handler: () async {
//TODO Elham* //TODO Elham*
widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[model.selectedAddressIndex].toJson()); widget.orderPreviewViewModel.paymentCheckoutData
model.saveSelectedAddressLocally(model.addresses[model.selectedAddressIndex]); .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); _navigateToPaymentOption(model);
}, },
), ),
@ -134,13 +150,15 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
} }
_navigateToPaymentOption(model) { _navigateToPaymentOption(model) {
if (widget.isUpdate) { if(widget.isUpdate) {
print("sfsf");
widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[model.selectedAddressIndex].toJson()); widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[model.selectedAddressIndex].toJson());
widget.changeMainState(); widget.changeMainState();
Navigator.pop(context); Navigator.pop(context);
return; return;
} }
Navigator.push( Navigator.push(
context, context,
FadePage( FadePage(
@ -150,7 +168,8 @@ class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
setState(() { setState(() {
if (result != null) { if (result != null) {
var paymentOption = result; var paymentOption = result;
widget.orderPreviewViewModel.paymentCheckoutData.paymentOption = paymentOption; widget.orderPreviewViewModel.paymentCheckoutData.paymentOption =
paymentOption;
} }
// widget.changeMainState(); // widget.changeMainState();
}) })
@ -165,7 +184,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) {
@ -191,13 +211,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,
), ),
), ),
@ -210,7 +235,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: [
@ -273,7 +299,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,
@ -291,13 +318,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