Commit 0fbe872
authored
[Android] Configure the button's handler directly instead of through a
## Description
The button's managed handler was configured by building a `ReadableMap`
and pushing it through `updateGestureHandlerConfig`, which then parsed
it straight back out. Since both ends are native, the map is pure
overhead on every prop transaction.
`NativeViewGestureHandler` gained a typed `Config` (plus a `HitSlop`)
data class and an `updateConfig` that applies it directly, and the view
manager now builds that instead of a map. `gestureHitSlop` is converted
from DIPs to pixels once, when the prop is set, rather than on every
config write.
Two things fell out of the rewrite:
- Handlers are created with an empty config and attached only *after*
`updateConfig` runs. Setting `enabled = false` on an already-attached
handler cancels it, so a button mounted as disabled used to dispatch a
pointless cancel event right after mount.
- `GestureHandler.isEnabled`'s setter is now `protected` so subclasses
can apply it.
## Test plan
- Buttons behave the same as before across
press/cancel/hit-slop/testID/enabled changes.
- Mounting a button with `enabled={false}` no longer emits a cancel
event.
- Confirmed `hitSlop` values still land in pixels (visually, against a
button with a large slop).ReadableMap (#4358)1 parent 7dc8dec commit 0fbe872
3 files changed
Lines changed: 82 additions & 23 deletions
File tree
- packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler
- core
- react
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
71 | 87 | | |
72 | 88 | | |
73 | 89 | | |
| |||
225 | 241 | | |
226 | 242 | | |
227 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
228 | 262 | | |
229 | 263 | | |
230 | 264 | | |
| |||
Lines changed: 47 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
106 | 121 | | |
107 | 122 | | |
108 | 123 | | |
| |||
439 | 454 | | |
440 | 455 | | |
441 | 456 | | |
442 | | - | |
| 457 | + | |
443 | 458 | | |
444 | 459 | | |
445 | 460 | | |
446 | 461 | | |
447 | 462 | | |
448 | 463 | | |
449 | 464 | | |
| 465 | + | |
450 | 466 | | |
451 | | - | |
| 467 | + | |
452 | 468 | | |
453 | 469 | | |
454 | | - | |
455 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
456 | 484 | | |
457 | 485 | | |
458 | | - | |
459 | 486 | | |
460 | | - | |
461 | | - | |
462 | 487 | | |
463 | 488 | | |
464 | 489 | | |
| |||
467 | 492 | | |
468 | 493 | | |
469 | 494 | | |
470 | | - | |
| 495 | + | |
471 | 496 | | |
472 | 497 | | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
484 | 509 | | |
485 | 510 | | |
486 | 511 | | |
| |||
512 | 537 | | |
513 | 538 | | |
514 | 539 | | |
515 | | - | |
| 540 | + | |
516 | 541 | | |
517 | 542 | | |
518 | 543 | | |
| |||
526 | 551 | | |
527 | 552 | | |
528 | 553 | | |
529 | | - | |
| 554 | + | |
530 | 555 | | |
531 | 556 | | |
532 | 557 | | |
| |||
0 commit comments