Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import UIKit
/// Opens up `Nickname` on a given parent view controller
public struct PresentNickname: Action {
/// - Parameters:
/// - prefilled: Optional value to be set as placeholder/pre-existent text
/// - completion: Closure that passes the value of the text set
/// - parent: Parent view controller from which presentation should happen
/// - animated: Animate the transition
public init(
prefilled: String?,
completion: @escaping (String) -> Void,
from parent: UIViewController,
animated: Bool = true
) {
self.prefilled = prefilled
self.completion = completion
self.parent = parent
self.animated = animated
}
/// Optional value to be set as placeholder/pre-existent text
public var prefilled: String?
/// Closure that passes the value of the text set
public var completion: (String) -> Void
/// Parent view controller from which presentation should happen
public var parent: UIViewController
/// Animate the transition
public var animated: Bool
}
/// Performs `PresentNickname` action
public struct PresentNicknameNavigator: TypedNavigator {
/// Custom transitioning delegate
let transitioningDelegate = BottomTransitioningDelegate()
/// View controller which should be opened up
var viewController: () -> UIViewController
/// - Parameters:
/// - viewController: view controller which should be presented
public init(_ viewController: @escaping () -> UIViewController) {
self.viewController = viewController
}
public func perform(_ action: PresentNickname, completion: @escaping () -> Void) {
let controller = viewController()
controller.transitioningDelegate = transitioningDelegate
controller.modalPresentationStyle = .overFullScreen
action.parent.present(
controller,
animated: action.animated,
completion: completion
)
}
}