Skip to content

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

@yangtavour

Description

@yangtavour

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions