Beispiel #1
0
        public async Task FlyoutHeaderAdaptsToMinimumHeight()
        {
            await RunShellTest(shell =>
            {
                var layout = new VerticalStackLayout()
                {
                    new Label()
                    {
                        Text = "Flyout Header"
                    }
                };

                layout.MinimumHeightRequest = 30;

                shell.FlyoutHeader         = layout;
                shell.FlyoutHeaderBehavior = FlyoutHeaderBehavior.CollapseOnScroll;
            },
                               async (shell, handler) =>
            {
                await OpenFlyout(handler);
                var flyoutFrame = GetFrameRelativeToFlyout(handler, shell.FlyoutHeader as IView);

                AssertionExtensions.CloseEnough(flyoutFrame.Height, 30);
            });
        }
Beispiel #2
0
        public async Task FlyoutHeaderContentAndFooterAllMeasureCorrectly(FlyoutHeaderBehavior behavior)
        {
            await RunShellTest(shell =>
            {
                shell.FlyoutHeader = new Label()
                {
                    Text = "Flyout Header"
                };
                shell.FlyoutFooter = new Label()
                {
                    Text = "Flyout Footer"
                };
                shell.FlyoutContent = new VerticalStackLayout()
                {
                    new Label()
                    {
                        Text = "Flyout Content"
                    }
                };
                shell.FlyoutHeaderBehavior = behavior;
            },
                               async (shell, handler) =>
            {
                await OpenFlyout(handler);

                var flyoutFrame  = GetFlyoutFrame(handler);
                var headerFrame  = GetFrameRelativeToFlyout(handler, (IView)shell.FlyoutHeader);
                var contentFrame = GetFrameRelativeToFlyout(handler, (IView)shell.FlyoutContent);
                var footerFrame  = GetFrameRelativeToFlyout(handler, (IView)shell.FlyoutFooter);

                // validate header position
                AssertionExtensions.CloseEnough(0, headerFrame.X, message: "Header X");
                AssertionExtensions.CloseEnough(0, headerFrame.Y, message: "Header Y");
                AssertionExtensions.CloseEnough(flyoutFrame.Width, headerFrame.Width, message: "Header Width");

                // validate content position
                AssertionExtensions.CloseEnough(0, contentFrame.X, message: "Content X");
                AssertionExtensions.CloseEnough(headerFrame.Height, contentFrame.Y, epsilon: 0.5, message: "Content Y");
                AssertionExtensions.CloseEnough(flyoutFrame.Width, contentFrame.Width, message: "Content Width");

                // validate footer position
                AssertionExtensions.CloseEnough(0, footerFrame.X, message: "Footer X");
                AssertionExtensions.CloseEnough(headerFrame.Height + contentFrame.Height, footerFrame.Y, epsilon: 0.5, message: "Footer Y");
                AssertionExtensions.CloseEnough(flyoutFrame.Width, footerFrame.Width, message: "Footer Width");

                //All three views should measure to the height of the flyout
                AssertionExtensions.CloseEnough(headerFrame.Height + contentFrame.Height + footerFrame.Height, flyoutFrame.Height, epsilon: 0.5, message: "Total Height");
            });
        }
Beispiel #3
0
        public async Task FlyoutHeaderCollapsesOnScroll()
        {
            await RunShellTest(shell =>
            {
                Enumerable.Range(0, 100)
                .ForEach(i =>
                {
                    shell.FlyoutHeaderBehavior = FlyoutHeaderBehavior.CollapseOnScroll;
                    shell.Items.Add(new FlyoutItem()
                    {
                        Title = $"FlyoutItem {i}", Items = { new ContentPage() }
                    });
                });

                var layout = new VerticalStackLayout()
                {
                    new Label()
                    {
                        Text = "Header Content"
                    }
                };

                layout.HeightRequest = 250;

                shell.FlyoutHeader = new ScrollView()
                {
                    MinimumHeightRequest = 100,
                    Content = layout
                };
            },
                               async (shell, handler) =>
            {
                await OpenFlyout(handler);
                await Task.Delay(10);

                var initialBox = (shell.FlyoutHeader as IView).GetBoundingBox();

                AssertionExtensions.CloseEnough(250, initialBox.Height, 0.3);

                await ScrollFlyoutToBottom(handler);

                var scrolledBox = (shell.FlyoutHeader as IView).GetBoundingBox();
                AssertionExtensions.CloseEnough(100, scrolledBox.Height, 0.3);
            });
        }
Beispiel #4
0
        public async Task FlyoutContentSetsCorrectBottomPaddingWhenMinHeightIsSetForFlyoutHeader()
        {
            await RunShellTest(shell =>
            {
                var layout = new VerticalStackLayout()
                {
                    new Label()
                    {
                        Text = "Flyout Header"
                    }
                };

                layout.MinimumHeightRequest = 30;
                shell.FlyoutHeader          = layout;

                shell.FlyoutFooter = new Label()
                {
                    Text = "Flyout Footer"
                };
                shell.FlyoutContent = new VerticalStackLayout()
                {
                    new Label()
                    {
                        Text = "Flyout Content"
                    }
                };
                shell.FlyoutHeaderBehavior = FlyoutHeaderBehavior.CollapseOnScroll;
            },
                               async (shell, handler) =>
            {
                await OpenFlyout(handler);

                var headerFrame  = GetFrameRelativeToFlyout(handler, (IView)shell.FlyoutHeader);
                var contentFrame = GetFrameRelativeToFlyout(handler, (IView)shell.FlyoutContent);
                var footerFrame  = GetFrameRelativeToFlyout(handler, (IView)shell.FlyoutFooter);

                // validate footer position
                AssertionExtensions.CloseEnough(footerFrame.Y, headerFrame.Height + contentFrame.Height);
            });
        }
Beispiel #5
0
        public async Task FlyoutHeaderMinimumHeight(FlyoutHeaderBehavior behavior)
        {
            await RunShellTest(shell =>
            {
                var layout = new VerticalStackLayout()
                {
                    new Label()
                    {
                        Text = "Flyout Header"
                    }
                };

                shell.FlyoutHeader         = layout;
                shell.FlyoutHeaderBehavior = behavior;
            },
                               async (shell, handler) =>
            {
                await OpenFlyout(handler);
                var flyoutFrame = GetFrameRelativeToFlyout(handler, shell.FlyoutHeader as IView);


                if (behavior == FlyoutHeaderBehavior.CollapseOnScroll)
                {
                    // 56 was pulled from the ActionBar height on Android
                    // and then just used across all three platforms for
                    // the min height when using collapse on scroll
                    AssertionExtensions.CloseEnough(56, flyoutFrame.Height);
                }
                else
                {
                    AssertionExtensions.AssertWithMessage(() =>
                                                          Assert.True(flyoutFrame.Height < 56),
                                                          $"Expected < 56 Actual: {flyoutFrame.Height}"
                                                          );
                }
            });
        }