Skip to content

Commit

Permalink
[iOS] Fixes for iOS11 (#1238)
Browse files Browse the repository at this point in the history
* [iOS] Add SafeArea support

* [iOS] Only apply SafeArea on iOS11 or newer

* [iOS] Handle SafeAreaInsets on ViewCell and GroupCell

* [iOS] Set page padding from safe area

* [Controls] Use SafeArea PS

* [iOS] Add platform specific for LargeTiles

* [iOS] Add LargeTitleDisplayMode platform specific for ios11

* [iOS] Fix page size when large title collapses

* [iOS] Add platform specific to expose SafeAreaInsets from iOS11

* [Controls] Large titles iOS specific gallery page

* [iOS] Remove comment code on PS example

* [Controls] Add gallery sample for Safe Area PS

* [iOS] Inside a TabbedPage safe area bottom is handle by UITabViewController

* [Core,iOS]If we are not using safearea set the padding to the default

* [iOS] Revert SafeAreas on navpage

* [iOS] Fix safe area inset for ViewCell

* [iOS] Handle ViewCell margin correctly on iOS11

* [Core,iOS] Rename to UsingSafeArea, use BPKey instead for SafeAreaInsets

* [Core,iOS] Rename to UsingLargeTitles

* [iOS,Core] Rename to PrefersLargeTitles
  • Loading branch information
rmarinho authored and Jason Smith committed Nov 2, 2017
1 parent f026776 commit 0426994
Show file tree
Hide file tree
Showing 18 changed files with 1,244 additions and 8 deletions.
7 changes: 6 additions & 1 deletion Xamarin.Forms.Controls/App.cs
Expand Up @@ -5,6 +5,7 @@
using System.Threading.Tasks;
using Xamarin.Forms.Internals;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;

namespace Xamarin.Forms.Controls
Expand Down Expand Up @@ -47,10 +48,14 @@ public App()

public Page CreateDefaultMainPage()
{
var layout = new StackLayout { BackgroundColor = Color.Red };
layout.Children.Add(new Label { Text ="This is master Page" });
var master = new ContentPage { Title = "Master", Content = layout, BackgroundColor = Color.SkyBlue };
master.On<iOS>().SetUseSafeArea(true);
return new MasterDetailPage
{
AutomationId = DefaultMainPageId,
Master = new ContentPage { Title = "Master", Content = new View { BackgroundColor = Color.Red } },
Master = master,
Detail = CoreGallery.GetMainPage()
};
}
Expand Down
5 changes: 5 additions & 0 deletions Xamarin.Forms.Controls/CoreGallery.cs
Expand Up @@ -11,6 +11,8 @@
using Xamarin.Forms.Controls.GalleryPages;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;

namespace Xamarin.Forms.Controls
{
Expand All @@ -33,6 +35,7 @@ internal class CoreContentPage : ContentPage
{
public CoreContentPage ()
{
On<iOS>().SetUseSafeArea(true);
AutomationId = "ContentPageRoot";
Content = new StackLayout { Children = { new CoreRootView (), new CorePageView (this, NavigationBehavior.PushModalAsync) } };
}
Expand Down Expand Up @@ -80,6 +83,8 @@ public CoreNavigationPage ()
return false;
});

On<iOS>().SetPrefersLargeTitles(true);

Navigation.PushAsync (new CoreRootPage (this));
}
}
Expand Down
@@ -0,0 +1,59 @@
using System;
using System.Windows.Input;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;

namespace Xamarin.Forms.Controls.GalleryPages.PlatformSpecificsGalleries
{
public class LargeTitlesPageiOS : ContentPage
{
public LargeTitlesPageiOS(ICommand restore)
{
Title = "Large Titles";

var offscreenPageLimit = new Label();
var content = new StackLayout
{
VerticalOptions = LayoutOptions.Fill,
HorizontalOptions = LayoutOptions.Fill,
Children =
{
new Button
{
Text = "LargeTitleDisplayMode.Never",
Command = new Command(() => On<iOS>().SetLargeTitleDisplay(LargeTitleDisplayMode.Never))
},
new Button
{
Text = "LargeTitleDisplayMode.Always",
Command = new Command(() => On<iOS>().SetLargeTitleDisplay(LargeTitleDisplayMode.Always))
},
new Button
{
Text = "LargeTitleDisplayMode.Automatic -> next page will have same LargeTitleDisplayMode as this one",
Command = new Command(async () =>{
var page = new ContentPage { Title = "Page Title" };
page.On<iOS>().SetLargeTitleDisplay(LargeTitleDisplayMode.Automatic);
await Navigation.PushAsync(page);
} )
},
new Button
{
Text = "Tooggle UseLargeTitles on Navigation",
Command = new Command( () =>{
var navPage = (Parent as NavigationPage);
navPage.On<iOS>().SetPrefersLargeTitles(!navPage.On<iOS>().PrefersLargeTitles());
} )
},
offscreenPageLimit
}
};

var restoreButton = new Button { Text = "Back To Gallery" };
restoreButton.Clicked += async (sender, args) => await Navigation.PopAsync();
content.Children.Add(restoreButton);

Content = content;
}
}
}

0 comments on commit 0426994

Please sign in to comment.