protected void NavigateBack(Action done = null, BackBehaviour behaviour = BackBehaviour.CloseLastSubView) { Mvvm.Api.Resolver.Resolve <INavigation>().NavigateBack(() => { done?.Invoke(); }, behaviour); }
protected void NavigateBack(IPayload payload, Action done = null, BackBehaviour behaviour = BackBehaviour.CloseLastSubView) { if (CallbackAction == null) { return; } // Set payload id var payloadId = Guid.NewGuid(); // Add payload var payloads = Mvvm.Api.Resolver.Resolve <IPayloads>(); payloads.Add(payloadId, payload); Mvvm.Api.Resolver.Resolve <INavigation>().NavigateBack(CallbackAction, payloadId, () => done?.Invoke(), behaviour); }
public void NavigateBack(Action <Guid> callbackAction, Guid payloadId, Action done = null, BackBehaviour behaviour = BackBehaviour.CloseLastSubView) { _appNavigation.NavigateBack(callbackAction, payloadId, done, behaviour); }
public void NavigateBack(Action done = null, BackBehaviour behaviour = BackBehaviour.CloseLastSubView) { _appNavigation.NavigateBack(done, behaviour); }
public void NavigateBack(Action <Guid> callbackAction, Guid payloadId, Action done = null, BackBehaviour behaviour = BackBehaviour.CloseLastSubView) { NavigateBack(() => { callbackAction.Invoke(payloadId); done?.Invoke(); }, behaviour); }
public void NavigateBack(Action done = null, BackBehaviour behaviour = BackBehaviour.CloseLastSubView) { // Check the navigation controller if (GetNavigationController()?.VisibleViewController == null) { System.Diagnostics.Debug.WriteLine("AppNavigation.NavigateBack: Could not find a navigation controller or a visible VC!"); return; } // Get the current VC var currentVC = GetNavigationController().VisibleViewController as IViewControllerBase; if (currentVC == null) { throw new Exception("The current VC does not implement IViewControllerBase!"); } // Check if we have SubViews int subViewCountThreshold = 0; switch (behaviour) { case BackBehaviour.CloseLastSubView: subViewCountThreshold = 0; break; case BackBehaviour.SkipFromLastSubView: subViewCountThreshold = 1; break; case BackBehaviour.FullViewsOnly: subViewCountThreshold = int.MaxValue; break; } if (SubViewNavigationStack?.Count > subViewCountThreshold) { // Remove the current subview from the stack var subView = SubViewNavigationStack.Pop(); subView?.RemoveFromParentViewController(); subView = null; if (SubViewNavigationStack.Count > 0) { // Subviews left -> Inflate the next one InflateSubView(SubViewNavigationStack.Pop()); done?.Invoke(); return; } RemoveAllSubViews(); done?.Invoke(); return; } // Remove all subviews RemoveAllSubViews(); SubViewNavigationStack?.Clear(); // Dismiss the VC if (currentVC.AsModal) { GetNavigationController()?.DismissViewController(true, () => { done?.Invoke(); }); } else { GetNavigationController()?.PopViewController(true); done?.Invoke(); } }
private void NavigateBackInternal(Action callbackListener, Action done = null, BackBehaviour behaviour = BackBehaviour.CloseLastSubView) { if (GetContext() is AppCompatActivity activity) { int subViewCountThreshold = 0; switch (behaviour) { case BackBehaviour.CloseLastSubView: subViewCountThreshold = 0; break; case BackBehaviour.SkipFromLastSubView: subViewCountThreshold = 1; break; case BackBehaviour.FullViewsOnly: subViewCountThreshold = int.MaxValue; break; } if (activity.SupportFragmentManager?.BackStackEntryCount <= subViewCountThreshold) { callbackListener?.Invoke(); if (CanUseActivityTransitions) { activity.FinishAfterTransition(); } else { activity.Finish(); } } else { try { activity.SupportFragmentManager?.PopBackStackImmediate(); } catch { // swallow exceptions, there's a bug in FragmentManager.java } callbackListener?.Invoke(); } done?.Invoke(); } else { System.Diagnostics.Debug.WriteLine("AppNavigation.NavigateBack: Context is null or not an activity!"); } }
public void NavigateBack(Action done = null, BackBehaviour behaviour = BackBehaviour.CloseLastSubView) { NavigateBackInternal(null, done, behaviour); }