Skip to content

Commit 706161e

Browse files
kubafloPureWeen
authored andcommitted
Fixed the picker title's color (#23075)
* Fixed the picker title's color (#16737) * Added a test category * Enable test on all platforms
1 parent 736b1e6 commit 706161e

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="Maui.Controls.Sample.Issues.Issue16737">
5+
<VerticalStackLayout>
6+
<Label AutomationId="label"
7+
Text="Picker test"/>
8+
<Picker
9+
Title="Select something"
10+
TitleColor="Red"
11+
TextColor="Red">
12+
<Picker.ItemsSource>
13+
<x:Array Type="{x:Type x:String}">
14+
<x:String>Maui</x:String>
15+
<x:String>Maui</x:String>
16+
</x:Array>
17+
</Picker.ItemsSource>
18+
</Picker>
19+
</VerticalStackLayout>
20+
</ContentPage>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Microsoft.Maui.Controls;
2+
using Microsoft.Maui.Controls.Xaml;
3+
4+
namespace Maui.Controls.Sample.Issues
5+
{
6+
[XamlCompilation(XamlCompilationOptions.Compile)]
7+
[Issue(IssueTracker.Github, 16737, "Title colour on Android Picker, initially appears grey", PlatformAffected.All)]
8+
public partial class Issue16737 : ContentPage
9+
{
10+
public Issue16737()
11+
{
12+
InitializeComponent();
13+
}
14+
}
15+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using NUnit.Framework;
2+
using NUnit.Framework.Legacy;
3+
using UITest.Appium;
4+
using UITest.Core;
5+
6+
namespace Microsoft.Maui.TestCases.Tests.Issues
7+
{
8+
public class Issue16737 : _IssuesUITest
9+
{
10+
public Issue16737(TestDevice device) : base(device) { }
11+
12+
public override string Issue => "Title colour on Android Picker, initially appears grey";
13+
14+
[Test]
15+
[Category(UITestCategories.Picker)]
16+
public void Issue16737Test()
17+
{
18+
_ = App.WaitForElement("label");
19+
20+
// The test passes if the title's color is red
21+
VerifyScreenshot();
22+
}
23+
}
24+
}

src/Core/src/Platform/Android/PickerExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public static void UpdateTitleColor(this MauiPicker platformPicker, IPicker pick
1616
{
1717
if (PlatformInterop.CreateEditTextColorStateList(platformPicker.TextColors, titleColor.ToPlatform()) is ColorStateList c)
1818
platformPicker.SetHintTextColor(c);
19+
else if(picker.TextColor == picker.TitleColor)
20+
platformPicker.SetHintTextColor(titleColor.ToPlatform());
1921
}
2022
}
2123

0 commit comments

Comments
 (0)