@momo-kits/foundation 0.102.6-beta.9 → 0.102.7-beta.0
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/Components.tsx +11 -0
- package/Application/StackScreen.tsx +46 -9
- package/Application/types.ts +2 -2
- package/Badge/BadgeDotAnimation.tsx +5 -32
- package/Badge/index.tsx +2 -1
- package/Badge/styles.ts +50 -6
- package/index.ts +1 -0
- package/package.json +1 -1
|
@@ -35,6 +35,7 @@ import {Badge, BadgeDot} from '../Badge';
|
|
|
35
35
|
import {HeaderType} from '../Layout/types';
|
|
36
36
|
import Navigation from './Navigation';
|
|
37
37
|
import {InputRef, InputSearch, InputSearchProps} from '../Input';
|
|
38
|
+
import {BadgeDotAnimation} from '../Badge';
|
|
38
39
|
|
|
39
40
|
const SCREEN_PADDING = 12;
|
|
40
41
|
const BACK_WIDTH = 28;
|
|
@@ -71,6 +72,11 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
71
72
|
if (badgeType === 'dot') {
|
|
72
73
|
return <BadgeDot size="small" style={styles.badgeDot} />;
|
|
73
74
|
}
|
|
75
|
+
if (badgeType === 'dot-animation') {
|
|
76
|
+
return (
|
|
77
|
+
<BadgeDotAnimation size="small" style={styles.badgeDotAnimation} />
|
|
78
|
+
);
|
|
79
|
+
}
|
|
74
80
|
|
|
75
81
|
if (isNumber(badgeValue)) {
|
|
76
82
|
return <Badge label={badgeValue} style={styles.badge} />;
|
|
@@ -763,6 +769,11 @@ const styles = StyleSheet.create({
|
|
|
763
769
|
top: -Spacing.XS,
|
|
764
770
|
right: -Spacing.XS,
|
|
765
771
|
},
|
|
772
|
+
badgeDotAnimation: {
|
|
773
|
+
position: 'absolute',
|
|
774
|
+
top: -Spacing.XS,
|
|
775
|
+
right: -Spacing.XS,
|
|
776
|
+
},
|
|
766
777
|
extendedHeader: {
|
|
767
778
|
aspectRatio: 1.75,
|
|
768
779
|
position: 'absolute',
|
|
@@ -17,7 +17,8 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
17
17
|
const {showGrid, navigator} = useContext(ApplicationContext);
|
|
18
18
|
const tracking = useRef<any>({
|
|
19
19
|
timeoutLoad: undefined,
|
|
20
|
-
|
|
20
|
+
timeoutInteraction: undefined,
|
|
21
|
+
timeoutTracking: undefined,
|
|
21
22
|
startTime: Date.now(),
|
|
22
23
|
endTime: Date.now(),
|
|
23
24
|
traceIdLoad: undefined,
|
|
@@ -43,6 +44,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
43
44
|
delete data.initialParams;
|
|
44
45
|
|
|
45
46
|
const screenName = Component?.name || Component?.type?.name || 'Invalid';
|
|
47
|
+
const routes = props.navigation.getState()?.routes || [];
|
|
46
48
|
|
|
47
49
|
/**
|
|
48
50
|
* set options for screen
|
|
@@ -71,16 +73,19 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
71
73
|
navigator?.showModal({screen: EmptyScreen});
|
|
72
74
|
}, 300);
|
|
73
75
|
}
|
|
74
|
-
|
|
75
|
-
props.navigation?.addListener?.('focus', () => {
|
|
76
|
+
|
|
77
|
+
const subscription = props.navigation?.addListener?.('focus', () => {
|
|
78
|
+
navigator?.maxApi?.of?.({screenName});
|
|
76
79
|
navigator?.maxApi?.getDataObserver('CURRENT_SCREEN', (data: any) => {
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
let preScreenName = data?.screenName;
|
|
81
|
+
if (routes?.length > 1) {
|
|
82
|
+
const screen = routes?.[routes?.length - 2]?.params?.screen;
|
|
83
|
+
preScreenName = screen?.name || screen?.type?.name || 'Invalid';
|
|
79
84
|
}
|
|
85
|
+
onScreenNavigated(preScreenName);
|
|
80
86
|
navigator?.maxApi?.setObserver('CURRENT_SCREEN', {screenName});
|
|
81
87
|
});
|
|
82
88
|
});
|
|
83
|
-
|
|
84
89
|
navigator?.maxApi?.startTraceScreenLoad?.(screenName, (data: any) => {
|
|
85
90
|
tracking.current.traceIdLoad = data?.traceId;
|
|
86
91
|
});
|
|
@@ -90,9 +95,17 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
90
95
|
tracking.current.traceIdInteraction = data?.traceId;
|
|
91
96
|
}
|
|
92
97
|
);
|
|
98
|
+
|
|
99
|
+
tracking.current.timeoutTracking = setTimeout(() => {
|
|
100
|
+
onScreenLoad();
|
|
101
|
+
onScreenInteraction();
|
|
102
|
+
}, 5000);
|
|
103
|
+
|
|
93
104
|
return () => {
|
|
94
105
|
onScreenLoad();
|
|
95
106
|
onScreenInteraction();
|
|
107
|
+
clearTimeout(tracking.current.timeoutTracking);
|
|
108
|
+
subscription?.();
|
|
96
109
|
};
|
|
97
110
|
}, []);
|
|
98
111
|
|
|
@@ -111,7 +124,6 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
111
124
|
code: context.code,
|
|
112
125
|
buildNumber: context.buildNumber,
|
|
113
126
|
screenName,
|
|
114
|
-
action: 'push',
|
|
115
127
|
componentName: 'Screen',
|
|
116
128
|
state: 'load',
|
|
117
129
|
duration: tracking.current.timeLoad,
|
|
@@ -158,6 +170,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
158
170
|
componentName: 'Screen',
|
|
159
171
|
state: 'interaction',
|
|
160
172
|
duration: tracking.current.timeInteraction - tracking.current.timeLoad,
|
|
173
|
+
totalDuration: tracking.current.timeInteraction,
|
|
161
174
|
});
|
|
162
175
|
navigator?.maxApi?.stopTrace?.(
|
|
163
176
|
tracking.current.traceIdInteraction,
|
|
@@ -180,6 +193,30 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
180
193
|
}
|
|
181
194
|
};
|
|
182
195
|
|
|
196
|
+
/**
|
|
197
|
+
* tracking for screen navigated
|
|
198
|
+
*/
|
|
199
|
+
const onScreenNavigated = (preScreenName: string) => {
|
|
200
|
+
context.autoTracking?.({
|
|
201
|
+
appId: context.appId,
|
|
202
|
+
code: context.code,
|
|
203
|
+
buildNumber: context.buildNumber,
|
|
204
|
+
preScreenName,
|
|
205
|
+
screenName,
|
|
206
|
+
componentName: 'Screen',
|
|
207
|
+
state: 'navigated',
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* debug toast
|
|
212
|
+
*/
|
|
213
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
214
|
+
appId: context.appId,
|
|
215
|
+
message: `${screenName} screen_navigated`,
|
|
216
|
+
type: 'ERROR',
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
|
|
183
220
|
return (
|
|
184
221
|
<ScreenContext.Provider
|
|
185
222
|
value={{
|
|
@@ -187,8 +224,8 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
187
224
|
onElementLoad: () => {
|
|
188
225
|
clearTimeout(tracking.current.timeoutLoad);
|
|
189
226
|
tracking.current.endTime = Date.now();
|
|
190
|
-
tracking.current.
|
|
191
|
-
tracking.current.
|
|
227
|
+
tracking.current.timeoutInteraction?.cancel?.();
|
|
228
|
+
tracking.current.timeoutInteraction =
|
|
192
229
|
InteractionManager.runAfterInteractions(() => {
|
|
193
230
|
tracking.current.timeInteraction =
|
|
194
231
|
Date.now() - tracking.current.startTime;
|
package/Application/types.ts
CHANGED
|
@@ -129,7 +129,7 @@ export type NavigationButtonProps = {
|
|
|
129
129
|
tintColor?: string;
|
|
130
130
|
useBorder?: boolean;
|
|
131
131
|
onPress: () => void;
|
|
132
|
-
badgeType?: 'dot' | 'number';
|
|
132
|
+
badgeType?: 'dot' | 'number' | 'dot-animation';
|
|
133
133
|
badgeValue?: number;
|
|
134
134
|
accessibilityLabel?: string;
|
|
135
135
|
};
|
|
@@ -137,7 +137,7 @@ export type NavigationButtonProps = {
|
|
|
137
137
|
export type PinnedToolType = {
|
|
138
138
|
key: string;
|
|
139
139
|
badgeValue?: number;
|
|
140
|
-
badgeType?: 'number' | 'dot';
|
|
140
|
+
badgeType?: 'number' | 'dot' | 'dot-animation';
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
export type RuntimeToolType = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, {useEffect, useRef} from 'react';
|
|
2
|
-
import {Animated,
|
|
2
|
+
import {Animated, View} from 'react-native';
|
|
3
3
|
import {BadgeDotProps} from './types';
|
|
4
|
-
import
|
|
4
|
+
import styles from './styles';
|
|
5
5
|
|
|
6
6
|
const DURATION = 500;
|
|
7
7
|
|
|
@@ -11,7 +11,8 @@ const BadgeDotAnimation = ({size, style}: BadgeDotProps) => {
|
|
|
11
11
|
const waveScaleAnim = useRef(new Animated.Value(1)).current;
|
|
12
12
|
const waveOpacityAnim = useRef(new Animated.Value(0)).current;
|
|
13
13
|
|
|
14
|
-
const dotStyle =
|
|
14
|
+
const dotStyle =
|
|
15
|
+
size === 'small' ? styles.dotAnimationSmall : styles.dotAnimation;
|
|
15
16
|
const waveStyle = size === 'small' ? styles.waveSmall : styles.wave;
|
|
16
17
|
|
|
17
18
|
useEffect(() => {
|
|
@@ -67,7 +68,7 @@ const BadgeDotAnimation = ({size, style}: BadgeDotProps) => {
|
|
|
67
68
|
}, []);
|
|
68
69
|
|
|
69
70
|
return (
|
|
70
|
-
<View style={[styles.
|
|
71
|
+
<View style={[styles.dotAnimationContainer, style]}>
|
|
71
72
|
{/* Wave Animation */}
|
|
72
73
|
<Animated.View
|
|
73
74
|
style={[
|
|
@@ -91,32 +92,4 @@ const BadgeDotAnimation = ({size, style}: BadgeDotProps) => {
|
|
|
91
92
|
);
|
|
92
93
|
};
|
|
93
94
|
|
|
94
|
-
const styles = StyleSheet.create({
|
|
95
|
-
...CommonStyle,
|
|
96
|
-
container: {
|
|
97
|
-
position: 'relative',
|
|
98
|
-
alignItems: 'center',
|
|
99
|
-
justifyContent: 'center',
|
|
100
|
-
},
|
|
101
|
-
dot: {
|
|
102
|
-
...CommonStyle.dot,
|
|
103
|
-
borderWidth: 0,
|
|
104
|
-
},
|
|
105
|
-
dotSmall: {
|
|
106
|
-
...CommonStyle.dotSmall,
|
|
107
|
-
borderWidth: 0,
|
|
108
|
-
},
|
|
109
|
-
wave: {
|
|
110
|
-
...CommonStyle.dot,
|
|
111
|
-
opacity: 0,
|
|
112
|
-
position: 'absolute',
|
|
113
|
-
borderWidth: 0,
|
|
114
|
-
},
|
|
115
|
-
waveSmall: {
|
|
116
|
-
...CommonStyle.dotSmall,
|
|
117
|
-
borderWidth: 0,
|
|
118
|
-
position: 'absolute',
|
|
119
|
-
},
|
|
120
|
-
});
|
|
121
|
-
|
|
122
95
|
export default BadgeDotAnimation;
|
package/Badge/index.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import Badge from './Badge';
|
|
2
2
|
import BadgeDot from './BadgeDot';
|
|
3
3
|
import BadgeRibbon from './BadgeRibbon';
|
|
4
|
+
import BadgeDotAnimation from './BadgeDotAnimation';
|
|
4
5
|
import {BadgeProps, BadgeDotProps, BadgeRibbonProps} from './types';
|
|
5
6
|
|
|
6
|
-
export {Badge, BadgeRibbon, BadgeDot};
|
|
7
|
+
export {Badge, BadgeRibbon, BadgeDot, BadgeDotAnimation};
|
|
7
8
|
export type {BadgeProps, BadgeDotProps, BadgeRibbonProps};
|
package/Badge/styles.ts
CHANGED
|
@@ -2,6 +2,10 @@ import {StyleSheet} from 'react-native';
|
|
|
2
2
|
import {Colors, Radius, Spacing} from '../Consts';
|
|
3
3
|
import {scaleSize} from '../Text';
|
|
4
4
|
|
|
5
|
+
const DOT_SIZE = 16;
|
|
6
|
+
|
|
7
|
+
const DOT_SMALL_SIZE = 10;
|
|
8
|
+
|
|
5
9
|
export default StyleSheet.create({
|
|
6
10
|
badge: {
|
|
7
11
|
paddingHorizontal: Spacing.XS,
|
|
@@ -15,21 +19,61 @@ export default StyleSheet.create({
|
|
|
15
19
|
borderColor: Colors.black_01,
|
|
16
20
|
alignSelf: 'baseline',
|
|
17
21
|
},
|
|
22
|
+
dotAnimationContainer: {
|
|
23
|
+
position: 'relative',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
justifyContent: 'center',
|
|
26
|
+
},
|
|
18
27
|
dot: {
|
|
19
|
-
width:
|
|
20
|
-
height:
|
|
28
|
+
width: DOT_SIZE,
|
|
29
|
+
height: DOT_SIZE,
|
|
21
30
|
borderWidth: 2,
|
|
22
31
|
borderColor: Colors.black_01,
|
|
23
32
|
backgroundColor: Colors.red_03,
|
|
24
|
-
borderRadius:
|
|
33
|
+
borderRadius: DOT_SIZE / 2,
|
|
25
34
|
},
|
|
26
35
|
dotSmall: {
|
|
27
|
-
width:
|
|
28
|
-
height:
|
|
36
|
+
width: DOT_SMALL_SIZE,
|
|
37
|
+
height: DOT_SMALL_SIZE,
|
|
29
38
|
borderWidth: 1,
|
|
30
39
|
borderColor: Colors.black_01,
|
|
31
40
|
backgroundColor: Colors.red_03,
|
|
32
|
-
borderRadius:
|
|
41
|
+
borderRadius: DOT_SMALL_SIZE / 2,
|
|
42
|
+
},
|
|
43
|
+
dotAnimation: {
|
|
44
|
+
width: DOT_SIZE,
|
|
45
|
+
height: DOT_SIZE,
|
|
46
|
+
borderColor: Colors.black_01,
|
|
47
|
+
backgroundColor: Colors.red_03,
|
|
48
|
+
borderRadius: DOT_SIZE / 2,
|
|
49
|
+
borderWidth: 0,
|
|
50
|
+
},
|
|
51
|
+
dotAnimationSmall: {
|
|
52
|
+
width: DOT_SMALL_SIZE,
|
|
53
|
+
height: DOT_SMALL_SIZE,
|
|
54
|
+
borderColor: Colors.black_01,
|
|
55
|
+
backgroundColor: Colors.red_03,
|
|
56
|
+
borderRadius: DOT_SMALL_SIZE / 2,
|
|
57
|
+
borderWidth: 0,
|
|
58
|
+
},
|
|
59
|
+
wave: {
|
|
60
|
+
width: DOT_SIZE,
|
|
61
|
+
height: DOT_SIZE,
|
|
62
|
+
borderColor: Colors.black_01,
|
|
63
|
+
backgroundColor: Colors.red_03,
|
|
64
|
+
borderRadius: DOT_SIZE / 2,
|
|
65
|
+
opacity: 0,
|
|
66
|
+
position: 'absolute',
|
|
67
|
+
borderWidth: 0,
|
|
68
|
+
},
|
|
69
|
+
waveSmall: {
|
|
70
|
+
width: DOT_SMALL_SIZE,
|
|
71
|
+
height: DOT_SMALL_SIZE,
|
|
72
|
+
borderColor: Colors.black_01,
|
|
73
|
+
backgroundColor: Colors.red_03,
|
|
74
|
+
borderRadius: DOT_SMALL_SIZE / 2,
|
|
75
|
+
borderWidth: 0,
|
|
76
|
+
position: 'absolute',
|
|
33
77
|
},
|
|
34
78
|
ribbon: {
|
|
35
79
|
alignSelf: 'baseline',
|
package/index.ts
CHANGED