Swiftpack.co - Naturally-Inviting/swift-tca-custom-alert as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Naturally-Inviting.
Naturally-Inviting/swift-tca-custom-alert 0.2.0
Custom modals and alerts using SwiftUI and TCA!
⭐️ 3
🕓 4 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/Naturally-Inviting/swift-tca-custom-alert.git", from: "0.2.0")

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-alert 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

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)
            }
        )
    }
}

Demo

This demo application can be accessed via TCACustomAlert.xcworkspace.

Presentation Demo

🏎️ Road Map

  • ☑ Tests
  • ☐ Accessibility

GitHub

link
Stars: 3
Last commit: 4 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Initial release
1 year ago

A small library for presenting custom alerts using SwiftUI and The Composable Architecture (TCA).

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics