@react-navigation/bottom-tabs 7.5.0 → 7.7.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/navigators/createBottomTabNavigator.js +2 -0
- package/lib/module/navigators/createBottomTabNavigator.js.map +1 -1
- package/lib/module/unstable/NativeBottomTabView.js +6 -0
- package/lib/module/unstable/NativeBottomTabView.js.map +1 -0
- package/lib/module/unstable/NativeBottomTabView.native.js +225 -0
- package/lib/module/unstable/NativeBottomTabView.native.js.map +1 -0
- package/lib/module/unstable/NativeScreen/NativeScreen.js +166 -0
- package/lib/module/unstable/NativeScreen/NativeScreen.js.map +1 -0
- package/lib/module/unstable/NativeScreen/debounce.js +12 -0
- package/lib/module/unstable/NativeScreen/debounce.js.map +1 -0
- package/lib/module/unstable/NativeScreen/types.js +4 -0
- package/lib/module/unstable/NativeScreen/types.js.map +1 -0
- package/lib/module/unstable/NativeScreen/useAnimatedHeaderHeight.js +12 -0
- package/lib/module/unstable/NativeScreen/useAnimatedHeaderHeight.js.map +1 -0
- package/lib/module/unstable/NativeScreen/useHeaderConfig.js +283 -0
- package/lib/module/unstable/NativeScreen/useHeaderConfig.js.map +1 -0
- package/lib/module/unstable/createNativeBottomTabNavigator.js +6 -0
- package/lib/module/unstable/createNativeBottomTabNavigator.js.map +1 -0
- package/lib/module/unstable/createNativeBottomTabNavigator.native.js +65 -0
- package/lib/module/unstable/createNativeBottomTabNavigator.native.js.map +1 -0
- package/lib/module/unstable/index.js +16 -0
- package/lib/module/unstable/index.js.map +1 -0
- package/lib/module/unstable/types.js +4 -0
- package/lib/module/unstable/types.js.map +1 -0
- package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts +1 -1
- package/lib/typescript/src/navigators/createBottomTabNavigator.d.ts.map +1 -1
- package/lib/typescript/src/unstable/NativeBottomTabView.d.ts +10 -0
- package/lib/typescript/src/unstable/NativeBottomTabView.d.ts.map +1 -0
- package/lib/typescript/src/unstable/NativeBottomTabView.native.d.ts +10 -0
- package/lib/typescript/src/unstable/NativeBottomTabView.native.d.ts.map +1 -0
- package/lib/typescript/src/unstable/NativeScreen/NativeScreen.d.ts +8 -0
- package/lib/typescript/src/unstable/NativeScreen/NativeScreen.d.ts.map +1 -0
- package/lib/typescript/src/unstable/NativeScreen/debounce.d.ts +2 -0
- package/lib/typescript/src/unstable/NativeScreen/debounce.d.ts.map +1 -0
- package/lib/typescript/src/unstable/NativeScreen/types.d.ts +467 -0
- package/lib/typescript/src/unstable/NativeScreen/types.d.ts.map +1 -0
- package/lib/typescript/src/unstable/NativeScreen/useAnimatedHeaderHeight.d.ts +5 -0
- package/lib/typescript/src/unstable/NativeScreen/useAnimatedHeaderHeight.d.ts.map +1 -0
- package/lib/typescript/src/unstable/NativeScreen/useHeaderConfig.d.ts +11 -0
- package/lib/typescript/src/unstable/NativeScreen/useHeaderConfig.d.ts.map +1 -0
- package/lib/typescript/src/unstable/createNativeBottomTabNavigator.d.ts +2 -0
- package/lib/typescript/src/unstable/createNativeBottomTabNavigator.d.ts.map +1 -0
- package/lib/typescript/src/unstable/createNativeBottomTabNavigator.native.d.ts +16 -0
- package/lib/typescript/src/unstable/createNativeBottomTabNavigator.native.d.ts.map +1 -0
- package/lib/typescript/src/unstable/index.d.ts +13 -0
- package/lib/typescript/src/unstable/index.d.ts.map +1 -0
- package/lib/typescript/src/unstable/types.d.ts +276 -0
- package/lib/typescript/src/unstable/types.d.ts.map +1 -0
- package/package.json +12 -6
- package/src/navigators/createBottomTabNavigator.tsx +2 -0
- package/src/unstable/NativeBottomTabView.native.tsx +303 -0
- package/src/unstable/NativeBottomTabView.tsx +20 -0
- package/src/unstable/NativeScreen/NativeScreen.tsx +242 -0
- package/src/unstable/NativeScreen/debounce.tsx +14 -0
- package/src/unstable/NativeScreen/types.ts +517 -0
- package/src/unstable/NativeScreen/useAnimatedHeaderHeight.tsx +18 -0
- package/src/unstable/NativeScreen/useHeaderConfig.tsx +423 -0
- package/src/unstable/createNativeBottomTabNavigator.native.tsx +116 -0
- package/src/unstable/createNativeBottomTabNavigator.tsx +4 -0
- package/src/unstable/index.tsx +22 -0
- package/src/unstable/types.tsx +353 -0
|
@@ -7,6 +7,7 @@ function BottomTabNavigator({
|
|
|
7
7
|
id,
|
|
8
8
|
initialRouteName,
|
|
9
9
|
backBehavior,
|
|
10
|
+
UNSTABLE_routeNamesChangeBehavior,
|
|
10
11
|
children,
|
|
11
12
|
layout,
|
|
12
13
|
screenListeners,
|
|
@@ -24,6 +25,7 @@ function BottomTabNavigator({
|
|
|
24
25
|
id,
|
|
25
26
|
initialRouteName,
|
|
26
27
|
backBehavior,
|
|
28
|
+
UNSTABLE_routeNamesChangeBehavior,
|
|
27
29
|
children,
|
|
28
30
|
layout,
|
|
29
31
|
screenListeners,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createNavigatorFactory","TabRouter","useNavigationBuilder","BottomTabView","jsx","_jsx","BottomTabNavigator","id","initialRouteName","backBehavior","children","layout","screenListeners","screenOptions","screenLayout","UNSTABLE_router","rest","state","descriptors","navigation","NavigationContent","createBottomTabNavigator","config"],"sourceRoot":"../../../src","sources":["navigators/createBottomTabNavigator.tsx"],"mappings":";;AAAA,SACEA,sBAAsB,EAMtBC,SAAS,EAGTC,oBAAoB,QACf,0BAA0B;AAQjC,SAASC,aAAa,QAAQ,2BAAwB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEvD,SAASC,kBAAkBA,CAAC;EAC1BC,EAAE;EACFC,gBAAgB;EAChBC,YAAY;EACZC,QAAQ;EACRC,MAAM;EACNC,eAAe;EACfC,aAAa;EACbC,YAAY;EACZC,eAAe;EACf,GAAGC;AACoB,CAAC,EAAE;EAC1B,MAAM;IAAEC,KAAK;IAAEC,WAAW;IAAEC,UAAU;IAAEC;EAAkB,CAAC,
|
|
1
|
+
{"version":3,"names":["createNavigatorFactory","TabRouter","useNavigationBuilder","BottomTabView","jsx","_jsx","BottomTabNavigator","id","initialRouteName","backBehavior","UNSTABLE_routeNamesChangeBehavior","children","layout","screenListeners","screenOptions","screenLayout","UNSTABLE_router","rest","state","descriptors","navigation","NavigationContent","createBottomTabNavigator","config"],"sourceRoot":"../../../src","sources":["navigators/createBottomTabNavigator.tsx"],"mappings":";;AAAA,SACEA,sBAAsB,EAMtBC,SAAS,EAGTC,oBAAoB,QACf,0BAA0B;AAQjC,SAASC,aAAa,QAAQ,2BAAwB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEvD,SAASC,kBAAkBA,CAAC;EAC1BC,EAAE;EACFC,gBAAgB;EAChBC,YAAY;EACZC,iCAAiC;EACjCC,QAAQ;EACRC,MAAM;EACNC,eAAe;EACfC,aAAa;EACbC,YAAY;EACZC,eAAe;EACf,GAAGC;AACoB,CAAC,EAAE;EAC1B,MAAM;IAAEC,KAAK;IAAEC,WAAW;IAAEC,UAAU;IAAEC;EAAkB,CAAC,GACzDnB,oBAAoB,CAMlBD,SAAS,EAAE;IACXM,EAAE;IACFC,gBAAgB;IAChBC,YAAY;IACZC,iCAAiC;IACjCC,QAAQ;IACRC,MAAM;IACNC,eAAe;IACfC,aAAa;IACbC,YAAY;IACZC;EACF,CAAC,CAAC;EAEJ,oBACEX,IAAA,CAACgB,iBAAiB;IAAAV,QAAA,eAChBN,IAAA,CAACF,aAAa;MAAA,GACRc,IAAI;MACRC,KAAK,EAAEA,KAAM;MACbE,UAAU,EAAEA,UAAW;MACvBD,WAAW,EAAEA;IAAY,CAC1B;EAAC,CACe,CAAC;AAExB;AAEA,OAAO,SAASG,wBAAwBA,CAmBtCC,MAAe,EAAmC;EAClD,OAAOvB,sBAAsB,CAACM,kBAAkB,CAAC,CAACiB,MAAM,CAAC;AAC3D","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeBottomTabView","_","Error"],"sourceRoot":"../../../src","sources":["unstable/NativeBottomTabView.tsx"],"mappings":";;AAiBA,OAAO,SAASA,mBAAmBA,CAACC,CAAQ,EAAE;EAC5C,MAAM,IAAIC,KAAK,CAAC,wDAAwD,CAAC;AAC3E","ignoreList":[]}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { getLabel, Lazy, SafeAreaProviderCompat } from '@react-navigation/elements';
|
|
4
|
+
import { CommonActions, StackActions, useTheme } from '@react-navigation/native';
|
|
5
|
+
import Color from 'color';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import { Platform, PlatformColor } from 'react-native';
|
|
8
|
+
import { BottomTabs, BottomTabsScreen } from 'react-native-screens';
|
|
9
|
+
import { NativeScreen } from "./NativeScreen/NativeScreen.js";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
export function NativeBottomTabView({
|
|
12
|
+
state,
|
|
13
|
+
navigation,
|
|
14
|
+
descriptors
|
|
15
|
+
}) {
|
|
16
|
+
const {
|
|
17
|
+
colors,
|
|
18
|
+
fonts
|
|
19
|
+
} = useTheme();
|
|
20
|
+
const focusedRouteKey = state.routes[state.index].key;
|
|
21
|
+
const previousRouteKeyRef = React.useRef(focusedRouteKey);
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
const previousRouteKey = previousRouteKeyRef.current;
|
|
24
|
+
if (previousRouteKey !== focusedRouteKey && descriptors[previousRouteKey]?.options.popToTopOnBlur) {
|
|
25
|
+
const prevRoute = state.routes.find(route => route.key === previousRouteKey);
|
|
26
|
+
if (prevRoute?.state?.type === 'stack' && prevRoute.state.key) {
|
|
27
|
+
const popToTopAction = {
|
|
28
|
+
...StackActions.popToTop(),
|
|
29
|
+
target: prevRoute.state.key
|
|
30
|
+
};
|
|
31
|
+
navigation.dispatch(popToTopAction);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
previousRouteKeyRef.current = focusedRouteKey;
|
|
35
|
+
}, [descriptors, focusedRouteKey, navigation, state.index, state.routes]);
|
|
36
|
+
const currentOptions = descriptors[state.routes[state.index].key]?.options;
|
|
37
|
+
const {
|
|
38
|
+
backgroundColor: tabBarBackgroundColor,
|
|
39
|
+
shadowColor: tabBarShadowColor
|
|
40
|
+
} = currentOptions.tabBarStyle || {};
|
|
41
|
+
const {
|
|
42
|
+
fontFamily = Platform.select({
|
|
43
|
+
ios: fonts.medium.fontFamily,
|
|
44
|
+
default: fonts.regular.fontFamily
|
|
45
|
+
}),
|
|
46
|
+
fontWeight = Platform.select({
|
|
47
|
+
ios: fonts.medium.fontWeight,
|
|
48
|
+
default: fonts.regular.fontWeight
|
|
49
|
+
}),
|
|
50
|
+
fontSize,
|
|
51
|
+
fontStyle
|
|
52
|
+
} = currentOptions.tabBarLabelStyle || {};
|
|
53
|
+
const activeTintColor = currentOptions.tabBarActiveTintColor ?? colors.primary;
|
|
54
|
+
const inactiveTintColor = currentOptions.tabBarInactiveTintColor ?? Platform.select({
|
|
55
|
+
ios: PlatformColor('label'),
|
|
56
|
+
default: colors.text
|
|
57
|
+
});
|
|
58
|
+
const activeIndicatorColor = currentOptions?.tabBarActiveIndicatorColor ?? typeof activeTintColor === 'string' ? Color(activeTintColor)?.alpha(0.1).string() : undefined;
|
|
59
|
+
const onTransitionStart = ({
|
|
60
|
+
closing,
|
|
61
|
+
route
|
|
62
|
+
}) => {
|
|
63
|
+
navigation.emit({
|
|
64
|
+
type: 'transitionStart',
|
|
65
|
+
data: {
|
|
66
|
+
closing
|
|
67
|
+
},
|
|
68
|
+
target: route.key
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
const onTransitionEnd = ({
|
|
72
|
+
closing,
|
|
73
|
+
route
|
|
74
|
+
}) => {
|
|
75
|
+
navigation.emit({
|
|
76
|
+
type: 'transitionEnd',
|
|
77
|
+
data: {
|
|
78
|
+
closing
|
|
79
|
+
},
|
|
80
|
+
target: route.key
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
return /*#__PURE__*/_jsx(SafeAreaProviderCompat, {
|
|
84
|
+
children: /*#__PURE__*/_jsx(BottomTabs, {
|
|
85
|
+
tabBarItemLabelVisibilityMode: currentOptions?.tabBarLabelVisibilityMode,
|
|
86
|
+
tabBarControllerMode: currentOptions?.tabBarControllerMode,
|
|
87
|
+
tabBarMinimizeBehavior: currentOptions?.tabBarMinimizeBehavior,
|
|
88
|
+
tabBarTintColor: activeTintColor,
|
|
89
|
+
tabBarItemIconColor: inactiveTintColor,
|
|
90
|
+
tabBarItemIconColorActive: activeTintColor,
|
|
91
|
+
tabBarItemTitleFontColor: inactiveTintColor,
|
|
92
|
+
tabBarItemTitleFontColorActive: activeTintColor,
|
|
93
|
+
tabBarItemTitleFontFamily: fontFamily,
|
|
94
|
+
tabBarItemTitleFontWeight: fontWeight,
|
|
95
|
+
tabBarItemTitleFontSize: fontSize,
|
|
96
|
+
tabBarItemTitleFontSizeActive: fontSize,
|
|
97
|
+
tabBarBackgroundColor: currentOptions.tabBarStyle?.backgroundColor,
|
|
98
|
+
tabBarItemActiveIndicatorColor: activeIndicatorColor,
|
|
99
|
+
tabBarItemActiveIndicatorEnabled: currentOptions?.tabBarActiveIndicatorEnabled,
|
|
100
|
+
tabBarItemRippleColor: currentOptions?.tabBarRippleColor,
|
|
101
|
+
experimentalControlNavigationStateInJS: true,
|
|
102
|
+
onNativeFocusChange: e => {
|
|
103
|
+
const route = state.routes.find(route => route.key === e.nativeEvent.tabKey);
|
|
104
|
+
if (route) {
|
|
105
|
+
const isFocused = state.index === state.routes.findIndex(r => r.key === route.key);
|
|
106
|
+
const event = navigation.emit({
|
|
107
|
+
type: 'tabPress',
|
|
108
|
+
target: route.key,
|
|
109
|
+
canPreventDefault: true
|
|
110
|
+
});
|
|
111
|
+
if (!isFocused && !event.defaultPrevented) {
|
|
112
|
+
React.startTransition(() => {
|
|
113
|
+
navigation.dispatch({
|
|
114
|
+
...CommonActions.navigate(route.name, route.params),
|
|
115
|
+
target: state.key
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
children: state.routes.map((route, index) => {
|
|
122
|
+
const {
|
|
123
|
+
options,
|
|
124
|
+
render,
|
|
125
|
+
navigation
|
|
126
|
+
} = descriptors[route.key];
|
|
127
|
+
const isFocused = state.index === index;
|
|
128
|
+
const isPreloaded = state.preloadedRouteKeys.includes(route.key);
|
|
129
|
+
const {
|
|
130
|
+
title,
|
|
131
|
+
lazy = true,
|
|
132
|
+
tabBarLabel,
|
|
133
|
+
tabBarBadgeStyle,
|
|
134
|
+
tabBarIcon,
|
|
135
|
+
tabBarBadge,
|
|
136
|
+
tabBarSystemItem
|
|
137
|
+
} = options;
|
|
138
|
+
const tabTitle =
|
|
139
|
+
// On iOS, `systemItem` already provides a localized label
|
|
140
|
+
// So we should only use `tabBarLabel` if explicitly provided
|
|
141
|
+
Platform.OS === 'ios' && tabBarSystemItem != null ? tabBarLabel : getLabel({
|
|
142
|
+
label: tabBarLabel,
|
|
143
|
+
title
|
|
144
|
+
}, route.name);
|
|
145
|
+
const tabItemAppearance = {
|
|
146
|
+
tabBarItemTitleFontFamily: fontFamily,
|
|
147
|
+
tabBarItemTitleFontSize: fontSize,
|
|
148
|
+
tabBarItemTitleFontWeight: fontWeight,
|
|
149
|
+
tabBarItemTitleFontStyle: fontStyle
|
|
150
|
+
};
|
|
151
|
+
const badgeBackgroundColor = tabBarBadgeStyle?.backgroundColor ?? colors.notification;
|
|
152
|
+
const badgeTextColor = typeof badgeBackgroundColor === 'string' && Color(badgeBackgroundColor)?.isLight() ? 'black' : 'white';
|
|
153
|
+
const icon = typeof tabBarIcon === 'function' ? getPlatformIcon(tabBarIcon({
|
|
154
|
+
focused: false
|
|
155
|
+
})) : tabBarIcon != null ? getPlatformIcon(tabBarIcon) : undefined;
|
|
156
|
+
const selectedIcon = typeof tabBarIcon === 'function' ? getPlatformIcon(tabBarIcon({
|
|
157
|
+
focused: true
|
|
158
|
+
})) : undefined;
|
|
159
|
+
return /*#__PURE__*/_jsx(BottomTabsScreen, {
|
|
160
|
+
onWillDisappear: () => onTransitionStart({
|
|
161
|
+
closing: true,
|
|
162
|
+
route
|
|
163
|
+
}),
|
|
164
|
+
onWillAppear: () => onTransitionStart({
|
|
165
|
+
closing: false,
|
|
166
|
+
route
|
|
167
|
+
}),
|
|
168
|
+
onDidAppear: () => onTransitionEnd({
|
|
169
|
+
closing: false,
|
|
170
|
+
route
|
|
171
|
+
}),
|
|
172
|
+
onDidDisappear: () => onTransitionEnd({
|
|
173
|
+
closing: true,
|
|
174
|
+
route
|
|
175
|
+
}),
|
|
176
|
+
tabKey: route.key,
|
|
177
|
+
icon: icon,
|
|
178
|
+
selectedIcon: selectedIcon?.ios ?? selectedIcon?.shared,
|
|
179
|
+
tabBarItemBadgeBackgroundColor: badgeBackgroundColor,
|
|
180
|
+
tabBarItemBadgeTextColor: badgeTextColor,
|
|
181
|
+
badgeValue: tabBarBadge?.toString(),
|
|
182
|
+
systemItem: tabBarSystemItem,
|
|
183
|
+
isFocused: isFocused,
|
|
184
|
+
title: tabTitle,
|
|
185
|
+
standardAppearance: {
|
|
186
|
+
tabBarBackgroundColor,
|
|
187
|
+
tabBarShadowColor,
|
|
188
|
+
stacked: {
|
|
189
|
+
normal: tabItemAppearance
|
|
190
|
+
},
|
|
191
|
+
inline: {
|
|
192
|
+
normal: tabItemAppearance
|
|
193
|
+
},
|
|
194
|
+
compactInline: {
|
|
195
|
+
normal: tabItemAppearance
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
children: /*#__PURE__*/_jsx(Lazy, {
|
|
199
|
+
enabled: lazy ? isFocused || isPreloaded : true,
|
|
200
|
+
render: () => /*#__PURE__*/_jsx(NativeScreen, {
|
|
201
|
+
route: route,
|
|
202
|
+
navigation: navigation,
|
|
203
|
+
options: options,
|
|
204
|
+
children: render()
|
|
205
|
+
})
|
|
206
|
+
})
|
|
207
|
+
}, route.key);
|
|
208
|
+
})
|
|
209
|
+
})
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function getPlatformIcon(icon) {
|
|
213
|
+
return {
|
|
214
|
+
ios: icon?.type === 'sfSymbol' ? icon : icon?.type === 'image' && icon.tinted !== false ? {
|
|
215
|
+
type: 'templateSource',
|
|
216
|
+
templateSource: icon.source
|
|
217
|
+
} : undefined,
|
|
218
|
+
android: icon?.type === 'drawableResource' ? icon : undefined,
|
|
219
|
+
shared: icon?.type === 'image' ? {
|
|
220
|
+
type: 'imageSource',
|
|
221
|
+
imageSource: icon.source
|
|
222
|
+
} : undefined
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=NativeBottomTabView.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getLabel","Lazy","SafeAreaProviderCompat","CommonActions","StackActions","useTheme","Color","React","Platform","PlatformColor","BottomTabs","BottomTabsScreen","NativeScreen","jsx","_jsx","NativeBottomTabView","state","navigation","descriptors","colors","fonts","focusedRouteKey","routes","index","key","previousRouteKeyRef","useRef","useEffect","previousRouteKey","current","options","popToTopOnBlur","prevRoute","find","route","type","popToTopAction","popToTop","target","dispatch","currentOptions","backgroundColor","tabBarBackgroundColor","shadowColor","tabBarShadowColor","tabBarStyle","fontFamily","select","ios","medium","default","regular","fontWeight","fontSize","fontStyle","tabBarLabelStyle","activeTintColor","tabBarActiveTintColor","primary","inactiveTintColor","tabBarInactiveTintColor","text","activeIndicatorColor","tabBarActiveIndicatorColor","alpha","string","undefined","onTransitionStart","closing","emit","data","onTransitionEnd","children","tabBarItemLabelVisibilityMode","tabBarLabelVisibilityMode","tabBarControllerMode","tabBarMinimizeBehavior","tabBarTintColor","tabBarItemIconColor","tabBarItemIconColorActive","tabBarItemTitleFontColor","tabBarItemTitleFontColorActive","tabBarItemTitleFontFamily","tabBarItemTitleFontWeight","tabBarItemTitleFontSize","tabBarItemTitleFontSizeActive","tabBarItemActiveIndicatorColor","tabBarItemActiveIndicatorEnabled","tabBarActiveIndicatorEnabled","tabBarItemRippleColor","tabBarRippleColor","experimentalControlNavigationStateInJS","onNativeFocusChange","e","nativeEvent","tabKey","isFocused","findIndex","r","event","canPreventDefault","defaultPrevented","startTransition","navigate","name","params","map","render","isPreloaded","preloadedRouteKeys","includes","title","lazy","tabBarLabel","tabBarBadgeStyle","tabBarIcon","tabBarBadge","tabBarSystemItem","tabTitle","OS","label","tabItemAppearance","tabBarItemTitleFontStyle","badgeBackgroundColor","notification","badgeTextColor","isLight","icon","getPlatformIcon","focused","selectedIcon","onWillDisappear","onWillAppear","onDidAppear","onDidDisappear","shared","tabBarItemBadgeBackgroundColor","tabBarItemBadgeTextColor","badgeValue","toString","systemItem","standardAppearance","stacked","normal","inline","compactInline","enabled","tinted","templateSource","source","android","imageSource"],"sourceRoot":"../../../src","sources":["unstable/NativeBottomTabView.native.tsx"],"mappings":";;AAAA,SACEA,QAAQ,EACRC,IAAI,EACJC,sBAAsB,QACjB,4BAA4B;AACnC,SACEC,aAAa,EAGbC,YAAY,EAEZC,QAAQ,QACH,0BAA0B;AACjC,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAA0BC,QAAQ,EAAEC,aAAa,QAAQ,cAAc;AACvE,SACEC,UAAU,EACVC,gBAAgB,QAGX,sBAAsB;AAE7B,SAASC,YAAY,QAAQ,gCAA6B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAc3D,OAAO,SAASC,mBAAmBA,CAAC;EAAEC,KAAK;EAAEC,UAAU;EAAEC;AAAmB,CAAC,EAAE;EAC7E,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGf,QAAQ,CAAC,CAAC;EAEpC,MAAMgB,eAAe,GAAGL,KAAK,CAACM,MAAM,CAACN,KAAK,CAACO,KAAK,CAAC,CAACC,GAAG;EACrD,MAAMC,mBAAmB,GAAGlB,KAAK,CAACmB,MAAM,CAACL,eAAe,CAAC;EAEzDd,KAAK,CAACoB,SAAS,CAAC,MAAM;IACpB,MAAMC,gBAAgB,GAAGH,mBAAmB,CAAC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,MAAM,EAAE;cACND,MAAM,EAAEtB;YACV,CAAC;YACDwB,aAAa,EAAE;cACbF,MAAM,EAAEtB;YACV;UACF,CAAE;UAAAjD,QAAA,eAEF1D,IAAA,CAACb,IAAI;YACHiJ,OAAO,EAAElC,IAAI,GAAGhB,SAAS,IAAIY,WAAW,GAAG,IAAK;YAChDD,MAAM,EAAEA,CAAA,kBACN7F,IAAA,CAACF,YAAY;cACXsB,KAAK,EAAEA,KAAM;cACbjB,UAAU,EAAEA,UAAW;cACvBa,OAAO,EAAEA,OAAQ;cAAA0C,QAAA,EAEhBmC,MAAM,CAAC;YAAC,CACG;UACd,CACH;QAAC,GAnCGzE,KAAK,CAACV,GAoCK,CAAC;MAEvB,CAAC;IAAC,CACQ;EAAC,CACS,CAAC;AAE7B;AAEA,SAASwG,eAAeA,CAACD,IAAU,EAAgB;EACjD,OAAO;IACL/E,GAAG,EACD+E,IAAI,EAAE5F,IAAI,KAAK,UAAU,GACrB4F,IAAI,GACJA,IAAI,EAAE5F,IAAI,KAAK,OAAO,IAAI4F,IAAI,CAACoB,MAAM,KAAK,KAAK,GAC7C;MACEhH,IAAI,EAAE,gBAAgB;MACtBiH,cAAc,EAAErB,IAAI,CAACsB;IACvB,CAAC,GACDnF,SAAS;IACjBoF,OAAO,EAAEvB,IAAI,EAAE5F,IAAI,KAAK,kBAAkB,GAAG4F,IAAI,GAAG7D,SAAS;IAC7DqE,MAAM,EACJR,IAAI,EAAE5F,IAAI,KAAK,OAAO,GAClB;MACEA,IAAI,EAAE,aAAa;MACnBoH,WAAW,EAAExB,IAAI,CAACsB;IACpB,CAAC,GACDnF;EACR,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { getDefaultHeaderHeight, HeaderHeightContext, HeaderShownContext, useFrameSize } from '@react-navigation/elements';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { Animated, Platform, StatusBar, StyleSheet, useAnimatedValue, View } from 'react-native';
|
|
6
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
7
|
+
import { ScreenStack, ScreenStackItem } from 'react-native-screens';
|
|
8
|
+
import { debounce } from "./debounce.js";
|
|
9
|
+
import { AnimatedHeaderHeightContext } from "./useAnimatedHeaderHeight.js";
|
|
10
|
+
import { useHeaderConfig } from "./useHeaderConfig.js";
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
const ANDROID_DEFAULT_HEADER_HEIGHT = 56;
|
|
13
|
+
export function NativeScreen({
|
|
14
|
+
route,
|
|
15
|
+
navigation,
|
|
16
|
+
options,
|
|
17
|
+
children
|
|
18
|
+
}) {
|
|
19
|
+
const {
|
|
20
|
+
headerShown = true,
|
|
21
|
+
headerTransparent,
|
|
22
|
+
headerBackground,
|
|
23
|
+
header: renderCustomHeader
|
|
24
|
+
} = options;
|
|
25
|
+
const isModal = false;
|
|
26
|
+
const insets = useSafeAreaInsets();
|
|
27
|
+
|
|
28
|
+
// Modals are fullscreen in landscape only on iPhone
|
|
29
|
+
const isIPhone = Platform.OS === 'ios' && !(Platform.isPad || Platform.isTV);
|
|
30
|
+
const isParentHeaderShown = React.useContext(HeaderShownContext);
|
|
31
|
+
const parentHeaderHeight = React.useContext(HeaderHeightContext);
|
|
32
|
+
const isLandscape = useFrameSize(frame => frame.width > frame.height);
|
|
33
|
+
const topInset = isParentHeaderShown || Platform.OS === 'ios' && isModal || isIPhone && isLandscape ? 0 : insets.top;
|
|
34
|
+
const defaultHeaderHeight = useFrameSize(frame => Platform.select({
|
|
35
|
+
// FIXME: Currently screens isn't using Material 3
|
|
36
|
+
// So our `getDefaultHeaderHeight` doesn't return the correct value
|
|
37
|
+
// So we hardcode the value here for now until screens is updated
|
|
38
|
+
android: ANDROID_DEFAULT_HEADER_HEIGHT + topInset,
|
|
39
|
+
default: getDefaultHeaderHeight(frame, isModal, topInset)
|
|
40
|
+
}));
|
|
41
|
+
const [headerHeight, setHeaderHeight] = React.useState(defaultHeaderHeight);
|
|
42
|
+
|
|
43
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
44
|
+
const setHeaderHeightDebounced = React.useCallback(
|
|
45
|
+
// Debounce the header height updates to avoid excessive re-renders
|
|
46
|
+
debounce(setHeaderHeight, 100), []);
|
|
47
|
+
const hasCustomHeader = renderCustomHeader != null;
|
|
48
|
+
let headerHeightCorrectionOffset = 0;
|
|
49
|
+
if (Platform.OS === 'android' && !hasCustomHeader) {
|
|
50
|
+
const statusBarHeight = StatusBar.currentHeight ?? 0;
|
|
51
|
+
|
|
52
|
+
// FIXME: On Android, the native header height is not correctly calculated
|
|
53
|
+
// It includes status bar height even if statusbar is not translucent
|
|
54
|
+
// And the statusbar value itself doesn't match the actual status bar height
|
|
55
|
+
// So we subtract the bogus status bar height and add the actual top inset
|
|
56
|
+
headerHeightCorrectionOffset = -statusBarHeight + topInset;
|
|
57
|
+
}
|
|
58
|
+
const rawAnimatedHeaderHeight = useAnimatedValue(defaultHeaderHeight);
|
|
59
|
+
const animatedHeaderHeight = React.useMemo(() => Animated.add(rawAnimatedHeaderHeight, headerHeightCorrectionOffset), [headerHeightCorrectionOffset, rawAnimatedHeaderHeight]);
|
|
60
|
+
const headerTopInsetEnabled = topInset !== 0;
|
|
61
|
+
const onHeaderHeightChange = Animated.event([{
|
|
62
|
+
nativeEvent: {
|
|
63
|
+
headerHeight: rawAnimatedHeaderHeight
|
|
64
|
+
}
|
|
65
|
+
}], {
|
|
66
|
+
useNativeDriver: true,
|
|
67
|
+
listener: e => {
|
|
68
|
+
if (hasCustomHeader) {
|
|
69
|
+
// If we have a custom header, don't use native header height
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (Platform.OS === 'android' && (options.headerBackground != null || options.headerTransparent)) {
|
|
73
|
+
// FIXME: On Android, we get 0 if the header is translucent
|
|
74
|
+
// So we set a default height in that case
|
|
75
|
+
setHeaderHeight(ANDROID_DEFAULT_HEADER_HEIGHT + topInset);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (e.nativeEvent && typeof e.nativeEvent === 'object' && 'headerHeight' in e.nativeEvent && typeof e.nativeEvent.headerHeight === 'number') {
|
|
79
|
+
const headerHeight = e.nativeEvent.headerHeight + headerHeightCorrectionOffset;
|
|
80
|
+
|
|
81
|
+
// Only debounce if header has large title or search bar
|
|
82
|
+
// As it's the only case where the header height can change frequently
|
|
83
|
+
const doesHeaderAnimate = Platform.OS === 'ios' && (options.headerLargeTitle || options.headerSearchBarOptions);
|
|
84
|
+
if (doesHeaderAnimate) {
|
|
85
|
+
setHeaderHeightDebounced(headerHeight);
|
|
86
|
+
} else {
|
|
87
|
+
setHeaderHeight(headerHeight);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const headerConfig = useHeaderConfig({
|
|
93
|
+
...options,
|
|
94
|
+
route,
|
|
95
|
+
headerHeight,
|
|
96
|
+
headerShown: hasCustomHeader ? false : headerShown === true,
|
|
97
|
+
headerTopInsetEnabled
|
|
98
|
+
});
|
|
99
|
+
return /*#__PURE__*/_jsx(ScreenStack, {
|
|
100
|
+
style: styles.container,
|
|
101
|
+
children: /*#__PURE__*/_jsx(ScreenStackItem, {
|
|
102
|
+
screenId: route.key,
|
|
103
|
+
headerConfig: headerConfig,
|
|
104
|
+
onHeaderHeightChange: onHeaderHeightChange,
|
|
105
|
+
children: /*#__PURE__*/_jsx(AnimatedHeaderHeightContext.Provider, {
|
|
106
|
+
value: animatedHeaderHeight,
|
|
107
|
+
children: /*#__PURE__*/_jsxs(HeaderHeightContext.Provider, {
|
|
108
|
+
value: headerShown ? headerHeight : parentHeaderHeight ?? 0,
|
|
109
|
+
children: [headerBackground != null ?
|
|
110
|
+
/*#__PURE__*/
|
|
111
|
+
/**
|
|
112
|
+
* To show a custom header background, we render it at the top of the screen below the header
|
|
113
|
+
* The header also needs to be positioned absolutely (with `translucent` style)
|
|
114
|
+
*/
|
|
115
|
+
_jsx(View, {
|
|
116
|
+
style: [styles.background, headerTransparent ? styles.translucent : null, {
|
|
117
|
+
height: headerHeight
|
|
118
|
+
}],
|
|
119
|
+
children: headerBackground()
|
|
120
|
+
}) : null, hasCustomHeader && headerShown ? /*#__PURE__*/_jsx(View, {
|
|
121
|
+
onLayout: e => {
|
|
122
|
+
const headerHeight = e.nativeEvent.layout.height;
|
|
123
|
+
setHeaderHeight(headerHeight);
|
|
124
|
+
rawAnimatedHeaderHeight.setValue(headerHeight);
|
|
125
|
+
},
|
|
126
|
+
style: [styles.header, headerTransparent ? styles.absolute : null],
|
|
127
|
+
children: renderCustomHeader?.({
|
|
128
|
+
route,
|
|
129
|
+
navigation,
|
|
130
|
+
options
|
|
131
|
+
})
|
|
132
|
+
}) : null, /*#__PURE__*/_jsx(HeaderShownContext.Provider, {
|
|
133
|
+
value: isParentHeaderShown || headerShown,
|
|
134
|
+
children: children
|
|
135
|
+
})]
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
const styles = StyleSheet.create({
|
|
142
|
+
container: {
|
|
143
|
+
flex: 1
|
|
144
|
+
},
|
|
145
|
+
header: {
|
|
146
|
+
zIndex: 1
|
|
147
|
+
},
|
|
148
|
+
absolute: {
|
|
149
|
+
position: 'absolute',
|
|
150
|
+
top: 0,
|
|
151
|
+
start: 0,
|
|
152
|
+
end: 0
|
|
153
|
+
},
|
|
154
|
+
translucent: {
|
|
155
|
+
position: 'absolute',
|
|
156
|
+
top: 0,
|
|
157
|
+
start: 0,
|
|
158
|
+
end: 0,
|
|
159
|
+
zIndex: 1,
|
|
160
|
+
elevation: 1
|
|
161
|
+
},
|
|
162
|
+
background: {
|
|
163
|
+
overflow: 'hidden'
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
//# sourceMappingURL=NativeScreen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getDefaultHeaderHeight","HeaderHeightContext","HeaderShownContext","useFrameSize","React","Animated","Platform","StatusBar","StyleSheet","useAnimatedValue","View","useSafeAreaInsets","ScreenStack","ScreenStackItem","debounce","AnimatedHeaderHeightContext","useHeaderConfig","jsx","_jsx","jsxs","_jsxs","ANDROID_DEFAULT_HEADER_HEIGHT","NativeScreen","route","navigation","options","children","headerShown","headerTransparent","headerBackground","header","renderCustomHeader","isModal","insets","isIPhone","OS","isPad","isTV","isParentHeaderShown","useContext","parentHeaderHeight","isLandscape","frame","width","height","topInset","top","defaultHeaderHeight","select","android","default","headerHeight","setHeaderHeight","useState","setHeaderHeightDebounced","useCallback","hasCustomHeader","headerHeightCorrectionOffset","statusBarHeight","currentHeight","rawAnimatedHeaderHeight","animatedHeaderHeight","useMemo","add","headerTopInsetEnabled","onHeaderHeightChange","event","nativeEvent","useNativeDriver","listener","e","doesHeaderAnimate","headerLargeTitle","headerSearchBarOptions","headerConfig","style","styles","container","screenId","key","Provider","value","background","translucent","onLayout","layout","setValue","absolute","create","flex","zIndex","position","start","end","elevation","overflow"],"sourceRoot":"../../../../src","sources":["unstable/NativeScreen/NativeScreen.tsx"],"mappings":";;AAAA,SACEA,sBAAsB,EACtBC,mBAAmB,EACnBC,kBAAkB,EAClBC,YAAY,QACP,4BAA4B;AACnC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SACEC,QAAQ,EACRC,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,gBAAgB,EAChBC,IAAI,QACC,cAAc;AACrB,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SAASC,WAAW,EAAEC,eAAe,QAAQ,sBAAsB;AAGnE,SAASC,QAAQ,QAAQ,eAAY;AACrC,SAASC,2BAA2B,QAAQ,8BAA2B;AACvE,SAASC,eAAe,QAAQ,sBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAMpD,MAAMC,6BAA6B,GAAG,EAAE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-0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["debounce","func","duration","timeout","args","clearTimeout","setTimeout","apply"],"sourceRoot":"../../../../src","sources":["unstable/NativeScreen/debounce.tsx"],"mappings":";;AAAA,OAAO,SAASA,QAAQA,CACtBC,IAAO,EACPC,QAAgB,EACb;EACH,IAAIC,OAAsC;EAE1C,OAAO,UAAyB,GAAGC,IAAI,EAAE;IACvCC,YAAY,CAACF,OAAO,CAAC;IAErBA,OAAO,GAAGG,UAAU,CAAC,MAAM;MACzBL,IAAI,CAACM,KAAK,CAAC,IAAI,EAAEH,IAAI,CAAC;IACxB,CAAC,EAAEF,QAAQ,CAAC;EACd,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["unstable/NativeScreen/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
export const AnimatedHeaderHeightContext = /*#__PURE__*/React.createContext(undefined);
|
|
5
|
+
export function useAnimatedHeaderHeight() {
|
|
6
|
+
const animatedValue = React.useContext(AnimatedHeaderHeightContext);
|
|
7
|
+
if (animatedValue === undefined) {
|
|
8
|
+
throw new Error("Couldn't find the header height. Are you inside a screen in a native stack navigator?");
|
|
9
|
+
}
|
|
10
|
+
return animatedValue;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=useAnimatedHeaderHeight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","AnimatedHeaderHeightContext","createContext","undefined","useAnimatedHeaderHeight","animatedValue","useContext","Error"],"sourceRoot":"../../../../src","sources":["unstable/NativeScreen/useAnimatedHeaderHeight.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAG9B,OAAO,MAAMC,2BAA2B,gBAAGD,KAAK,CAACE,aAAa,CAE5DC,SAAS,CAAC;AAEZ,OAAO,SAASC,uBAAuBA,CAAA,EAAG;EACxC,MAAMC,aAAa,GAAGL,KAAK,CAACM,UAAU,CAACL,2BAA2B,CAAC;EAEnE,IAAII,aAAa,KAAKF,SAAS,EAAE;IAC/B,MAAM,IAAII,KAAK,CACb,uFACF,CAAC;EACH;EAEA,OAAOF,aAAa;AACtB","ignoreList":[]}
|