finish address add/edit/delete/select

merge-requests/176/head
mosazaid 5 years ago
parent 378562b781
commit 6ac8d67b83

@ -357,6 +357,7 @@ const GET_E_REFERRALS = "Services/Patients.svc/REST/GetEReferrals";
// pharmacy // pharmacy
const PHARMACY_VERIFY_CUSTOMER = "epharmacy/api/VerifyCustomer"; const PHARMACY_VERIFY_CUSTOMER = "epharmacy/api/VerifyCustomer";
const PHARMACY_GET_COUNTRY = "epharmacy/api/countries";
const PHARMACY_CREATE_CUSTOMER = "epharmacy/api/CreateCustomer"; const PHARMACY_CREATE_CUSTOMER = "epharmacy/api/CreateCustomer";
const GET_PHARMACY_BANNER = "epharmacy/api/promotionbanners"; const GET_PHARMACY_BANNER = "epharmacy/api/promotionbanners";
const GET_PHARMACY_TOP_MANUFACTURER = "epharmacy/api/topmanufacturer"; const GET_PHARMACY_TOP_MANUFACTURER = "epharmacy/api/topmanufacturer";
@ -366,6 +367,9 @@ const GET_CUSTOMERS_ADDRESSES = "epharmacy/api/Customers/";
const GET_WISHLIST = "epharmacy/api/shopping_cart_items/"; const GET_WISHLIST = "epharmacy/api/shopping_cart_items/";
const GET_ORDER = "orders?"; const GET_ORDER = "orders?";
const GET_ORDER_DETAILS = "epharmacy/api/orders/"; const GET_ORDER_DETAILS = "epharmacy/api/orders/";
const ADD_CUSTOMER_ADDRESS = "epharmacy/api/addcustomeraddress";
const EDIT_CUSTOMER_ADDRESS = "epharmacy/api/editcustomeraddress";
const DELETE_CUSTOMER_ADDRESS = "epharmacy/api/deletecustomeraddress";
const GET_ADDRESS = "epharmacy/api/Customers/272843?fields=addresses"; const GET_ADDRESS = "epharmacy/api/Customers/272843?fields=addresses";
const GET_SHOPPING_CART = "epharmacy/api/shopping_cart_items/"; const GET_SHOPPING_CART = "epharmacy/api/shopping_cart_items/";
const GET_SHIPPING_OPTIONS = "epharmacy/api/get_shipping_option/"; const GET_SHIPPING_OPTIONS = "epharmacy/api/get_shipping_option/";

@ -21,3 +21,4 @@ const THEME_VALUE = 'is_vibration';
const MAIN_USER = 'main-user'; const MAIN_USER = 'main-user';
const PHARMACY_LAST_VISITED_PRODUCTS = 'last-visited'; const PHARMACY_LAST_VISITED_PRODUCTS = 'last-visited';
const PHARMACY_CUSTOMER_ID = 'costumer-id'; const PHARMACY_CUSTOMER_ID = 'costumer-id';
const PHARMACY_SELECTED_ADDRESS = 'selected-address';

@ -0,0 +1,32 @@
class CountryData {
int id;
String name;
String namen;
String twoLetterIsoCode;
String threeLetterIsoCode;
CountryData(
{this.id,
this.name,
this.namen,
this.twoLetterIsoCode,
this.threeLetterIsoCode});
CountryData.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
namen = json['namen'];
twoLetterIsoCode = json['two_letter_iso_code'];
threeLetterIsoCode = json['three_letter_iso_code'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
data['namen'] = this.namen;
data['two_letter_iso_code'] = this.twoLetterIsoCode;
data['three_letter_iso_code'] = this.threeLetterIsoCode;
return data;
}
}

