Skip to content

Commit

Permalink
feat: make navbar optional for modal (#54 #44)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmidID authored Sep 11, 2024
1 parent e6d7e11 commit 934a6ed
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/AvaloniaInside.Shell/Page.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace AvaloniaInside.Shell;

[PseudoClasses(":modal")]
[TemplatePart("PART_TabStripPlaceHolder", typeof(ContentPresenter))]
public class Page : UserControl, INavigationLifecycle, INavigatorLifecycle, INavigationBarProvider
{
private ContentPresenter? _navigationBarPlaceHolder;
Expand Down Expand Up @@ -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;
Expand Down
21 changes: 21 additions & 0 deletions src/AvaloniaInside.Shell/ShellView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,27 @@ public NavigationBarAttachType NavigationBarAttachType

#endregion

#region NavigationBarForModal

/// <summary>
/// Defines the <see cref="NavigationBarAttachTypeProperty"/> property.
/// </summary>
public static readonly StyledProperty<bool> NavigationBarForModalProperty =
AvaloniaProperty.Register<ShellView, bool>(
nameof(NavigationBarForModal),
defaultValue: false);

/// <summary>
/// Gets or sets the type of attach navigation bar.
/// </summary>
public bool NavigationBarForModal
{
get => GetValue(NavigationBarForModalProperty);
set => SetValue(NavigationBarForModalProperty, value);
}

#endregion

#endregion

#region Safe area properties
Expand Down

0 comments on commit 934a6ed

Please sign in to comment.