@momo-kits/foundation 0.168.1-beta.39 → 0.168.1-beta.40
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/Application/BottomSheet.tsx +398 -86
- package/Application/BottomTab/BottomTabBar.tsx +275 -215
- package/Application/BottomTab/CustomBottomTabItem.tsx +107 -131
- package/Application/BottomTab/DuoBarCompression.tsx +28 -14
- package/Application/BottomTab/DuoTabBar.tsx +540 -32
- package/Application/BottomTab/TabBarIcon.tsx +72 -146
- package/Application/BottomTab/index.tsx +353 -89
- package/Application/BottomTab/useLiquidSelection.ts +374 -0
- package/Application/Components/BackgroundImageView.tsx +0 -4
- package/Application/Components/DuoGlassBackground.tsx +5 -7
- package/Application/Components/HeaderAnimated.tsx +13 -41
- package/Application/Components/HeaderBackground.tsx +3 -20
- package/Application/Components/HeaderExtendHeader.tsx +46 -66
- package/Application/Components/HeaderLeft.tsx +18 -5
- package/Application/Components/HeaderRight.tsx +529 -8
- package/Application/Components/HeaderTitle.tsx +579 -16
- package/Application/Components/NavigationButton.tsx +11 -18
- package/Application/Components/SearchHeader.tsx +18 -38
- package/Application/Localize.ts +0 -7
- package/Application/ModalScreen.tsx +18 -41
- package/Application/Navigation.ts +17 -15
- package/Application/NavigationContainer.tsx +21 -23
- package/Application/Navigator.ts +48 -20
- package/Application/ScaleSizeProvider.tsx +6 -13
- package/Application/StackScreen.tsx +172 -27
- package/Application/TooltipPortal.tsx +5 -12
- package/Application/WidgetContainer.tsx +7 -20
- package/Application/device.ts +52 -0
- package/Application/index.ts +1 -23
- package/Application/types.ts +242 -17
- package/Application/utils.tsx +493 -0
- package/Badge/Badge.tsx +0 -5
- package/Badge/BadgeDot.tsx +0 -1
- package/Badge/BadgeDotAnimation.tsx +7 -15
- package/Badge/BadgeRibbon.tsx +39 -47
- package/Badge/Shape.tsx +0 -2
- package/Badge/styles.ts +0 -2
- package/Badge/types.ts +2 -2
- package/Button/index.tsx +152 -21
- package/Button/styles.ts +1 -1
- package/CheckBox/index.tsx +6 -5
- package/Consts/theme.ts +10 -10
- package/Context/index.ts +1 -5
- package/Divider/DashDivider.tsx +11 -11
- package/Divider/index.tsx +7 -21
- package/FoundationList/index.tsx +0 -4
- package/Icon/index.tsx +6 -6
- package/Icon/types.ts +1 -1
- package/IconButton/index.tsx +12 -4
- package/Image/index.tsx +7 -9
- package/Input/Input.tsx +12 -10
- package/Input/InputDropDown.tsx +13 -10
- package/Input/InputMoney.tsx +152 -45
- package/Input/InputOTP.tsx +34 -36
- package/Input/InputPhoneNumber.tsx +5 -8
- package/Input/InputSearch.tsx +111 -19
- package/Input/InputTextArea.tsx +5 -5
- package/Input/SystemTextInput.tsx +2 -7
- package/Input/TextTyping.tsx +0 -4
- package/Input/common.tsx +17 -31
- package/Input/index.tsx +21 -24
- package/Input/styles.ts +5 -25
- package/Input/utils.ts +12 -14
- package/Layout/Card.tsx +4 -7
- package/Layout/FloatingButton.tsx +21 -26
- package/Layout/Item.tsx +2 -6
- package/Layout/ItemList.tsx +7 -9
- package/Layout/ItemSectionList.tsx +1 -2
- package/Layout/ReservedRegions.tsx +17 -34
- package/Layout/Screen.tsx +696 -122
- package/Layout/Section.tsx +7 -9
- package/Layout/TrackingScope.tsx +0 -1
- package/Layout/index.ts +4 -10
- package/Layout/styles.ts +0 -2
- package/Layout/types.ts +4 -2
- package/Layout/utils.ts +181 -40
- package/Loader/DotLoader.tsx +3 -11
- package/Loader/Loader.tsx +0 -4
- package/Loader/ProgressBar.tsx +6 -3
- package/Loader/Spinner.tsx +3 -11
- package/Loader/styles.ts +0 -4
- package/Loader/utils.ts +7 -11
- package/Pagination/Dot.tsx +0 -4
- package/Pagination/PaginationDot.tsx +0 -1
- package/Pagination/PaginationNumber.tsx +3 -5
- package/Pagination/PaginationScroll.tsx +0 -5
- package/Pagination/PaginationWhiteDot.tsx +0 -1
- package/Pagination/index.tsx +0 -4
- package/Pagination/types.ts +2 -2
- package/Popup/PopupNotify.tsx +102 -94
- package/Popup/PopupPromotion.tsx +11 -9
- package/Popup/types.ts +4 -11
- package/Popup/utils.ts +18 -50
- package/Radio/index.tsx +10 -6
- package/Radio/styles.ts +0 -6
- package/Skeleton/index.tsx +9 -9
- package/Skeleton/styles.ts +0 -1
- package/Switch/index.tsx +0 -1
- package/Tag/index.tsx +4 -8
- package/Tag/types.ts +3 -3
- package/Text/index.tsx +5 -25
- package/Text/styles.ts +1 -1
- package/Text/types.ts +6 -1
- package/Text/utils.ts +4 -20
- package/Title/index.tsx +40 -42
- package/Title/styles.ts +0 -6
- package/ViewBoundary/index.tsx +2 -4
- package/index.ts +6 -0
- package/package.json +1 -2
- package/Application/BottomSheet.hooks.ts +0 -195
- package/Application/BottomSheet.parts.tsx +0 -157
- package/Application/BottomSheet.styles.ts +0 -43
- package/Application/BottomTab/ActiveIndicator.tsx +0 -91
- package/Application/BottomTab/BottomTabBar.styles.ts +0 -65
- package/Application/BottomTab/BottomTabInset.tsx +0 -18
- package/Application/BottomTab/CurvedContainer.tsx +0 -155
- package/Application/BottomTab/DuoRailTabBar.tsx +0 -223
- package/Application/BottomTab/DuoTabBar.styles.ts +0 -81
- package/Application/BottomTab/TabScreen.tsx +0 -160
- package/Application/BottomTab/metrics.ts +0 -164
- package/Application/BottomTab/tabItems.ts +0 -46
- package/Application/BottomTab/usePressLift.ts +0 -32
- package/Application/Components/HeaderRight.styles.ts +0 -146
- package/Application/Components/HeaderTitle.shared.ts +0 -44
- package/Application/Components/HeaderTitle.styles.ts +0 -125
- package/Application/Components/HeaderToolkitAction.tsx +0 -180
- package/Application/Components/SwipeBackHaptic.tsx +0 -95
- package/Application/Components/TitleJourney.tsx +0 -110
- package/Application/Components/TitleLocation.tsx +0 -73
- package/Application/Components/TitleUser.tsx +0 -304
- package/Application/Components/useToolkitActions.tsx +0 -218
- package/Application/ModalIconButton.tsx +0 -66
- package/Application/StackScreen.tracking.ts +0 -143
- package/Application/headerLayout.ts +0 -158
- package/Application/hooks.ts +0 -137
- package/Application/modalLayout.ts +0 -176
- package/Application/navigationOptions.tsx +0 -212
- package/Application/types.header.ts +0 -121
- package/Application/types.tabs.ts +0 -48
- package/Application/types.theme.ts +0 -87
- package/Application/utils.ts +0 -107
- package/Button/utils.ts +0 -133
- package/Input/InputMoneyView.tsx +0 -194
- package/Input/SearchTextTyping.tsx +0 -108
- package/Input/moneyUtils.ts +0 -23
- package/Layout/layoutMetrics.ts +0 -58
- package/Layout/layoutTypes.ts +0 -86
- package/Layout/screenContent.tsx +0 -92
- package/Layout/screenFooter.tsx +0 -63
- package/Layout/screenHeader.tsx +0 -321
- package/Layout/screenQuickReturn.tsx +0 -64
- package/Layout/screenScroll.ts +0 -107
- package/Layout/screenTypes.ts +0 -143
|
@@ -1,263 +1,323 @@
|
|
|
1
1
|
import { BottomTabBarProps } from '@react-navigation/bottom-tabs';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { CommonActions, Route } from '@react-navigation/native';
|
|
3
|
+
import React, { useCallback, useContext } from 'react';
|
|
4
|
+
import {
|
|
5
|
+
Platform,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
TouchableOpacity,
|
|
8
|
+
useWindowDimensions,
|
|
9
|
+
View,
|
|
10
|
+
} from 'react-native';
|
|
4
11
|
import Animated, {
|
|
5
12
|
useAnimatedStyle,
|
|
6
13
|
useSharedValue,
|
|
7
14
|
withTiming,
|
|
8
15
|
} from 'react-native-reanimated';
|
|
9
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
10
|
-
import { Colors,
|
|
16
|
+
import { EdgeInsets, useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
17
|
+
import { Colors, Radius, Styles } from '../../Consts';
|
|
11
18
|
import { Icon } from '../../Icon';
|
|
12
19
|
import { Text } from '../../Text';
|
|
13
20
|
import { FloatingButtonProps } from '../types';
|
|
14
21
|
import CustomBottomTabItem from './CustomBottomTabItem';
|
|
15
22
|
import { ApplicationContext, MiniAppContext } from '../../Context';
|
|
16
|
-
import { CurvedContainer } from './CurvedContainer';
|
|
17
|
-
import { ActiveIndicator } from './ActiveIndicator';
|
|
18
|
-
import { getHorizontalBarWidth, TabBarMetrics, TabBarMotion } from './metrics';
|
|
19
|
-
import { getTabItems, TabItem } from './tabItems';
|
|
20
|
-
import { styles } from './BottomTabBar.styles';
|
|
21
23
|
|
|
22
24
|
type Props = BottomTabBarProps & {
|
|
23
|
-
activeTintColor
|
|
24
|
-
inactiveTintColor
|
|
25
|
+
activeTintColor?: string;
|
|
26
|
+
inactiveTintColor?: string;
|
|
25
27
|
floatingButton?: FloatingButtonProps;
|
|
28
|
+
activeBackgroundColor?: string;
|
|
29
|
+
allowFontScaling?: boolean;
|
|
30
|
+
inactiveBackgroundColor?: string;
|
|
31
|
+
labelStyle?: any;
|
|
32
|
+
iconStyle?: any;
|
|
33
|
+
showLabel?: boolean;
|
|
34
|
+
style?: any;
|
|
35
|
+
tabStyle?: any;
|
|
36
|
+
badgeStyle?: any;
|
|
26
37
|
};
|
|
27
38
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* Special type takes 2 or 4 tabs.
|
|
31
|
-
*/
|
|
32
|
-
const hasCenterAction = (floatingButton: unknown, tabCount: number) => {
|
|
33
|
-
return !!floatingButton && tabCount % 2 === 0;
|
|
39
|
+
const getPaddingBottom = (insets: EdgeInsets) => {
|
|
40
|
+
return Math.max(insets.bottom - Platform.select({ ios: 4, default: 0 }), 0);
|
|
34
41
|
};
|
|
35
42
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
export default function BottomTabBar({
|
|
44
|
+
state,
|
|
45
|
+
navigation,
|
|
46
|
+
descriptors,
|
|
47
|
+
activeBackgroundColor,
|
|
48
|
+
activeTintColor,
|
|
49
|
+
allowFontScaling,
|
|
50
|
+
inactiveBackgroundColor,
|
|
51
|
+
inactiveTintColor,
|
|
52
|
+
labelStyle,
|
|
53
|
+
iconStyle,
|
|
54
|
+
showLabel,
|
|
55
|
+
style,
|
|
56
|
+
floatingButton,
|
|
57
|
+
}: Props) {
|
|
58
|
+
const { theme } = useContext(ApplicationContext);
|
|
59
|
+
const { routes } = state;
|
|
60
|
+
const widthDevice = useWindowDimensions()?.width;
|
|
61
|
+
const insets = useSafeAreaInsets();
|
|
62
|
+
const useFloating = floatingButton && state.routes.length % 2 === 0;
|
|
63
|
+
const itemWidth =
|
|
64
|
+
(widthDevice - insets.left - insets.right) /
|
|
65
|
+
(state.routes.length + (useFloating ? 1 : 0));
|
|
66
|
+
// const buildLink = useLinkBuilder();
|
|
67
|
+
const indicatorAnimated = useSharedValue(0);
|
|
47
68
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*/
|
|
52
|
-
const useCenterActionPress = () => {
|
|
53
|
-
const scale = useSharedValue(1);
|
|
54
|
-
const buttonStyle = useAnimatedStyle(() => ({
|
|
55
|
-
transform: [{ scale: scale.value }],
|
|
69
|
+
const indicatorStyle = useAnimatedStyle(() => ({
|
|
70
|
+
width: itemWidth,
|
|
71
|
+
transform: [{ translateX: indicatorAnimated.value }],
|
|
56
72
|
}));
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
TabBarMotion.ctaPressedScale,
|
|
60
|
-
TabBarMotion.ctaPress,
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
const onPressOut = () => {
|
|
64
|
-
scale.value = withTiming(1, TabBarMotion.ctaPress);
|
|
65
|
-
};
|
|
66
|
-
return { buttonStyle, onPressIn, onPressOut };
|
|
67
|
-
};
|
|
73
|
+
const paddingBottom = getPaddingBottom(insets);
|
|
74
|
+
const focusedTab = state?.routes[state.index]?.name || routes[0]?.params;
|
|
68
75
|
|
|
69
|
-
/**
|
|
70
|
-
* Center action (.Nav/CTA): a button rising out of the notch, its label below
|
|
71
|
-
* (growing downward when scaled).
|
|
72
|
-
*/
|
|
73
|
-
const CenterAction: React.FC<{ floatingButton: FloatingButtonProps }> = ({
|
|
74
|
-
floatingButton,
|
|
75
|
-
}) => {
|
|
76
|
-
const { theme } = useContext(ApplicationContext);
|
|
77
76
|
const context = useContext<any>(MiniAppContext);
|
|
78
77
|
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
79
|
-
const { icon, label, onPress, labelContent } = floatingButton;
|
|
80
|
-
const { buttonStyle, onPressIn, onPressOut } = useCenterActionPress();
|
|
81
|
-
let iconNode = icon;
|
|
82
|
-
if (typeof icon === 'string') {
|
|
83
|
-
iconNode = (
|
|
84
|
-
<Icon
|
|
85
|
-
source={icon}
|
|
86
|
-
size={TabBarMetrics.ctaIconSize}
|
|
87
|
-
color={Colors.black_01}
|
|
88
|
-
/>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
78
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
79
|
+
/**
|
|
80
|
+
* render tab item
|
|
81
|
+
*/
|
|
82
|
+
const renderTabItem = useCallback(
|
|
83
|
+
(data: Route<string, any>[]) => {
|
|
84
|
+
return data?.map(route => {
|
|
85
|
+
const focused = route?.params?.name === focusedTab;
|
|
86
|
+
const { options } = descriptors[route.key];
|
|
87
|
+
|
|
88
|
+
const onPress = () => {
|
|
89
|
+
const event = navigation.emit({
|
|
90
|
+
type: 'tabPress',
|
|
91
|
+
target: route.key,
|
|
92
|
+
canPreventDefault: true,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
if (!focused && !event.defaultPrevented) {
|
|
96
|
+
navigation.dispatch({
|
|
97
|
+
...CommonActions.navigate(route.name),
|
|
98
|
+
target: state.key,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const onLongPress = () => {
|
|
104
|
+
navigation.emit({
|
|
105
|
+
type: 'tabLongPress',
|
|
106
|
+
target: route.key,
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<CustomBottomTabItem
|
|
112
|
+
key={route.key}
|
|
113
|
+
route={route}
|
|
114
|
+
label={options.tabBarLabel || options.title || route.name}
|
|
115
|
+
focused={focused}
|
|
116
|
+
onPress={onPress}
|
|
117
|
+
onLongPress={onLongPress}
|
|
118
|
+
activeTintColor={activeTintColor ?? theme.colors.primary}
|
|
119
|
+
inactiveTintColor={inactiveTintColor ?? theme.colors.text.default}
|
|
120
|
+
activeBackgroundColor={activeBackgroundColor}
|
|
121
|
+
inactiveBackgroundColor={inactiveBackgroundColor}
|
|
122
|
+
icon={options.tabBarIcon}
|
|
123
|
+
badge={options.tabBarBadge}
|
|
124
|
+
showLabel={showLabel}
|
|
125
|
+
labelStyle={labelStyle}
|
|
126
|
+
iconStyle={iconStyle}
|
|
127
|
+
style={options.tabBarStyle}
|
|
128
|
+
badgeStyle={options.tabBarBadgeStyle}
|
|
129
|
+
allowFontScaling={allowFontScaling}
|
|
130
|
+
/>
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
[
|
|
135
|
+
focusedTab,
|
|
136
|
+
descriptors,
|
|
137
|
+
activeTintColor,
|
|
138
|
+
theme.colors.primary,
|
|
139
|
+
theme.colors.text.default,
|
|
140
|
+
inactiveTintColor,
|
|
141
|
+
activeBackgroundColor,
|
|
142
|
+
inactiveBackgroundColor,
|
|
143
|
+
showLabel,
|
|
144
|
+
labelStyle,
|
|
145
|
+
iconStyle,
|
|
146
|
+
allowFontScaling,
|
|
147
|
+
navigation,
|
|
148
|
+
state.key,
|
|
149
|
+
],
|
|
127
150
|
);
|
|
128
|
-
};
|
|
129
151
|
|
|
130
|
-
/**
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}> = ({ items, width, activeTintColor, inactiveTintColor, floatingButton }) => {
|
|
141
|
-
const withCta = hasCenterAction(floatingButton, items.length);
|
|
142
|
-
const [layouts, setLayouts] = useState<
|
|
143
|
-
Record<string, { x: number; y: number; width: number }>
|
|
144
|
-
>({});
|
|
145
|
-
const selected = layouts[items.find(item => item.focused)?.route.key ?? ''];
|
|
152
|
+
/**
|
|
153
|
+
* render floating button
|
|
154
|
+
*/
|
|
155
|
+
const renderFloatingButton = useCallback(() => {
|
|
156
|
+
const renderFloatingIcon = () => {
|
|
157
|
+
if (typeof floatingButton?.icon === 'string') {
|
|
158
|
+
return <Icon source={floatingButton?.icon} size={32} color={'white'} />;
|
|
159
|
+
}
|
|
160
|
+
return floatingButton?.icon;
|
|
161
|
+
};
|
|
146
162
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
163
|
+
return (
|
|
164
|
+
<View style={[Styles.flex, showBaseLineDebug && styles.debugBaseLine]}>
|
|
165
|
+
<TouchableOpacity
|
|
166
|
+
onPress={floatingButton?.onPress}
|
|
167
|
+
style={styles.floatingContainer}
|
|
168
|
+
>
|
|
169
|
+
<View
|
|
170
|
+
style={{
|
|
171
|
+
...styles.floatingContent,
|
|
172
|
+
backgroundColor: activeTintColor ?? theme.colors.primary,
|
|
173
|
+
}}
|
|
174
|
+
>
|
|
175
|
+
{renderFloatingIcon()}
|
|
176
|
+
</View>
|
|
177
|
+
<View
|
|
178
|
+
style={{
|
|
179
|
+
top: -4,
|
|
180
|
+
backgroundColor: activeTintColor ?? theme.colors.primary,
|
|
181
|
+
borderRadius: Radius.XL,
|
|
182
|
+
paddingHorizontal: 6,
|
|
183
|
+
}}
|
|
184
|
+
>
|
|
185
|
+
<Text
|
|
186
|
+
numberOfLines={1}
|
|
187
|
+
typography={'description_xs_regular'}
|
|
188
|
+
color={'white'}
|
|
189
|
+
>
|
|
190
|
+
{floatingButton?.label}
|
|
191
|
+
</Text>
|
|
192
|
+
</View>
|
|
193
|
+
</TouchableOpacity>
|
|
194
|
+
</View>
|
|
195
|
+
);
|
|
196
|
+
}, [
|
|
197
|
+
activeTintColor,
|
|
198
|
+
floatingButton?.icon,
|
|
199
|
+
floatingButton?.label,
|
|
200
|
+
floatingButton?.onPress,
|
|
201
|
+
showBaseLineDebug,
|
|
202
|
+
theme.colors.primary,
|
|
203
|
+
]);
|
|
169
204
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
205
|
+
/**
|
|
206
|
+
* animated indicator
|
|
207
|
+
*/
|
|
208
|
+
React.useEffect(() => {
|
|
209
|
+
let index = state.index;
|
|
210
|
+
if (useFloating && index > (state.routes.length - 1) / 2) {
|
|
211
|
+
index += 1;
|
|
212
|
+
}
|
|
213
|
+
indicatorAnimated.value = withTiming(itemWidth * index, { duration: 200 });
|
|
214
|
+
}, [
|
|
215
|
+
state.index,
|
|
216
|
+
itemWidth,
|
|
217
|
+
indicatorAnimated,
|
|
218
|
+
useFloating,
|
|
219
|
+
state.routes.length,
|
|
220
|
+
]);
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* render tab bar
|
|
224
|
+
*/
|
|
225
|
+
const renderTabBar = () => {
|
|
226
|
+
if (useFloating) {
|
|
227
|
+
const middleIndex = routes.length / 2;
|
|
228
|
+
const leftArr = routes.slice(0, middleIndex);
|
|
229
|
+
const rightArr = routes.slice(middleIndex);
|
|
173
230
|
return (
|
|
174
231
|
<>
|
|
175
|
-
{
|
|
176
|
-
|
|
177
|
-
{
|
|
232
|
+
{renderTabItem(leftArr)}
|
|
233
|
+
{renderFloatingButton()}
|
|
234
|
+
{renderTabItem(rightArr)}
|
|
178
235
|
</>
|
|
179
236
|
);
|
|
180
237
|
}
|
|
181
|
-
return
|
|
238
|
+
return renderTabItem(routes);
|
|
182
239
|
};
|
|
183
240
|
|
|
184
|
-
const customContainer = withCta && floatingButton?.container;
|
|
185
|
-
|
|
186
241
|
return (
|
|
187
242
|
<View
|
|
188
|
-
style={[styles.container, { width }]}
|
|
189
|
-
accessibilityLabel={'bottom_tab_bar'}
|
|
190
|
-
>
|
|
191
|
-
{customContainer || (
|
|
192
|
-
<CurvedContainer
|
|
193
|
-
width={width}
|
|
194
|
-
height={TabBarMetrics.height}
|
|
195
|
-
radius={TabBarMetrics.height / 2}
|
|
196
|
-
notchCenterX={withCta ? width / 2 : undefined}
|
|
197
|
-
/>
|
|
198
|
-
)}
|
|
199
|
-
<View style={styles.content}>
|
|
200
|
-
<ActiveIndicator
|
|
201
|
-
axis={'x'}
|
|
202
|
-
offset={selected?.x}
|
|
203
|
-
extent={selected?.width}
|
|
204
|
-
radius={TabBarMetrics.indicatorRadius}
|
|
205
|
-
style={[
|
|
206
|
-
styles.indicator,
|
|
207
|
-
{ top: selected?.y ?? TabBarMetrics.paddingVertical },
|
|
208
|
-
]}
|
|
209
|
-
/>
|
|
210
|
-
{renderContent()}
|
|
211
|
-
</View>
|
|
212
|
-
</View>
|
|
213
|
-
);
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Phone tab bar: the horizontal bar floats over the tab content above the home indicator,
|
|
218
|
-
* so content shows around it and through the notch. The transparent strip above it keeps
|
|
219
|
-
* the rising center action touchable.
|
|
220
|
-
*/
|
|
221
|
-
export default function BottomTabBar(props: Props) {
|
|
222
|
-
const { state, floatingButton, activeTintColor, inactiveTintColor } = props;
|
|
223
|
-
const window = useWindowDimensions();
|
|
224
|
-
const insets = useSafeAreaInsets();
|
|
225
|
-
const withCta = hasCenterAction(floatingButton, state.routes.length);
|
|
226
|
-
const width = getHorizontalBarWidth(
|
|
227
|
-
window.width,
|
|
228
|
-
window.height,
|
|
229
|
-
insets.left,
|
|
230
|
-
insets.right,
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
return (
|
|
234
|
-
<View
|
|
235
|
-
pointerEvents={'box-none'}
|
|
236
243
|
style={[
|
|
237
|
-
styles.
|
|
238
|
-
|
|
244
|
+
floatingButton ? styles.tabBarFloatingButton : styles.tabBar,
|
|
245
|
+
{
|
|
246
|
+
backgroundColor: theme.colors.background.surface,
|
|
247
|
+
borderTopColor: theme.colors.border.default,
|
|
248
|
+
},
|
|
239
249
|
{
|
|
240
|
-
paddingBottom:
|
|
241
|
-
// centered between the side safe areas
|
|
250
|
+
paddingBottom: paddingBottom,
|
|
242
251
|
paddingLeft: insets.left,
|
|
243
252
|
paddingRight: insets.right,
|
|
244
253
|
},
|
|
254
|
+
style,
|
|
245
255
|
]}
|
|
256
|
+
pointerEvents={'auto'}
|
|
246
257
|
>
|
|
247
|
-
<
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
258
|
+
<View style={styles.content} accessibilityLabel={'bottom_tab_bar'}>
|
|
259
|
+
{useFloating && floatingButton?.container}
|
|
260
|
+
<Animated.View
|
|
261
|
+
style={[{ position: 'absolute', top: 0 }, indicatorStyle]}
|
|
262
|
+
>
|
|
263
|
+
<View
|
|
264
|
+
style={[
|
|
265
|
+
styles.indicator,
|
|
266
|
+
{ backgroundColor: activeTintColor ?? theme.colors.primary },
|
|
267
|
+
]}
|
|
268
|
+
/>
|
|
269
|
+
</Animated.View>
|
|
270
|
+
{renderTabBar()}
|
|
271
|
+
</View>
|
|
254
272
|
</View>
|
|
255
273
|
);
|
|
256
274
|
}
|
|
257
275
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
276
|
+
const styles = StyleSheet.create({
|
|
277
|
+
content: {
|
|
278
|
+
flex: 1,
|
|
279
|
+
flexDirection: 'row',
|
|
280
|
+
},
|
|
281
|
+
tabBar: {
|
|
282
|
+
left: 0,
|
|
283
|
+
right: 0,
|
|
284
|
+
bottom: 0,
|
|
285
|
+
borderTopWidth: StyleSheet.hairlineWidth,
|
|
286
|
+
elevation: 8,
|
|
287
|
+
},
|
|
288
|
+
tabBarFloatingButton: {
|
|
289
|
+
left: 0,
|
|
290
|
+
right: 0,
|
|
291
|
+
bottom: 0,
|
|
292
|
+
zIndex: 1,
|
|
293
|
+
shadowColor: Colors.black_20,
|
|
294
|
+
shadowOffset: { width: 0, height: -2 },
|
|
295
|
+
shadowOpacity: 0.05,
|
|
296
|
+
shadowRadius: 3,
|
|
297
|
+
elevation: 8,
|
|
298
|
+
},
|
|
299
|
+
floatingContainer: {
|
|
300
|
+
position: 'absolute',
|
|
301
|
+
alignItems: 'center',
|
|
302
|
+
left: 0,
|
|
303
|
+
right: 0,
|
|
304
|
+
top: -2,
|
|
305
|
+
bottom: Platform.OS === 'ios' ? -6 : 4
|
|
306
|
+
},
|
|
307
|
+
floatingContent: {
|
|
308
|
+
alignItems: 'center',
|
|
309
|
+
justifyContent: 'center',
|
|
310
|
+
height: 48,
|
|
311
|
+
width: 48,
|
|
312
|
+
borderRadius: 24,
|
|
313
|
+
top: -10,
|
|
314
|
+
},
|
|
315
|
+
indicator: {
|
|
316
|
+
height: 2,
|
|
317
|
+
width: 44,
|
|
318
|
+
alignSelf: 'center',
|
|
319
|
+
borderBottomLeftRadius: 1,
|
|
320
|
+
borderBottomRightRadius: 1,
|
|
321
|
+
},
|
|
322
|
+
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
323
|
+
});
|