Skip to content
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

[Android] Tabs briefly display wrong background color when navigating between flyout items #24965

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
44fae26
[Android] Tabs briefly display wrong background color when navigating…
KarthikRajaKalaimani Sep 27, 2024
69d6dca
Merge branch 'dotnet:main' into fix-16522
KarthikRajaKalaimani Sep 27, 2024
ec6d044
[Android] Tabs briefly display wrong background color when navigating…
KarthikRajaKalaimani Sep 27, 2024
d4f54ef
Merge branch 'fix-16522' of https://github.com/NanthiniMahalingam/mau…
KarthikRajaKalaimani Sep 27, 2024
2013130
Merge branch 'dotnet:main' into fix-16522
NanthiniMahalingam Oct 3, 2024
bea929b
Remove unwanted casting.
NanthiniMahalingam Oct 3, 2024
ab26c9b
Merge branch 'dotnet:main' into fix-16522
KarthikRajaKalaimani Oct 8, 2024
df6427f
[Android] Tabs briefly display wrong background color when navigating…
KarthikRajaKalaimani Sep 27, 2024
aa50a13
[Android] Tabs briefly display wrong background color when navigating…
KarthikRajaKalaimani Sep 27, 2024
3240bee
Remove unwanted casting.
NanthiniMahalingam Oct 3, 2024
670af0f
Merge branch 'dotnet:main' into fix-16522
KarthikRajaKalaimani Oct 14, 2024
f832659
Merge branch 'fix-16522' of https://github.com/NanthiniMahalingam/mau…
KarthikRajaKalaimani Oct 14, 2024
099302c
Fix for device test failed in android api 23 has committed
KarthikRajaKalaimani Oct 14, 2024
7b41d77
Merge branch 'dotnet:main' into fix-16522
KarthikRajaKalaimani Oct 25, 2024
c813e9d
UI test case added
KarthikRajaKalaimani Nov 4, 2024
91cc6eb
Snapshot for ios added
KarthikRajaKalaimani Nov 4, 2024
64f79c1
Android snapshots committed
KarthikRajaKalaimani Nov 4, 2024
5a33ac9
Snapshot added for windows platform
KarthikRajaKalaimani Nov 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Google.Android.Material.Navigation;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Maui.Controls.Handlers.Compatibility;
using Microsoft.Maui.Graphics;
using AColor = Android.Graphics.Color;
using AView = Android.Views.View;
Expand Down Expand Up @@ -85,7 +86,21 @@ public override AView OnCreateView(LayoutInflater inflater, ViewGroup container,

HookEvents(ShellItem);
SetupMenu();

var appearance = ShellContext.Shell.GetAppearanceForPivot(ShellItem);
if (_bottomView.Background is ColorDrawable background)
{
if (appearance is IShellAppearanceElement appearanceElement)
{
if (appearanceElement.EffectiveTabBarBackgroundColor is not null)
{
background.Color = appearanceElement.EffectiveTabBarBackgroundColor.ToPlatform();
}
else
{
background.Color = ShellRenderer.DefaultBottomNavigationViewBackgroundColor.ToPlatform();
}
}
}
_appearanceTracker = ShellContext.CreateBottomNavViewAppearanceTracker(ShellItem);
_bottomNavigationTracker = new BottomNavigationViewTracker();
((IShellController)ShellContext.Shell).AddAppearanceObserver(this, ShellItem);
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/src/Core/Shell/Shell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,7 @@ internal T GetEffectiveValue<T>(
return defaultValue();
}

ShellAppearance GetAppearanceForPivot(Element pivot)
internal ShellAppearance GetAppearanceForPivot(Element pivot)
{
// this algorithm is pretty simple
// 1) Get the "CurrentPage" by walking down from the pivot
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue16522.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8" ?>
<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue16522"
TabBarBackgroundColor="#0000FF"
>
<FlyoutItem Title="Main">
<Tab Title="Main">
<ShellContent>
<ContentPage Title="Main">
<StackLayout Padding="10">
<Label AutomationId="Label" Text="Welcome to the Main Page!"
FontSize="24"
HorizontalOptions="Center" />
<!-- Add additional UI elements here -->
</StackLayout>
</ContentPage>
</ShellContent>
</Tab>

<Tab Title="Settings">
<ShellContent>
<ContentPage Title="Settings">
<StackLayout Padding="10">
<Label Text="Settings Page"
FontSize="24"
HorizontalOptions="Center" />
<!-- Additional UI for Settings -->
</StackLayout>
</ContentPage>
</ShellContent>
</Tab>
</FlyoutItem>

<FlyoutItem Title="About">
<ShellContent>
<ContentPage Title="About">
<StackLayout Padding="10">
<Label Text="About Page"
FontSize="24"
HorizontalOptions="Center" />
<!-- Additional UI for About -->
</StackLayout>
</ContentPage>
</ShellContent>
</FlyoutItem>
</Shell>
12 changes: 12 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue16522.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Maui.Controls.Sample.Issues
{
[Issue(IssueTracker.Github, 16522, "[Android] Tabs briefly display wrong background color when navigating between flyout items", PlatformAffected.Android)]
public partial class Issue16522 : Shell
{
public Issue16522()
{
InitializeComponent();

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#if !MACCATALYST
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue16522 : _IssuesUITest
{
public Issue16522(TestDevice device) : base(device)
{
}

public override string Issue => "[Android] Tabs briefly display wrong background color when navigating between flyout items";

[Test]
[Category(UITestCategories.Shell)]
public void ShellTabBarBackgroundColor()
{
App.WaitForElement("Label");
VerifyScreenshot();
}
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading