summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs')
-rwxr-xr-x[-rw-r--r--]Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs48
1 files changed, 24 insertions, 24 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs
index 7a2f732..84481fc 100644..100755
--- a/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs
@@ -35,6 +35,7 @@ namespace Xamarin.Forms.Platform.Tizen
Page _previousPage = null;
TaskCompletionSource<bool> _currentTaskSource = null;
ToolbarTracker _toolbarTracker = null;
+ IDictionary<Page, NaviItem> _naviItemMap;
Page CurrentPage => Element.CurrentPage;
Page PreviousPage => Element.Navigation.NavigationStack.Count > 1 ? Element.Navigation.NavigationStack[Element.Navigation.NavigationStack.Count - 2] : null;
@@ -67,6 +68,7 @@ namespace Xamarin.Forms.Platform.Tizen
_naviFrame.AnimationFinished += OnAnimationFinished;
SetNativeControl(_naviFrame);
+ _naviItemMap = new Dictionary<Page, NaviItem>();
}
if (_toolbarTracker == null)
@@ -102,7 +104,7 @@ namespace Xamarin.Forms.Platform.Tizen
foreach (Page page in pageController.InternalChildren)
{
- _naviFrame.Push(Platform.GetOrCreateRenderer(page).NativeView, SpanTitle(page.Title));
+ _naviItemMap[page] = _naviFrame.Push(Platform.GetOrCreateRenderer(page).NativeView, SpanTitle(page.Title));
page.PropertyChanged += NavigationBarPropertyChangedHandler;
UpdateHasNavigationBar(page);
@@ -288,24 +290,12 @@ namespace Xamarin.Forms.Platform.Tizen
NaviItem GetNaviItemForPage(Page page)
{
- NaviItem item = null;
-
- if (page != null)
+ NaviItem item;
+ if (_naviItemMap.TryGetValue(page, out item))
{
- IVisualElementRenderer renderer = Platform.GetRenderer(page);
- if (renderer != null)
- {
- EvasObject content = renderer.NativeView;
-
- for (int i = _naviFrame.NavigationStack.Count - 1; i >= 0; --i)
- if (_naviFrame.NavigationStack[i].Content == content)
- {
- item = _naviFrame.NavigationStack[i];
- break;
- }
- }
+ return item;
}
- return item;
+ return null;
}
Native.Button GetToolbarButton(ToolbarButtonPosition position)
@@ -403,16 +393,20 @@ namespace Xamarin.Forms.Platform.Tizen
CompleteCurrentNavigationTask();
}
else
+ {
CurrentNaviItem?.Delete();
+ }
+
+ if (_naviItemMap.ContainsKey(nre.Page))
+ _naviItemMap.Remove(nre.Page);
}
}
void OnPopToRootRequested(object sender, NavigationRequestedEventArgs nre)
{
List<NaviItem> copyOfStack = new List<NaviItem>(_naviFrame.NavigationStack);
- copyOfStack.Reverse();
- NaviItem topItem = copyOfStack.FirstOrDefault();
- NaviItem rootItem = copyOfStack.LastOrDefault();
+ NaviItem rootItem = copyOfStack.FirstOrDefault();
+ NaviItem topItem = copyOfStack.LastOrDefault();
foreach (NaviItem naviItem in copyOfStack)
if (naviItem != rootItem && naviItem != topItem)
@@ -431,13 +425,16 @@ namespace Xamarin.Forms.Platform.Tizen
else
topItem?.Delete();
}
+
+ _naviItemMap.Clear();
+ _naviItemMap[Element.Navigation.NavigationStack.Last()] = rootItem;
}
void OnPushRequested(object sender, NavigationRequestedEventArgs nre)
{
if (nre.Animated || _naviFrame.NavigationStack.Count == 0)
{
- _naviFrame.Push(Platform.GetOrCreateRenderer(nre.Page).NativeView, SpanTitle(nre.Page.Title));
+ _naviItemMap[nre.Page] = _naviFrame.Push(Platform.GetOrCreateRenderer(nre.Page).NativeView, SpanTitle(nre.Page.Title));
_currentTaskSource = new TaskCompletionSource<bool>();
nre.Task = _currentTaskSource.Task;
@@ -446,14 +443,17 @@ namespace Xamarin.Forms.Platform.Tizen
CompleteCurrentNavigationTask();
}
else
- _naviFrame.InsertAfter(_naviFrame.NavigationStack.Last(), Platform.GetOrCreateRenderer(nre.Page).NativeView, SpanTitle(nre.Page.Title));
-
+ {
+ _naviItemMap[nre.Page] = _naviFrame.InsertAfter(_naviFrame.NavigationStack.Last(), Platform.GetOrCreateRenderer(nre.Page).NativeView, SpanTitle(nre.Page.Title));
+ }
UpdateHasNavigationBar(nre.Page);
}
void OnRemovePageRequested(object sender, NavigationRequestedEventArgs nre)
{
GetNaviItemForPage(nre.Page).Delete();
+ if (_naviItemMap.ContainsKey(nre.Page))
+ _naviItemMap.Remove(nre.Page);
}
void OnInsertPageBeforeRequested(object sender, NavigationRequestedEventArgs nre)
@@ -464,7 +464,7 @@ namespace Xamarin.Forms.Platform.Tizen
throw new ArgumentNullException("page");
EvasObject page = Platform.GetOrCreateRenderer(nre.Page).NativeView;
- _naviFrame.InsertBefore(GetNaviItemForPage(nre.BeforePage), page, SpanTitle(nre.Page.Title));
+ _naviItemMap[nre.Page] = _naviFrame.InsertBefore(GetNaviItemForPage(nre.BeforePage), page, SpanTitle(nre.Page.Title));
UpdateHasNavigationBar(nre.Page);
}