finish address add/edit/delete/select

merge-update-with-lab-changes
mosazaid 5 years ago
parent 378562b781
commit 6ac8d67b83

@ -357,6 +357,7 @@ const GET_E_REFERRALS = "Services/Patients.svc/REST/GetEReferrals";
// pharmacy
const PHARMACY_VERIFY_CUSTOMER = "epharmacy/api/VerifyCustomer";
const PHARMACY_GET_COUNTRY = "epharmacy/api/countries";
const PHARMACY_CREATE_CUSTOMER = "epharmacy/api/CreateCustomer";
const GET_PHARMACY_BANNER = "epharmacy/api/promotionbanners";
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_ORDER = "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_SHOPPING_CART = "epharmacy/api/shopping_cart_items/";
const GET_SHIPPING_OPTIONS = "epharmacy/api/get_shipping_option/";

@ -21,3 +21,4 @@ const THEME_VALUE = 'is_vibration';
const MAIN_USER = 'main-user';
const PHARMACY_LAST_VISITED_PRODUCTS = 'last-visited';
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;
List<PointsAmountPerYear> transferPointsAmountPerYear;
List<PointsDetails> transferPointsDetails;
int waitingPoints;
int loyalityAmount;
int loyalityPoints;
dynamic waitingPoints;
dynamic loyalityAmount;
dynamic loyalityPoints;
int purchaseRate;
LakumInquiryInformationObjVersion(

@ -1,24 +1,117 @@
import 'package:diplomaticquarterapp/config/shared_pref_kay.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/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 '../base_view_model.dart';
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);
await _PharmacyAddressService.getAddress();
if (_PharmacyAddressService.hasError) {
error = _PharmacyAddressService.error;
await _pharmacyAddressService.getAddresses();
if (_pharmacyAddressService.hasError) {
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);
} 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/pharmacy_module_page.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/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
@ -242,12 +243,14 @@ class _SelectAddressWidgetState extends State<SelectAddressWidget> {
Addresses address;
_navigateToAddressPage() {
Navigator.push(
context, FadePage(page: AddressSelectPageTest(widget.addresses)))
Navigator.push(context, FadePage(page: PharmacyAddressesPage()))
.then((result) {
address = result;
widget.model.paymentCheckoutData.address = address;
widget.model.getInformationsByAddress();
if (result != null) {
address = result;
widget.model.paymentCheckoutData.address = address;
widget.model.getInformationsByAddress();
}
/* setState(() {
if (result != null) {
address = result;
@ -610,7 +613,9 @@ class _LakumWidgetState extends State<LakumWidget> {
fontWeight: FontWeight.bold,
),
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,
height: 50,
child: TextField(
@ -687,11 +692,11 @@ class _LakumWidgetState extends State<LakumWidget> {
shape: BoxShape.rectangle,
borderRadius: projectProvider.isArabic
? BorderRadius.only(
topLeft: Radius.circular(6),
bottomLeft: Radius.circular(6))
topLeft: Radius.circular(6),
bottomLeft: Radius.circular(6))
: BorderRadius.only(
topRight: Radius.circular(6),
bottomRight: Radius.circular(6)),
topRight: Radius.circular(6),
bottomRight: Radius.circular(6)),
border: Border.fromBorderSide(BorderSide(
color: Color(0xff3666E0),
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/ProductTileItem.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/widgets/buttons/borderedButton.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
@ -188,7 +189,9 @@ class GridViewButtons extends StatelessWidget {
opacity: 0,
hasColorFilter: false,
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(
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_html/style.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 {
final Addresses editedAddress;
final Function(PickResult) onPick;
AddAddressPage(this.editedAddress, this.onPick);
@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
void initState() {
// TODO: implement initState
_initialPosition = LatLng(24.662617030, 46.7334844);
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) {
mapController = controller;
_getCurrentLocation() async {
await Geolocator.getLastKnownPosition().then((value) {
_latitude = value.latitude;
_longitude = value.longitude;
}).catchError((e) {
_longitude = 0;
_latitude = 0;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(TranslationBase.of(context).addNewAddress, style: TextStyle(color:Colors.white)),
backgroundColor: Colors.green,
),
body: Stack(
children: <Widget> [
GoogleMap(
zoomControlsEnabled: true,
myLocationButtonEnabled: true,
myLocationEnabled: true,
onMapCreated: _onMapCreated,
onCameraMove: (object) {
// widget.currentLat = object.target.latitude;
// widget.currentLong = object.target.longitude;
},
onCameraIdle: _getAddressFromLatLng,
padding: EdgeInsets.only(bottom: 90.0),
initialCameraPosition: CameraPosition(
target: _initialPosition,
zoom: 13.0,
),
),
// 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,
),
),
),
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>(
builder: (_, model, wi) => AppScaffold(
appBarTitle: TranslationBase.of(context).changeAddress,
isShowAppBar: true,
isPharmacy: true,
backgroundColor: Colors.white,
appBarWidget: appBarWidget,
body: Container(
height: height * 1,
child: PickupLocationFromMap(
latitude: _latitude,
longitude: _longitude,
isWithAppBar: false,
buttonColor: Color(0xFF5AB145),
buttonLabel: TranslationBase.of(context).save,
onPick: (value) {
widget.onPick(value);
},
),
),
),
);
);
}
// 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/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/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.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/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
_PharmacyAddressesState createState() => _PharmacyAddressesState();
}
class _PharmacyAddressesState extends State<PharmacyAddressesPage>{
int selectedRadio;
bool _value = false;
AppSharedPreferences sharedPref = AppSharedPreferences();
}
@override
void initState(){
// WidgetsBinding.instance.addPostFrameCallback((_) => getAllAddress());
class _PharmacyAddressesState extends State<PharmacyAddressesPage> {
super.initState();
selectedRadio=0;
}
setSelectedRadio(int val){
setState(() {
selectedRadio = val;
});
void navigateToAddressPage(
BuildContext ctx, PharmacyAddressesViewModel model, Addresses address) {
Navigator.push(
ctx,
FadePage(
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>(
onModelReady: (model) => model.getAddress(),
builder: (_,model, wi )=> AppScaffold(
appBarTitle: "",
// centerTitle: true,
// title: Text(TranslationBase.of(context).changeAddress, style: TextStyle(color:Colors.white)),
// backgroundColor: Colors.green,
onModelReady: (model) => model.getAddressesList(),
builder: (_, model, wi) => AppScaffold(
appBarTitle: TranslationBase.of(context).changeAddress,
isShowAppBar: true,
isPharmacy:true ,
isPharmacy: true,
backgroundColor: Colors.white,
appBarWidget: appBarWidget,
body: Container(
child:SingleChildScrollView(
height: height * 0.90,
child: SingleChildScrollView(
child: Column(
children:<Widget>[
ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
physics: ScrollPhysics(),
itemCount: 5 ,
itemBuilder: (context, index){
return Container(
child: Padding(
padding:EdgeInsets.only(top:10.0, left:5.0, right:5.0, bottom:5.0,),
child: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.center,
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();
children: <Widget>[
...List.generate(
model.addresses != null ? model.addresses.length : 0,
(index) => AddressItemWidget(
model,
model.addresses[index],
() {
setState(() {
model.setSelectedAddressIndex(index);
});
},
model.selectedAddressIndex == index,
(address) {
navigateToAddressPage(context, model, address);
}),
);
},
child: Container(
margin: EdgeInsets.only(bottom: 100.0),
height: 50.0,
color: Colors.transparent,
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.green,
style: BorderStyle.solid,
width: 1.0
),
color: Colors.transparent,
borderRadius: BorderRadius.circular(5.0)
),
child: Center(
child: Text(
TranslationBase.of(context).addAddress,
style: TextStyle(
color: Colors.green,
fontWeight: FontWeight.bold,
),
),
),
),
),
Container(
color: Colors.white,
margin: EdgeInsets.all(8),
child: BorderedButton(
TranslationBase.of(context).addAddress,
hasBorder: true,
borderColor: Color(0xFF0fca6d),
textColor: Color(0xFF0fca6d),
fontWeight: FontWeight.bold,
backgroundColor: Colors.white,
fontSize: 14,
vPadding: 12,
hasShadow: true,
handler: () {
navigateToAddressPage(context, model, null);
},
),
),
],
),
),
),
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(5.0)
bottomSheet: Container(
height: height * 0.10,
color: Colors.white,
child: Column(
children: [
Divider(
color: Colors.grey.shade300,
height: 1,
thickness: 1,
indent: 0,
endIndent: 0,
),
child: Center(
child: Text(TranslationBase.of(context).confirmAddress,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
Container(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
child: BorderedButton(
TranslationBase.of(context).confirmAddress,
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(){
}
getEditAddress(){
}
getDeleteAddress(){
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: Padding(
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 0),
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/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/models/Authentication/authenticated_user.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{
List<PharmacyAddressesModel> get address => address;
Future getAddresses() async {
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();
AppGlobal appGlobal = new AppGlobal();
AuthenticatedUser authUser = new AuthenticatedUser();
AuthProvider authProvider = new AuthProvider();
Future addCustomerAddress(Addresses address) async {
makeCustomerAddress(address, ADD_CUSTOMER_ADDRESS);
}
List<PharmacyAddressesModel> _addressList = List();
List<PharmacyAddressesModel> get reviewList => _addressList;
Future editCustomerAddress(Addresses address) async {
makeCustomerAddress(address, EDIT_CUSTOMER_ADDRESS);
}
Future deleteCustomerAddress(Addresses address) async {
makeCustomerAddress(address, DELETE_CUSTOMER_ADDRESS);
}
Future getAddress() async {
print("step 1");
Future makeCustomerAddress(Addresses address, String url) async {
var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
hasError = false;
await baseAppClient.getPharmacy(GET_ORDER,
onSuccess: (dynamic response, int statusCode) {
_addressList.clear();
response['customers'].forEach((item) {
_addressList.add(PharmacyAddressesModel.fromJson(item));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
});
}}
super.error = "";
Map<String, dynamic> customerObject = Map();
customerObject["addresses"] = [address];
customerObject["id"] = customerId;
customerObject["email"] = address.email;
customerObject["role_ids"] = [3];
Map<String, dynamic> body = Map();
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 Widget icon;
final FontWeight fontWeight;
final bool hasShadow;
BorderedButton(
this.text, {
@ -36,6 +37,7 @@ class BorderedButton extends StatelessWidget {
this.fontSize = 0,
this.icon,
this.fontWeight,
this.hasShadow = false,
});
@override
@ -46,14 +48,21 @@ class BorderedButton extends StatelessWidget {
},
child: Container(
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: backgroundColor ?? Colors.white,
borderRadius: BorderRadius.circular(radius),
border: Border.fromBorderSide(BorderSide(
color: hasBorder ? borderColor : Colors.white,
width: 0.8,
)),
),
shape: BoxShape.rectangle,
color: backgroundColor ?? Colors.white,
borderRadius: BorderRadius.circular(radius),
border: Border.fromBorderSide(BorderSide(
color: hasBorder ? borderColor : Colors.white,
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: Row(
mainAxisAlignment: MainAxisAlignment.center,
@ -69,8 +78,11 @@ class BorderedButton extends StatelessWidget {
text,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: fontSize == 0 ? SizeConfig.textMultiplier * 1.6 : fontSize,
fontWeight: fontWeight != null ? fontWeight : FontWeight.normal,
fontSize: fontSize == 0
? SizeConfig.textMultiplier * 1.6
: fontSize,
fontWeight:
fontWeight != null ? fontWeight : FontWeight.normal,
color: textColor ?? Color(0xffc4aa54)),
),
),

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

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

Loading…
Cancel
Save