@momo-kits/foundation 0.77.1-optimize.2 → 0.77.1-optimize.3
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/StackScreen.tsx +7 -4
- package/Application/utils.tsx +1 -19
- package/Icon/index.tsx +1 -0
- package/Image/index.tsx +38 -34
- package/Input/Input.tsx +1 -1
- package/Layout/FloatingButton.tsx +30 -9
- package/Layout/Screen.tsx +3 -8
- package/Popup/PopupNotify.tsx +14 -10
- package/index.ts +1 -2
- package/package.json +1 -1
|
@@ -62,6 +62,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
62
62
|
tracked.current.timeoutInteraction = setTimeout(() => {
|
|
63
63
|
onScreenInteraction();
|
|
64
64
|
}, 5000);
|
|
65
|
+
|
|
65
66
|
return () => {
|
|
66
67
|
onScreenLoad();
|
|
67
68
|
onScreenInteraction();
|
|
@@ -74,13 +75,14 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
74
75
|
const onScreenLoad = () => {
|
|
75
76
|
clearTimeout(tracked.current.timeoutLoad);
|
|
76
77
|
if (!tracked.current?.releaseLoad) {
|
|
77
|
-
|
|
78
|
+
context.autoTracking?.({
|
|
78
79
|
appId: context.appId,
|
|
79
80
|
code: context.code,
|
|
81
|
+
buildNumber: context.buildNumber,
|
|
80
82
|
screenName,
|
|
81
83
|
componentName: 'Screen',
|
|
82
84
|
state: 'load',
|
|
83
|
-
|
|
85
|
+
duration: timeLoad.current,
|
|
84
86
|
});
|
|
85
87
|
navigator?.maxApi?.showToastDebug?.({
|
|
86
88
|
appId: `auto - ${context.appId}`,
|
|
@@ -96,13 +98,14 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
96
98
|
const onScreenInteraction = () => {
|
|
97
99
|
clearTimeout(tracked.current.timeoutInteraction);
|
|
98
100
|
if (!tracked.current?.releaseInteraction) {
|
|
99
|
-
|
|
101
|
+
context.autoTracking?.({
|
|
100
102
|
appId: context.appId,
|
|
101
103
|
code: context.code,
|
|
104
|
+
buildNumber: context.buildNumber,
|
|
102
105
|
screenName,
|
|
103
106
|
componentName: 'Screen',
|
|
104
107
|
state: 'interaction',
|
|
105
|
-
|
|
108
|
+
duration: timeInteraction.current - timeLoad.current,
|
|
106
109
|
});
|
|
107
110
|
|
|
108
111
|
navigator?.maxApi?.showToastDebug?.({
|
package/Application/utils.tsx
CHANGED
|
@@ -12,8 +12,7 @@ import {
|
|
|
12
12
|
} from './Components';
|
|
13
13
|
import {NavigationOptions, Theme} from './types';
|
|
14
14
|
import {Colors} from '../Consts';
|
|
15
|
-
|
|
16
|
-
const isIOS = Platform.OS === 'ios';
|
|
15
|
+
|
|
17
16
|
/**
|
|
18
17
|
* default options for stack screen
|
|
19
18
|
*/
|
|
@@ -142,22 +141,6 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
142
141
|
};
|
|
143
142
|
};
|
|
144
143
|
|
|
145
|
-
const getAccessibilityID = (
|
|
146
|
-
key = '',
|
|
147
|
-
override: string | undefined = undefined,
|
|
148
|
-
) => {
|
|
149
|
-
if (isIOS) {
|
|
150
|
-
return {
|
|
151
|
-
accessible: true,
|
|
152
|
-
testID: override || key,
|
|
153
|
-
};
|
|
154
|
-
} else {
|
|
155
|
-
return {
|
|
156
|
-
accessibilityLabel: override || key,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
|
|
161
144
|
const formatNameLength = (name = '') => {
|
|
162
145
|
let formattedName = name;
|
|
163
146
|
if (formattedName.length > 100) {
|
|
@@ -171,5 +154,4 @@ export {
|
|
|
171
154
|
getModalOptions,
|
|
172
155
|
getOptions,
|
|
173
156
|
formatNameLength,
|
|
174
|
-
getAccessibilityID,
|
|
175
157
|
};
|
package/Icon/index.tsx
CHANGED
package/Image/index.tsx
CHANGED
|
@@ -2,7 +2,11 @@ import React, {useContext, useEffect, useRef, useState} from 'react';
|
|
|
2
2
|
import {StyleSheet, View} from 'react-native';
|
|
3
3
|
import FastImage, {Source} from 'react-native-fast-image';
|
|
4
4
|
import styles from './styles';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ApplicationContext,
|
|
7
|
+
ComponentContext,
|
|
8
|
+
MiniAppContext,
|
|
9
|
+
} from '../Application';
|
|
6
10
|
import {Skeleton} from '../Skeleton';
|
|
7
11
|
import {Icon} from '../Icon';
|
|
8
12
|
import {Styles} from '../Consts';
|
|
@@ -30,9 +34,9 @@ const Image: React.FC<ImageProps> = ({
|
|
|
30
34
|
};
|
|
31
35
|
|
|
32
36
|
useEffect(() => {
|
|
33
|
-
if(app.enableAutoId){
|
|
37
|
+
if (app.enableAutoId) {
|
|
34
38
|
component?.addChildren?.(test.accessibilityLabel, 'add');
|
|
35
|
-
return () => component?.addChildren(test.accessibilityLabel, 'remove');
|
|
39
|
+
return () => component?.addChildren?.(test.accessibilityLabel, 'remove');
|
|
36
40
|
}
|
|
37
41
|
}, []);
|
|
38
42
|
|
|
@@ -57,37 +61,37 @@ const Image: React.FC<ImageProps> = ({
|
|
|
57
61
|
};
|
|
58
62
|
|
|
59
63
|
return (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
64
|
+
<FastImage
|
|
65
|
+
{...rest}
|
|
66
|
+
{...test}
|
|
67
|
+
source={source}
|
|
68
|
+
style={[styles.container, style]}
|
|
69
|
+
onProgress={() => {
|
|
70
|
+
error.current = false;
|
|
71
|
+
if (status !== 'loading' && loading) {
|
|
72
|
+
setStatus('loading');
|
|
73
|
+
}
|
|
74
|
+
}}
|
|
75
|
+
onLoadStart={() => {
|
|
76
|
+
error.current = false;
|
|
77
|
+
}}
|
|
78
|
+
onLoad={() => {
|
|
79
|
+
error.current = false;
|
|
80
|
+
}}
|
|
81
|
+
onLoadEnd={() => {
|
|
82
|
+
let current: Status = 'success';
|
|
83
|
+
if (error.current) {
|
|
84
|
+
current = 'error';
|
|
85
|
+
}
|
|
86
|
+
if (status !== current) {
|
|
87
|
+
setStatus(current);
|
|
88
|
+
}
|
|
89
|
+
}}
|
|
90
|
+
onError={() => {
|
|
91
|
+
error.current = true;
|
|
92
|
+
}}>
|
|
93
|
+
{renderContent()}
|
|
94
|
+
</FastImage>
|
|
91
95
|
);
|
|
92
96
|
};
|
|
93
97
|
|
package/Input/Input.tsx
CHANGED
|
@@ -169,7 +169,7 @@ const Input = forwardRef(
|
|
|
169
169
|
<TextInput
|
|
170
170
|
{...props}
|
|
171
171
|
accessibilityLabel={accessibilityLabel}
|
|
172
|
-
editable={editable
|
|
172
|
+
editable={editable || !disabled}
|
|
173
173
|
secureTextEntry={secure}
|
|
174
174
|
textAlignVertical="center"
|
|
175
175
|
ref={inputRef}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
LayoutChangeEvent,
|
|
5
5
|
StyleSheet,
|
|
6
6
|
TouchableOpacity,
|
|
7
|
+
View,
|
|
7
8
|
} from 'react-native';
|
|
8
9
|
import {ApplicationContext} from '../Application';
|
|
9
10
|
import {Icon} from '../Icon';
|
|
@@ -18,9 +19,11 @@ export interface FloatingButtonProps {
|
|
|
18
19
|
size?: 'small' | 'large';
|
|
19
20
|
animatedValue?: Animated.Value;
|
|
20
21
|
bottom?: number;
|
|
22
|
+
renderComponent?: () => React.ReactNode;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
26
|
+
renderComponent,
|
|
24
27
|
label = '',
|
|
25
28
|
onPress = () => {},
|
|
26
29
|
position = 'right',
|
|
@@ -35,31 +38,31 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
35
38
|
const minWidth = size == 'small' ? 36 : 48;
|
|
36
39
|
const [widthAnimated, setWidthAnimated] = useState<Animated.Value>();
|
|
37
40
|
const lastOffset = useRef(0);
|
|
38
|
-
const
|
|
41
|
+
const lastDirection = useRef<string>();
|
|
39
42
|
const [showText, setShowText] = React.useState(true);
|
|
40
43
|
|
|
41
44
|
useEffect(() => {
|
|
42
45
|
if (!label) return;
|
|
43
46
|
|
|
44
47
|
const listener = animatedValue?.addListener(({value}) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (down) {
|
|
48
|
+
const direction = value > lastOffset.current ? 'down' : 'up';
|
|
49
|
+
lastOffset.current = value;
|
|
50
|
+
if (lastDirection.current !== direction) {
|
|
51
|
+
lastDirection.current = direction;
|
|
52
|
+
if (direction === 'down') {
|
|
50
53
|
Animated.timing(widthAnimated!, {
|
|
51
54
|
toValue: minWidth,
|
|
52
|
-
duration:
|
|
55
|
+
duration: 200,
|
|
53
56
|
useNativeDriver: false,
|
|
54
57
|
}).start(() => setShowText(false));
|
|
55
58
|
} else {
|
|
56
59
|
Animated.timing(widthAnimated!, {
|
|
57
60
|
toValue: maxWidth.current,
|
|
58
|
-
duration:
|
|
61
|
+
duration: 200,
|
|
59
62
|
useNativeDriver: false,
|
|
60
63
|
}).start(() => setShowText(true));
|
|
61
64
|
}
|
|
62
|
-
}
|
|
65
|
+
}
|
|
63
66
|
});
|
|
64
67
|
|
|
65
68
|
return () => {
|
|
@@ -76,6 +79,23 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
76
79
|
setWidthAnimated(new Animated.Value(layout.width));
|
|
77
80
|
};
|
|
78
81
|
|
|
82
|
+
if (renderComponent) {
|
|
83
|
+
return (
|
|
84
|
+
<View
|
|
85
|
+
onLayout={handleLayout}
|
|
86
|
+
style={[
|
|
87
|
+
styles.container,
|
|
88
|
+
{
|
|
89
|
+
right: position === 'right' ? 12 : undefined,
|
|
90
|
+
alignSelf: position === 'center' ? 'center' : 'flex-end',
|
|
91
|
+
bottom,
|
|
92
|
+
},
|
|
93
|
+
]}>
|
|
94
|
+
{renderComponent()}
|
|
95
|
+
</View>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
79
99
|
return (
|
|
80
100
|
<Animated.View
|
|
81
101
|
onLayout={handleLayout}
|
|
@@ -102,6 +122,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
102
122
|
<Text
|
|
103
123
|
style={styles.label}
|
|
104
124
|
color="white"
|
|
125
|
+
numberOfLines={1}
|
|
105
126
|
typography="action_default_bold">
|
|
106
127
|
{label}
|
|
107
128
|
</Text>
|
package/Layout/Screen.tsx
CHANGED
|
@@ -114,7 +114,7 @@ const Screen = forwardRef(
|
|
|
114
114
|
}: ScreenProps,
|
|
115
115
|
ref,
|
|
116
116
|
) => {
|
|
117
|
-
const animatedValue = useRef<Animated.Value
|
|
117
|
+
const animatedValue = useRef<Animated.Value>(new Animated.Value(0));
|
|
118
118
|
const {theme} = useContext(ApplicationContext);
|
|
119
119
|
const insets = useSafeAreaInsets();
|
|
120
120
|
const heightHeader = useHeaderHeight();
|
|
@@ -190,12 +190,9 @@ const Screen = forwardRef(
|
|
|
190
190
|
image={null}
|
|
191
191
|
backgroundColor={theme.colors.background.surface}
|
|
192
192
|
useBorder={true}
|
|
193
|
-
animatedValue={animatedValue.current}
|
|
194
193
|
/>
|
|
195
194
|
),
|
|
196
|
-
headerTitle: (props: any) =>
|
|
197
|
-
<HeaderTitle {...props} animatedValue={animatedValue.current} />
|
|
198
|
-
),
|
|
195
|
+
headerTitle: (props: any) => <HeaderTitle {...props} />,
|
|
199
196
|
};
|
|
200
197
|
break;
|
|
201
198
|
|
|
@@ -228,8 +225,6 @@ const Screen = forwardRef(
|
|
|
228
225
|
Component = Animated.ScrollView;
|
|
229
226
|
handleScroll = scrollViewProps?.onScroll;
|
|
230
227
|
if (animatedHeader || floatingButtonProps) {
|
|
231
|
-
animatedValue.current = new Animated.Value(0);
|
|
232
|
-
|
|
233
228
|
handleScroll = Animated.event(
|
|
234
229
|
[
|
|
235
230
|
{
|
|
@@ -239,7 +234,7 @@ const Screen = forwardRef(
|
|
|
239
234
|
},
|
|
240
235
|
],
|
|
241
236
|
{
|
|
242
|
-
useNativeDriver:
|
|
237
|
+
useNativeDriver: true,
|
|
243
238
|
listener: (e: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
244
239
|
if (animatedHeader?.type == 'surface') {
|
|
245
240
|
const offsetY = e.nativeEvent.contentOffset.y;
|
package/Popup/PopupNotify.tsx
CHANGED
|
@@ -199,16 +199,20 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
199
199
|
{title}
|
|
200
200
|
</Text>
|
|
201
201
|
<Description style={[styles.description, descriptionStyle]}>
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
202
|
+
{typeof description === 'string' ? (
|
|
203
|
+
<Text
|
|
204
|
+
typography={'body_default_regular'}
|
|
205
|
+
onTextLayout={({nativeEvent: {lines}}) => {
|
|
206
|
+
const enableScroll = lines.length > 3;
|
|
207
|
+
if (enableScroll != scrollContent) {
|
|
208
|
+
setScrollContent(enableScroll);
|
|
209
|
+
}
|
|
210
|
+
}}>
|
|
211
|
+
{description}
|
|
212
|
+
</Text>
|
|
213
|
+
) : (
|
|
214
|
+
description
|
|
215
|
+
)}
|
|
212
216
|
</Description>
|
|
213
217
|
{!!error && (
|
|
214
218
|
<View style={styles.information}>
|
package/index.ts
CHANGED
|
@@ -4,12 +4,11 @@ import {
|
|
|
4
4
|
useSafeAreaInsets,
|
|
5
5
|
} from 'react-native-safe-area-context';
|
|
6
6
|
import LinearGradient from 'react-native-linear-gradient';
|
|
7
|
-
import {getAccessibilityID} from "./Application/utils";
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* native export
|
|
11
10
|
*/
|
|
12
|
-
export {SafeAreaView, useSafeAreaInsets, SafeAreaProvider, LinearGradient
|
|
11
|
+
export {SafeAreaView, useSafeAreaInsets, SafeAreaProvider, LinearGradient};
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* foundation component
|