async Task PushModalInternal(Page modal, bool animated) { TaskCompletionSource <bool> tcs = null; if (CurrentModalNavigationTask != null && !CurrentModalNavigationTask.IsCompleted) { var previousTask = CurrentModalNavigationTask; tcs = new TaskCompletionSource <bool>(); CurrentModalNavigationTask = tcs.Task; await previousTask; } var after = _internalNaviframe.NavigationStack.LastOrDefault(); NaviItem pushed = null; if (animated || after == null) { pushed = _internalNaviframe.Push(Platform.GetOrCreateRenderer(modal).NativeView, modal.Title); } else { pushed = _internalNaviframe.InsertAfter(after, Platform.GetOrCreateRenderer(modal).NativeView, modal.Title); } pushed.TitleBarVisible = false; bool shouldWait = animated && after != null; await WaitForCompletion(shouldWait, tcs); }
void OnPushRequested(object sender, NavigationRequestedEventArgs nre) { if (nre.Animated || _naviFrame.NavigationStack.Count == 0) { _naviItemMap[nre.Page] = _naviFrame.Push(Platform.GetOrCreateRenderer(nre.Page).NativeView, SpanTitle(nre.Page.Title)); _currentTaskSource = new TaskCompletionSource <bool>(); nre.Task = _currentTaskSource.Task; // There is no TransitionFinished (AnimationFinished) event after the first Push if (_naviFrame.NavigationStack.Count == 1) { CompleteCurrentNavigationTask(); } } else { _naviItemMap[nre.Page] = _naviFrame.InsertAfter(_naviFrame.NavigationStack.Last(), Platform.GetOrCreateRenderer(nre.Page).NativeView, SpanTitle(nre.Page.Title)); } UpdateHasNavigationBar(nre.Page); }
EvasObject CreatePage(Window parent) { Table table = new Table(parent); table.Geometry = square; table.Show(); Label label = new Label(parent) { Text = string.Format("<span color=#000000 font_size=15>{0} Page</span>", _sequence++), WeightX = 1, AlignmentX = -1, BackgroundColor = Color.Black, Geometry = new Rect(square.X, square.Y, square.Width, square.Height / 9) }; Button push = new Button(parent) { Text = "<span color=#000000 font_size=15>Push</span>", WeightX = 1, AlignmentX = -1, BackgroundColor = Color.Black, Geometry = new Rect(square.X, square.Y + square.Height / 9, square.Width / 2, square.Height / 9) }; Button pop = new Button(parent) { Text = "<span color=#000000 font_size=15>pop</span>", WeightX = 1, AlignmentX = -1, BackgroundColor = Color.Black, Geometry = new Rect(square.X + square.Width / 2, square.Y + square.Height / 9, square.Width / 2, square.Height / 9) }; Button insertBeforeTop = new Button(parent) { Text = "<span color=#000000 font_size=15>insertBeforeTop</span>", WeightX = 1, AlignmentX = -1, BackgroundColor = Color.Black, Geometry = new Rect(square.X, square.Y + square.Height / 9 * 2, square.Width / 2, square.Height / 9) }; Button insertAfterTop = new Button(parent) { Text = "<span color=#000000 font_size=15>insertAfterTop</span>", WeightX = 1, AlignmentX = -1, BackgroundColor = Color.Black, Geometry = new Rect(square.X + square.Width / 2, square.Y + square.Height / 9 * 2, square.Width / 2, square.Height / 9) }; Button removeTop = new Button(parent) { Text = "<span color=#000000 font_size=15>removeTop</span>", WeightX = 1, AlignmentX = -1, BackgroundColor = Color.Black, Geometry = new Rect(square.X, square.Y + square.Height / 9 * 3, square.Width, square.Height / 9) }; Button barChange = new Button(parent) { Text = "<span color=#000000 font_size=15>TitleBarColor Change</span>", WeightX = 1, AlignmentX = -1, BackgroundColor = Color.Black, Geometry = new Rect(square.X, square.Y + square.Height / 9 * 4, square.Width / 2, square.Height / 9) }; Button barColorDefault = new Button(parent) { Text = "<span color=#000000 font_size=15>TitleBarColor - Default</span>", WeightX = 1, AlignmentX = -1, BackgroundColor = Color.Black, Geometry = new Rect(square.X + square.Width / 2, square.Y + square.Height / 9 * 4, square.Width / 2, square.Height / 9) }; label.Show(); push.Show(); pop.Show(); insertBeforeTop.Show(); insertAfterTop.Show(); removeTop.Show(); barChange.Show(); barColorDefault.Show(); push.Clicked += (s, e) => { _navi.Push(CreatePage(parent), string.Format("{0} Page", _sequence - 1)); }; pop.Clicked += (s, e) => { var item = _navi.NavigationStack.LastOrDefault(); int nativePointer = (int)(IntPtr)(item.Content); Console.WriteLine("----- Before Call _navi.Pop() {0:x} ", nativePointer); _navi.Pop(); Console.WriteLine("----- After Call _navi.Pop() {0:x} ", nativePointer); }; insertBeforeTop.Clicked += (s, e) => { _navi.InsertBefore(_navi.NavigationStack.LastOrDefault(), CreatePage(parent), string.Format("{0} Page", _sequence - 1)); }; insertAfterTop.Clicked += (s, e) => { _navi.InsertAfter(_navi.NavigationStack.LastOrDefault(), CreatePage(parent), string.Format("{0} Page", _sequence - 1)); }; removeTop.Clicked += (s, e) => { var item = _navi.NavigationStack.LastOrDefault(); int nativePointer = (int)(IntPtr)(item.Content); Console.WriteLine("----- Before Call NaviItem.Delete() {0:x} ", nativePointer); item.Delete(); Console.WriteLine("----- After Call NaviItem.Delete() {0:x} ", nativePointer); }; Random rand = new Random(DateTime.Now.Millisecond); barChange.Clicked += (s, e) => { int currentIndex = _navi.NavigationStack.Count - 1; if (currentIndex >= 0) { _navi.NavigationStack[currentIndex].TitleBarBackgroundColor = Color.FromHex(string.Format("#{0:X8}", rand.Next())); } }; barColorDefault.Clicked += (s, e) => { int currentIndex = _navi.NavigationStack.Count - 1; if (currentIndex >= 0) { _navi.NavigationStack[currentIndex].TitleBarBackgroundColor = Color.Default; } }; table.Pack(label, 0, 0, 1, 1); table.Pack(push, 0, 1, 1, 1); table.Pack(pop, 1, 1, 1, 1); table.Pack(insertBeforeTop, 0, 2, 1, 1); table.Pack(insertAfterTop, 1, 2, 1, 1); table.Pack(removeTop, 0, 3, 1, 1); table.Pack(barChange, 0, 4, 1, 1); table.Pack(barColorDefault, 1, 4, 1, 1); return(table); }
EvasObject CreatePage(Window parent) { Box box = new Box(parent); box.Show(); Label label = new Label(parent) { Text = string.Format("{0} Page", _sequence++), WeightX = 1, AlignmentX = -1, }; Button push = new Button(parent) { Text = "Push", WeightX = 1, AlignmentX = -1, }; Button pop = new Button(parent) { Text = "pop", WeightX = 1, AlignmentX = -1, }; Button insertBeforeTop = new Button(parent) { Text = "insertBeforeTop", WeightX = 1, AlignmentX = -1, }; Button insertAfterTop = new Button(parent) { Text = "insertAfterTop", WeightX = 1, AlignmentX = -1, }; Button removeTop = new Button(parent) { Text = "removeTop", WeightX = 1, AlignmentX = -1, }; Button barChange = new Button(parent) { Text = "TitleBarColor Change", WeightX = 1, AlignmentX = -1, }; Button barColorDefault = new Button(parent) { Text = "TitleBarColor - Default", WeightX = 1, AlignmentX = -1, }; label.Show(); push.Show(); pop.Show(); insertBeforeTop.Show(); insertAfterTop.Show(); removeTop.Show(); barChange.Show(); barColorDefault.Show(); push.Clicked += (s, e) => { _navi.Push(CreatePage(parent), string.Format("{0} Page", _sequence - 1)); }; pop.Clicked += (s, e) => { var item = _navi.NavigationStack.LastOrDefault(); int nativePointer = (int)(IntPtr)(item.Content); Console.WriteLine("----- Before Call _navi.Pop() {0:x} ", nativePointer); _navi.Pop(); Console.WriteLine("----- After Call _navi.Pop() {0:x} ", nativePointer); }; insertBeforeTop.Clicked += (s, e) => { _navi.InsertBefore(_navi.NavigationStack.LastOrDefault(), CreatePage(parent), string.Format("{0} Page", _sequence - 1)); }; insertAfterTop.Clicked += (s, e) => { _navi.InsertAfter(_navi.NavigationStack.LastOrDefault(), CreatePage(parent), string.Format("{0} Page", _sequence - 1)); }; removeTop.Clicked += (s, e) => { var item = _navi.NavigationStack.LastOrDefault(); int nativePointer = (int)(IntPtr)(item.Content); Console.WriteLine("----- Before Call NaviItem.Delete() {0:x} ", nativePointer); item.Delete(); Console.WriteLine("----- After Call NaviItem.Delete() {0:x} ", nativePointer); }; Random rand = new Random(DateTime.Now.Millisecond); barChange.Clicked += (s, e) => { int currentIndex = _navi.NavigationStack.Count - 1; if (currentIndex >= 0) { _navi.NavigationStack[currentIndex].TitleBarBackgroundColor = Color.FromHex(string.Format("#{0:X8}", rand.Next())); } }; barColorDefault.Clicked += (s, e) => { int currentIndex = _navi.NavigationStack.Count - 1; if (currentIndex >= 0) { _navi.NavigationStack[currentIndex].TitleBarBackgroundColor = Color.Default; } }; box.PackEnd(label); box.PackEnd(push); box.PackEnd(pop); box.PackEnd(insertBeforeTop); box.PackEnd(insertAfterTop); box.PackEnd(removeTop); box.PackEnd(barChange); box.PackEnd(barColorDefault); return(box); }