@momo-kits/foundation 0.77.1-optimize.2 → 0.77.1-optimzie.4
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/BottomTab/BottomTabBar.tsx +1 -36
- package/Application/BottomTab/index.tsx +1 -1
- 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/Layout/FloatingButton.tsx +40 -17
- package/Layout/Screen.tsx +4 -8
- package/Popup/PopupNotify.tsx +14 -10
- package/index.ts +1 -2
- package/package.json +1 -1
|
@@ -46,8 +46,6 @@ type Options = {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
const DEFAULT_MAX_TAB_ITEM_WIDTH = 125;
|
|
49
|
-
const DEFAULT_TABBAR_HEIGHT = 49;
|
|
50
|
-
const COMPACT_TABBAR_HEIGHT = 32;
|
|
51
49
|
|
|
52
50
|
const shouldUseHorizontalLabels = ({
|
|
53
51
|
state,
|
|
@@ -87,38 +85,6 @@ const shouldUseHorizontalLabels = ({
|
|
|
87
85
|
const getPaddingBottom = (insets: EdgeInsets) =>
|
|
88
86
|
Math.max(insets.bottom - Platform.select({ios: 4, default: 0}), 0);
|
|
89
87
|
|
|
90
|
-
export const getTabBarHeight = ({
|
|
91
|
-
dimensions,
|
|
92
|
-
insets,
|
|
93
|
-
style,
|
|
94
|
-
...rest
|
|
95
|
-
}: Options & {
|
|
96
|
-
insets: EdgeInsets;
|
|
97
|
-
style: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
98
|
-
}) => {
|
|
99
|
-
// @ts-ignore
|
|
100
|
-
const customHeight = StyleSheet.flatten(style)?.height;
|
|
101
|
-
|
|
102
|
-
if (typeof customHeight === 'number') {
|
|
103
|
-
return customHeight;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const isLandscape = dimensions.width > dimensions.height;
|
|
107
|
-
const horizontalLabels = shouldUseHorizontalLabels({dimensions, ...rest});
|
|
108
|
-
const paddingBottom = getPaddingBottom(insets);
|
|
109
|
-
|
|
110
|
-
if (
|
|
111
|
-
Platform.OS === 'ios' &&
|
|
112
|
-
!Platform.isPad &&
|
|
113
|
-
isLandscape &&
|
|
114
|
-
horizontalLabels
|
|
115
|
-
) {
|
|
116
|
-
return COMPACT_TABBAR_HEIGHT + paddingBottom;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return DEFAULT_TABBAR_HEIGHT + paddingBottom;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
88
|
export default function BottomTabBar({
|
|
123
89
|
state,
|
|
124
90
|
navigation,
|
|
@@ -409,7 +375,7 @@ export default function BottomTabBar({
|
|
|
409
375
|
position: isTabBarHidden ? 'absolute' : (null as any),
|
|
410
376
|
},
|
|
411
377
|
{
|
|
412
|
-
paddingBottom: paddingBottom
|
|
378
|
+
paddingBottom: paddingBottom,
|
|
413
379
|
paddingHorizontal: Math.max(insets.left, insets.right),
|
|
414
380
|
},
|
|
415
381
|
style,
|
|
@@ -464,7 +430,6 @@ const styles = StyleSheet.create({
|
|
|
464
430
|
justifyContent: 'center',
|
|
465
431
|
height: 48,
|
|
466
432
|
width: 48,
|
|
467
|
-
|
|
468
433
|
borderRadius: 100,
|
|
469
434
|
top: -12,
|
|
470
435
|
},
|
|
@@ -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
|
|
|
@@ -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,33 @@ 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
|
-
const down = value > lastOffset.current;
|
|
48
|
+
if (value !== lastOffset.current) {
|
|
49
|
+
const direction = value > lastOffset.current ? 'down' : 'up';
|
|
48
50
|
lastOffset.current = value;
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
if (lastDirection.current !== direction) {
|
|
52
|
+
lastDirection.current = direction;
|
|
53
|
+
if (direction === 'down') {
|
|
54
|
+
Animated.timing(widthAnimated!, {
|
|
55
|
+
toValue: minWidth,
|
|
56
|
+
duration: 200,
|
|
57
|
+
useNativeDriver: false,
|
|
58
|
+
}).start(() => setShowText(false));
|
|
59
|
+
} else {
|
|
60
|
+
Animated.timing(widthAnimated!, {
|
|
61
|
+
toValue: maxWidth.current,
|
|
62
|
+
duration: 200,
|
|
63
|
+
useNativeDriver: false,
|
|
64
|
+
}).start(() => setShowText(true));
|
|
65
|
+
}
|
|
61
66
|
}
|
|
62
|
-
}
|
|
67
|
+
}
|
|
63
68
|
});
|
|
64
69
|
|
|
65
70
|
return () => {
|
|
@@ -76,6 +81,23 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
76
81
|
setWidthAnimated(new Animated.Value(layout.width));
|
|
77
82
|
};
|
|
78
83
|
|
|
84
|
+
if (renderComponent) {
|
|
85
|
+
return (
|
|
86
|
+
<View
|
|
87
|
+
onLayout={handleLayout}
|
|
88
|
+
style={[
|
|
89
|
+
styles.container,
|
|
90
|
+
{
|
|
91
|
+
right: position === 'right' ? 12 : undefined,
|
|
92
|
+
alignSelf: position === 'center' ? 'center' : 'flex-end',
|
|
93
|
+
bottom,
|
|
94
|
+
},
|
|
95
|
+
]}>
|
|
96
|
+
{renderComponent()}
|
|
97
|
+
</View>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
79
101
|
return (
|
|
80
102
|
<Animated.View
|
|
81
103
|
onLayout={handleLayout}
|
|
@@ -102,6 +124,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
102
124
|
<Text
|
|
103
125
|
style={styles.label}
|
|
104
126
|
color="white"
|
|
127
|
+
numberOfLines={1}
|
|
105
128
|
typography="action_default_bold">
|
|
106
129
|
{label}
|
|
107
130
|
</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,8 +234,9 @@ const Screen = forwardRef(
|
|
|
239
234
|
},
|
|
240
235
|
],
|
|
241
236
|
{
|
|
242
|
-
useNativeDriver:
|
|
237
|
+
useNativeDriver: true,
|
|
243
238
|
listener: (e: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
239
|
+
scrollViewProps?.onScroll?.(e);
|
|
244
240
|
if (animatedHeader?.type == 'surface') {
|
|
245
241
|
const offsetY = e.nativeEvent.contentOffset.y;
|
|
246
242
|
let color = Colors.black_01;
|
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
|