@momo-kits/foundation 0.77.1-optimize.2 → 0.77.1-optimzie.4

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.
@@ -46,8 +46,6 @@ type Options = {
46
46
  };
47
47
 
48
48
  const DEFAULT_MAX_TAB_ITEM_WIDTH = 125;
49
- const DEFAULT_TABBAR_HEIGHT = 49;
50
- const COMPACT_TABBAR_HEIGHT = 32;
51
49
 
52
50
  const shouldUseHorizontalLabels = ({
53
51
  state,
@@ -87,38 +85,6 @@ const shouldUseHorizontalLabels = ({
87
85
  const getPaddingBottom = (insets: EdgeInsets) =>
88
86
  Math.max(insets.bottom - Platform.select({ios: 4, default: 0}), 0);
89
87
 
90
- export const getTabBarHeight = ({
91
- dimensions,
92
- insets,
93
- style,
94
- ...rest
95
- }: Options & {
96
- insets: EdgeInsets;
97
- style: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
98
- }) => {
99
- // @ts-ignore
100
- const customHeight = StyleSheet.flatten(style)?.height;
101
-
102
- if (typeof customHeight === 'number') {
103
- return customHeight;
104
- }
105
-
106
- const isLandscape = dimensions.width > dimensions.height;
107
- const horizontalLabels = shouldUseHorizontalLabels({dimensions, ...rest});
108
- const paddingBottom = getPaddingBottom(insets);
109
-
110
- if (
111
- Platform.OS === 'ios' &&
112
- !Platform.isPad &&
113
- isLandscape &&
114
- horizontalLabels
115
- ) {
116
- return COMPACT_TABBAR_HEIGHT + paddingBottom;
117
- }
118
-
119
- return DEFAULT_TABBAR_HEIGHT + paddingBottom;
120
- };
121
-
122
88
  export default function BottomTabBar({
123
89
  state,
124
90
  navigation,
@@ -409,7 +375,7 @@ export default function BottomTabBar({
409
375
  position: isTabBarHidden ? 'absolute' : (null as any),
410
376
  },
411
377
  {
412
- paddingBottom: paddingBottom - 0,
378
+ paddingBottom: paddingBottom,
413
379
  paddingHorizontal: Math.max(insets.left, insets.right),
414
380
  },
415
381
  style,
@@ -464,7 +430,6 @@ const styles = StyleSheet.create({
464
430
  justifyContent: 'center',
465
431
  height: 48,
466
432
  width: 48,
467
-
468
433
  borderRadius: 100,
469
434
  top: -12,
470
435
  },
@@ -75,7 +75,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
75
75
  )}
76
76
  tabBarOptions={{
77
77
  style: {
78
- height: 68 + Math.min(insets.bottom, 21),
78
+ height: 64 + Math.min(insets.bottom, 21),
79
79
  },
80
80
  tabStyle: {
81
81
  height: 68,
@@ -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
 
@@ -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,33 @@ 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
+ if (value !== lastOffset.current) {
49
+ const direction = value > lastOffset.current ? 'down' : 'up';
48
50
  lastOffset.current = value;
49
- if (down) {
50
- Animated.timing(widthAnimated!, {
51
- toValue: minWidth,
52
- duration: 300,
53
- useNativeDriver: false,
54
- }).start(() => setShowText(false));
55
- } else {
56
- Animated.timing(widthAnimated!, {
57
- toValue: maxWidth.current,
58
- duration: 300,
59
- useNativeDriver: false,
60
- }).start(() => setShowText(true));
51
+ if (lastDirection.current !== direction) {
52
+ lastDirection.current = direction;
53
+ if (direction === 'down') {
54
+ Animated.timing(widthAnimated!, {
55
+ toValue: minWidth,
56
+ duration: 200,
57
+ useNativeDriver: false,
58
+ }).start(() => setShowText(false));
59
+ } else {
60
+ Animated.timing(widthAnimated!, {
61
+ toValue: maxWidth.current,
62
+ duration: 200,
63
+ useNativeDriver: false,
64
+ }).start(() => setShowText(true));
65
+ }
61
66
  }
62
- }, 500);
67
+ }
63
68
  });
64
69
 
65
70
  return () => {
@@ -76,6 +81,23 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
76
81
  setWidthAnimated(new Animated.Value(layout.width));
77
82
  };
78
83
 
84
+ if (renderComponent) {
85
+ return (
86
+ <View
87
+ onLayout={handleLayout}
88
+ style={[
89
+ styles.container,
90
+ {
91
+ right: position === 'right' ? 12 : undefined,
92
+ alignSelf: position === 'center' ? 'center' : 'flex-end',
93
+ bottom,
94
+ },
95
+ ]}>
96
+ {renderComponent()}
97
+ </View>
98
+ );
99
+ }
100
+
79
101
  return (
80
102
  <Animated.View
81
103
  onLayout={handleLayout}
@@ -102,6 +124,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
102
124
  <Text
103
125
  style={styles.label}
104
126
  color="white"
127
+ numberOfLines={1}
105
128
  typography="action_default_bold">
106
129
  {label}
107
130
  </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,8 +234,9 @@ const Screen = forwardRef(
239
234
  },
240
235
  ],
241
236
  {
242
- useNativeDriver: false,
237
+ useNativeDriver: true,
243
238
  listener: (e: NativeSyntheticEvent<NativeScrollEvent>) => {
239
+ scrollViewProps?.onScroll?.(e);
244
240
  if (animatedHeader?.type == 'surface') {
245
241
  const offsetY = e.nativeEvent.contentOffset.y;
246
242
  let color = Colors.black_01;
@@ -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-optimzie.4",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},