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

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.
@@ -40,7 +40,7 @@ kotlin {
40
40
  }
41
41
 
42
42
  cocoapods {
43
- version = "0.160.1-beta.5-debug"
43
+ version = "0.160.1-beta.6-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -94,6 +94,7 @@ val ApplicationContext = staticCompositionLocalOf<MiniAppContext?> {
94
94
 
95
95
  var IsShowBaseLineDebug = false
96
96
 
97
+ var UseFontScaleSystem = true
97
98
  val AppConfig = staticCompositionLocalOf<KitConfig?> {
98
99
  null
99
100
  }
@@ -11,7 +11,7 @@ import androidx.compose.ui.unit.*
11
11
  import org.jetbrains.compose.resources.Font
12
12
  import org.jetbrains.compose.resources.FontResource
13
13
  import org.jetbrains.compose.resources.InternalResourceApi
14
- import vn.momo.kits.application.IsShowBaseLineDebug
14
+ import vn.momo.kits.application.UseFontScaleSystem
15
15
  import vn.momo.kits.platform.getScreenDimensions
16
16
  import vn.momo.uikits.resources.Res
17
17
  import vn.momo.uikits.resources.momosignature
@@ -33,17 +33,19 @@ const val MAX_FONT_SCALE = 1.2f
33
33
 
34
34
  @Composable
35
35
  fun scaleSize(size: Float): Float {
36
- if (!IsShowBaseLineDebug) return size
36
+ if (UseFontScaleSystem) {
37
+ val deviceWidth = getScreenDimensions().width
38
+ val deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE
39
+ val fontScale = LocalDensity.current.fontScale
37
40
 
38
- val deviceWidth = getScreenDimensions().width
39
- val deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE
40
- val fontScale = LocalDensity.current.fontScale
41
+ val maxSize = size * MAX_FONT_SCALE
42
+ val fontSizeScaleDevice = if (deviceScale > 1) deviceScale * size else size
43
+ val fontSizeScaleOS = if (fontScale > 1) fontScale * size else size
41
44
 
42
- val maxSize = size * MAX_FONT_SCALE
43
- val fontSizeScaleDevice = if (deviceScale > 1) deviceScale * size else size
44
- val fontSizeScaleOS = if (fontScale > 1) fontScale * size else size
45
+ return min(max(fontSizeScaleDevice, fontSizeScaleOS), maxSize)
46
+ }
45
47
 
46
- return min(max(fontSizeScaleDevice, fontSizeScaleOS), maxSize)
48
+ return size
47
49
  }
48
50
 
49
51
  @Composable
@@ -18,7 +18,7 @@ androidx-appcompat = "1.7.0"
18
18
  material = "1.10.0"
19
19
  maxapi = "0.1.1"
20
20
  vanniktechMavenPublish = "0.34.0"
21
- kits = "0.160.1-beta.5"
21
+ kits = "0.160.1-beta.6"
22
22
  nativemaxapi = "0.0.6"
23
23
 
24
24
  [libraries]
package/gradle.properties CHANGED
@@ -18,7 +18,7 @@ kotlin.apple.xcodeCompatibility.nowarn=true
18
18
  name="ComposeKits"
19
19
  group=vn.momo.kits
20
20
  artifact.id=kits
21
- version=0.160.1-beta.5
21
+ version=0.160.1-beta.6
22
22
 
23
23
  repo=GitLab
24
24
  url=https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven
@@ -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-debug",
3
+ "version": "0.160.1-beta.6-debug",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},