@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,160 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
NavigationContainer,
|
|
3
|
-
NavigationIndependentTree,
|
|
4
|
-
useFocusEffect,
|
|
5
|
-
} from '@react-navigation/native';
|
|
6
|
-
import { createStackNavigator } from '@react-navigation/stack';
|
|
7
|
-
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
|
8
|
-
import { View } from 'react-native';
|
|
9
|
-
import StackScreen from '../StackScreen';
|
|
10
|
-
import { getOptions, getStackOptions } from '../navigationOptions';
|
|
11
|
-
import { useAppState } from '../hooks';
|
|
12
|
-
import { ApplicationContext, MiniAppContext } from '../../Context';
|
|
13
|
-
import { Styles } from '../../Consts';
|
|
14
|
-
import { useScreenLayout } from '../../Layout';
|
|
15
|
-
import { getHeaderRowOptions } from '../../Layout/utils';
|
|
16
|
-
import { BottomTabInsetContext } from './BottomTabInset';
|
|
17
|
-
|
|
18
|
-
const Stack = createStackNavigator();
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Content of one tab: its own stack, padded clear of the floating tab bar
|
|
22
|
-
* until a Screen inside claims that inset, plus screen_navigated tracking.
|
|
23
|
-
*/
|
|
24
|
-
const TabScreen: React.FC<any> = ({ route, navigation }) => {
|
|
25
|
-
const { navigator } = useContext(ApplicationContext);
|
|
26
|
-
const context = useContext<any>(MiniAppContext);
|
|
27
|
-
const { nested, options, screen, initialParams } = route?.params;
|
|
28
|
-
const headerStyleOptions = getHeaderRowOptions(useScreenLayout());
|
|
29
|
-
|
|
30
|
-
const screenName = screen?.name || screen?.type?.name || 'Invalid';
|
|
31
|
-
const { isBackgroundToForeground } = useAppState();
|
|
32
|
-
// Pad clear of the floating bar unless a Screen inside claims the inset to scroll under it.
|
|
33
|
-
const { inset: tabBarInset } = useContext(BottomTabInsetContext);
|
|
34
|
-
const [insetClaimed, setInsetClaimed] = useState(false);
|
|
35
|
-
const tabInsetValue = useMemo(
|
|
36
|
-
() => ({ inset: tabBarInset, claim: () => setInsetClaimed(true) }),
|
|
37
|
-
[tabBarInset],
|
|
38
|
-
);
|
|
39
|
-
const tabInsetStyle = { paddingBottom: insetClaimed ? 0 : tabBarInset };
|
|
40
|
-
|
|
41
|
-
const onScreenNavigated = (pre: string, current: string) => {
|
|
42
|
-
if (!isBackgroundToForeground) {
|
|
43
|
-
const data: any = {
|
|
44
|
-
preScreenName: pre,
|
|
45
|
-
screenName: current,
|
|
46
|
-
componentName: 'Screen',
|
|
47
|
-
state: 'navigated',
|
|
48
|
-
action: 'push',
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
context?.autoTracking?.({
|
|
52
|
-
...context,
|
|
53
|
-
...data,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
navigator?.maxApi?.showToastDebug?.({
|
|
57
|
-
appId: context.appId,
|
|
58
|
-
message: `${screenName} screen_navigated`,
|
|
59
|
-
type: 'ERROR',
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
useFocusEffect(
|
|
65
|
-
React.useCallback(
|
|
66
|
-
() => {
|
|
67
|
-
setTimeout(() => {
|
|
68
|
-
navigator?.maxApi?.getDataObserver?.(
|
|
69
|
-
'current_screen',
|
|
70
|
-
(data: any) => {
|
|
71
|
-
onScreenNavigated(data?.screenName, screenName);
|
|
72
|
-
navigator?.maxApi?.setObserver?.('current_screen', {
|
|
73
|
-
screenName,
|
|
74
|
-
});
|
|
75
|
-
},
|
|
76
|
-
);
|
|
77
|
-
}, 100);
|
|
78
|
-
},
|
|
79
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80
|
-
[],
|
|
81
|
-
),
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
useEffect(
|
|
85
|
-
() => {
|
|
86
|
-
const onFocusApp = navigator?.maxApi?.listen?.('onFocusApp', () => {
|
|
87
|
-
if (navigation.isFocused()) {
|
|
88
|
-
navigator?.maxApi?.getDataObserver?.(
|
|
89
|
-
'current_screen',
|
|
90
|
-
(data: any) => {
|
|
91
|
-
onScreenNavigated(data?.screenName, screenName);
|
|
92
|
-
navigator?.maxApi?.setObserver?.('current_screen', {
|
|
93
|
-
screenName,
|
|
94
|
-
});
|
|
95
|
-
},
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
return () => {
|
|
101
|
-
onFocusApp?.remove?.();
|
|
102
|
-
};
|
|
103
|
-
},
|
|
104
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
105
|
-
[],
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
let stackOptions = {};
|
|
109
|
-
if (options) {
|
|
110
|
-
stackOptions = getOptions(options);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (nested) {
|
|
114
|
-
return (
|
|
115
|
-
<BottomTabInsetContext.Provider value={tabInsetValue}>
|
|
116
|
-
<View style={[Styles.flex, tabInsetStyle]}>
|
|
117
|
-
<Stack.Navigator screenOptions={headerStyleOptions}>
|
|
118
|
-
<Stack.Screen
|
|
119
|
-
name="Stack"
|
|
120
|
-
component={StackScreen}
|
|
121
|
-
initialParams={{
|
|
122
|
-
screen,
|
|
123
|
-
options: stackOptions,
|
|
124
|
-
initialParams,
|
|
125
|
-
bottomTab: 'nested',
|
|
126
|
-
}}
|
|
127
|
-
options={{ ...getStackOptions() }}
|
|
128
|
-
/>
|
|
129
|
-
</Stack.Navigator>
|
|
130
|
-
</View>
|
|
131
|
-
</BottomTabInsetContext.Provider>
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return (
|
|
136
|
-
<BottomTabInsetContext.Provider value={tabInsetValue}>
|
|
137
|
-
<View style={[Styles.flex, tabInsetStyle]}>
|
|
138
|
-
<NavigationIndependentTree>
|
|
139
|
-
<NavigationContainer>
|
|
140
|
-
<Stack.Navigator screenOptions={headerStyleOptions}>
|
|
141
|
-
<Stack.Screen
|
|
142
|
-
name="Stack"
|
|
143
|
-
component={StackScreen}
|
|
144
|
-
initialParams={{
|
|
145
|
-
screen,
|
|
146
|
-
options: stackOptions,
|
|
147
|
-
initialParams,
|
|
148
|
-
bottomTab: 'default',
|
|
149
|
-
}}
|
|
150
|
-
options={{ ...getStackOptions(), ...options }}
|
|
151
|
-
/>
|
|
152
|
-
</Stack.Navigator>
|
|
153
|
-
</NavigationContainer>
|
|
154
|
-
</NavigationIndependentTree>
|
|
155
|
-
</View>
|
|
156
|
-
</BottomTabInsetContext.Provider>
|
|
157
|
-
);
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
export default TabScreen;
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { BoxShadowValue } from 'react-native';
|
|
2
|
-
import { Easing } from 'react-native-reanimated';
|
|
3
|
-
import { Colors, Radius, Spacing } from '../../Consts';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Navigation bar measurements (Figma "Specs Navigation", DS-984), in sync with momo-native-kits
|
|
7
|
-
* `TabBarMetrics`: the horizontal floating bar (center action in a notch) and the vertical
|
|
8
|
-
* iPhone Duo rail (center action under the container).
|
|
9
|
-
*/
|
|
10
|
-
const TabBarMetrics = {
|
|
11
|
-
height: 68,
|
|
12
|
-
margin: Spacing.S,
|
|
13
|
-
paddingVertical: Spacing.S,
|
|
14
|
-
paddingHorizontal: Spacing.M,
|
|
15
|
-
itemGap: Spacing.XS,
|
|
16
|
-
iconSize: 24,
|
|
17
|
-
// active indicator behind the icon: 24 icon + XS·M padding
|
|
18
|
-
indicatorPaddingVertical: Spacing.XS,
|
|
19
|
-
indicatorPaddingHorizontal: Spacing.M,
|
|
20
|
-
indicatorRadius: Radius.XL,
|
|
21
|
-
indicatorHeight: 32,
|
|
22
|
-
labelMaxScale: 1.2,
|
|
23
|
-
labelHeight: 18,
|
|
24
|
-
railLabelHeight: 14,
|
|
25
|
-
systemIndicatorHeight: 24,
|
|
26
|
-
foldableMinShortSide: 600,
|
|
27
|
-
foldableWidthRatio: 0.65,
|
|
28
|
-
ctaSlotWidth: 92,
|
|
29
|
-
ctaSize: 48,
|
|
30
|
-
ctaIconSize: 28,
|
|
31
|
-
ctaLift: 22,
|
|
32
|
-
ctaLabelGap: Spacing.M,
|
|
33
|
-
ctaLabelHeight: 18,
|
|
34
|
-
railContainerWidth: 56,
|
|
35
|
-
railPaddingHorizontal: Spacing.XS,
|
|
36
|
-
railPaddingBottom: Spacing.S,
|
|
37
|
-
railItemWidth: 48,
|
|
38
|
-
railItemHeight: 62,
|
|
39
|
-
railIndicatorHeight: 40,
|
|
40
|
-
railIndicatorPaddingVertical: Spacing.S,
|
|
41
|
-
railIndicatorRadius: 20,
|
|
42
|
-
railCtaGap: Spacing.L,
|
|
43
|
-
railCtaSize: 52,
|
|
44
|
-
railCtaLabelGap: Spacing.XS,
|
|
45
|
-
railCtaWidth: 68,
|
|
46
|
-
railCtaHeight: 70,
|
|
47
|
-
badgeMaxWidth: 58,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Navigation bar motion (MoMo Navigation Prototype): the active indicator slides to the
|
|
52
|
-
* selected item with a little overshoot, icon and label tints cross-fade, and the center
|
|
53
|
-
* action shrinks while pressed.
|
|
54
|
-
*/
|
|
55
|
-
const TabBarMotion = {
|
|
56
|
-
indicator: { duration: 550, easing: Easing.bezier(0.34, 1.4, 0.5, 1) },
|
|
57
|
-
tint: { duration: 250 },
|
|
58
|
-
ctaPress: { duration: 150 },
|
|
59
|
-
ctaPressedScale: 0.92,
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Figma Effect/Popover on the center action button: 8% y8 blur 24 spread -12, 4% y12 blur 32
|
|
64
|
-
* spread -16
|
|
65
|
-
*/
|
|
66
|
-
const CTA_SHADOW: BoxShadowValue[] = [
|
|
67
|
-
{
|
|
68
|
-
offsetX: 0,
|
|
69
|
-
offsetY: 8,
|
|
70
|
-
blurRadius: 24,
|
|
71
|
-
spreadDistance: -12,
|
|
72
|
-
color: `${Colors.black_20}14`,
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
offsetX: 0,
|
|
76
|
-
offsetY: 12,
|
|
77
|
-
blurRadius: 32,
|
|
78
|
-
spreadDistance: -16,
|
|
79
|
-
color: `${Colors.black_20}0A`,
|
|
80
|
-
},
|
|
81
|
-
];
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Inner light and tint of the active indicator: white 12% from below, primary 12% from above.
|
|
85
|
-
*/
|
|
86
|
-
const getIndicatorShadow = (primary: string): BoxShadowValue[] => [
|
|
87
|
-
{
|
|
88
|
-
offsetX: 0,
|
|
89
|
-
offsetY: -2,
|
|
90
|
-
blurRadius: 2,
|
|
91
|
-
color: `${Colors.black_01}1F`,
|
|
92
|
-
inset: true,
|
|
93
|
-
},
|
|
94
|
-
{ offsetX: 0, offsetY: 1, blurRadius: 2, color: `${primary}1F`, inset: true },
|
|
95
|
-
];
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Notch dipped into the container top edge under the center action (Figma "Backgroud" path):
|
|
99
|
-
* starts NOTCH_HALF_WIDTH left of the center, then cubic segments as [control1, control2, end],
|
|
100
|
-
* each point [dx from the center, dy below the top edge].
|
|
101
|
-
*/
|
|
102
|
-
const NOTCH_HALF_WIDTH = 50.758;
|
|
103
|
-
const NOTCH_CURVES: [number, number][][] = [
|
|
104
|
-
[
|
|
105
|
-
[-39.749, 0],
|
|
106
|
-
[-31.231, 9.765],
|
|
107
|
-
[-24.563, 18.526],
|
|
108
|
-
],
|
|
109
|
-
[
|
|
110
|
-
[-18.928, 25.93],
|
|
111
|
-
[-10.022, 30.709],
|
|
112
|
-
[0, 30.709],
|
|
113
|
-
],
|
|
114
|
-
[
|
|
115
|
-
[10.022, 30.709],
|
|
116
|
-
[18.928, 25.93],
|
|
117
|
-
[24.563, 18.526],
|
|
118
|
-
],
|
|
119
|
-
[
|
|
120
|
-
[31.231, 9.765],
|
|
121
|
-
[39.749, 0],
|
|
122
|
-
[NOTCH_HALF_WIDTH, 0],
|
|
123
|
-
],
|
|
124
|
-
];
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Width of the horizontal bar: 65% of the short side on an unfolded foldable, otherwise the
|
|
128
|
-
* window minus the side safe areas and margins.
|
|
129
|
-
*/
|
|
130
|
-
const getHorizontalBarWidth = (
|
|
131
|
-
width: number,
|
|
132
|
-
height: number,
|
|
133
|
-
insetLeft: number,
|
|
134
|
-
insetRight: number,
|
|
135
|
-
) => {
|
|
136
|
-
const shortSide = Math.min(width, height);
|
|
137
|
-
if (shortSide >= TabBarMetrics.foldableMinShortSide) {
|
|
138
|
-
return shortSide * TabBarMetrics.foldableWidthRatio;
|
|
139
|
-
}
|
|
140
|
-
return width - insetLeft - insetRight - 2 * TabBarMetrics.margin;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Height of the vertical rail container, plus the center action under it.
|
|
145
|
-
*/
|
|
146
|
-
const getRailHeight = (tabCount: number, hasCta: boolean) => {
|
|
147
|
-
const itemsHeight = tabCount * TabBarMetrics.railItemHeight;
|
|
148
|
-
let ctaHeight = 0;
|
|
149
|
-
if (hasCta) {
|
|
150
|
-
ctaHeight = TabBarMetrics.railCtaGap + TabBarMetrics.railCtaHeight;
|
|
151
|
-
}
|
|
152
|
-
return itemsHeight + TabBarMetrics.railPaddingBottom + ctaHeight;
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export {
|
|
156
|
-
TabBarMetrics,
|
|
157
|
-
TabBarMotion,
|
|
158
|
-
getHorizontalBarWidth,
|
|
159
|
-
getRailHeight,
|
|
160
|
-
getIndicatorShadow,
|
|
161
|
-
CTA_SHADOW,
|
|
162
|
-
NOTCH_CURVES,
|
|
163
|
-
NOTCH_HALF_WIDTH,
|
|
164
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { BottomTabBarProps } from '@react-navigation/bottom-tabs';
|
|
2
|
-
import { CommonActions, Route } from '@react-navigation/native';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Navigation items of the tab bar, with the press handlers of the system tab bar.
|
|
6
|
-
*/
|
|
7
|
-
const getTabItems = ({ state, descriptors, navigation }: BottomTabBarProps) => {
|
|
8
|
-
return state.routes.map((route: Route<string>, index: number) => {
|
|
9
|
-
const { options } = descriptors[route.key];
|
|
10
|
-
const focused = index === state.index;
|
|
11
|
-
const label = `${options.title ?? route.name}`;
|
|
12
|
-
|
|
13
|
-
const onPress = () => {
|
|
14
|
-
const event = navigation.emit({
|
|
15
|
-
type: 'tabPress',
|
|
16
|
-
target: route.key,
|
|
17
|
-
canPreventDefault: true,
|
|
18
|
-
});
|
|
19
|
-
if (!focused && !event.defaultPrevented) {
|
|
20
|
-
navigation.dispatch({
|
|
21
|
-
...CommonActions.navigate(route.name),
|
|
22
|
-
target: state.key,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const onLongPress = () => {
|
|
28
|
-
navigation.emit({ type: 'tabLongPress', target: route.key });
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
route,
|
|
33
|
-
focused,
|
|
34
|
-
label,
|
|
35
|
-
icon: options.tabBarIcon as any,
|
|
36
|
-
badge: options.tabBarBadge,
|
|
37
|
-
onPress,
|
|
38
|
-
onLongPress,
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
type TabItem = ReturnType<typeof getTabItems>[number];
|
|
44
|
-
|
|
45
|
-
export { getTabItems };
|
|
46
|
-
export type { TabItem };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useAnimatedStyle,
|
|
3
|
-
useReducedMotion,
|
|
4
|
-
useSharedValue,
|
|
5
|
-
withSpring,
|
|
6
|
-
} from 'react-native-reanimated';
|
|
7
|
-
|
|
8
|
-
const SPRING = { damping: 18, stiffness: 220, mass: 0.8 };
|
|
9
|
-
const PRESSED_SCALE = 1.1;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Press lift for a single button (e.g. the compressed rail): it scales up while held,
|
|
13
|
-
* unless the OS asks for reduced motion.
|
|
14
|
-
*/
|
|
15
|
-
const usePressLift = () => {
|
|
16
|
-
const reduceMotion = useReducedMotion();
|
|
17
|
-
const lift = useSharedValue(0);
|
|
18
|
-
const style = useAnimatedStyle(() => ({
|
|
19
|
-
transform: [{ scale: 1 + lift.value * (PRESSED_SCALE - 1) }],
|
|
20
|
-
}));
|
|
21
|
-
const onPressIn = () => {
|
|
22
|
-
if (!reduceMotion) {
|
|
23
|
-
lift.value = withSpring(1, SPRING);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const onPressOut = () => {
|
|
27
|
-
lift.value = withSpring(0, SPRING);
|
|
28
|
-
};
|
|
29
|
-
return { style, onPressIn, onPressOut };
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export { usePressLift };
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { Platform, StyleSheet } from 'react-native';
|
|
2
|
-
import { Colors, Spacing } from '../../Consts';
|
|
3
|
-
import { HeaderBarMetrics } from '../headerLayout';
|
|
4
|
-
|
|
5
|
-
const { buttonSize, pillWidth, pillHeight, sidePadding } = HeaderBarMetrics;
|
|
6
|
-
|
|
7
|
-
export const styles = StyleSheet.create({
|
|
8
|
-
navigationButton: {
|
|
9
|
-
height: buttonSize,
|
|
10
|
-
width: buttonSize,
|
|
11
|
-
borderRadius: buttonSize / 2,
|
|
12
|
-
justifyContent: 'center',
|
|
13
|
-
alignItems: 'center',
|
|
14
|
-
backgroundColor: Colors.black_01 + '99',
|
|
15
|
-
borderColor: Colors.black_20 + '33',
|
|
16
|
-
borderWidth: 0.2,
|
|
17
|
-
},
|
|
18
|
-
headerBackground: {
|
|
19
|
-
width: '100%',
|
|
20
|
-
height: undefined,
|
|
21
|
-
position: 'absolute',
|
|
22
|
-
aspectRatio: 375 / 154,
|
|
23
|
-
},
|
|
24
|
-
headerTitleContainer: {
|
|
25
|
-
alignItems: 'center',
|
|
26
|
-
justifyContent: 'center',
|
|
27
|
-
width: '70%',
|
|
28
|
-
},
|
|
29
|
-
circle: {
|
|
30
|
-
width: 32,
|
|
31
|
-
height: 32,
|
|
32
|
-
borderRadius: 16,
|
|
33
|
-
borderWidth: 0.5,
|
|
34
|
-
borderColor: Colors.black_04,
|
|
35
|
-
},
|
|
36
|
-
dotAvatar: {
|
|
37
|
-
position: 'absolute',
|
|
38
|
-
width: 12,
|
|
39
|
-
height: 12,
|
|
40
|
-
borderRadius: 6,
|
|
41
|
-
bottom: -2,
|
|
42
|
-
right: -2,
|
|
43
|
-
borderWidth: 2,
|
|
44
|
-
borderColor: Colors.black_01,
|
|
45
|
-
},
|
|
46
|
-
headerButton: { paddingHorizontal: 4 },
|
|
47
|
-
headerRightButton: {
|
|
48
|
-
flexDirection: 'row',
|
|
49
|
-
justifyContent: 'center',
|
|
50
|
-
alignItems: 'center',
|
|
51
|
-
paddingRight: sidePadding,
|
|
52
|
-
},
|
|
53
|
-
toolkitContainer: {
|
|
54
|
-
height: pillHeight,
|
|
55
|
-
borderRadius: pillHeight / 2,
|
|
56
|
-
justifyContent: 'center',
|
|
57
|
-
alignItems: 'center',
|
|
58
|
-
flexDirection: 'row',
|
|
59
|
-
backgroundColor: Colors.black_01 + '99',
|
|
60
|
-
borderColor: Colors.black_20 + '33',
|
|
61
|
-
borderWidth: 0.2,
|
|
62
|
-
marginLeft: Spacing.S,
|
|
63
|
-
},
|
|
64
|
-
toolkitButton: {
|
|
65
|
-
flex: 1,
|
|
66
|
-
height: '100%',
|
|
67
|
-
justifyContent: 'center',
|
|
68
|
-
alignItems: 'center',
|
|
69
|
-
},
|
|
70
|
-
divider: {
|
|
71
|
-
width: 0.5,
|
|
72
|
-
height: 12,
|
|
73
|
-
},
|
|
74
|
-
sideBarColumn: {
|
|
75
|
-
gap: Spacing.M,
|
|
76
|
-
},
|
|
77
|
-
headerLeft: {
|
|
78
|
-
marginLeft: 12,
|
|
79
|
-
},
|
|
80
|
-
badge: {
|
|
81
|
-
position: 'absolute',
|
|
82
|
-
top: -Spacing.S,
|
|
83
|
-
right: -6,
|
|
84
|
-
},
|
|
85
|
-
badgeDot: {
|
|
86
|
-
position: 'absolute',
|
|
87
|
-
top: -Spacing.XXS,
|
|
88
|
-
right: -Spacing.XXS,
|
|
89
|
-
},
|
|
90
|
-
badgeDotAnimation: {
|
|
91
|
-
position: 'absolute',
|
|
92
|
-
top: -Spacing.XS,
|
|
93
|
-
right: -Spacing.XS,
|
|
94
|
-
},
|
|
95
|
-
gradientContainer: {
|
|
96
|
-
width: '100%',
|
|
97
|
-
height: '100%',
|
|
98
|
-
position: 'absolute',
|
|
99
|
-
overflow: 'hidden',
|
|
100
|
-
},
|
|
101
|
-
extendedHeader: {
|
|
102
|
-
aspectRatio: 2.43,
|
|
103
|
-
position: 'absolute',
|
|
104
|
-
width: '100%',
|
|
105
|
-
},
|
|
106
|
-
verifiedDot: {
|
|
107
|
-
width: 4,
|
|
108
|
-
height: 4,
|
|
109
|
-
borderRadius: 2,
|
|
110
|
-
backgroundColor: Colors.green_03,
|
|
111
|
-
position: 'absolute',
|
|
112
|
-
alignSelf: 'center',
|
|
113
|
-
},
|
|
114
|
-
shadowHeader: {
|
|
115
|
-
...Platform.select({
|
|
116
|
-
ios: {
|
|
117
|
-
shadowColor: Colors.black_20,
|
|
118
|
-
shadowOffset: {
|
|
119
|
-
width: 3,
|
|
120
|
-
height: 3,
|
|
121
|
-
},
|
|
122
|
-
shadowOpacity: 0.12,
|
|
123
|
-
shadowRadius: 10,
|
|
124
|
-
},
|
|
125
|
-
android: {
|
|
126
|
-
shadowColor: Colors.black_17,
|
|
127
|
-
shadowOffset: {
|
|
128
|
-
width: 3,
|
|
129
|
-
height: 3,
|
|
130
|
-
},
|
|
131
|
-
shadowOpacity: 0.12,
|
|
132
|
-
shadowRadius: 10,
|
|
133
|
-
elevation: 10,
|
|
134
|
-
},
|
|
135
|
-
}),
|
|
136
|
-
},
|
|
137
|
-
onBoarding: {
|
|
138
|
-
marginRight: Spacing.M,
|
|
139
|
-
},
|
|
140
|
-
toolkitWide: {
|
|
141
|
-
width: pillWidth,
|
|
142
|
-
},
|
|
143
|
-
toolkitNarrow: {
|
|
144
|
-
width: buttonSize,
|
|
145
|
-
},
|
|
146
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
import { MiniAppContext } from '../../Context';
|
|
3
|
-
import { Spacing } from '../../Consts';
|
|
4
|
-
import { isWhiteListDesignSystem } from '../utils';
|
|
5
|
-
import { useScreenLayout } from '../../Layout';
|
|
6
|
-
import { HeaderBarMetrics } from '../headerLayout';
|
|
7
|
-
|
|
8
|
-
const { sidePadding, buttonSize, titleGap, clusterWidth } = HeaderBarMetrics;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Header title font: MoMoTrustDisplay for design-system whitelisted mini apps,
|
|
12
|
-
* SFProText otherwise.
|
|
13
|
-
*/
|
|
14
|
-
const useHeaderFontFamily = (): string => {
|
|
15
|
-
const context = useContext<any>(MiniAppContext);
|
|
16
|
-
return isWhiteListDesignSystem(context) ? 'MoMoTrustDisplay' : 'SFProText';
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* side paddings, back button, title gaps and right cluster sharing the
|
|
21
|
-
* navigation bar with the title
|
|
22
|
-
*/
|
|
23
|
-
const HEADER_ACTIONS_WIDTH =
|
|
24
|
-
sidePadding * 2 + buttonSize + titleGap * 2 + clusterWidth;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Max header title width. The iPhone Duo side bar takes back and toolkit out of
|
|
28
|
-
* the bar, so the title gets the content width; otherwise it shares the bar with
|
|
29
|
-
* them, minus the status bar clusters on the iPhone Duo inner portrait row.
|
|
30
|
-
*/
|
|
31
|
-
const useTitleMaxWidth = () => {
|
|
32
|
-
const layout = useScreenLayout();
|
|
33
|
-
const { width, contentWidth, sideBar, statusBarClearance } = layout;
|
|
34
|
-
let clearance = 0;
|
|
35
|
-
if (statusBarClearance) {
|
|
36
|
-
clearance = statusBarClearance.left + statusBarClearance.right;
|
|
37
|
-
}
|
|
38
|
-
if (sideBar) {
|
|
39
|
-
return contentWidth - Spacing.M * 2 - clearance;
|
|
40
|
-
}
|
|
41
|
-
return width - HEADER_ACTIONS_WIDTH - clearance;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export { useHeaderFontFamily, HEADER_ACTIONS_WIDTH, useTitleMaxWidth };
|