Skip to content

Update how handler configuration is handled on Android #3484

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

j-piasecki
Copy link
Member

Description

All handler factories were stored in the RNGestureHandlerModule which always seemed like an odd place to keep them in to me. This PR moves each factory to be a nested class of the relevant gesture handler. This gives us private access to the handler inside the factory, which in turn allows to get rid of the setter methods and assign directly instead. Those were with use since RNGH was written in java, but we have Kotlin now. It's time to let go and use proper syntax.

It also adds default constants for each config property that didn't have it before.

Test plan

Example app


fun setMinNumberOfPointers(minNumberOfPointers: Int) = apply {
this.minNumberOfPointers = minNumberOfPointers
shouldCancelWhenOutside = DEFAULT_SHOULD_CANCEL_WHEN_OUTSIDE
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like shouldCancelWhenOutside was reset to false on every config update so the default in the initializer wasn't doing anything 🙈

this.disallowInterruption = disallowInterruption
shouldActivateOnStart = DEFAULT_SHOULD_ACTIVATE_ON_START
disallowInterruption = DEFAULT_DISALLOW_INTERRUPTION
shouldCancelWhenOutside = DEFAULT_SHOULD_CANCEL_WHEN_OUTSIDE
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

numberOfPointersRequired = numberOfPointers
return this
maxDist = defaultMaxDist
shouldCancelWhenOutside = DEFAULT_SHOULD_CANCEL_WHEN_OUTSIDE
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

@j-piasecki j-piasecki requested a review from m-bert April 17, 2025 11:58
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

Successfully merging this pull request may close these issues.

1 participant