Skip to content

inekipelov/swiftui-alert-advance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alert Advance

Swift Version SPM License Swift Tests
iOS

Embed SwiftUI views inside UIAlertController alerts and action sheets with simple alertContent and confirmationDialogContent modifiers.

Highlights

  • Custom SwiftUI content inside UIAlertController.
  • Drop-in modifiers – no need to rework existing alerts or confirmation dialogs.

Preview

Alert content Confirmation dialog content
Alert preview Confirmation dialog preview

Usage

import SwiftUI
import AlertAdvance

struct ContentView: View {
    @State private var showAlert = false
    @State private var showSheet = false

    var body: some View {
        VStack(spacing: 16) {
            Button("Show alert") { showAlert = true }
                .alert("Title", isPresented: $showAlert) {
                    Button("OK") {}
                }
                .alertContent(isPresented: $showAlert) {
                    VStack {
                        Text("Custom alert content")
                        ProgressView()
                    }
                    .padding()
                }

            Button("Show confirmation") { showSheet = true }
                .confirmationDialog("Title", isPresented: $showSheet) {
                    Button("Action") {}
                }
                .confirmationDialogContent(isPresented: $showSheet) {
                    VStack {
                        Text("Custom sheet content")
                        Image(systemName: "hand.thumbsup.fill")
                    }
                    .padding()
                }
        }
        .padding()
    }
}

Installation

Add via Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/inekipelov/swiftui-alert-advance.git", from: "0.1.0")
],
targets: [
    .target(
        name: "YourTarget",
        dependencies: [
            .product(name: "AlertAdvance", package: "swiftui-alert-advance")
        ]
    )
]

About

SwiftUI helpers that let you embed custom SwiftUI views inside UIAlertController

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages