Exemplo n.º 1
0
        public ModalPopupTestPage()
        {
            BackgroundColor = Color.White;
            Padding         = new Thickness(20, Device.OnPlatform(20, 0, 0), 20, 20);

            var shadowToggle = new Switch();

            shadowToggle.SetBinding(Switch.IsToggledProperty, "HasShadow");
            shadowToggle.BindingContext = this;

            var shadowInvertedToggle = new Switch();

            shadowInvertedToggle.SetBinding(Switch.IsToggledProperty, "ShadowInverted");
            shadowInvertedToggle.BindingContext = this;

            var cornerRadiusSlider = new Slider
            {
                Maximum       = 40,
                Minimum       = 0,
                HeightRequest = 20,
            };

            cornerRadiusSlider.SetBinding(Slider.ValueProperty, "CornerRadius");
            cornerRadiusSlider.BindingContext = this;

            var paddingSlider = new Slider
            {
                Maximum       = 100,
                Minimum       = 0,
                HeightRequest = 20,
            };

            paddingSlider.SetBinding(Slider.ValueProperty, "PUDPadding");
            paddingSlider.BindingContext = this;

            //var listener = new FormsOrientation.Listener ();

            var hidePopupButton = new Forms9Patch.MaterialButton
            {
                Text            = "DONE",
                BackgroundColor = Color.Blue,
                DarkTheme       = true,
            };
            var showPopupButton = new Forms9Patch.MaterialButton
            {
                Text              = "Show Modal popup",
                BackgroundColor   = Color.Blue,
                DarkTheme         = true,
                WidthRequest      = 150,
                HorizontalOptions = LayoutOptions.Center,
            };

            var cancelOnBackgroundTouchButton = new Forms9Patch.MaterialButton
            {
                Text           = "Cancel on Background touch",
                ToggleBehavior = true,
                IsSelected     = true
            };

            cancelOnBackgroundTouchButton.SetBinding(Forms9Patch.MaterialButton.IsSelectedProperty, "CancelOnBackgroundTouch");
            cancelOnBackgroundTouchButton.BindingContext = this;


            var blackSegment = new Forms9Patch.Segment {
                HtmlText = "<font color=\"#000000\">Black</font>"
            };
            var redSegment = new Forms9Patch.Segment {
                HtmlText = "<font color=\"#FF0000\">Red</font>"
            };
            var greenSegment = new Forms9Patch.Segment {
                HtmlText = "<font color=\"#00FF00\">Green</font>"
            };
            var blueSegment = new Forms9Patch.Segment {
                HtmlText = "<font color=\"#0000FF\">Blue</font>"
            };

            var overlayColorSelector = new Forms9Patch.MaterialSegmentedControl
            {
                Segments =
                {
                    blackSegment,
                    redSegment,
                    greenSegment,
                    blueSegment,
                },
                BackgroundColor = Color.White
            };

            var modal = new Forms9Patch.ModalPopup
            {
                Content = new StackLayout
                {
                    Children =
                    {
                        new Label {
                            Text      = "Hello Modal popup!",
                            TextColor = Color.Black,
                        },
                        new Label {
                            Text = "Padding:", FontSize = 10,
                        },
                        paddingSlider,
                        new Label {
                            Text = "Corner Radius:", FontSize = 10,
                        },
                        cornerRadiusSlider,
                        hidePopupButton,
                        new Label {
                            Text = "PageOverlayColor:", FontSize = 10,
                        },
                        overlayColorSelector
                    },
                    //BackgroundColor = Color.FromRgb(100,100,100),
                    //Padding = 20,
                },
                OutlineRadius   = 4,
                OutlineWidth    = 1,
                OutlineColor    = Color.Black,
                BackgroundColor = Color.Aqua,
                HasShadow       = true,
                HeightRequest   = 200,
                WidthRequest    = 200,
            };

            modal.SetBinding(Forms9Patch.ModalPopup.OutlineRadiusProperty, "CornerRadius");
            modal.SetBinding(Forms9Patch.ModalPopup.OutlineWidthProperty, "OutlineWidth");
            modal.SetBinding(Forms9Patch.ModalPopup.PaddingProperty, "PUPadding");
            modal.SetBinding(Forms9Patch.ModalPopup.HasShadowProperty, "HasShadow");
            modal.SetBinding(Forms9Patch.ModalPopup.ShadowInvertedProperty, "ShadowInverted");
            modal.SetBinding(Forms9Patch.ModalPopup.CancelOnPageOverlayTouchProperty, "CancelOnBackgroundTouch");
            modal.BindingContext = this;


            showPopupButton.Tapped += (sender, e) =>
            {
                modal.IsVisible = true;
            };
            hidePopupButton.Tapped += (sender, e) =>
            {
                modal.IsVisible = false;
                System.Diagnostics.Debug.WriteLine("button " + showPopupButton.Text);
            };

            blackSegment.Selected += (sender, e) => { modal.PageOverlayColor = Color.FromRgba(0, 0, 0, 128); };
            redSegment.Selected   += (sender, e) => { modal.PageOverlayColor = Color.FromRgba(255, 0, 0, 128); };
            greenSegment.Selected += (sender, e) => { modal.PageOverlayColor = Color.FromRgba(0, 255, 0, 128); };
            blueSegment.Selected  += (sender, e) => { modal.PageOverlayColor = Color.FromRgba(0, 0, 255, 128); };

            Detail = new ContentPage
            {
                BackgroundColor = Color.White,
                Title           = "PopupTestPage - Detail",
                Content         = new StackLayout
                {
                    Children =
                    {
                        new Label                 {
                            Text      = "Hello ContentPage",
                            TextColor = Color.Black,
                        },
                        new StackLayout           {
                            Orientation = StackOrientation.Horizontal,
                            Children    =
                            {
                                new StackLayout   {
                                    Children =
                                    {
                                        new Label {
                                            Text = "Has Shadow", FontSize = 10,
                                        },
                                        shadowToggle,
                                    },
                                    HorizontalOptions = LayoutOptions.StartAndExpand,
                                },
                                new StackLayout   {
                                    Children =
                                    {
                                        new Label {
                                            Text = "Inset Shadow", FontSize = 10,
                                        },
                                        shadowInvertedToggle,
                                    },
                                    HorizontalOptions = LayoutOptions.EndAndExpand,
                                }
                            }
                        },
                        cancelOnBackgroundTouchButton,
                        showPopupButton,
                    },
                    Padding = 20,
                },
            };

            Master = new ContentPage
            {
                Title   = "PopupTestPage - Master",
                Content = new Label
                {
                    Text = "Master Page",
                },
                BackgroundColor = Color.Gray,
            };
        }
