private async void Picker_SelectedIndexChanged(object sender, EventArgs e) { if (locationPicker.SelectedIndex == 0) { var request = new GeolocationRequest(GeolocationAccuracy.High); var location = await Geolocation.GetLocationAsync(request); if (location != null) { string sample = location.Latitude + "," + location.Longitude; var coordinates = sample.Split(','); var userModel = sqliteManager.getUserModel(); var address = await getAddress(double.Parse(coordinates[0]), double.Parse(coordinates[0])); userModel.location = sample; userModel.city = address; sqliteManager.updateUserModel(userModel); locationPicker.Title = address; // } else { } } else { await Navigation.PushAsync(new Chatter.View.MapViewer(locationString)); } }
private async Task updateField() { if (category == 0) { var userModel = sqliteManager.getUserModel(); userModel.username = accountFieldEntryAfter.Text; sqliteManager.updateUserModel(userModel); var isSucess = await api.updateUserName(userModel.id, userModel.username); if (!isSucess) { await DisplayAlert("Update", "Unable to update username", "Okay"); return; } await DisplayAlert("Update", "Username successfully changed", "Okay"); } else if (category == 1) { var userModel = sqliteManager.getUserModel(); userModel.password = accountFieldEntryAfter.Text; sqliteManager.updateUserModel(userModel); var isSucess = await api.updatePassword(userModel.id, userModel.password); if (!isSucess) { await DisplayAlert("Update", "Unable to update password", "Okay"); return; } await DisplayAlert("Update", "Password successfully changed", "Okay"); } await Navigation.PopAsync(); }
private async void map_MapClicked(object sender, MapClickedEventArgs e) { string location; map.Pins.Clear(); map.Pins.Add(new Pin { Label = "Pin from tap", Position = new Position(e.Position.Latitude, e.Position.Longitude) }); var isAccepted = await DisplayAlert("Select Location", "Are you sure to this location?", "Yes", "No"); if (!isAccepted) { return; } //Update Location var userModel = sqliteManager.getUserModel(); var userCity = await getAddress(e.Position.Latitude, e.Position.Longitude); location = e.Position.Latitude.ToString() + "," + e.Position.Longitude.ToString(); userModel.location = location; userModel.city = userCity; sqliteManager.updateUserModel(userModel); //await DisplayAlert("Address",await getAddress(e.Position.Latitude,e.Position.Longitude),"Okay"); await api.updateUser(sqliteManager.getUserModel()); await Navigation.PopAsync(); }
private string getDistance(InboxModel model) { var userModel = sqliteManager.getUserModel(); string[] currentLocArr = userModel.location.Split(','); string[] otherUserLocArr = model.location.Split(','); Location myLocation = new Location(Convert.ToDouble(currentLocArr[0]), Convert.ToDouble(currentLocArr[1])); Location otherLocation = new Location(Convert.ToDouble(otherUserLocArr[0]), Convert.ToDouble(otherUserLocArr[1])); double kmDistance; if (userSearchReference.distance_metric == 0) { kmDistance = Location.CalculateDistance(myLocation, otherLocation, DistanceUnits.Kilometers); } else { kmDistance = Location.CalculateDistance(myLocation, otherLocation, DistanceUnits.Miles); } return(Math.Round(kmDistance, 2).ToString()); }
async Task loadUser() { try { userModel = sqliteManager.getUserModel(); otherUser = await api.getSpeificUser(userId); var list = await api.otherUserImageList(userId); var igPhotos = await api.getIgPhotos(userId); var spotifyList = await api.getSpotifyList(userId); distanceLabel.Text = getDistance(otherUser); metricLabel.Text = searchRefence.distance_metric == 0 ? "Km." : "Mi."; BindingContext = otherUser; if (list != null) { foreach (GalleryModel model in list) { if (_isAlreadyLiked) { model.isShow = false; } else { model.isShow = true; } galleryModel.Add(model); } galleryView.ItemsSource = galleryModel; } if (spotifyList == null) { spotifyFrame.IsVisible = false; spotifyListLayout.IsVisible = false; } else { spotifyFrame.IsVisible = true; spotifyListLayout.IsVisible = true; foreach (var spotVal in spotifyList) { spotifyModelLocals.Add(spotVal); //await DisplayAlert("test",spotVal.image,"Okay"); } spotifyListView.ItemsSource = spotifyModelLocals; } //await DisplayAlert("Hayss", igPhotos, "Okay"); if (igPhotos == null) { instaFrame.IsVisible = false; instaLayout.IsVisible = false; return; } foreach (var modeler in igPhotos) { instagramPhotos.Add(modeler); } instagramAlbum.FlowItemsSource = instagramPhotos; //BindableLayout.SetItemsSource(instagramAlbum, instagramPhotos); } catch (Exception ex) { await DisplayAlert("Error", ex.ToString(), "Okay"); } }