예제 #1
0
        async void SearchBar_SearchButtonPressed(object sender, EventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("search bar searches now...");

            FlickrSearchSearchBar mySearchBar = (FlickrSearchSearchBar)sender;
            var client = new HttpClient();
            var uri    = new Uri(String.Format("https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=a7a0c39eac2e0a720c4d911b13a43197&text={0}&sort=relevance&content_type=7&per_page=200&page=1&format=json&nojsoncallback=1", mySearchBar.Text));
            var json   = await client.GetStringAsync(uri);

            SearchResult result = JsonConvert.DeserializeObject <SearchResult> (json);

            dataSource = new FlickrSearchDataSource(result.photos);
            this.ReloadImageView();
        }
예제 #2
0
        public FlickrSearchMainPage()
        {
            dataSource = new FlickrSearchDataSource();

            backButton = new Button {
                Text          = "<",
                TextColor     = Color.Aqua,
                WidthRequest  = 40,
                HeightRequest = 40,
                IsEnabled     = false
            };
            backButton.Clicked += BackButton_Clicked;

            forwardButton = new Button {
                Text          = ">",
                TextColor     = Color.Aqua,
                WidthRequest  = 40,
                HeightRequest = 40,
                IsEnabled     = false
            };
            forwardButton.Clicked += ForwardButton_Clicked;

            imageView = new ResultDisplayer {
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };
            ReloadImageView();

            searchBar = new FlickrSearchSearchBar {
                Placeholder       = "search term",
                CancelButtonColor = Color.FromHex("d0d0d0")
            };
            searchBar.SearchButtonPressed += SearchBar_SearchButtonPressed;

            var stack = new StackLayout {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
                Orientation       = StackOrientation.Horizontal,
                Children          = { backButton, imageView, forwardButton }
            };

            var absoluteLayout = new AbsoluteLayout();

            absoluteLayout.Children.Add(searchBar, new Point(10, 20));
            absoluteLayout.Children.Add(stack, new Point(5, 90));

            Content = absoluteLayout;
        }