I am trying to learn Swift and Composable Architecture, and I am following this tutorial. Now the above code works as expected, I having issue with showing different views in the same sheet. I have created another destination from LoginView
like below
struct LoginFeature: Reducer {
...
...
var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .forgotPasswordButtonTapped:
state.destination = .forgotPassword(
ForgotPasswordFeature.State()
)
return .none
case .privacyPolicyButtonTapped:
state.destination = .privacyPolicy(
GeneralWebFeature.State(urlString: "<some link>")
)
return .none
...
...
}
and
extension LoginFeature {
struct Destination: Reducer {
enum State: Equatable {
case forgotPassword(ForgotPasswordFeature.State)
case privacyPolicy(GeneralWebFeature.State)
}
enum Action: Equatable {
case forgotPassword(ForgotPasswordFeature.Action)
case privacyPolicy(GeneralWebFeature.Action)
}
var body: some ReducerOf<Self> {
Scope(state: /State.forgotPassword, action: /Action.forgotPassword) {
ForgotPasswordFeature()
}
Scope(state: /State.privacyPolicy, action: /Action.privacyPolicy) {
GeneralWebFeature()
}
}
}
}
Now the problem is how to modify this sheet
to support multiple views since the state
and action
param does not support multiple actions, or this a wrong approach?
.sheet(
store: self.store.scope(
state: \.$destination,
action: { .destination($0) }
),
state: /LoginFeature.Destination.State.forgotPassword,
action: LoginFeature.Destination.Action.forgotPassword
) { forgotPasswordStore in
NavigationStack {
ForgotPasswordView(store: forgotPasswordStore)
}
}
Little help will be highly appreciated, thank you.
Add another sheet modifier to handle the privacyPolicy destination. See sample below: