Skip to content

Commit 961052d

Browse files
authored
- Make getNavigationController function public (#103)
- Use router's viewController accessor instead of force casting - Extend RouterProtocol instead of Router class if it makes sense - Bump version number to 1.3.2
1 parent b54c781 commit 961052d

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

Example/modules/home/HomeInteractor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import Viperit
1111

1212
final class HomeInteractor: Interactor {
1313
func someInteractorOperation() {
14-
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2)) {
15-
self.presenter.reactToSomeInteractorOperation()
14+
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2)) { [weak self] in
15+
self?.presenter.reactToSomeInteractorOperation()
1616
}
1717
}
1818
}

Viperit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
Pod::Spec.new do |s|
44
s.name = 'Viperit'
5-
s.version = '1.3.1'
5+
s.version = '1.3.2'
66
s.summary = 'Viper Framework for iOS written in Swift'
77

88
s.description = <<-DESC

Viperit/Core/Router.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

Viperit/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.3.1</string>
18+
<string>1.3.2</string>
1919
<key>CFBundleVersion</key>
2020
<string>1</string>
2121
<key>LSRequiresIPhoneOS</key>

0 commit comments

Comments
 (0)