@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,187 +1,113 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import type { Route } from '@react-navigation/native';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {
|
|
4
|
+
type StyleProp,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
type TextStyle,
|
|
7
|
+
View,
|
|
8
|
+
type ViewStyle,
|
|
9
|
+
} from 'react-native';
|
|
8
10
|
|
|
9
|
-
import { Colors
|
|
10
|
-
import {
|
|
11
|
-
import { BadgeDot } from '../../Badge';
|
|
12
|
-
import { Text } from '../../Text';
|
|
13
|
-
import ScaleSizeProvider from '../ScaleSizeProvider';
|
|
14
|
-
import { TabBarMetrics, TabBarMotion } from './metrics';
|
|
11
|
+
import { Colors } from '../../Consts';
|
|
12
|
+
import { Badge, BadgeDot } from '../../Badge';
|
|
15
13
|
|
|
16
14
|
type Props = {
|
|
17
|
-
|
|
18
|
-
// '' shows a dot, anything else a label badge
|
|
15
|
+
route: Route<string>;
|
|
19
16
|
badge?: string | number;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
badgeStyle?: StyleProp<TextStyle> | any;
|
|
18
|
+
activeOpacity: number;
|
|
19
|
+
inactiveOpacity: number;
|
|
20
|
+
activeTintColor?: string;
|
|
21
|
+
inactiveTintColor?: string;
|
|
22
|
+
renderIcon: (props: {
|
|
25
23
|
focused: boolean;
|
|
26
24
|
color: string;
|
|
27
25
|
size: number;
|
|
28
26
|
}) => React.ReactNode;
|
|
27
|
+
allowFontScaling?: boolean;
|
|
28
|
+
style: StyleProp<ViewStyle>;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
32
|
+
* Icon sizes taken from Apple HIG
|
|
33
|
+
* https://developer.apple.com/design/human-interface-guidelines/tab-bars
|
|
34
34
|
*/
|
|
35
|
-
|
|
36
|
-
badgeLabel?: string | number,
|
|
37
|
-
showDot?: boolean,
|
|
38
|
-
) => {
|
|
39
|
-
if (badgeLabel === undefined || badgeLabel === null) {
|
|
40
|
-
return showDot ? '' : undefined;
|
|
41
|
-
}
|
|
42
|
-
const text = `${badgeLabel}`;
|
|
43
|
-
if (text === '') {
|
|
44
|
-
return '';
|
|
45
|
-
}
|
|
46
|
-
if (/^\d+$/.test(text)) {
|
|
47
|
-
const value = Number(text);
|
|
48
|
-
if (value === 0) {
|
|
49
|
-
return showDot ? '' : undefined;
|
|
50
|
-
}
|
|
51
|
-
return value > 99 ? '99+' : text;
|
|
52
|
-
}
|
|
53
|
-
return text;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Label badge of a tab: numbers use the error color, text the warning color (Figma Badge
|
|
58
|
-
* round numeric / text). The text keeps its design size to fit the 16 height.
|
|
59
|
-
*/
|
|
60
|
-
const TabBadge: React.FC<{ label: string; vertical?: boolean }> = ({
|
|
61
|
-
label,
|
|
62
|
-
vertical,
|
|
63
|
-
}) => {
|
|
64
|
-
const { theme } = useContext(ApplicationContext);
|
|
65
|
-
const isNumber = /^\d+\+?$/.test(label);
|
|
66
|
-
let backgroundColor = theme.colors.warning.primary;
|
|
67
|
-
if (isNumber) {
|
|
68
|
-
backgroundColor = theme.colors.error.primary;
|
|
69
|
-
}
|
|
70
|
-
const badge = (
|
|
71
|
-
<View
|
|
72
|
-
style={[
|
|
73
|
-
styles.badge,
|
|
74
|
-
{
|
|
75
|
-
backgroundColor,
|
|
76
|
-
borderColor: theme.colors.background.surface,
|
|
77
|
-
},
|
|
78
|
-
]}
|
|
79
|
-
>
|
|
80
|
-
<ScaleSizeProvider scaleSizeMaxRate={1}>
|
|
81
|
-
<Text
|
|
82
|
-
numberOfLines={1}
|
|
83
|
-
typography={'action_xxs_bold'}
|
|
84
|
-
color={Colors.black_01}
|
|
85
|
-
>
|
|
86
|
-
{label}
|
|
87
|
-
</Text>
|
|
88
|
-
</ScaleSizeProvider>
|
|
89
|
-
</View>
|
|
90
|
-
);
|
|
91
|
-
if (vertical) {
|
|
92
|
-
return <View style={styles.badgeCentered}>{badge}</View>;
|
|
93
|
-
}
|
|
94
|
-
return <View style={styles.badgeLeading}>{badge}</View>;
|
|
95
|
-
};
|
|
35
|
+
const ICON_SIZE_WIDE = 35;
|
|
96
36
|
|
|
97
|
-
/**
|
|
98
|
-
* Tab icon (24) with its badge; active and inactive icons are stacked and cross-fade on
|
|
99
|
-
* focus.
|
|
100
|
-
*/
|
|
101
37
|
export function TabBarIcon({
|
|
102
|
-
|
|
38
|
+
route: _,
|
|
103
39
|
badge,
|
|
104
|
-
|
|
40
|
+
badgeStyle,
|
|
41
|
+
activeOpacity,
|
|
42
|
+
inactiveOpacity,
|
|
105
43
|
activeTintColor,
|
|
106
44
|
inactiveTintColor,
|
|
107
45
|
renderIcon,
|
|
46
|
+
style,
|
|
108
47
|
}: Props) {
|
|
109
|
-
const
|
|
110
|
-
const progress = useSharedValue(focused ? 1 : 0);
|
|
111
|
-
|
|
112
|
-
useEffect(() => {
|
|
113
|
-
progress.value = withTiming(focused ? 1 : 0, TabBarMotion.tint);
|
|
114
|
-
}, [focused, progress]);
|
|
115
|
-
|
|
116
|
-
const activeStyle = useAnimatedStyle(() => ({ opacity: progress.value }));
|
|
117
|
-
const inactiveStyle = useAnimatedStyle(() => ({
|
|
118
|
-
opacity: 1 - progress.value,
|
|
119
|
-
}));
|
|
48
|
+
const iconSize = 25;
|
|
120
49
|
|
|
121
50
|
const renderBadge = () => {
|
|
122
|
-
if (badge
|
|
123
|
-
return
|
|
51
|
+
if (badge == null) {
|
|
52
|
+
return;
|
|
124
53
|
}
|
|
125
54
|
if (badge === '') {
|
|
126
|
-
return <BadgeDot size={'small'} style={styles.
|
|
55
|
+
return <BadgeDot size={'small'} style={[styles.badge, badgeStyle]} />;
|
|
127
56
|
}
|
|
128
|
-
return <
|
|
57
|
+
return <Badge style={[styles.badge, badgeStyle]} label={badge} />;
|
|
129
58
|
};
|
|
130
59
|
|
|
60
|
+
// We render the icon twice at the same position on top of each other:
|
|
61
|
+
// active and inactive one, so we can fade between them.
|
|
131
62
|
return (
|
|
132
|
-
<View style={styles.
|
|
133
|
-
<
|
|
134
|
-
{
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
63
|
+
<View style={[styles.wrapperUikit, style]}>
|
|
64
|
+
<View
|
|
65
|
+
style={[
|
|
66
|
+
styles.icon,
|
|
67
|
+
{
|
|
68
|
+
opacity: activeOpacity,
|
|
69
|
+
// Workaround for react-native >= 0.54 layout bug
|
|
70
|
+
minWidth: iconSize,
|
|
71
|
+
},
|
|
72
|
+
]}
|
|
73
|
+
>
|
|
74
|
+
{renderIcon({
|
|
75
|
+
focused: true,
|
|
76
|
+
size: iconSize,
|
|
77
|
+
color: activeTintColor ?? Colors.black_20,
|
|
78
|
+
})}
|
|
79
|
+
</View>
|
|
80
|
+
<View style={[styles.icon, { opacity: inactiveOpacity }]}>
|
|
81
|
+
{renderIcon({
|
|
82
|
+
focused: false,
|
|
83
|
+
size: iconSize,
|
|
84
|
+
color: inactiveTintColor ?? Colors.black_04,
|
|
85
|
+
})}
|
|
86
|
+
</View>
|
|
139
87
|
{renderBadge()}
|
|
140
88
|
</View>
|
|
141
89
|
);
|
|
142
90
|
}
|
|
143
91
|
|
|
144
|
-
const BADGE_HEIGHT = 16;
|
|
145
|
-
const BADGE_BORDER = 1;
|
|
146
|
-
|
|
147
92
|
const styles = StyleSheet.create({
|
|
148
93
|
icon: {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
94
|
+
// We render the icon twice at the same position on top of each other:
|
|
95
|
+
// active and inactive one, so we can fade between them:
|
|
96
|
+
// Cover the whole iconContainer:
|
|
97
|
+
position: 'absolute',
|
|
98
|
+
alignSelf: 'center',
|
|
154
99
|
alignItems: 'center',
|
|
155
100
|
justifyContent: 'center',
|
|
101
|
+
height: '100%',
|
|
102
|
+
width: '100%',
|
|
156
103
|
},
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
top: -Spacing.XXS,
|
|
161
|
-
},
|
|
162
|
-
badgeLeading: {
|
|
163
|
-
position: 'absolute',
|
|
164
|
-
left: Spacing.M,
|
|
165
|
-
top: -7,
|
|
166
|
-
width: TabBarMetrics.badgeMaxWidth,
|
|
167
|
-
alignItems: 'flex-start',
|
|
168
|
-
},
|
|
169
|
-
badgeCentered: {
|
|
170
|
-
position: 'absolute',
|
|
171
|
-
left: (TabBarMetrics.iconSize - TabBarMetrics.badgeMaxWidth) / 2,
|
|
172
|
-
top: -10,
|
|
173
|
-
width: TabBarMetrics.badgeMaxWidth,
|
|
174
|
-
alignItems: 'center',
|
|
104
|
+
wrapperUikit: {
|
|
105
|
+
width: ICON_SIZE_WIDE,
|
|
106
|
+
height: ICON_SIZE_WIDE,
|
|
175
107
|
},
|
|
176
108
|
badge: {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
// the border is drawn inside the 4 padding, like the Figma inside stroke
|
|
181
|
-
paddingHorizontal: Spacing.XS - BADGE_BORDER,
|
|
182
|
-
borderRadius: BADGE_HEIGHT / 2,
|
|
183
|
-
borderWidth: BADGE_BORDER,
|
|
184
|
-
alignItems: 'center',
|
|
185
|
-
justifyContent: 'center',
|
|
109
|
+
position: 'absolute',
|
|
110
|
+
end: -3,
|
|
111
|
+
top: -3,
|
|
186
112
|
},
|
|
187
113
|
});
|