@momo-kits/foundation 0.159.1-beta.4 → 0.160.1-beta.1

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.
@@ -16,7 +16,6 @@ import { DeviceEventEmitter } from 'react-native';
16
16
  import StackScreen from './StackScreen';
17
17
  import ModalScreen from './ModalScreen';
18
18
  import Navigator from './Navigator';
19
- import ScaleSizeProvider from './ScaleSizeProvider';
20
19
  import { getModalOptions, getStackOptions } from './utils';
21
20
  import { NavigationContainerProps } from './types';
22
21
  import { ApplicationContext, MiniAppContext } from '../Context';
@@ -36,12 +35,6 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
36
35
  maxApi,
37
36
  initialParams,
38
37
  localize = new Localize({ vi: {}, en: {} }),
39
- features = {
40
- enableBottomTabAnimation: true,
41
- enableHapticDialog: true,
42
- enableForceFoundationList: false,
43
- enableHapticBottomTab: true,
44
- },
45
38
  }) => {
46
39
  const context = useContext<any>(MiniAppContext);
47
40
  const [currentContext, setCurrentContext] = useState<any>({});
@@ -49,26 +42,20 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
49
42
  const mergedContext = {
50
43
  ...context,
51
44
  ...currentContext,
52
- features: {
53
- ...context?.features,
54
- ...features,
55
- },
56
45
  };
57
46
 
58
47
  return (
59
48
  <SafeAreaProvider>
60
49
  <MiniAppContext.Provider value={mergedContext}>
61
- <ScaleSizeProvider scaleSizeMaxRate={mergedContext?.scaleSizeMaxRate}>
62
- <Navigation
63
- screen={screen}
64
- theme={theme}
65
- options={options}
66
- maxApi={maxApi}
67
- setCurrentContext={setCurrentContext}
68
- initialParams={initialParams}
69
- localize={localize}
70
- />
71
- </ScaleSizeProvider>
50
+ <Navigation
51
+ screen={screen}
52
+ theme={theme}
53
+ options={options}
54
+ maxApi={maxApi}
55
+ setCurrentContext={setCurrentContext}
56
+ initialParams={initialParams}
57
+ localize={localize}
58
+ />
72
59
  </MiniAppContext.Provider>
73
60
  </SafeAreaProvider>
74
61
  );
@@ -158,7 +158,6 @@ export type NavigationContainerProps = {
158
158
  maxApi: any;
159
159
  initialParams?: any;
160
160
  localize: LocalizeProps;
161
- features?: FeatureFlags;
162
161
  };
163
162
 
164
163
  export type WidgetContainerProps = {
package/Context/index.ts CHANGED
@@ -9,9 +9,6 @@ const MiniAppContext = (Platform as any).MiniAppContext ?? Context;
9
9
  const ScreenContext = (Platform as any).ScreenContext ?? Context;
10
10
  const ComponentContext = (Platform as any).ComponentContext ?? Context;
11
11
  const SkeletonContext = createContext({ loading: false });
12
- const ScaleSizeContext = createContext<{ scaleSizeMaxRate?: number }>({
13
- scaleSizeMaxRate: undefined,
14
- });
15
12
  const TrackingScopeContext = createContext<{ scopeName?: string }>({
16
13
  scopeName: undefined,
17
14
  });
@@ -23,5 +20,4 @@ export {
23
20
  ComponentContext,
24
21
  SkeletonContext,
25
22
  TrackingScopeContext,
26
- ScaleSizeContext,
27
23
  };
@@ -92,7 +92,7 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
92
92
 
93
93
  const styles = StyleSheet.create({
94
94
  container: {
95
- aspectRatio: 0.5625, // 9:16
95
+ aspectRatio: 0.72,
96
96
  width: '100%',
97
97
  },
98
98
  debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
package/Text/utils.ts CHANGED
@@ -1,18 +1,36 @@
1
1
  import { Dimensions, PixelRatio, useWindowDimensions } from 'react-native';
2
2
  import { useContext } from 'react';
3
- import { ScaleSizeContext } from '../Context';
3
+ import { MiniAppContext } from '../Context';
4
4
 
5
5
  const deviceWidth = Dimensions.get('window').width;
6
6
  const DEFAULT_SCREEN_SIZE = 375;
7
7
  const MAX_FONT_SCALE = 1.2;
8
- const MAX_DEVICE_SCALE = 5;
9
8
 
10
9
  const useScaleSize = (size: number) => {
11
- return size;
10
+ const { width } = useWindowDimensions();
11
+ const context = useContext<any>(MiniAppContext);
12
+ const allowFontScale = context?.features?.allowFontScale ?? true;
13
+ if (!allowFontScale) return size;
14
+
15
+ const deviceScale = width / DEFAULT_SCREEN_SIZE;
16
+ const fontScale = PixelRatio.getFontScale();
17
+
18
+ const maxSize = size * MAX_FONT_SCALE;
19
+ const fontSizeScaleDevice = deviceScale > 1 ? deviceScale * size : size;
20
+ const fontSizeScaleOS = fontScale > 1 ? fontScale * size : size;
21
+
22
+ return Math.min(Math.max(fontSizeScaleDevice, fontSizeScaleOS), maxSize);
12
23
  };
13
24
 
14
25
  const scaleSize = (size: number) => {
15
- return size;
26
+ const deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE;
27
+ const fontScale = PixelRatio.getFontScale();
28
+
29
+ const maxSize = size * MAX_FONT_SCALE;
30
+ const fontSizeScaleDevice = deviceScale > 1 ? deviceScale * size : size;
31
+ const fontSizeScaleOS = fontScale > 1 ? fontScale * size : size;
32
+
33
+ return Math.min(Math.max(fontSizeScaleDevice, fontSizeScaleOS), maxSize);
16
34
  };
17
35
 
18
36
  export { scaleSize, useScaleSize };
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
1
  {
2
- "name": "@momo-kits/foundation",
3
- "version": "0.159.1-beta.4",
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
- "lottie-react-native": "7.2.4"
24
- },
25
- "peerDependencies": {
26
- "react-native": "*"
27
- },
28
- "devDependencies": {
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.160.1-beta.1",
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
+ "lottie-react-native": "7.2.4"
24
+ },
25
+ "peerDependencies": {
26
+ "react-native": "*"
27
+ },
28
+ "devDependencies": {
29
+ "@types/color": "3.0.6"
30
+ },
31
+ "publishConfig": {
32
+ "registry": "https://registry.npmjs.org/"
33
+ },
34
+ "license": "MoMo"
35
+ }
@@ -1,16 +0,0 @@
1
- import React, { FC } from 'react';
2
- import { ScaleSizeContext } from '../Context';
3
- import { ScaleSizeProviderProps } from './types';
4
-
5
- const ScaleSizeProvider: FC<ScaleSizeProviderProps> = ({
6
- scaleSizeMaxRate,
7
- children,
8
- }) => {
9
- return (
10
- <ScaleSizeContext.Provider value={{ scaleSizeMaxRate }}>
11
- {children}
12
- </ScaleSizeContext.Provider>
13
- );
14
- };
15
-
16
- export default ScaleSizeProvider;