Fix Tutorial code
MODIFY
swift/Samples/Tutorial/Frameworks/Tutorial2Complete/Sources/RootWorkflow.swift
swift/Samples/Tutorial/Frameworks/Tutorial2Complete/Sources/RootWorkflow.swift
@@ -86,14 +86,14 @@ extension RootWorkflow {
// MARK: Rendering
extension RootWorkflow {
- typealias Rendering = BackStackScreen
+ typealias Rendering = BackStackScreen<AnyScreen>
func render(state: RootWorkflow.State, context: RenderContext<RootWorkflow>) -> Rendering {
// Create a sink to handle the back action from the TodoListWorkflow to logout.
let sink = context.makeSink(of: Action.self)
// Our list of back stack items. Will always include the "WelcomeScreen".
- var backStackItems: [BackStackScreen.Item] = []
+ var backStackItems: [BackStackScreen<AnyScreen>.Item] = []
let welcomeScreen = WelcomeWorkflow()
.mapOutput { output -> Action in
@@ -107,7 +107,7 @@ extension RootWorkflow {
let welcomeBackStackItem = BackStackScreen.Item(
key: "welcome",
- screen: welcomeScreen,
+ screen: welcomeScreen.asAnyScreen(),
// Hide the navigation bar.
barVisibility: .hidden
)
@@ -129,9 +129,9 @@ extension RootWorkflow {
let todoListBackStackItem = BackStackScreen.Item(
key: "todoList",
- screen: todoListScreen,
+ screen: todoListScreen.asAnyScreen(),
// Specify the title, back button, and right button.
- barContent: BackStackScreen.BarContent(
+ barContent: .init(
title: "Welcome \(name)",
// When `back` is pressed, emit the .logout action to return to the welcome screen.
leftItem: .button(.back(handler: {

MODIFY
swift/Samples/Tutorial/Frameworks/Tutorial3Complete/Sources/RootWorkflow.swift
swift/Samples/Tutorial/Frameworks/Tutorial3Complete/Sources/RootWorkflow.swift
@@ -86,13 +86,13 @@ extension RootWorkflow {
// MARK: Rendering
extension RootWorkflow {
- typealias Rendering = BackStackScreen
+ typealias Rendering = BackStackScreen<AnyScreen>
func render(state: RootWorkflow.State, context: RenderContext<RootWorkflow>) -> Rendering {
// Delete the `let sink = context.makeSink(of: ...) as we no longer need a sink.
// Our list of back stack items. Will always include the "WelcomeScreen".
- var backStackItems: [BackStackScreen.Item] = []
+ var backStackItems: [BackStackScreen<AnyScreen>.Item] = []
let welcomeScreen = WelcomeWorkflow()
.mapOutput { output -> Action in
@@ -106,7 +106,7 @@ extension RootWorkflow {
let welcomeBackStackItem = BackStackScreen.Item(
key: "welcome",
- screen: welcomeScreen,
+ screen: welcomeScreen.asAnyScreen(),
// Hide the navigation bar.
barVisibility: .hidden
)

MODIFY
swift/Samples/Tutorial/Frameworks/Tutorial3Complete/Sources/Todo/Edit/TodoEditWorkflow.swift
swift/Samples/Tutorial/Frameworks/Tutorial3Complete/Sources/Todo/Edit/TodoEditWorkflow.swift
@@ -106,7 +106,7 @@ extension TodoEditWorkflow {
// MARK: Rendering
extension TodoEditWorkflow {
- typealias Rendering = BackStackScreen.Item
+ typealias Rendering = BackStackScreen<AnyScreen>.Item
func render(state: TodoEditWorkflow.State, context: RenderContext<TodoEditWorkflow>) -> Rendering {
// The sink is used to send actions back to this workflow.
@@ -125,13 +125,13 @@ extension TodoEditWorkflow {
let backStackItem = BackStackScreen.Item(
key: "edit",
- screen: todoEditScreen,
- barContent: BackStackScreen.BarContent(
+ screen: todoEditScreen.asAnyScreen(),
+ barContent: .init(
title: "Edit",
leftItem: .button(.back(handler: {
sink.send(.discardChanges)
})),
- rightItem: .button(BackStackScreen.BarContent.Button(
+ rightItem: .button(.init(
content: .text("Save"),
handler: {
sink.send(.saveChanges)

MODIFY
swift/Samples/Tutorial/Frameworks/Tutorial3Complete/Sources/Todo/List/TodoListWorkflow.swift
swift/Samples/Tutorial/Frameworks/Tutorial3Complete/Sources/Todo/List/TodoListWorkflow.swift
@@ -116,7 +116,7 @@ extension TodoListWorkflow {
// MARK: Rendering
extension TodoListWorkflow {
- typealias Rendering = [BackStackScreen.Item]
+ typealias Rendering = [BackStackScreen<AnyScreen>.Item]
func render(state: TodoListWorkflow.State, context: RenderContext<TodoListWorkflow>) -> Rendering {
// Define a sink to be able to send actions.
@@ -135,8 +135,8 @@ extension TodoListWorkflow {
let todoListItem = BackStackScreen.Item(
key: "list",
- screen: todoListScreen,
- barContent: BackStackScreen.BarContent(
+ screen: todoListScreen.asAnyScreen(),
+ barContent: .init(
title: "Welcome \(name)",
leftItem: .button(.back(handler: {
// When the left button is tapped, send the .onBack action.

MODIFY
swift/Samples/Tutorial/Frameworks/Tutorial4Complete/Sources/RootWorkflow.swift
swift/Samples/Tutorial/Frameworks/Tutorial4Complete/Sources/RootWorkflow.swift
@@ -86,13 +86,13 @@ extension RootWorkflow {
// MARK: Rendering
extension RootWorkflow {
- typealias Rendering = BackStackScreen
+ typealias Rendering = BackStackScreen<AnyScreen>
func render(state: RootWorkflow.State, context: RenderContext<RootWorkflow>) -> Rendering {
// Delete the `let sink = context.makeSink(of: ...) as we no longer need a sink.
// Our list of back stack items. Will always include the "WelcomeScreen".
- var backStackItems: [BackStackScreen.Item] = []
+ var backStackItems: [BackStackScreen<AnyScreen>.Item] = []
let welcomeScreen = WelcomeWorkflow()
.mapOutput { output -> Action in
@@ -106,7 +106,7 @@ extension RootWorkflow {
let welcomeBackStackItem = BackStackScreen.Item(
key: "welcome",
- screen: welcomeScreen,
+ screen: welcomeScreen.asAnyScreen(),
// Hide the navigation bar.
barVisibility: .hidden
)

MODIFY
swift/Samples/Tutorial/Frameworks/Tutorial4Complete/Sources/Todo/Edit/TodoEditWorkflow.swift
swift/Samples/Tutorial/Frameworks/Tutorial4Complete/Sources/Todo/Edit/TodoEditWorkflow.swift
@@ -106,7 +106,7 @@ extension TodoEditWorkflow {
// MARK: Rendering
extension TodoEditWorkflow {
- typealias Rendering = BackStackScreen.Item
+ typealias Rendering = BackStackScreen<AnyScreen>.Item
func render(state: TodoEditWorkflow.State, context: RenderContext<TodoEditWorkflow>) -> Rendering {
// The sink is used to send actions back to this workflow.
@@ -125,13 +125,13 @@ extension TodoEditWorkflow {
let backStackItem = BackStackScreen.Item(
key: "edit",
- screen: todoEditScreen,
- barContent: BackStackScreen.BarContent(
+ screen: todoEditScreen.asAnyScreen(),
+ barContent: .init(
title: "Edit",
leftItem: .button(.back(handler: {
sink.send(.discardChanges)
})),
- rightItem: .button(BackStackScreen.BarContent.Button(
+ rightItem: .button(.init(
content: .text("Save"),
handler: {
sink.send(.saveChanges)

MODIFY
swift/Samples/Tutorial/Frameworks/Tutorial4Complete/Sources/Todo/List/TodoListWorkflow.swift
swift/Samples/Tutorial/Frameworks/Tutorial4Complete/Sources/Todo/List/TodoListWorkflow.swift
@@ -93,7 +93,7 @@ extension TodoListWorkflow {
// MARK: Rendering
extension TodoListWorkflow {
- typealias Rendering = BackStackScreen.Item
+ typealias Rendering = BackStackScreen<AnyScreen>.Item
func render(state: TodoListWorkflow.State, context: RenderContext<TodoListWorkflow>) -> Rendering {
// Define a sink to be able to send the .onBack action.
@@ -112,14 +112,14 @@ extension TodoListWorkflow {
let todoListItem = BackStackScreen.Item(
key: "list",
- screen: todoListScreen,
- barContent: BackStackScreen.BarContent(
+ screen: todoListScreen.asAnyScreen(),
+ barContent: .init(
title: "Welcome \(name)",
leftItem: .button(.back(handler: {
// When the left button is tapped, send the .onBack action.
sink.send(.onBack)
})),
- rightItem: .button(BackStackScreen.BarContent.Button(
+ rightItem: .button(.init(
content: .text("New Todo"),
handler: {
sink.send(.new)

MODIFY
swift/Samples/Tutorial/Frameworks/Tutorial4Complete/Sources/Todo/TodoWorkflow.swift
swift/Samples/Tutorial/Frameworks/Tutorial4Complete/Sources/Todo/TodoWorkflow.swift
@@ -133,7 +133,7 @@ extension TodoWorkflow {
// MARK: Rendering
extension TodoWorkflow {
- typealias Rendering = [BackStackScreen.Item]
+ typealias Rendering = [BackStackScreen<AnyScreen>.Item]
func render(state: TodoWorkflow.State, context: RenderContext<TodoWorkflow>) -> Rendering {
let todoListItem = TodoListWorkflow(

MODIFY
swift/Samples/Tutorial/Frameworks/Tutorial5Complete/Sources/RootWorkflow.swift
swift/Samples/Tutorial/Frameworks/Tutorial5Complete/Sources/RootWorkflow.swift
@@ -86,13 +86,13 @@ extension RootWorkflow {
// MARK: Rendering
extension RootWorkflow {
- typealias Rendering = BackStackScreen
+ typealias Rendering = BackStackScreen<AnyScreen>
func render(state: RootWorkflow.State, context: RenderContext<RootWorkflow>) -> Rendering {
// Delete the `let sink = context.makeSink(of: ...) as we no longer need a sink.
// Our list of back stack items. Will always include the "WelcomeScreen".
- var backStackItems: [BackStackScreen.Item] = []
+ var backStackItems: [BackStackScreen<AnyScreen>.Item] = []
let welcomeScreen = WelcomeWorkflow()
.mapOutput { output -> Action in
@@ -106,7 +106,7 @@ extension RootWorkflow {
let welcomeBackStackItem = BackStackScreen.Item(
key: "welcome",
- screen: welcomeScreen,
+ screen: welcomeScreen.asAnyScreen(),
// Hide the navigation bar.
barVisibility: .hidden
)

MODIFY
swift/Samples/Tutorial/Frameworks/Tutorial5Complete/Sources/Todo/Edit/TodoEditWorkflow.swift
swift/Samples/Tutorial/Frameworks/Tutorial5Complete/Sources/Todo/Edit/TodoEditWorkflow.swift
@@ -106,7 +106,7 @@ extension TodoEditWorkflow {
// MARK: Rendering
extension TodoEditWorkflow {
- typealias Rendering = BackStackScreen.Item
+ typealias Rendering = BackStackScreen<AnyScreen>.Item
func render(state: TodoEditWorkflow.State, context: RenderContext<TodoEditWorkflow>) -> Rendering {
// The sink is used to send actions back to this workflow.
@@ -125,13 +125,13 @@ extension TodoEditWorkflow {
let backStackItem = BackStackScreen.Item(
key: "edit",
- screen: todoEditScreen,
- barContent: BackStackScreen.BarContent(
+ screen: todoEditScreen.asAnyScreen(),
+ barContent: .init(
title: "Edit",
leftItem: .button(.back(handler: {
sink.send(.discardChanges)
})),
- rightItem: .button(BackStackScreen.BarContent.Button(
+ rightItem: .button(.init(
content: .text("Save"),
handler: {
sink.send(.saveChanges)

MODIFY
swift/Samples/Tutorial/Frameworks/Tutorial5Complete/Sources/Todo/List/TodoListWorkflow.swift
swift/Samples/Tutorial/Frameworks/Tutorial5Complete/Sources/Todo/List/TodoListWorkflow.swift
@@ -93,7 +93,7 @@ extension TodoListWorkflow {
// MARK: Rendering
extension TodoListWorkflow {
- typealias Rendering = BackStackScreen.Item
+ typealias Rendering = BackStackScreen<AnyScreen>.Item
func render(state: TodoListWorkflow.State, context: RenderContext<TodoListWorkflow>) -> Rendering {
// Define a sink to be able to send the .onBack action.
@@ -112,14 +112,14 @@ extension TodoListWorkflow {
let todoListItem = BackStackScreen.Item(
key: "list",
- screen: todoListScreen,
- barContent: BackStackScreen.BarContent(
+ screen: todoListScreen.asAnyScreen(),
+ barContent: .init(
title: "Welcome \(name)",
leftItem: .button(.back(handler: {
// When the left button is tapped, send the .onBack action.
sink.send(.onBack)
})),
- rightItem: .button(BackStackScreen.BarContent.Button(
+ rightItem: .button(.init(
content: .text("New Todo"),
handler: {
sink.send(.new)

MODIFY
swift/Samples/Tutorial/Frameworks/Tutorial5Complete/Sources/Todo/TodoWorkflow.swift
swift/Samples/Tutorial/Frameworks/Tutorial5Complete/Sources/Todo/TodoWorkflow.swift
@@ -133,7 +133,7 @@ extension TodoWorkflow {
// MARK: Rendering
extension TodoWorkflow {
- typealias Rendering = [BackStackScreen.Item]
+ typealias Rendering = [BackStackScreen<AnyScreen>.Item]
func render(state: TodoWorkflow.State, context: RenderContext<TodoWorkflow>) -> Rendering {
let todoListItem = TodoListWorkflow(

MODIFY
swift/Samples/Tutorial/Frameworks/Tutorial5Complete/Tests/TodoWorkflowTests.swift
swift/Samples/Tutorial/Frameworks/Tutorial5Complete/Tests/TodoWorkflowTests.swift
import BackStackContainer
import WorkflowTesting
import XCTest
+import Workflow
@testable import Tutorial5
class TodoWorkflowTests: XCTestCase {
@@ -39,7 +40,7 @@ class TodoWorkflowTests: XCTestCase {
screen: TodoListScreen(
todoTitles: ["Title"],
onTodoSelected: { _ in }
- )),
+ ).asAnyScreen()),
// Simulate selecting the first todo:
output: TodoListWorkflow.Output.selectTodo(index: 0)
),
@@ -81,7 +82,7 @@ class TodoWorkflowTests: XCTestCase {
screen: TodoListScreen(
todoTitles: ["Title"],
onTodoSelected: { _ in }
- ))
+ ).asAnyScreen())
),
// Expect the TodoEditWorkflow. Additionally, simulate it emitting an output of ".save" to update the state.
ExpectedWorkflow(
@@ -91,7 +92,7 @@ class TodoWorkflowTests: XCTestCase {
note: "Note",
onTitleChanged: { _ in },
onNoteChanged: { _ in }
- )),
+ ).asAnyScreen()),
output: TodoEditWorkflow.Output.save(TodoModel(
title: "Updated Title",
note: "Updated Note"

Fix Tutorial code