diff options
author | E.Z. Hart <hartez@users.noreply.github.com> | 2016-06-16 09:45:09 -0600 |
---|---|---|
committer | Rui Marinho <me@ruimarinho.net> | 2016-06-16 16:45:09 +0100 |
commit | d5be2f0144ca810fdfbf59808d526c26fe86017e (patch) | |
tree | 3ad7e4465307cd6d633184e05d85eb3a4df59e01 /Xamarin.Forms.Core/NavigationPage.cs | |
parent | 04f7bd296ee67af9189ecd7fdfbd2808ca16ce9a (diff) | |
download | xamarin-forms-d5be2f0144ca810fdfbf59808d526c26fe86017e.tar.gz xamarin-forms-d5be2f0144ca810fdfbf59808d526c26fe86017e.tar.bz2 xamarin-forms-d5be2f0144ca810fdfbf59808d526c26fe86017e.zip |
Prep Page for removal of InternalsVisibleTo (#150)
Diffstat (limited to 'Xamarin.Forms.Core/NavigationPage.cs')
-rw-r--r-- | Xamarin.Forms.Core/NavigationPage.cs | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/Xamarin.Forms.Core/NavigationPage.cs b/Xamarin.Forms.Core/NavigationPage.cs index b13fc6c4..85c8ac89 100644 --- a/Xamarin.Forms.Core/NavigationPage.cs +++ b/Xamarin.Forms.Core/NavigationPage.cs @@ -63,8 +63,8 @@ namespace Xamarin.Forms { get { - var result = new Stack<Page>(InternalChildren.Count); - foreach (Page page in InternalChildren) + var result = new Stack<Page>(PageController.InternalChildren.Count); + foreach (Page page in PageController.InternalChildren) result.Push(page); return result; } @@ -72,9 +72,11 @@ namespace Xamarin.Forms int INavigationPageController.StackDepth { - get { return InternalChildren.Count; } + get { return PageController.InternalChildren.Count; } } + IPageController PageController => this as IPageController; + public Page CurrentPage { get { return (Page)GetValue(CurrentPageProperty); } @@ -231,7 +233,7 @@ namespace Xamarin.Forms return null; } - var page = (Page)InternalChildren.Last(); + var page = (Page)PageController.InternalChildren.Last(); var args = new NavigationRequestedEventArgs(page, animated); @@ -249,9 +251,9 @@ namespace Xamarin.Forms if (!removed && !fast) return CurrentPage; - InternalChildren.Remove(page); + PageController.InternalChildren.Remove(page); - CurrentPage = (Page)InternalChildren.Last(); + CurrentPage = (Page)PageController.InternalChildren.Last(); if (Popped != null) Popped(this, args); @@ -293,18 +295,17 @@ namespace Xamarin.Forms void InsertPageBefore(Page page, Page before) { - if (!InternalChildren.Contains(before)) + if (!PageController.InternalChildren.Contains(before)) throw new ArgumentException("before must be a child of the NavigationPage", "before"); - if (InternalChildren.Contains(page)) + if (PageController.InternalChildren.Contains(page)) throw new ArgumentException("Cannot insert page which is already in the navigation stack"); EventHandler<NavigationRequestedEventArgs> handler = InsertPageBeforeRequestedInternal; - if (handler != null) - handler(this, new NavigationRequestedEventArgs(page, before, false)); + handler?.Invoke(this, new NavigationRequestedEventArgs(page, before, false)); - int index = InternalChildren.IndexOf(before); - InternalChildren.Insert(index, page); + int index = PageController.InternalChildren.IndexOf(before); + PageController.InternalChildren.Insert(index, page); // Shouldn't be required? if (Width > 0 && Height > 0) @@ -316,9 +317,9 @@ namespace Xamarin.Forms if (((INavigationPageController)this).StackDepth == 1) return; - var root = (Page)InternalChildren.First(); + var root = (Page)PageController.InternalChildren.First(); - InternalChildren.ToArray().Where(c => c != root).ForEach(c => InternalChildren.Remove(c)); + PageController.InternalChildren.ToArray().Where(c => c != root).ForEach(c => PageController.InternalChildren.Remove(c)); CurrentPage = root; @@ -339,7 +340,7 @@ namespace Xamarin.Forms async Task PushAsyncInner(Page page, bool animated) { - if (InternalChildren.Contains(page)) + if (PageController.InternalChildren.Contains(page)) return; PushPage(page); @@ -361,7 +362,7 @@ namespace Xamarin.Forms void PushPage(Page page) { - InternalChildren.Add(page); + PageController.InternalChildren.Add(page); CurrentPage = page; } @@ -377,14 +378,14 @@ namespace Xamarin.Forms return; } - if (!InternalChildren.Contains(page)) + if (!PageController.InternalChildren.Contains(page)) throw new ArgumentException("Page to remove must be contained on this Navigation Page"); EventHandler<NavigationRequestedEventArgs> handler = RemovePageRequestedInternal; if (handler != null) handler(this, new NavigationRequestedEventArgs(page, true)); - InternalChildren.Remove(page); + PageController.InternalChildren.Remove(page); } void SafePop() @@ -403,7 +404,7 @@ namespace Xamarin.Forms public NavigationImpl(NavigationPage owner) { Owner = owner; - _castingList = new Lazy<ReadOnlyCastingList<Page, Element>>(() => new ReadOnlyCastingList<Page, Element>(Owner.InternalChildren)); + _castingList = new Lazy<ReadOnlyCastingList<Page, Element>>(() => new ReadOnlyCastingList<Page, Element>(((IPageController)Owner).InternalChildren)); } NavigationPage Owner { get; } |