コード例 #1
0
        protected virtual void UpdateFlyoutHeader()
        {
            _ = Element ?? throw new InvalidOperationException($"{nameof(Element)} should have been set by base class.");
            _ = MauiContext ?? throw new InvalidOperationException($"{nameof(MauiContext)} should have been set by base class.");

            if (_headerView != null)
            {
                _headerView.MeasureInvalidated -= OnHeaderSizeChanged;
                _headerView = null;
            }

            _headerView     = (Element as IShellController).FlyoutHeader;
            _headerBehavior = Element.FlyoutHeaderBehavior;

            BuildMenu();

            if (_headerView != null)
            {
                if (HeaderOnMenu)
                {
                    _navigationView.Header = null;
                }
                else
                {
                    _navigationView.Header          = _headerView.ToPlatform(MauiContext);
                    _headerView.MeasureInvalidated += OnHeaderSizeChanged;
                }
            }
            else
            {
                _navigationView.Header = null;
            }
        }
コード例 #2
0
 public static Shell FlyoutHeader(this Shell shell, object header, DataTemplate template,
                                  FlyoutHeaderBehavior behavior = Xamarin.Forms.FlyoutHeaderBehavior.Default)
 {
     shell.FlyoutHeader         = header;
     shell.FlyoutHeaderTemplate = template;
     shell.FlyoutHeaderBehavior = behavior;
     return(shell);
 }
コード例 #3
0
            internal void SetFlyoutHeaderBehavior(FlyoutHeaderBehavior flyoutHeaderBehavior)
            {
                if (_flyoutHeaderBehavior == flyoutHeaderBehavior)
                {
                    return;
                }

                _flyoutHeaderBehavior = flyoutHeaderBehavior;
                UpdateMinimumHeight();
            }
コード例 #4
0
ファイル: ShellFlyoutTests.cs プロジェクト: Glepooek/maui
        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");
            });
        }
コード例 #5
0
ファイル: ShellFlyoutTests.cs プロジェクト: Glepooek/maui
        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}"
                                                          );
                }
            });
        }
コード例 #6
0
 public static T FlyoutHeaderBehavior <T>(this T shell, FlyoutHeaderBehavior flyoutHeaderBehavior) where T : IRxShell
 {
     shell.FlyoutHeaderBehavior = flyoutHeaderBehavior;
     return(shell);
 }
コード例 #7
0
 public static Shell FlyoutHeaderBehavior(this Shell shell, FlyoutHeaderBehavior behavior)
 {
     shell.FlyoutHeaderBehavior = behavior;
     return(shell);
 }