diff options
author | E.Z. Hart <hartez@users.noreply.github.com> | 2016-05-04 08:22:34 -0600 |
---|---|---|
committer | Rui Marinho <me@ruimarinho.net> | 2016-05-04 15:22:34 +0100 |
commit | a8acdcc11793c9f44098f2cd478d51677d742945 (patch) | |
tree | 811cf1ee2e2ff0baa8674f116b6b5c08590f56cf /Xamarin.Forms.Platform.iOS/Renderers | |
parent | 8d383746caab00dd3ee0b62dc992a2a99c7a6d06 (diff) | |
download | xamarin-forms-a8acdcc11793c9f44098f2cd478d51677d742945.tar.gz xamarin-forms-a8acdcc11793c9f44098f2cd478d51677d742945.tar.bz2 xamarin-forms-a8acdcc11793c9f44098f2cd478d51677d742945.zip |
Add IMasterDetailPageController and update renderers (#146)
Diffstat (limited to 'Xamarin.Forms.Platform.iOS/Renderers')
-rw-r--r-- | Xamarin.Forms.Platform.iOS/Renderers/PhoneMasterDetailRenderer.cs | 8 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.iOS/Renderers/TabletMasterDetailRenderer.cs | 19 |
2 files changed, 16 insertions, 11 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/PhoneMasterDetailRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/PhoneMasterDetailRenderer.cs index dcefbcf6..e4c73521 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/PhoneMasterDetailRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/PhoneMasterDetailRenderer.cs @@ -43,6 +43,8 @@ namespace Xamarin.Forms.Platform.iOS WantsFullScreenLayout = true; } + IMasterDetailPageController MasterDetailPageController => Element as IMasterDetailPageController; + bool Presented { get { return _presented; } @@ -153,7 +155,7 @@ namespace Xamarin.Forms.Platform.iOS public override void WillRotate(UIInterfaceOrientation toInterfaceOrientation, double duration) { - if (!((MasterDetailPage)Element).ShouldShowSplitMode && _presented) + if (!MasterDetailPageController.ShouldShowSplitMode && _presented) Presented = false; base.WillRotate(toInterfaceOrientation, duration); @@ -270,8 +272,8 @@ namespace Xamarin.Forms.Platform.iOS else _detailController.View.Frame = target; - ((MasterDetailPage)Element).MasterBounds = new Rectangle(0, 0, masterFrame.Width, masterFrame.Height); - ((MasterDetailPage)Element).DetailBounds = new Rectangle(0, 0, frame.Width, frame.Height); + MasterDetailPageController.MasterBounds = new Rectangle(0, 0, masterFrame.Width, masterFrame.Height); + MasterDetailPageController.DetailBounds = new Rectangle(0, 0, frame.Width, frame.Height); if (Presented) _clickOffView.Frame = _detailController.View.Frame; diff --git a/Xamarin.Forms.Platform.iOS/Renderers/TabletMasterDetailRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/TabletMasterDetailRenderer.cs index e7c92dfa..e49ed5ae 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/TabletMasterDetailRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/TabletMasterDetailRenderer.cs @@ -64,6 +64,8 @@ namespace Xamarin.Forms.Platform.iOS get { return _masterDetailPage ?? (_masterDetailPage = (MasterDetailPage)Element); } } + IMasterDetailPageController MasterDetailPageController => MasterDetailPage as IMasterDetailPageController; + UIBarButtonItem PresentButton { get { return _innerDelegate == null ? null : _innerDelegate.PresentButton; } @@ -175,10 +177,10 @@ namespace Xamarin.Forms.Platform.iOS var masterBounds = _masterController.View.Frame; if (!masterBounds.IsEmpty) - MasterDetailPage.MasterBounds = new Rectangle(0, 0, masterBounds.Width, masterBounds.Height); + MasterDetailPageController.MasterBounds = new Rectangle(0, 0, masterBounds.Width, masterBounds.Height); if (!detailsBounds.IsEmpty) - MasterDetailPage.DetailBounds = new Rectangle(0, 0, detailsBounds.Width, detailsBounds.Height); + MasterDetailPageController.DetailBounds = new Rectangle(0, 0, detailsBounds.Width, detailsBounds.Height); } public override void ViewDidLoad() @@ -208,16 +210,17 @@ namespace Xamarin.Forms.Platform.iOS { // On IOS8 the MasterViewController ViewAppear/Disappear weren't being called correctly after rotation // We now close the Master by using the new SplitView API, basicly we set it to hidden and right back to the Normal/AutomaticMode - if (!MasterDetailPage.ShouldShowSplitMode && _masterVisible) + if (!MasterDetailPageController.ShouldShowSplitMode && _masterVisible) { - MasterDetailPage.CanChangeIsPresented = true; + MasterDetailPageController.CanChangeIsPresented = true; if (Forms.IsiOS8OrNewer) { PreferredDisplayMode = UISplitViewControllerDisplayMode.PrimaryHidden; PreferredDisplayMode = UISplitViewControllerDisplayMode.Automatic; } } - MasterDetailPage.UpdateMasterBehavior(MasterDetailPage); + + MasterDetailPageController.UpdateMasterBehavior(); MessagingCenter.Send<IVisualElementRenderer>(this, NavigationRenderer.UpdateToolbarButtons); base.WillRotate(toInterfaceOrientation, duration); } @@ -273,14 +276,14 @@ namespace Xamarin.Forms.Platform.iOS void MasterControllerWillAppear(object sender, EventArgs e) { _masterVisible = true; - if (MasterDetailPage.CanChangeIsPresented) + if (MasterDetailPageController.CanChangeIsPresented) ((IElementController)Element).SetValueFromRenderer(MasterDetailPage.IsPresentedProperty, true); } void MasterControllerWillDisappear(object sender, EventArgs e) { _masterVisible = false; - if (MasterDetailPage.CanChangeIsPresented) + if (MasterDetailPageController.CanChangeIsPresented) ((IElementController)Element).SetValueFromRenderer(MasterDetailPage.IsPresentedProperty, false); } @@ -294,7 +297,7 @@ namespace Xamarin.Forms.Platform.iOS void ToggleMaster() { - if (_masterVisible == MasterDetailPage.IsPresented || MasterDetailPage.ShouldShowSplitMode) + if (_masterVisible == MasterDetailPage.IsPresented || MasterDetailPageController.ShouldShowSplitMode) return; PerformButtonSelector(); |