@momo-kits/foundation 0.167.2-beta.1 → 0.168.1-beta.2
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 +113 -14
- package/Application/BottomTab/BottomTabBar.tsx +6 -3
- package/Application/BottomTab/CustomBottomTabItem.tsx +3 -5
- package/Application/BottomTab/DuoBarCompression.tsx +135 -0
- package/Application/BottomTab/DuoTabBar.tsx +537 -0
- package/Application/BottomTab/index.tsx +145 -134
- package/Application/Components/DuoGlassBackground.tsx +158 -0
- package/Application/Components/DuoQuickReturnHeader.tsx +42 -0
- package/Application/Components/HeaderAnimated.tsx +9 -3
- package/Application/Components/HeaderExtendHeader.tsx +70 -28
- package/Application/Components/HeaderLeft.tsx +38 -0
- package/Application/Components/HeaderRight.tsx +144 -9
- package/Application/Components/HeaderTitle.tsx +43 -7
- package/Application/Components/SearchHeader.tsx +20 -15
- package/Application/Components/SideBarButton.tsx +134 -0
- package/Application/ModalScreen.tsx +16 -2
- package/Application/NavigationContainer.tsx +22 -38
- package/Application/Navigator.ts +1 -3
- package/Application/StackScreen.tsx +2 -5
- package/Application/device.ts +29 -0
- package/Application/types.ts +10 -1
- package/Application/utils.tsx +10 -7
- package/Badge/Badge.tsx +2 -3
- package/Badge/BadgeDotAnimation.tsx +3 -3
- package/Button/index.tsx +11 -11
- package/Consts/theme.ts +3 -4
- package/Input/Input.tsx +3 -4
- package/Input/InputMoney.tsx +22 -45
- package/Input/InputOTP.tsx +9 -12
- package/Input/InputPhoneNumber.tsx +3 -4
- package/Input/InputSearch.tsx +17 -14
- package/Input/InputTextArea.tsx +3 -4
- package/Input/SystemTextInput.tsx +2 -3
- package/Input/TextTyping.tsx +11 -6
- package/Input/utils.ts +2 -3
- package/Layout/Card.tsx +8 -26
- package/Layout/FloatingButton.tsx +3 -3
- package/Layout/Item.tsx +1 -10
- package/Layout/ReservedRegions.tsx +78 -0
- package/Layout/Screen.tsx +242 -48
- package/Layout/Section.tsx +5 -18
- package/Layout/index.ts +4 -4
- package/Layout/styles.ts +5 -0
- package/Layout/utils.ts +477 -5
- package/Pagination/Dot.tsx +3 -6
- package/Popup/PopupNotify.tsx +33 -22
- package/Popup/PopupPromotion.tsx +21 -8
- package/Popup/utils.ts +32 -0
- package/Radio/index.tsx +2 -3
- package/Text/utils.ts +1 -2
- package/Title/index.tsx +8 -11
- package/package.json +5 -2
- package/Layout/GridSystem.tsx +0 -137
package/Popup/utils.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Dimensions, useWindowDimensions } from 'react-native';
|
|
2
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
3
|
+
import { Spacing } from '../Consts';
|
|
4
|
+
import { getDuoTopInset, isIPhoneDuo } from '../Application/device';
|
|
5
|
+
|
|
6
|
+
// width of a system alert on the iPhone Duo inner display, in both orientations
|
|
7
|
+
const DUO_POPUP_MAX_WIDTH = 440;
|
|
8
|
+
|
|
9
|
+
const usePopupWidth = () => {
|
|
10
|
+
const windowSize = useWindowDimensions();
|
|
11
|
+
if (!isIPhoneDuo()) {
|
|
12
|
+
return Dimensions.get('window').width - Spacing.XL * 2;
|
|
13
|
+
}
|
|
14
|
+
return Math.min(windowSize.width - Spacing.XL * 2, DUO_POPUP_MAX_WIDTH);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// room left for a popup on iPhone Duo, where landscape is too short for it
|
|
18
|
+
const usePopupMaxHeight = () => {
|
|
19
|
+
const insets = useSafeAreaInsets();
|
|
20
|
+
const { width, height } = useWindowDimensions();
|
|
21
|
+
if (!isIPhoneDuo()) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
return (
|
|
25
|
+
height -
|
|
26
|
+
getDuoTopInset(insets, width, height) -
|
|
27
|
+
insets.bottom -
|
|
28
|
+
Spacing.XL * 2
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { usePopupWidth, usePopupMaxHeight };
|
package/Radio/index.tsx
CHANGED
|
@@ -47,10 +47,9 @@ const Radio: FC<RadioProps> = ({
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
if (disabled) {
|
|
50
|
+
const { background, text } = theme.colors;
|
|
50
51
|
disabledStyle = {
|
|
51
|
-
borderColor: selected
|
|
52
|
-
? theme.colors.background.tonal
|
|
53
|
-
: theme.colors.text.disable,
|
|
52
|
+
borderColor: selected ? background.tonal : text.disable,
|
|
54
53
|
};
|
|
55
54
|
}
|
|
56
55
|
|
package/Text/utils.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { Dimensions, PixelRatio, useWindowDimensions } from 'react-native';
|
|
|
2
2
|
import { useContext } from 'react';
|
|
3
3
|
import { MiniAppContext } from '../Context';
|
|
4
4
|
|
|
5
|
-
const deviceWidth = Dimensions.get('window').width;
|
|
6
5
|
const DEFAULT_SCREEN_SIZE = 375;
|
|
7
6
|
const MAX_FONT_SCALE = 1.5;
|
|
8
7
|
const MAX_DEVICE_SCALE = 5;
|
|
@@ -40,7 +39,7 @@ const useScaleSize = (size: number, scaleRate?: number) => {
|
|
|
40
39
|
|
|
41
40
|
const scaleSize = (size: number) => {
|
|
42
41
|
const fontScale = PixelRatio.getFontScale();
|
|
43
|
-
const deviceScale =
|
|
42
|
+
const deviceScale = Dimensions.get('window').width / DEFAULT_SCREEN_SIZE;
|
|
44
43
|
|
|
45
44
|
let fontSizeDeviceScale = size;
|
|
46
45
|
let fontSizeOSScale = size;
|
package/Title/index.tsx
CHANGED
|
@@ -78,8 +78,10 @@ const Title: FC<TitleProps> = ({
|
|
|
78
78
|
const titleFontFamily = exportFontFamily('bold');
|
|
79
79
|
const isSection = type === 'section';
|
|
80
80
|
const numberOfLines = showTrailingAction || !!badgeLabel ? 1 : 2;
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
let buttonTypo: Typography = 'action_s_bold';
|
|
82
|
+
if (buttonSize === 'small') {
|
|
83
|
+
buttonTypo = 'action_xs_bold';
|
|
84
|
+
}
|
|
83
85
|
const flexStyle: ViewStyle = showTrailingAction ? { maxWidth: '95%' } : {};
|
|
84
86
|
const componentName = 'Title';
|
|
85
87
|
|
|
@@ -114,6 +116,7 @@ const Title: FC<TitleProps> = ({
|
|
|
114
116
|
};
|
|
115
117
|
|
|
116
118
|
const renderContent = () => {
|
|
119
|
+
const maxWidth = contentWidth > 0 ? contentWidth - badgeWidth : undefined;
|
|
117
120
|
return (
|
|
118
121
|
<View style={styles.contentView}>
|
|
119
122
|
<View
|
|
@@ -132,10 +135,7 @@ const Title: FC<TitleProps> = ({
|
|
|
132
135
|
styleSheet[typography],
|
|
133
136
|
{ fontFamily: titleFontFamily },
|
|
134
137
|
styles.title,
|
|
135
|
-
{
|
|
136
|
-
maxWidth:
|
|
137
|
-
contentWidth > 0 ? contentWidth - badgeWidth : undefined,
|
|
138
|
-
},
|
|
138
|
+
{ maxWidth },
|
|
139
139
|
]}
|
|
140
140
|
>
|
|
141
141
|
{title}
|
|
@@ -175,6 +175,7 @@ const Title: FC<TitleProps> = ({
|
|
|
175
175
|
};
|
|
176
176
|
|
|
177
177
|
const renderActionLeft = () => {
|
|
178
|
+
const iconAlpha = isSection ? '99' : '4D';
|
|
178
179
|
return (
|
|
179
180
|
<TouchableOpacity
|
|
180
181
|
accessibilityLabel={componentId + '|trailing-touch'}
|
|
@@ -186,11 +187,7 @@ const Title: FC<TitleProps> = ({
|
|
|
186
187
|
<View
|
|
187
188
|
style={[
|
|
188
189
|
styles.iconLeft,
|
|
189
|
-
{
|
|
190
|
-
backgroundColor: isSection
|
|
191
|
-
? Colors.black_06 + '99'
|
|
192
|
-
: Colors.black_06 + '4D',
|
|
193
|
-
},
|
|
190
|
+
{ backgroundColor: Colors.black_06 + iconAlpha },
|
|
194
191
|
]}
|
|
195
192
|
>
|
|
196
193
|
<Icon
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.168.1-beta.2",
|
|
4
4
|
"description": "React Native Component Kits",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {},
|
|
@@ -18,12 +18,15 @@
|
|
|
18
18
|
"react-native-gesture-handler": "2.27.1",
|
|
19
19
|
"react-native-linear-gradient": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-linear-gradient#v3.0.0",
|
|
20
20
|
"react-native-reanimated": "4.2.2",
|
|
21
|
+
"react-native-worklets": "0.6.1",
|
|
21
22
|
"react-native-safe-area-context": "5.5.2",
|
|
23
|
+
"react-native-reserved-regions": "0.2.0",
|
|
22
24
|
"@shopify/flash-list": "2.1.0",
|
|
23
25
|
"lottie-react-native": "7.2.4"
|
|
24
26
|
},
|
|
25
27
|
"peerDependencies": {
|
|
26
|
-
"react-native": "*"
|
|
28
|
+
"react-native": "*",
|
|
29
|
+
"react-native-worklets": "0.6.1"
|
|
27
30
|
},
|
|
28
31
|
"devDependencies": {
|
|
29
32
|
"@types/color": "3.0.6"
|
package/Layout/GridSystem.tsx
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
3
|
-
import { Dimensions, StyleSheet, View } from 'react-native';
|
|
4
|
-
import { ApplicationContext } from '../Context';
|
|
5
|
-
import { Colors, Spacing } from '../Consts';
|
|
6
|
-
import { GridContextProps } from './types';
|
|
7
|
-
import { useGridSystem } from './utils';
|
|
8
|
-
|
|
9
|
-
const GridSystem: React.FC<any> = ({
|
|
10
|
-
width = Dimensions.get('window').width,
|
|
11
|
-
useMargin = true,
|
|
12
|
-
gutterSize = Spacing.M,
|
|
13
|
-
screenGrid = true,
|
|
14
|
-
gridColor = Colors.blue_07,
|
|
15
|
-
}) => {
|
|
16
|
-
const { theme } = useContext(ApplicationContext);
|
|
17
|
-
const { numberOfColumns } = useGridSystem();
|
|
18
|
-
|
|
19
|
-
const margin = useMargin ? Spacing.M : 0;
|
|
20
|
-
const widthSection = width - margin * 2;
|
|
21
|
-
const totalGutterSize = gutterSize * (numberOfColumns - 1);
|
|
22
|
-
const sizePerSpan = (widthSection - totalGutterSize) / numberOfColumns;
|
|
23
|
-
|
|
24
|
-
const grid: GridContextProps = {
|
|
25
|
-
numberOfColumns,
|
|
26
|
-
gutterSize,
|
|
27
|
-
sizePerSpan,
|
|
28
|
-
getSizeSpan: span => {
|
|
29
|
-
return span * sizePerSpan + (span - 1) * gutterSize;
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
const insets = useSafeAreaInsets();
|
|
33
|
-
|
|
34
|
-
const list: number[] = [];
|
|
35
|
-
for (let i = 1; i <= grid.numberOfColumns; i++) {
|
|
36
|
-
list.push(i);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<>
|
|
41
|
-
<View
|
|
42
|
-
pointerEvents="none"
|
|
43
|
-
style={[
|
|
44
|
-
styles.gridContainer,
|
|
45
|
-
screenGrid && insets,
|
|
46
|
-
{
|
|
47
|
-
borderColor: theme.colors.error.primary,
|
|
48
|
-
marginHorizontal: margin,
|
|
49
|
-
top: Spacing.M,
|
|
50
|
-
bottom: Spacing.M,
|
|
51
|
-
},
|
|
52
|
-
]}
|
|
53
|
-
>
|
|
54
|
-
{list.map((_, index) => {
|
|
55
|
-
return (
|
|
56
|
-
<View style={{ flexDirection: 'row' }} key={index.toString()}>
|
|
57
|
-
{index !== 0 && <View style={{ width: grid.gutterSize }} />}
|
|
58
|
-
<View
|
|
59
|
-
key={`Grid${index.toString()}`}
|
|
60
|
-
pointerEvents="none"
|
|
61
|
-
style={[
|
|
62
|
-
styles.gridColumn,
|
|
63
|
-
{
|
|
64
|
-
width: grid.sizePerSpan,
|
|
65
|
-
backgroundColor: gridColor,
|
|
66
|
-
},
|
|
67
|
-
]}
|
|
68
|
-
/>
|
|
69
|
-
</View>
|
|
70
|
-
);
|
|
71
|
-
})}
|
|
72
|
-
</View>
|
|
73
|
-
{screenGrid && (
|
|
74
|
-
<>
|
|
75
|
-
<View pointerEvents="none" style={styles.dangerLeftContainer} />
|
|
76
|
-
<View pointerEvents="none" style={styles.dangerRightContainer} />
|
|
77
|
-
<View
|
|
78
|
-
pointerEvents="none"
|
|
79
|
-
style={[styles.dangerTopContainer, { height: Spacing.M }]}
|
|
80
|
-
/>
|
|
81
|
-
<View
|
|
82
|
-
pointerEvents="none"
|
|
83
|
-
style={[styles.dangerBottomContainer, { height: insets.bottom }]}
|
|
84
|
-
/>
|
|
85
|
-
</>
|
|
86
|
-
)}
|
|
87
|
-
</>
|
|
88
|
-
);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const styles = StyleSheet.create({
|
|
92
|
-
gridContainer: {
|
|
93
|
-
position: 'absolute',
|
|
94
|
-
top: 0,
|
|
95
|
-
bottom: 0,
|
|
96
|
-
left: 0,
|
|
97
|
-
right: 0,
|
|
98
|
-
flexDirection: 'row',
|
|
99
|
-
borderWidth: 1,
|
|
100
|
-
},
|
|
101
|
-
gridColumn: {
|
|
102
|
-
height: '100%',
|
|
103
|
-
opacity: 0.2,
|
|
104
|
-
},
|
|
105
|
-
dangerTopContainer: {
|
|
106
|
-
opacity: 0.2,
|
|
107
|
-
backgroundColor: Colors.red_03,
|
|
108
|
-
width: '100%',
|
|
109
|
-
top: 0,
|
|
110
|
-
position: 'absolute',
|
|
111
|
-
},
|
|
112
|
-
dangerBottomContainer: {
|
|
113
|
-
opacity: 0.2,
|
|
114
|
-
backgroundColor: Colors.red_03,
|
|
115
|
-
width: '100%',
|
|
116
|
-
bottom: 0,
|
|
117
|
-
position: 'absolute',
|
|
118
|
-
},
|
|
119
|
-
dangerLeftContainer: {
|
|
120
|
-
opacity: 0.2,
|
|
121
|
-
backgroundColor: Colors.red_03,
|
|
122
|
-
width: Spacing.M,
|
|
123
|
-
height: '100%',
|
|
124
|
-
left: 0,
|
|
125
|
-
position: 'absolute',
|
|
126
|
-
},
|
|
127
|
-
dangerRightContainer: {
|
|
128
|
-
opacity: 0.2,
|
|
129
|
-
backgroundColor: Colors.red_03,
|
|
130
|
-
width: Spacing.M,
|
|
131
|
-
height: '100%',
|
|
132
|
-
right: 0,
|
|
133
|
-
position: 'absolute',
|
|
134
|
-
},
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
export default GridSystem;
|