merge-requests/390/merge
Mirza.Shafique 4 years ago
parent 32f62fbe56
commit f20883184e

@ -49,96 +49,97 @@ class _CMCLocationPageState extends State<CMCLocationPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
return BaseView<CMCViewModel>( return BaseView<CMCViewModel>(
onModelReady: (model) {}, onModelReady: (model) {},
builder: (_, model, widget) => AppScaffold( builder: (_, model, widget) => AppScaffold(
isShowDecPage: false, isShowDecPage: false,
isShowAppBar: true, isShowAppBar: true,
baseViewModel: model, baseViewModel: model,
showNewAppBar: true, showNewAppBar: true,
showNewAppBarTitle: true, showNewAppBarTitle: true,
backgroundColor: CustomColors.appBackgroudGreyColor, backgroundColor: CustomColors.appBackgroudGreyColor,
description: TranslationBase.of(context).infoCMC, description: TranslationBase.of(context).infoCMC,
imagesInfo: [ imagesInfo: [
ImagesInfo(imageAr: 'https://hmgwebservices.com/Images/MobileApp/CMC/ar/0.png', imageEn: 'https://hmgwebservices.com/Images/MobileApp/CMC/en/0.png'), ImagesInfo(imageAr: 'https://hmgwebservices.com/Images/MobileApp/CMC/ar/0.png', imageEn: 'https://hmgwebservices.com/Images/MobileApp/CMC/en/0.png'),
], ],
appBarTitle: TranslationBase.of(context).addNewAddress, appBarTitle: TranslationBase.of(context).addNewAddress,
body: PlacePicker( body: PlacePicker(
apiKey: GOOGLE_API_KEY, apiKey: GOOGLE_API_KEY,
enableMyLocationButton: true, enableMyLocationButton: true,
automaticallyImplyAppBarLeading: false, automaticallyImplyAppBarLeading: false,
autocompleteOnTrailingWhitespace: true, autocompleteOnTrailingWhitespace: true,
selectInitialPosition: true, selectInitialPosition: true,
autocompleteLanguage: projectViewModel.currentLanguage, autocompleteLanguage: projectViewModel.currentLanguage,
enableMapTypeButton: true, enableMapTypeButton: true,
searchForInitialValue: false, searchForInitialValue: false,
onPlacePicked: (PickResult result) { onPlacePicked: (PickResult result) {
print(result.adrAddress); print(result.adrAddress);
}, },
selectedPlaceWidgetBuilder: (_, selectedPlace, state, isSearchBarFocused) { selectedPlaceWidgetBuilder: (_, selectedPlace, state, isSearchBarFocused) {
print("state: $state, isSearchBarFocused: $isSearchBarFocused"); print("state: $state, isSearchBarFocused: $isSearchBarFocused");
return isSearchBarFocused return isSearchBarFocused
? Container() ? Container()
: FloatingCard( : FloatingCard(
bottomPosition: 0.0, bottomPosition: 0.0,
leftPosition: 0.0, leftPosition: 0.0,
rightPosition: 0.0, rightPosition: 0.0,
width: 500, width: 500,
borderRadius: BorderRadius.circular(12.0), borderRadius: BorderRadius.circular(12.0),
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: Column( child: Column(
children: [ children: [
SecondaryButton( SecondaryButton(
color: CustomColors.accentColor, color: CustomColors.accentColor,
textColor: Colors.white, textColor: Colors.white,
onTap: () async { onTap: () async {
print(selectedPlace); print(selectedPlace);
AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel( AddNewAddressRequestModel addNewAddressRequestModel = new AddNewAddressRequestModel(
customer: Customer(addresses: [ customer: Customer(addresses: [
Addresses( Addresses(
address1: selectedPlace.formattedAddress, address1: selectedPlace.formattedAddress,
address2: selectedPlace.formattedAddress, address2: selectedPlace.formattedAddress,
customerAttributes: "", customerAttributes: "",
city: "", city: "",
createdOnUtc: "", createdOnUtc: "",
id: 0, id: 0,
latLong: "$latitude,$longitude", latLong: "$latitude,$longitude",
email: "") email: "")
]), ]),
); );
selectedPlace.addressComponents.forEach((e) { selectedPlace.addressComponents.forEach((e) {
if (e.types.contains("country")) { if (e.types.contains("country")) {
addNewAddressRequestModel.customer.addresses[0].country = e.longName; addNewAddressRequestModel.customer.addresses[0].country = e.longName;
} }
if (e.types.contains("postal_code")) { if (e.types.contains("postal_code")) {
addNewAddressRequestModel.customer.addresses[0].zipPostalCode = e.longName; addNewAddressRequestModel.customer.addresses[0].zipPostalCode = e.longName;
} }
if (e.types.contains("locality")) { if (e.types.contains("locality")) {
addNewAddressRequestModel.customer.addresses[0].city = e.longName; addNewAddressRequestModel.customer.addresses[0].city = e.longName;
} }
}); });
await model.addAddressInfo(addNewAddressRequestModel: addNewAddressRequestModel); await model.addAddressInfo(addNewAddressRequestModel: addNewAddressRequestModel);
if (model.state == ViewState.ErrorLocal) { if (model.state == ViewState.ErrorLocal) {
Utils.showErrorToast(model.error); Utils.showErrorToast(model.error);
} else { } else {
AppToast.showSuccessToast(message: "Address Added Successfully"); AppToast.showSuccessToast(message: "Address Added Successfully");
} }
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
label: TranslationBase.of(context).addNewAddress, label: TranslationBase.of(context).addNewAddress,
),
],
),
), ),
); ],
}, ),
initialPosition: LatLng(latitude, longitude), ),
useCurrentLocation: showCurrentLocation, );
), },
)); initialPosition: LatLng(latitude, longitude),
useCurrentLocation: showCurrentLocation,
),
),
);
} }
} }

