Awesome
:bread: Toaster
<img width="297" alt="image" src="https://user-images.githubusercontent.com/5355966/227464882-4d0442e0-a186-470e-ba99-597c502168fa.png">Installation
Add the git URL from Package Dependencies in Xcode.
https://github.com/ryohey/Toaster.git
Usage
Button("Show Toast") {
toast.present(.defaultSuccess(text: "Success!"))
}
Setup
- Add
@StateObject var toast = ToastMessages()
- Add
.toast(_, layout:)
to the host view - Call
toast.present()
struct ContentView: View {
@StateObject var toast = ToastMessages()
var body: some View {
VStack {
Button("Show Toast") {
toast.present(.defaultSuccess(text: "Success!"))
}
}
.padding()
.toast(
toast,
layout: .init(padding: .init(
top: 0,
leading: 16,
bottom: 16,
trailing: 16
))
)
}
}