@momo-kits/foundation 0.167.1-duotest.2 → 0.167.1
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 +14 -115
- package/Application/BottomTab/BottomTabBar.tsx +3 -6
- package/Application/BottomTab/index.tsx +135 -162
- package/Application/Components/HeaderExtendHeader.tsx +28 -75
- package/Application/Components/HeaderLeft.tsx +0 -38
- package/Application/Components/HeaderRight.tsx +9 -142
- package/Application/Components/HeaderTitle.tsx +7 -43
- package/Application/Components/SearchHeader.tsx +15 -22
- package/Application/ModalScreen.tsx +2 -16
- package/Application/NavigationContainer.tsx +38 -22
- package/Application/Navigator.ts +3 -1
- package/Application/StackScreen.tsx +9 -63
- package/Application/types.ts +1 -27
- package/Application/utils.tsx +6 -242
- package/Consts/theme.ts +4 -3
- package/Input/Input.tsx +4 -3
- package/Input/InputMoney.tsx +8 -5
- package/Input/InputPhoneNumber.tsx +4 -3
- package/Input/InputSearch.tsx +4 -3
- package/Input/InputTextArea.tsx +4 -3
- package/Layout/Card.tsx +26 -8
- package/Layout/FloatingButton.tsx +3 -3
- package/Layout/GridSystem.tsx +137 -0
- package/Layout/Item.tsx +10 -1
- package/Layout/Screen.tsx +52 -199
- package/Layout/Section.tsx +18 -5
- package/Layout/index.ts +4 -4
- package/Layout/styles.ts +0 -5
- package/Layout/utils.ts +5 -465
- package/Popup/PopupNotify.tsx +22 -33
- package/Popup/PopupPromotion.tsx +8 -20
- package/Text/utils.ts +2 -1
- package/package.json +2 -3
- package/Application/BottomTab/DuoBarCompression.tsx +0 -135
- package/Application/BottomTab/DuoTabBar.tsx +0 -462
- package/Application/Components/DuoGlassBackground.tsx +0 -179
- package/Application/Components/DuoQuickReturnHeader.tsx +0 -42
- package/Application/Components/OptionalGlassView.ts +0 -11
- package/Application/Components/OptionalScrollObserver.ts +0 -12
- package/Application/Components/SideBarButton.tsx +0 -139
- package/Application/device.ts +0 -29
- package/Layout/ReservedRegions.tsx +0 -47
- package/Popup/utils.ts +0 -32
|
@@ -6,9 +6,10 @@ import React, {
|
|
|
6
6
|
useState,
|
|
7
7
|
} from 'react';
|
|
8
8
|
import {
|
|
9
|
+
NativeSyntheticEvent,
|
|
9
10
|
StyleSheet,
|
|
10
11
|
TextInput,
|
|
11
|
-
|
|
12
|
+
TextInputFocusEventData,
|
|
12
13
|
TouchableOpacity,
|
|
13
14
|
View,
|
|
14
15
|
} from 'react-native';
|
|
@@ -92,12 +93,12 @@ const InputPhoneNumber = forwardRef(
|
|
|
92
93
|
onChangeText?.(text);
|
|
93
94
|
};
|
|
94
95
|
|
|
95
|
-
const _onFocus = (e:
|
|
96
|
+
const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
96
97
|
setFocused(true);
|
|
97
98
|
onFocus?.(e);
|
|
98
99
|
};
|
|
99
100
|
|
|
100
|
-
const _onBlur = (e:
|
|
101
|
+
const _onBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
101
102
|
setFocused(false);
|
|
102
103
|
onBlur?.(e);
|
|
103
104
|
};
|
package/Input/InputSearch.tsx
CHANGED
|
@@ -10,8 +10,9 @@ import React, {
|
|
|
10
10
|
useState,
|
|
11
11
|
} from 'react';
|
|
12
12
|
import {
|
|
13
|
+
NativeSyntheticEvent,
|
|
13
14
|
TextInput,
|
|
14
|
-
|
|
15
|
+
TextInputFocusEventData,
|
|
15
16
|
TouchableOpacity,
|
|
16
17
|
View,
|
|
17
18
|
} from 'react-native';
|
|
@@ -165,12 +166,12 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
|
|
|
165
166
|
props.accessibilityLabel,
|
|
166
167
|
);
|
|
167
168
|
|
|
168
|
-
const _onFocus = (e:
|
|
169
|
+
const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
169
170
|
setFocused(true);
|
|
170
171
|
onFocus?.(e);
|
|
171
172
|
};
|
|
172
173
|
|
|
173
|
-
const _onBlur = (e:
|
|
174
|
+
const _onBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
174
175
|
setFocused(false);
|
|
175
176
|
onBlur?.(e);
|
|
176
177
|
};
|
package/Input/InputTextArea.tsx
CHANGED
|
@@ -7,8 +7,9 @@ import React, {
|
|
|
7
7
|
useState,
|
|
8
8
|
} from 'react';
|
|
9
9
|
import {
|
|
10
|
+
NativeSyntheticEvent,
|
|
10
11
|
TextInput,
|
|
11
|
-
|
|
12
|
+
TextInputFocusEventData,
|
|
12
13
|
TouchableOpacity,
|
|
13
14
|
View,
|
|
14
15
|
} from 'react-native';
|
|
@@ -78,12 +79,12 @@ const InputTextArea = forwardRef(
|
|
|
78
79
|
setInputValue(text);
|
|
79
80
|
};
|
|
80
81
|
|
|
81
|
-
const _onFocus = (e:
|
|
82
|
+
const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
82
83
|
setFocused(true);
|
|
83
84
|
onFocus?.(e);
|
|
84
85
|
};
|
|
85
86
|
|
|
86
|
-
const _onBlur = (e:
|
|
87
|
+
const _onBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
87
88
|
setFocused(false);
|
|
88
89
|
onBlur?.(e);
|
|
89
90
|
};
|
package/Layout/Card.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
|
-
import { View, ViewProps } from 'react-native';
|
|
3
|
-
import { useGridSystem
|
|
2
|
+
import { Dimensions, View, ViewProps } from 'react-native';
|
|
3
|
+
import { useGridSystem } from './utils';
|
|
4
4
|
import { GridContextProps } from './types';
|
|
5
|
-
import { GridContext } from './index';
|
|
5
|
+
import { GridContext, GridSystem } from './index';
|
|
6
6
|
import { Image } from '../Image';
|
|
7
|
-
import { ApplicationContext } from '../Context';
|
|
7
|
+
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
8
8
|
import styles from './styles';
|
|
9
|
-
import { Radius, Shadow, Spacing } from '../Consts';
|
|
9
|
+
import { Colors, Radius, Shadow, Spacing } from '../Consts';
|
|
10
10
|
|
|
11
11
|
export interface CardProps extends ViewProps {
|
|
12
12
|
/**
|
|
@@ -27,13 +27,12 @@ const Card: React.FC<CardProps> = ({
|
|
|
27
27
|
useShadow = false,
|
|
28
28
|
...props
|
|
29
29
|
}) => {
|
|
30
|
-
const { theme } = useContext(ApplicationContext);
|
|
30
|
+
const { showGrid, theme } = useContext(ApplicationContext);
|
|
31
31
|
const { numberOfColumns } = useGridSystem();
|
|
32
|
-
const { contentWidth } = useScreenLayout();
|
|
33
32
|
|
|
34
33
|
const gutterSize = 8;
|
|
35
34
|
const margin = 12;
|
|
36
|
-
const widthSection =
|
|
35
|
+
const widthSection = Dimensions.get('window').width - margin * 2;
|
|
37
36
|
let sizePerSpan =
|
|
38
37
|
(widthSection - margin * 2 - gutterSize * (numberOfColumns - 1)) /
|
|
39
38
|
numberOfColumns -
|
|
@@ -48,6 +47,23 @@ const Card: React.FC<CardProps> = ({
|
|
|
48
47
|
},
|
|
49
48
|
};
|
|
50
49
|
|
|
50
|
+
/**
|
|
51
|
+
* render overlay only dev mode
|
|
52
|
+
*/
|
|
53
|
+
const renderOverlay = () => {
|
|
54
|
+
return (
|
|
55
|
+
<>
|
|
56
|
+
<GridSystem
|
|
57
|
+
width={widthSection}
|
|
58
|
+
gutterSize={Spacing.S}
|
|
59
|
+
screenGrid={false}
|
|
60
|
+
gridColor={Colors.red_01}
|
|
61
|
+
/>
|
|
62
|
+
<View pointerEvents={'none'} style={styles.boxGridCard} />
|
|
63
|
+
</>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
51
67
|
return (
|
|
52
68
|
<GridContext.Provider value={gridContext}>
|
|
53
69
|
<View
|
|
@@ -79,7 +95,9 @@ const Card: React.FC<CardProps> = ({
|
|
|
79
95
|
]}
|
|
80
96
|
/>
|
|
81
97
|
)}
|
|
98
|
+
{/* Render only allowed children as valid React elements */}
|
|
82
99
|
{children}
|
|
100
|
+
{showGrid && renderOverlay()}
|
|
83
101
|
</View>
|
|
84
102
|
</GridContext.Provider>
|
|
85
103
|
);
|
|
@@ -10,8 +10,8 @@ import Animated, {
|
|
|
10
10
|
useAnimatedStyle,
|
|
11
11
|
useSharedValue,
|
|
12
12
|
withTiming,
|
|
13
|
+
runOnJS,
|
|
13
14
|
} from 'react-native-reanimated';
|
|
14
|
-
import { scheduleOnRN } from 'react-native-worklets';
|
|
15
15
|
import { ApplicationContext } from '../Context';
|
|
16
16
|
import { Icon } from '../Icon';
|
|
17
17
|
import { useScaleSize, exportFontFamily } from '../Text';
|
|
@@ -78,7 +78,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
78
78
|
minWidth,
|
|
79
79
|
{ duration: 100 },
|
|
80
80
|
finished => {
|
|
81
|
-
if (finished)
|
|
81
|
+
if (finished) runOnJS(setShowText)(false);
|
|
82
82
|
},
|
|
83
83
|
);
|
|
84
84
|
} else {
|
|
@@ -87,7 +87,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
87
87
|
maxWidth.value,
|
|
88
88
|
{ duration: 100 },
|
|
89
89
|
finished => {
|
|
90
|
-
if (finished)
|
|
90
|
+
if (finished) runOnJS(setShowText)(true);
|
|
91
91
|
},
|
|
92
92
|
);
|
|
93
93
|
}
|
|
@@ -0,0 +1,137 @@
|
|
|
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;
|
package/Layout/Item.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
2
|
import { View, ViewProps } from 'react-native';
|
|
3
3
|
import { GridContext } from './index';
|
|
4
|
-
import { MiniAppContext } from '../Context';
|
|
4
|
+
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
5
5
|
import styles from './styles';
|
|
6
6
|
import { SpanNumber } from './types';
|
|
7
7
|
|
|
@@ -23,11 +23,19 @@ const Item: React.FC<ItemProps> = ({
|
|
|
23
23
|
children,
|
|
24
24
|
style,
|
|
25
25
|
}) => {
|
|
26
|
+
const { showGrid } = useContext(ApplicationContext);
|
|
26
27
|
const context = useContext<any>(MiniAppContext);
|
|
27
28
|
const grid = useContext(GridContext);
|
|
28
29
|
|
|
29
30
|
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
30
31
|
|
|
32
|
+
/**
|
|
33
|
+
* render overlay view only dev mode
|
|
34
|
+
*/
|
|
35
|
+
const renderOverlay = () => {
|
|
36
|
+
return <View pointerEvents={'none'} style={styles.boxGrid} />;
|
|
37
|
+
};
|
|
38
|
+
|
|
31
39
|
return (
|
|
32
40
|
<View
|
|
33
41
|
style={[
|
|
@@ -41,6 +49,7 @@ const Item: React.FC<ItemProps> = ({
|
|
|
41
49
|
]}
|
|
42
50
|
>
|
|
43
51
|
{children}
|
|
52
|
+
{showGrid && renderOverlay()}
|
|
44
53
|
</View>
|
|
45
54
|
);
|
|
46
55
|
};
|