@@ -14,9 +14,14 @@ import {{ import }}
14
14
@MainActor
15
15
{% if owns_view %}
16
16
internal protocol {{ node_name }}Flow: {{ view_controllable_flow_type }} {}
17
+ {% elif node_name == "Scene" %}
18
+ internal protocol {{ node_name }}Flow: Flow {
19
+ func getViewController() -> Window{{ node_name }}ViewControllable
20
+ }
17
21
{% else %}
18
22
internal protocol {{ node_name }}Flow: Flow {}
19
23
{% endif %}
24
+ {% if node_name != "App" %}
20
25
21
26
/**
22
27
PURPOSE:
@@ -33,6 +38,7 @@ public protocol {{ node_name }}Dependency: Dependency {
33
38
{% else %}
34
39
public protocol {{ node_name }}Dependency: Dependency {}
35
40
{% endif %}
41
+ {% endif %}
36
42
37
43
/**
38
44
PURPOSE:
@@ -42,6 +48,10 @@ public protocol {{ node_name }}Dependency: Dependency {}
42
48
*/
43
49
{% if owns_view %}
44
50
internal typealias {{ node_name }}DynamicBuildDependency = {{ node_name }}Listener
51
+ {% elif node_name == "App" %}
52
+ internal typealias {{ node_name }}DynamicBuildDependency = Void
53
+ {% elif node_name == "Scene" %}
54
+ internal typealias {{ node_name }}DynamicBuildDependency = ({{ node_name }}Listener, Window{{ node_name }}ViewControllable)
45
55
{% else %}
46
56
internal typealias {{ node_name }}DynamicBuildDependency = ({{ node_name }}Listener, {{ node_name }}ViewControllable)
47
57
{% endif %}
@@ -60,10 +70,14 @@ internal typealias {{ node_name }}DynamicComponentDependency = Void
60
70
PURPOSE:
61
71
Declares dependencies that are owned by this Node.
62
72
*/
73
+ {% if node_name == "App" %}
74
+ public final class {{ node_name }}Component: BootstrapComponent {
75
+ {% else %}
63
76
public final class {{ node_name }}Component: Component
64
77
<
65
78
{{ node_name }}Dependency
66
79
> {
80
+ {% endif %}
67
81
68
82
/*
69
83
Dependencies
@@ -89,6 +103,10 @@ public final class {{ node_name }}Component: Component
89
103
}
90
104
91
105
*/
106
+ {% if node_name == "App" %}
107
+
108
+ fileprivate let appService: AppService = AppServiceImp()
109
+ {% endif %}
92
110
93
111
{% if is_periphery_comment_enabled %}
94
112
// periphery:ignore
@@ -102,15 +120,25 @@ public final class {{ node_name }}Component: Component
102
120
///
103
121
/// Remove `dynamicDependency` default parameter when its type is not `Void`.
104
122
///
123
+ {% if node_name == "App" %}
124
+ /// - Parameter dynamicDependency: The dynamic component dependency
125
+ {% else %}
105
126
/// - Parameters:
106
127
/// - parent: The parent scope
107
128
/// - dynamicDependency: The dynamic component dependency
129
+ {% endif %}
108
130
internal init(
131
+ {% if node_name != "App" %}
109
132
parent: Scope,
133
+ {% endif %}
110
134
dynamicDependency: {{ node_name }}DynamicComponentDependency = ()
111
135
) {
112
136
self.dynamicDependency = dynamicDependency
137
+ {% if node_name == "App" %}
138
+ super.init()
139
+ {% else %}
113
140
super.init(parent: parent)
141
+ {% endif %}
114
142
}
115
143
116
144
/*
@@ -124,6 +152,22 @@ public final class {{ node_name }}Component: Component
124
152
}
125
153
126
154
*/
155
+ {% if node_name == "App" %}
156
+
157
+ fileprivate func sceneComponentFactory() -> SceneComponent {
158
+ SceneComponent(parent: self)
159
+ }
160
+ {% elif node_name == "Scene" %}
161
+
162
+ fileprivate func windowComponentFactory() -> WindowComponent {
163
+ WindowComponent(parent: self)
164
+ }
165
+ {% elif node_name == "Window" %}
166
+
167
+ fileprivate func rootComponentFactory() -> RootComponent {
168
+ RootComponent(parent: self)
169
+ }
170
+ {% endif %}
127
171
}
128
172
129
173
// MARK: - Builder
@@ -138,10 +182,19 @@ public final class {{ node_name }}Component: Component
138
182
/// @mockable
139
183
@MainActor
140
184
internal protocol {{ node_name }}Builder: AnyObject {
185
+ {% if node_name == "App" %}
186
+ func build() -> {{ node_name }}Flow
187
+ {% elif node_name == "Scene" %}
188
+ func build(
189
+ withListener listener: {{ node_name }}Listener,
190
+ viewController: Window{{ node_name }}ViewControllable
191
+ ) -> {{ node_name }}Flow
192
+ {% else %}
141
193
func build(
142
194
withListener listener: {{ node_name }}Listener{% if not owns_view %}{{ ',' }}
143
195
viewController: {{ node_name }}ViewControllable{% endif +%}
144
196
) -> {{ node_name }}Flow
197
+ {% endif %}
145
198
}
146
199
147
200
{% if is_periphery_comment_enabled %}
@@ -165,18 +218,29 @@ internal final class {{ node_name }}BuilderImp: AbstractBuilder
165
218
/// The dynamic dependencies can be tuples or structs containing multiple values when necessary.
166
219
{% if owns_view %}
167
220
/// - Parameter listener: An object that can listen for signals from the Node
168
- {% else %}
221
+ {% elif node_name != "App" %}
169
222
/// - Parameters:
170
223
/// - listener: An object that can listen for signals from the Node
171
224
/// - viewController: The injected view controller
172
225
{% endif %}
173
226
/// - Returns: The Flow instance
227
+ {% if node_name == "App" %}
228
+ internal func build() -> {{ node_name }}Flow {
229
+ {% elif node_name == "Scene" %}
230
+ internal func build(
231
+ withListener listener: {{ node_name }}Listener,
232
+ viewController: Window{{ node_name }}ViewControllable
233
+ ) -> {{ node_name }}Flow {
234
+ {% else %}
174
235
internal func build(
175
236
withListener listener: {{ node_name }}Listener{% if not owns_view %}{{ ',' }}
176
237
viewController: {{ node_name }}ViewControllable{% endif +%}
177
238
) -> {{ node_name }}Flow {
239
+ {% endif %}
178
240
{% if owns_view %}
179
241
let dynamicBuildDependency: {{ node_name }}DynamicBuildDependency = listener
242
+ {% elif node_name == "App" %}
243
+ let dynamicBuildDependency: {{ node_name }}DynamicBuildDependency = ()
180
244
{% else %}
181
245
let dynamicBuildDependency: {{ node_name }}DynamicBuildDependency = (listener, viewController)
182
246
{% endif %}
@@ -195,14 +259,18 @@ internal final class {{ node_name }}BuilderImp: AbstractBuilder
195
259
) -> {{ node_name }}Flow {
196
260
{% if owns_view %}
197
261
let listener: {{ node_name }}Listener = dynamicBuildDependency
198
- {% else %}
262
+ {% elif node_name != "App" %}
199
263
let listener: {{ node_name }}Listener = dynamicBuildDependency.0
264
+ {% if node_name == "Scene" %}
265
+ let viewController: Window{{ node_name }}ViewControllable = dynamicBuildDependency.1
266
+ {% else %}
200
267
let viewController: {{ node_name }}ViewControllable = dynamicBuildDependency.1
201
268
{% endif %}
269
+ {% endif %}
202
270
{% if analytics_properties %}
203
271
let analytics: {{ node_name }}AnalyticsImp = .init(
204
272
{% for property in analytics_properties %}
205
- {{ property.name }}: component.dependency.{{ property.name }}{% if not forloop.last %}{{ ',' }}
273
+ {{ property.name }}: component{% if node_name != "App" %} .dependency{% endif %} .{{ property.name }}{% if not forloop.last %}{{ ',' }}
206
274
{% endif %}
207
275
{% endfor +%}
208
276
)
@@ -211,9 +279,12 @@ internal final class {{ node_name }}BuilderImp: AbstractBuilder
211
279
{% endif %}
212
280
let context: {{ node_name }}ContextImp = .init(
213
281
workers: [],
214
- analytics: analytics
282
+ analytics: analytics{% if node_name == "App" %}{{ ',' }}
283
+ windowSceneState: component.appService.windowSceneState{% endif +%}
215
284
)
285
+ {% if node_name != "App" %}
216
286
context.listener = listener
287
+ {% endif %}
217
288
{% if owns_view %}
218
289
let viewStateFactory: {{ node_name }}ViewStateFactory = .init()
219
290
let viewController: {{ node_name }}ViewController = .init(
@@ -223,13 +294,16 @@ internal final class {{ node_name }}BuilderImp: AbstractBuilder
223
294
viewController.receiver = context
224
295
{% endif %}
225
296
let flow: {{ node_name }}FlowImp = .init(
226
- context: context,
227
- viewController: viewController{% if flow_properties %}{{ ',' }}
297
+ context: context{% if node_name != "App" %}{{ ',' }}
298
+ viewController: viewController{% endif +%}{% if flow_properties %}{{ ',' }}
228
299
{% for property in flow_properties %}
229
- {{ property.name }}: component.dependency.{{ property.name }}{% if not forloop.last %}{{ ',' }}
300
+ {{ property.name }}: component{% if node_name != "App" %} .dependency{% endif %} .{{ property.name }}{% if not forloop.last %}{{ ',' }}
230
301
{% endif %}
231
302
{% endfor %}
232
- {% endif +%}
303
+ {% endif +%}{% if node_name == "App" %}{{ ',' }}
304
+ sceneBuilder: SceneBuilderImp(componentFactory: component.sceneComponentFactory){% endif +%}{% if node_name == "Scene" %}{{ ',' }}
305
+ windowBuilder: WindowBuilderImp(componentFactory: component.windowComponentFactory){% endif +%}{% if node_name == "Window" %}{{ ',' }}
306
+ rootBuilder: RootBuilderImp(componentFactory: component.rootComponentFactory){% endif +%}
233
307
)
234
308
context.flow = flow
235
309
return flow
0 commit comments