Skip to content

[.Net 10] Shell.SetNavBarVisibilityAnimationEnabled property #29279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 3, 2025

Conversation

kubaflo
Copy link
Contributor

@kubaflo kubaflo commented May 1, 2025

Description of Change

<Tab Shell.NavBarVisibilityAnimationEnabled="True">
    <ShellContent
                    Title="Home"
                    ContentTemplate="{DataTemplate local:MainPage}"
                    Route="MainPage"/>
</Tab>

This PR introduces a new public property: NavBarVisibilityAnimationEnabled

For now, the implementation only applies to iOS. If support for Android/Windows is desired in the future, it can be added separately.

NavBarVisibilityAnimationEnabled is a bool property added to Shell. It controls whether the navigation bar's visibility changes are animated. The default value is true to preserve existing behavior.

Issues Fixed

Fixes #26994

Demo

public MainPage()
{
	InitializeComponent();
	var setHasNavigationBarSwitch = new Switch() { IsToggled = true };
	setHasNavigationBarSwitch.Toggled += (s, e) => Shell.SetNavBarIsVisible(this, e.Value);
	var setNavigationBarHiddenAnimation = new Switch() { IsToggled = true };
	setNavigationBarHiddenAnimation.Toggled += (s, e) => Shell.SetNavBarVisibilityAnimationEnabled(this, e.Value);

	Content = new VerticalStackLayout
	{
		Spacing = 5,
		Children =
			{
				new HorizontalStackLayout
				{
					Children =
					{
						new Label {
							Text = "NavigationPage.SetHasNavigationBar: ",
						},
						setHasNavigationBarSwitch,
					}
				},
				new HorizontalStackLayout
				{
					Children =
					{
						new Label {
							Text = "Page.NavigationBarHiddenAnimation: ",
						},
						setNavigationBarHiddenAnimation,
					}
				}
			}
	};
}

Screen.Recording.2025-06-24.at.19.49.27.mov

@Copilot Copilot AI review requested due to automatic review settings May 1, 2025 14:04
@kubaflo kubaflo requested a review from a team as a code owner May 1, 2025 14:04
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label May 1, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new public property, NavBarVisibilityAnimationEnabled, to control whether navigation bar visibility changes are animated (currently only implemented for iOS). The key changes include:

  • Adding the new attached BindableProperty and its getter/setter in Shell.cs with XML documentation.
  • Updating PublicAPI.Unshipped.txt files across multiple platforms to include the new public API.
  • Propagating the property in property propagation logic and using its value in iOS renderers to drive the navigation bar animation behavior.

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Controls/src/Core/Shell/Shell.cs Added NavBarVisibilityAnimationEnabled property and related API methods.
src/Controls/src/Core/PublicAPI/... Updated public API definitions to reflect the newly added property.
src/Controls/src/Core/Internals/PropertyPropagationExtensions.cs Propagated the new property from parent elements.
src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellSectionRenderer.cs Updated navigation bar hide logic to use the new animation flag.
src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellItemRenderer.cs Incorporated the new property in updating navigation bar appearance.
Files not reviewed (1)
  • src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt: Language not supported

@@ -68,6 +68,12 @@ static void OnBackButonBehaviorPropertyChanged(BindableObject bindable, object o
public static readonly BindableProperty NavBarIsVisibleProperty =
BindableProperty.CreateAttached("NavBarIsVisible", typeof(bool), typeof(Shell), true, propertyChanged: OnNavBarIsVisibleChanged);

/// <summary>
/// Determines if the navigation bar visibility change should be animated.
Copy link
Preview

Copilot AI May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider updating the documentation to explicitly mention that the current implementation of NavBarVisibilityAnimationEnabled only applies to iOS and does not affect Android/Windows behavior.

Suggested change
/// Determines if the navigation bar visibility change should be animated.
/// Determines if the navigation bar visibility change should be animated.
/// This property is currently only applicable on iOS and does not affect behavior on Android or Windows.

Copilot uses AI. Check for mistakes.

/// </summary>
/// <param name="obj">The object that retrieves the animation setting.</param>
/// <returns><see langword="true"/> if the animation is enabled; otherwise, <see langword="false"/>.</returns>
public static bool GetNavBarVisibilityAnimationEnabled(BindableObject obj) => (bool)obj.GetValue(NavBarVisibilityAnimationEnabledProperty);
Copy link
Preview

Copilot AI May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that tests in TestCases.HostApp and TestCases.Shared.Tests cover the behavior of the new NavBarVisibilityAnimationEnabled property, especially to verify that navigation bar animations behave as expected on iOS.

Copilot uses AI. Check for mistakes.

@kubaflo kubaflo self-assigned this May 1, 2025
@kubaflo kubaflo added platform/ios area-controls-shell Shell Navigation, Routes, Tabs, Flyout labels May 1, 2025
@PureWeen PureWeen added this to the .NET 10.0-preview6 milestone Jun 5, 2025
@PureWeen PureWeen added the p/0 Work that we can't release without label Jun 19, 2025
@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing Jun 19, 2025
@kubaflo kubaflo changed the base branch from main to net10.0 June 19, 2025 22:48
@kubaflo kubaflo force-pushed the NavBarVisibilityAnimationEnabled branch from c1c55ed to 1af5ea3 Compare June 19, 2025 22:57
@PureWeen
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@@ -775,8 +774,6 @@ public override void WillShowViewController(UINavigationController navigationCon
navBarVisible = Shell.GetNavBarIsVisible(element);
}

navigationController.SetNavigationBarHidden(!navBarVisible, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure this doesn't break anything? What's the advantage of removing this line?

@kubaflo kubaflo force-pushed the NavBarVisibilityAnimationEnabled branch 2 times, most recently from 4f8521a to 2fde877 Compare June 24, 2025 23:09
@PureWeen
Copy link
Member

/rebase

@github-actions github-actions bot force-pushed the NavBarVisibilityAnimationEnabled branch from 2fde877 to f4bcacd Compare June 26, 2025 14:18
@PureWeen
Copy link
Member

/rebase

@PureWeen
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working great!

@github-project-automation github-project-automation bot moved this from Ready To Review to Approved in MAUI SDK Ongoing Jul 3, 2025
@PureWeen PureWeen merged commit fe7e229 into dotnet:net10.0 Jul 3, 2025
88 of 129 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout community ✨ Community Contribution p/0 Work that we can't release without platform/ios
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[iOS] Shell.NavBarIsVisible="False" briefly displays navigation bar and disappears
2 participants