/// <summary> /// Performs backward navigation from the <paramref name="sourceView"/> with returning a lifecycle-aware view model result. /// </summary> /// <typeparam name="TResult">The type of the source view model result.</typeparam> /// <param name="sourceView">The source navigation view from which navigation is performed from.</param> /// <param name="resultCode">Determines whether the result should be set as successful or canceled.</param> /// <param name="result">The source view model result. Can be <see langword="null"/>.</param> /// <param name="animated">Determines if the transition is to be animated.</param> /// <param name="navigationStrategy"> /// The strategy used for performing navigation. Can be <see langword="null"/>. /// <para>The default is <see cref="BackwardNavigationStrategy.DismissViewController(Action?)"/> if <paramref name="sourceView"/> is presented or /// <see cref="BackwardNavigationStrategy.PopViewController()"/> if <paramref name="sourceView"/> is pushed.</para> /// </param> /// <exception cref="ArgumentNullException"><paramref name="sourceView"/> is <see langword="null"/>.</exception> public void NavigateBack <TResult>( INavigationView <ILifecycleViewModelWithResult <TResult> > sourceView, ResultCode resultCode, TResult?result, bool animated, BackwardNavigationDelegate?navigationStrategy = null) where TResult : Result { if (sourceView == null) { throw new ArgumentNullException(nameof(sourceView)); } sourceView.SetResult(resultCode, result); (navigationStrategy ?? GetBackwardNavigationStrategy(sourceView)).Invoke(sourceView, animated); }
/// <summary> /// Performs backward navigation from the <paramref name="sourceView"/> with a result. /// </summary> /// <typeparam name="TResult">The type of the source view model result.</typeparam> /// <param name="sourceView">The source view from which navigation is performed from.</param> /// <param name="resultCode">Determines whether the result has been set successfully or canceled.</param> /// <param name="result">The source view model result.</param> /// <param name="navigationStrategy">The strategy used for performing navigation. Default is <see cref="BackwardNavigationStrategy.Finish()"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="sourceView"/> is <c>null</c>.</exception> public void NavigateBack <TResult>( [NotNull] INavigationView <IViewModelWithResult <TResult> > sourceView, ResultCode resultCode, [CanBeNull] TResult result, [CanBeNull] BackwardNavigationDelegate navigationStrategy = null) where TResult : Result { if (sourceView == null) { throw new ArgumentNullException(nameof(sourceView)); } var intent = new Intent(); intent.PutResult(result); sourceView.SetResult(resultCode, intent); (navigationStrategy ?? NavigationStrategy.Backward.Finish()).Invoke(sourceView); }
/// <summary> /// Performs backward navigation from the <paramref name="sourceView"/> with returning a lifecycle-aware view model result. /// </summary> /// <typeparam name="TResult">The type of the source view model result.</typeparam> /// <param name="sourceView">The source navigation view from which navigation is performed from.</param> /// <param name="resultCode">Determines whether the result should be set as successful or canceled.</param> /// <param name="result">The source view model result. Can be <see langword="null"/>.</param> /// <param name="navigationStrategy"> /// The strategy used for performing navigation. Can be <see langword="null"/>. /// <para>The default is <see cref="BackwardNavigationStrategy.Finish()"/>.</para> /// </param> /// <exception cref="ArgumentNullException"><paramref name="sourceView"/> is <see langword="null"/>.</exception> public void NavigateBack <TResult>( INavigationView <ILifecycleViewModelWithResult <TResult> > sourceView, ResultCode resultCode, TResult?result, BackwardNavigationDelegate?navigationStrategy = null) where TResult : Result { if (sourceView == null) { throw new ArgumentNullException(nameof(sourceView)); } var resultIntent = new Intent(); resultIntent.PutResult(result); sourceView.SetResult(resultCode, resultIntent); (navigationStrategy ?? NavigationStrategy.Backward.Finish()).Invoke(sourceView); }
/// <summary> /// Performs backward navigation from the <paramref name="sourceView"/> with a result. /// </summary> /// <typeparam name="TResult">The type of the source view model result.</typeparam> /// <param name="sourceView">The source view from which navigation is performed from.</param> /// <param name="resultCode">Determines whether the result has been set successfully or canceled.</param> /// <param name="result">The source view model result.</param> /// <param name="animated">Determines if the transition is to be animated.</param> /// <param name="navigationStrategy"> /// The strategy used for performing navigation. /// Default is <see cref="BackwardNavigationStrategy.DismissViewController(Action)"/> if <paramref name="sourceView"/> is being presented or /// <see cref="BackwardNavigationStrategy.PopViewController()"/> if <paramref name="sourceView"/> is being pushed. /// </param> /// <exception cref="ArgumentNullException"> /// <para><paramref name="sourceView"/> is <c>null</c>.</para> /// <para>-or-</para> /// <para><see cref="UINavigationController"/> returned by <paramref name="sourceView"/> is <c>null</c>.</para> /// </exception> public void NavigateBack <TResult>( [NotNull] INavigationView <IViewModelWithResult <TResult> > sourceView, ResultCode resultCode, [CanBeNull] TResult result, bool animated, [CanBeNull] BackwardNavigationDelegate navigationStrategy = null) where TResult : Result { if (sourceView == null) { throw new ArgumentNullException(nameof(sourceView)); } var navigationController = sourceView.GetNavigationController(); if (navigationController == null) { throw new ArgumentNullException("View's navigation controller is 'null'.", nameof(sourceView)); } sourceView.SetResult(resultCode, result); (navigationStrategy ?? GetBackwardNavigationStrategy(sourceView)).Invoke(navigationController, sourceView, animated); }