@momo-kits/native-kits 0.117.1-beta.9 → 0.118.0-beta.1

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.
@@ -29,10 +29,10 @@ fun HeaderDefault(
29
29
  val height = statusBarHeight + HEADER_HEIGHT.dp
30
30
  Box(
31
31
  modifier = Modifier.fillMaxWidth().height(height)
32
- .background(backgroundColor ?: AppTheme.current.colors.background.surface)
32
+ .background(if(headerTransparent && backgroundColor != null) backgroundColor else AppTheme.current.colors.background.surface)
33
33
  .bottomBorder(
34
34
  strokeWidth = 1.dp,
35
- color = backgroundColor?: AppTheme.current.colors.border.default
35
+ color = if(headerTransparent && backgroundColor != null) backgroundColor else AppTheme.current.colors.border.default
36
36
  )
37
37
  ) {
38
38
  Box(
@@ -110,7 +110,8 @@ fun PopupNotify(
110
110
  image.ifNotNull(
111
111
  Image(
112
112
  source = image,
113
- modifier = Modifier.fillMaxWidth().aspectRatio(1.777f)
113
+ modifier = Modifier.fillMaxWidth().aspectRatio(1.777f),
114
+ options = Options(alignment = Alignment.Center)
114
115
  ), null
115
116
  )
116
117
 
@@ -42,7 +42,7 @@ fun PopupPromotion(
42
42
  indication = null,
43
43
  onClick = onPress
44
44
  ),
45
- options = Options(alignment = Alignment.Center, contentScale = ContentScale.Fit)
45
+ options = Options(alignment = Alignment.Center, contentScale = ContentScale.Crop)
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.2f
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)
@@ -46,15 +61,15 @@ fun getFont(font: String): FontFamily {
46
61
  fun getFontFamily(fontFamily: String, fontWeight: FontWeight? = FontWeight.Normal): FontFamily {
47
62
  val key = "$fontFamily-${fontWeight?.weight}"
48
63
  val fontMap = mapOf(
49
- "SFProText-100" to "sfprotext_thin.otf",
50
- "SFProText-200" to "sfprotext_ultralight.otf",
64
+ "SFProText-100" to "sfprotext_thin.ttf",
65
+ "SFProText-200" to "sfprotext_ultralight.ttf",
51
66
  "SFProText-300" to "sfprotext_light.ttf",
52
67
  "SFProText-400" to "sfprotext_regular.ttf",
53
68
  "SFProText-500" to "sfprotext_medium.ttf",
54
69
  "SFProText-600" to "sfprotext_semibold.ttf",
55
70
  "SFProText-700" to "sfprotext_bold.ttf",
56
71
  "SFProText-800" to "sfprotext_heavy.ttf",
57
- "SFProText-900" to "sfprotext_black.otf",
72
+ "SFProText-900" to "sfprotext_black.ttf",
58
73
 
59
74
  "MoMoSignature-100" to "momosignature.otf",
60
75
  "MoMoSignature-200" to "momosignature.otf",
@@ -179,14 +179,14 @@ struct ToolkitHeaderRight: View {
179
179
  }
180
180
 
181
181
  var body: some View {
182
- let backgroundButtonColor: Color = tintColor == Colors.black01 ? Color.black.opacity(0.6) : Colors.black01.opacity(0.6)
183
- let borderColor: Color = tintColor == Colors.black01 ? Color.white.opacity(0.2) : Color.black.opacity(0.2)
182
+ let backgroundButtonColor: Color = tintColor == Colors.black01 ? Colors.black20.opacity(0.6) : Colors.black01.opacity(0.6)
183
+ let borderColor: Color = tintColor == Colors.black01 ? Colors.black01.opacity(0.2) : Colors.black20.opacity(0.2)
184
184
  let navButtonConfig = getNavigationButtonConfig()
185
185
  let showBadge = headerRight?.tools.contains { group in
186
186
  group.items.contains { $0.showBadge }
187
187
  } ?? false
188
188
 
189
- HStack(alignment: .center) {
189
+ HStack(alignment: .center, spacing: 0) {
190
190
  if headerRight?.useShortcut == true {
191
191
  NavigationButton(
192
192
  disabled: isLoading,
@@ -234,8 +234,8 @@ struct NavigationButton: View {
234
234
  var tintColor: Color?
235
235
 
236
236
  var body: some View {
237
- let backgroundButtonColor: Color = tintColor == Colors.black01 ? Color.black.opacity(0.6) : Colors.black01.opacity(0.6)
238
- let borderColor: Color = tintColor == Colors.black01 ? Color.white.opacity(0.2) : Color.black.opacity(0.2)
237
+ let backgroundButtonColor: Color = tintColor == Colors.black01 ? Colors.black20.opacity(0.6) : Colors.black01.opacity(0.6)
238
+ let borderColor: Color = tintColor == Colors.black01 ? Colors.black01.opacity(0.2) : Colors.black20.opacity(0.2)
239
239
 
240
240
  ZStack {
241
241
  Circle()
@@ -6,6 +6,7 @@ import SwiftUI
6
6
  public enum PopupButtonDirection {
7
7
  case row
8
8
  case column
9
+ case auto
9
10
  }
10
11
 
11
12
  // MARK: - PopupButtonType
@@ -37,7 +38,14 @@ public struct PopupDisplay: View {
37
38
 
38
39
  // MARK: Public
39
40
 
41
+ @State private var textHeight: CGFloat = .zero
42
+ @State private var isScrollable = false
43
+
40
44
  public var body: some View {
45
+ var shouldUseColumn: Bool {
46
+ buttonDirection == .column || (buttonDirection == .auto && (closeButtonTitle.count > 12 || actionButtonTitle.count > 12))
47
+ }
48
+
41
49
  VStack(spacing: 12) {
42
50
  ZStack(alignment: .topTrailing) {
43
51
  SwiftUI.Button(action: onClose) {
@@ -75,12 +83,37 @@ public struct PopupDisplay: View {
75
83
  .lineLimit(2)
76
84
  .accessibility(identifier: "title_popup_permission")
77
85
 
78
- Text(description)
79
- .foregroundColor(.black)
80
- .font(.paragraph)
81
- .opacity(0.6)
82
- .multilineTextAlignment(.leading)
83
- .padding(.bottom, 8)
86
+ Group {
87
+ if isScrollable {
88
+ ScrollView(showsIndicators: false) {
89
+ Text(description)
90
+ .font(.paragraph)
91
+ .foregroundColor(.black)
92
+ .opacity(0.6)
93
+ .multilineTextAlignment(.leading)
94
+ .background(GeometryReader { geo in
95
+ Color.clear
96
+ .onAppear {
97
+ textHeight = geo.size.height
98
+ }
99
+ })
100
+ }
101
+ .frame(height: 60)
102
+ } else {
103
+ Text(description)
104
+ .font(.paragraph)
105
+ .foregroundColor(.black)
106
+ .opacity(0.6)
107
+ .multilineTextAlignment(.leading)
108
+ .background(GeometryReader { geo in
109
+ Color.clear
110
+ .onAppear {
111
+ textHeight = geo.size.height
112
+ isScrollable = textHeight > 60 // adjust threshold to ~3 lines
113
+ }
114
+ })
115
+ }
116
+ }.padding(.bottom, 8)
84
117
 
85
118
  if(!errorCode.isEmpty) {
86
119
  Text(errorCode)
@@ -94,17 +127,17 @@ public struct PopupDisplay: View {
94
127
  .padding(.horizontal, 24)
95
128
  .padding(.bottom, 16)
96
129
 
97
- if buttonDirection == .row {
130
+ if shouldUseColumn {
98
131
  if buttonType == .text {
99
- RowTextButtons
132
+ ColumnTextButtons
100
133
  } else {
101
- RowButtons
134
+ ColumnButtons
102
135
  }
103
136
  } else {
104
137
  if buttonType == .text {
105
- ColumnTextButtons
138
+ RowTextButtons
106
139
  } else {
107
- ColumnButtons
140
+ RowButtons
108
141
  }
109
142
  }
110
143
 
@@ -27,8 +27,9 @@ public struct PopupPromotion: View {
27
27
  .frame(maxWidth: UIScreen.main.bounds.width - Spacing.XL * 2)
28
28
  .clipped()
29
29
  }
30
+ .scaledToFill()
30
31
  .aspectRatio(0.72, contentMode: .fit)
31
- .frame(maxWidth: UIScreen.main.bounds.width - Spacing.XL * 2)
32
+ .frame(maxWidth: UIScreen.main.bounds.width - Spacing.XL * 2, alignment: .center)
32
33
  .clipped()
33
34
  .onTapGesture {
34
35
  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 = 1.2
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
+ #Wed Aug 21 14:20:12 ICT 2024
8
+ sdk.dir=/Users/huynhdung/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.9",
3
+ "version": "0.118.0-beta.1",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},