private async void BtnAdd_Clicked(object sender, EventArgs e) { Busy(); url = await services.UploadFile(file.GetStream(), Path.GetFileName(file.Path)); Pet p = await services.AddPetTask( petType, name, age, sex, url, breed.Text, _petSize, _medCond, medicalConditionDetails.Text, personality.Text, _pottyTrained, _apartmentFriendly );; NotBusy(); // TODO - prettify this alert var result = await DisplayAlert(null, "Pet added successfully!", "Add another", "View my pets"); // true for view my pets, false for add another if (!result) { // View my Pets await Application.Current.MainPage.Navigation.PushAsync(new PetDetailsPage(p, null)); } if (result) { // Add another pet await Application.Current.MainPage.Navigation.PopAsync(); } //await Application.Current.MainPage.Navigation.PushAsync(new PetDetailsPage(p, null)); // now we need to update list of pets -- check if it doesn't do it automatically /* var allPets = services.getPets(); * lstPets.ItemsSource = allPets; */ }
private async void UploadImagesButton_Clicked(object sender, EventArgs e) { // Get the list of images we have selected. List <string> imagePaths = ImgCarouselView.ItemsSource as List <string>; // If user is using Android, compress the images. (Optional) if (Device.RuntimePlatform == Device.Android) { imagePaths = CompressAllImages(imagePaths); } // Change info text. (Optional) InfoText.Text = "Uploading..."; for (int i = 0; i < imagePaths.Count; i++) { System.IO.Stream str = _imgStreams[i]; string path = Path.GetFileName(imagePaths[i]) + ".jpg"; string url = (await service.UploadFile(str, path)); urls.Add(url); } await service.AddPetMedia(pet, urls); // Change info text. (Optional) InfoText.Text = "Upload complete."; // Clear temp files after upload. if (Device.RuntimePlatform == Device.Android) { DependencyService.Get <IMediaService>().ClearFileDirectory(); } if (Device.RuntimePlatform == Device.iOS) { GMMultiImagePicker.Current.ClearFileDirectory(); } //await Application.Current.MainPage.Navigation.PopAsync(); // broke the nav bar maybe await Navigation.PopAsync(); }