@ -27,9 +27,9 @@ class LakumInquiryInformationObjVersion {
int transferPoints; int transferPoints;
List<PointsAmountPerYear> transferPointsAmountPerYear; List<PointsAmountPerYear> transferPointsAmountPerYear;
List<PointsDetails> transferPointsDetails; List<PointsDetails> transferPointsDetails;
int waitingPoints; dynamic waitingPoints;
int loyalityAmount; dynamic loyalityAmount;
int loyalityPoints; dynamic loyalityPoints;
int purchaseRate; int purchaseRate;
LakumInquiryInformationObjVersion( LakumInquiryInformationObjVersion(

@ -1,24 +1,117 @@
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/Country.dart';
import 'package:diplomaticquarterapp/services/pharmacy_services/pharmacyAddress_service.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/pharmacyAddress_service.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyAddressesModel.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyAddressesModel.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:google_maps_place_picker/google_maps_place_picker.dart';
import '../../../locator.dart'; import '../../../locator.dart';
import '../base_view_model.dart'; import '../base_view_model.dart';
class PharmacyAddressesViewModel extends BaseViewModel { class PharmacyAddressesViewModel extends BaseViewModel {
PharmacyAddressService _PharmacyAddressService = locator<PharmacyAddressService>(); PharmacyAddressService _pharmacyAddressService =
locator<PharmacyAddressService>();
List<Addresses> get addresses => _pharmacyAddressService.addresses;
List<PharmacyAddressesModel> get address => _PharmacyAddressService.address; int get selectedAddressIndex => _pharmacyAddressService.selectedAddressIndex;
CountryData get country => _pharmacyAddressService.country;
setSelectedAddressIndex(int index) {
_pharmacyAddressService.selectedAddressIndex = index;
}
Future getAddress() async { Future getAddressesList() async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _PharmacyAddressService.getAddress(); await _pharmacyAddressService.getAddresses();
if (_PharmacyAddressService.hasError) { if (_pharmacyAddressService.hasError) {
error = _PharmacyAddressService.error; error = _pharmacyAddressService.error;
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
}
}
/* Future getCountries(String countryName) async {
setState(ViewState.Busy);
await _pharmacyAddressService.getCountries(countryName);
if (_pharmacyAddressService.hasError) {
error = _pharmacyAddressService.error;
// setState(ViewState.Error);
} else {
// setState(ViewState.Idle);
}
}*/
Future addEditAddress(PickResult value, Addresses editedAddress) async {
setState(ViewState.Busy);
Addresses sendingAddress;
if (editedAddress == null) {
sendingAddress = Addresses();
sendingAddress.id = "0";
sendingAddress.firstName = user.firstName;
sendingAddress.lastName = user.lastName;
sendingAddress.email = user.emailAddress;
sendingAddress.company = null;
} else {
sendingAddress = editedAddress;
}
value.addressComponents.forEach((element) {
if (element.types.contains("country")) {
sendingAddress.country = element.longName;
}
if (element.types.contains("administrative_area_level_1")) {
sendingAddress.city = element.longName;
}
if (element.types.contains("postal_code")) {
sendingAddress.zipPostalCode = element.longName;
}
if (element.types.contains("administrative_area_level_2")) {
sendingAddress.province = element.longName;
}
});
sendingAddress.latLong = value.geometry.location.toString();
await _pharmacyAddressService.getCountries(sendingAddress.country);
sendingAddress.countryId = country.id;
sendingAddress.stateProvinceId = null;
sendingAddress.address1 = value.formattedAddress;
sendingAddress.address2 = "";
sendingAddress.phoneNumber = user.mobileNumber;
sendingAddress.faxNumber = user.faxNumber;
sendingAddress.customerAttributes = "";
sendingAddress.createdOnUtc = DateTime.now().toString();
if (editedAddress == null) {
await _pharmacyAddressService.addCustomerAddress(sendingAddress);
} else {
await _pharmacyAddressService.editCustomerAddress(sendingAddress);
}
if (_pharmacyAddressService.hasError) {
error = _pharmacyAddressService.error;
setState(ViewState.Error); setState(ViewState.Error);
} else { } else {
setState(ViewState.Idle);
}
}
Future deleteAddresses(Addresses sendingAddress) async {
setState(ViewState.Busy);
await _pharmacyAddressService.deleteCustomerAddress(sendingAddress);
if (_pharmacyAddressService.hasError) {
error = _pharmacyAddressService.error;
setState(ViewState.Error);
} else {
setState(ViewState.Idle);
} }
} }
Future saveSelectedAddressLocally(Addresses selectedAddress) async {
await sharedPref.setObject(PHARMACY_SELECTED_ADDRESS, selectedAddress);
}
} }

@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/pages/pharmacies/screens/address-select-pag
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/pharmacies/screens/pharmacy_module_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_page.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.dart';
import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
@ -242,12 +243,14 @@ class _SelectAddressWidgetState extends State<SelectAddressWidget> {
Addresses address; Addresses address;
_navigateToAddressPage() { _navigateToAddressPage() {
Navigator.push( Navigator.push(context, FadePage(page: PharmacyAddressesPage()))
context, FadePage(page: AddressSelectPageTest(widget.addresses)))
.then((result) { .then((result) {
address = result; if (result != null) {
widget.model.paymentCheckoutData.address = address; address = result;
widget.model.getInformationsByAddress(); widget.model.paymentCheckoutData.address = address;
widget.model.getInformationsByAddress();
}
/* setState(() { /* setState(() {
if (result != null) { if (result != null) {
address = result; address = result;
@ -610,7 +613,9 @@ class _LakumWidgetState extends State<LakumWidget> {
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
Container( Container(
margin: projectProvider.isArabic ? EdgeInsets.only(right: 4) : EdgeInsets.only(left: 4), margin: projectProvider.isArabic
? EdgeInsets.only(right: 4)
: EdgeInsets.only(left: 4),
width: 60, width: 60,
height: 50, height: 50,
child: TextField( child: TextField(
@ -687,11 +692,11 @@ class _LakumWidgetState extends State<LakumWidget> {
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: projectProvider.isArabic borderRadius: projectProvider.isArabic
? BorderRadius.only( ? BorderRadius.only(
topLeft: Radius.circular(6), topLeft: Radius.circular(6),
bottomLeft: Radius.circular(6)) bottomLeft: Radius.circular(6))
: BorderRadius.only( : BorderRadius.only(
topRight: Radius.circular(6), topRight: Radius.circular(6),
bottomRight: Radius.circular(6)), bottomRight: Radius.circular(6)),
border: Border.fromBorderSide(BorderSide( border: Border.fromBorderSide(BorderSide(
color: Color(0xff3666E0), color: Color(0xff3666E0),
width: 0.8, width: 0.8,

@ -7,6 +7,7 @@ import 'package:diplomaticquarterapp/pages/pharmacies/screens/lakum-main-page.da
import 'package:diplomaticquarterapp/pages/pharmacies/widgets/BannerPager.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/BannerPager.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductTileItem.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductTileItem.dart';
import 'package:diplomaticquarterapp/pages/pharmacies/widgets/manufacturerItem.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/manufacturerItem.dart';
import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.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';
@ -188,7 +189,9 @@ class GridViewButtons extends StatelessWidget {
opacity: 0, opacity: 0,
hasColorFilter: false, hasColorFilter: false,
child: GridViewCard(TranslationBase.of(context).myPrescriptions, child: GridViewCard(TranslationBase.of(context).myPrescriptions,
'assets/images/pharmacy_module/prescription_icon.png', () {}), 'assets/images/pharmacy_module/prescription_icon.png', () {
Navigator.push(context, FadePage(page: PharmacyAddressesPage()));
}),
), ),
DashboardItem( DashboardItem(
imageName: 'pharmacy_module/bg_4.png', imageName: 'pharmacy_module/bg_4.png',

@ -1,127 +1,82 @@
import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/pickupLocation/PickupLocationFromMap.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_html/style.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:geolocator/geolocator.dart';
import 'package:google_maps_place_picker/google_maps_place_picker.dart';
class AddAddressPage extends StatefulWidget { class AddAddressPage extends StatefulWidget {
final Addresses editedAddress;
final Function(PickResult) onPick;
AddAddressPage(this.editedAddress, this.onPick);
@override @override
_AddAddressState createState() => _AddAddressState(); _AddAddressPageState createState() => _AddAddressPageState();
} }
class _AddAddressState extends State<AddAddressPage> { class _AddAddressPageState extends State<AddAddressPage> {
double _latitude;
double _longitude;
void onMapCreated(controller){
setState(() {
mapController= controller;
});
}
void _getAddressFromLatLng() {}
_onMapTypeButtonPressed(){}
_onAddMarkerButtonPressed(){}
LatLng _initialPosition;
GoogleMapController mapController;
@override @override
void initState() { void initState() {
// TODO: implement initState
_initialPosition = LatLng(24.662617030, 46.7334844);
super.initState(); super.initState();
if (widget.editedAddress != null &&
widget.editedAddress.latLong != null &&
widget.editedAddress.latLong != "") {
List<String> latLng = widget.editedAddress.latLong.split(",");
_latitude = double.parse(latLng[0]);
_longitude = double.parse(latLng[1]);
} else {
_getCurrentLocation();
}
} }
void _onMapCreated(GoogleMapController controller) { _getCurrentLocation() async {
mapController = controller; await Geolocator.getLastKnownPosition().then((value) {
_latitude = value.latitude;
_longitude = value.longitude;
}).catchError((e) {
_longitude = 0;
_latitude = 0;
});
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( PreferredSizeWidget appBarWidget = AppBarWidget(
appBar: AppBar( "${TranslationBase.of(context).changeAddress}", null, true);
centerTitle: true, final mediaQuery = MediaQuery.of(context);
title: Text(TranslationBase.of(context).addNewAddress, style: TextStyle(color:Colors.white)), final height = mediaQuery.size.height -
backgroundColor: Colors.green, appBarWidget.preferredSize.height -
), mediaQuery.padding.top;
body: Stack(
children: <Widget> [ return BaseView<PharmacyAddressesViewModel>(
GoogleMap( builder: (_, model, wi) => AppScaffold(
zoomControlsEnabled: true, appBarTitle: TranslationBase.of(context).changeAddress,
myLocationButtonEnabled: true, isShowAppBar: true,
myLocationEnabled: true, isPharmacy: true,
onMapCreated: _onMapCreated, backgroundColor: Colors.white,
onCameraMove: (object) { appBarWidget: appBarWidget,
// widget.currentLat = object.target.latitude; body: Container(
// widget.currentLong = object.target.longitude; height: height * 1,
}, child: PickupLocationFromMap(
onCameraIdle: _getAddressFromLatLng, latitude: _latitude,
padding: EdgeInsets.only(bottom: 90.0), longitude: _longitude,
initialCameraPosition: CameraPosition( isWithAppBar: false,
target: _initialPosition, buttonColor: Color(0xFF5AB145),
zoom: 13.0, buttonLabel: TranslationBase.of(context).save,
), onPick: (value) {
), widget.onPick(value);
// Align( },
// alignment: Alignment.topRight,
// child: Column(
// children:<Widget> [
// button(_onMapTypeButtonPressed,Icons.map),
// SizedBox(
// height:16.0,
// ),
// button(_onAddMarkerButtonPressed, Icons.add_location)
// ],
// ),
// ),
]
),
bottomSheet: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return AddAddressPage();
}),
);
},
child: Container(
height: 50.0,
color: Colors.green,
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.green,
style: BorderStyle.solid,
width: 1.0
),
color: Colors.green,
borderRadius: BorderRadius.circular(10.0)
),
child: Center(
child: Text(TranslationBase.of(context).confirmLocation,
style: TextStyle(
color: Colors.white,
fontSize: 15.0,
fontWeight: FontWeight.bold,
),
),
),
), ),
), ),
), ),
); );
} }
// Widget button(Function function, IconData icon){
// return FloatingActionButton(
// onPressed: function,
// materialTapTargetSize: MaterialTapTargetSize.padded,
// backgroundColor: Colors.red,
// child: Icon(
// icon,
// size: 18.0,
// ),);
// }
} }

@ -1,380 +1,320 @@
import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart';
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/AddAddress.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/AddAddress.dart';
import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/services/pharmacy_services/pharmacyAddress_service.dart'; import 'package:google_maps_place_picker/google_maps_place_picker.dart';
class PharmacyAddressesPage extends StatefulWidget{ class PharmacyAddressesPage extends StatefulWidget {
@override @override
_PharmacyAddressesState createState() => _PharmacyAddressesState(); _PharmacyAddressesState createState() => _PharmacyAddressesState();
} }
class _PharmacyAddressesState extends State<PharmacyAddressesPage>{
int selectedRadio;
bool _value = false;
AppSharedPreferences sharedPref = AppSharedPreferences();
@override class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
void initState(){
// WidgetsBinding.instance.addPostFrameCallback((_) => getAllAddress());
super.initState(); void navigateToAddressPage(
selectedRadio=0; BuildContext ctx, PharmacyAddressesViewModel model, Addresses address) {
} Navigator.push(
setSelectedRadio(int val){ ctx,
setState(() { FadePage(
selectedRadio = val; page: AddAddressPage(address, (pickResult) {
}); model.addEditAddress(pickResult, address);
})));
} }
Widget build (BuildContext context){ Widget build(BuildContext context) {
PreferredSizeWidget appBarWidget = AppBarWidget(
"${TranslationBase.of(context).changeAddress}", null, true);
final mediaQuery = MediaQuery.of(context);
final height = mediaQuery.size.height -
appBarWidget.preferredSize.height -
mediaQuery.padding.top;
return BaseView<PharmacyAddressesViewModel>( return BaseView<PharmacyAddressesViewModel>(
onModelReady: (model) => model.getAddress(), onModelReady: (model) => model.getAddressesList(),
builder: (_,model, wi )=> AppScaffold( builder: (_, model, wi) => AppScaffold(
appBarTitle: "", appBarTitle: TranslationBase.of(context).changeAddress,
// centerTitle: true,
// title: Text(TranslationBase.of(context).changeAddress, style: TextStyle(color:Colors.white)),
// backgroundColor: Colors.green,
isShowAppBar: true, isShowAppBar: true,
isPharmacy:true , isPharmacy: true,
backgroundColor: Colors.white,
appBarWidget: appBarWidget,
body: Container( body: Container(
child:SingleChildScrollView( height: height * 0.90,
child: SingleChildScrollView(
child: Column( child: Column(
children:<Widget>[ children: <Widget>[
ListView.builder( ...List.generate(
scrollDirection: Axis.vertical, model.addresses != null ? model.addresses.length : 0,
shrinkWrap: true, (index) => AddressItemWidget(
physics: ScrollPhysics(), model,
itemCount: 5 , model.addresses[index],
itemBuilder: (context, index){ () {
return Container( setState(() {
child: Padding( model.setSelectedAddressIndex(index);
padding:EdgeInsets.only(top:10.0, left:5.0, right:5.0, bottom:5.0,), });
child: Column( },
children: [ model.selectedAddressIndex == index,
Row( (address) {
crossAxisAlignment: CrossAxisAlignment.center, navigateToAddressPage(context, model, address);
children:<Widget> [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children:<Widget> [
InkWell(
onTap: () {
setState(() {
_value = !_value;
});
},
child: Container(
margin: EdgeInsets.only(right: 20),
child: Padding(
padding: const EdgeInsets.all(5.0),
child: _value
? Container(
child: SvgPicture.asset(
'assets/images/pharmacy/check_icon.svg',
height: 25,
width: 25,),
)
: Container(
child: SvgPicture.asset(
'assets/images/pharmacy/check_icon.svg',
height: 23,
width: 23,
color: Colors.transparent,
),
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey,
style: BorderStyle.solid,
width: 1.0
),
color: Colors.transparent,
borderRadius: BorderRadius.circular(50.0)
),
),
),
),
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children:<Widget> [
Text('NAME',
style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold,
),
),
SizedBox(
height: 5,),
Text('Address',
style: TextStyle(fontSize: 15.0, color: Colors.grey,
),
),
SizedBox(
height: 5,),
Row(
children:<Widget> [
Container(
margin: EdgeInsets.only(bottom: 8),
child: SvgPicture.asset(
'assets/images/pharmacy/mobile_number_icon.svg',
height: 13,),
),
Container(
margin: EdgeInsets.only(left: 10, bottom: 8),
child: Text('588888778',
style: TextStyle(fontSize: 15.0,
),
),
),
],
),
SizedBox(
height: 15,),
Row(
children:<Widget> [
Column(
children: <Widget> [
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return AddAddressPage();
}),
);
},
child: Row(
children:<Widget> [
Container(
margin: EdgeInsets.only(right:10, bottom: 15),
child: SvgPicture.asset(
'assets/images/pharmacy/edit_icon.svg',
height: 15,),
),
Container(
margin: EdgeInsets.only(right:5, bottom: 15),
padding: EdgeInsets.only(right: 10.0),
child: Text(TranslationBase.of(context).edit,
style: TextStyle(fontSize: 15.0,
color: Colors.blue,
),
),
decoration: BoxDecoration(
border: Border(
right: BorderSide(
color: Colors.grey,
width: 1.0,
),
),
),
),
],
),
),
],
),
Column(
children: <Widget> [
InkWell(
onTap: () {
// confirmDelete(snapshot.data[index]["id"]);
confirmDelete("address");
},
child: Row(
children:<Widget> [
Container(
margin: EdgeInsets.only(left: 15, right: 10, bottom: 15),
child: SvgPicture.asset(
'assets/images/pharmacy/delete_red_icon.svg',
height: 15,),
),
Container(
margin: EdgeInsets.only(bottom: 15),
child: Text(TranslationBase.of(context).delete,
style: TextStyle(fontSize: 15.0,
color: Colors.redAccent,
),
),
),
],
),
),
],
)
],
),
],
),
SizedBox(
height: 10,
),
],
),
Divider(
color: Colors.grey[350],
height: 20,
thickness: 6,
indent: 0,
endIndent: 0,
),
],
),
),
);
}
),
SizedBox(
height: 10,
),
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return AddAddressPage();
}), }),
); ),
}, Container(
child: Container( color: Colors.white,
margin: EdgeInsets.only(bottom: 100.0), margin: EdgeInsets.all(8),
height: 50.0, child: BorderedButton(
color: Colors.transparent, TranslationBase.of(context).addAddress,
child: Container( hasBorder: true,
decoration: BoxDecoration( borderColor: Color(0xFF0fca6d),
border: Border.all( textColor: Color(0xFF0fca6d),
color: Colors.green, fontWeight: FontWeight.bold,
style: BorderStyle.solid, backgroundColor: Colors.white,
width: 1.0 fontSize: 14,
), vPadding: 12,
color: Colors.transparent, hasShadow: true,
borderRadius: BorderRadius.circular(5.0) handler: () {
), navigateToAddressPage(context, model, null);
child: Center( },
child: Text(
TranslationBase.of(context).addAddress,
style: TextStyle(
color: Colors.green,
fontWeight: FontWeight.bold,
),
),
),
),
), ),
), ),
], ],
), ),
), ),
), ),
bottomSheet: InkWell( bottomSheet: Container(
onTap: () { height: height * 0.10,
Navigator.push( color: Colors.white,
context, child: Column(
MaterialPageRoute(builder: (context) { children: [
return AddAddressPage(); Divider(
}), color: Colors.grey.shade300,
); height: 1,
}, thickness: 1,
child: Container( indent: 0,
height: 50.0, endIndent: 0,
color: Colors.green,
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.green,
style: BorderStyle.solid,
width: 1.0
),
color: Colors.green,
borderRadius: BorderRadius.circular(5.0)
), ),
child: Center( Container(
child: Text(TranslationBase.of(context).confirmAddress, padding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
style: TextStyle( child: BorderedButton(
color: Colors.white, TranslationBase.of(context).confirmAddress,
fontWeight: FontWeight.bold, hasBorder: true,
), borderColor: Color(0xFF5AB145),
textColor: Colors.white,
fontWeight: FontWeight.bold,
backgroundColor: Color(0xFF5AB145),
fontSize: 14,
vPadding: 12,
handler: () {
model.saveSelectedAddressLocally(
model.addresses[model.selectedAddressIndex]);
Navigator.pop(context,
model.addresses[model.selectedAddressIndex]);
},
), ),
), ),
), ],
), ),
), ),
), ),
); );
} }
confirmDelete(address){
showDialog(
context: context,
builder: (BuildContext context)=> AlertDialog(
title: Text(TranslationBase.of(context).confirmDeleteMsg,
style: TextStyle(
fontWeight: FontWeight.bold,
),),
content: Text("address"),
actions:[
FlatButton(
child: Text(TranslationBase.of(context).cancel,
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
fontSize: 16,
),),
onPressed: (){
Navigator.pop(context);
},
),
FlatButton(
child: Text(TranslationBase.of(context).confirmDelete,
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
fontSize: 16,
),),
onPressed: (){
// http.delete("https://uat.hmgwebservices.com/epharmacy/api/Customers/272843?fields=addresses/$id");
Navigator.push(context,
MaterialPageRoute(builder: (context)=> PharmacyAddressesPage() ));
},
),
],
)
);
}
}
getAllAddress() {
// print("ADDRESSES");
// PharmacyAddressService service = new PharmacyAddressService();
// service.getAddress(AppGlobal.context).then((res) {
// print(res);
// });
} }
class AddressItemWidget extends StatelessWidget {
final PharmacyAddressesViewModel model;
final Addresses address;
final Function selectAddress;
final bool isSelected;
final Function(Addresses) onTabEditAddress;
AddressItemWidget(this.model, this.address, this.selectAddress,
this.isSelected, this.onTabEditAddress);
getConfirmAddress(){ @override
Widget build(BuildContext context) {
} return Container(
getEditAddress(){ color: Colors.white,
child: Padding(
} padding: EdgeInsets.symmetric(vertical: 8, horizontal: 0),
getDeleteAddress(){ child: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
InkWell(
onTap: selectAddress,
child: Container(
margin: EdgeInsets.only(left: 16, right: 16),
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Container(
decoration: new BoxDecoration(
color: !isSelected ? Colors.white : Colors.green,
shape: BoxShape.circle,
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,
size: 25,
),
),
),
),
),
),
],
),
Expanded(
child: Container(
child: Container(
margin:
EdgeInsets.symmetric(vertical: 12, horizontal: 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 0),
child: Texts(
"${address.firstName} ${address.lastName}",
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Texts(
"${address.address1} ${address.address2} ${address.address2},, ${address.city}, ${address.country} ${address.zipPostalCode}",
fontSize: 12,
fontWeight: FontWeight.normal,
color: Colors.grey.shade500,
),
),
Row(
children: [
Container(
margin: const EdgeInsets.only(right: 8),
child: Icon(
Icons.phone,
size: 20,
color: Colors.black,
),
),
Texts(
"${address.phoneNumber}",
fontSize: 14,
fontWeight: FontWeight.bold,
color: Colors.grey,
),
],
),
SizedBox(
height: 10,
),
Container(
height: 25,
child: Row(
children: <Widget>[
BorderedButton(
TranslationBase.of(context).edit,
backgroundColor: Colors.transparent,
hasBorder: true,
borderColor: Colors.transparent,
textColor: Color(0x990000FF),
handler: () {
onTabEditAddress(address);
},
icon: Icon(
Icons.edit,
size: 15,
color: Color(0x990000FF),
),
),
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 8),
child: SizedBox(
child: Container(
width: 1,
color: Colors.grey.shade400,
),
),
),
BorderedButton(
TranslationBase.of(context).delete,
backgroundColor: Colors.transparent,
hasBorder: true,
borderColor: Colors.transparent,
textColor: Color(0x99FF0000),
handler: () {
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,
okFunction: () => {
model
.deleteAddresses(address)
.then((_) {
ConfirmDialog.closeAlertDialog(
context);
AppToast.showErrorToast(
message:
"Address has been deleted");
})
},
cancelFunction: () => {});
dialog.showAlertDialog(context);
},
icon: Icon(
Icons.delete,
size: 15,
color: Color(0x99FF0000),
),
),
],
),
),
],
),
),
),
),
],
),
Divider(
color: Colors.grey.shade200,
height: 10,
thickness: 10,
indent: 0,
endIndent: 0,
),
],
),
),
);
}
} }

@ -1,36 +1,102 @@
import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/Country.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:flutter/material.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyAddressesModel.dart';
class PharmacyAddressService extends BaseService {
List<Addresses> addresses = List();
CountryData country;
int selectedAddressIndex = 0;
class PharmacyAddressService extends BaseService{ Future getAddresses() async {
List<PharmacyAddressesModel> get address => address; var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
Map<String, String> queryParams = {'fields': 'addresses'};
hasError = false;
Addresses selectedAddress;
try {
await baseAppClient.get("$GET_CUSTOMERS_ADDRESSES$customerId",
onSuccess: (dynamic response, int statusCode) async {
addresses.clear();
var savedAddress =
await sharedPref.getObject(PHARMACY_SELECTED_ADDRESS);
if (savedAddress != null) {
selectedAddress = Addresses.fromJson(savedAddress);
}
int index = 0;
response['customers'][0]['addresses'].forEach((item) {
Addresses address = Addresses.fromJson(item);
if (selectedAddress != null && selectedAddress.id == item["id"]) {
selectedAddressIndex = index;
}
addresses.add(address);
index++;
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, queryParams: queryParams);
} catch (error) {
throw error;
}
}
Future getCountries(String countryName) async {
hasError = false;
try {
await baseAppClient.get("$PHARMACY_GET_COUNTRY",
onSuccess: (dynamic response, int statusCode) {
// countries.clear();
response['countries'].forEach((item) {
if (CountryData.fromJson(item).name == countryName ||
CountryData.fromJson(item).namen == countryName) {
country = CountryData.fromJson(item);
}
// countries.add(CountryData.fromJson(item));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
});
} catch (error) {
throw error;
}
}
AppSharedPreferences sharedPref = AppSharedPreferences(); Future addCustomerAddress(Addresses address) async {
AppGlobal appGlobal = new AppGlobal(); makeCustomerAddress(address, ADD_CUSTOMER_ADDRESS);
AuthenticatedUser authUser = new AuthenticatedUser(); }
AuthProvider authProvider = new AuthProvider();
List<PharmacyAddressesModel> _addressList = List(); Future editCustomerAddress(Addresses address) async {
List<PharmacyAddressesModel> get reviewList => _addressList; makeCustomerAddress(address, EDIT_CUSTOMER_ADDRESS);
}
Future deleteCustomerAddress(Addresses address) async {
makeCustomerAddress(address, DELETE_CUSTOMER_ADDRESS);
}
Future getAddress() async { Future makeCustomerAddress(Addresses address, String url) async {
print("step 1"); var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
hasError = false; hasError = false;
await baseAppClient.getPharmacy(GET_ORDER, super.error = "";
onSuccess: (dynamic response, int statusCode) {
_addressList.clear(); Map<String, dynamic> customerObject = Map();
response['customers'].forEach((item) { customerObject["addresses"] = [address];
_addressList.add(PharmacyAddressesModel.fromJson(item)); customerObject["id"] = customerId;
}); customerObject["email"] = address.email;
}, onFailure: (String error, int statusCode) { customerObject["role_ids"] = [3];
hasError = true; Map<String, dynamic> body = Map();
super.error = error; body["customer"] = customerObject;
});
}} await baseAppClient.post("$url", onSuccess: (response, statusCode) async {
addresses.clear();
response['customers'][0]['addresses'].forEach((item) {
addresses.add(Addresses.fromJson(item));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
}

@ -18,6 +18,7 @@ class BorderedButton extends StatelessWidget {
final double fontSize; final double fontSize;
final Widget icon; final Widget icon;
final FontWeight fontWeight; final FontWeight fontWeight;
final bool hasShadow;
BorderedButton( BorderedButton(
this.text, { this.text, {
@ -36,6 +37,7 @@ class BorderedButton extends StatelessWidget {
this.fontSize = 0, this.fontSize = 0,
this.icon, this.icon,
this.fontWeight, this.fontWeight,
this.hasShadow = false,
}); });
@override @override
@ -46,14 +48,21 @@ class BorderedButton extends StatelessWidget {
}, },
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
color: backgroundColor ?? Colors.white, color: backgroundColor ?? Colors.white,
borderRadius: BorderRadius.circular(radius), borderRadius: BorderRadius.circular(radius),
border: Border.fromBorderSide(BorderSide( border: Border.fromBorderSide(BorderSide(
color: hasBorder ? borderColor : Colors.white, color: hasBorder ? borderColor : Colors.white,
width: 0.8, width: 0.8,
)), )),
), boxShadow: [
BoxShadow(
color: !hasShadow ? Colors.transparent : Colors.grey.withOpacity(0.5),
// spreadRadius: 5,
blurRadius: 15.0,
offset: Offset(0.0, 0.75) // changes position of shadow
),
]),
child: Container( child: Container(
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@ -69,8 +78,11 @@ class BorderedButton extends StatelessWidget {
text, text,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: fontSize == 0 ? SizeConfig.textMultiplier * 1.6 : fontSize, fontSize: fontSize == 0
fontWeight: fontWeight != null ? fontWeight : FontWeight.normal, ? SizeConfig.textMultiplier * 1.6
: fontSize,
fontWeight:
fontWeight != null ? fontWeight : FontWeight.normal,
color: textColor ?? Color(0xffc4aa54)), color: textColor ?? Color(0xffc4aa54)),
), ),
), ),

@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
class ConfirmDialog { class ConfirmDialog {
final BuildContext context; final BuildContext context;
final title;
final confirmMessage; final confirmMessage;
final okText; final okText;
final cancelText; final cancelText;
@ -14,6 +15,7 @@ class ConfirmDialog {
ConfirmDialog( ConfirmDialog(
{@required this.context, {@required this.context,
this.title,
@required this.confirmMessage, @required this.confirmMessage,
@required this.okText, @required this.okText,
@required this.cancelText, @required this.cancelText,
@ -31,7 +33,7 @@ class ConfirmDialog {
// set up the AlertDialog // set up the AlertDialog
AlertDialog alert = AlertDialog( AlertDialog alert = AlertDialog(
title: Text(TranslationBase.of(context).confirm), title: title != null ? Text(title) : Text(TranslationBase.of(context).confirm),
content: Text(this.confirmMessage), content: Text(this.confirmMessage),
actions: [ actions: [
cancelButton, cancelButton,

@ -1,6 +1,7 @@
import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.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/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/others/close_back.dart'; import 'package:diplomaticquarterapp/widgets/others/close_back.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
@ -13,24 +14,36 @@ class PickupLocationFromMap extends StatelessWidget {
final Function(PickResult) onPick; final Function(PickResult) onPick;
final double latitude; final double latitude;
final double longitude; final double longitude;
final bool isWithAppBar;
final String buttonLabel;
final Color buttonColor;
const PickupLocationFromMap({Key key, this.onPick, this.latitude, this.longitude}) const PickupLocationFromMap(
{Key key,
this.onPick,
this.latitude,
this.longitude,
this.isWithAppBar = true,
this.buttonLabel,
this.buttonColor})
: super(key: key); : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: isWithAppBar
elevation: 0, ? AppBar(
textTheme: TextTheme( elevation: 0,
headline6: textTheme: TextTheme(
TextStyle(color: Colors.white, fontWeight: FontWeight.bold), headline6:
), TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
title: Text('Location'), ),
leading: CloseBack(), title: Text('Location'),
centerTitle: true, leading: CloseBack(),
), centerTitle: true,
)
: null,
body: PlacePicker( body: PlacePicker(
apiKey: GOOGLE_API_KEY, apiKey: GOOGLE_API_KEY,
enableMyLocationButton: true, enableMyLocationButton: true,
@ -57,17 +70,30 @@ class PickupLocationFromMap extends StatelessWidget {
child: state == SearchingState.Searching child: state == SearchingState.Searching
? Center(child: CircularProgressIndicator()) ? Center(child: CircularProgressIndicator())
: Container( : Container(
margin: EdgeInsets.all(12), margin: EdgeInsets.all(12),
child: SecondaryButton( child: BorderedButton(
color: Colors.grey[800], buttonLabel != null ? buttonLabel : TranslationBase.of(context).next,
textColor: Colors.white, textColor: Colors.white,
onTap: () { fontWeight: FontWeight.bold,
backgroundColor: buttonColor != null ? buttonColor : Colors.grey[800],
fontSize: 14,
vPadding: 12,
radius: 10,
handler: () {
onPick(selectedPlace); onPick(selectedPlace);
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
label: TranslationBase.of(context).next,
), ),
), /* SecondaryButton(
color: Colors.grey[800],
textColor: Colors.white,
onTap: () {
onPick(selectedPlace);
Navigator.of(context).pop();
},
label: TranslationBase.of(context).next,
),*/
),
); );
}, },
initialPosition: LatLng(latitude, longitude), initialPosition: LatLng(latitude, longitude),

Loading…
Cancel
Save