Add Screen.asAnyScreen() convenience
MODIFY
swift/Samples/TicTacToe/Sources/Authentication/AuthenticationWorkflow.swift
swift/Samples/TicTacToe/Sources/Authentication/AuthenticationWorkflow.swift
@@ -176,7 +176,7 @@ extension AuthenticationWorkflow {
return .login(email: email, password: password)
}
}.rendered(with: context)
- backStackItems.append(BackStackScreen.Item(screen: AnyScreen(loginScreen), barVisibility: .hidden))
+ backStackItems.append(BackStackScreen.Item(screen: loginScreen.asAnyScreen(), barVisibility: .hidden))
switch state {
case .emailPassword:
@@ -252,7 +252,7 @@ extension AuthenticationWorkflow {
)
return BackStackScreen.Item(
- screen: AnyScreen(twoFactorScreen),
+ screen: twoFactorScreen.asAnyScreen(),
barVisibility: .visible(BackStackScreen.BarContent(
leftItem: BackStackScreen.BarContent.BarButtonItem.button(BackStackScreen.BarContent.Button(
content: .text("Cancel"),

MODIFY
swift/Samples/TicTacToe/Sources/Game/RunGameWorkflow.swift
swift/Samples/TicTacToe/Sources/Game/RunGameWorkflow.swift
@@ -92,11 +92,11 @@ extension RunGameWorkflow {
var alert: Alert?
var backStackItems: [BackStackScreen<AnyScreen>.Item] = [BackStackScreen.Item(
- screen: AnyScreen(newGameScreen(
+ screen: newGameScreen(
sink: sink,
playerX: state.playerX,
playerO: state.playerO
- )),
+ ).asAnyScreen(),
barVisibility: .hidden
)]
@@ -111,7 +111,7 @@ extension RunGameWorkflow {
)
.rendered(with: context)
backStackItems.append(BackStackScreen.Item(
- screen: AnyScreen(takeTurnsScreen),
+ screen: takeTurnsScreen.asAnyScreen(),
barVisibility: .visible(BackStackScreen.BarContent(
leftItem: BackStackScreen.BarContent.BarButtonItem.button(BackStackScreen.BarContent.Button(
content: .text("Quit"),
@@ -130,7 +130,7 @@ extension RunGameWorkflow {
)
.rendered(with: context)
backStackItems.append(BackStackScreen.Item(
- screen: AnyScreen(takeTurnsScreen),
+ screen: takeTurnsScreen.asAnyScreen(),
barVisibility: .visible(BackStackScreen.BarContent(
leftItem: BackStackScreen.BarContent.BarButtonItem.button(BackStackScreen.BarContent.Button(
content: .text("Quit"),

MODIFY
swift/WorkflowUI/Sources/Screen/AnyScreen/AnyScreen.swift
swift/WorkflowUI/Sources/Screen/AnyScreen/AnyScreen.swift
}
}
+ extension Screen {
+ /// Wraps the screen in an AnyScreen
+ public func asAnyScreen() -> AnyScreen {
+ AnyScreen(self)
+ }
+ }
+
#endif

Add Screen.asAnyScreen() convenience