@momo-kits/foundation 0.162.2-beta.20 → 0.162.2-beta.22
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';
|
|
@@ -46,6 +45,13 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
46
45
|
const context = useContext<any>(MiniAppContext);
|
|
47
46
|
const [currentContext, setCurrentContext] = useState<any>({});
|
|
48
47
|
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const sub = maxApi?.observer?.('font_scale_config', (data: any) => {
|
|
50
|
+
setCurrentContext((prev: any) => ({ ...prev, fontScale: data }));
|
|
51
|
+
});
|
|
52
|
+
return () => sub?.remove?.();
|
|
53
|
+
}, [maxApi]);
|
|
54
|
+
|
|
49
55
|
const mergedContext = {
|
|
50
56
|
...context,
|
|
51
57
|
...currentContext,
|
|
@@ -58,17 +64,15 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
58
64
|
return (
|
|
59
65
|
<SafeAreaProvider>
|
|
60
66
|
<MiniAppContext.Provider value={mergedContext}>
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/>
|
|
71
|
-
</ScaleSizeProvider>
|
|
67
|
+
<Navigation
|
|
68
|
+
screen={screen}
|
|
69
|
+
theme={theme}
|
|
70
|
+
options={options}
|
|
71
|
+
maxApi={maxApi}
|
|
72
|
+
setCurrentContext={setCurrentContext}
|
|
73
|
+
initialParams={initialParams}
|
|
74
|
+
localize={localize}
|
|
75
|
+
/>
|
|
72
76
|
</MiniAppContext.Provider>
|
|
73
77
|
</SafeAreaProvider>
|
|
74
78
|
);
|
|
@@ -2,6 +2,7 @@ import React, { FC } from 'react';
|
|
|
2
2
|
import { ScaleSizeContext } from '../Context';
|
|
3
3
|
import { ScaleSizeProviderProps } from './types';
|
|
4
4
|
|
|
5
|
+
/** @deprecated Max font scale is fixed at 1.5; this provider no longer affects scaling. */
|
|
5
6
|
const ScaleSizeProvider: FC<ScaleSizeProviderProps> = ({
|
|
6
7
|
scaleSizeMaxRate,
|
|
7
8
|
children,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext, useRef, useState } from 'react';
|
|
1
|
+
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
3
3
|
import Navigator from './Navigator';
|
|
4
4
|
import ScaleSizeProvider from './ScaleSizeProvider';
|
|
@@ -44,6 +44,13 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
44
44
|
const navigator = useRef(new Navigator(navigationRef, isReady, true));
|
|
45
45
|
const [currentContext, setCurrentContext] = useState({});
|
|
46
46
|
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const sub = maxApi?.observer?.('font_scale_config', (data: any) => {
|
|
49
|
+
setCurrentContext((prev: any) => ({ ...prev, fontScale: data }));
|
|
50
|
+
});
|
|
51
|
+
return () => sub?.remove?.();
|
|
52
|
+
}, [maxApi]);
|
|
53
|
+
|
|
47
54
|
let headerBackground = context?.designConfig?.headerBar;
|
|
48
55
|
let headerGradient = theme.colors?.gradient;
|
|
49
56
|
|
|
@@ -74,12 +81,9 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
74
81
|
};
|
|
75
82
|
|
|
76
83
|
return (
|
|
77
|
-
<View style={{ height: height ?? '100%', minHeight:1 }}>
|
|
84
|
+
<View style={{ height: height ?? '100%', minHeight: 1 }}>
|
|
78
85
|
<SafeAreaProvider>
|
|
79
86
|
<MiniAppContext.Provider value={mergedContext}>
|
|
80
|
-
<ScaleSizeProvider
|
|
81
|
-
scaleSizeMaxRate={mergedContext?.scaleSizeMaxRate}
|
|
82
|
-
>
|
|
83
87
|
<ApplicationContext.Provider
|
|
84
88
|
value={{
|
|
85
89
|
navigator: navigator.current,
|
|
@@ -157,7 +161,6 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
157
161
|
</ReactNavigationContainer>
|
|
158
162
|
</NavigationIndependentTree>
|
|
159
163
|
</ApplicationContext.Provider>
|
|
160
|
-
</ScaleSizeProvider>
|
|
161
164
|
</MiniAppContext.Provider>
|
|
162
165
|
</SafeAreaProvider>
|
|
163
166
|
</View>
|
package/Context/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ 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
|
+
/** @deprecated Max font scale is fixed at 1.5; this context is no longer read. */
|
|
12
13
|
const ScaleSizeContext = createContext<{ scaleSizeMaxRate?: number }>({
|
|
13
14
|
scaleSizeMaxRate: undefined,
|
|
14
15
|
});
|
package/Text/utils.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dimensions, PixelRatio, useWindowDimensions } from 'react-native';
|
|
2
2
|
import { useContext } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { MiniAppContext } from '../Context';
|
|
4
4
|
|
|
5
5
|
const deviceWidth = Dimensions.get('window').width;
|
|
6
6
|
const DEFAULT_SCREEN_SIZE = 375;
|
|
@@ -8,12 +8,15 @@ const MAX_FONT_SCALE = 1.5;
|
|
|
8
8
|
const MAX_DEVICE_SCALE = 5;
|
|
9
9
|
|
|
10
10
|
const useScaleSize = (size: number, scaleRate?: number) => {
|
|
11
|
-
const
|
|
11
|
+
const context = useContext<any>(MiniAppContext);
|
|
12
|
+
if (context?.fontScale?.useOSScaleRate === false) {
|
|
13
|
+
return size * (context.fontScale.userScaleRate ?? 1);
|
|
14
|
+
}
|
|
12
15
|
const fontScale = PixelRatio.getFontScale();
|
|
13
16
|
const { width } = useWindowDimensions();
|
|
14
17
|
const deviceScale = width / DEFAULT_SCREEN_SIZE;
|
|
15
18
|
|
|
16
|
-
const maxScaleRate = scaleRate ??
|
|
19
|
+
const maxScaleRate = scaleRate ?? MAX_FONT_SCALE;
|
|
17
20
|
|
|
18
21
|
let fontSizeDeviceScale = size;
|
|
19
22
|
let fontSizeOSScale = size;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.162.2-beta.
|
|
3
|
+
"version": "0.162.2-beta.22",
|
|
4
4
|
"description": "React Native Component Kits",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {},
|
|
@@ -8,19 +8,19 @@
|
|
|
8
8
|
"@momo-kits/foundation"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
+
"react-native-fast-image": "git+https://oauth2:k_r5y_gV6sX9-TqQxgcd@gitlab.mservice.com.vn/momo-platform/public/react-native-fast-image.git#v8.11.0",
|
|
11
12
|
"@react-navigation/bottom-tabs": "7.4.2",
|
|
12
13
|
"@react-navigation/core": "7.12.1",
|
|
13
14
|
"@react-navigation/elements": "2.5.2",
|
|
14
15
|
"@react-navigation/native": "7.1.14",
|
|
15
16
|
"@react-navigation/routers": "7.4.1",
|
|
16
17
|
"@react-navigation/stack": "7.4.2",
|
|
17
|
-
"@shopify/flash-list": "2.1.0",
|
|
18
|
-
"lottie-react-native": "7.2.4",
|
|
19
|
-
"react-native-fast-image": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-fast-image.git#v8.11.0",
|
|
20
18
|
"react-native-gesture-handler": "2.27.1",
|
|
21
|
-
"react-native-linear-gradient": "git+https://oauth2:
|
|
22
|
-
"react-native-reanimated": "4.
|
|
23
|
-
"react-native-safe-area-context": "5.5.2"
|
|
19
|
+
"react-native-linear-gradient": "git+https://oauth2:k_r5y_gV6sX9-TqQxgcd@gitlab.mservice.com.vn/momo-platform/public/react-native-linear-gradient#v3.0.0",
|
|
20
|
+
"react-native-reanimated": "4.1.3",
|
|
21
|
+
"react-native-safe-area-context": "5.5.2",
|
|
22
|
+
"@shopify/flash-list": "2.1.0",
|
|
23
|
+
"lottie-react-native": "7.2.4"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react-native": "*"
|
|
@@ -32,4 +32,4 @@
|
|
|
32
32
|
"registry": "https://registry.npmjs.org/"
|
|
33
33
|
},
|
|
34
34
|
"license": "MoMo"
|
|
35
|
-
}
|
|
35
|
+
}
|