Skip to content

Is there a pretty way of presenting multiple alerts via destination enum? #3501

Closed Answered by mbrandonw
iharandreyev asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @iharandreyev, there is no need for the SomeAlert reducer. You can just use AlertState directly in your Destination and it will work fine. Here's a fix to your code:

import SwiftUI

@Reducer
struct SheetFeature { }

@Reducer
struct MultipleAlertsFeature {
  @ObservableState
  struct State {
    @Presents
    var destination: Destination.State?
  }

  @CasePathable
  enum Action {
    case destination(PresentationAction<Destination.Action>)

    case showProceedAlertButtonTapped
    case showInfoAlertButtonTapped
    case showSheetButtonTapped
  }

  @Reducer
  enum Destination {
    case proceedAlert(AlertState<ProceedingAlertAction>)
    case infoAlert(AlertState<InfoAlertAction>)
    c…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by iharandreyev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants