Skip to content

CLASS

ScreenViewController

open class ScreenViewController<ScreenType: Screen>: WorkflowUIViewController

Generic base class that can be subclassed in order to to define a UI implementation that is powered by the given screen type.

Using this base class, a screen can be implemented as:

struct MyScreen: Screen {
    func viewControllerDescription(environment: ViewEnvironment) -> ViewControllerDescription {
        return MyScreenViewController.description(for: self, environment: environment)
    }
}

private class MyScreenViewController: ScreenViewController<MyScreen> {
    override func screenDidChange(from previousScreen: MyScreen, previousEnvironment: ViewEnvironment) {
        // … update views as necessary
    }
}

Properties

screen

public private(set) final var screen: ScreenType

screenType

public final var screenType: Screen.Type

Methods

init(screen:environment:)

public required init(screen: ScreenType, environment: ViewEnvironment)

init(coder:)

update(screen:)

public final func update(screen: ScreenType)

screenDidChange(from:previousEnvironment:)

open func screenDidChange(from previousScreen: ScreenType, previousEnvironment: ViewEnvironment)

Subclasses should override this method in order to update any relevant UI bits when the screen model changes.