Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples of uses in UINavigationControllers and UITabBarController #16

Open
elprl opened this issue Nov 27, 2018 · 3 comments
Open

Examples of uses in UINavigationControllers and UITabBarController #16

elprl opened this issue Nov 27, 2018 · 3 comments
Labels

Comments

@elprl
Copy link

elprl commented Nov 27, 2018

Could the example project be updated with a use case for modules in UINavigationControllers and UITabBarControllers? Also, will you be doing a Swift 4.2 update?

@elprl
Copy link
Author

elprl commented Nov 28, 2018

Or a suggestion here on how to do it?

@elprl
Copy link
Author

elprl commented Dec 5, 2018

For others wondering about this, I ended up adding the following extension:

extension ModuleProtocol {
    
    func presentWithNavController(from fromVC: UIViewController?, style: UIModalTransitionStyle, completion: CodeBlock? = nil) {
        let navVC = UINavigationController(rootViewController: viewController)
        navVC.modalTransitionStyle = style
        fromVC?.present(navVC, animated: true, completion: completion)
    }
    
    func replaceRoot(from navController: UINavigationController?) {
        guard let navvy = navController else { return }
        var vcs = navvy.viewControllers
        vcs[vcs.count - 1] = viewController
        navvy.setViewControllers(vcs, animated: true)
    }
}

Which can then be used as follows:
ProductDetailedModule().presentWithNavController(from: viewController, style: .coverVertical)

@codytwinton
Copy link
Owner

@elprl - Thanks for reaching out! I'll do my best to resolve this asap.

For now, I'm open to pull requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants