public override void ViewDidLoad() { base.ViewDidLoad(); viewModel = new ImageSearchViewModel(); CollectionViewImages.WeakDataSource = this; ButtonSearch.TouchUpInside += async(sender, args) => { ButtonSearch.Enabled = false; ActivityIsLoading.StartAnimating(); // iOS 빌트인 애니메이션 await UIView.AnimateAsync(1.0, () => CollectionViewImages.Alpha = 0); // Shared 코드 호출 await viewModel.SearchForImagesAsync(TextFieldQuery.Text); CollectionViewImages.ReloadData(); await UIView.AnimateAsync(1.0, () => CollectionViewImages.Alpha = 1); ActivityIsLoading.StopAnimating(); ButtonSearch.Enabled = true; }; SetupCamera(); }
public override void ViewDidLoad() { base.ViewDidLoad(); //iOS Image Search code viewModel = new ImageSearchViewModel(); CollectionViewImages.WeakDataSource = this; //Button Click event to get images ButtonSearch.TouchUpInside += async(sender, args) => { ButtonSearch.Enabled = false; ActivityIsLoading.StartAnimating(); await viewModel.SearchForImagesAsync(TextFieldQuery.Text); CollectionViewImages.ReloadData(); ButtonSearch.Enabled = true; ActivityIsLoading.StopAnimating(); }; //IOS Keyboard Done Code var toolbar = new UIToolbar(new CGRect(0.0f, 0.0f, TextFieldQuery.Frame.Size.Width, 44.0f)); toolbar.Items = new[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate { TextFieldQuery.ResignFirstResponder(); }) }; TextFieldQuery.InputAccessoryView = toolbar; }
public override void ViewDidLoad() { base.ViewDidLoad(); viewModel = new ImageSearchViewModel(); CollectionViewImages.WeakDataSource = this; ButtonSearch.TouchUpInside += async(sender, args) => { ButtonSearch.Enabled = false; ActivityIsLoading.StartAnimating(); await viewModel.SearchForImagesAsync(TextFieldQuery.Text); CollectionViewImages.ReloadData(); ButtonSearch.Enabled = true; ActivityIsLoading.StopAnimating(); }; NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Camera, async delegate { await viewModel.TakePhotoAndAnalyzeAsync(false); }); }
public async void FillImageCells() { viewModel = new ImageSearchViewModel(); CollectionViewImages.WeakDataSource = this; ActivityIsLoading.StartAnimating(); await viewModel.SearchForImagesAsync(_query); CollectionViewImages.ReloadData(); ActivityIsLoading.StopAnimating(); }
void SetupCamera() { NavigationItem.RightBarButtonItem = new UIBarButtonItem( UIBarButtonSystemItem.Camera, async delegate { ButtonSearch.Enabled = false; ActivityIsLoading.StartAnimating(); await viewModel.TakePhotoAndAnalyzeAsync(false); ButtonSearch.Enabled = true; ActivityIsLoading.StopAnimating(); }); }
public async void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath) { ActivityIsLoading.StartAnimating(); string description = await viewModel.GetImageDescription(viewModel.Images[indexPath.Row].ImageLink); var resultAlert = UIAlertController.Create("Image Analysis", description, UIAlertControllerStyle.Alert); resultAlert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(resultAlert, true, null); ActivityIsLoading.StopAnimating(); }
async void HandleButtonSearchTouchUpInside(object sender, EventArgs e) { //Dismiss Keyboard View.EndEditing(true); ButtonSearch.Enabled = false; ActivityIsLoading.StartAnimating(); await viewModel.SearchForImagesAsync(TextFieldQuery.Text); CollectionViewImages.ReloadData(); ButtonSearch.Enabled = true; ActivityIsLoading.StopAnimating(); }
public override void ViewDidLoad() { base.ViewDidLoad(); viewModel = new ImageSearchViewModel(); CollectionViewImages.WeakDataSource = this; ButtonSearch.TouchUpInside += async(sender, args) => { ButtonSearch.Enabled = false; ActivityIsLoading.StartAnimating(); await viewModel.SearchForImagesAsync(TextFieldQuery.Text); CollectionViewImages.ReloadData(); ButtonSearch.Enabled = true; ActivityIsLoading.StopAnimating(); }; }
public override void ViewDidLoad() { base.ViewDidLoad(); viewModel = new ImageSearchViewModel(); CollectionViewImages.WeakDataSource = this; CollectionViewImages.AllowsSelection = true; CollectionViewImages.Delegate = this; ButtonSearch.TouchUpInside += async(sender, e) => { ButtonSearch.Enabled = false; ActivityIsLoading.StartAnimating(); await viewModel.SearchForImagesAsync(TextFieldQuery.Text); CollectionViewImages.ReloadData(); ButtonSearch.Enabled = true; ActivityIsLoading.StopAnimating(); }; var cameraButton = new UIBarButtonItem(UIBarButtonSystemItem.Camera, async(sender, e) => { ActivityIsLoading.StartAnimating(); await viewModel.TakePhotAsync(); ActivityIsLoading.StopAnimating(); }); var pickButton = new UIBarButtonItem(UIBarButtonSystemItem.Organize, async(sender, e) => { ActivityIsLoading.StartAnimating(); await viewModel.TakePhotAsync(false); ActivityIsLoading.StopAnimating(); }); this.NavigationItem.RightBarButtonItems = new UIBarButtonItem[] { cameraButton, pickButton }; }
private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { BeginInvokeOnMainThread(() => { switch (e.PropertyName) { case nameof(viewModel.IsBusy): { ButtonSearch.Enabled = !viewModel.IsBusy; if (viewModel.IsBusy) { ActivityIsLoading.StartAnimating(); } else { ActivityIsLoading.StopAnimating(); } } break; } }); }