Skip to content

Commit

Permalink
[iOS] Fix reapply of safe insets (xamarin#2719) fixes xamarin#1584
Browse files Browse the repository at this point in the history
  • Loading branch information
rmarinho authored May 28, 2018
1 parent 4df442f commit 4bf2ffe
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Xamarin.Forms.Core/PlatformConfiguration/iOSSpecific/Page.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void SetPreferredStatusBarUpdateAnimation(BindableObject element,
element.SetValue(PreferredStatusBarUpdateAnimationProperty, value);
else if (value == UIStatusBarAnimation.Slide)
element.SetValue(PreferredStatusBarUpdateAnimationProperty, value);
else
else
element.SetValue(PreferredStatusBarUpdateAnimationProperty, value);
}

Expand All @@ -65,6 +65,10 @@ public static IPlatformElementConfiguration<iOS, FormsElement> SetPreferredStatu
{
page.Padding = default(Thickness);
}
else
{
UpdatePadding(GetSafeAreaInsets(page), page);
}
});

public static bool GetUseSafeArea(BindableObject element)
Expand Down Expand Up @@ -114,12 +118,15 @@ public static IPlatformElementConfiguration<iOS, FormsElement> SetLargeTitleDisp
static readonly BindablePropertyKey SafeAreaInsetsPropertyKey = BindableProperty.CreateReadOnly(nameof(SafeAreaInsets), typeof(Thickness), typeof(Page), default(Thickness), propertyChanged: (bindable, oldValue, newValue) =>
{
var page = bindable as Xamarin.Forms.Page;
if (page.On<iOS>().UsingSafeArea())
{
page.Padding = (Thickness)newValue;
}
UpdatePadding((Thickness)newValue, page);
});

static void UpdatePadding(Thickness thickness, FormsElement page)
{
if (page.On<iOS>().UsingSafeArea())
page.Padding = thickness;
}

public static readonly BindableProperty SafeAreaInsetsProperty = SafeAreaInsetsPropertyKey.BindableProperty;

public static Thickness GetSafeAreaInsets(BindableObject element)
Expand Down

0 comments on commit 4bf2ffe

Please sign in to comment.