@momo-kits/foundation 0.159.1-beta.5 → 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.
- package/Application/NavigationContainer.tsx +9 -22
- package/Application/types.ts +0 -1
- package/Context/index.ts +0 -4
- package/Text/utils.ts +16 -42
- package/package.json +34 -34
- package/Application/ScaleSizeProvider.tsx +0 -16
|
@@ -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
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
);
|
package/Application/types.ts
CHANGED
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
|
};
|
package/Text/utils.ts
CHANGED
|
@@ -1,62 +1,36 @@
|
|
|
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;
|
|
7
7
|
const MAX_FONT_SCALE = 1.2;
|
|
8
|
-
const MAX_DEVICE_SCALE = 5;
|
|
9
8
|
|
|
10
|
-
const useScaleSize = (size: number
|
|
11
|
-
const { scaleSizeMaxRate = MAX_FONT_SCALE } = useContext(ScaleSizeContext);
|
|
12
|
-
const fontScale = PixelRatio.getFontScale();
|
|
9
|
+
const useScaleSize = (size: number) => {
|
|
13
10
|
const { width } = useWindowDimensions();
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
const context = useContext<any>(MiniAppContext);
|
|
12
|
+
const allowFontScale = context?.features?.allowFontScale ?? true;
|
|
13
|
+
if (!allowFontScale) return size;
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (deviceScale > 1) {
|
|
22
|
-
fontSizeDeviceScale = Math.min(
|
|
23
|
-
fontSizeDeviceScale * deviceScale,
|
|
24
|
-
fontSizeDeviceScale + MAX_DEVICE_SCALE,
|
|
25
|
-
);
|
|
26
|
-
}
|
|
15
|
+
const deviceScale = width / DEFAULT_SCREEN_SIZE;
|
|
16
|
+
const fontScale = PixelRatio.getFontScale();
|
|
27
17
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
fontSizeOSScale * maxScaleRate,
|
|
32
|
-
);
|
|
33
|
-
}
|
|
18
|
+
const maxSize = size * MAX_FONT_SCALE;
|
|
19
|
+
const fontSizeScaleDevice = deviceScale > 1 ? deviceScale * size : size;
|
|
20
|
+
const fontSizeScaleOS = fontScale > 1 ? fontScale * size : size;
|
|
34
21
|
|
|
35
|
-
return Math.max(
|
|
22
|
+
return Math.min(Math.max(fontSizeScaleDevice, fontSizeScaleOS), maxSize);
|
|
36
23
|
};
|
|
37
24
|
|
|
38
25
|
const scaleSize = (size: number) => {
|
|
39
|
-
const fontScale = PixelRatio.getFontScale();
|
|
40
26
|
const deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE;
|
|
27
|
+
const fontScale = PixelRatio.getFontScale();
|
|
41
28
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (deviceScale > 1) {
|
|
46
|
-
fontSizeDeviceScale = Math.min(
|
|
47
|
-
fontSizeDeviceScale * deviceScale,
|
|
48
|
-
fontSizeDeviceScale + MAX_DEVICE_SCALE,
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (fontScale > 1) {
|
|
53
|
-
fontSizeOSScale = Math.min(
|
|
54
|
-
fontSizeOSScale * fontScale,
|
|
55
|
-
fontSizeOSScale * MAX_FONT_SCALE,
|
|
56
|
-
);
|
|
57
|
-
}
|
|
29
|
+
const maxSize = size * MAX_FONT_SCALE;
|
|
30
|
+
const fontSizeScaleDevice = deviceScale > 1 ? deviceScale * size : size;
|
|
31
|
+
const fontSizeScaleOS = fontScale > 1 ? fontScale * size : size;
|
|
58
32
|
|
|
59
|
-
return Math.max(
|
|
33
|
+
return Math.min(Math.max(fontSizeScaleDevice, fontSizeScaleOS), maxSize);
|
|
60
34
|
};
|
|
61
35
|
|
|
62
36
|
export { scaleSize, useScaleSize };
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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;
|