@momo-kits/foundation 0.150.2-beta.32 → 0.150.2-beta.34

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.
@@ -37,7 +37,6 @@ const TabScreen: React.FC<any> = ({ route, navigation }) => {
37
37
  const { navigator } = useContext(ApplicationContext);
38
38
  const context = useContext<any>(MiniAppContext);
39
39
  const { nested, options, screen, initialParams } = route?.params;
40
- const useAnimation = route?.params?.useAnimation ?? true;
41
40
  const insets = useSafeAreaInsets();
42
41
 
43
42
  const opacityValue = 0.3;
@@ -74,75 +73,78 @@ const TabScreen: React.FC<any> = ({ route, navigation }) => {
74
73
  );
75
74
 
76
75
  useFocusEffect(
77
- React.useCallback(() => {
78
- Animated.parallel([
79
- Animated.timing(opacity, {
80
- toValue: 1,
81
- duration: 200,
82
- useNativeDriver: true,
83
- }),
84
- Animated.timing(scale, {
85
- toValue: 1,
86
- duration: 200,
87
- useNativeDriver: true,
88
- }),
89
- ]).start();
76
+ React.useCallback(
77
+ () => {
78
+ Animated.parallel([
79
+ Animated.timing(opacity, {
80
+ toValue: 1,
81
+ duration: 200,
82
+ useNativeDriver: true,
83
+ }),
84
+ Animated.timing(scale, {
85
+ toValue: 1,
86
+ duration: 200,
87
+ useNativeDriver: true,
88
+ }),
89
+ ]).start();
90
90
 
91
- setTimeout(() => {
92
- navigator?.maxApi?.getDataObserver?.('current_screen', (data: any) => {
93
- onScreenNavigated(data?.screenName, screenName);
94
- navigator?.maxApi?.setObserver?.('current_screen', { screenName });
95
- });
96
- }, 100);
91
+ setTimeout(() => {
92
+ navigator?.maxApi?.getDataObserver?.(
93
+ 'current_screen',
94
+ (data: any) => {
95
+ onScreenNavigated(data?.screenName, screenName);
96
+ navigator?.maxApi?.setObserver?.('current_screen', {
97
+ screenName,
98
+ });
99
+ },
100
+ );
101
+ }, 100);
97
102
 
98
- return () => {
99
- if (navigation.getState().index !== route?.params.index) {
100
- Animated.parallel([
101
- Animated.timing(opacity, {
102
- toValue: opacityValue,
103
- duration: 200,
104
- useNativeDriver: true,
105
- }),
106
- Animated.timing(scale, {
107
- toValue: scaleValue,
108
- duration: 200,
109
- useNativeDriver: true,
110
- }),
111
- ]).start();
112
- }
113
- };
114
- }, [
115
- navigation,
116
- navigator?.maxApi,
117
- onScreenNavigated,
118
- opacity,
119
- route?.params.index,
120
- scale,
121
- screenName,
122
- ]),
103
+ return () => {
104
+ if (navigation.getState().index !== route?.params.index) {
105
+ Animated.parallel([
106
+ Animated.timing(opacity, {
107
+ toValue: opacityValue,
108
+ duration: 200,
109
+ useNativeDriver: true,
110
+ }),
111
+ Animated.timing(scale, {
112
+ toValue: scaleValue,
113
+ duration: 200,
114
+ useNativeDriver: true,
115
+ }),
116
+ ]).start();
117
+ }
118
+ };
119
+ },
120
+ // eslint-disable-next-line react-hooks/exhaustive-deps
121
+ [],
122
+ ),
123
123
  );
124
124
 
125
- useEffect(() => {
126
- const onFocusApp = navigator?.maxApi?.listen?.('onFocusApp', () => {
127
- if (navigation.isFocused()) {
128
- navigator?.maxApi?.getDataObserver?.('current_screen', (data: any) => {
129
- onScreenNavigated(data?.screenName, screenName);
130
- navigator?.maxApi?.setObserver?.('current_screen', { screenName });
131
- });
132
- }
133
- });
134
-
135
- return () => {
136
- onFocusApp?.remove?.();
137
- };
138
- }, [navigation, navigator?.maxApi, onScreenNavigated, screenName]);
125
+ useEffect(
126
+ () => {
127
+ const onFocusApp = navigator?.maxApi?.listen?.('onFocusApp', () => {
128
+ if (navigation.isFocused()) {
129
+ navigator?.maxApi?.getDataObserver?.(
130
+ 'current_screen',
131
+ (data: any) => {
132
+ onScreenNavigated(data?.screenName, screenName);
133
+ navigator?.maxApi?.setObserver?.('current_screen', {
134
+ screenName,
135
+ });
136
+ },
137
+ );
138
+ }
139
+ });
139
140
 
140
- let opacityStyle: undefined | Animated.Value;
141
- let scaleStyle: number | Animated.Value = 1;
142
- if (useAnimation) {
143
- opacityStyle = opacity;
144
- scaleStyle = scale;
145
- }
141
+ return () => {
142
+ onFocusApp?.remove?.();
143
+ };
144
+ },
145
+ // eslint-disable-next-line react-hooks/exhaustive-deps
146
+ [],
147
+ );
146
148
 
147
149
  let stackOptions = {};
148
150
  if (options) {
@@ -155,8 +157,8 @@ const TabScreen: React.FC<any> = ({ route, navigation }) => {
155
157
  style={[
156
158
  styles.container,
157
159
  {
158
- opacity: opacityStyle,
159
- transform: [{ scale: scaleStyle }],
160
+ opacity,
161
+ transform: [{ scale }],
160
162
  },
161
163
  ]}
162
164
  >
@@ -188,8 +190,8 @@ const TabScreen: React.FC<any> = ({ route, navigation }) => {
188
190
  style={[
189
191
  styles.container,
190
192
  {
191
- opacity: opacityStyle,
192
- transform: [{ scale: scaleStyle }],
193
+ opacity,
194
+ transform: [{ scale }],
193
195
  },
194
196
  ]}
195
197
  >
@@ -227,7 +229,6 @@ const BottomTab: React.FC<BottomTabProps> = ({
227
229
  navigation,
228
230
  initialRouteName,
229
231
  floatingButton,
230
- useAnimation = true,
231
232
  }) => {
232
233
  const { theme, navigator } = useContext(ApplicationContext);
233
234
  const dimensions = useWindowDimensions();
@@ -340,7 +341,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
340
341
  key={`BottomTab-${item.name}`}
341
342
  name={item.name}
342
343
  component={TabScreen}
343
- initialParams={{ ...item, nested, index, useAnimation }}
344
+ initialParams={{ ...item, nested, index }}
344
345
  listeners={handler}
345
346
  options={{
346
347
  tabBarLabel: ({ focused, color }) => {
@@ -285,15 +285,15 @@ const StackScreen: React.FC<any> = props => {
285
285
  * tracking for loading screen
286
286
  */
287
287
  const onScreenLoading = () => {
288
- if (!tracking.current?.releaseLoading) {
289
- const timeLoad =
290
- tracking.current.timeEndLoading - tracking.current.timeStartLoading;
288
+ const start = tracking.current.timeStartLoading;
289
+ const end = tracking.current.timeEndLoading;
290
+ if (!tracking.current?.releaseLoading && start && end && end > start) {
291
291
  context?.autoTracking?.({
292
292
  ...context,
293
293
  screenName,
294
294
  componentName: 'Screen',
295
295
  state: 'loading',
296
- duration: timeLoad,
296
+ duration: end - start,
297
297
  loadingType: 'skeleton',
298
298
  });
299
299
  tracking.current.releaseLoading = true;
@@ -380,7 +380,6 @@ const StackScreen: React.FC<any> = props => {
380
380
  /**
381
381
  * tracking for loading screen
382
382
  */
383
- clearTimeout(tracking.current.timeoutLoading);
384
383
  if (!loading) {
385
384
  tracking.current.timeEndLoading = Date.now();
386
385
  }
@@ -388,6 +387,7 @@ const StackScreen: React.FC<any> = props => {
388
387
  /**
389
388
  * timeout for handle tracking screen
390
389
  */
390
+ clearTimeout(tracking.current.timeoutLoading);
391
391
  tracking.current.timeoutLoading = setTimeout(() => {
392
392
  onScreenLoading();
393
393
  }, 2000);
@@ -269,7 +269,6 @@ export type BottomTabProps = {
269
269
  blur?: (e: EventArg<'blur', false, unknown>) => void;
270
270
  };
271
271
  floatingButton?: FloatingButtonProps;
272
- useAnimation?: boolean;
273
272
  };
274
273
 
275
274
  export type FloatingButtonProps = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.150.2-beta.32",
3
+ "version": "0.150.2-beta.34",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},