@momo-kits/foundation 0.102.6-beta.0 → 0.102.6-beta.1

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.
@@ -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/BadgeDotAnimation';
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.S,
775
+ right: -Spacing.S,
776
+ },
766
777
  extendedHeader: {
767
778
  aspectRatio: 1.75,
768
779
  position: 'absolute',
@@ -99,6 +99,8 @@ const StackScreen: React.FC<ScreenParams> = props => {
99
99
  traceIdInteraction: undefined,
100
100
  releaseLoad: undefined,
101
101
  releaseInteraction: undefined,
102
+ timeoutLoad: undefined,
103
+ timeoutInteraction: undefined,
102
104
  });
103
105
  const interaction = useRef<any>();
104
106
  const context = useContext<any>(MiniAppContext);
@@ -133,6 +135,15 @@ const StackScreen: React.FC<ScreenParams> = props => {
133
135
  };
134
136
  }
135
137
  navigation.setOptions(defaultOptions);
138
+ navigator?.maxApi?.startTraceScreenLoad?.(screenName, (data: any) => {
139
+ tracked.current.traceIdLoad = data?.traceId;
140
+ });
141
+ navigator?.maxApi?.startTraceScreenInteraction?.(
142
+ screenName,
143
+ (data: any) => {
144
+ tracked.current.traceIdInteraction = data?.traceId;
145
+ }
146
+ );
136
147
  }, [options]);
137
148
 
138
149
  /**
@@ -145,16 +156,16 @@ const StackScreen: React.FC<ScreenParams> = props => {
145
156
  }, 300);
146
157
  }
147
158
  navigator?.maxApi?.of?.({screenName});
148
- navigator?.maxApi?.startTraceScreenLoad?.(screenName, (data: any) => {
149
- tracked.current.traceIdLoad = data?.traceId;
150
- });
151
- navigator?.maxApi?.startTraceScreenInteraction?.(
152
- screenName,
153
- (data: any) => {
154
- tracked.current.traceIdInteraction = data?.traceId;
155
- }
156
- );
159
+ tracked.current.timeoutLoad = setTimeout(() => {
160
+ onScreenLoad();
161
+ }, 5000);
162
+ tracked.current.timeoutInteraction = setTimeout(() => {
163
+ onScreenInteraction();
164
+ }, 5000);
165
+
157
166
  return () => {
167
+ clearTimeout(tracked.current.timeoutLoad);
168
+ clearTimeout(tracked.current.timeoutInteraction);
158
169
  onScreenLoad();
159
170
  onScreenInteraction();
160
171
  };
@@ -190,9 +201,8 @@ const StackScreen: React.FC<ScreenParams> = props => {
190
201
  * debug
191
202
  */
192
203
  navigator?.maxApi?.showToastDebug?.({
193
- appId: context.appId,
204
+ appId: `auto - ${context.appId}`,
194
205
  message: `${screenName} screen_load_time ${timeLoad.current}`,
195
- type: 'error',
196
206
  });
197
207
  if (timeLoad.current <= 0 && context.enableAutoId) {
198
208
  Alert.alert(screenName, "Can't get screen load time");
@@ -232,9 +242,8 @@ const StackScreen: React.FC<ScreenParams> = props => {
232
242
  * debug toast
233
243
  */
234
244
  navigator?.maxApi?.showToastDebug?.({
235
- appId: context.appId,
245
+ appId: `auto - ${context.appId}`,
236
246
  message: `${screenName} screen_interaction_time ${timeInteraction.current}`,
237
- type: 'error',
238
247
  });
239
248
  if (timeInteraction.current <= 0 && context.enableAutoId) {
240
249
  Alert.alert(screenName, "Can't get screen interaction time");
@@ -257,8 +266,6 @@ const StackScreen: React.FC<ScreenParams> = props => {
257
266
  if (timeLoad.current === 0) {
258
267
  timeLoad.current = endTime.current - startTime.current;
259
268
  }
260
- onScreenLoad();
261
- onScreenInteraction();
262
269
  }, 2000);
263
270
  },
264
271
  }}>
@@ -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
  };
