swift-tca-custom-alert

main

Custom modals and alerts using SwiftUI and TCA!
Naturally-Inviting/swift-tca-custom-alert

TCACustomAlert

📝 Description

This package allows for custom alert presentation with The Composable Architecture from Point-Free.

Installation

Install in Xcode as a package dependency.

  1. From the File menu, select Add Packages...
  2. Enter "https://github.com/Naturally-Inviting/swift-tca-custom-aler" into the package URL field.

Basics

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

WithViewStore(store) { _ in 
  VStack {
    ContentView()
  }
  .customTcaAlert(
    store.scope(
        state: \.alertState,
        action: AlertDemoReducer.Action.alert
    ),
    content: {
        VStack(spacing: 16) {
            Text("Hello")
                .font(.headline)
            Button("Dismiss", action: { viewStore.send(.alert(.dismiss)) })
                .padding(.top)
        }
        .padding()
        .background()
        .cornerRadius(8)
        .padding(.horizontal)
    }
  )
}

Demo

This demo application can be accessed via TCACustomAlert.xcworkspace.

Presentation Demo

🏎️ Road Map

  • Tests
  • Accessibility

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

Last updated: Wed Jan 25 2023 15:02:11 GMT-0500 (GMT-05:00)