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] Fix ToolbarItem font color issue after changing available state. #24065

Merged
merged 8 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 1 addition & 1 deletion src/Controls/src/Core/Toolbar/Toolbar.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void OnToolbarItemPropertyChanged(object? sender, PropertyChangedEventArgs e)
newToolBarItems.AddRange(toolbarItems);

if (sender is ToolbarItem ti)
PlatformView.OnToolbarItemPropertyChanged(e, ti, newToolBarItems, MauiContext!, null, OnToolbarItemPropertyChanged, _currentMenuItems, _currentToolbarItems, UpdateMenuItemIcon);
PlatformView.OnToolbarItemPropertyChanged(e, ti, newToolBarItems, MauiContext!, BarTextColor, OnToolbarItemPropertyChanged, _currentMenuItems, _currentToolbarItems, UpdateMenuItemIcon);
}

void UpdateMenuItemIcon(Context context, IMenuItem menuItem, ToolbarItem toolBarItem)
Expand Down
17 changes: 17 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue10660.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
Shell.TitleColor="Yellow"
x:Class="Maui.Controls.Sample.Issues.Issue10660">

<ContentPage.ToolbarItems>
<ToolbarItem x:Name="ChangeState" AutomationId="ChangeState" Text="Close" Clicked="ChangeStateClicked"/>
</ContentPage.ToolbarItems>

<Grid>
<Label Text="Issue 10660"
HorizontalOptions="Center"
VerticalOptions="Center"/>
</Grid>
</ContentPage>
20 changes: 20 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue10660.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.ObjectModel;
using Microsoft.Maui.Controls;

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 10660, "Inconsistent toolbar text color on interaction", PlatformAffected.Android)]
public partial class Issue10660 : ContentPage
{

public Issue10660()
{
InitializeComponent();
}

private void ChangeStateClicked(object sender, EventArgs e)
{
ChangeState.Text = ChangeState.Text == "Close" ? "Open" : "Close";
}
}
18 changes: 18 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue22937.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
Shell.TitleColor="Red"
x:Class="Maui.Controls.Sample.Issues.Issue22937">

<ContentPage.ToolbarItems>
<ToolbarItem x:Name="ChangeState" AutomationId="ChangeState" Text="Edit" Clicked="ChangeStateClicked"/>
<ToolbarItem x:Name="SaveButton" AutomationId="SaveButton" Text="Save"/>
</ContentPage.ToolbarItems>

<Grid>
<Label Text="Issue 22937"
HorizontalOptions="Center"
VerticalOptions="Center"/>
</Grid>
</ContentPage>
20 changes: 20 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue22937.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.ObjectModel;
using Microsoft.Maui.Controls;

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 22937, "ToolbarItem font color not updating properly after changing the available state at runtime", PlatformAffected.Android)]
public partial class Issue22937 : ContentPage
{

public Issue22937()
{
InitializeComponent();
}

private void ChangeStateClicked(object sender, EventArgs e)
{
SaveButton.IsEnabled = !SaveButton.IsEnabled;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#if !MACCATALYST
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Tests.Issues
{
public class Issue10660 : _IssuesUITest
{
public override string Issue => "[Android] Inconsistent toolbar text color on interaction";

public Issue10660(TestDevice device)
: base(device)
{ }

[Test]
[Category(UITestCategories.ToolbarItem)]
public async void ToolbarTextColorOnInteraction()
{
App.WaitForElement("ChangeState");
App.Tap("ChangeState");

await Task.Delay(100);
PureWeen marked this conversation as resolved.
Show resolved Hide resolved

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

namespace Microsoft.Maui.TestCases.Tests.Tests.Issues
{
public class Issue22937 : _IssuesUITest
{
public override string Issue => "[Android] ToolbarItem font color not updating properly after changing the available state at runtime";

public Issue22937(TestDevice device)
: base(device)
{ }

[Test]
[Category(UITestCategories.ToolbarItem)]
public async void ToolbarItemFontColorDynamicUpdate()
{
App.WaitForElement("ChangeState");
App.Tap("ChangeState");

await Task.Delay(100);

VerifyScreenshot();
}
}
}
#endif
Loading