react-native-root-toast icon indicating copy to clipboard operation
react-native-root-toast copied to clipboard

Feature Request: Can We Introduce OnPress() For Custom Buttons On The Toast?

Open KhalilKhalaf opened this issue 8 years ago • 4 comments

First off, thanks for the great project + maintenance.

The project has a hideOnPress() property, therefore user can interact with the toast. Can we expose the OnPress() so that we can add button(s) on the toast?

Usage would be:

User enters some invalid info, then toast would be:

you entered invalid info.
button: Reset 
another button: Save Anyway

KhalilKhalaf avatar Oct 02 '17 14:10 KhalilKhalaf

+1

NikolaRavic avatar Sep 30 '18 21:09 NikolaRavic

+2

LeslieJAnderson avatar Mar 04 '19 19:03 LeslieJAnderson

For anyone finding this, onPress is already exposed -- just not documented.

let toast = Toast.show("This is a message", { duration: Toast.durations.LONG, position: Toast.positions.TOP, shadow: true, animation: true, hideOnPress: true, delay: 0, onPress: () => { // calls on toast being pressed }, onShow: () => { // calls on toast\s appear animation start }, onShown: () => { // calls on toast`s appear animation end. }, onHide: () => { // calls on toast`s hide animation start. }, onHidden: () => { // calls on toast`s hide animation end. } });`

mschiano avatar Jul 09 '19 15:07 mschiano

~~Yes, although the function receives no information from the toast so it's difficult to act on the keypress in any meaningful way.~~

Because this is set on the toast options for the particular notification, of course you can load in whatever action you want. I think this can be closed.

CC: https://github.com/magicismight/react-native-root-toast/pull/10

bradjones1 avatar Dec 31 '21 02:12 bradjones1