@momo-kits/foundation 0.159.1-beta.4 → 0.159.1-beta.5
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/Popup/PopupPromotion.tsx +1 -1
- package/Text/utils.ts +47 -3
- package/package.json +1 -1
package/Popup/PopupPromotion.tsx
CHANGED
package/Text/utils.ts
CHANGED
|
@@ -7,12 +7,56 @@ const DEFAULT_SCREEN_SIZE = 375;
|
|
|
7
7
|
const MAX_FONT_SCALE = 1.2;
|
|
8
8
|
const MAX_DEVICE_SCALE = 5;
|
|
9
9
|
|
|
10
|
-
const useScaleSize = (size: number) => {
|
|
11
|
-
|
|
10
|
+
const useScaleSize = (size: number, scaleRate?: number) => {
|
|
11
|
+
const { scaleSizeMaxRate = MAX_FONT_SCALE } = useContext(ScaleSizeContext);
|
|
12
|
+
const fontScale = PixelRatio.getFontScale();
|
|
13
|
+
const { width } = useWindowDimensions();
|
|
14
|
+
const deviceScale = width / DEFAULT_SCREEN_SIZE;
|
|
15
|
+
|
|
16
|
+
const maxScaleRate = scaleRate ?? scaleSizeMaxRate;
|
|
17
|
+
|
|
18
|
+
let fontSizeDeviceScale = size;
|
|
19
|
+
let fontSizeOSScale = size;
|
|
20
|
+
|
|
21
|
+
if (deviceScale > 1) {
|
|
22
|
+
fontSizeDeviceScale = Math.min(
|
|
23
|
+
fontSizeDeviceScale * deviceScale,
|
|
24
|
+
fontSizeDeviceScale + MAX_DEVICE_SCALE,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (fontScale > 1) {
|
|
29
|
+
fontSizeOSScale = Math.min(
|
|
30
|
+
fontSizeOSScale * fontScale,
|
|
31
|
+
fontSizeOSScale * maxScaleRate,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return Math.max(fontSizeDeviceScale, fontSizeOSScale);
|
|
12
36
|
};
|
|
13
37
|
|
|
14
38
|
const scaleSize = (size: number) => {
|
|
15
|
-
|
|
39
|
+
const fontScale = PixelRatio.getFontScale();
|
|
40
|
+
const deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE;
|
|
41
|
+
|
|
42
|
+
let fontSizeDeviceScale = size;
|
|
43
|
+
let fontSizeOSScale = size;
|
|
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
|
+
}
|
|
58
|
+
|
|
59
|
+
return Math.max(fontSizeDeviceScale, fontSizeOSScale);
|
|
16
60
|
};
|
|
17
61
|
|
|
18
62
|
export { scaleSize, useScaleSize };
|