also looking at this
fix(native): type tab visibility and back gesture options
#2093
3 files
+53
-0
| @@ -47,6 +47,10 @@ export interface NativeNavigationOptions { | ||
| 47 | 47 | title?: string |
| 48 | 48 | largeTitle?: boolean |
| 49 | 49 | hidden?: boolean |
| 50 | /** Hide the app's tab bar while this screen is visible. */ | |
| 51 | tabBarHidden?: boolean | |
| 52 | /** Allow the iOS interactive back gesture. Defaults to true. */ | |
| 53 | swipeBack?: boolean | |
| 50 | 54 | backTitle?: string |
| 51 | 55 | leftButtons?: NativeNavigationButton[] |
| 52 | 56 | rightButtons?: NativeNavigationButton[] |
| @@ -1,5 +1,7 @@ | ||
| 1 | 1 | import { describe, expect, it } from 'bun:test' |
| 2 | 2 | import { NativeCapabilityError, STXBridge } from '../../src/native/bridge/protocol' |
| 3 | import { installCraftBridge } from '../../src/native/runtime/craft-bridge' | |
| 4 | import type { NativeNavigationOptions } from '../../src/native/runtime/craft' | |
| 3 | 5 | |
| 4 | 6 | function host() { |
| 5 | 7 | const sent: Array<Record<string, any>> = [] |
| @@ -15,6 +17,23 @@ function host() { | ||
| 15 | 17 | } |
| 16 | 18 | |
| 17 | 19 | describe('typed native capability bridge', () => { |
| 20 | it.each(['ios', 'android'])('preserves screen chrome options and explicit navigation on %s', (platform) => { | |
| 21 | const native = host() | |
| 22 | const protocol = new STXBridge() | |
| 23 | protocol.initialize(native.bridge) | |
| 24 | const craft = installCraftBridge(protocol, { ...native.bridge, platform }, {}) | |
| 25 | const options: NativeNavigationOptions = { hidden: true, tabBarHidden: true, swipeBack: false } | |
| 26 | craft.navigation.setOptions(options) | |
| 27 | craft.navigation.open('/feed') | |
| 28 | craft.navigation.setOptions({ hidden: false, tabBarHidden: false, swipeBack: true }) | |
| 29 | expect(native.sent.map(({ type, payload }) => ({ type, payload }))).toEqual([ | |
| 30 | { type: 'NAVIGATION_SET_OPTIONS', payload: options }, | |
| 31 | { type: 'NAVIGATE_OPEN', payload: { path: '/feed' } }, | |
| 32 | { type: 'NAVIGATION_SET_OPTIONS', payload: { hidden: false, tabBarHidden: false, swipeBack: true } }, | |
| 33 | ]) | |
| 34 | protocol.dispose() | |
| 35 | }) | |
| 36 | ||
| 18 | 37 | it('sends protocol v1 and resolves a correlated response', async () => { |
| 19 | 38 | const native = host() |
| 20 | 39 | const bridge = new STXBridge() |