This package allows for custom alert presentation with The Composable Architecture from Point-Free.
Install in Xcode as a package dependency.
- From the File menu, select Add Packages...
- Enter
https://github.com/Naturally-Inviting/swift-tca-custom-alert
into the package URL field.
To create an alert, you need to have a store which can scope the changes of CustomTcaAlert.State
and CustomTcaAlert.Action
. Then pass in a view as the alert content.
import TCACustomAlert
struct MyView: View {
let store: StoreOf<MyFeature>
var body: some View {
VStack {
ContentView()
}
.customTcaAlert(
store.scope(
state: \.alertState,
action: \.alert
),
content: {
VStack(spacing: 16) {
Text("Hello")
.font(.headline)
Button("Dismiss", action: { store.send(.alert(.dismiss)) })
.padding(.top)
}
.padding()
.background()
.cornerRadius(8)
.padding(.horizontal)
}
)
}
}
This demo application can be accessed via TCACustomAlert.xcworkspace
.
Presentation Demo |
---|
- Tests
- Accessibility