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
(cherry picked from commit cb79bd5)
  • Loading branch information
AntPolkanov committed May 1, 2024
1 parent f0215c0 commit 4d29736
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
Expand Up @@ -115,10 +115,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

Expand All @@ -127,6 +134,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);
Expand Down

0 comments on commit 4d29736

Please sign in to comment.