WorkflowView
@available(iOS 14.0, macOS 11, tvOS 14.0, watchOS 7.0, *)
public struct WorkflowView<Content> : View where Content : View
Used to build a Workflow in SwiftUI; Embed WorkflowItems in a WorkflowView to create a SwiftUI view.
Discussion
The preferred method for creating a Workflow with SwiftUI is a combination of WorkflowView and WorkflowItem. Initialize with arguments if your first FlowRepresentable has an input type.
Example
WorkflowView(isLaunched: $isLaunched.animation(), launchingWith: "String in") {
WorkflowItem(FirstView.self)
.applyModifiers {
$0.background(Color.gray)
.transition(.slide)
.animation(.spring())
}
WorkflowItem(SecondView.self)
.persistence(.removedAfterProceeding)
.applyModifiers {
$0.SecondViewSpecificModifier()
.padding(10)
.background(Color.purple)
.transition(.opacity)
.animation(.easeInOut)
}
}
.onAbandon { print("isLaunched is now false") }
.onFinish { args in print("Finished 1: \(args)") }
.onFinish { print("Finished 2: \($0)") }
.background(Color.green)
-
Declaration
Swift
public var body: some View { get } -
Creates a base for proceeding with a
WorkflowItem.Declaration
Swift
public init<WI: _WorkflowItemProtocol>(isLaunched: Binding<Bool> = .constant(true), @WorkflowBuilder content: () -> WI) where Content == WorkflowLauncher<WI>, WI.FlowRepresentableType.WorkflowInput == NeverParameters
isLaunchedbinding that controls launching the underlying
Workflow.contentWorkflowBuilderconsisting ofWorkflowItems that define your workflow. -
Creates a base for proceeding with a
WorkflowItem.Declaration
Swift
public init<WI: _WorkflowItemProtocol>(isLaunched: Binding<Bool> = .constant(true), launchingWith args: WI.FlowRepresentableType.WorkflowInput, @WorkflowBuilder content: () -> WI) where Content == WorkflowLauncher<WI>Parameters
isLaunchedbinding that controls launching the underlying
Workflow.launchingWitharguments passed to the first loaded
FlowRepresentablein the underlyingWorkflow.contentWorkflowBuilderconsisting ofWorkflowItems that define your workflow. -
Creates a base for proceeding with a
WorkflowItem.Declaration
Swift
public init<WI: _WorkflowItemProtocol>(isLaunched: Binding<Bool> = .constant(true), launchingWith args: AnyWorkflow.PassedArgs, @WorkflowBuilder content: () -> WI) where Content == WorkflowLauncher<WI>, WI.FlowRepresentableType.WorkflowInput == AnyWorkflow.PassedArgsParameters
isLaunchedbinding that controls launching the underlying
Workflow.launchingWitharguments passed to the first loaded
FlowRepresentablein the underlyingWorkflow.contentWorkflowBuilderconsisting ofWorkflowItems that define your workflow. -
Creates a base for proceeding with a
WorkflowItem.Declaration
Swift
public init<WI: _WorkflowItemProtocol>(isLaunched: Binding<Bool> = .constant(true), launchingWith args: AnyWorkflow.PassedArgs, @WorkflowBuilder content: () -> WI) where Content == WorkflowLauncher<WI>Parameters
isLaunchedbinding that controls launching the underlying
Workflow.launchingWitharguments passed to the first loaded
FlowRepresentablein the underlyingWorkflow.contentWorkflowBuilderconsisting ofWorkflowItems that define your workflow. -
Creates a base for proceeding with a
WorkflowItem.Declaration
Swift
public init<A, WI: _WorkflowItemProtocol>(isLaunched: Binding<Bool> = .constant(true), launchingWith args: A, @WorkflowBuilder content: () -> WI) where Content == WorkflowLauncher<WI>, WI.FlowRepresentableType.WorkflowInput == AnyWorkflow.PassedArgsParameters
isLaunchedbinding that controls launching the underlying
Workflow.launchingWitharguments passed to the first loaded
FlowRepresentablein the underlyingWorkflow.contentWorkflowBuilderconsisting ofWorkflowItems that define your workflow. -
Creates a base for proceeding with a
WorkflowItem.Declaration
Swift
public init<A, WI: _WorkflowItemProtocol>(isLaunched: Binding<Bool> = .constant(true), launchingWith args: A, @WorkflowBuilder content: () -> WI) where Content == WorkflowLauncher<WI>, WI.FlowRepresentableType.WorkflowInput == NeverParameters
isLaunchedbinding that controls launching the underlying
Workflow.launchingWitharguments passed to the first loaded
FlowRepresentablein the underlyingWorkflow.contentWorkflowBuilderconsisting ofWorkflowItems that define your workflow. -
Creates a base for proceeding with a
WorkflowItem.Declaration
Swift
public init<WI: _WorkflowItemProtocol>(isLaunched: Binding<Bool> = .constant(true), @WorkflowBuilder content: () -> WI) where Content == WorkflowLauncher<WI>, WI.FlowRepresentableType.WorkflowInput == AnyWorkflow.PassedArgsParameters
isLaunchedbinding that controls launching the underlying
Workflow.contentWorkflowBuilderconsisting ofWorkflowItems that define your workflow. -
Creates a base for proceeding with a
WorkflowItem.Declaration
Swift
public init(isLaunched: Binding<Bool> = .constant(true), launchingWith startingArgs: AnyWorkflow.PassedArgs = .none, workflow: AnyWorkflow) where Content == WorkflowLauncher<WorkflowItemWrapper<AnyWorkflowItem, Never>>Parameters
isLaunchedbinding that controls launching the underlying
Workflow.startingArgsarguments passed to the first loaded
FlowRepresentablein the underlyingWorkflow.workflowworkflow to be launched; must contain
FlowRepresentables of typeView -
Creates a base for proceeding with a
WorkflowItem.Declaration
Swift
public init<A>(isLaunched: Binding<Bool> = .constant(true), launchingWith startingArgs: A, workflow: AnyWorkflow) where Content == WorkflowLauncher<WorkflowItemWrapper<AnyWorkflowItem, Never>>Parameters
isLaunchedbinding that controls launching the underlying
Workflow.startingArgsarguments passed to the first loaded
FlowRepresentablein the underlyingWorkflow.workflowworkflow to be launched; must contain
FlowRepresentables of typeView -
Adds an action to perform when this
Workflowhas finished.Declaration
Swift
public func onFinish<WI>(_ closure: @escaping (AnyWorkflow.PassedArgs) -> Void) -> WorkflowView<Content> where Content == WorkflowLauncher<WI>, WI : _WorkflowItemProtocol -
Adds an action to perform when this
Workflowhas abandoned.Declaration
Swift
public func onAbandon<WI>(_ closure: @escaping () -> Void) -> WorkflowView<Content> where Content == WorkflowLauncher<WI>, WI : _WorkflowItemProtocol -
Subscribers to a combine publisher, when a value is emitted the workflow will abandon.
Declaration
Swift
public func abandonOn<WI, P>(_ publisher: P) -> WorkflowView<Content> where Content == WorkflowLauncher<WI>, WI : _WorkflowItemProtocol, P : Publisher, P.Failure == Never -
Wraps content in a NavigationView.
Declaration
Swift
public func embedInNavigationView<WI>() -> WorkflowView<Content> where Content == WorkflowLauncher<WI>, WI : _WorkflowItemProtocol
View on GitHub
WorkflowView Structure Reference