Comments (4)
You can use the completion handler to take an action:
.toast(isPresenting: $showAlert, duration: 2, tapToDismiss: true, alert: {
//AlertToast Goes Here
}, completion: { dismissed in
//Completion block after dismiss (returns true)
})
Hope this answers your question.
from alerttoast.
I tried that, but it's always called with true. So I can't differentiate between user tapping on to dismiss, or it just being auto dismissed after 2 seconds. The same complexion handler is called on both occasions.
from alerttoast.
I've now added a new handler onTap
that you can use.
.toast(isPresenting: $showAlert, duration: 2, tapToDismiss: true, alert: {
//AlertToast Goes Here
}, onTap: {
//On tap would call either `tapToDismiss` is false/true
//If tapToDismiss is true, this action would call and then dismiss the alert
}, completion: {
//Completion block after dismiss WITHOUT escaping variables
})
Don't forget to set duration
to 0 if you don't want the alert to be auto dismissed.
If you don't get the update in few minutes, try adding with SPM from the master branch.
In the next update, all add this function as a function to AlertToast
type.
Would look like this:
AlertToast(type: .regular, title: "Next Update")
.onTap{
//Actions goes here
}
Watch
the repo if you would like to be notified.
from alerttoast.
Amazing that’s great. Thanks.
from alerttoast.
Related Issues (20)
- Cannot find 'AlertStyle' in scope HOT 1
- No linebreaks in subtitle? HOT 9
- Toaster not clearing on first call HOT 5
- Background opacity of View when AlertToast type hud HOT 3
- Default alert width is too small to show message HOT 5
- Loading Toast Cannot Be Dismissed HOT 1
- toast<Item>(item: Binding<Item?>, content: (Item) -> AlertToast) modifier HOT 2
- Alert isn't positioning correctly under iOS 16 HOT 1
- tvOS compatibility possible? HOT 1
- Swipe to dismiss toast HOT 1
- If type is .loading, its background parent view is still clickable HOT 2
- No toast! Have implemented per instructions, but the AlertToast() does not respond with any visualisation. Have traced that it gets called, but nothing happens on screen. - Xcode 14.2, SwiftUI, iOS 16.2, Simulator and physical device. HOT 1
- Long Subtitle text doesn't correctly wrap in DisplayMode "hub" or "banner" HOT 6
- Toast Window Not Large Enough On MacOS: The text gets truncated and replaced with "..."
- Popover cuts off `.hud` alert HOT 5
- Create Example Project HOT 1
- The subtitle line gets cut off on iOS banners HOT 1
- Not usable as global modifier when sheet is presented HOT 7
- Is there any way to set the toast always on the top of screen, instead of on the center of view HOT 1
- System image not being displayed when AlertToast added to a package.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alerttoast.