Пример #1
0
        async void OnAlertYesNoClicked(DataImg element, Frame tmp)
        {
            bool   answer = false;
            string str    = "Do you really want to remove this image from your favorites?";
            string str1   = "Do you really want to remove this album from your favorites?";


            answer = await DisplayAlert("Question?", (element.is_album == true)?str1 : str, "Yes", "No");

            if (answer == true)
            {
                if (element.is_album == true)
                {
                    GalleryPage.test2(element.id);
                }
                else
                {
                    GalleryPage.test(element.id);
                }
                _mainStackLayout.Children.Remove(tmp);
            }
        }
Пример #2
0
        public void AddImageInGallery(string url, string id, ImageApi img)
        {
            string tmp = null;

            if (img.favorite == true)
            {
                tmp = "heart.png";
            }
            else
            {
                tmp = "like.png";
            }
            ImageButton butonn = new ImageButton
            {
                Margin            = 10,
                Source            = tmp,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.Center,
                BackgroundColor   = Color.FromHex("000000"),
                HeightRequest     = 40
            };
            Label vue = new Label
            {
                Text = img.views != null?img.views.ToString() : "0",
                           Margin            = new Thickness(0, 0, 60, 0),
                           HorizontalOptions = LayoutOptions.EndAndExpand,
                           VerticalOptions   = LayoutOptions.Center,
            };
            Image imgvue = new Image
            {
                Margin            = 10,
                Source            = "eyes.png",
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Center,
                BackgroundColor   = Color.FromHex("000000"),
                HeightRequest     = 40
            };
            Grid grid_buttom = new Grid
            {
                Children =
                {
                    butonn,
                    vue,
                    imgvue
                }
            };

            butonn.Clicked += delegate {
                img.favorite = !img.favorite;
                if (img.favorite == true)
                {
                    butonn.Source = "heart.png";
                }
                else
                {
                    butonn.Source = "like.png";
                }
                GalleryPage.test(id);
            };
            BoxView line = new BoxView()
            {
                Color         = Color.FromHex("101010"),
                WidthRequest  = 100,
                HeightRequest = 2,
                Margin        = new Thickness(0, 5, 0, 0)
            };
            Label dess = new Label
            {
                Text     = (img.description != null) ? img.description.ToString() : "",
                FontSize = 18,
                Margin   = new Thickness(5, 0, 0, 0)
            };

            _stackLayout.Children.Add(new Frame
            {
                BackgroundColor = Color.FromHex("000000"),
                Content         = new StackLayout
                {
                    Children =
                    {
                        new Image {
                            Source        = url,
                            HeightRequest = 300
                        },
                        grid_buttom,
                        line,
                        dess
                    }
                },
            });
        }