@momo-kits/foundation 0.112.1-optimize.6 → 0.112.1-optimize.6-beta.8

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.
@@ -127,6 +127,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
127
127
  state?: (e: any) => void;
128
128
  } = {
129
129
  tabPress: e => {
130
+ navigator?.maxApi?.triggerEventVibration?.('light');
130
131
  listeners?.tabPress?.(e);
131
132
  },
132
133
  focus: e => {
@@ -28,6 +28,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
28
28
  timeLoad: 0,
29
29
  timeInteraction: 0,
30
30
  widgets: [],
31
+ params: undefined,
31
32
  });
32
33
  const widgets = useRef<any>([]);
33
34
  const context = useContext<any>(MiniAppContext);
@@ -117,6 +118,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
117
118
  state: 'load',
118
119
  duration: timeLoad,
119
120
  widgets: tracking.current.widgets,
121
+ params: tracking.current.params,
120
122
  });
121
123
  navigator?.maxApi?.stopTrace?.(
122
124
  tracking.current.traceIdLoad,
@@ -165,6 +167,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
165
167
  state: 'interaction',
166
168
  duration: tracking.current.timeInteraction - timeLoad,
167
169
  totalDuration: tracking.current.timeInteraction,
170
+ params: tracking.current.params,
168
171
  });
169
172
  navigator?.maxApi?.stopTrace?.(
170
173
  tracking.current.traceIdInteraction,
@@ -254,6 +257,9 @@ const StackScreen: React.FC<ScreenParams> = props => {
254
257
  onScreenInteraction();
255
258
  }, 2000);
256
259
  },
260
+ onSetParams: (data: any) => {
261
+ tracking.current.params = data;
262
+ },
257
263
  }}>
258
264
  <Component heightHeader={heightHeader} {...data} />
259
265
  {showGrid && <GridSystem />}
@@ -16,15 +16,17 @@ import {setAutomationID} from './utils';
16
16
  const Context = createContext({});
17
17
  const ApplicationContext = createContext(defaultContext);
18
18
 
19
- const MiniAppContext = (Platform as any).MiniAppContext ?? createContext({});
20
- const ScreenContext = (Platform as any).ScreenContext ?? createContext({});
19
+ const MiniAppContext = (Platform as any).MiniAppContext ?? Context;
20
+ const ScreenContext = (Platform as any).ScreenContext ?? Context;
21
21
  const ComponentContext = (Platform as any).ComponentContext ?? Context;
22
+ const SkeletonContext = createContext({loading: false});
22
23
 
