Skip to content

ankush445/FancyToastKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FancyToastKit 🍞✨

A lightweight and customizable toast notification library built with SwiftUI.


✨ Features

  • ✅ SwiftUI native (ViewModifier based)
  • ✅ Multiple toast styles (Success, Error, Warning, Info)
  • ✅ Auto dismiss with duration
  • ✅ Smooth animations
  • ✅ Haptic feedback (iOS)
  • ✅ Accessibility support (VoiceOver)
  • ✅ iPhone & iPad support
  • ✅ Zero dependencies

📦 Installation

Swift Package Manager

  1. Open your project in Xcode
  2. Go to File → Add Packages
  3. Enter:
https://github.com/ankush445/FancyToastKit.git
  1. Add the package to your target

📥 Import

After adding the package, import it in your file:

import FancyToastKit

⚠️ Make sure the module name matches your package target name (FancyToastKit)


🚀 Usage

1. Create State

@State private var toast: FancyToast?

2. Attach Modifier

var body: some View {
    ContentView()
        .toastView(toast: $toast)
}

3. Show Toast

toast = FancyToast(
    type: .success,
    title: "Success",
    message: "Profile updated successfully!",
    duration: 2.5
)

🎨 Toast Types

.success
.error
.warning
.info

🧠 How It Works

  • Uses a ViewModifier for easy integration
  • Displays toast from the top
  • Automatically dismisses after duration
  • Cancels previous toast if a new one appears
  • Includes smooth animation + transition

📱 Example

struct DemoView: View {
    @State private var toast: FancyToast?
    
    var body: some View {
        VStack {
            Button("Show Toast") {
                toast = FancyToast(
                    type: .error,
                    title: "Error",
                    message: "Something went wrong"
                )
            }
        }
        .toastView(toast: $toast)
    }
}

📁 Project Structure

F ancyToastKit/
│
├── Package.swift
├── README.md
│
└── Sources/
    └── FancyToastKit/
        ├── FancyToastKit.swift
        ├── FancyToastView.swift
        ├── FancyToastModifier.swift

♿ Accessibility

  • Automatically announces toast message using VoiceOver

🛠 Customization

You can customize:

  • Toast duration
  • Colors (via FancyToastStyle)
  • Layout inside FancyToastView
  • Animation inside FancyToastModifier

🤝 Contributing

Pull requests are welcome! Feel free to open issues or suggest improvements.


📄 License

MIT License


👨‍💻 Author

Ankush Mittal


⭐️ Support

If you like this project, give it a ⭐️ on GitHub!

Releases

No releases published

Packages

 
 
 

Contributors

Languages