Skip to content

A SwiftUI-based toast notification system for iOS and macOS applications.

License

Notifications You must be signed in to change notification settings

nookery/MagicAlert

Repository files navigation

MagicAlert

中文

A SwiftUI-based toast notification system for iOS and macOS applications.

Features

  • Toast Notifications: Display temporary messages to users
  • Multiple Toast Types: Success, error, warning, and info toasts
  • Customizable Styling: Easily customize appearance and behavior
  • Error Handling: Built-in error view component
  • SwiftUI Native: Fully built with SwiftUI for modern apps

Screenshots

MagicAlert Demo

Installation

Swift Package Manager

Add MagicAlert as a dependency to your Package.swift:

dependencies: [
    .package(url: "https://github.com/nookery/MagicAlert.git", from: "1.0.0")
]

Or add it directly in Xcode:

  1. Go to File → Add Packages...
  2. Enter the repository URL: https://github.com/nookery/MagicAlert.git
  3. Choose the version you want to use

Usage

Add the .withMagicToast() modifier to your root view and use MagicMessageProvider.shared to display messages:

import SwiftUI
import MagicAlert

struct ContentView: View {
    var body: some View {
        VStack {
            Button("Show Success") {
                MagicMessageProvider.shared.success("Operation successful")
            }

            Button("Show Error") {
                MagicMessageProvider.shared.error("Operation failed")
            }

            Button("Show Info") {
                MagicMessageProvider.shared.info("This is an info message")
            }

            Button("Show Warning") {
                MagicMessageProvider.shared.warning("Please be careful")
            }

            Button("Show Loading") {
                MagicMessageProvider.shared.loading("Processing...")
            }
        }
        .withMagicToast() // Enable toast functionality
    }
}

Requirements

  • iOS 17.0+
  • macOS 14.0+
  • Swift 5.9+

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A SwiftUI-based toast notification system for iOS and macOS applications.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages