Skip to content

Fixed Shell.NavBarHasShadow on Android #20188

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 5 commits into from
Feb 28, 2024

Conversation

kubaflo
Copy link
Contributor

@kubaflo kubaflo commented Jan 27, 2024

Description of Change

Fixed Shell.NavBarHasShadow on Android

Issues Fixed

Fixes #19458

Screen.Recording.2024-01-27.at.01.14.23.mov

@kubaflo kubaflo requested a review from a team as a code owner January 27, 2024 00:18
@ghost ghost added the community ✨ Community Contribution label Jan 27, 2024
@ghost
Copy link

ghost commented Jan 27, 2024

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.

@@ -101,6 +101,11 @@ void OnToggleFlyoutBackgroundColor(object sender, EventArgs e)
flyoutBackgroundColor.Background = AppShell.FlyoutBackground;
}

void OnToggleNavBarHasShadow(object sender, EventArgs e)
{
Shell.SetNavBarHasShadow(this, !Shell.GetNavBarHasShadow(this));
Copy link
Contributor

Choose a reason for hiding this comment

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

Updated the Shell sample to easily test the NavBarHasShadow property.

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

[Theory]
[InlineData(true)]
[InlineData(false)]
public async Task CanHideNavBarShadow(bool navBarHasShadow)
Copy link
Contributor

Choose a reason for hiding this comment

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

Added Device Tests.

jsuarezruiz
jsuarezruiz previously approved these changes Feb 21, 2024
@PureWeen
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@@ -561,15 +561,15 @@ void UpdateNavBarHasShadow(Page page)
if (page == null || !_appBar.IsAlive())
return;

// 4 is the default
_appBarElevation = _appBar.Context.ToPixels(4);
Copy link
Member

Choose a reason for hiding this comment

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

The point of the original code was to reduce the amount of calls to _appBar.Context. The original code did a really bad job of it :-)

Maybe something like this? I think this is what the original author was intending.

			if (Shell.GetNavBarHasShadow(page))
			{
				if (_appBarElevation <= 0)
				     _appBarElevation = _appBar.Context.ToPixels(4);

				_appBar.SetElevation(_appBarElevation);
			}
			else
			{
				// 4 is the default
				_appBar.SetElevation(0f);
			}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed, thanks!

@PureWeen
Copy link
Member

Failing tests unrelated

@PureWeen PureWeen merged commit b0c6e45 into dotnet:main Feb 28, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shell.NavBarHasShadow not working correctly on Android
4 participants