/// <summary> /// Performs forward navigation from the <paramref name="sourceView"/> to the <paramref name="targetView"/>. /// </summary> /// <typeparam name="TTargetView">The type of the target view.</typeparam> /// <param name="sourceView">The source view from which navigation is performed from.</param> /// <param name="targetView">The target view for navigation.</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="ForwardNavigationStrategy.PresentViewController(Action)"/> if <paramref name="targetView"/> is <see cref="UINavigationController"/> or /// <see cref="ForwardNavigationStrategy.PushViewController()"/> if <paramref name="targetView"/> is <see cref="UIViewController"/>. /// </param> /// <exception cref="ArgumentNullException"> /// <para><paramref name="sourceView"/> or <paramref name="targetView"/> 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 Navigate <TTargetView>( [NotNull] INavigationView <IViewModel> sourceView, [NotNull] TTargetView targetView, bool animated, [CanBeNull] ForwardNavigationDelegate navigationStrategy = null) where TTargetView : UIViewController { if (sourceView == null) { throw new ArgumentNullException(nameof(sourceView)); } if (targetView == null) { throw new ArgumentNullException(nameof(targetView)); } var navigationController = sourceView.GetNavigationController(); if (navigationController == null) { throw new ArgumentNullException("View's navigation controller is 'null'.", nameof(sourceView)); } (navigationStrategy ?? GetForwardNavigationStrategy(targetView)).Invoke(navigationController, targetView, animated); }
public static void NavigateForResult <TActivity, TParameters, TResult>( [NotNull] this NavigationServiceBase navigationService, [NotNull] IAndroidView <IViewModelWithResultHandler> fromView, [CanBeNull] TParameters parameters, [CanBeNull] ForwardNavigationDelegate navigationStrategy = null) where TActivity : Activity, IActivityView <IViewModelWithParameters <TParameters> >, IActivityView <IViewModelWithResult <TResult> > where TParameters : ViewModelParametersBase where TResult : ViewModelResultBase { if (navigationService == null) { throw new ArgumentNullException(nameof(navigationService)); } if (fromView == null) { throw new ArgumentNullException(nameof(fromView)); } var activity = fromView.GetActivity(); var targetActivityType = typeof(TActivity); var intent = new Intent(activity, targetActivityType); intent.PutViewModelParameters(parameters); var requestCode = RequestCode.Get <TResult>(activity, targetActivityType); (navigationStrategy ?? NavigationStrategy.Forward.Default()).Invoke(fromView, requestCode, intent); }
/// <summary> /// Performs forward navigation from the <paramref name="sourceView"/> to the <paramref name="targetView"/> with receiving a result when it finished. /// </summary> /// <typeparam name="TTargetView">The type of the target view.</typeparam> /// <typeparam name="TResult">The type of the target view model result.</typeparam> /// <param name="sourceView">The source view from which navigation is performed from.</param> /// <param name="targetView">The target view for navigation.</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="ForwardNavigationStrategy.PresentViewController(Action)"/> if <paramref name="targetView"/> is <see cref="UINavigationController"/> or /// <see cref="ForwardNavigationStrategy.PushViewController()"/> if <paramref name="targetView"/> is <see cref="UIViewController"/>. /// </param> /// <exception cref="ArgumentNullException"> /// <para><paramref name="sourceView"/> or <paramref name="targetView"/> 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 NavigateForResult <TTargetView, TResult>( [NotNull] INavigationView <IViewModelWithResultHandler> sourceView, [NotNull] TTargetView targetView, bool animated, [CanBeNull] ForwardNavigationDelegate navigationStrategy = null) where TTargetView : UIViewController, INavigationView <IViewModelWithResult <TResult> > where TResult : Result { if (sourceView == null) { throw new ArgumentNullException(nameof(sourceView)); } if (targetView == null) { throw new ArgumentNullException(nameof(targetView)); } var navigationController = sourceView.GetNavigationController(); if (navigationController == null) { throw new ArgumentNullException("View's navigation controller is 'null'.", nameof(sourceView)); } targetView.ResultSetWeakSubscribe(sourceView.HandleResult); (navigationStrategy ?? GetForwardNavigationStrategy(targetView)).Invoke(navigationController, targetView, animated); }
public static void NavigateForResult <TViewController, TResult>( [NotNull] this NavigationServiceBase navigationService, [NotNull] IIosView <IViewModelWithResultHandler> fromView, [NotNull] TViewController toView, bool animated, [CanBeNull] ForwardNavigationDelegate navigationStrategy = null) where TViewController : UIViewController, IIosView <IViewModelWithResult <TResult> > where TResult : ViewModelResultBase { if (navigationService == null) { throw new ArgumentNullException(nameof(navigationService)); } if (fromView == null) { throw new ArgumentNullException(nameof(fromView)); } if (toView == null) { throw new ArgumentNullException(nameof(toView)); } toView.ResultSetWeakSubscribe(fromView.HandleResult); var navigationController = fromView.GetNavigationController(); (navigationStrategy ?? NavigationStrategy.Forward.Default()).Invoke(navigationController, toView, animated); }
public static void Navigate <TViewController>( [NotNull] this NavigationServiceBase navigationService, [NotNull] IIosView fromView, [NotNull] TViewController toView, bool animated, [CanBeNull] ForwardNavigationDelegate navigationStrategy = null) where TViewController : UIViewController { if (navigationService == null) { throw new ArgumentNullException(nameof(navigationService)); } if (fromView == null) { throw new ArgumentNullException(nameof(fromView)); } if (toView == null) { throw new ArgumentNullException(nameof(toView)); } var navigationController = fromView.GetNavigationController(); (navigationStrategy ?? NavigationStrategy.Forward.Default()).Invoke(navigationController, toView, animated); }
/// <summary> /// Performs forward navigation from the <paramref name="sourceView"/> to the target one. /// </summary> /// <param name="sourceView">The source view from which navigation is performed from.</param> /// <param name="targetViewIntent">The description of the target view.</param> /// <param name="navigationStrategy">The strategy used for performing navigation. Default is <see cref="ForwardNavigationStrategy.StartActivity(Android.OS.Bundle)"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="sourceView"/> or <paramref name="targetViewIntent"/> is <c>null</c>.</exception> public void Navigate( [NotNull] INavigationView <IViewModel> sourceView, [NotNull] Intent targetViewIntent, [CanBeNull] ForwardNavigationDelegate navigationStrategy = null) { if (sourceView == null) { throw new ArgumentNullException(nameof(sourceView)); } if (targetViewIntent == null) { throw new ArgumentNullException(nameof(targetViewIntent)); } (navigationStrategy ?? NavigationStrategy.Forward.StartActivity()).Invoke(sourceView, targetViewIntent); }
public static void Navigate <TActivity>( [NotNull] this NavigationServiceBase navigationService, [NotNull] IAndroidView fromView, [CanBeNull] ForwardNavigationDelegate navigationStrategy = null) where TActivity : Activity, IActivityView <IViewModelWithoutParameters> { if (navigationService == null) { throw new ArgumentNullException(nameof(navigationService)); } if (fromView == null) { throw new ArgumentNullException(nameof(fromView)); } var activity = fromView.GetActivity(); var targetActivityType = typeof(TActivity); var intent = new Intent(activity, targetActivityType); (navigationStrategy ?? NavigationStrategy.Forward.Default()).Invoke(fromView, null, intent); }
/// <summary> /// Performs forward navigation from the <paramref name="sourceView"/> to the target one. /// </summary> /// <typeparam name="TTargetView">The type of the target view.</typeparam> /// <param name="sourceView">The source view from which navigation is performed from.</param> /// <param name="navigationStrategy">The strategy used for performing navigation. Default is <see cref="ForwardNavigationStrategy.StartActivity(Android.OS.Bundle)"/>.</param> /// <exception cref="ArgumentNullException"> /// <para><paramref name="sourceView"/> is <c>null</c>.</para> /// <para>-or-</para> /// <para><see cref="Android.Support.V4.App.FragmentActivity"/> returned by <paramref name="sourceView"/> is <c>null</c>.</para> /// </exception> public void Navigate <TTargetView>( [NotNull] INavigationView <IViewModel> sourceView, [CanBeNull] ForwardNavigationDelegate navigationStrategy = null) where TTargetView : Android.Support.V4.App.FragmentActivity, IView <IViewModel> { if (sourceView == null) { throw new ArgumentNullException(nameof(sourceView)); } var context = sourceView.GetActivity(); if (context == null) { throw new ArgumentNullException("View's activity is 'null'.", nameof(sourceView)); } var intent = new Intent(context, typeof(TTargetView)); (navigationStrategy ?? NavigationStrategy.Forward.StartActivity()).Invoke(sourceView, intent); }
public static void Navigate( [NotNull] this NavigationServiceBase navigationService, [NotNull] IAndroidView fromView, [NotNull] Type toViewType, [CanBeNull] ForwardNavigationDelegate navigationStrategy = null) { if (navigationService == null) { throw new ArgumentNullException(nameof(navigationService)); } if (fromView == null) { throw new ArgumentNullException(nameof(fromView)); } if (toViewType == null) { throw new ArgumentNullException(nameof(toViewType)); } var activity = fromView.GetActivity(); var intent = new Intent(activity, toViewType); (navigationStrategy ?? NavigationStrategy.Forward.Default()).Invoke(fromView, null, intent); }