コード例 #1
0
        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();
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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);
            });
        }
コード例 #4
0
        public async void FillImageCells()
        {
            viewModel = new ImageSearchViewModel();
            CollectionViewImages.WeakDataSource = this;


            ActivityIsLoading.StartAnimating();

            await viewModel.SearchForImagesAsync(_query);

            CollectionViewImages.ReloadData();

            ActivityIsLoading.StopAnimating();
        }
コード例 #5
0
        void SetupCamera()
        {
            NavigationItem.RightBarButtonItem = new UIBarButtonItem(
                UIBarButtonSystemItem.Camera, async delegate
            {
                ButtonSearch.Enabled = false;
                ActivityIsLoading.StartAnimating();

                await viewModel.TakePhotoAndAnalyzeAsync(false);

                ButtonSearch.Enabled = true;
                ActivityIsLoading.StopAnimating();
            });
        }
コード例 #6
0
        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();
        }
コード例 #7
0
        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();
        }
コード例 #8
0
        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();
            };
        }
コード例 #9
0
        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 };
        }
コード例 #10
0
 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;
         }
     });
 }