CustomAlertKit

2.0.2

CustomAlertKit provides a customizable bottomsheet, snackbar and alert for any SwiftUI View. Available for CocoaPods and Swift Package Manager.
bence-t0th/CustomAlertKit

What's New

2.0.2 - Bugfixes

2024-06-19T09:00:19Z

CustomAlertKit

Version License Platform SPM

Installation

CustomAlertKit supports Swift Package Manager and CocoaPods.

Swift Package Manager

To install CustomAlertKit using Swift Package Manager you can follow the tutorial published by Apple using the URL for the repo:

  1. In Xcode, select “File” → “Add Packages Dependencies”
  2. Enter https://github.com/bence-t0th/CustomAlertKit.git

CocoaPods

Add the pod to your Podfile:

pod 'CustomAlertKit'

And then run:

pod install

After installing the cocoapod into your project import CustomAlertKit with

import CustomAlertKit

Usage

Bottomsheet

Bottomsheet

@State var bottomsheetVisible = false

var body: some View {
    ...
    }
    .bottomSheet(visible: $bottomsheetVisible, background: .blur(.regular), contentBackgroundColor: .white) {
        Text("This is a bottomsheet with blurred background")
            .frame(height: 250)
    }
}

Snackbar

Snackbar

@State var snackbarVisible = false

var body: some View {
    ...
    }
    .snackbar(visible: $snackbarVisible) {
        Text("This is a snackbar")
            .padding(16)
            .background(.green)
            .clipShape(Capsule())
    }
}

Alert

Alert

@State var alertVisible = false

var body: some View {
    ...
    }
    .alert(visible: $alertVisible, background: .color(.black.opacity(0.4))) {
        VStack {
            Text("This is an alert with opaque background")
            Button(action: {
                withAnimation {
                    alertVisible.toggle()
                }
            }, label: {
                Text("Close")
            })
        }
        .padding(32)
        .background(.red)
    }
}

Requirements

CustomAlertKit requires iOS 15 deployment target, and it is compatible only with SwiftUI.

Author

Bence Tóth

License

CustomAlertKit is available under the MIT license. See the LICENSE file for more info.

Description

  • Swift Tools 5.10.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Oct 18 2024 15:28:04 GMT-0900 (Hawaii-Aleutian Daylight Time)