@@ -0,0 +1,122 @@
1
+ import React, {useEffect, useRef} from 'react';
2
+ import {Animated, StyleSheet, View} from 'react-native';
3
+ import {BadgeDotProps} from './types';
4
+ import CommonStyle from './styles';
5
+
6
+ const DURATION = 500;
7
+
8
+ const BadgeDotAnimation = ({size, style}: BadgeDotProps) => {
9
+ // Refs for animated values
10
+ const scaleAnim = useRef(new Animated.Value(1)).current;
11
+ const waveScaleAnim = useRef(new Animated.Value(1)).current;
12
+ const waveOpacityAnim = useRef(new Animated.Value(0)).current;
13
+
14
+ const dotStyle = size === 'small' ? styles.dotSmall : styles.dot;
15
+ const waveStyle = size === 'small' ? styles.waveSmall : styles.wave;
16
+
17
+ useEffect(() => {
18
+ // Infinite loop animation for the scale and wave effect
19
+ const animation = Animated.loop(
20
+ Animated.parallel([
21
+ // Dot pulse animation
22
+ Animated.sequence([
23
+ Animated.spring(scaleAnim, {
24
+ toValue: 1, // Scale up slightly
25
+ friction: 5, // Controls the "bounciness" of the spring
26
+ tension: 30, // Controls the "stiffness" of the spring
27
+ useNativeDriver: true,
28
+ }),
29
+ Animated.spring(scaleAnim, {
30
+ toValue: 1.2,
31
+ friction: 5,
32
+ tension: 30,
33
+ useNativeDriver: true,
34
+ }),
35
+ ]), // Wave animation
36
+ Animated.sequence([
37
+ Animated.timing(waveScaleAnim, {
38
+ toValue: 2.5,
39
+ duration: DURATION * 2,
40
+ useNativeDriver: true,
41
+ }),
42
+ Animated.timing(waveScaleAnim, {
43
+ toValue: 1, // Reset wave size
44
+ duration: 0,
45
+ useNativeDriver: true,
46
+ }),
47
+ ]), // Wave opacity animation
48
+ Animated.sequence([
49
+ Animated.timing(waveOpacityAnim, {
50
+ toValue: 0.3, // Wave becomes visible
51
+ duration: DURATION,
52
+ useNativeDriver: true,
53
+ }),
54
+ Animated.timing(waveOpacityAnim, {
55
+ toValue: 0, // Wave fades out
56
+ duration: DURATION * 1.2,
57
+ useNativeDriver: true,
58
+ }),
59
+ ]),
60
+ ])
61
+ );
62
+ animation.start();
63
+
64
+ return () => {
65
+ animation.stop();
66
+ };
67
+ }, [scaleAnim, waveScaleAnim, waveOpacityAnim]);
68
+
69
+ return (
70
+ <View style={[styles.container, style]}>
71
+ {/* Wave Animation */}
72
+ <Animated.View
73
+ style={[
74
+ waveStyle,
75
+ {
76
+ transform: [{scale: waveScaleAnim}],
77
+ opacity: waveOpacityAnim,
78
+ },
79
+ ]}
80
+ />
81
+ {/* Dot Animation */}
82
+ <Animated.View
83
+ style={[
84
+ dotStyle,
85
+ {
86
+ transform: [{scale: scaleAnim}],
87
+ },
88
+ ]}
89
+ />
90
+ </View>
91
+ );
92
+ };
93
+
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
+ export default BadgeDotAnimation;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.102.6-beta.0",
3
+ "version": "0.102.6-beta.1",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},
package/publish.sh CHANGED
@@ -9,8 +9,8 @@ elif [ "$1" == "latest" ]; then
9
9
  npm version prerelease --preid=rc
10
10
  npm publish --tag latest --access=public
11
11
  else
12
- # npm version $(npm view @momo-kits/foundation@beta version)
13
- # npm version prerelease --preid=beta
12
+ npm version $(npm view @momo-kits/foundation@beta version)
13
+ npm version prerelease --preid=beta
14
14
  npm publish --tag beta --access=public
15
15
  fi
16
16