Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: add onPressIn / onPressOut to the api #17

Open
yangtavour opened this issue May 18, 2021 · 1 comment
Open

Feature Request: add onPressIn / onPressOut to the api #17

yangtavour opened this issue May 18, 2021 · 1 comment

Comments

@yangtavour
Copy link

I'd love the ability to be able to run callbacks that trigger based on user's touch.. For example, for the onPressIn and onPressOut events, I'm trying to dynamically render a rating display UI Component based on when the user is actively rating / touching the component or not.. Unfortunately I can't do that with the current API it seems and wrapping it in a TouchableOpacity or other touch sensing component (TouchableWithoutFeedback), makes the component behave as if it were readonly..

My initial guess / intuition is that it looks like the highest level TouchableOpacity takes precedence over the lower ones.. Is there a way to insert a call back for those properties here that I'm missing, and if not, would it be difficult to pass down a callback into whatever component is capable of handling onPress events?

What I'm attempting to do:

  <TouchableOpacity
          activeOpacity={1}
          onPressIn={() => setActivelyRating(true)}
          onPressOut={() => setActivelyRating(false)}
        >
          <StarRatingBar
            testID={testID}
            starStyle={getStarStyles({ disabled, size, customSizes })}
            readOnly={false}
            dontShowScore
            spacing={10}
            valueToFix={1} // accuracy of decimals
            continuous
            score={+rating}
            allowsHalfStars
            accurateHalfStars
            tintColor={getTintColor({ disabled })}
            onStarValueChanged={val => handleStarChange(val)}
            scoreTextStyle={getRatingTextStyle({ disabled, size })}
          />
</TouchableOpacity>
@yangtavour
Copy link
Author

Also, onFinishRating would be nice.. I'm currently having to debounce my onStarValueChange to mimick that effect.. I want a callback that fires only once after the users thumb has left the screen.. Unfortunately, due to the TouchableOpacity issue above, it looks like I can't roll out my own onFinishRating either..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant