@momo-kits/foundation 0.77.1-optimize.2 → 0.77.1-optimize.3

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.
@@ -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
- navigator?.maxApi?.dispatchFunction?.('autoTracking', {
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
- time: timeLoad.current,
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
- navigator?.maxApi?.dispatchFunction?.('autoTracking', {
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
- time: timeInteraction.current,
108
+ duration: timeInteraction.current - timeLoad.current,
106
109
  });
107
110
 
108
111
  navigator?.maxApi?.showToastDebug?.({
@@ -12,8 +12,7 @@ import {
12
12
  } from './Components';
13
13
  import {NavigationOptions, Theme} from './types';
14
14
  import {Colors} from '../Consts';
15
- import {Platform} from 'react-native';
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
@@ -33,6 +33,7 @@ const Icon: React.FC<IconProps> = ({
33
33
  loading={false}
34
34
  source={getIconSource()}
35
35
  style={[style, {width: size, height: size}]}
36
+ resizeMode='contain'
36
37
  {...tintColorProps}
37
38
  />
38
39
  );
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 {ApplicationContext, ComponentContext, MiniAppContext} from '../Application';
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
- <FastImage
61
- {...rest}
62
- {...test}
63
- source={source}
64
- style={[styles.container, style]}
65
- onProgress={() => {
66
- error.current = false;
67
- if (status !== 'loading' && loading) {
68
- setStatus('loading');
69
- }
70
- }}
71
- onLoadStart={() => {
72
- error.current = false;
73
- }}
74
- onLoad={() => {
75
- error.current = false;
76
- }}
77
- onLoadEnd={() => {
78
- let current: Status = 'success';
79
- if (error.current) {
80
- current = 'error';
81
- }
82
- if (status !== current) {
83
- setStatus(current);
84
- }
85
- }}
86
- onError={() => {
87
- error.current = true;
88
- }}>
89
- {renderContent()}
90
- </FastImage>
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
 
package/Input/Input.tsx CHANGED
@@ -169,7 +169,7 @@ const Input = forwardRef(
169
169
  <TextInput
170
170
  {...props}
171
171
  accessibilityLabel={accessibilityLabel}
172
- editable={editable && !disabled}
172
+ editable={editable || !disabled}
173
173
  secureTextEntry={secure}
174
174
  textAlignVertical="center"
175
175
  ref={inputRef}
@@ -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,31 @@ 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 debounce = useRef<any>();
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
- clearTimeout(debounce.current);
46
- debounce.current = setTimeout(() => {
47
- const down = value > lastOffset.current;
48
- lastOffset.current = value;
49
- if (down) {
48
+ const direction = value > lastOffset.current ? 'down' : 'up';
49
+ lastOffset.current = value;
50
+ if (lastDirection.current !== direction) {
51
+ lastDirection.current = direction;
52
+ if (direction === 'down') {
50
53
  Animated.timing(widthAnimated!, {
51
54
  toValue: minWidth,
52
- duration: 300,
55
+ duration: 200,
53
56
  useNativeDriver: false,
54
57
  }).start(() => setShowText(false));
55
58
  } else {
56
59
  Animated.timing(widthAnimated!, {
57
60
  toValue: maxWidth.current,
58
- duration: 300,
61
+ duration: 200,
59
62
  useNativeDriver: false,
60
63
  }).start(() => setShowText(true));
61
64
  }
62
- }, 500);
65
+ }
63
66
  });
64
67
 
65
68
  return () => {
@@ -76,6 +79,23 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
76
79
  setWidthAnimated(new Animated.Value(layout.width));
77
80
  };
78
81
 
82
+ if (renderComponent) {
83
+ return (
84
+ <View
85
+ onLayout={handleLayout}
86
+ style={[
87
+ styles.container,
88
+ {
89
+ right: position === 'right' ? 12 : undefined,
90
+ alignSelf: position === 'center' ? 'center' : 'flex-end',
91
+ bottom,
92
+ },
93
+ ]}>
94
+ {renderComponent()}
95
+ </View>
96
+ );
97
+ }
98
+
79
99
  return (
80
100
  <Animated.View
81
101
  onLayout={handleLayout}
@@ -102,6 +122,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
102
122
  <Text
103
123
  style={styles.label}
104
124
  color="white"
125
+ numberOfLines={1}
105
126
  typography="action_default_bold">
106
127
  {label}
107
128
  </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 | undefined>(undefined);
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,7 +234,7 @@ const Screen = forwardRef(
239
234
  },
240
235
  ],
241
236
  {
242
- useNativeDriver: false,
237
+ useNativeDriver: true,
243
238
  listener: (e: NativeSyntheticEvent<NativeScrollEvent>) => {
244
239
  if (animatedHeader?.type == 'surface') {
245
240
  const offsetY = e.nativeEvent.contentOffset.y;
@@ -199,16 +199,20 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
199
199
  {title}
200
200
  </Text>
201
201
  <Description style={[styles.description, descriptionStyle]}>
202
- <Text
203
- typography={'body_default_regular'}
204
- onTextLayout={({nativeEvent: {lines}}) => {
205
- const enableScroll = lines.length > 3;
206
- if (enableScroll != scrollContent) {
207
- setScrollContent(enableScroll);
208
- }
209
- }}>
210
- {description}
211
- </Text>
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, getAccessibilityID};
11
+ export {SafeAreaView, useSafeAreaInsets, SafeAreaProvider, LinearGradient};
13
12
 
14
13
  /**
15
14
  * foundation component
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.77.1-optimize.2",
3
+ "version": "0.77.1-optimize.3",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},