From cb79bd5d1ee36d1cbf56274ce6674955ba8beec7 Mon Sep 17 00:00:00 2001 From: "Anton Polkanov [SSW]" <123032112+AntPolkanov@users.noreply.github.com> Date: Wed, 1 May 2024 14:41:32 +1000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Mobile=20|=20Prevent=20app=20cra?= =?UTF-8?q?sh=20when=20BackgroundColor=20is=20null=20(#883)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MobileUI/MauiProgram.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/MobileUI/MauiProgram.cs b/src/MobileUI/MauiProgram.cs index 970d09c44..c21e1062a 100644 --- a/src/MobileUI/MauiProgram.cs +++ b/src/MobileUI/MauiProgram.cs @@ -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);