Пример #1
0
        public async void GetImages()
        {
            var json = await WebsiteCaller.ExecuteCall("https://continents-6124.restdb.io/rest/gallery");

            dynamic         response = JArray.Parse(json);
            List <ImageUrl> result   = response.ToObject <List <ImageUrl> >();

            var grid = new Grid {
                VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, RowSpacing = 5
            };

            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });

            for (int i = 0; i < (result.Count + 1) / 2; i++)
            {
                grid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(200, GridUnitType.Absolute)
                });
            }

            for (int i = 0; i < result.Count; i++)
            {
                grid.Children.Add(new Image {
                    Source = result[i].Url, Aspect = Aspect.AspectFill, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand
                }, 0, i);
            }

            sLayout.Children.Add(grid);
        }
Пример #2
0
        public async void LoadArticles()
        {
            var json = await WebsiteCaller.ExecuteCall("https://continents-6124.restdb.io/rest/news-articles");

            dynamic response = JArray.Parse(json);
            var     result   = response.ToObject <List <Article> >();

            foreach (Article article in result)
            {
                sLayout.Children.Add(new NewsView
                {
                    ImageUrl = article.ImageUrl,
                    InfoText = article.Body,
                    Title    = article.Title,
                    Date     = "Written on " + article.Date.ToString("D")
                });
            }
        }