Skip to content

Commit

Permalink
doc: Add SwiftUI section
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeWeidmann committed Jan 20, 2025
1 parent f6c08d1 commit 058eb8e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ A view that tries to replicate iOS default toast message view.
Add this lib to your project using SPM or Cocoapods.

To get the simple "Apple look" you only have to do this:

## UIKit

```swift
import NotificationToast

Expand All @@ -37,6 +40,28 @@ You can present the view with a haptic feedback at the same time (`nil` by defau
toast.show(haptic: .success)
```

## SwiftUI

```swift
@State var isPresented = false

Button("Present toast") {
isPresented = true
}
.toast(isPresented: $isPresented, title: "Safari pasted from Notes")
```

Similarly to UIKit, you can customize the view using the optional parameters (see auto-completion for all the options):
```swift
@State var isPresented = false

Button("Present toast") {
isPresented = true
}
.toast(isPresented: $isPresented, title: "AirPods Pro", subtitle: "Connected", icon: UIImage(systemName: "airpodspro"))
```


# Contribute
As this is my first 'UI' package I'm sure it can be greatly improved, PR are welcome 😊

Expand Down

0 comments on commit 058eb8e

Please sign in to comment.