Skip to content

Commit

Permalink
Merge pull request #2 from mentalflux/confirmation-dialog-fix
Browse files Browse the repository at this point in the history
Restore missing @ComposeActionConfirmationDialogCase macro
  • Loading branch information
scogeo authored Feb 14, 2024
2 parents e042b51 + 9d916a9 commit 9f2f26c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/TCAComposer/Macros/ComposeMacros.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ public macro ComposeActionAlertCase(_ name: String = "") =
module: "TCAComposerMacros", type: "ComposeDirectiveMacro"
)

/// Specifies the enum to use for the `ConfirmationDialogAction` for a confirmation dialog declared in a ``ComposeReducer(_:children:)`` child.
///
/// This is an alternative method of declaring confirmation dialogs
@attached(peer)
public macro ComposeActionConfirmationDialogCase(_ name: String = "") =
#externalMacro(
module: "TCAComposerMacros", type: "ComposeDirectiveMacro"
)

/// Directs ``Composer()`` to generate `CasePath`s on an existing `Action` enum. The macro should only be attached
/// to an empty `AllCasePaths` struct declaration inside of the `Action`
@attached(peer)
Expand Down
38 changes: 38 additions & 0 deletions Tests/TCAComposerTests/TestReducers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,44 @@ struct CounterParentWithExistingStateAndAction {
}
}

// MARK: Alerts and Confirmation Dialogs

@ComposeReducer(
children: [
.presentsAlert()
]
)
@Composer
struct PresentsAlertReducer {

@ComposeActionAlertCase
enum AlertAction {
case confirmDelete
}

@ComposeBody(action: \Action.Cases.alert.confirmDelete)
func handleAlert() {}

}

@ComposeReducer(
children: [
.presentsConfirmationDialog()
]
)
@Composer
struct PresentsConfirmationDialogReducer {

@ComposeActionConfirmationDialogCase
enum ConfirmationDialogAction {
case confirmDelete
}

@ComposeBody(action: \Action.Cases.confirmationDialog.confirmDelete)
func handleConfirmationDialog() {}
}


// MARK: Navigation Destination

@ComposeReducer(
Expand Down

0 comments on commit 9f2f26c

Please sign in to comment.