@ -132,15 +132,16 @@ class _NewCMCStepThreePageState extends State<NewCMCStepThreePage> {
// _controller.complete(controller); // _controller.complete(controller);
// }, // },
// ), // ),
child: Image.network("https://maps.googleapis.com/maps/api/staticmap?center=" + child: Image.network(
widget.cmcInsertPresOrderRequestModel.latitude.toString() + "https://maps.googleapis.com/maps/api/staticmap?center=" +
"," + widget.cmcInsertPresOrderRequestModel.latitude.toString() +
widget.cmcInsertPresOrderRequestModel.longitude.toString() + "," +
"&zoom=16&size=600x300&maptype=roadmap&markers=color:red%7C" + widget.cmcInsertPresOrderRequestModel.longitude.toString() +
widget.cmcInsertPresOrderRequestModel.latitude.toString() + "&zoom=16&size=600x300&maptype=roadmap&markers=color:red%7C" +
"," + widget.cmcInsertPresOrderRequestModel.latitude.toString() +
widget.cmcInsertPresOrderRequestModel.longitude.toString() + "," +
"&key=AIzaSyCyDbWUM9d_sBUGIE8PcuShzPaqO08NSC8", widget.cmcInsertPresOrderRequestModel.longitude.toString() +
"&key=AIzaSyCyDbWUM9d_sBUGIE8PcuShzPaqO08NSC8",
width: double.infinity, width: double.infinity,
height: double.infinity, height: double.infinity,
fit: BoxFit.cover, fit: BoxFit.cover,

@ -194,7 +194,11 @@ class _NewCMCStepTowPageState extends State<NewCMCStepTowPage> {
longitude: longitude, longitude: longitude,
), ),
), ),
); ).then((value) {
setState(() {
});
});
}, },
child: Padding( child: Padding(
padding: EdgeInsets.only(left: 12, right: 12, bottom: 16, top: 8), padding: EdgeInsets.only(left: 12, right: 12, bottom: 16, top: 8),

Loading…
Cancel
Save