@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,63 +1,199 @@
|
|
|
1
|
+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from '@react-navigation/
|
|
6
|
-
import {
|
|
7
|
-
import React, { useContext, useLayoutEffect } from 'react';
|
|
3
|
+
NavigationContainer,
|
|
4
|
+
NavigationIndependentTree,
|
|
5
|
+
useFocusEffect,
|
|
6
|
+
} from '@react-navigation/native';
|
|
7
|
+
import { createStackNavigator } from '@react-navigation/stack';
|
|
8
|
+
import React, { useContext, useEffect, useLayoutEffect } from 'react';
|
|
9
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
8
10
|
import {
|
|
9
|
-
Easing,
|
|
10
11
|
NativeModules,
|
|
11
12
|
Platform,
|
|
12
13
|
StatusBar,
|
|
14
|
+
StyleSheet,
|
|
13
15
|
useWindowDimensions,
|
|
16
|
+
View,
|
|
14
17
|
} from 'react-native';
|
|
18
|
+
import Animated, {
|
|
19
|
+
useAnimatedStyle,
|
|
20
|
+
useSharedValue,
|
|
21
|
+
withTiming,
|
|
22
|
+
} from 'react-native-reanimated';
|
|
23
|
+
import { Colors } from '../../Consts';
|
|
15
24
|
import { Icon } from '../../Icon';
|
|
25
|
+
import { exportFontFamily, Text } from '../../Text';
|
|
26
|
+
import StackScreen from '../StackScreen';
|
|
16
27
|
import { BottomTabProps } from '../types';
|
|
17
|
-
import
|
|
18
|
-
import BottomTabBar
|
|
19
|
-
import {
|
|
20
|
-
import { getTabBadge } from './TabBarIcon';
|
|
21
|
-
import { DuoTabBar, useDuoTabBarInset } from './DuoTabBar';
|
|
22
|
-
import { BottomTabInsetContext } from './BottomTabInset';
|
|
28
|
+
import { getOptions, getStackOptions, useAppState } from '../utils';
|
|
29
|
+
import BottomTabBar from './BottomTabBar';
|
|
30
|
+
import { DuoTabBar } from './DuoTabBar';
|
|
23
31
|
import { DuoBarCompressionProvider } from './DuoBarCompression';
|
|
24
|
-
import
|
|
25
|
-
import { ApplicationContext } from '../../Context';
|
|
32
|
+
import { ApplicationContext, MiniAppContext } from '../../Context';
|
|
26
33
|
import { useScreenLayout } from '../../Layout';
|
|
27
|
-
|
|
28
|
-
type SceneInterpolator = BottomTabNavigationOptions['sceneStyleInterpolator'];
|
|
34
|
+
import { getHeaderRowOptions } from '../../Layout/utils';
|
|
29
35
|
|
|
30
36
|
const Tab = createBottomTabNavigator();
|
|
37
|
+
const Stack = createStackNavigator();
|
|
31
38
|
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
const TabScreen: React.FC<any> = ({ route, navigation }) => {
|
|
40
|
+
const { navigator } = useContext(ApplicationContext);
|
|
41
|
+
const context = useContext<any>(MiniAppContext);
|
|
42
|
+
const { nested, options, screen, initialParams } = route?.params;
|
|
43
|
+
const headerStyleOptions = getHeaderRowOptions(useScreenLayout());
|
|
44
|
+
|
|
45
|
+
const opacityValue = 0.3;
|
|
46
|
+
const scaleValue = 0.97;
|
|
47
|
+
const opacity = useSharedValue(opacityValue);
|
|
48
|
+
const scale = useSharedValue(scaleValue);
|
|
49
|
+
const screenName = screen?.name || screen?.type?.name || 'Invalid';
|
|
50
|
+
const { isBackgroundToForeground } = useAppState();
|
|
51
|
+
|
|
52
|
+
const tabAnimatedStyle = useAnimatedStyle(() => ({
|
|
53
|
+
opacity: opacity.value,
|
|
54
|
+
transform: [{ scale: scale.value }],
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
const onScreenNavigated = (pre: string, current: string) => {
|
|
58
|
+
if (!isBackgroundToForeground) {
|
|
59
|
+
const data: any = {
|
|
60
|
+
preScreenName: pre,
|
|
61
|
+
screenName: current,
|
|
62
|
+
componentName: 'Screen',
|
|
63
|
+
state: 'navigated',
|
|
64
|
+
action: 'push',
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
context?.autoTracking?.({
|
|
68
|
+
...context,
|
|
69
|
+
...data,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* debug toast
|
|
74
|
+
*/
|
|
75
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
76
|
+
appId: context.appId,
|
|
77
|
+
message: `${screenName} screen_navigated`,
|
|
78
|
+
type: 'ERROR',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
useFocusEffect(
|
|
84
|
+
React.useCallback(
|
|
85
|
+
() => {
|
|
86
|
+
opacity.value = withTiming(1, { duration: 200 });
|
|
87
|
+
scale.value = withTiming(1, { duration: 200 });
|
|
88
|
+
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
navigator?.maxApi?.getDataObserver?.(
|
|
91
|
+
'current_screen',
|
|
92
|
+
(data: any) => {
|
|
93
|
+
onScreenNavigated(data?.screenName, screenName);
|
|
94
|
+
navigator?.maxApi?.setObserver?.('current_screen', {
|
|
95
|
+
screenName,
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
);
|
|
99
|
+
}, 100);
|
|
100
|
+
|
|
101
|
+
return () => {
|
|
102
|
+
if (navigation.getState().index !== route?.params.index) {
|
|
103
|
+
opacity.value = withTiming(opacityValue, { duration: 200 });
|
|
104
|
+
scale.value = withTiming(scaleValue, { duration: 200 });
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
109
|
+
[],
|
|
110
|
+
),
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
useEffect(
|
|
114
|
+
() => {
|
|
115
|
+
const onFocusApp = navigator?.maxApi?.listen?.('onFocusApp', () => {
|
|
116
|
+
if (navigation.isFocused()) {
|
|
117
|
+
navigator?.maxApi?.getDataObserver?.(
|
|
118
|
+
'current_screen',
|
|
119
|
+
(data: any) => {
|
|
120
|
+
onScreenNavigated(data?.screenName, screenName);
|
|
121
|
+
navigator?.maxApi?.setObserver?.('current_screen', {
|
|
122
|
+
screenName,
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
return () => {
|
|
130
|
+
onFocusApp?.remove?.();
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
134
|
+
[],
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
let stackOptions = {};
|
|
138
|
+
if (options) {
|
|
139
|
+
stackOptions = getOptions(options);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (nested) {
|
|
143
|
+
return (
|
|
144
|
+
<Animated.View style={[styles.container, tabAnimatedStyle]}>
|
|
145
|
+
<Stack.Navigator
|
|
146
|
+
screenOptions={headerStyleOptions}
|
|
147
|
+
>
|
|
148
|
+
<Stack.Screen
|
|
149
|
+
name="Stack"
|
|
150
|
+
component={StackScreen}
|
|
151
|
+
initialParams={{
|
|
152
|
+
screen,
|
|
153
|
+
options: stackOptions,
|
|
154
|
+
initialParams,
|
|
155
|
+
bottomTab: 'nested',
|
|
156
|
+
}}
|
|
157
|
+
options={{ ...getStackOptions() }}
|
|
158
|
+
/>
|
|
159
|
+
</Stack.Navigator>
|
|
160
|
+
</Animated.View>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
37
163
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const getTabSlide = (width: number): SceneInterpolator => {
|
|
43
|
-
return ({ current }) => ({
|
|
44
|
-
sceneStyle: {
|
|
45
|
-
transform: [
|
|
164
|
+
return (
|
|
165
|
+
<Animated.View
|
|
166
|
+
style={[
|
|
167
|
+
styles.container,
|
|
46
168
|
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
outputRange: [-width, 0, width],
|
|
50
|
-
}),
|
|
169
|
+
opacity,
|
|
170
|
+
transform: [{ scale }],
|
|
51
171
|
},
|
|
52
|
-
]
|
|
53
|
-
|
|
54
|
-
|
|
172
|
+
]}
|
|
173
|
+
>
|
|
174
|
+
<NavigationIndependentTree>
|
|
175
|
+
<NavigationContainer>
|
|
176
|
+
<Stack.Navigator
|
|
177
|
+
screenOptions={headerStyleOptions}
|
|
178
|
+
>
|
|
179
|
+
<Stack.Screen
|
|
180
|
+
name="Stack"
|
|
181
|
+
component={StackScreen}
|
|
182
|
+
initialParams={{
|
|
183
|
+
screen,
|
|
184
|
+
options: stackOptions,
|
|
185
|
+
initialParams,
|
|
186
|
+
bottomTab: 'default',
|
|
187
|
+
}}
|
|
188
|
+
options={{ ...getStackOptions(), ...options }}
|
|
189
|
+
/>
|
|
190
|
+
</Stack.Navigator>
|
|
191
|
+
</NavigationContainer>
|
|
192
|
+
</NavigationIndependentTree>
|
|
193
|
+
</Animated.View>
|
|
194
|
+
);
|
|
55
195
|
};
|
|
56
196
|
|
|
57
|
-
/**
|
|
58
|
-
* App tab navigator: the floating bar on phones, the rail or floating bar on
|
|
59
|
-
* iPhone Duo, tabs sliding in index order. Shares the bar inset with its tabs.
|
|
60
|
-
*/
|
|
61
197
|
const BottomTab: React.FC<BottomTabProps> = ({
|
|
62
198
|
nested,
|
|
63
199
|
tabs,
|
|
@@ -69,15 +205,17 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
69
205
|
}) => {
|
|
70
206
|
const { theme, navigator } = useContext(ApplicationContext);
|
|
71
207
|
const { isIPhoneDuo } = useScreenLayout();
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
// The center action's button rises above the bar; tab content leaves room for it too.
|
|
75
|
-
let tabBarInset = barInset;
|
|
76
|
-
if (barInset && hasCenterAction(floatingButton, tabs.length)) {
|
|
77
|
-
tabBarInset = barInset + TabBarMetrics.ctaLift;
|
|
78
|
-
}
|
|
208
|
+
const dimensions = useWindowDimensions();
|
|
209
|
+
const insets = useSafeAreaInsets();
|
|
79
210
|
const initialIndex = tabs.findIndex(i => i.name === initialRouteName);
|
|
211
|
+
const indicatorAnimated = useSharedValue(0);
|
|
80
212
|
const activeIndex = React.useRef(initialIndex > 0 ? initialIndex : 0);
|
|
213
|
+
const itemWidth = dimensions.width / tabs.length;
|
|
214
|
+
|
|
215
|
+
const indicatorStyle = useAnimatedStyle(() => ({
|
|
216
|
+
width: itemWidth,
|
|
217
|
+
transform: [{ translateX: indicatorAnimated.value }],
|
|
218
|
+
}));
|
|
81
219
|
|
|
82
220
|
useLayoutEffect(() => {
|
|
83
221
|
navigation?.setOptions({
|
|
@@ -87,29 +225,36 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
87
225
|
});
|
|
88
226
|
}, [navigation]);
|
|
89
227
|
|
|
90
|
-
|
|
228
|
+
useEffect(() => {
|
|
229
|
+
indicatorAnimated.value = withTiming(itemWidth * activeIndex.current, {
|
|
230
|
+
duration: 200,
|
|
231
|
+
});
|
|
232
|
+
}, [itemWidth, indicatorAnimated]);
|
|
233
|
+
|
|
234
|
+
// Focus, not mount: pushing a screen from a tab leaves BottomTab mounted but blurred, and
|
|
235
|
+
// onFocus only fires on tab changes.
|
|
91
236
|
useFocusEffect(
|
|
92
237
|
React.useCallback(() => {
|
|
93
238
|
NativeModules?.MiniAppModule?.setShouldUseFloatingArrowBack?.(
|
|
94
239
|
activeIndex.current !== 0,
|
|
95
240
|
);
|
|
96
|
-
return () =>
|
|
241
|
+
return () =>
|
|
97
242
|
NativeModules?.MiniAppModule?.setShouldUseFloatingArrowBack?.(false);
|
|
98
|
-
};
|
|
99
243
|
}, []),
|
|
100
244
|
);
|
|
101
245
|
|
|
102
246
|
const onFocus = (e: any) => {
|
|
103
247
|
activeIndex.current = tabs.findIndex(i => e.target.includes(i.name));
|
|
248
|
+
indicatorAnimated.value = withTiming(itemWidth * activeIndex.current, {
|
|
249
|
+
duration: 200,
|
|
250
|
+
});
|
|
104
251
|
|
|
105
252
|
const isFirstTab = activeIndex.current === 0;
|
|
106
253
|
const gestureEnabled = Platform.OS === 'ios' && isFirstTab;
|
|
107
254
|
navigation?.setOptions({
|
|
108
255
|
gestureEnabled: gestureEnabled,
|
|
109
256
|
});
|
|
110
|
-
NativeModules?.MiniAppModule?.setShouldUseFloatingArrowBack?.(
|
|
111
|
-
!gestureEnabled,
|
|
112
|
-
);
|
|
257
|
+
NativeModules?.MiniAppModule?.setShouldUseFloatingArrowBack?.(!gestureEnabled);
|
|
113
258
|
};
|
|
114
259
|
|
|
115
260
|
const handler: {
|
|
@@ -132,20 +277,8 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
132
277
|
},
|
|
133
278
|
};
|
|
134
279
|
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
const TabBar = isIPhoneDuo ? DuoTabBar : BottomTabBar;
|
|
138
|
-
return (
|
|
139
|
-
<ScaleSizeProvider scaleSizeMaxRate={TabBarMetrics.labelMaxScale}>
|
|
140
|
-
<TabBar
|
|
141
|
-
{...props}
|
|
142
|
-
floatingButton={floatingButton}
|
|
143
|
-
inactiveTintColor={theme.colors.text.secondary}
|
|
144
|
-
activeTintColor={theme.colors.primary}
|
|
145
|
-
/>
|
|
146
|
-
</ScaleSizeProvider>
|
|
147
|
-
);
|
|
148
|
-
};
|
|
280
|
+
const isIOS = Platform.OS === 'ios';
|
|
281
|
+
const bottomInset = isIOS ? Math.min(insets.bottom, 21) : insets.bottom;
|
|
149
282
|
|
|
150
283
|
return (
|
|
151
284
|
<DuoBarCompressionProvider
|
|
@@ -153,21 +286,93 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
153
286
|
tabCount={tabs.length}
|
|
154
287
|
hasQr={!!floatingButton}
|
|
155
288
|
>
|
|
156
|
-
<
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
289
|
+
<Tab.Navigator
|
|
290
|
+
screenOptions={{
|
|
291
|
+
headerShown: false,
|
|
292
|
+
headerTransparent: true,
|
|
293
|
+
headerBackground: undefined,
|
|
294
|
+
tabBarLabelPosition: 'below-icon',
|
|
295
|
+
tabBarBackground: () => (
|
|
296
|
+
<View
|
|
297
|
+
style={[
|
|
298
|
+
styles.container,
|
|
299
|
+
{
|
|
300
|
+
backgroundColor: theme.colors.background.surface,
|
|
301
|
+
},
|
|
302
|
+
]}
|
|
303
|
+
>
|
|
304
|
+
<Animated.View
|
|
305
|
+
style={[styles.indicatorContainer, indicatorStyle]}
|
|
306
|
+
>
|
|
307
|
+
<View
|
|
308
|
+
style={[
|
|
309
|
+
styles.indicator,
|
|
310
|
+
{ backgroundColor: theme.colors.primary },
|
|
311
|
+
]}
|
|
312
|
+
/>
|
|
313
|
+
</Animated.View>
|
|
314
|
+
</View>
|
|
315
|
+
),
|
|
316
|
+
}}
|
|
317
|
+
tabBar={props =>
|
|
318
|
+
isIPhoneDuo ? (
|
|
319
|
+
<DuoTabBar
|
|
320
|
+
{...props}
|
|
321
|
+
floatingButton={floatingButton}
|
|
322
|
+
inactiveTintColor={theme.colors.text.hint}
|
|
323
|
+
activeTintColor={theme.colors.primary}
|
|
324
|
+
/>
|
|
325
|
+
) : (
|
|
326
|
+
<BottomTabBar
|
|
327
|
+
{...props}
|
|
328
|
+
floatingButton={floatingButton}
|
|
329
|
+
inactiveTintColor={theme.colors.text.hint}
|
|
330
|
+
activeTintColor={theme.colors.primary}
|
|
331
|
+
style={[{ height: 64 + bottomInset }]}
|
|
332
|
+
/>
|
|
333
|
+
)
|
|
334
|
+
}
|
|
335
|
+
initialRouteName={initialRouteName}
|
|
336
|
+
>
|
|
337
|
+
{tabs.map((item, index) => {
|
|
338
|
+
const isNum = !isNaN(parseInt(`${item?.badgeLabel}`, 10));
|
|
339
|
+
const isDot =
|
|
340
|
+
typeof item?.badgeLabel === 'string' && !item?.badgeLabel;
|
|
341
|
+
const isNumZero = isNum && Number(item.badgeLabel) === 0;
|
|
342
|
+
|
|
343
|
+
let badgeLabel = item?.badgeLabel;
|
|
344
|
+
if (isNumZero) {
|
|
345
|
+
badgeLabel = undefined;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
let badgeStyle: {
|
|
349
|
+
marginRight: number;
|
|
350
|
+
top: number;
|
|
351
|
+
backgroundColor: string;
|
|
352
|
+
width?: number;
|
|
353
|
+
} = {
|
|
354
|
+
marginRight: -8,
|
|
355
|
+
top: -4,
|
|
356
|
+
backgroundColor: Colors.orange_03,
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
if (isNum) {
|
|
360
|
+
badgeStyle = {
|
|
361
|
+
marginRight: -4,
|
|
362
|
+
top: -4,
|
|
363
|
+
backgroundColor: Colors.red_03,
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
if (isDot) {
|
|
367
|
+
badgeStyle = {
|
|
368
|
+
marginRight: -2,
|
|
369
|
+
top: -2,
|
|
370
|
+
backgroundColor: Colors.orange_03,
|
|
371
|
+
width: 12,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return (
|
|
171
376
|
<Tab.Screen
|
|
172
377
|
key={`BottomTab-${item.name}`}
|
|
173
378
|
name={item.name}
|
|
@@ -175,19 +380,78 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
175
380
|
initialParams={{ ...item, nested, index }}
|
|
176
381
|
listeners={handler}
|
|
177
382
|
options={{
|
|
383
|
+
tabBarLabel: ({ focused, color }) => {
|
|
384
|
+
return (
|
|
385
|
+
<Text
|
|
386
|
+
numberOfLines={1}
|
|
387
|
+
typography={
|
|
388
|
+
focused ? 'label_xs_medium' : 'description_xs_regular'
|
|
389
|
+
}
|
|
390
|
+
color={color}
|
|
391
|
+
>
|
|
392
|
+
{item.label}
|
|
393
|
+
</Text>
|
|
394
|
+
);
|
|
395
|
+
},
|
|
178
396
|
title: item.label,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
397
|
+
tabBarStyle: [
|
|
398
|
+
{
|
|
399
|
+
height: 64,
|
|
400
|
+
},
|
|
401
|
+
styles.tabStyle,
|
|
402
|
+
],
|
|
403
|
+
tabBarBadge: badgeLabel,
|
|
404
|
+
tabBarBadgeStyle: [
|
|
405
|
+
{
|
|
406
|
+
borderColor: 'white',
|
|
407
|
+
borderWidth: 2,
|
|
408
|
+
fontSize: 10,
|
|
409
|
+
lineHeight: 14,
|
|
410
|
+
fontWeight: 'bold',
|
|
411
|
+
alignSelf: 'center',
|
|
412
|
+
fontFamily: exportFontFamily('bold'),
|
|
413
|
+
},
|
|
414
|
+
badgeStyle,
|
|
415
|
+
],
|
|
416
|
+
tabBarIcon: ({ color }) => (
|
|
417
|
+
<Icon source={item.icon} color={color} size={28} />
|
|
182
418
|
),
|
|
183
419
|
...item,
|
|
184
420
|
}}
|
|
185
421
|
/>
|
|
186
|
-
)
|
|
187
|
-
|
|
188
|
-
</
|
|
422
|
+
);
|
|
423
|
+
})}
|
|
424
|
+
</Tab.Navigator>
|
|
189
425
|
</DuoBarCompressionProvider>
|
|
190
426
|
);
|
|
191
427
|
};
|
|
192
428
|
|
|
429
|
+
const styles = StyleSheet.create({
|
|
430
|
+
container: { flex: 1 },
|
|
431
|
+
indicatorContainer: { position: 'absolute', top: 0 },
|
|
432
|
+
indicator: {
|
|
433
|
+
height: 2,
|
|
434
|
+
width: 48,
|
|
435
|
+
alignSelf: 'center',
|
|
436
|
+
borderBottomLeftRadius: 2,
|
|
437
|
+
borderBottomRightRadius: 2,
|
|
438
|
+
},
|
|
439
|
+
tabBarStyle: {
|
|
440
|
+
...Platform.select({
|
|
441
|
+
ios: {
|
|
442
|
+
shadowColor: Colors.black_10,
|
|
443
|
+
shadowOffset: { width: 0, height: 4 },
|
|
444
|
+
shadowOpacity: 1,
|
|
445
|
+
shadowRadius: 4,
|
|
446
|
+
},
|
|
447
|
+
android: {
|
|
448
|
+
elevation: 4,
|
|
449
|
+
},
|
|
450
|
+
}),
|
|
451
|
+
},
|
|
452
|
+
tabStyle: {
|
|
453
|
+
paddingVertical: 4,
|
|
454
|
+
},
|
|
455
|
+
});
|
|
456
|
+
|
|
193
457
|
export default BottomTab;
|