public PhotoViewModel(IUserDialogService dialogs, IMediaPicker picker) { this.dialogs = dialogs; this.picker = picker; this.FromCamera = new Command(async () => { if (!picker.IsCameraAvailable) dialogs.Alert("Camera is not available"); else { var result = await picker.TakePhoto(); this.OnPhotoReceived(result); } }); this.FromGallery = new Command(async () => { if (!picker.IsPhotoGalleryAvailable) dialogs.Alert("Photo Gallery is unavailable"); else { var result = await picker.PickPhoto(); this.OnPhotoReceived(result); } }); this.Choice = new Command(() => dialogs.ActionSheet(new ActionSheetConfig() .Add("Camera", () => this.FromCamera.Execute(null)) .Add("Gallery", () => this.FromGallery.Execute(null)) .Add("Cancel") )); }
public PhotoViewModel(IUserDialogService dialogs, IMediaPicker picker) { this.dialogs = dialogs; this.FromCamera = new Command(async() => { if (!picker.IsCameraAvailable) { dialogs.Alert("Camera is not available"); } else { var result = await picker.TakePhoto(); this.OnPhotoReceived(result); } }); this.FromGallery = new Command(async() => { if (!picker.IsPhotoGalleryAvailable) { dialogs.Alert("Photo Gallery is unavailable"); } else { var result = await picker.PickPhoto(); this.OnPhotoReceived(result); } }); this.Choice = new Command(() => dialogs.ActionSheet(new ActionSheetConfig() .Add("Camera", () => this.FromCamera.Execute(null)) .Add("Gallery", () => this.FromGallery.Execute(null)) .Add("Cancel") )); }
async void ImageFromGallery() { if (!_mediaPicker.IsPhotoGalleryAvailable) { _userDialogService.Alert("Photo Gallery is unavailable"); } else { var result = await _mediaPicker.PickPhoto(); this.OnImageReceived(result); } }