Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        internal static IIosView <IViewModel> FindParentViewWithModel([NotNull] this UIViewController parent)
        {
            IIosView <IViewModel> parentView = null;
            var parentViewController         = parent;

            while (parentView == null && parentViewController != null)
            {
                parentView           = parentViewController as IIosView <IViewModel>;
                parentViewController = parentViewController.ParentViewController;
            }

            return(parentView);
        }
Пример #4
0
        public static void RemoveChild(this IIosView parent, Widget control)
        {
            var parentViewController = parent.Controller;

            if (parentViewController != null)
            {
                // wire up view controllers, if both have one
                var childController = control.GetViewController(false);
                if (childController != null)
                {
                    childController.RemoveFromParentViewController();
                }
            }

            control.GetContainerView().RemoveFromSuperview();
        }
Пример #5
0
        public static void AddChild(this IIosView parent, Widget control)
        {
            var parentViewController = parent.Controller;

            if (parentViewController != null)
            {
                // wire up view controllers, if both have one
                var childController = control.GetViewController(false);
                if (childController != null)
                {
                    parentViewController.AddChildViewController(childController);
                }
            }

            parent.ContentControl.AddSubview(control.GetContainerView());
        }
        public static IDisposable ResultSetWeakSubscribe(
            [NotNull] this IIosView <IViewModel> iosView,
            [NotNull] EventHandler <ViewModelResultSetEventArgs> resultSetHandler)
        {
            if (iosView == null)
            {
                throw new ArgumentNullException(nameof(iosView));
            }
            if (resultSetHandler == null)
            {
                throw new ArgumentNullException(nameof(resultSetHandler));
            }

            return(new WeakEventSubscription <IIosView <IViewModel>, ViewModelResultSetEventArgs>(
                       iosView,
                       (eventSource, eventHandler) => eventSource.NotNull().ResultSet += eventHandler,
                       (eventSource, eventHandler) => eventSource.NotNull().ResultSet -= eventHandler,
                       resultSetHandler));
        }
Пример #7
0
        public static UINavigationController GetNavigationController([NotNull] this IIosView view)
        {
            if (view == null)
            {
                throw new System.ArgumentNullException(nameof(view));
            }

            UINavigationController parentNavigationControllerOrSelf = null;

            if (view is UINavigationController navigationController)
            {
                parentNavigationControllerOrSelf = navigationController;
            }
            else if (view is UIViewController viewController)
            {
                parentNavigationControllerOrSelf = viewController.NavigationController;
            }

            return(parentNavigationControllerOrSelf);
        }
Пример #8
0
        public static void NavigateBack <TResult>(
            [NotNull] this NavigationServiceBase navigationService,
            [NotNull] IIosView <IViewModelWithResult <TResult> > fromView,
            ViewModelResultCode resultCode,
            [CanBeNull] TResult result,
            bool animated,
            [CanBeNull] BackwardNavigationDelegate navigationStrategy = null)
            where TResult : ViewModelResultBase
        {
            if (navigationService == null)
            {
                throw new ArgumentNullException(nameof(navigationService));
            }
            if (fromView == null)
            {
                throw new ArgumentNullException(nameof(fromView));
            }

            fromView.SetResult(resultCode, result);
            var navigationController = fromView.GetNavigationController();

            (navigationStrategy ?? NavigationStrategy.Backward.Default()).Invoke(navigationController, fromView, animated);
        }