Skip to content

Commit

Permalink
🐛 Mobile | Prevent app crash when BackgroundColor is null (#883)
Browse files Browse the repository at this point in the history
AntPolkanov authored May 1, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent dbca6ed commit cb79bd5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/MobileUI/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -107,10 +107,17 @@ public static MauiApp CreateMauiApp()
{
handler.PlatformView.BackgroundTintList = Android.Content.Res.ColorStateList.ValueOf(Colors.Transparent.ToPlatform());
});

Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping(nameof(Entry), (handler, entry) =>
{
// color in the underline while preserving the background color
handler.PlatformView.BackgroundTintList = Android.Content.Res.ColorStateList.ValueOf(((Entry)entry).BackgroundColor.ToPlatform());
var e = (Entry)entry;
if (e?.BackgroundColor == null)
{
return;
}

handler.PlatformView.BackgroundTintList = Android.Content.Res.ColorStateList.ValueOf(e.BackgroundColor.ToPlatform());
});
#endif

@@ -119,6 +126,7 @@ public static MauiApp CreateMauiApp()
{
handler.PlatformView.TintColor = UIKit.UIColor.FromRGB(204,65,65);
});

Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping(nameof(Entry), (handler, editor) =>
{
handler.PlatformView.TintColor = UIKit.UIColor.FromRGB(204,65,65);

0 comments on commit cb79bd5

Please sign in to comment.