-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRootRouter.swift
More file actions
65 lines (50 loc) · 1.56 KB
/
Copy pathRootRouter.swift
File metadata and controls
65 lines (50 loc) · 1.56 KB
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
61
62
63
64
65
//
// RootRouter.swift
// RootFeature
//
// Created by kimnahun on 2026-01-21.
// Copyright © 2026 NDGL-iOS. All rights reserved.
//
import RIBs
import MainFeature
// MARK: - RootInteractable
protocol RootInteractable: Interactable, MainListener {
var router: RootRouting? { get set }
var listener: RootListener? { get set }
}
// MARK: - RootViewControllable
public protocol RootViewControllable: ViewControllable {
func present(viewController: ViewControllable)
func dismiss(viewController: ViewControllable)
func setRootViewController(_ viewController: ViewControllable)
}
// MARK: - RootRouter
final class RootRouter: LaunchRouter<RootInteractable, RootViewControllable>, RootRouting {
private let mainBuilder: MainBuildable
private var mainRouter: MainRouting?
init(
interactor: RootInteractable,
viewController: RootViewControllable,
mainBuilder: MainBuildable
) {
self.mainBuilder = mainBuilder
super.init(interactor: interactor, viewController: viewController)
interactor.router = self
}
override func didLoad() {
super.didLoad()
}
// MARK: - RootRouting
func attachMain() {
guard mainRouter == nil else { return }
let router = mainBuilder.build(withListener: interactor)
mainRouter = router
attachChild(router)
viewController.setRootViewController(router.viewControllable)
}
func detachMain() {
guard let router = mainRouter else { return }
detachChild(router)
mainRouter = nil
}
}