23
24
  export {
24
25
  ApplicationContext,
25
26
  MiniAppContext,
26
27
  ScreenContext,
27
28
  ComponentContext,
29
+ SkeletonContext,
28
30
  NavigationContainer,
29
31
  Localize,
30
32
  HeaderTitle,
package/Image/index.tsx CHANGED
@@ -2,7 +2,7 @@ import React, {useContext, 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 {ApplicationContext} from '../Application';
5
+ import {ApplicationContext, SkeletonContext} from '../Application';
6
6
  import {Skeleton} from '../Skeleton';
7
7
  import {Icon} from '../Icon';
8
8
  import {Styles} from '../Consts';
@@ -19,6 +19,7 @@ const Image: React.FC<ImageProps> = ({
19
19
  ...rest
20
20
  }) => {
21
21
  const {theme} = useContext(ApplicationContext);
22
+ const skeleton = useContext(SkeletonContext);
22
23
  const error = useRef(false);
23
24
  const [status, setStatus] = useState<Status>('success');
24
25
 
@@ -43,6 +44,15 @@ const Image: React.FC<ImageProps> = ({
43
44
  </View>
44
45
  );
45
46
  }
47
+
48
+ if (skeleton.loading) {
49
+ return (
50
+ <View style={[StyleSheet.absoluteFill, Styles.flexCenter]}>
51
+ <Skeleton />
52
+ </View>
53
+ );
54
+ }
55
+
46
56
  return children;
47
57
  };
48
58
 
package/Layout/Screen.tsx CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  ViewProps,
24
24
  } from 'react-native';
25
25
  import {useSafeAreaInsets} from 'react-native-safe-area-context';
26
- import {ApplicationContext} from '../Application';
26
+ import {ApplicationContext, ScreenContext} from '../Application';
27
27
  import Navigation from '../Application/Navigation';
28
28
  import {
29
29
  AnimatedHeader,
@@ -148,6 +148,11 @@ export interface ScreenProps extends ViewProps {
148
148
  * Optional. Custom headerBackground Image
149
149
  */
150
150
  headerBackground?: string;
151
+
152
+ /**
153
+ * Optional. Custom tracking params
154
+ */
155
+ trackingParams?: object;
151
156
  }
152
157
 
153
158
  const Screen = forwardRef(
@@ -174,11 +179,13 @@ const Screen = forwardRef(
174
179
  animatedValue: customAnimatedValue,
175
180
  headerBackground,
176
181
  gradientColor,
182
+ trackingParams,
177
183
  }: ScreenProps,
178
184
  ref: any
179
185
  ) => {
180
186
  const screenRef = useRef<View | ScrollView>();
181
187
  const {theme} = useContext(ApplicationContext);
188
+ const screen: any = useContext(ScreenContext);
182
189
  const insets = useSafeAreaInsets();
183
190
  const heightHeader = useHeaderHeight();
184
191
  const animatedValue = useRef<Animated.Value>(
@@ -195,6 +202,11 @@ const Screen = forwardRef(
195
202
  keyboardOffset = -Math.min(insets.bottom, 21);
196
203
  }
197
204
 
205
+ /**
206
+ * inject params for screen tracking
207
+ */
208
+ screen?.onSetParams?.(trackingParams);
209
+
198
210
  /**
199
211
  * export options for screen
200
212
  * @param headerType
@@ -1,9 +1,18 @@
1
1
  import React, {useEffect, useMemo, useRef, useState} from 'react';
2
- import {Animated, Easing, Platform, StyleSheet, View} from 'react-native';
2
+ import {
3
+ Animated,
4
+ Easing,
5
+ LayoutAnimation,
6
+ Platform,
7
+ StyleSheet,
8
+ UIManager,
9
+ View,
10
+ } from 'react-native';
3
11
  import LinearGradient from 'react-native-linear-gradient';
4
12
  import {SkeletonTypes} from './types';
5
13
  import {Colors, Styles} from '../Consts';
6
14
  import styles from './styles';
15
+ import {SkeletonContext} from '../Application';
7
16
 
8
17
  const Skeleton: React.FC<SkeletonTypes> = ({style}) => {
9
18
  const [width, setWidth] = useState(0);
@@ -24,7 +33,7 @@ const Skeleton: React.FC<SkeletonTypes> = ({style}) => {
24
33
  duration: 1000,
25
34
  easing: Easing.linear,
26
35
  useNativeDriver: Platform.OS !== 'web',
27
- }),
36
+ })
28
37
  );
29
38
  }, [beginShimmerPosition]);
30
39
 
@@ -69,4 +78,35 @@ const Skeleton: React.FC<SkeletonTypes> = ({style}) => {
69
78
  );
70
79
  };
71
80
 
72
- export {Skeleton};
81
+ const SkeletonProvider: React.FC<{loading: boolean}> = ({
82
+ loading = true,
83
+ children,
84
+ }) => {
85
+ const [previous, setPrevious] = useState(loading);
86
+
87
+ useEffect(() => {
88
+ if (previous !== loading) {
89
+ if (Platform.OS === 'android') {
90
+ if (UIManager.setLayoutAnimationEnabledExperimental) {
91
+ UIManager.setLayoutAnimationEnabledExperimental(true);
92
+ }
93
+ }
94
+ LayoutAnimation.configureNext({
95
+ duration: 600,
96
+ create: {
97
+ type: LayoutAnimation.Types.easeInEaseOut,
98
+ property: LayoutAnimation.Properties.opacity,
99
+ },
100
+ });
101
+ setPrevious(loading);
102
+ }
103
+ }, [loading]);
104
+
105
+ return (
106
+ <SkeletonContext.Provider value={{loading: previous}}>
107
+ {children}
108
+ </SkeletonContext.Provider>
109
+ );
110
+ };
111
+
112
+ export {Skeleton, SkeletonProvider};
package/Text/index.tsx CHANGED
@@ -1,9 +1,14 @@
1
1
  import React, {useContext} from 'react';
2
- import {Text as RNText, TextProps as RNTextProps} from 'react-native';
2
+ import {Text as RNText, TextProps as RNTextProps, View} from 'react-native';
3
3
  import styles from './styles';
4
4
  import {Typography, TypographyWeight} from './types';
5
- import {ApplicationContext, setAutomationID} from '../Application';
5
+ import {
6
+ ApplicationContext,
7
+ setAutomationID,
8
+ SkeletonContext,
9
+ } from '../Application';
6
10
  import {scaleSize} from './utils';
11
+ import {Skeleton} from '../Skeleton';
7
12
 
8
13
  const SFProText: TypographyWeight = {
9
14
  100: 'Thin',
@@ -125,7 +130,7 @@ const Text: React.FC<TextProps> = ({
125
130
  ...rest
126
131
  }) => {
127
132
  const {theme} = useContext(ApplicationContext);
128
-
133
+ const skeleton = useContext(SkeletonContext);
129
134
  const textStyle = getTypoStyle(typography, fontFamily);
130
135
 
131
136
  if (deprecatedValues.includes(typography)) {
@@ -134,6 +139,20 @@ const Text: React.FC<TextProps> = ({
134
139
  );
135
140
  }
136
141
 
142
+ if (skeleton.loading) {
143
+ return (
144
+ <View>
145
+ <Skeleton
146
+ style={[
147
+ style,
148
+ textStyle,
149
+ {height: textStyle?.lineHeight * 0.7 * (rest.numberOfLines ?? 1)},
150
+ ]}
151
+ />
152
+ </View>
153
+ );
154
+ }
155
+
137
156
  return (
138
157
  <RNText
139
158
  {...rest}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.112.1-optimize.6",
3
+ "version": "0.112.1-optimize.6-beta.8",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},