@react-navigation/bottom-tabs 7.9.0 → 8.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/navigators/createBottomTabNavigator.js +27 -9
- package/lib/module/navigators/createBottomTabNavigator.js.map +1 -1
- package/lib/module/utils/BottomTabAnimationContext.js +5 -0
- package/lib/module/utils/BottomTabAnimationContext.js.map +1 -0
- package/lib/module/utils/useBottomTabAnimation.js +12 -0
- package/lib/module/utils/useBottomTabAnimation.js.map +1 -0
- package/lib/module/utils/useTabBarPosition.js +34 -0
- package/lib/module/utils/useTabBarPosition.js.map +1 -0
- package/lib/module/views/BottomTabBar.js +46 -49
- package/lib/module/views/BottomTabBar.js.map +1 -1
- package/lib/module/views/BottomTabItem.js +17 -15
- package/lib/module/views/BottomTabItem.js.map +1 -1
- package/lib/module/views/BottomTabViewCommon.js +16 -0
- package/lib/module/views/BottomTabViewCommon.js.map +1 -0
- package/lib/module/views/{BottomTabView.js → BottomTabViewCustom.js} +107 -106
- package/lib/module/views/BottomTabViewCustom.js.map +1 -0
- package/lib/module/views/BottomTabViewNative.android.js +4 -0
- package/lib/module/views/BottomTabViewNative.android.js.map +1 -0
- package/lib/module/views/BottomTabViewNative.ios.js +4 -0
- package/lib/module/views/BottomTabViewNative.ios.js.map +1 -0
- package/lib/module/views/BottomTabViewNative.js +5 -0
- package/lib/module/views/BottomTabViewNative.js.map +1 -0
- package/lib/module/{unstable/NativeBottomTabView.native.js → views/BottomTabViewNativeImpl.js} +95 -77
- package/lib/module/views/BottomTabViewNativeImpl.js.map +1 -0
- package/lib/module/views/ScreenContent.js +39 -0
- package/lib/module/views/ScreenContent.js.map +1 -0
- package/lib/module/views/TabBarIcon.js +40 -4
- package/lib/module/views/TabBarIcon.js.map +1 -1
- package/lib/typescript/src/index.d.ts +4 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts +10 -6
- package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +383 -115
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/BottomTabAnimationContext.d.ts +4 -0
- package/lib/typescript/src/utils/BottomTabAnimationContext.d.ts.map +1 -0
- package/lib/typescript/src/utils/useBottomTabAnimation.d.ts +2 -0
- package/lib/typescript/src/utils/useBottomTabAnimation.d.ts.map +1 -0
- package/lib/typescript/src/utils/useTabBarPosition.d.ts +3 -0
- package/lib/typescript/src/utils/useTabBarPosition.d.ts.map +1 -0
- package/lib/typescript/src/views/BottomTabBar.d.ts +4 -4
- package/lib/typescript/src/views/BottomTabBar.d.ts.map +1 -1
- package/lib/typescript/src/views/BottomTabItem.d.ts +16 -14
- package/lib/typescript/src/views/BottomTabItem.d.ts.map +1 -1
- package/lib/typescript/src/views/{BottomTabView.d.ts → BottomTabViewCommon.d.ts} +2 -2
- package/lib/typescript/src/views/BottomTabViewCommon.d.ts.map +1 -0
- package/lib/typescript/src/views/BottomTabViewCustom.d.ts +10 -0
- package/lib/typescript/src/views/BottomTabViewCustom.d.ts.map +1 -0
- package/lib/typescript/src/views/BottomTabViewNative.android.d.ts +2 -0
- package/lib/typescript/src/views/BottomTabViewNative.android.d.ts.map +1 -0
- package/lib/typescript/src/views/BottomTabViewNative.d.ts +3 -0
- package/lib/typescript/src/views/BottomTabViewNative.d.ts.map +1 -0
- package/lib/typescript/src/views/BottomTabViewNative.ios.d.ts +2 -0
- package/lib/typescript/src/views/BottomTabViewNative.ios.d.ts.map +1 -0
- package/lib/typescript/src/views/BottomTabViewNativeImpl.d.ts +10 -0
- package/lib/typescript/src/views/BottomTabViewNativeImpl.d.ts.map +1 -0
- package/lib/typescript/src/views/ScreenContent.d.ts +13 -0
- package/lib/typescript/src/views/ScreenContent.d.ts.map +1 -0
- package/lib/typescript/src/views/TabBarIcon.d.ts +9 -9
- package/lib/typescript/src/views/TabBarIcon.d.ts.map +1 -1
- package/package.json +11 -16
- package/src/index.tsx +7 -2
- package/src/navigators/createBottomTabNavigator.tsx +78 -27
- package/src/types.tsx +417 -122
- package/src/utils/BottomTabAnimationContext.tsx +7 -0
- package/src/utils/useBottomTabAnimation.tsx +15 -0
- package/src/utils/useTabBarPosition.tsx +41 -0
- package/src/views/BottomTabBar.tsx +68 -67
- package/src/views/BottomTabItem.tsx +39 -34
- package/src/views/BottomTabViewCommon.tsx +26 -0
- package/src/views/{BottomTabView.tsx → BottomTabViewCustom.tsx} +142 -129
- package/src/views/BottomTabViewNative.android.tsx +1 -0
- package/src/views/BottomTabViewNative.ios.tsx +1 -0
- package/src/views/BottomTabViewNative.tsx +3 -0
- package/src/{unstable/NativeBottomTabView.native.tsx → views/BottomTabViewNativeImpl.tsx} +139 -116
- package/src/views/ScreenContent.tsx +58 -0
- package/src/views/TabBarIcon.tsx +63 -10
- package/lib/module/unstable/NativeBottomTabView.js +0 -6
- package/lib/module/unstable/NativeBottomTabView.js.map +0 -1
- package/lib/module/unstable/NativeBottomTabView.native.js.map +0 -1
- package/lib/module/unstable/NativeScreen/NativeScreen.js +0 -152
- package/lib/module/unstable/NativeScreen/NativeScreen.js.map +0 -1
- package/lib/module/unstable/NativeScreen/debounce.js +0 -12
- package/lib/module/unstable/NativeScreen/debounce.js.map +0 -1
- package/lib/module/unstable/NativeScreen/types.js +0 -4
- package/lib/module/unstable/NativeScreen/types.js.map +0 -1
- package/lib/module/unstable/NativeScreen/useAnimatedHeaderHeight.js +0 -12
- package/lib/module/unstable/NativeScreen/useAnimatedHeaderHeight.js.map +0 -1
- package/lib/module/unstable/NativeScreen/useHeaderConfig.js +0 -304
- package/lib/module/unstable/NativeScreen/useHeaderConfig.js.map +0 -1
- package/lib/module/unstable/createNativeBottomTabNavigator.js +0 -6
- package/lib/module/unstable/createNativeBottomTabNavigator.js.map +0 -1
- package/lib/module/unstable/createNativeBottomTabNavigator.native.js +0 -65
- package/lib/module/unstable/createNativeBottomTabNavigator.native.js.map +0 -1
- package/lib/module/unstable/index.js +0 -16
- package/lib/module/unstable/index.js.map +0 -1
- package/lib/module/unstable/types.js +0 -4
- package/lib/module/unstable/types.js.map +0 -1
- package/lib/module/views/BottomTabView.js.map +0 -1
- package/lib/module/views/ScreenFallback.js +0 -42
- package/lib/module/views/ScreenFallback.js.map +0 -1
- package/lib/typescript/src/unstable/NativeBottomTabView.d.ts +0 -10
- package/lib/typescript/src/unstable/NativeBottomTabView.d.ts.map +0 -1
- package/lib/typescript/src/unstable/NativeBottomTabView.native.d.ts +0 -10
- package/lib/typescript/src/unstable/NativeBottomTabView.native.d.ts.map +0 -1
- package/lib/typescript/src/unstable/NativeScreen/NativeScreen.d.ts +0 -8
- package/lib/typescript/src/unstable/NativeScreen/NativeScreen.d.ts.map +0 -1
- package/lib/typescript/src/unstable/NativeScreen/debounce.d.ts +0 -2
- package/lib/typescript/src/unstable/NativeScreen/debounce.d.ts.map +0 -1
- package/lib/typescript/src/unstable/NativeScreen/types.d.ts +0 -523
- package/lib/typescript/src/unstable/NativeScreen/types.d.ts.map +0 -1
- package/lib/typescript/src/unstable/NativeScreen/useAnimatedHeaderHeight.d.ts +0 -5
- package/lib/typescript/src/unstable/NativeScreen/useAnimatedHeaderHeight.d.ts.map +0 -1
- package/lib/typescript/src/unstable/NativeScreen/useHeaderConfig.d.ts +0 -11
- package/lib/typescript/src/unstable/NativeScreen/useHeaderConfig.d.ts.map +0 -1
- package/lib/typescript/src/unstable/createNativeBottomTabNavigator.d.ts +0 -2
- package/lib/typescript/src/unstable/createNativeBottomTabNavigator.d.ts.map +0 -1
- package/lib/typescript/src/unstable/createNativeBottomTabNavigator.native.d.ts +0 -16
- package/lib/typescript/src/unstable/createNativeBottomTabNavigator.native.d.ts.map +0 -1
- package/lib/typescript/src/unstable/index.d.ts +0 -13
- package/lib/typescript/src/unstable/index.d.ts.map +0 -1
- package/lib/typescript/src/unstable/types.d.ts +0 -319
- package/lib/typescript/src/unstable/types.d.ts.map +0 -1
- package/lib/typescript/src/views/BottomTabView.d.ts.map +0 -1
- package/lib/typescript/src/views/ScreenFallback.d.ts +0 -18
- package/lib/typescript/src/views/ScreenFallback.d.ts.map +0 -1
- package/src/unstable/NativeBottomTabView.tsx +0 -20
- package/src/unstable/NativeScreen/NativeScreen.tsx +0 -212
- package/src/unstable/NativeScreen/debounce.tsx +0 -14
- package/src/unstable/NativeScreen/types.ts +0 -573
- package/src/unstable/NativeScreen/useAnimatedHeaderHeight.tsx +0 -18
- package/src/unstable/NativeScreen/useHeaderConfig.tsx +0 -434
- package/src/unstable/createNativeBottomTabNavigator.native.tsx +0 -116
- package/src/unstable/createNativeBottomTabNavigator.tsx +0 -4
- package/src/unstable/index.tsx +0 -23
- package/src/unstable/types.tsx +0 -405
- package/src/views/ScreenFallback.tsx +0 -50
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
Container,
|
|
3
|
+
Lazy,
|
|
4
4
|
SafeAreaProviderCompat,
|
|
5
|
-
|
|
6
|
-
} from '@react-navigation/elements';
|
|
5
|
+
} from '@react-navigation/elements/internal';
|
|
7
6
|
import {
|
|
8
7
|
type NavigationAction,
|
|
9
8
|
type ParamListBase,
|
|
@@ -11,8 +10,14 @@ import {
|
|
|
11
10
|
type TabNavigationState,
|
|
12
11
|
} from '@react-navigation/native';
|
|
13
12
|
import * as React from 'react';
|
|
14
|
-
import {
|
|
15
|
-
|
|
13
|
+
import {
|
|
14
|
+
Animated,
|
|
15
|
+
Platform,
|
|
16
|
+
type StyleProp,
|
|
17
|
+
StyleSheet,
|
|
18
|
+
type ViewStyle,
|
|
19
|
+
} from 'react-native';
|
|
20
|
+
import { Screen, ScreenContainer } from 'react-native-screens';
|
|
16
21
|
|
|
17
22
|
import {
|
|
18
23
|
FadeTransition,
|
|
@@ -21,17 +26,18 @@ import {
|
|
|
21
26
|
import type {
|
|
22
27
|
BottomTabBarProps,
|
|
23
28
|
BottomTabDescriptorMap,
|
|
24
|
-
BottomTabHeaderProps,
|
|
25
29
|
BottomTabNavigationConfig,
|
|
26
30
|
BottomTabNavigationHelpers,
|
|
27
31
|
BottomTabNavigationOptions,
|
|
28
|
-
|
|
32
|
+
BottomTabSceneStyleInterpolator,
|
|
29
33
|
} from '../types';
|
|
34
|
+
import { BottomTabAnimationContext } from '../utils/BottomTabAnimationContext';
|
|
30
35
|
import { BottomTabBarHeightCallbackContext } from '../utils/BottomTabBarHeightCallbackContext';
|
|
31
36
|
import { BottomTabBarHeightContext } from '../utils/BottomTabBarHeightContext';
|
|
32
37
|
import { useAnimatedHashMap } from '../utils/useAnimatedHashMap';
|
|
38
|
+
import { useTabBarPosition } from '../utils/useTabBarPosition';
|
|
33
39
|
import { BottomTabBar, getTabBarHeight } from './BottomTabBar';
|
|
34
|
-
import {
|
|
40
|
+
import { ScreenContent } from './ScreenContent';
|
|
35
41
|
|
|
36
42
|
type Props = BottomTabNavigationConfig & {
|
|
37
43
|
state: TabNavigationState<ParamListBase>;
|
|
@@ -72,29 +78,17 @@ const renderTabBarDefault = (props: BottomTabBarProps) => (
|
|
|
72
78
|
<BottomTabBar {...props} />
|
|
73
79
|
);
|
|
74
80
|
|
|
75
|
-
export function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const focusedRouteKey = state.routes[state.index].key;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* List of loaded tabs, tabs will be loaded when navigated to.
|
|
91
|
-
*/
|
|
92
|
-
const [loaded, setLoaded] = React.useState([focusedRouteKey]);
|
|
93
|
-
|
|
94
|
-
if (!loaded.includes(focusedRouteKey)) {
|
|
95
|
-
// Set the current tab to be loaded if it was not loaded before
|
|
96
|
-
setLoaded([...loaded, focusedRouteKey]);
|
|
97
|
-
}
|
|
81
|
+
export function BottomTabViewCustom({
|
|
82
|
+
tabBar = renderTabBarDefault,
|
|
83
|
+
state,
|
|
84
|
+
navigation,
|
|
85
|
+
descriptors,
|
|
86
|
+
detachInactiveScreens = Platform.OS === 'web' ||
|
|
87
|
+
Platform.OS === 'android' ||
|
|
88
|
+
Platform.OS === 'ios',
|
|
89
|
+
}: Props) {
|
|
90
|
+
const { routes } = state;
|
|
91
|
+
const focusedRouteKey = routes[state.index].key;
|
|
98
92
|
|
|
99
93
|
const previousRouteKeyRef = React.useRef(focusedRouteKey);
|
|
100
94
|
const tabAnims = useAnimatedHashMap(state);
|
|
@@ -187,58 +181,38 @@ export function BottomTabView(props: Props) {
|
|
|
187
181
|
tabAnims,
|
|
188
182
|
]);
|
|
189
183
|
|
|
190
|
-
const dimensions = SafeAreaProviderCompat.initialMetrics.frame;
|
|
191
184
|
const [tabBarHeight, setTabBarHeight] = React.useState(() =>
|
|
192
185
|
getTabBarHeight({
|
|
193
186
|
state,
|
|
194
187
|
descriptors,
|
|
195
|
-
dimensions,
|
|
196
|
-
insets:
|
|
197
|
-
|
|
198
|
-
...props.safeAreaInsets,
|
|
199
|
-
},
|
|
200
|
-
style: descriptors[state.routes[state.index].key].options.tabBarStyle,
|
|
188
|
+
dimensions: SafeAreaProviderCompat.initialMetrics.frame,
|
|
189
|
+
insets: SafeAreaProviderCompat.initialMetrics.insets,
|
|
190
|
+
style: descriptors[focusedRouteKey].options.tabBarStyle,
|
|
201
191
|
})
|
|
202
192
|
);
|
|
203
193
|
|
|
204
|
-
const renderTabBar = () => {
|
|
205
|
-
return (
|
|
206
|
-
<SafeAreaInsetsContext.Consumer>
|
|
207
|
-
{(insets) =>
|
|
208
|
-
tabBar({
|
|
209
|
-
state: state,
|
|
210
|
-
descriptors: descriptors,
|
|
211
|
-
navigation: navigation,
|
|
212
|
-
insets: {
|
|
213
|
-
top: safeAreaInsets?.top ?? insets?.top ?? 0,
|
|
214
|
-
right: safeAreaInsets?.right ?? insets?.right ?? 0,
|
|
215
|
-
bottom: safeAreaInsets?.bottom ?? insets?.bottom ?? 0,
|
|
216
|
-
left: safeAreaInsets?.left ?? insets?.left ?? 0,
|
|
217
|
-
},
|
|
218
|
-
})
|
|
219
|
-
}
|
|
220
|
-
</SafeAreaInsetsContext.Consumer>
|
|
221
|
-
);
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
const { routes } = state;
|
|
225
|
-
|
|
226
|
-
// If there is no animation, we only have 2 states: visible and invisible
|
|
227
|
-
const hasTwoStates = !routes.some((route) =>
|
|
228
|
-
hasAnimation(descriptors[route.key].options)
|
|
229
|
-
);
|
|
230
|
-
|
|
231
|
-
const { tabBarPosition = 'bottom' } = descriptors[focusedRouteKey].options;
|
|
232
|
-
|
|
233
194
|
const tabBarElement = (
|
|
234
195
|
<BottomTabBarHeightCallbackContext.Provider
|
|
235
196
|
key="tabbar"
|
|
236
197
|
value={setTabBarHeight}
|
|
237
198
|
>
|
|
238
|
-
{
|
|
199
|
+
{tabBar({
|
|
200
|
+
state: state,
|
|
201
|
+
descriptors: descriptors,
|
|
202
|
+
navigation: navigation,
|
|
203
|
+
})}
|
|
239
204
|
</BottomTabBarHeightCallbackContext.Provider>
|
|
240
205
|
);
|
|
241
206
|
|
|
207
|
+
// If there is no animation, we only have 2 states: visible and invisible
|
|
208
|
+
const hasTwoStates = !routes.some((route) =>
|
|
209
|
+
hasAnimation(descriptors[route.key].options)
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
const tabBarPosition = useTabBarPosition(
|
|
213
|
+
descriptors[focusedRouteKey].options
|
|
214
|
+
);
|
|
215
|
+
|
|
242
216
|
return (
|
|
243
217
|
<SafeAreaProviderCompat
|
|
244
218
|
style={{
|
|
@@ -251,7 +225,7 @@ export function BottomTabView(props: Props) {
|
|
|
251
225
|
{tabBarPosition === 'top' || tabBarPosition === 'left'
|
|
252
226
|
? tabBarElement
|
|
253
227
|
: null}
|
|
254
|
-
<
|
|
228
|
+
<ScreenContainer
|
|
255
229
|
key="screens"
|
|
256
230
|
enabled={detachInactiveScreens}
|
|
257
231
|
hasTwoStates={hasTwoStates}
|
|
@@ -259,48 +233,67 @@ export function BottomTabView(props: Props) {
|
|
|
259
233
|
>
|
|
260
234
|
{routes.map((route, index) => {
|
|
261
235
|
const descriptor = descriptors[route.key];
|
|
236
|
+
|
|
237
|
+
const { navigation, options, render } = descriptor;
|
|
238
|
+
|
|
262
239
|
const {
|
|
263
240
|
lazy = true,
|
|
264
241
|
animation = 'none',
|
|
265
242
|
sceneStyleInterpolator = NAMED_TRANSITIONS_PRESETS[animation]
|
|
266
243
|
.sceneStyleInterpolator,
|
|
267
|
-
|
|
244
|
+
sceneStyle: customSceneStyle,
|
|
245
|
+
} = options;
|
|
246
|
+
|
|
268
247
|
const isFocused = state.index === index;
|
|
269
248
|
const isPreloaded = state.preloadedRouteKeys.includes(route.key);
|
|
270
249
|
|
|
271
|
-
|
|
272
|
-
lazy &&
|
|
273
|
-
!loaded.includes(route.key) &&
|
|
274
|
-
!isFocused &&
|
|
275
|
-
!isPreloaded
|
|
276
|
-
) {
|
|
277
|
-
// Don't render a lazy screen if we've never navigated to it or it wasn't preloaded
|
|
278
|
-
return null;
|
|
279
|
-
}
|
|
250
|
+
const animationEnabled = hasAnimation(descriptor.options);
|
|
280
251
|
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
252
|
+
const content = (
|
|
253
|
+
<AnimatedScreenContent
|
|
254
|
+
progress={tabAnims[route.key]}
|
|
255
|
+
animationEnabled={animationEnabled}
|
|
256
|
+
sceneStyleInterpolator={sceneStyleInterpolator}
|
|
257
|
+
style={customSceneStyle}
|
|
258
|
+
>
|
|
259
|
+
<Lazy enabled={lazy} visible={isFocused || isPreloaded}>
|
|
260
|
+
<ScreenContent
|
|
261
|
+
isFocused={isFocused}
|
|
262
|
+
route={route}
|
|
263
|
+
navigation={navigation}
|
|
264
|
+
options={options}
|
|
265
|
+
>
|
|
266
|
+
<BottomTabBarHeightContext.Provider
|
|
267
|
+
value={tabBarPosition === 'bottom' ? tabBarHeight : 0}
|
|
268
|
+
>
|
|
269
|
+
{render()}
|
|
270
|
+
</BottomTabBarHeightContext.Provider>
|
|
271
|
+
</ScreenContent>
|
|
272
|
+
</Lazy>
|
|
273
|
+
</AnimatedScreenContent>
|
|
274
|
+
);
|
|
295
275
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
276
|
+
if (Platform.OS === 'web') {
|
|
277
|
+
/**
|
|
278
|
+
* Don't use react-native-screens on web:
|
|
279
|
+
* - It applies display: none as fallback, which triggers `onLayout` events
|
|
280
|
+
* - We still need to hide the view when screens is not enabled
|
|
281
|
+
* - We can use `inert` to handle a11y better for unfocused screens
|
|
282
|
+
*/
|
|
283
|
+
return (
|
|
284
|
+
<Container
|
|
285
|
+
key={route.key}
|
|
286
|
+
inert={!isFocused}
|
|
287
|
+
style={{
|
|
288
|
+
...StyleSheet.absoluteFillObject,
|
|
289
|
+
visibility: isFocused ? 'visible' : 'hidden',
|
|
290
|
+
}}
|
|
291
|
+
>
|
|
292
|
+
{content}
|
|
293
|
+
</Container>
|
|
294
|
+
);
|
|
295
|
+
}
|
|
302
296
|
|
|
303
|
-
const animationEnabled = hasAnimation(descriptor.options);
|
|
304
297
|
const activityState = isFocused
|
|
305
298
|
? STATE_ON_TOP // the screen is on top after the transition
|
|
306
299
|
: animationEnabled // is animation is not enabled, immediately move to inactive state
|
|
@@ -316,40 +309,24 @@ export function BottomTabView(props: Props) {
|
|
|
316
309
|
: STATE_INACTIVE;
|
|
317
310
|
|
|
318
311
|
return (
|
|
319
|
-
<
|
|
312
|
+
<Screen
|
|
320
313
|
key={route.key}
|
|
321
|
-
style={[
|
|
322
|
-
|
|
314
|
+
style={[
|
|
315
|
+
StyleSheet.absoluteFill,
|
|
316
|
+
{
|
|
317
|
+
zIndex: isFocused ? 0 : -1,
|
|
318
|
+
pointerEvents: isFocused ? 'auto' : 'none',
|
|
319
|
+
},
|
|
320
|
+
]}
|
|
321
|
+
activityState={activityState}
|
|
323
322
|
enabled={detachInactiveScreens}
|
|
324
|
-
freezeOnBlur={freezeOnBlur}
|
|
325
323
|
shouldFreeze={activityState === STATE_INACTIVE && !isPreloaded}
|
|
326
324
|
>
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
>
|
|
330
|
-
<Screen
|
|
331
|
-
focused={isFocused}
|
|
332
|
-
route={descriptor.route}
|
|
333
|
-
navigation={descriptor.navigation}
|
|
334
|
-
headerShown={headerShown}
|
|
335
|
-
headerStatusBarHeight={headerStatusBarHeight}
|
|
336
|
-
headerTransparent={headerTransparent}
|
|
337
|
-
header={header({
|
|
338
|
-
layout: dimensions,
|
|
339
|
-
route: descriptor.route,
|
|
340
|
-
navigation:
|
|
341
|
-
descriptor.navigation as BottomTabNavigationProp<ParamListBase>,
|
|
342
|
-
options: descriptor.options,
|
|
343
|
-
})}
|
|
344
|
-
style={[customSceneStyle, animationEnabled && sceneStyle]}
|
|
345
|
-
>
|
|
346
|
-
{descriptor.render()}
|
|
347
|
-
</Screen>
|
|
348
|
-
</BottomTabBarHeightContext.Provider>
|
|
349
|
-
</MaybeScreen>
|
|
325
|
+
{content}
|
|
326
|
+
</Screen>
|
|
350
327
|
);
|
|
351
328
|
})}
|
|
352
|
-
</
|
|
329
|
+
</ScreenContainer>
|
|
353
330
|
{tabBarPosition === 'bottom' || tabBarPosition === 'right'
|
|
354
331
|
? tabBarElement
|
|
355
332
|
: null}
|
|
@@ -357,9 +334,45 @@ export function BottomTabView(props: Props) {
|
|
|
357
334
|
);
|
|
358
335
|
}
|
|
359
336
|
|
|
337
|
+
function AnimatedScreenContent({
|
|
338
|
+
progress,
|
|
339
|
+
animationEnabled,
|
|
340
|
+
sceneStyleInterpolator,
|
|
341
|
+
children,
|
|
342
|
+
style,
|
|
343
|
+
}: {
|
|
344
|
+
progress: Animated.Value;
|
|
345
|
+
animationEnabled: boolean;
|
|
346
|
+
sceneStyleInterpolator?: BottomTabSceneStyleInterpolator;
|
|
347
|
+
children: React.ReactNode;
|
|
348
|
+
style: StyleProp<ViewStyle>;
|
|
349
|
+
}) {
|
|
350
|
+
const interpolationProps = React.useMemo(() => {
|
|
351
|
+
return {
|
|
352
|
+
current: { progress },
|
|
353
|
+
};
|
|
354
|
+
}, [progress]);
|
|
355
|
+
|
|
356
|
+
const { sceneStyle } = sceneStyleInterpolator?.(interpolationProps) ?? {};
|
|
357
|
+
|
|
358
|
+
return (
|
|
359
|
+
<Animated.View
|
|
360
|
+
style={[styles.scene, style, animationEnabled && sceneStyle]}
|
|
361
|
+
>
|
|
362
|
+
<BottomTabAnimationContext.Provider value={interpolationProps}>
|
|
363
|
+
{children}
|
|
364
|
+
</BottomTabAnimationContext.Provider>
|
|
365
|
+
</Animated.View>
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
360
369
|
const styles = StyleSheet.create({
|
|
361
370
|
screens: {
|
|
362
371
|
flex: 1,
|
|
363
372
|
overflow: 'hidden',
|
|
364
373
|
},
|
|
374
|
+
scene: {
|
|
375
|
+
flex: 1,
|
|
376
|
+
pointerEvents: 'box-none',
|
|
377
|
+
},
|
|
365
378
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BottomTabViewNativeImpl';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BottomTabViewNativeImpl';
|