Exemplo n.º 2
0
        public ModalPopupTestPage()
        {
            BackgroundColor = Color.White;
            Padding         = new Thickness(20, Device.OnPlatform(20, 0, 0), 20, 20);

            var shadowToggle = new Switch();

            shadowToggle.SetBinding(Switch.IsToggledProperty, "HasShadow");
            shadowToggle.BindingContext = this;

            var shadowInvertedToggle = new Switch();

            shadowInvertedToggle.SetBinding(Switch.IsToggledProperty, "ShadowInverted");
            shadowInvertedToggle.BindingContext = this;

            var cornerRadiusSlider = new Slider {
                Maximum       = 40,
                Minimum       = 0,
                HeightRequest = 20,
            };

            cornerRadiusSlider.SetBinding(Slider.ValueProperty, "CornerRadius");
            cornerRadiusSlider.BindingContext = this;

            var paddingSlider = new Slider {
                Maximum       = 100,
                Minimum       = 0,
                HeightRequest = 20,
            };

            paddingSlider.SetBinding(Slider.ValueProperty, "PUDPadding");
            paddingSlider.BindingContext = this;

            //var listener = new FormsOrientation.Listener ();

            var hidePopupButton = new Forms9Patch.MaterialButton {
                Text            = "DONE",
                BackgroundColor = Color.Blue,
                DarkTheme       = true,
            };
            var showPopupButton = new Forms9Patch.MaterialButton {
                Text              = "Show Modal popup",
                BackgroundColor   = Color.Blue,
                DarkTheme         = true,
                WidthRequest      = 150,
                HorizontalOptions = LayoutOptions.Center,
            };

            var modal = new Forms9Patch.ModalPopup {
                Content = new StackLayout {
                    Children =
                    {
                        new Label {
                            Text      = "Hello Modal popup!",
                            TextColor = Color.Black,
                        },
                        new Label {
                            Text = "Padding:", FontSize = 10,
                        },
                        paddingSlider,
                        new Label {
                            Text = "Corner Radius:", FontSize = 10,
                        },
                        cornerRadiusSlider,
                        hidePopupButton,
                    },
                    //BackgroundColor = Color.FromRgb(100,100,100),
                    //Padding = 20,
                },
                OutlineRadius   = 4,
                OutlineWidth    = 1,
                OutlineColor    = Color.Black,
                BackgroundColor = Color.Aqua,
                HasShadow       = true,
            };

            modal.SetBinding(Forms9Patch.ModalPopup.OutlineRadiusProperty, "CornerRadius");
            modal.SetBinding(Forms9Patch.ModalPopup.OutlineWidthProperty, "OutlineWidth");
            modal.SetBinding(Forms9Patch.ModalPopup.PaddingProperty, "PUPadding");
            modal.SetBinding(Forms9Patch.ModalPopup.HasShadowProperty, "HasShadow");
            modal.SetBinding(Forms9Patch.ModalPopup.ShadowInvertedProperty, "ShadowInverted");
            modal.BindingContext = this;


            showPopupButton.Tapped += (sender, e) => {
                modal.IsVisible = true;
            };
            hidePopupButton.Tapped += (sender, e) => {
                modal.IsVisible = false;
                System.Diagnostics.Debug.WriteLine("button " + showPopupButton.Text);
            };

            Detail = new ContentPage {
                BackgroundColor = Color.White,
                Title           = "PopupTestPage - Detail",
                Content         = new StackLayout {
                    Children =
                    {
                        new Label                 {
                            Text      = "Hello ContentPage",
                            TextColor = Color.Black,
                        },
                        new StackLayout           {
                            Orientation = StackOrientation.Horizontal,
                            Children    =
                            {
                                new StackLayout   {
                                    Children =
                                    {
                                        new Label {
                                            Text = "Has Shadow", FontSize = 10,
                                        },
                                        shadowToggle,
                                    },
                                    HorizontalOptions = LayoutOptions.StartAndExpand,
                                },
                                new StackLayout   {
                                    Children =
                                    {
                                        new Label {
                                            Text = "Inset Shadow", FontSize = 10,
                                        },
                                        shadowInvertedToggle,
                                    },
                                    HorizontalOptions = LayoutOptions.EndAndExpand,
                                }
                            }
                        },
                        showPopupButton,
                    },
                    Padding = 20,
                },
            };

            Master = new ContentPage {
                Title   = "PopupTestPage - Master",
                Content = new Label {
                    Text = "Master Page",
                },
                BackgroundColor = Color.Gray,
            };
        }