@momo-kits/native-kits 0.117.1-beta.12 → 0.117.1-beta.20

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.
@@ -110,8 +110,7 @@ fun PopupNotify(
110
110
  image.ifNotNull(
111
111
  Image(
112
112
  source = image,
113
- modifier = Modifier.fillMaxWidth().aspectRatio(1.777f),
114
- options = Options(alignment = Alignment.Center)
113
+ modifier = Modifier.fillMaxWidth().aspectRatio(1.777f)
115
114
  ), null
116
115
  )
117
116
 
@@ -42,7 +42,7 @@ fun PopupPromotion(
42
42
  indication = null,
43
43
  onClick = onPress
44
44
  ),
45
- options = Options(alignment = Alignment.Center, contentScale = ContentScale.Crop)
45
+ options = Options(alignment = Alignment.Center, contentScale = ContentScale.Fit)
46
46
  )
47
47
  }
48
48
  Box(
@@ -2,6 +2,7 @@ package vn.momo.kits.const
2
2
 
3
3
  import androidx.compose.runtime.Composable
4
4
  import androidx.compose.runtime.Immutable
5
+ import androidx.compose.ui.platform.LocalDensity
5
6
  import androidx.compose.ui.text.TextStyle
6
7
  import androidx.compose.ui.text.font.FontFamily
7
8
  import androidx.compose.ui.text.font.FontWeight
@@ -12,17 +13,31 @@ import org.jetbrains.compose.resources.FontResource
12
13
  import org.jetbrains.compose.resources.InternalResourceApi
13
14
  import org.jetbrains.compose.resources.ResourceItem
14
15
  import vn.momo.kits.platform.getScreenDimensions
16
+ import kotlin.math.min
15
17
 
16
18
  const val DEFAULT_SCREEN_SIZE = 375f
19
+ const val MAX_FONT_SCALE = 1.5f
20
+ const val MAX_DEVICE_SCALE = 5
17
21
 
18
22
  @Composable
19
23
  fun scaleSize(size: Float): Float {
20
24
  val deviceWidth = getScreenDimensions().width
21
- val scaleRate = deviceWidth / DEFAULT_SCREEN_SIZE
22
- if (scaleRate > 1) {
23
- return if ((scaleRate * size) > (size + 5)) size + 5 else scaleRate * size
25
+ val deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE
26
+
27
+ val density = LocalDensity.current
28
+ val fontScale = density.fontScale
29
+
30
+ var fontSize = size / fontScale //To ignore OS scale
31
+
32
+ if (deviceScale > 1) {
33
+ fontSize = min(deviceScale * fontSize, fontSize + MAX_DEVICE_SCALE)
24
34
  }
25
- return size
35
+
36
+ if (fontScale > 1) {
37
+ fontSize = min(fontScale * fontSize, fontSize * MAX_FONT_SCALE)
38
+ }
39
+
40
+ return fontSize
26
41
  }
27
42
 
28
43
  @OptIn(InternalResourceApi::class)
@@ -6,7 +6,6 @@ import SwiftUI
6
6
  public enum PopupButtonDirection {
7
7
  case row
8
8
  case column
9
- case auto
10
9
  }
11
10
 
12
11
  // MARK: - PopupButtonType
@@ -39,10 +38,6 @@ public struct PopupDisplay: View {
39
38
  // MARK: Public
40
39
 
41
40
  public var body: some View {
42
- var shouldUseColumn: Bool {
43
- buttonDirection == .column || (buttonDirection == .auto && (closeButtonTitle.count > 12 || actionButtonTitle.count > 12))
44
- }
45
-
46
41
  VStack(spacing: 12) {
47
42
  ZStack(alignment: .topTrailing) {
48
43
  SwiftUI.Button(action: onClose) {
@@ -99,17 +94,17 @@ public struct PopupDisplay: View {
99
94
  .padding(.horizontal, 24)
100
95
  .padding(.bottom, 16)
101
96
 
102
- if shouldUseColumn {
97
+ if buttonDirection == .row {
103
98
  if buttonType == .text {
104
- ColumnTextButtons
99
+ RowTextButtons
105
100
  } else {
106
- ColumnButtons
101
+ RowButtons
107
102
  }
108
103
  } else {
109
104
  if buttonType == .text {
110
- RowTextButtons
105
+ ColumnTextButtons
111
106
  } else {
112
- RowButtons
107
+ ColumnButtons
113
108
  }
114
109
  }
115
110
 
@@ -27,9 +27,8 @@ public struct PopupPromotion: View {
27
27
  .frame(maxWidth: UIScreen.main.bounds.width - Spacing.XL * 2)
28
28
  .clipped()
29
29
  }
30
- .scaledToFill()
31
30
  .aspectRatio(0.72, contentMode: .fit)
32
- .frame(maxWidth: UIScreen.main.bounds.width - Spacing.XL * 2, alignment: .center)
31
+ .frame(maxWidth: UIScreen.main.bounds.width - Spacing.XL * 2)
33
32
  .clipped()
34
33
  .onTapGesture {
35
34
  onAction?()
@@ -2,7 +2,28 @@ import SwiftUI
2
2
 
3
3
  public extension Font {
4
4
  static func appFont(size: CGFloat) -> Font {
5
- return Font.system(size: size)
5
+ let defaultScreenSize: CGFloat = 375
6
+ let maxFontScale: CGFloat = 10
7
+ let maxDeviceScale: CGFloat = 5
8
+
9
+ let deviceWidth = UIScreen.main.bounds.width
10
+ let deviceScale = deviceWidth / defaultScreenSize
11
+
12
+ let defaultFont = UIFont.systemFont(ofSize: UIFont.labelFontSize)
13
+ let scaledFont = UIFontMetrics.default.scaledFont(for: defaultFont)
14
+ let fontScale = scaledFont.pointSize / defaultFont.pointSize
15
+
16
+ var fontSize = size
17
+
18
+ if deviceScale > 1 {
19
+ fontSize = min(fontSize * deviceScale, fontSize + maxDeviceScale)
20
+ }
21
+
22
+ if fontScale > 1 {
23
+ fontSize = min(fontSize * fontScale, fontSize * maxFontScale)
24
+ }
25
+
26
+ return Font.system(size: fontSize)
6
27
  }
7
28
 
8
29
  // New supported typography styles
package/local.properties CHANGED
@@ -4,5 +4,5 @@
4
4
  # Location of the SDK. This is only used by Gradle.
5
5
  # For customization when using a Version Control System, please read the
6
6
  # header note.
7
- #Thu Jan 09 10:43:10 ICT 2025
8
- sdk.dir=/Users/sophia/Library/Android/sdk
7
+ #Tue Apr 08 11:13:31 ICT 2025
8
+ sdk.dir=/Users/sonnguyen/Library/Android/sdk
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.117.1-beta.12",
3
+ "version": "0.117.1-beta.20",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},