async void UploadButton_Clicked(object sender, System.EventArgs e) { LoadingOverlay.IsVisible = true; LoadingAnimation.Play(); // Upload photo var stream = pickedPhoto != null?pickedPhoto.GetStream() : new MemoryStream(photoResult.Image); var success = false; //await viewModel.UploadPhoto(stream, ""); if (success) { PhotoPreview.Source = null; viewModel.Caption = string.Empty; await Navigation.PopAsync(); // Navigate back to categories page App.AppShell.SelectedItem = null; // Hack: Xamarin.Forms Bug does not allow the same navigation twice otherwise App.AppShell.SelectedItem = App.AppShell.Children.First(); } LoadingOverlay.IsVisible = false; LoadingAnimation.IsPlaying = false; LoadingAnimation.Pause(); }
async void UploadButton_Clicked(object sender, System.EventArgs e) { Analytics.TrackEvent("Upload Button Clicked"); LoadingOverlay.IsVisible = true; LoadingAnimation.Play(); // Upload photo var success = await viewModel.UploadPhoto(file.GetStream(), file.Path); if (success) { CameraControls.IsVisible = true; UploadControls.IsVisible = false; PhotoPreview.Source = null; viewModel.Caption = string.Empty; // Navigate back to categories page App.AppShell.SelectedItem = null; // Hack: Xamarin.Forms Bug does not allow the same navigation twice otherwise App.AppShell.SelectedItem = App.AppShell.Children.First(); } LoadingOverlay.IsVisible = false; LoadingAnimation.IsPlaying = false; LoadingAnimation.Pause(); }
async void UploadButton_Clicked(object sender, System.EventArgs e) { if (PhotoPreview.Source == null) { return; } LoadingOverlay.IsVisible = true; LoadingAnimation.Play(); using (var stream = new MemoryStream()) { var croppedImage = await PhotoPreview.GetImageAsJpegAsync(); await croppedImage.CopyToAsync(stream); stream.Position = 0; // Upload photo var success = await viewModel.UploadPhoto(stream, file.Path); if (success) { PhotoPreview.Source = null; viewModel.Caption = string.Empty; // Navigate back to categories page App.AppShell.SelectedItem = null; // Hack: Xamarin.Forms Bug does not allow the same navigation twice otherwise App.AppShell.SelectedItem = App.AppShell.Children.First(); Analytics.TrackEvent("Photo uploaded"); } } LoadingOverlay.IsVisible = false; LoadingAnimation.Pause(); }