protected virtual ValueTask <bool> CloseModalViewController(IMvxViewModel viewModel) { if (ModalViewControllers == null || !ModalViewControllers.Any()) { return(new ValueTask <bool>(false)); } var modal = ModalViewControllers .FirstOrDefault(v => v is IMvxTvosView && v.GetIMvxTvosView().ViewModel == viewModel); if (modal != null) { return(CloseModalViewController(modal)); } UIViewController viewController = null; foreach (var vc in ModalViewControllers.Where(v => v is UINavigationController)) { var rootViewController = ((UINavigationController)vc).ViewControllers.FirstOrDefault(); if (rootViewController != null && rootViewController.GetIMvxTvosView().ViewModel == viewModel) { viewController = vc; break; } } if (viewController != null) { return(CloseModalViewController(viewController)); } return(new ValueTask <bool>(false)); }
protected virtual Task <bool> CloseModalViewController(IMvxViewModel toClose, MvxModalPresentationAttribute attribute) { if (ModalViewControllers == null || !ModalViewControllers.Any()) { return(Task.FromResult(false)); } // check for plain modals var modalToClose = ModalViewControllers.FirstOrDefault(v => v is IMvxIosView && v.GetIMvxIosView().ViewModel == toClose); if (modalToClose != null) { return(CloseModalViewController(modalToClose, attribute)); } // check for modal navigation stacks UIViewController controllerToClose = null; foreach (var vc in ModalViewControllers.Where(v => v is UINavigationController)) { var root = ((UINavigationController)vc).ViewControllers.FirstOrDefault(); if (root != null && root.GetIMvxIosView().ViewModel == toClose) { controllerToClose = vc; break; } } if (controllerToClose != null) { return(CloseModalViewController(controllerToClose, attribute)); } return(Task.FromResult(false)); }
protected virtual bool CloseModalViewController(IMvxViewModel toClose) { if (ModalViewControllers == null || !ModalViewControllers.Any()) { return(false); } // check for plain modals var modalToClose = ModalViewControllers.FirstOrDefault(v => v is IMvxIosView && v.GetIMvxIosView().ViewModel == toClose); if (modalToClose != null) { CloseModalViewController(modalToClose); return(true); } // check for modal navigation stacks UIViewController controllerToClose = null; foreach (var vc in ModalViewControllers.Where(v => v is UINavigationController)) { var root = ((UINavigationController)vc).ViewControllers.FirstOrDefault(); if (root != null && root.GetIMvxIosView().ViewModel == toClose) { controllerToClose = root; break; } } if (controllerToClose != null) { CloseModalViewController(controllerToClose); return(true); } return(false); }