Contents

matthew-2000/swifttoast

**SwiftToast** is a lightweight and customizable SwiftUI library for displaying non-intrusive toast messages in your iOS/macOS applications. Designed for simplicity and flexibility, it allows you to show short notifications with custom styling and animations.

πŸš€ About SwiftToast

SwiftToast is a lightweight and customizable SwiftUI library for displaying non-intrusive toast messages in your iOS/macOS applications. Designed for simplicity and flexibility, it allows you to show short notifications with custom styling and animations.

✨ Features

  • πŸ“Œ Easy to use: Simple API for quick integration
  • 🎨 Customizable: Change colors, fonts, durations, and positions
  • 🎭 Smooth animations: Fade, slide, bounce, and more
  • 🎯 Positioning: Show toast at the top or bottom of the screen
  • πŸ”„ Supports Swift Package Manager (SPM)

πŸ“¦ Installation

Using Swift Package Manager (SPM)

  1. Open your Xcode project.
  2. Go to File > Add Packages...
  3. Enter the following URL:

`` https://github.com/matthew-2000/SwiftToast.git ``

  1. Choose Latest Version and click Add Package.

πŸ›  Usage

1️⃣ Basic Usage

To display a simple toast message:

import SwiftUI
import SwiftToast

struct ContentView: View {
    @State private var showToast = false
    
    var body: some View {
        VStack {
            Button("Show Toast") {
                showToast = true
            }
        }
        .toast(isPresented: $showToast, message: "Hello, SwiftToast!")
    }
}

2️⃣ Customization

You can customize the toast appearance, duration, and position:

.toast(
    isPresented: $showToast,
    message: "Customized Toast!",
    duration: 3,
    backgroundColor: .blue,
    textColor: .white,
    font: .headline,
    position: .top,
    animationStyle: .bounce
)
🎨 Customization Options:

| Parameter | Type | Default Value | Description | |------------------|--------------------|------------------------|-------------| | message | String | Required | The toast text | | duration | TimeInterval | 2 seconds | How long the toast is visible | | backgroundColor | Color | .black.opacity(0.8) | Background color | | textColor | Color | .white | Text color | | font | Font | .body | Font style | | position | VerticalAlignment | .bottom | .top or .bottom | | animationStyle | ToastAnimationStyle | .slide | .fade, .slide, .bounce, .scale, .custom(...) |


🎭 Animations

SwiftToast includes built-in animations, or you can add your own:

.toast(
    isPresented: $showToast,
    message: "Spring animation!",
    animationStyle: .spring(response: 0.5, dampingFraction: 0.6)
)

Available animations:

  • .fade β†’ Simple fade in/out
  • .slide β†’ Smooth slide transition
  • .bounce β†’ Spring-like bounce effect
  • .scale β†’ Scale-in effect
  • .custom(Animation) β†’ Use your own animation

βœ… Testing

To run unit tests:

swift test

Or, in Xcode: Cmd + U to run all tests.


🌟 Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature-name)
  3. Commit your changes (git commit -m "Add new feature")
  4. Push to the branch (git push origin feature-name)
  5. Open a pull request πŸš€

πŸ“„ License

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


πŸ’‘ Credits

Developed by Matteo Ercolino β€’ GitHub


πŸ“’ Support

If you find this project useful, ⭐️ star the repository and share it with others!


πŸš€ Happy coding with SwiftToast! πŸŽ‰

Package Metadata

Repository: matthew-2000/swifttoast

Default branch: main

README: README.md