summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2017-01-23 19:42:38 (GMT)
committerGitHub <noreply@github.com>2017-01-23 19:42:38 (GMT)
commit2c56d6211db41a1b105ac466630dca783d5bd1ec (patch)
tree4e476c7c527198e2a5c0048bf8f44e48bb6658da /Xamarin.Forms.Core
parentc468302e9da38354d0b8d3004ac44f39b65f5fbf (diff)
downloadxamarin-forms-2c56d6211db41a1b105ac466630dca783d5bd1ec.zip
xamarin-forms-2c56d6211db41a1b105ac466630dca783d5bd1ec.tar.gz
xamarin-forms-2c56d6211db41a1b105ac466630dca783d5bd1ec.tar.bz2
Reduce overhead of pushing existing navigation stack (#672)
* Make StackCopy less awkward * Clean up comment * Update docs * Update docs * Replace SecondToLast with an arbitrarily deep Peek method * Update docs * Handle negative depths in Peek()
Diffstat (limited to 'Xamarin.Forms.Core')
-rw-r--r--Xamarin.Forms.Core/INavigationPageController.cs4
-rw-r--r--Xamarin.Forms.Core/NavigationPage.cs19
2 files changed, 16 insertions, 7 deletions
diff --git a/Xamarin.Forms.Core/INavigationPageController.cs b/Xamarin.Forms.Core/INavigationPageController.cs
index eddbe75..d4ae867 100644
--- a/Xamarin.Forms.Core/INavigationPageController.cs
+++ b/Xamarin.Forms.Core/INavigationPageController.cs
@@ -7,7 +7,9 @@ namespace Xamarin.Forms
{
public interface INavigationPageController
{
- Stack<Page> StackCopy { get; }
+ Page Peek(int depth);
+
+ IEnumerable<Page> Pages { get; }
int StackDepth { get; }
diff --git a/Xamarin.Forms.Core/NavigationPage.cs b/Xamarin.Forms.Core/NavigationPage.cs
index 7b393b9..fdafec0 100644
--- a/Xamarin.Forms.Core/NavigationPage.cs
+++ b/Xamarin.Forms.Core/NavigationPage.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using Xamarin.Forms.Internals;
@@ -61,17 +62,23 @@ namespace Xamarin.Forms
internal Task CurrentNavigationTask { get; set; }
- Stack<Page> INavigationPageController.StackCopy
+ Page INavigationPageController.Peek(int depth)
{
- get
+ if (depth < 0)
{
- var result = new Stack<Page>(PageController.InternalChildren.Count);
- foreach (Page page in PageController.InternalChildren)
- result.Push(page);
- return result;
+ return null;
}
+
+ if (PageController.InternalChildren.Count <= depth)
+ {
+ return null;
+ }
+
+ return (Page)PageController.InternalChildren[PageController.InternalChildren.Count - depth - 1];
}
+ IEnumerable<Page> INavigationPageController.Pages => PageController.InternalChildren.Cast<Page>();
+
int INavigationPageController.StackDepth
{
get { return PageController.InternalChildren.Count; }