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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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,
					}
				}
			}
	};
}

@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
Copy link
Contributor

Hey there @@kubaflo! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

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
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 platform/iOS 🍎
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iOS] Shell.NavBarIsVisible="False" briefly displays navigation bar and disappears
1 participant