@momo-kits/native-kits 0.160.1-beta.5 → 0.160.1-beta.6

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.
@@ -17,7 +17,7 @@ public class MiniAppContext {
17
17
  public var toolkitConfig: [String: Any] = [:]
18
18
  public var providerId: String = "momo"
19
19
  public var permissions: [[String: Any]] = []
20
-
20
+
21
21
  public init(appId: String, appCode: String, appName: Any? = nil, appIcon: String, description: Any? = nil, support: [String: Any] = [:], toolkitConfig: [String: Any] = [:], providerId: String = "momo", permissions: [[String: Any]] = []) {
22
22
  self.appId = appId
23
23
  self.appCode = appCode
@@ -39,11 +39,13 @@ public class KitConfig {
39
39
 
40
40
  public var IsShowBaseLineDebug = false
41
41
 
42
+ public var UseFontScaleSystem = true
43
+
42
44
  public class ApplicationEnvironment: ObservableObject {
43
45
  let applicationContext: MiniAppContext?
44
46
  let composeApi: KitComposeApi?
45
47
  let config: KitConfig?
46
-
48
+
47
49
  public init(applicationContext: MiniAppContext? = nil, composeApi: KitComposeApi? = nil, config: KitConfig? = nil) {
48
50
  self.applicationContext = applicationContext
49
51
  self.composeApi = composeApi
@@ -4,20 +4,22 @@ private let DEFAULT_SCREEN_SIZE: CGFloat = 375
4
4
  private let MAX_FONT_SCALE: CGFloat = 1.2
5
5
 
6
6
  public func scaleSize(_ size: CGFloat) -> CGFloat {
7
- if IsShowBaseLineDebug { return size }
7
+ if UseFontScaleSystem {
8
+ let deviceWidth = UIScreen.main.bounds.width
9
+ let deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE
8
10
 
9
- let deviceWidth = UIScreen.main.bounds.width
10
- let deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE
11
+ let defaultFont = UIFont.systemFont(ofSize: UIFont.labelFontSize)
12
+ let scaledFont = UIFontMetrics.default.scaledFont(for: defaultFont)
13
+ let fontScale = scaledFont.pointSize / defaultFont.pointSize
11
14
 
12
- let defaultFont = UIFont.systemFont(ofSize: UIFont.labelFontSize)
13
- let scaledFont = UIFontMetrics.default.scaledFont(for: defaultFont)
14
- let fontScale = scaledFont.pointSize / defaultFont.pointSize
15
+ let maxSize = size * MAX_FONT_SCALE
16
+ let fontSizeScaleDevice = deviceScale > 1 ? deviceScale * size : size
17
+ let fontSizeScaleOS = fontScale > 1 ? fontScale * size : size
15
18
 
16
- let maxSize = size * MAX_FONT_SCALE
17
- let fontSizeScaleDevice = deviceScale > 1 ? deviceScale * size : size
18
- let fontSizeScaleOS = fontScale > 1 ? fontScale * size : size
19
+ return min(max(fontSizeScaleDevice, fontSizeScaleOS), maxSize)
20
+ }
19
21
 
20
- return min(max(fontSizeScaleDevice, fontSizeScaleOS), maxSize)
22
+ return size
21
23
  }
22
24
 
23
25
  public enum TypographyStyle {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.160.1-beta.5",
3
+ "version": "0.160.1-beta.6",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},