@momo-kits/foundation 0.81.51-beta.0 → 0.81.52

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.
Files changed (71) hide show
  1. package/Application/{BottomTab/index.tsx → BottomTab.tsx} +18 -42
  2. package/Application/Components.tsx +91 -356
  3. package/Application/ModalScreen.tsx +185 -14
  4. package/Application/Navigation.ts +19 -5
  5. package/Application/NavigationContainer.tsx +72 -62
  6. package/Application/Navigator.ts +48 -154
  7. package/Application/StackScreen.tsx +32 -289
  8. package/Application/index.ts +15 -13
  9. package/Application/types.ts +35 -81
  10. package/Application/utils.tsx +30 -76
  11. package/Assets/icon_bank.json +1 -1
  12. package/Badge/Badge.tsx +1 -1
  13. package/Badge/index.tsx +1 -2
  14. package/Badge/styles.ts +6 -50
  15. package/Button/index.tsx +26 -44
  16. package/CheckBox/index.tsx +26 -37
  17. package/CheckBox/types.ts +3 -5
  18. package/Consts/colors+spacing+radius.ts +0 -14
  19. package/Icon/index.tsx +8 -9
  20. package/Icon/types.ts +2 -2
  21. package/IconButton/index.tsx +14 -24
  22. package/Image/index.tsx +8 -23
  23. package/Image/types.ts +0 -2
  24. package/Input/Input.tsx +26 -116
  25. package/Input/InputDropDown.tsx +51 -66
  26. package/Input/InputMoney.tsx +15 -106
  27. package/Input/InputOTP.tsx +26 -49
  28. package/Input/InputSearch.tsx +99 -252
  29. package/Input/InputTextArea.tsx +6 -26
  30. package/Input/common.tsx +22 -48
  31. package/Input/index.tsx +77 -112
  32. package/Input/styles.ts +11 -48
  33. package/Input/utils.ts +1 -1
  34. package/Layout/Card.tsx +3 -4
  35. package/Layout/GridSystem.tsx +1 -1
  36. package/Layout/ItemList.tsx +2 -3
  37. package/Layout/Screen.tsx +121 -242
  38. package/Layout/Section.tsx +3 -4
  39. package/Layout/styles.ts +13 -11
  40. package/Layout/types.ts +1 -1
  41. package/Layout/utils.ts +4 -4
  42. package/Loader/index.tsx +0 -2
  43. package/Pagination/PaginationScroll.tsx +2 -2
  44. package/Pagination/styles.ts +1 -1
  45. package/Popup/PopupNotify.tsx +46 -57
  46. package/Popup/PopupPromotion.tsx +8 -6
  47. package/Popup/types.ts +7 -1
  48. package/Radio/index.tsx +20 -35
  49. package/Radio/types.ts +3 -5
  50. package/Switch/index.tsx +18 -32
  51. package/Switch/types.ts +3 -5
  52. package/Tag/index.tsx +2 -9
  53. package/Tag/styles.ts +2 -3
  54. package/Tag/types.ts +0 -12
  55. package/Text/index.tsx +5 -24
  56. package/Text/styles.ts +8 -8
  57. package/Title/index.tsx +103 -170
  58. package/Title/styles.ts +9 -36
  59. package/Title/types.ts +48 -16
  60. package/code-scanner.js +16 -125
  61. package/index.ts +0 -7
  62. package/package.json +7 -8
  63. package/publish.sh +21 -16
  64. package/tsconfig.json +1 -1
  65. package/Application/BottomSheet.tsx +0 -216
  66. package/Application/BottomTab/BottomTabBar.tsx +0 -278
  67. package/Application/Localize.ts +0 -44
  68. package/Application/constants.ts +0 -9
  69. package/Badge/BadgeDotAnimation.tsx +0 -95
  70. package/Input/TextTyping.tsx +0 -113
  71. package/Layout/FloatingButton.tsx +0 -168
@@ -1,113 +0,0 @@
1
- import React, {FC, memo, useEffect, useRef} from 'react';
2
- import {Platform, StyleSheet, TextInput, TextStyle} from 'react-native';
3
- import {Colors} from '../Consts';
4
- import {scaleSize} from '../Text';
5
-
6
- export interface TextTypingProps {
7
- data: string[];
8
- timeDelayEnd?: number;
9
- timeDelayNextChar?: number;
10
- inputStyle?: TextStyle;
11
- }
12
-
13
- const TextTyping: FC<TextTypingProps> = ({
14
- data = [],
15
- timeDelayEnd = 2000,
16
- timeDelayNextChar = 20,
17
- inputStyle = {},
18
- }) => {
19
- const textRef = useRef<TextInput>(null);
20
-
21
- const currentIndex = useRef<number>(0);
22
- const currentCharIndex = useRef<number>(0);
23
- const currentText = useRef('');
24
-
25
- useEffect(() => {
26
- setTimeout(() => {
27
- playAnimation();
28
- }, 1000);
29
- }, []);
30
-
31
- const playAnimation = () => {
32
- const handleResetList = () => {
33
- currentIndex.current = 0;
34
- handleAnimation();
35
- };
36
-
37
- const handleAnimation = () => {
38
- const listChar = data?.[currentIndex.current]?.split('') || [];
39
- listChar.length !== 0 && showChar(listChar?.[currentCharIndex.current]);
40
- };
41
-
42
- currentIndex.current >= data?.length
43
- ? handleResetList()
44
- : handleAnimation();
45
- };
46
-
47
- const showChar = (char?: string) => {
48
- const handleResetString = () => {
49
- setTimeout(() => {
50
- reset();
51
- }, timeDelayEnd);
52
- };
53
-
54
- const handleShowChar = () => {
55
- setTimeout(() => {
56
- textRef.current?.setNativeProps?.({
57
- text: currentText.current + char,
58
- });
59
- currentText.current += char;
60
- currentCharIndex.current++;
61
- playAnimation();
62
- }, timeDelayNextChar);
63
- };
64
-
65
- currentCharIndex.current >= (data?.[currentIndex.current]?.length || 0)
66
- ? handleResetString()
67
- : handleShowChar();
68
- };
69
-
70
- const reset = () => {
71
- const handleNextString = () => {
72
- currentIndex.current++;
73
- playAnimation();
74
- };
75
-
76
- const handleReset = () => {
77
- setTimeout(() => {
78
- textRef.current?.setNativeProps?.({
79
- text: currentText.current.slice(0, -1),
80
- });
81
- currentText.current = currentText.current.slice(0, -1);
82
- currentCharIndex.current--;
83
- reset();
84
- }, timeDelayNextChar);
85
- };
86
-
87
- currentCharIndex.current <= 0 ? handleNextString() : handleReset();
88
- };
89
-
90
- return (
91
- <TextInput
92
- style={[styles.inputStyle, inputStyle]}
93
- ref={textRef}
94
- editable={false}
95
- autoCorrect={false}
96
- pointerEvents={'none'}
97
- numberOfLines={1}
98
- />
99
- );
100
- };
101
-
102
- export default memo(TextTyping);
103
-
104
- const styles = StyleSheet.create({
105
- inputStyle: {
106
- color: Colors.black_12,
107
- fontSize: scaleSize(12),
108
- height: Platform.select({
109
- android: 60,
110
- ios: 36,
111
- }),
112
- },
113
- });
@@ -1,168 +0,0 @@
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
- });