File tree Expand file tree Collapse file tree 2 files changed +56
-1
lines changed
Screen/AnyContentContainerScreen
ViewControllerDescription Expand file tree Collapse file tree 2 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 1+ //
2+ // AnyContentContainerScreen.swift
3+ // WorkflowUI
4+ //
5+ // Created by Kyle Van Essen on 9/26/22.
6+ //
7+
8+ import Foundation
9+
10+ ///
11+ ///
12+ public struct AnyContentContainerScreen : Screen {
13+ public let content : AnyScreen
14+
15+ public init < ScreenType: Screen > ( _ content: ScreenType ) {
16+ if let content = content as? Self {
17+ self = content
18+ } else {
19+ self . content = content. asAnyScreen ( )
20+ }
21+ }
22+
23+ // MARK: Screen
24+
25+ public func viewControllerDescription( environment: ViewEnvironment ) -> ViewControllerDescription {
26+ let description = content. viewControllerDescription ( environment: environment)
27+
28+ return ViewControllerDescription (
29+ /// The inner `DescribedViewController` will respect `performInitialUpdate` from
30+ /// the nested screen – so our value should always be false.
31+ performInitialUpdate: false ,
32+ type: DescribedViewController . self,
33+ build: {
34+ DescribedViewController ( description: description)
35+ } ,
36+ update: { vc in
37+ vc. update ( description: description)
38+ }
39+ )
40+ }
41+ }
42+
43+ extension Screen {
44+ ///
45+ ///
46+ public func inContainerScreen( ) -> AnyContentContainerScreen {
47+ AnyContentContainerScreen ( self )
48+ }
49+ }
Original file line number Diff line number Diff line change 1818
1919 import UIKit
2020
21+ /// Displays the backing `ViewControllerDescription` for a given `Screen`.
22+ ///
2123 public final class DescribedViewController : UIViewController {
2224 var currentViewController : UIViewController
2325
6365 }
6466
6567 public func update< S: Screen > ( screen: S , environment: ViewEnvironment ) {
66- update ( description: screen. viewControllerDescription ( environment: environment) )
68+ if let screen = screen as? AnyContentContainerScreen {
69+ update ( description: screen. content. viewControllerDescription ( environment: environment) )
70+ } else {
71+ update ( description: screen. viewControllerDescription ( environment: environment) )
72+ }
6773 }
6874
6975 override public func viewDidLoad( ) {
You can’t perform that action at this time.
0 commit comments