@momo-kits/foundation 0.151.1-beta.4-sp.5 → 0.151.1-beta.6

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.
@@ -240,7 +240,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
240
240
  onDismiss();
241
241
  }}
242
242
  style={StyleSheet.absoluteFillObject}
243
- isModalKit={true}
244
243
  >
245
244
  <KeyboardAvoidingView
246
245
  behavior={Platform.select({
@@ -77,18 +77,6 @@ export function Badge({
77
77
  const borderRadius = size / 2;
78
78
  const fontSize = Math.floor((size * 3) / 4);
79
79
 
80
- const isNumber = () => {
81
- const numberRegex = /^\d+$/;
82
- return numberRegex.test(String(children));
83
- };
84
-
85
- const formatTitle = () => {
86
- if (isNumber() && Number(children) > 99) {
87
- return '99+';
88
- }
89
- return children;
90
- };
91
-
92
80
  return (
93
81
  <Animated.Text
94
82
  numberOfLines={1}
@@ -115,9 +103,8 @@ export function Badge({
115
103
  styles.container,
116
104
  restStyle,
117
105
  ]}
118
- {...rest}
119
- >
120
- {formatTitle()}
106
+ {...rest}>
107
+ {children}
121
108
  </Animated.Text>
122
109
  );
123
110
  }
@@ -5,7 +5,13 @@ import {
5
5
  useFocusEffect,
6
6
  } from '@react-navigation/native';
7
7
  import { createStackNavigator } from '@react-navigation/stack';
8
- import React, { useContext, useEffect, useLayoutEffect, useRef } from 'react';
8
+ import React, {
9
+ useCallback,
10
+ useContext,
11
+ useEffect,
12
+ useLayoutEffect,
13
+ useRef,
14
+ } from 'react';
9
15
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
10
16
  import {
11
17
  Animated,
@@ -21,7 +27,7 @@ import { exportFontFamily, Text } from '../../Text';
21
27
  import { ApplicationContext, MiniAppContext } from '../index';
22
28
  import StackScreen from '../StackScreen';
23
29
  import { BottomTabProps } from '../types';
24
- import { getOptions, getStackOptions, useAppState } from '../utils';
30
+ import { getOptions, getStackOptions } from '../utils';
25
31
  import BottomTabBar from './BottomTabBar';
26
32
 
27
33
  const Tab = createBottomTabNavigator();
@@ -38,10 +44,9 @@ const TabScreen: React.FC<any> = ({ route, navigation }) => {
38
44
  const opacity = useRef(new Animated.Value(opacityValue)).current;
39
45
  const scale = useRef(new Animated.Value(scaleValue)).current;
40
46
  const screenName = screen?.name || screen?.type?.name || 'Invalid';
41
- const { isBackgroundToForeground } = useAppState();
42
47
 
43
- const onScreenNavigated = (pre: string, current: string) => {
44
- if (!isBackgroundToForeground) {
48
+ const onScreenNavigated = useCallback(
49
+ (pre: string, current: string) => {
45
50
  const data: any = {
46
51
  preScreenName: pre,
47
52
  screenName: current,
@@ -63,8 +68,9 @@ const TabScreen: React.FC<any> = ({ route, navigation }) => {
63
68
  message: `${screenName} screen_navigated`,
64
69
  type: 'ERROR',
65
70
  });
66
- }
67
- };
71
+ },
72
+ [context, navigator?.maxApi, screenName],
73
+ );
68
74
 
69
75
  useFocusEffect(
70
76
  React.useCallback(
@@ -107,7 +107,6 @@ const Modal: React.FC<ModalParams> = props => {
107
107
  visible={true}
108
108
  onRequestClose={onDismiss}
109
109
  style={StyleSheet.absoluteFillObject}
110
- isModalKit={true}
111
110
  >
112
111
  <KeyboardAvoidingView
113
112
  style={Styles.flexCenter}
@@ -47,7 +47,20 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
47
47
  const context = useContext<any>(MiniAppContext);
48
48
  const [currentContext, setCurrentContext] = useState({});
49
49
  return (
50
- <SafeAreaProvider>
50
+ <SafeAreaProvider initialMetrics={{
51
+ insets: {
52
+ top: 0,
53
+ bottom: 0,
54
+ left:0,
55
+ right: 0,
56
+ },
57
+ frame: {
58
+ width: 0,
59
+ height: 0,
60
+ x: 0,
61
+ y: 0,
62
+ }
63
+ }}>
51
64
  <MiniAppContext.Provider
52
65
  value={{
53
66
  ...context,
@@ -6,7 +6,6 @@ import Navigation from './Navigation';
6
6
  import { ApplicationContext, MiniAppContext, ScreenContext } from './index';
7
7
  import { GridSystem } from '../Layout';
8
8
  import { version } from '../package.json';
9
- import { useAppState } from './utils';
10
9
 
11
10
  const runAfterInteractions = InteractionManager.runAfterInteractions;
12
11
 
@@ -49,7 +48,6 @@ const StackScreen: React.FC<any> = props => {
49
48
  } = props.route.params;
50
49
  const navigation = useRef(new Navigation(props.navigation, context)).current;
51
50
  const heightHeader = useHeaderHeight();
52
- const { isBackgroundToForeground } = useAppState();
53
51
 
54
52
  const data = {
55
53
  ...initialParams,
@@ -142,31 +140,29 @@ const StackScreen: React.FC<any> = props => {
142
140
  }, []);
143
141
 
144
142
  const onScreenNavigated = (pre: string, current: string) => {
145
- if (!isBackgroundToForeground) {
146
- const item: any = {
147
- preScreenName: pre,
148
- screenName: current,
149
- componentName: 'Screen',
150
- state: 'navigated',
151
- action: tracking.current?.mounted ? 'back' : 'push',
152
- };
153
-
154
- context?.autoTracking?.({
155
- ...context,
156
- ...item,
157
- });
158
-
159
- tracking.current.mounted = true;
143
+ const item: any = {
144
+ preScreenName: pre,
145
+ screenName: current,
146
+ componentName: 'Screen',
147
+ state: 'navigated',
148
+ action: tracking.current?.mounted ? 'back' : 'push',
149
+ };
160
150
 
161
- /**
162
- * debug toast
163
- */
164
- navigator?.maxApi?.showToastDebug?.({
165
- appId: context.appId,
166
- message: `${screenName} screen_navigated`,
167
- type: 'ERROR',
168
- });
169
- }
151
+ context?.autoTracking?.({
152
+ ...context,
153
+ ...item,
154
+ });
155
+
156
+ tracking.current.mounted = true;
157
+
158
+ /**
159
+ * debug toast
160
+ */
161
+ navigator?.maxApi?.showToastDebug?.({
162
+ appId: context.appId,
163
+ message: `${screenName} screen_navigated`,
164
+ type: 'ERROR',
165
+ });
170
166
  };
171
167
 
172
168
  /**
@@ -69,7 +69,22 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
69
69
 
70
70
  return (
71
71
  <View style={{ height: height ?? '100%' }}>
72
- <SafeAreaProvider>
72
+ <SafeAreaProvider
73
+ initialMetrics={{
74
+ insets: {
75
+ top: 0,
76
+ bottom: 0,
77
+ left: 0,
78
+ right: 0,
79
+ },
80
+ frame: {
81
+ width: 0,
82
+ height: 0,
83
+ x: 0,
84
+ y: 0,
85
+ },
86
+ }}
87
+ >
73
88
  <MiniAppContext.Provider
74
89
  value={{
75
90
  ...context,
@@ -1,4 +1,4 @@
1
- import React, { useContext, useEffect, useMemo, useRef } from 'react';
1
+ import React, { useContext, useMemo } from 'react';
2
2
  import {
3
3
  StackNavigationOptions,
4
4
  TransitionPresets,
@@ -12,7 +12,7 @@ import {
12
12
  } from './Components';
13
13
  import { HeaderTitleProps, NavigationOptions } from './types';
14
14
  import { Colors, Spacing } from '../Consts';
15
- import { Animated, AppState, Platform } from 'react-native';
15
+ import { Animated, Platform } from 'react-native';
16
16
  import { MiniAppContext, ScreenContext, TrackingScopeContext } from './index';
17
17
 
18
18
  /**
@@ -205,36 +205,6 @@ export const getImageName = (source: any): string => {
205
205
  return '';
206
206
  };
207
207
 
208
- const useAppState = () => {
209
- const isBackgroundToForeground = useRef(false);
210
- const appState = useRef(AppState.currentState);
211
-
212
- useEffect(() => {
213
- const subscription = AppState.addEventListener('change', nextAppState => {
214
- isBackgroundToForeground.current = !!(
215
- appState.current.match(/inactive|background/) &&
216
- nextAppState === 'active'
217
- );
218
- appState.current = nextAppState;
219
-
220
- if (isBackgroundToForeground.current) {
221
- setTimeout(() => {
222
- isBackgroundToForeground.current = false;
223
- }, 100);
224
- }
225
- });
226
-
227
- return () => {
228
- subscription.remove();
229
- };
230
- }, []);
231
-
232
- return {
233
- isBackgroundToForeground: isBackgroundToForeground.current,
234
- appState: appState.current,
235
- };
236
- };
237
-
238
208
  export {
239
209
  getStackOptions,
240
210
  getModalOptions,
@@ -242,5 +212,4 @@ export {
242
212
  exportHeaderTitle,
243
213
  setAutomationID,
244
214
  useComponentId,
245
- useAppState,
246
215
  };
package/Input/Input.tsx CHANGED
@@ -85,7 +85,6 @@ const Input = forwardRef(
85
85
 
86
86
  const onClearText = () => {
87
87
  inputRef?.current?.clear();
88
- inputRef.current?.setNativeProps({ text: '' });
89
88
  _onChangeText('');
90
89
  };
91
90
 
@@ -122,7 +122,6 @@ const InputMoney = forwardRef(
122
122
 
123
123
  const onClearText = () => {
124
124
  inputRef?.current?.clear();
125
- inputRef.current?.setNativeProps({ text: '' });
126
125
  setDisplayValue('');
127
126
  setNumericValue('');
128
127
  onChangeText?.('');
@@ -166,7 +166,6 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
166
166
 
167
167
  const onClearText = () => {
168
168
  inputRef?.current?.clear();
169
- inputRef.current?.setNativeProps({ text: '' });
170
169
  _onChangeText('');
171
170
  };
172
171
 
@@ -62,7 +62,6 @@ const InputTextArea = forwardRef(
62
62
 
63
63
  const onClearText = () => {
64
64
  inputRef?.current?.clear();
65
- inputRef.current?.setNativeProps({ text: '' });
66
65
  _onChangeText('');
67
66
  };
68
67
 
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
1
  {
2
- "name": "@momo-kits/foundation",
3
- "version": "0.151.1-beta.4-sp.5",
4
- "description": "React Native Component Kits",
5
- "main": "index.ts",
6
- "scripts": {},
7
- "keywords": [
8
- "@momo-kits/foundation"
9
- ],
10
- "dependencies": {
11
- "react-native-fast-image": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-fast-image.git#v8.11.0",
12
- "@react-navigation/bottom-tabs": "7.4.2",
13
- "@react-navigation/core": "7.12.1",
14
- "@react-navigation/elements": "2.5.2",
15
- "@react-navigation/native": "7.1.14",
16
- "@react-navigation/routers": "7.4.1",
17
- "@react-navigation/stack": "7.4.2",
18
- "react-native-gesture-handler": "2.27.1",
19
- "react-native-linear-gradient": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-linear-gradient#v3.0.0",
20
- "react-native-reanimated": "4.1.0",
21
- "react-native-safe-area-context": "5.5.2",
22
- "@shopify/flash-list": "2.1.0"
23
- },
24
- "peerDependencies": {
25
- "react-native": "*"
26
- },
27
- "devDependencies": {
28
- "@momo-platform/versions": "4.1.11",
29
- "@types/color": "3.0.6"
30
- },
31
- "publishConfig": {
32
- "registry": "https://registry.npmjs.org/"
33
- },
34
- "license": "MoMo"
35
- }
2
+ "name": "@momo-kits/foundation",
3
+ "version": "0.151.1-beta.6",
4
+ "description": "React Native Component Kits",
5
+ "main": "index.ts",
6
+ "scripts": {},
7
+ "keywords": [
8
+ "@momo-kits/foundation"
9
+ ],
10
+ "dependencies": {
11
+ "react-native-fast-image": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-fast-image.git#v8.11.0",
12
+ "@react-navigation/bottom-tabs": "7.4.2",
13
+ "@react-navigation/core": "7.12.1",
14
+ "@react-navigation/elements": "2.5.2",
15
+ "@react-navigation/native": "7.1.14",
16
+ "@react-navigation/routers": "7.4.1",
17
+ "@react-navigation/stack": "7.4.2",
18
+ "react-native-gesture-handler": "2.27.1",
19
+ "react-native-linear-gradient": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-linear-gradient#v3.0.0",
20
+ "react-native-reanimated": "4.1.0",
21
+ "react-native-safe-area-context": "5.5.2",
22
+ "@shopify/flash-list": "2.1.0"
23
+ },
24
+ "peerDependencies": {
25
+ "react-native": "*"
26
+ },
27
+ "devDependencies": {
28
+ "@momo-platform/versions": "4.1.11",
29
+ "@types/color": "3.0.6"
30
+ },
31
+ "publishConfig": {
32
+ "registry": "https://registry.npmjs.org/"
33
+ },
34
+ "license": "MoMo"
35
+ }