Check if Element parent is null before getting the padding insets (#5757)
authorShane Neuville <shane94@hotmail.com>
Mon, 1 Apr 2019 08:53:53 +0000 (02:53 -0600)
committerRui Marinho <me@ruimarinho.net>
Mon, 1 Apr 2019 08:53:53 +0000 (09:53 +0100)
* Check if Element parent is null before getting the padding insets

* - move if up earlier

Xamarin.Forms.Platform.iOS/Renderers/PageRenderer.cs

index a4c9e12..2295f19 100644 (file)
@@ -242,7 +242,8 @@ namespace Xamarin.Forms.Platform.iOS
 
                void UpdateUseSafeArea()
                {
-                       if (!Forms.IsiOS11OrNewer) return;
+                       if (!Forms.IsiOS11OrNewer)
+                               return;
 
                        if (!UsingSafeArea)
                        {
@@ -258,7 +259,14 @@ namespace Xamarin.Forms.Platform.iOS
 
                void UpdateShellInsetPadding()
                {
-                       var setInsets = Shell.GetSetPaddingInsets(Element) || Shell.GetSetPaddingInsets(Element?.Parent);
+                       if (Element == null)
+                               return;
+
+                       var setInsets = Shell.GetSetPaddingInsets(Element);
+
+                       if (!setInsets && Element.Parent != null)
+                               setInsets = Shell.GetSetPaddingInsets(Element.Parent);
+
                        if (setInsets)
                        {
                                nfloat topPadding = 0;