Skip to content
Merged
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
25 changes: 24 additions & 1 deletion src/Core/src/Platform/Android/TimePickerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace Microsoft.Maui.Platform
using System;
using Android.Content.Res;

namespace Microsoft.Maui.Platform
{
public static class TimePickerExtensions
{
Expand All @@ -19,5 +22,25 @@ internal static void SetTime(this MauiTimePicker mauiTimePicker, ITimePicker tim

mauiTimePicker.Text = time.ToFormattedString(format);
}

// TODO: Make it public in Net10
internal static void UpdateTextColor(this MauiTimePicker platformTimePicker, ITimePicker timePicker)
{
var textColor = timePicker.TextColor;

if (textColor is not null && PlatformInterop.CreateEditTextColorStateList(platformTimePicker.TextColors, textColor.ToPlatform()) is ColorStateList c)
{
platformTimePicker.SetTextColor(c);
}
else if (OperatingSystem.IsAndroidVersionAtLeast(23) && platformTimePicker.Context?.Theme is Resources.Theme theme)
{
// Restore to default (theme primary text color) instead of passing null
using var ta = theme.ObtainStyledAttributes([Android.Resource.Attribute.TextColorPrimary]);
if (ta.GetColorStateList(0) is ColorStateList cs)
{
platformTimePicker.SetTextColor(cs);
}
}
}
}
}