jkomyno/react-native-user-inactivity

Button press

apstone opened this issue · 4 comments

I am curious how hard it would be to be able to tell onAction if a user pressed a button (touchableWithoutFeedback). I like and appreciate the default behavior of this component but am curious if it would be able to add some more context to onAction, specifically if the user has pressed a certain button and handle that differently.

My situation is that onAction, I want to dismiss a modal, but inside that modal there is a button to navigate. Currently I cannot press this button because it will hide the modal.

Do you have any suggestions?

Hi, sorry for the tremendous delay, the new version (1.0.0) is in progress and if we can come up with a nice and intuitive API for your request, I'll gladly add it (or accept a PR that does it).
Currently, the package relies on PanResponder for detecting whether the user has touched a <View />.
Do you have any idea on how to retrieve some additional context on the press action using PanResponder?

@apstone I've found that each PanResponder method's first argument is an event, let's call it evt.
evt.nativeEvent.identifier contains the ID of the touched area.
For instance, if the touched surface is the component <View style={styles.container} id="a123">,
evt.nativeEvent.identifier will be a123.

@jkomyno That is a great find! I implemented this a different (hacky) way, but I think that you have found the correct solution. This may be useful in docs?

@apstone I'll add it to the docs as soon as v1.0.0 is ready to be released (my estimate is 13th August 2019)