Skip to content

Commit

Permalink
Fixed the picker title's color (dotnet#16737)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubaflo committed Nov 21, 2024
1 parent 083ffa8 commit 9060823
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issues16737.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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"
x:Class="Maui.Controls.Sample.Issues.Issue16737">
<VerticalStackLayout>
<Label Text="Picker test"/>
<Picker
AutomationId="picker"
Title="Select something"
TitleColor="Red"
TextColor="Red">
<Picker.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Maui</x:String>
<x:String>Maui</x:String>
</x:Array>
</Picker.ItemsSource>
</Picker>
</VerticalStackLayout>
</ContentPage>
15 changes: 15 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issues16737.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Xaml;

namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 16737, "Title colour on Android Picker, initially appears grey", PlatformAffected.All)]
public partial class Issue16737 : ContentPage
{
public Issue16737()
{
InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#if ANDROID
using NUnit.Framework;
using NUnit.Framework.Legacy;
using UITest.Appium;
using UITest.Core;

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

public override string Issue => "Title colour on Android Picker, initially appears grey";

[Test]
public void Issue16737Test()
{
_ = App.WaitForElement("picker");

// The test passes if the title's color is red
VerifyScreenshot();
}
}
}
#endif
2 changes: 2 additions & 0 deletions src/Core/src/Platform/Android/PickerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public static void UpdateTitleColor(this MauiPicker platformPicker, IPicker pick
{
if (PlatformInterop.CreateEditTextColorStateList(platformPicker.TextColors, titleColor.ToPlatform()) is ColorStateList c)
platformPicker.SetHintTextColor(c);
else if(picker.TextColor == picker.TitleColor)
platformPicker.SetHintTextColor(titleColor.ToPlatform());
}
}

Expand Down

0 comments on commit 9060823

Please sign in to comment.