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 all 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
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.
29 changes: 29 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue10660.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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"
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues"
Shell.TitleColor="Red"
x:Class="Maui.Controls.Sample.Issues.Issue10660">

<Shell.ToolbarItems>
<ToolbarItem x:Name="StateButton" Text="Close"/>
</Shell.ToolbarItems>

<ShellContent Title="Home page"
Route="MainPage">
<ShellContent.ContentTemplate>
<DataTemplate>
<ContentPage>
<StackLayout>
<Button Text="Change Text"
AutomationId="ChangeText"
Clicked="ChangeTextClicked"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage>
</DataTemplate>
</ShellContent.ContentTemplate>
</ShellContent>
</Shell>

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 : Shell
{

public Issue10660()
{
InitializeComponent();
}

private void ChangeTextClicked(object sender, EventArgs e)
{
StateButton.Text = StateButton.Text == "Close" ? "Open" : "Close";
}
}
29 changes: 29 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue22937.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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"
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues"
Shell.TitleColor="Red"
x:Class="Maui.Controls.Sample.Issues.Issue22937">

<Shell.ToolbarItems>
<ToolbarItem x:Name="EditButton" Text="Edit"/>
<ToolbarItem x:Name="SaveButton" Text="Save"/>
</Shell.ToolbarItems>

<ShellContent Title="Home page"
Route="MainPage">
<ShellContent.ContentTemplate>
<DataTemplate>
<ContentPage>
<StackLayout>
<Button Text="Change State"
AutomationId="ChangeState"
Clicked="ChangeStateClicked"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage>
</DataTemplate>
</ShellContent.ContentTemplate>
</ShellContent>
</Shell>
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 : Shell
{

public Issue22937()
{
InitializeComponent();
}

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

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

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

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

VerifyScreenshot();
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#if ANDROID || WINDOWS
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

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

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

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

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