expo-router 6.0.0-beta.5 → 6.0.0-beta.7
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/build/native-tabs/NativeBottomTabs/NativeTabTrigger.d.ts +9 -2
- package/build/native-tabs/NativeBottomTabs/NativeTabTrigger.d.ts.map +1 -1
- package/build/native-tabs/NativeBottomTabs/NativeTabTrigger.js +136 -49
- package/build/native-tabs/NativeBottomTabs/NativeTabTrigger.js.map +1 -1
- package/build/native-tabs/NativeBottomTabs/NativeTabs.d.ts +3 -2
- package/build/native-tabs/NativeBottomTabs/NativeTabs.d.ts.map +1 -1
- package/build/native-tabs/NativeBottomTabs/NativeTabsTriggerTabBar.d.ts +24 -0
- package/build/native-tabs/NativeBottomTabs/NativeTabsTriggerTabBar.d.ts.map +1 -0
- package/build/native-tabs/NativeBottomTabs/NativeTabsTriggerTabBar.js +28 -0
- package/build/native-tabs/NativeBottomTabs/NativeTabsTriggerTabBar.js.map +1 -0
- package/build/native-tabs/NativeBottomTabs/NativeTabsView.d.ts.map +1 -1
- package/build/native-tabs/NativeBottomTabs/NativeTabsView.js +115 -18
- package/build/native-tabs/NativeBottomTabs/NativeTabsView.js.map +1 -1
- package/build/native-tabs/NativeBottomTabs/NativeTabsView.web.d.ts.map +1 -1
- package/build/native-tabs/NativeBottomTabs/NativeTabsView.web.js +57 -27
- package/build/native-tabs/NativeBottomTabs/NativeTabsView.web.js.map +1 -1
- package/build/native-tabs/NativeBottomTabs/appearance.d.ts +20 -0
- package/build/native-tabs/NativeBottomTabs/appearance.d.ts.map +1 -0
- package/build/native-tabs/NativeBottomTabs/appearance.js +131 -0
- package/build/native-tabs/NativeBottomTabs/appearance.js.map +1 -0
- package/build/native-tabs/NativeBottomTabs/types.d.ts +235 -77
- package/build/native-tabs/NativeBottomTabs/types.d.ts.map +1 -1
- package/build/native-tabs/NativeBottomTabs/types.js +14 -0
- package/build/native-tabs/NativeBottomTabs/types.js.map +1 -1
- package/build/native-tabs/common/elements.d.ts +84 -21
- package/build/native-tabs/common/elements.d.ts.map +1 -1
- package/build/native-tabs/common/elements.js +23 -0
- package/build/native-tabs/common/elements.js.map +1 -1
- package/build/native-tabs/index.d.ts +2 -1
- package/build/native-tabs/index.d.ts.map +1 -1
- package/build/native-tabs/index.js +3 -1
- package/build/native-tabs/index.js.map +1 -1
- package/ios/ExpoHead.podspec +2 -0
- package/package.json +5 -5
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import { NativeTabsTriggerTabBar } from './NativeTabsTriggerTabBar';
|
|
2
3
|
import type { ExtendedNativeTabOptions, NativeTabTriggerProps } from './types';
|
|
4
|
+
import { type IconProps } from '../common/elements';
|
|
3
5
|
/**
|
|
4
6
|
* The component used to customize the native tab options both in the _layout file and from the tab screen.
|
|
5
7
|
*
|
|
@@ -40,9 +42,14 @@ import type { ExtendedNativeTabOptions, NativeTabTriggerProps } from './types';
|
|
|
40
42
|
*
|
|
41
43
|
* > **Note:** You can use the alias `NativeTabs.Trigger` for this component.
|
|
42
44
|
*/
|
|
43
|
-
|
|
44
|
-
export declare
|
|
45
|
+
declare function NativeTabTriggerImpl(props: NativeTabTriggerProps): null;
|
|
46
|
+
export declare const NativeTabTrigger: typeof NativeTabTriggerImpl & {
|
|
47
|
+
TabBar: typeof NativeTabsTriggerTabBar;
|
|
48
|
+
};
|
|
49
|
+
export declare function convertTabPropsToOptions({ options, hidden, children, role, disablePopToTop, disableScrollToTop, }: NativeTabTriggerProps): ExtendedNativeTabOptions;
|
|
50
|
+
export declare function appendIconOptions(options: ExtendedNativeTabOptions, props: IconProps): void;
|
|
45
51
|
export declare function isNativeTabTrigger(child: ReactNode, contextKey?: string): child is ReactElement<NativeTabTriggerProps & {
|
|
46
52
|
name: string;
|
|
47
53
|
}>;
|
|
54
|
+
export {};
|
|
48
55
|
//# sourceMappingURL=NativeTabTrigger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeTabTrigger.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabTrigger.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"NativeTabTrigger.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabTrigger.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EACV,wBAAwB,EAGxB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAKL,KAAK,SAAS,EAKf,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,iBAAS,oBAAoB,CAAC,KAAK,EAAE,qBAAqB,QAqBzD;AAED,eAAO,MAAM,gBAAgB;;CAE3B,CAAC;AAEH,wBAAgB,wBAAwB,CAAC,EACvC,OAAO,EACP,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,eAAe,EACf,kBAAkB,GACnB,EAAE,qBAAqB,4BAiCvB;AAuBD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,EAAE,KAAK,EAAE,SAAS,QA8BpF;AAiFD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,SAAS,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,KAAK,IAAI,YAAY,CAAC,qBAAqB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CA6BjE"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.NativeTabTrigger =
|
|
4
|
+
exports.NativeTabTrigger = void 0;
|
|
5
5
|
exports.convertTabPropsToOptions = convertTabPropsToOptions;
|
|
6
|
+
exports.appendIconOptions = appendIconOptions;
|
|
6
7
|
exports.isNativeTabTrigger = isNativeTabTrigger;
|
|
7
8
|
const native_1 = require("@react-navigation/native");
|
|
8
9
|
const react_1 = require("react");
|
|
10
|
+
const NativeTabsTriggerTabBar_1 = require("./NativeTabsTriggerTabBar");
|
|
9
11
|
const utils_1 = require("./utils");
|
|
10
12
|
const useSafeLayoutEffect_1 = require("../../views/useSafeLayoutEffect");
|
|
11
13
|
const elements_1 = require("../common/elements");
|
|
@@ -49,7 +51,7 @@ const elements_1 = require("../common/elements");
|
|
|
49
51
|
*
|
|
50
52
|
* > **Note:** You can use the alias `NativeTabs.Trigger` for this component.
|
|
51
53
|
*/
|
|
52
|
-
function
|
|
54
|
+
function NativeTabTriggerImpl(props) {
|
|
53
55
|
const route = (0, native_1.useRoute)();
|
|
54
56
|
const navigation = (0, native_1.useNavigation)();
|
|
55
57
|
const isFocused = navigation.isFocused();
|
|
@@ -67,7 +69,10 @@ function NativeTabTrigger(props) {
|
|
|
67
69
|
}, [isFocused, props]);
|
|
68
70
|
return null;
|
|
69
71
|
}
|
|
70
|
-
|
|
72
|
+
exports.NativeTabTrigger = Object.assign(NativeTabTriggerImpl, {
|
|
73
|
+
TabBar: NativeTabsTriggerTabBar_1.NativeTabsTriggerTabBar,
|
|
74
|
+
});
|
|
75
|
+
function convertTabPropsToOptions({ options, hidden, children, role, disablePopToTop, disableScrollToTop, }) {
|
|
71
76
|
const initialOptions = {
|
|
72
77
|
...options,
|
|
73
78
|
hidden: !!hidden,
|
|
@@ -77,65 +82,147 @@ function convertTabPropsToOptions({ options, hidden, children, disablePopToTop,
|
|
|
77
82
|
scrollToTop: !disableScrollToTop,
|
|
78
83
|
},
|
|
79
84
|
},
|
|
85
|
+
role: role ?? options?.role,
|
|
80
86
|
};
|
|
81
|
-
const allowedChildren = (0, utils_1.filterAllowedChildrenElements)(children, [
|
|
87
|
+
const allowedChildren = (0, utils_1.filterAllowedChildrenElements)(children, [
|
|
88
|
+
elements_1.Badge,
|
|
89
|
+
elements_1.Label,
|
|
90
|
+
elements_1.Icon,
|
|
91
|
+
NativeTabsTriggerTabBar_1.NativeTabsTriggerTabBar,
|
|
92
|
+
]);
|
|
82
93
|
return allowedChildren.reduce((acc, child) => {
|
|
83
94
|
if ((0, utils_1.isChildOfType)(child, elements_1.Badge)) {
|
|
84
|
-
|
|
85
|
-
acc.badgeValue = String(child.props.children);
|
|
86
|
-
}
|
|
87
|
-
else if (!child.props.hidden) {
|
|
88
|
-
// If no value is provided, we set it to a space to show the badge
|
|
89
|
-
// Otherwise, the `react-native-screens` will interpret it as a hidden badge
|
|
90
|
-
// https://github.com/software-mansion/react-native-screens/blob/b4358fd95dd0736fc54df6bb97f210dc89edf24c/ios/bottom-tabs/RNSBottomTabsScreenComponentView.mm#L172
|
|
91
|
-
acc.badgeValue = ' ';
|
|
92
|
-
}
|
|
95
|
+
appendBadgeOptions(acc, child.props);
|
|
93
96
|
}
|
|
94
97
|
else if ((0, utils_1.isChildOfType)(child, elements_1.Label)) {
|
|
95
|
-
|
|
96
|
-
acc.title = '';
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
acc.title = child.props.children;
|
|
100
|
-
}
|
|
98
|
+
appendLabelOptions(acc, child.props);
|
|
101
99
|
}
|
|
102
100
|
else if ((0, utils_1.isChildOfType)(child, elements_1.Icon)) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
101
|
+
appendIconOptions(acc, child.props);
|
|
102
|
+
}
|
|
103
|
+
else if ((0, utils_1.isChildOfType)(child, NativeTabsTriggerTabBar_1.NativeTabsTriggerTabBar)) {
|
|
104
|
+
appendTabBarOptions(acc, child.props);
|
|
105
|
+
}
|
|
106
|
+
return acc;
|
|
107
|
+
}, { ...initialOptions });
|
|
108
|
+
}
|
|
109
|
+
function appendBadgeOptions(options, props) {
|
|
110
|
+
if (props.children) {
|
|
111
|
+
options.badgeValue = String(props.children);
|
|
112
|
+
options.selectedBadgeBackgroundColor = props.selectedBackgroundColor;
|
|
113
|
+
}
|
|
114
|
+
else if (!props.hidden) {
|
|
115
|
+
// If no value is provided, we set it to a space to show the badge
|
|
116
|
+
// Otherwise, the `react-native-screens` will interpret it as a hidden badge
|
|
117
|
+
// https://github.com/software-mansion/react-native-screens/blob/b4358fd95dd0736fc54df6bb97f210dc89edf24c/ios/bottom-tabs/RNSBottomTabsScreenComponentView.mm#L172
|
|
118
|
+
options.badgeValue = ' ';
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function appendLabelOptions(options, props) {
|
|
122
|
+
if (props.hidden) {
|
|
123
|
+
options.title = '';
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
options.title = props.children;
|
|
127
|
+
options.selectedLabelStyle = props.selectedStyle;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function appendIconOptions(options, props) {
|
|
131
|
+
if ('src' in props && props.src) {
|
|
132
|
+
const icon = convertIconSrcToIconOption(props);
|
|
133
|
+
options.icon = icon?.icon;
|
|
134
|
+
options.selectedIcon = icon?.selectedIcon;
|
|
135
|
+
}
|
|
136
|
+
else if ('sf' in props && process.env.EXPO_OS === 'ios') {
|
|
137
|
+
if (typeof props.sf === 'string') {
|
|
138
|
+
options.icon = props.sf
|
|
139
|
+
? {
|
|
140
|
+
sf: props.sf,
|
|
141
|
+
}
|
|
142
|
+
: undefined;
|
|
143
|
+
options.selectedIcon = undefined;
|
|
144
|
+
}
|
|
145
|
+
else if (props.sf) {
|
|
146
|
+
options.icon = props.sf.default
|
|
147
|
+
? {
|
|
148
|
+
sf: props.sf.default,
|
|
149
|
+
}
|
|
150
|
+
: undefined;
|
|
151
|
+
options.selectedIcon = props.sf.selected
|
|
152
|
+
? {
|
|
153
|
+
sf: props.sf.selected,
|
|
127
154
|
}
|
|
155
|
+
: undefined;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else if ('drawable' in props && process.env.EXPO_OS === 'android') {
|
|
159
|
+
options.icon = { drawable: props.drawable };
|
|
160
|
+
options.selectedIcon = undefined;
|
|
161
|
+
}
|
|
162
|
+
options.selectedIconColor = props.selectedColor;
|
|
163
|
+
}
|
|
164
|
+
function convertIconSrcToIconOption(icon) {
|
|
165
|
+
if (icon && icon.src) {
|
|
166
|
+
const { defaultIcon, selected } = typeof icon.src === 'object' && 'selected' in icon.src
|
|
167
|
+
? { defaultIcon: icon.src.default, selected: icon.src.selected }
|
|
168
|
+
: { defaultIcon: icon.src };
|
|
169
|
+
const options = {};
|
|
170
|
+
options.icon = convertSrcOrComponentToSrc(defaultIcon);
|
|
171
|
+
options.selectedIcon = convertSrcOrComponentToSrc(selected);
|
|
172
|
+
return options;
|
|
173
|
+
}
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
function convertSrcOrComponentToSrc(src) {
|
|
177
|
+
if (src) {
|
|
178
|
+
if ((0, react_1.isValidElement)(src)) {
|
|
179
|
+
if (src.type === elements_1.VectorIcon) {
|
|
180
|
+
const props = src.props;
|
|
181
|
+
return { src: props.family.getImageSource(props.name, 24, 'white') };
|
|
128
182
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
acc.selectedIcon = undefined;
|
|
183
|
+
else {
|
|
184
|
+
console.warn('Only VectorIcon is supported as a React element in Icon.src');
|
|
132
185
|
}
|
|
133
186
|
}
|
|
134
|
-
|
|
135
|
-
|
|
187
|
+
else {
|
|
188
|
+
return { src };
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return undefined;
|
|
192
|
+
}
|
|
193
|
+
function appendTabBarOptions(options, props) {
|
|
194
|
+
const { backgroundColor, blurEffect, iconColor, disableTransparentOnScrollEdge, badgeBackgroundColor, badgeTextColor, indicatorColor, labelStyle, } = props;
|
|
195
|
+
if (backgroundColor) {
|
|
196
|
+
options.backgroundColor = backgroundColor;
|
|
197
|
+
}
|
|
198
|
+
// We need better native integration of this on Android
|
|
199
|
+
// Simulating from JS side creates ugly transitions
|
|
200
|
+
if (process.env.EXPO_OS !== 'android') {
|
|
201
|
+
if (blurEffect) {
|
|
202
|
+
options.blurEffect = blurEffect;
|
|
203
|
+
}
|
|
204
|
+
if (iconColor) {
|
|
205
|
+
options.iconColor = iconColor;
|
|
206
|
+
}
|
|
207
|
+
if (disableTransparentOnScrollEdge !== undefined) {
|
|
208
|
+
options.disableTransparentOnScrollEdge = disableTransparentOnScrollEdge;
|
|
209
|
+
}
|
|
210
|
+
if (badgeBackgroundColor) {
|
|
211
|
+
options.badgeBackgroundColor = badgeBackgroundColor;
|
|
212
|
+
}
|
|
213
|
+
if (badgeTextColor) {
|
|
214
|
+
options.badgeTextColor = badgeTextColor;
|
|
215
|
+
}
|
|
216
|
+
if (indicatorColor) {
|
|
217
|
+
options.indicatorColor = indicatorColor;
|
|
218
|
+
}
|
|
219
|
+
if (labelStyle) {
|
|
220
|
+
options.labelStyle = labelStyle;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
136
223
|
}
|
|
137
224
|
function isNativeTabTrigger(child, contextKey) {
|
|
138
|
-
if ((0, react_1.isValidElement)(child) && child && child.type === NativeTabTrigger) {
|
|
225
|
+
if ((0, react_1.isValidElement)(child) && child && child.type === exports.NativeTabTrigger) {
|
|
139
226
|
if (typeof child.props === 'object' &&
|
|
140
227
|
child.props &&
|
|
141
228
|
'name' in child.props &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeTabTrigger.js","sourceRoot":"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C,KAAK,CAAC,KAAK,CAAC,IAAI,EACjB,CAAC;YACD,MAAM,IAAI,KAAK,CACb,uDAAuD,UAAU,8EAA8E,CAChJ,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;YAC1C,IACE,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,IAAI,CAChC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,GAAG,IAAI,KAAK,CAAC,KAAK,CAC9E,EACD,CAAC;gBACD,MAAM,IAAI,KAAK,CACb,uDAAuD,UAAU,0GAA0G,CAC5K,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["'use client';\n\nimport { useNavigation, useRoute } from '@react-navigation/native';\nimport { isValidElement, type ReactElement, type ReactNode } from 'react';\n\nimport type { ExtendedNativeTabOptions, NativeTabTriggerProps } from './types';\nimport { filterAllowedChildrenElements, isChildOfType } from './utils';\nimport { useSafeLayoutEffect } from '../../views/useSafeLayoutEffect';\nimport { Icon, Badge, Label } from '../common/elements';\n\n/**\n * The component used to customize the native tab options both in the _layout file and from the tab screen.\n *\n * When used in the _layout file, you need to provide a `name` prop.\n * When used in the tab screen, the `name` prop takes no effect.\n *\n * @example\n * ```tsx\n * // In _layout file\n * import { NativeTabs } from 'expo-router/unstable-native-tabs';\n *\n * export default function Layout() {\n * return (\n * <NativeTabs>\n * <NativeTabs.Trigger name=\"home\" />\n * <NativeTabs.Trigger name=\"settings\" />\n * </NativeTabs>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // In a tab screen\n * import { NativeTabs } from 'expo-router/unstable-native-tabs';\n *\n * export default function HomeScreen() {\n * return (\n * <View>\n * <NativeTabs.Trigger>\n * <Label>Home</Label>\n * </NativeTabs.Trigger>\n * <Text>This is home screen!</Text>\n * </View>\n * );\n * }\n * ```\n *\n * > **Note:** You can use the alias `NativeTabs.Trigger` for this component.\n */\nexport function NativeTabTrigger(props: NativeTabTriggerProps) {\n const route = useRoute();\n const navigation = useNavigation();\n const isFocused = navigation.isFocused();\n\n useSafeLayoutEffect(() => {\n // This will cause the tab to update only when it is focused.\n // As long as all tabs are loaded at the start, we don't need this check.\n // It is here to ensure similar behavior to stack\n if (isFocused) {\n if (navigation.getState()?.type !== 'tab') {\n throw new Error(\n `Trigger component can only be used in the tab screen. Current route: ${route.name}`\n );\n }\n const options = convertTabPropsToOptions(props);\n navigation.setOptions(options);\n }\n }, [isFocused, props]);\n\n return null;\n}\n\nexport function convertTabPropsToOptions({\n options,\n hidden,\n children,\n disablePopToTop,\n disableScrollToTop,\n}: NativeTabTriggerProps) {\n const initialOptions: ExtendedNativeTabOptions = {\n ...options,\n hidden: !!hidden,\n specialEffects: {\n repeatedTabSelection: {\n popToRoot: !disablePopToTop,\n scrollToTop: !disableScrollToTop,\n },\n },\n };\n const allowedChildren = filterAllowedChildrenElements(children, [Badge, Label, Icon]);\n return allowedChildren.reduce<ExtendedNativeTabOptions>(\n (acc, child) => {\n if (isChildOfType(child, Badge)) {\n if (child.props.children) {\n acc.badgeValue = String(child.props.children);\n } else if (!child.props.hidden) {\n // If no value is provided, we set it to a space to show the badge\n // Otherwise, the `react-native-screens` will interpret it as a hidden badge\n // https://github.com/software-mansion/react-native-screens/blob/b4358fd95dd0736fc54df6bb97f210dc89edf24c/ios/bottom-tabs/RNSBottomTabsScreenComponentView.mm#L172\n acc.badgeValue = ' ';\n }\n } else if (isChildOfType(child, Label)) {\n if (child.props.hidden) {\n acc.title = '';\n } else {\n acc.title = child.props.children;\n }\n } else if (isChildOfType(child, Icon)) {\n if ('src' in child.props || 'selectedSrc' in child.props) {\n acc.icon = child.props.src\n ? {\n src: child.props.src,\n }\n : undefined;\n acc.selectedIcon = child.props.selectedSrc\n ? {\n src: child.props.selectedSrc,\n }\n : undefined;\n } else if ('sf' in child.props || 'selectedSf' in child.props) {\n if (process.env.EXPO_OS === 'ios') {\n acc.icon = child.props.sf\n ? {\n sf: child.props.sf,\n }\n : undefined;\n acc.selectedIcon = child.props.selectedSf\n ? {\n sf: child.props.selectedSf,\n }\n : undefined;\n }\n }\n if (process.env.EXPO_OS === 'android') {\n acc.icon = { drawable: child.props.drawable };\n acc.selectedIcon = undefined;\n }\n }\n return acc;\n },\n { ...initialOptions }\n );\n}\n\nexport function isNativeTabTrigger(\n child: ReactNode,\n contextKey?: string\n): child is ReactElement<NativeTabTriggerProps & { name: string }> {\n if (isValidElement(child) && child && child.type === NativeTabTrigger) {\n if (\n typeof child.props === 'object' &&\n child.props &&\n 'name' in child.props &&\n !child.props.name\n ) {\n throw new Error(\n `<Trigger /> component in \\`default export\\` at \\`app${contextKey}/_layout\\` must have a \\`name\\` prop when used as a child of a Layout Route.`\n );\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (\n ['component', 'getComponent'].some(\n (key) => child.props && typeof child.props === 'object' && key in child.props\n )\n ) {\n throw new Error(\n `<Trigger /> component in \\`default export\\` at \\`app${contextKey}/_layout\\` must not have a \\`component\\` or \\`getComponent\\` prop when used as a child of a Layout Route`\n );\n }\n }\n\n return true;\n }\n\n return false;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NativeTabTrigger.js","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabTrigger.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AA8Fb,4DAwCC;AAuBD,8CA8BC;AAiFD,gDAgCC;AA1SD,qDAAmE;AACnE,iCAA0E;AAG1E,uEAAoE;AAOpE,mCAAuE;AACvE,yEAAsE;AACtE,iDAU4B;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,SAAS,oBAAoB,CAAC,KAA4B;IACxD,MAAM,KAAK,GAAG,IAAA,iBAAQ,GAAE,CAAC;IACzB,M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,IAAA,sBAAc,EAAC,KAAK,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,wBAAgB,EAAE,CAAC;QACtE,IACE,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;YAC/B,KAAK,CAAC,KAAK;YACX,MAAM,IAAI,KAAK,CAAC,KAAK;YACrB,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EACjB,CAAC;YACD,MAAM,IAAI,KAAK,CACb,uDAAuD,UAAU,8EAA8E,CAChJ,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;YAC1C,IACE,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,IAAI,CAChC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,GAAG,IAAI,KAAK,CAAC,KAAK,CAC9E,EACD,CAAC;gBACD,MAAM,IAAI,KAAK,CACb,uDAAuD,UAAU,0GAA0G,CAC5K,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["'use client';\n\nimport { useNavigation, useRoute } from '@react-navigation/native';\nimport { isValidElement, type ReactElement, type ReactNode } from 'react';\nimport type { ImageSourcePropType } from 'react-native';\n\nimport { NativeTabsTriggerTabBar } from './NativeTabsTriggerTabBar';\nimport type {\n ExtendedNativeTabOptions,\n NativeTabOptions,\n NativeTabsTriggerTabBarProps,\n NativeTabTriggerProps,\n} from './types';\nimport { filterAllowedChildrenElements, isChildOfType } from './utils';\nimport { useSafeLayoutEffect } from '../../views/useSafeLayoutEffect';\nimport {\n Icon,\n Badge,\n Label,\n type LabelProps,\n type IconProps,\n type BadgeProps,\n type SourceIconCombination,\n VectorIcon,\n type VectorIconProps,\n} from '../common/elements';\n\n/**\n * The component used to customize the native tab options both in the _layout file and from the tab screen.\n *\n * When used in the _layout file, you need to provide a `name` prop.\n * When used in the tab screen, the `name` prop takes no effect.\n *\n * @example\n * ```tsx\n * // In _layout file\n * import { NativeTabs } from 'expo-router/unstable-native-tabs';\n *\n * export default function Layout() {\n * return (\n * <NativeTabs>\n * <NativeTabs.Trigger name=\"home\" />\n * <NativeTabs.Trigger name=\"settings\" />\n * </NativeTabs>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // In a tab screen\n * import { NativeTabs } from 'expo-router/unstable-native-tabs';\n *\n * export default function HomeScreen() {\n * return (\n * <View>\n * <NativeTabs.Trigger>\n * <Label>Home</Label>\n * </NativeTabs.Trigger>\n * <Text>This is home screen!</Text>\n * </View>\n * );\n * }\n * ```\n *\n * > **Note:** You can use the alias `NativeTabs.Trigger` for this component.\n */\nfunction NativeTabTriggerImpl(props: NativeTabTriggerProps) {\n const route = useRoute();\n const navigation = useNavigation();\n const isFocused = navigation.isFocused();\n\n useSafeLayoutEffect(() => {\n // This will cause the tab to update only when it is focused.\n // As long as all tabs are loaded at the start, we don't need this check.\n // It is here to ensure similar behavior to stack\n if (isFocused) {\n if (navigation.getState()?.type !== 'tab') {\n throw new Error(\n `Trigger component can only be used in the tab screen. Current route: ${route.name}`\n );\n }\n const options = convertTabPropsToOptions(props);\n navigation.setOptions(options);\n }\n }, [isFocused, props]);\n\n return null;\n}\n\nexport const NativeTabTrigger = Object.assign(NativeTabTriggerImpl, {\n TabBar: NativeTabsTriggerTabBar,\n});\n\nexport function convertTabPropsToOptions({\n options,\n hidden,\n children,\n role,\n disablePopToTop,\n disableScrollToTop,\n}: NativeTabTriggerProps) {\n const initialOptions: ExtendedNativeTabOptions = {\n ...options,\n hidden: !!hidden,\n specialEffects: {\n repeatedTabSelection: {\n popToRoot: !disablePopToTop,\n scrollToTop: !disableScrollToTop,\n },\n },\n role: role ?? options?.role,\n };\n const allowedChildren = filterAllowedChildrenElements(children, [\n Badge,\n Label,\n Icon,\n NativeTabsTriggerTabBar,\n ]);\n return allowedChildren.reduce<ExtendedNativeTabOptions>(\n (acc, child) => {\n if (isChildOfType(child, Badge)) {\n appendBadgeOptions(acc, child.props);\n } else if (isChildOfType(child, Label)) {\n appendLabelOptions(acc, child.props);\n } else if (isChildOfType(child, Icon)) {\n appendIconOptions(acc, child.props);\n } else if (isChildOfType(child, NativeTabsTriggerTabBar)) {\n appendTabBarOptions(acc, child.props);\n }\n return acc;\n },\n { ...initialOptions }\n );\n}\n\nfunction appendBadgeOptions(options: ExtendedNativeTabOptions, props: BadgeProps) {\n if (props.children) {\n options.badgeValue = String(props.children);\n options.selectedBadgeBackgroundColor = props.selectedBackgroundColor;\n } else if (!props.hidden) {\n // If no value is provided, we set it to a space to show the badge\n // Otherwise, the `react-native-screens` will interpret it as a hidden badge\n // https://github.com/software-mansion/react-native-screens/blob/b4358fd95dd0736fc54df6bb97f210dc89edf24c/ios/bottom-tabs/RNSBottomTabsScreenComponentView.mm#L172\n options.badgeValue = ' ';\n }\n}\n\nfunction appendLabelOptions(options: ExtendedNativeTabOptions, props: LabelProps) {\n if (props.hidden) {\n options.title = '';\n } else {\n options.title = props.children;\n options.selectedLabelStyle = props.selectedStyle;\n }\n}\n\nexport function appendIconOptions(options: ExtendedNativeTabOptions, props: IconProps) {\n if ('src' in props && props.src) {\n const icon = convertIconSrcToIconOption(props);\n options.icon = icon?.icon;\n options.selectedIcon = icon?.selectedIcon;\n } else if ('sf' in props && process.env.EXPO_OS === 'ios') {\n if (typeof props.sf === 'string') {\n options.icon = props.sf\n ? {\n sf: props.sf,\n }\n : undefined;\n options.selectedIcon = undefined;\n } else if (props.sf) {\n options.icon = props.sf.default\n ? {\n sf: props.sf.default,\n }\n : undefined;\n options.selectedIcon = props.sf.selected\n ? {\n sf: props.sf.selected,\n }\n : undefined;\n }\n } else if ('drawable' in props && process.env.EXPO_OS === 'android') {\n options.icon = { drawable: props.drawable };\n options.selectedIcon = undefined;\n }\n options.selectedIconColor = props.selectedColor;\n}\n\nfunction convertIconSrcToIconOption(\n icon: SourceIconCombination | undefined\n): Pick<NativeTabOptions, 'icon' | 'selectedIcon'> | undefined {\n if (icon && icon.src) {\n const { defaultIcon, selected } =\n typeof icon.src === 'object' && 'selected' in icon.src\n ? { defaultIcon: icon.src.default, selected: icon.src.selected }\n : { defaultIcon: icon.src };\n\n const options: Pick<NativeTabOptions, 'icon' | 'selectedIcon'> = {};\n options.icon = convertSrcOrComponentToSrc(defaultIcon);\n options.selectedIcon = convertSrcOrComponentToSrc(selected);\n return options;\n }\n\n return undefined;\n}\n\nfunction convertSrcOrComponentToSrc(src: ImageSourcePropType | ReactElement | undefined) {\n if (src) {\n if (isValidElement(src)) {\n if (src.type === VectorIcon) {\n const props = src.props as VectorIconProps<string>;\n return { src: props.family.getImageSource(props.name, 24, 'white') };\n } else {\n console.warn('Only VectorIcon is supported as a React element in Icon.src');\n }\n } else {\n return { src };\n }\n }\n return undefined;\n}\n\nfunction appendTabBarOptions(\n options: ExtendedNativeTabOptions,\n props: NativeTabsTriggerTabBarProps\n) {\n const {\n backgroundColor,\n blurEffect,\n iconColor,\n disableTransparentOnScrollEdge,\n badgeBackgroundColor,\n badgeTextColor,\n indicatorColor,\n labelStyle,\n } = props;\n\n if (backgroundColor) {\n options.backgroundColor = backgroundColor;\n }\n // We need better native integration of this on Android\n // Simulating from JS side creates ugly transitions\n if (process.env.EXPO_OS !== 'android') {\n if (blurEffect) {\n options.blurEffect = blurEffect;\n }\n if (iconColor) {\n options.iconColor = iconColor;\n }\n if (disableTransparentOnScrollEdge !== undefined) {\n options.disableTransparentOnScrollEdge = disableTransparentOnScrollEdge;\n }\n if (badgeBackgroundColor) {\n options.badgeBackgroundColor = badgeBackgroundColor;\n }\n if (badgeTextColor) {\n options.badgeTextColor = badgeTextColor;\n }\n if (indicatorColor) {\n options.indicatorColor = indicatorColor;\n }\n if (labelStyle) {\n options.labelStyle = labelStyle;\n }\n }\n}\n\nexport function isNativeTabTrigger(\n child: ReactNode,\n contextKey?: string\n): child is ReactElement<NativeTabTriggerProps & { name: string }> {\n if (isValidElement(child) && child && child.type === NativeTabTrigger) {\n if (\n typeof child.props === 'object' &&\n child.props &&\n 'name' in child.props &&\n !child.props.name\n ) {\n throw new Error(\n `<Trigger /> component in \\`default export\\` at \\`app${contextKey}/_layout\\` must have a \\`name\\` prop when used as a child of a Layout Route.`\n );\n }\n\n if (process.env.NODE_ENV !== 'production') {\n if (\n ['component', 'getComponent'].some(\n (key) => child.props && typeof child.props === 'object' && key in child.props\n )\n ) {\n throw new Error(\n `<Trigger /> component in \\`default export\\` at \\`app${contextKey}/_layout\\` must not have a \\`component\\` or \\`getComponent\\` prop when used as a child of a Layout Route`\n );\n }\n }\n\n return true;\n }\n\n return false;\n}\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { NativeTabTrigger } from './NativeTabTrigger';
|
|
2
1
|
import type { NativeTabsProps } from './types';
|
|
3
2
|
/**
|
|
4
3
|
* The component used to create native tabs layout.
|
|
@@ -19,6 +18,8 @@ import type { NativeTabsProps } from './types';
|
|
|
19
18
|
* ```
|
|
20
19
|
*/
|
|
21
20
|
export declare const NativeTabs: ((props: NativeTabsProps) => import("react").JSX.Element) & {
|
|
22
|
-
Trigger:
|
|
21
|
+
Trigger: ((props: import("./types").NativeTabTriggerProps) => null) & {
|
|
22
|
+
TabBar: typeof import("./NativeTabsTriggerTabBar").NativeTabsTriggerTabBar;
|
|
23
|
+
};
|
|
23
24
|
};
|
|
24
25
|
//# sourceMappingURL=NativeTabs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeTabs.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabs.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NativeTabs.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU,WACb,eAAe;;;;CAIxB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { NativeTabsTriggerTabBarProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The component used to customize the style of the tab bar, when given trigger is selected.
|
|
4
|
+
*
|
|
5
|
+
* Prefer this to global changes of tab bar styles, directly in the page.
|
|
6
|
+
*
|
|
7
|
+
* > **Note:** You can use the alias `NativeTabs.Trigger.TabBar` for this component.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <NativeTabs
|
|
12
|
+
* backgroundColor="black"
|
|
13
|
+
* >
|
|
14
|
+
* <NativeTabs.Trigger name="page">
|
|
15
|
+
* <NativeTabs.Trigger.TabBar
|
|
16
|
+
* backgroundColor="white"
|
|
17
|
+
* />
|
|
18
|
+
* <Label>Page</Label>
|
|
19
|
+
* </NativeTabs.Trigger>
|
|
20
|
+
* </NativeTabs>
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
export declare function NativeTabsTriggerTabBar(props: NativeTabsTriggerTabBarProps): React.ReactNode;
|
|
24
|
+
//# sourceMappingURL=NativeTabsTriggerTabBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeTabsTriggerTabBar.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabsTriggerTabBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,GAAG,KAAK,CAAC,SAAS,CAE5F"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NativeTabsTriggerTabBar = NativeTabsTriggerTabBar;
|
|
4
|
+
/**
|
|
5
|
+
* The component used to customize the style of the tab bar, when given trigger is selected.
|
|
6
|
+
*
|
|
7
|
+
* Prefer this to global changes of tab bar styles, directly in the page.
|
|
8
|
+
*
|
|
9
|
+
* > **Note:** You can use the alias `NativeTabs.Trigger.TabBar` for this component.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <NativeTabs
|
|
14
|
+
* backgroundColor="black"
|
|
15
|
+
* >
|
|
16
|
+
* <NativeTabs.Trigger name="page">
|
|
17
|
+
* <NativeTabs.Trigger.TabBar
|
|
18
|
+
* backgroundColor="white"
|
|
19
|
+
* />
|
|
20
|
+
* <Label>Page</Label>
|
|
21
|
+
* </NativeTabs.Trigger>
|
|
22
|
+
* </NativeTabs>
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
function NativeTabsTriggerTabBar(props) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=NativeTabsTriggerTabBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeTabsTriggerTabBar.js","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabsTriggerTabBar.tsx"],"names":[],"mappings":";;AAuBA,0DAEC;AAvBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,uBAAuB,CAAC,KAAmC;IACzE,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { NativeTabsTriggerTabBarProps } from './types';\n\n/**\n * The component used to customize the style of the tab bar, when given trigger is selected.\n *\n * Prefer this to global changes of tab bar styles, directly in the page.\n *\n * > **Note:** You can use the alias `NativeTabs.Trigger.TabBar` for this component.\n *\n * @example\n * ```tsx\n * <NativeTabs\n * backgroundColor=\"black\"\n * >\n * <NativeTabs.Trigger name=\"page\">\n * <NativeTabs.Trigger.TabBar\n * backgroundColor=\"white\"\n * />\n * <Label>Page</Label>\n * </NativeTabs.Trigger>\n * </NativeTabs>\n *\n */\nexport function NativeTabsTriggerTabBar(props: NativeTabsTriggerTabBarProps): React.ReactNode {\n return null;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeTabsView.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabsView.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"NativeTabsView.d.ts","sourceRoot":"","sources":["../../../src/native-tabs/NativeBottomTabs/NativeTabsView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAkB9E,OAAO,EAKL,KAAK,mBAAmB,EACzB,MAAM,SAAS,CAAC;AAOjB,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,qBAwIxD"}
|
|
@@ -36,32 +36,67 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.NativeTabsView = NativeTabsView;
|
|
37
37
|
const react_1 = __importStar(require("react"));
|
|
38
38
|
const react_native_screens_1 = require("react-native-screens");
|
|
39
|
+
const appearance_1 = require("./appearance");
|
|
39
40
|
const types_1 = require("./types");
|
|
40
41
|
const utils_1 = require("./utils");
|
|
41
42
|
// We let native tabs to control the changes. This requires freeze to be disabled for tab bar.
|
|
42
43
|
// Otherwise user may see glitches when switching between tabs.
|
|
43
44
|
react_native_screens_1.featureFlags.experiment.controlledBottomTabs = false;
|
|
44
45
|
function NativeTabsView(props) {
|
|
45
|
-
const { builder,
|
|
46
|
+
const { builder, minimizeBehavior, disableIndicator, focusedIndex, disableTransparentOnScrollEdge, } = props;
|
|
46
47
|
const { state, descriptors, navigation } = builder;
|
|
47
48
|
const { routes } = state;
|
|
48
49
|
const deferredFocusedIndex = (0, react_1.useDeferredValue)(focusedIndex);
|
|
50
|
+
let standardAppearance = (0, appearance_1.convertStyleToAppearance)({
|
|
51
|
+
...props.labelStyle,
|
|
52
|
+
iconColor: props.iconColor,
|
|
53
|
+
blurEffect: props.blurEffect,
|
|
54
|
+
backgroundColor: props.backgroundColor,
|
|
55
|
+
badgeBackgroundColor: props.badgeBackgroundColor,
|
|
56
|
+
});
|
|
57
|
+
if (props.tintColor) {
|
|
58
|
+
standardAppearance = (0, appearance_1.appendSelectedStyleToAppearance)({ iconColor: props.tintColor, color: props.tintColor }, standardAppearance);
|
|
59
|
+
}
|
|
60
|
+
const scrollEdgeAppearance = (0, appearance_1.convertStyleToAppearance)({
|
|
61
|
+
...props.labelStyle,
|
|
62
|
+
iconColor: props.iconColor,
|
|
63
|
+
blurEffect: disableTransparentOnScrollEdge ? props.blurEffect : 'none',
|
|
64
|
+
backgroundColor: disableTransparentOnScrollEdge ? props.backgroundColor : null,
|
|
65
|
+
badgeBackgroundColor: props.badgeBackgroundColor,
|
|
66
|
+
});
|
|
67
|
+
const appearances = routes.map((route) => ({
|
|
68
|
+
standardAppearance: (0, appearance_1.createStandardAppearanceFromOptions)(descriptors[route.key].options, standardAppearance),
|
|
69
|
+
scrollEdgeAppearance: (0, appearance_1.createScrollEdgeAppearanceFromOptions)(descriptors[route.key].options, scrollEdgeAppearance),
|
|
70
|
+
}));
|
|
71
|
+
const options = routes.map((route) => descriptors[route.key].options);
|
|
49
72
|
const children = routes
|
|
50
73
|
.map((route, index) => ({ route, index }))
|
|
51
74
|
.filter(({ route: { key } }) => (0, utils_1.shouldTabBeVisible)(descriptors[key].options))
|
|
52
75
|
.map(({ route, index }) => {
|
|
53
76
|
const descriptor = descriptors[route.key];
|
|
54
77
|
const isFocused = index === deferredFocusedIndex;
|
|
55
|
-
|
|
56
|
-
return (<react_native_screens_1.BottomTabsScreen key={route.key} {...descriptor.options} tabBarItemBadgeBackgroundColor={style?.badgeBackgroundColor} tabBarItemBadgeTextColor={style?.badgeTextColor} tabBarItemTitlePositionAdjustment={style?.titlePositionAdjustment} iconResourceName={descriptor.options.icon?.drawable} icon={convertOptionsIconToPropsIcon(descriptor.options.icon)} selectedIcon={convertOptionsIconToPropsIcon(descriptor.options.selectedIcon)} title={title} freezeContents={false} tabKey={route.key} isFocused={isFocused}>
|
|
57
|
-
{descriptor.render()}
|
|
58
|
-
</react_native_screens_1.BottomTabsScreen>);
|
|
78
|
+
return (<Screen key={route.key} routeKey={route.key} name={route.name} descriptor={descriptor} isFocused={isFocused} standardAppearance={appearances[index].standardAppearance} scrollEdgeAppearance={appearances[index].scrollEdgeAppearance} badgeTextColor={props.badgeTextColor}/>);
|
|
59
79
|
});
|
|
60
|
-
return (<BottomTabsWrapper
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
80
|
+
return (<BottomTabsWrapper
|
|
81
|
+
// #region android props
|
|
82
|
+
tabBarItemTitleFontColor={appearances[deferredFocusedIndex].standardAppearance.stacked?.normal
|
|
83
|
+
?.tabBarItemTitleFontColor} tabBarItemTitleFontFamily={appearances[deferredFocusedIndex].standardAppearance.stacked?.normal
|
|
84
|
+
?.tabBarItemTitleFontFamily} tabBarItemTitleFontSize={appearances[deferredFocusedIndex].standardAppearance.stacked?.normal
|
|
85
|
+
?.tabBarItemTitleFontSize} tabBarItemTitleFontSizeActive={appearances[deferredFocusedIndex].standardAppearance.stacked?.normal
|
|
86
|
+
?.tabBarItemTitleFontSize} tabBarItemTitleFontWeight={appearances[deferredFocusedIndex].standardAppearance.stacked?.normal
|
|
87
|
+
?.tabBarItemTitleFontWeight} tabBarItemTitleFontStyle={appearances[deferredFocusedIndex].standardAppearance.stacked?.normal
|
|
88
|
+
?.tabBarItemTitleFontStyle} tabBarItemIconColor={appearances[deferredFocusedIndex].standardAppearance.stacked?.normal?.tabBarItemIconColor} tabBarBackgroundColor={appearances[deferredFocusedIndex].standardAppearance.tabBarBackgroundColor ??
|
|
89
|
+
props.backgroundColor ??
|
|
90
|
+
undefined} tabBarItemRippleColor={props.rippleColor} tabBarItemLabelVisibilityMode={props.labelVisibilityMode} tabBarItemIconColorActive={appearances[deferredFocusedIndex].standardAppearance?.stacked?.selected
|
|
91
|
+
?.tabBarItemIconColor ?? props?.tintColor} tabBarItemTitleFontColorActive={appearances[deferredFocusedIndex].standardAppearance?.stacked?.selected
|
|
92
|
+
?.tabBarItemTitleFontColor ?? props?.tintColor}
|
|
93
|
+
// tabBarItemTitleFontSizeActive={activeStyle?.fontSize}
|
|
94
|
+
tabBarItemActiveIndicatorColor={options[deferredFocusedIndex]?.indicatorColor ?? props?.indicatorColor} tabBarItemActiveIndicatorEnabled={!disableIndicator}
|
|
95
|
+
// #endregion
|
|
96
|
+
// #region iOS props
|
|
97
|
+
tabBarTintColor={props?.tintColor} tabBarMinimizeBehavior={minimizeBehavior}
|
|
98
|
+
// #endregion
|
|
99
|
+
onNativeFocusChange={({ nativeEvent: { tabKey } }) => {
|
|
65
100
|
const descriptor = descriptors[tabKey];
|
|
66
101
|
const route = descriptor.route;
|
|
67
102
|
navigation.dispatch({
|
|
@@ -75,6 +110,58 @@ function NativeTabsView(props) {
|
|
|
75
110
|
{children}
|
|
76
111
|
</BottomTabsWrapper>);
|
|
77
112
|
}
|
|
113
|
+
// TODO: remove after fix is merged in screens
|
|
114
|
+
const rolesIcons = {
|
|
115
|
+
bookmarks: 'book.fill',
|
|
116
|
+
contacts: 'person.crop.circle.fill',
|
|
117
|
+
downloads: 'square.and.arrow.down.fill',
|
|
118
|
+
favorites: 'star.fill',
|
|
119
|
+
featured: 'star.fill',
|
|
120
|
+
history: 'clock.fill',
|
|
121
|
+
more: 'ellipsis',
|
|
122
|
+
mostRecent: 'clock.fill',
|
|
123
|
+
mostViewed: 'list.number',
|
|
124
|
+
recents: 'clock.fill',
|
|
125
|
+
search: 'magnifyingglass',
|
|
126
|
+
topRated: 'star.fill',
|
|
127
|
+
};
|
|
128
|
+
function Screen(props) {
|
|
129
|
+
const { routeKey, name, descriptor, isFocused, standardAppearance, scrollEdgeAppearance, badgeTextColor, } = props;
|
|
130
|
+
const title = descriptor.options.title ?? name;
|
|
131
|
+
let icon = useAwaitedScreensIcon(descriptor.options.icon);
|
|
132
|
+
let selectedIcon = useAwaitedScreensIcon(descriptor.options.selectedIcon);
|
|
133
|
+
// Fix for an issue in screens
|
|
134
|
+
if (descriptor.options.role) {
|
|
135
|
+
if (descriptor.options.role && descriptor.options.role in rolesIcons) {
|
|
136
|
+
icon = { sf: rolesIcons[descriptor.options.role] };
|
|
137
|
+
selectedIcon = icon;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return (<react_native_screens_1.BottomTabsScreen {...descriptor.options} tabBarItemBadgeBackgroundColor={standardAppearance.stacked?.normal?.tabBarItemBadgeBackgroundColor} tabBarItemBadgeTextColor={badgeTextColor} standardAppearance={standardAppearance} scrollEdgeAppearance={scrollEdgeAppearance} iconResourceName={getAndroidIconResourceName(icon)} iconResource={getAndroidIconResource(icon)} icon={convertOptionsIconToPropsIcon(icon)} selectedIcon={convertOptionsIconToPropsIcon(selectedIcon)} title={title} freezeContents={false} tabKey={routeKey} systemItem={descriptor.options.role} isFocused={isFocused}>
|
|
141
|
+
{descriptor.render()}
|
|
142
|
+
</react_native_screens_1.BottomTabsScreen>);
|
|
143
|
+
}
|
|
144
|
+
function useAwaitedScreensIcon(icon) {
|
|
145
|
+
const src = icon && typeof icon === 'object' && 'src' in icon ? icon.src : undefined;
|
|
146
|
+
const [awaitedIcon, setAwaitedIcon] = (0, react_1.useState)(undefined);
|
|
147
|
+
(0, react_1.useEffect)(() => {
|
|
148
|
+
const loadIcon = async () => {
|
|
149
|
+
if (src && src instanceof Promise) {
|
|
150
|
+
const currentAwaitedIcon = { src: await src };
|
|
151
|
+
setAwaitedIcon(currentAwaitedIcon);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
loadIcon();
|
|
155
|
+
// Checking `src` rather then icon here, to avoid unnecessary re-renders
|
|
156
|
+
// The icon object can be recreated, while src should stay the same
|
|
157
|
+
// In this case as we control `VectorIcon`, it will only change if `family` or `name` props change
|
|
158
|
+
// So we should be safe with promise resolving
|
|
159
|
+
}, [src]);
|
|
160
|
+
return (0, react_1.useMemo)(() => (isAwaitedIcon(icon) ? icon : awaitedIcon), [awaitedIcon, icon]);
|
|
161
|
+
}
|
|
162
|
+
function isAwaitedIcon(icon) {
|
|
163
|
+
return !icon || !('src' in icon && icon.src instanceof Promise);
|
|
164
|
+
}
|
|
78
165
|
function convertOptionsIconToPropsIcon(icon) {
|
|
79
166
|
if (!icon) {
|
|
80
167
|
return undefined;
|
|
@@ -87,21 +174,31 @@ function convertOptionsIconToPropsIcon(icon) {
|
|
|
87
174
|
}
|
|
88
175
|
return undefined;
|
|
89
176
|
}
|
|
177
|
+
function getAndroidIconResource(icon) {
|
|
178
|
+
if (icon && 'src' in icon && icon.src) {
|
|
179
|
+
return icon.src;
|
|
180
|
+
}
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
function getAndroidIconResourceName(icon) {
|
|
184
|
+
if (icon && 'drawable' in icon && icon.drawable) {
|
|
185
|
+
return icon.drawable;
|
|
186
|
+
}
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
90
189
|
const supportedTabBarMinimizeBehaviorsSet = new Set(types_1.SUPPORTED_TAB_BAR_MINIMIZE_BEHAVIORS);
|
|
91
190
|
const supportedTabBarItemLabelVisibilityModesSet = new Set(types_1.SUPPORTED_TAB_BAR_ITEM_LABEL_VISIBILITY_MODES);
|
|
92
|
-
const supportedBlurEffectsSet = new Set(types_1.SUPPORTED_BLUR_EFFECTS);
|
|
93
191
|
function BottomTabsWrapper(props) {
|
|
94
|
-
|
|
192
|
+
let { tabBarMinimizeBehavior, tabBarItemLabelVisibilityMode, ...rest } = props;
|
|
95
193
|
if (tabBarMinimizeBehavior && !supportedTabBarMinimizeBehaviorsSet.has(tabBarMinimizeBehavior)) {
|
|
96
|
-
|
|
194
|
+
console.warn(`Unsupported minimizeBehavior: ${tabBarMinimizeBehavior}. Supported values are: ${types_1.SUPPORTED_TAB_BAR_MINIMIZE_BEHAVIORS.map((behavior) => `"${behavior}"`).join(', ')}`);
|
|
195
|
+
tabBarMinimizeBehavior = undefined;
|
|
97
196
|
}
|
|
98
197
|
if (tabBarItemLabelVisibilityMode &&
|
|
99
198
|
!supportedTabBarItemLabelVisibilityModesSet.has(tabBarItemLabelVisibilityMode)) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (tabBarBlurEffect && !supportedBlurEffectsSet.has(tabBarBlurEffect)) {
|
|
103
|
-
throw new Error(`Unsupported blurEffect: ${tabBarBlurEffect}. Supported values are: ${types_1.SUPPORTED_BLUR_EFFECTS.map((effect) => `"${effect}"`).join(', ')}`);
|
|
199
|
+
console.warn(`Unsupported labelVisibilityMode: ${tabBarItemLabelVisibilityMode}. Supported values are: ${types_1.SUPPORTED_TAB_BAR_ITEM_LABEL_VISIBILITY_MODES.map((mode) => `"${mode}"`).join(', ')}`);
|
|
200
|
+
tabBarItemLabelVisibilityMode = undefined;
|
|
104
201
|
}
|
|
105
|
-
return (<react_native_screens_1.BottomTabs
|
|
202
|
+
return (<react_native_screens_1.BottomTabs tabBarItemLabelVisibilityMode={tabBarItemLabelVisibilityMode} tabBarMinimizeBehavior={tabBarMinimizeBehavior} {...rest}/>);
|
|
106
203
|
}
|
|
107
204
|
//# sourceMappingURL=NativeTabsView.js.map
|