From 934a6ed20c3deb93918542d1788aa1e2bf1c3c36 Mon Sep 17 00:00:00 2001 From: Omid Mafakher Date: Wed, 11 Sep 2024 22:37:30 +0200 Subject: [PATCH] feat: make navbar optional for modal (#54 #44) --- src/AvaloniaInside.Shell/Page.cs | 4 ++++ src/AvaloniaInside.Shell/ShellView.cs | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/AvaloniaInside.Shell/Page.cs b/src/AvaloniaInside.Shell/Page.cs index ff3523c..682f3d9 100644 --- a/src/AvaloniaInside.Shell/Page.cs +++ b/src/AvaloniaInside.Shell/Page.cs @@ -11,6 +11,7 @@ namespace AvaloniaInside.Shell; [PseudoClasses(":modal")] +[TemplatePart("PART_TabStripPlaceHolder", typeof(ContentPresenter))] public class Page : UserControl, INavigationLifecycle, INavigatorLifecycle, INavigationBarProvider { private ContentPresenter? _navigationBarPlaceHolder; @@ -344,6 +345,9 @@ private void ApplyNavigationBar() if (Shell?.NavigationBarAttachType is not ({ } type and not NavigationBarAttachType.ToShell)) return; + if (IsModal && !Shell.NavigationBarForModal) + return; + if ((type == NavigationBarAttachType.ToLastPage && Chain is HostNavigationChain) || (type == NavigationBarAttachType.ToFirstHostThenPage && Chain.Back is HostNavigationChain)) return; diff --git a/src/AvaloniaInside.Shell/ShellView.cs b/src/AvaloniaInside.Shell/ShellView.cs index 4589c25..3fa6aee 100644 --- a/src/AvaloniaInside.Shell/ShellView.cs +++ b/src/AvaloniaInside.Shell/ShellView.cs @@ -169,6 +169,27 @@ public NavigationBarAttachType NavigationBarAttachType #endregion + #region NavigationBarForModal + + /// + /// Defines the property. + /// + public static readonly StyledProperty NavigationBarForModalProperty = + AvaloniaProperty.Register( + nameof(NavigationBarForModal), + defaultValue: false); + + /// + /// Gets or sets the type of attach navigation bar. + /// + public bool NavigationBarForModal + { + get => GetValue(NavigationBarForModalProperty); + set => SetValue(NavigationBarForModalProperty, value); + } + + #endregion + #endregion #region Safe area properties