@momo-kits/foundation 0.89.5 → 0.89.6-rc.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 +216 -0
- package/Application/BottomTab/BottomTabBar.tsx +278 -0
- package/Application/{BottomTab.tsx → BottomTab/index.tsx} +42 -18
- package/Application/Components.tsx +350 -86
- package/Application/Localize.ts +44 -0
- package/Application/ModalScreen.tsx +14 -185
- package/Application/Navigation.ts +5 -19
- package/Application/NavigationContainer.tsx +62 -72
- package/Application/Navigator.ts +53 -35
- package/Application/StackScreen.tsx +289 -32
- package/Application/index.ts +13 -15
- package/Application/types.ts +64 -35
- package/Application/utils.tsx +76 -30
- package/Assets/icon_bank.json +1 -1
- package/Badge/Badge.tsx +1 -1
- package/Badge/BadgeDotAnimation.tsx +95 -0
- package/Badge/index.tsx +2 -1
- package/Badge/styles.ts +50 -6
- package/Button/index.tsx +44 -26
- package/CheckBox/index.tsx +37 -26
- package/CheckBox/types.ts +5 -3
- package/Consts/colors+spacing+radius.ts +14 -0
- package/Icon/index.tsx +9 -8
- package/Icon/types.ts +2 -2
- package/IconButton/index.tsx +24 -14
- package/Image/index.tsx +23 -8
- package/Image/types.ts +2 -0
- package/Input/Input.tsx +116 -26
- package/Input/InputDropDown.tsx +66 -51
- package/Input/InputMoney.tsx +106 -15
- package/Input/InputOTP.tsx +49 -26
- package/Input/InputSearch.tsx +252 -99
- package/Input/InputTextArea.tsx +26 -6
- package/Input/TextTyping.tsx +113 -0
- package/Input/common.tsx +48 -22
- package/Input/index.tsx +112 -77
- package/Input/styles.ts +48 -11
- package/Input/utils.ts +1 -1
- package/Layout/Card.tsx +4 -3
- package/Layout/FloatingButton.tsx +168 -0
- package/Layout/GridSystem.tsx +1 -1
- package/Layout/ItemList.tsx +3 -2
- package/Layout/Screen.tsx +242 -121
- package/Layout/Section.tsx +4 -3
- package/Layout/styles.ts +11 -13
- package/Layout/types.ts +1 -1
- package/Layout/utils.ts +4 -4
- package/Loader/index.tsx +2 -0
- package/Pagination/PaginationScroll.tsx +2 -2
- package/Pagination/styles.ts +1 -1
- package/Popup/PopupNotify.tsx +56 -45
- package/Popup/PopupPromotion.tsx +5 -7
- package/Popup/types.ts +1 -7
- package/Radio/index.tsx +35 -20
- package/Radio/types.ts +5 -3
- package/Switch/index.tsx +32 -18
- package/Switch/types.ts +5 -3
- package/Tag/index.tsx +9 -2
- package/Tag/styles.ts +3 -2
- package/Tag/types.ts +12 -0
- package/Text/index.tsx +24 -5
- package/Text/styles.ts +8 -8
- package/Text/types.ts +19 -1
- package/Title/index.tsx +170 -103
- package/Title/styles.ts +36 -9
- package/Title/types.ts +16 -48
- package/code-scanner.js +125 -16
- package/index.ts +7 -0
- package/migrate_typo.js +56 -0
- package/package.json +11 -10
- package/publish.sh +16 -21
- package/tsconfig.json +1 -1
- package/verify.js +37 -40
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import {default as React, useContext, useEffect, useRef, useState} from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Animated,
|
|
4
|
+
LayoutChangeEvent,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
View,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import {ApplicationContext} from '../Application';
|
|
10
|
+
import {Icon} from '../Icon';
|
|
11
|
+
|
|
12
|
+
export interface FloatingButtonProps {
|
|
13
|
+
label?: string;
|
|
14
|
+
onPress?: () => void;
|
|
15
|
+
position?: 'center' | 'right';
|
|
16
|
+
icon?: string;
|
|
17
|
+
iconColor?: string;
|
|
18
|
+
size?: 'small' | 'large';
|
|
19
|
+
animatedValue?: Animated.Value;
|
|
20
|
+
bottom?: number;
|
|
21
|
+
renderComponent?: () => React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
25
|
+
renderComponent,
|
|
26
|
+
label = '',
|
|
27
|
+
onPress = () => {},
|
|
28
|
+
position = 'right',
|
|
29
|
+
icon = '',
|
|
30
|
+
iconColor = '',
|
|
31
|
+
size = 'small',
|
|
32
|
+
animatedValue,
|
|
33
|
+
bottom = 12,
|
|
34
|
+
}: FloatingButtonProps) => {
|
|
35
|
+
const {theme} = useContext(ApplicationContext);
|
|
36
|
+
const maxWidth = useRef(0);
|
|
37
|
+
const minWidth = size === 'small' ? 36 : 48;
|
|
38
|
+
const [opacityAnimated] = useState(new Animated.Value(0)); // Initial opacity set to 0
|
|
39
|
+
const [widthAnimated, setWidthAnimated] = useState<Animated.Value>();
|
|
40
|
+
const lastOffset = useRef(0);
|
|
41
|
+
const lastDirection = useRef<string>();
|
|
42
|
+
const [showText, setShowText] = React.useState(true);
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!label) return;
|
|
46
|
+
|
|
47
|
+
Animated.timing(opacityAnimated, {
|
|
48
|
+
toValue: 1,
|
|
49
|
+
duration: 100,
|
|
50
|
+
useNativeDriver: true,
|
|
51
|
+
}).start();
|
|
52
|
+
|
|
53
|
+
const listener = animatedValue?.addListener(({value}) => {
|
|
54
|
+
if (value !== lastOffset.current && value > 0) {
|
|
55
|
+
const direction = value > lastOffset.current ? 'down' : 'up';
|
|
56
|
+
lastOffset.current = value;
|
|
57
|
+
if (lastDirection.current !== direction) {
|
|
58
|
+
lastDirection.current = direction;
|
|
59
|
+
if (direction === 'down') {
|
|
60
|
+
Animated.timing(opacityAnimated, {
|
|
61
|
+
toValue: 0,
|
|
62
|
+
duration: 100,
|
|
63
|
+
useNativeDriver: true,
|
|
64
|
+
}).start();
|
|
65
|
+
Animated.timing(widthAnimated!, {
|
|
66
|
+
toValue: minWidth,
|
|
67
|
+
duration: 100,
|
|
68
|
+
useNativeDriver: false,
|
|
69
|
+
}).start(() => setShowText(false));
|
|
70
|
+
} else {
|
|
71
|
+
Animated.timing(opacityAnimated, {
|
|
72
|
+
toValue: 1,
|
|
73
|
+
duration: 100,
|
|
74
|
+
useNativeDriver: true,
|
|
75
|
+
}).start();
|
|
76
|
+
Animated.timing(widthAnimated!, {
|
|
77
|
+
toValue: maxWidth.current,
|
|
78
|
+
duration: 100,
|
|
79
|
+
useNativeDriver: false,
|
|
80
|
+
}).start(() => setShowText(true));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
return () => {
|
|
87
|
+
if (listener) {
|
|
88
|
+
animatedValue?.removeListener(listener);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}, [label, widthAnimated]);
|
|
92
|
+
|
|
93
|
+
const handleLayout = (event: LayoutChangeEvent) => {
|
|
94
|
+
const layout = event.nativeEvent.layout;
|
|
95
|
+
if (widthAnimated) return;
|
|
96
|
+
maxWidth.current = layout.width;
|
|
97
|
+
setWidthAnimated(new Animated.Value(layout.width));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
if (renderComponent) {
|
|
101
|
+
return (
|
|
102
|
+
<View
|
|
103
|
+
onLayout={handleLayout}
|
|
104
|
+
style={[
|
|
105
|
+
styles.container,
|
|
106
|
+
{
|
|
107
|
+
right: position === 'right' ? 12 : undefined,
|
|
108
|
+
alignSelf: position === 'center' ? 'center' : 'flex-end',
|
|
109
|
+
bottom,
|
|
110
|
+
},
|
|
111
|
+
]}>
|
|
112
|
+
{renderComponent()}
|
|
113
|
+
</View>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<Animated.View
|
|
119
|
+
onLayout={handleLayout}
|
|
120
|
+
style={[
|
|
121
|
+
styles.container,
|
|
122
|
+
{
|
|
123
|
+
right: position === 'right' ? 12 : undefined,
|
|
124
|
+
alignSelf: position === 'center' ? 'center' : 'flex-end',
|
|
125
|
+
width: widthAnimated,
|
|
126
|
+
height: size === 'small' ? 36 : 48,
|
|
127
|
+
backgroundColor: theme.colors.primary,
|
|
128
|
+
bottom,
|
|
129
|
+
},
|
|
130
|
+
]}>
|
|
131
|
+
<TouchableOpacity
|
|
132
|
+
style={{flexDirection: 'row', alignItems: 'center'}}
|
|
133
|
+
onPress={onPress}>
|
|
134
|
+
<Icon
|
|
135
|
+
source={icon}
|
|
136
|
+
size={size === 'small' ? 12 : 24}
|
|
137
|
+
color={iconColor}
|
|
138
|
+
/>
|
|
139
|
+
{showText && !!label && (
|
|
140
|
+
<Animated.Text
|
|
141
|
+
style={[styles.label, {opacity: opacityAnimated, color: 'white'}]}
|
|
142
|
+
numberOfLines={1}>
|
|
143
|
+
{label}
|
|
144
|
+
</Animated.Text>
|
|
145
|
+
)}
|
|
146
|
+
</TouchableOpacity>
|
|
147
|
+
</Animated.View>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const styles = StyleSheet.create({
|
|
152
|
+
container: {
|
|
153
|
+
flexDirection: 'row',
|
|
154
|
+
alignContent: 'center',
|
|
155
|
+
alignItems: 'center',
|
|
156
|
+
position: 'absolute',
|
|
157
|
+
borderRadius: 100,
|
|
158
|
+
paddingHorizontal: 12,
|
|
159
|
+
flexWrap: 'wrap',
|
|
160
|
+
alignSelf: 'flex-end',
|
|
161
|
+
},
|
|
162
|
+
label: {
|
|
163
|
+
marginLeft: 8,
|
|
164
|
+
fontSize: 16,
|
|
165
|
+
lineHeight: 22,
|
|
166
|
+
fontWeight: '700',
|
|
167
|
+
},
|
|
168
|
+
});
|
package/Layout/GridSystem.tsx
CHANGED
|
@@ -53,7 +53,7 @@ const GridSystem: React.FC<any> = ({
|
|
|
53
53
|
{list.map((_, index) => {
|
|
54
54
|
return (
|
|
55
55
|
<View style={{flexDirection: 'row'}} key={index.toString()}>
|
|
56
|
-
{index
|
|
56
|
+
{index !== 0 && <View style={{width: grid.gutterSize}} />}
|
|
57
57
|
<View
|
|
58
58
|
key={`Grid${index.toString()}`}
|
|
59
59
|
pointerEvents="none"
|
package/Layout/ItemList.tsx
CHANGED
|
@@ -20,7 +20,7 @@ const ItemList = forwardRef(
|
|
|
20
20
|
contentContainerStyle,
|
|
21
21
|
...props
|
|
22
22
|
}: ItemListProps,
|
|
23
|
-
ref
|
|
23
|
+
ref
|
|
24
24
|
) => {
|
|
25
25
|
const {gutterSize, numberOfColumns} = useContext(GridContext);
|
|
26
26
|
const widthItem = (widthSpan ?? numberOfColumns) as SpanNumber;
|
|
@@ -41,6 +41,7 @@ const ItemList = forwardRef(
|
|
|
41
41
|
<FlatList
|
|
42
42
|
ref={ref as React.RefObject<FlatList>}
|
|
43
43
|
{...props}
|
|
44
|
+
key={`ItemList-${numColumns}`}
|
|
44
45
|
numColumns={numColumns}
|
|
45
46
|
renderItem={_renderItem}
|
|
46
47
|
horizontal={false}
|
|
@@ -49,7 +50,7 @@ const ItemList = forwardRef(
|
|
|
49
50
|
contentContainerStyle={[contentContainerStyle, styles.protectedStyle]}
|
|
50
51
|
/>
|
|
51
52
|
);
|
|
52
|
-
}
|
|
53
|
+
}
|
|
53
54
|
);
|
|
54
55
|
|
|
55
56
|
export default ItemList;
|