@@ -12,6 +12,7 @@ public protocol RouterProtocol: ViperitComponent {
1212 var _presenter : PresenterProtocol ! { get set }
1313 var _view : UserInterfaceProtocol ! { get }
1414
15+ func embedInNavigationController( ) -> UINavigationController
1516 func show( inWindow window: UIWindow ? , embedInNavController: Bool , setupData: Any ? , makeKeyAndVisible: Bool )
1617 func show( from: UIViewController , embedInNavController: Bool , setupData: Any ? )
1718 func show( from containerView: UIViewController , insideView targetView: UIView , setupData: Any ? )
@@ -32,12 +33,12 @@ open class Router: RouterProtocol {
3233 }
3334
3435 open func embedInNavigationController( ) -> UINavigationController {
35- return getNavigationController ( ) ?? UINavigationController ( rootViewController: _view as! UIViewController )
36+ return getNavigationController ( ) ?? UINavigationController ( rootViewController: viewController )
3637 }
3738
3839 open func show( inWindow window: UIWindow ? , embedInNavController: Bool = false , setupData: Any ? = nil , makeKeyAndVisible: Bool = true ) {
3940 process ( setupData: setupData)
40- let view = embedInNavController ? embedInNavigationController ( ) : _view as? UIViewController
41+ let view = embedInNavController ? embedInNavigationController ( ) : viewController
4142 window? . rootViewController = view
4243 if makeKeyAndVisible {
4344 window? . makeKeyAndVisible ( )
@@ -46,7 +47,7 @@ open class Router: RouterProtocol {
4647
4748 open func show( from: UIViewController , embedInNavController: Bool = false , setupData: Any ? = nil ) {
4849 process ( setupData: setupData)
49- let view : UIViewController = embedInNavController ? embedInNavigationController ( ) : _view as! UIViewController
50+ let view : UIViewController = embedInNavController ? embedInNavigationController ( ) : viewController
5051 from. show ( view, sender: nil )
5152 }
5253
@@ -56,7 +57,7 @@ open class Router: RouterProtocol {
5657 }
5758
5859 public func present( from: UIViewController , embedInNavController: Bool = false , presentationStyle: UIModalPresentationStyle = . fullScreen, transitionStyle: UIModalTransitionStyle = . coverVertical, setupData: Any ? = nil , completion: ( ( ) -> Void ) ? = nil ) {
59- let view : UIViewController = embedInNavController ? embedInNavigationController ( ) : _view as! UIViewController
60+ let view : UIViewController = embedInNavController ? embedInNavigationController ( ) : viewController
6061 view. modalTransitionStyle = transitionStyle
6162 view. modalPresentationStyle = presentationStyle
6263
@@ -65,8 +66,7 @@ open class Router: RouterProtocol {
6566 }
6667
6768 public func dismiss( animated flag: Bool = true , completion: ( ( ) -> Void ) ? = nil ) {
68- guard let view = _view as? UIViewController else { return }
69- view. dismiss ( animated: flag, completion: completion)
69+ viewController. dismiss ( animated: flag, completion: completion)
7070 }
7171
7272 required public init ( ) { }
@@ -82,7 +82,7 @@ private extension Router {
8282}
8383
8484//MARK: - Get navigation controller helper
85- private extension Router {
85+ public extension RouterProtocol {
8686 func getNavigationController( ) -> UINavigationController ? {
8787 guard let view = _view as? UIViewController else { return nil }
8888 if let nav = view. navigationController {
@@ -97,7 +97,7 @@ private extension Router {
9797}
9898
9999//MARK: - Embed view in a container view
100- public extension Router {
100+ public extension RouterProtocol {
101101 func addAsChildView( ofView parentView: UIViewController , insideContainer containerView: UIView ) {
102102 guard let view = _view as? UIViewController else { return }
103103 parentView. addChild ( view)
0 commit comments