@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.
@@ -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
@@ -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
- return size;
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
- return size;
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.159.1-beta.4",
3
+ "version": "0.159.1-beta.5",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},