GithubHelp home page GithubHelp logo

Comments (4)

elai950 avatar elai950 commented on May 18, 2024

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.

helloniklas avatar helloniklas commented on May 18, 2024

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.

elai950 avatar elai950 commented on May 18, 2024

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.

helloniklas avatar helloniklas commented on May 18, 2024

Amazing that’s great. Thanks.

from alerttoast.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.