Commit 6f65cc3
authored
refactor(tabs): replace isNativeAction with actionOrigin enum (#3949)
## Description
Replaces the boolean `isNativeAction` field on the `onTabSelected` event
with a three-valued `actionOrigin` discriminator (`'user' |
'programmatic-js' | 'implicit'`).
Important thing to note here is that this change also enables us to add
more action origins in the future, such as native-programmatic actions.
One thing I'm not proud of is that the React model details are leaked
into the `TabsContainer` (`TabsContainer` / `RNSTabBarController` on
Android & iOS respectively). It now recognizes different sources
including the `programmatic-js`.
This is not great, but it shouldn't hinder us later when attempting to
test it natively.
The boolean was lossy: it conflated JS-driven updates with implicit
UIKit-driven selection changes (e.g. iPad horizontal size-class
transitions where UIKit reshuffles the selected tab as a side effect).
Consumers that needed to react to JS-originated transitions specifically
had no way to distinguish them. Promoting the field to an enum makes the
actor explicit at the API boundary; on iOS it also lets us collapse the
previous internal `RNSTabsNavigationStateUpdateSource` taxonomy into a
single shared enum (`RNSTabsActionOrigin`).
## Changes
- Public TS API: `isNativeAction: boolean` → `actionOrigin: 'user' |
'programmatic-js' | 'implicit'` on `TabSelectedEvent` (and the matching
codegen specs for iOS / Android native components).
- iOS:
- New `RNSTabsActionOrigin` enum (`User`, `ProgrammaticJs`, `Implicit`)
declared in `RNSTabsNavigationState.h`.
- Removed the now-redundant `RNSTabsNavigationStateUpdateSource` enum;
`progressNavigationState:withSource:` becomes
`progressNavigationState:withOrigin:`.
- `RNSTabsNavigationStateUpdateContext.isNativeAction` → `actionOrigin`;
propagated through `OnTabSelectedPayload` and the event emitter, with an
Obj-C → codegen-enum conversion in `RNSConversions-Tabs.mm`.
- The implicit reconciliation path (More-controller size-class
transition) now reports `Implicit` instead of being lumped into
`isNativeAction = YES`.
- Android:
- New `TabsActionOrigin` enum (`USER`, `PROGRAMMATIC_JS`) under
`gamma.tabs.container`. `'implicit'` is iOS-only at the moment and not
currently produced on Android — documented in the enum's KDoc.
- Threaded through `TabsContainerDelegate.onNavStateUpdate`,
`TabsHostEventEmitter`, and `TabsHostTabSelectedEvent` (event payload
key `actionOrigin`, serialized via `enum.toString()`).
## Test plan
No new automated tests; this is a rename/refactor of an existing public
field with no behavioral change on the user/JS paths. The implicit path
on iOS now reports a distinct origin where it previously reported
`isNativeAction = YES`, so manual verification on the affected
platforms:
- iOS — tab bar tap → `actionOrigin === 'user'`.
- iOS — JS-driven `navStateRequest` update → `actionOrigin ===
'programmatic-js'`.
- iOS — iPad horizontal size-class transition that collapses/expands the
More controller → `actionOrigin === 'implicit'` (previously
`isNativeAction: true`, now distinguishable).
- Android — tab bar tap → `actionOrigin === 'user'`; JS-driven update →
`actionOrigin === 'programmatic-js'`.
Reproduction lives in `FabricExample` Tabs test screens; log
`e.nativeEvent.actionOrigin` from `onTabSelected`.
## Checklist
- [ ] Included code example that can be used to test this change.
- [ ] For visual changes, included screenshots / GIFs / recordings
documenting the change.
- [x] For API changes, updated relevant public types.
- [ ] Ensured that CI passes1 parent ec0ea94 commit 6f65cc3
17 files changed
Lines changed: 101 additions & 46 deletions
File tree
- android/src/main/java/com/swmansion/rnscreens/gamma/tabs
- container
- host
- event
- ios
- conversion
- tabs/host
- src
- components/tabs/host
- fabric/tabs
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
| 380 | + | |
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
162 | | - | |
| 163 | + | |
163 | 164 | | |
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
168 | 169 | | |
169 | | - | |
| 170 | + | |
170 | 171 | | |
171 | 172 | | |
172 | 173 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | | - | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | | - | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
236 | 253 | | |
237 | 254 | | |
238 | 255 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | | - | |
| 239 | + | |
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | | - | |
258 | | - | |
| 257 | + | |
259 | 258 | | |
260 | 259 | | |
261 | 260 | | |
| |||
277 | 276 | | |
278 | 277 | | |
279 | 278 | | |
280 | | - | |
| 279 | + | |
281 | 280 | | |
282 | 281 | | |
283 | 282 | | |
| |||
299 | 298 | | |
300 | 299 | | |
301 | 300 | | |
302 | | - | |
| 301 | + | |
303 | 302 | | |
304 | 303 | | |
305 | 304 | | |
| |||
517 | 516 | | |
518 | 517 | | |
519 | 518 | | |
520 | | - | |
| 519 | + | |
521 | 520 | | |
522 | 521 | | |
523 | 522 | | |
| |||
574 | 573 | | |
575 | 574 | | |
576 | 575 | | |
577 | | - | |
578 | | - | |
| 576 | + | |
579 | 577 | | |
580 | 578 | | |
581 | 579 | | |
| |||
587 | 585 | | |
588 | 586 | | |
589 | 587 | | |
590 | | - | |
| 588 | + | |
591 | 589 | | |
592 | 590 | | |
593 | 591 | | |
| |||
666 | 664 | | |
667 | 665 | | |
668 | 666 | | |
669 | | - | |
| 667 | + | |
670 | 668 | | |
671 | 669 | | |
672 | 670 | | |
673 | 671 | | |
674 | | - | |
| 672 | + | |
675 | 673 | | |
676 | 674 | | |
677 | 675 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
612 | | - | |
| 612 | + | |
613 | 613 | | |
614 | 614 | | |
615 | 615 | | |
| |||
0 commit comments