@momo-kits/native-kits 0.162.32-debug → 0.162.33-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.
Files changed (25) hide show
  1. package/compose/build.gradle.kts +1 -1
  2. package/compose/compose.podspec +1 -1
  3. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -0
  4. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +1 -3
  5. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +16 -0
  6. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +28 -41
  7. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +40 -0
  8. package/gradle.properties +1 -1
  9. package/ios/native-kits.podspec +1 -1
  10. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  11. package/package.json +1 -1
  12. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  13. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  20. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  21. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  22. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  23. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  24. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  25. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
@@ -40,7 +40,7 @@ kotlin {
40
40
  }
41
41
 
42
42
  cocoapods {
43
- version = "0.162.32-debug"
43
+ version = "0.162.33-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |spec|
2
2
  spec.name = 'compose'
3
- spec.version = '0.164.1-beta.1'
3
+ spec.version = '0.164.1-beta.2-debug'
4
4
  spec.homepage = 'https://momo.vn'
5
5
  spec.source = { :http=> ''}
6
6
  spec.authors = ''
@@ -0,0 +1,19 @@
1
+ package vn.momo.kits.const
2
+
3
+ import androidx.compose.runtime.Composable
4
+ import androidx.compose.runtime.remember
5
+ import androidx.compose.ui.platform.LocalContext
6
+ import androidx.compose.ui.text.font.Font
7
+ import androidx.compose.ui.text.font.FontFamily
8
+
9
+ @Composable
10
+ internal actual fun hostFontFamily(fileName: String): FontFamily? {
11
+ val assets = LocalContext.current.applicationContext.assets
12
+ return remember(fileName) {
13
+ val path = "fonts/$fileName"
14
+ // AssetManager.open ném IOException nếu thiếu file; Font(path, assetManager) thì lỗi
15
+ // muộn lúc render nên phải kiểm tra tồn tại trước.
16
+ val exists = runCatching { assets.open(path).close() }.isSuccess
17
+ if (exists) FontFamily(Font(path = path, assetManager = assets)) else null
18
+ }
19
+ }
@@ -35,8 +35,6 @@ import vn.momo.kits.application.IsShowBaseLineDebug
35
35
  import vn.momo.kits.const.*
36
36
  import vn.momo.kits.modifier.conditional
37
37
  import vn.momo.kits.modifier.setAutomationId
38
- import vn.momo.uikits.resources.Res
39
- import vn.momo.uikits.resources.sfprotext_regular
40
38
 
41
39
  data class InputSizeDetail(
42
40
  val borderWidth: Dp,
@@ -268,7 +266,7 @@ fun Input(
268
266
  )
269
267
  }
270
268
 
271
- val passwordFontFamily = getFont(Res.font.sfprotext_regular)
269
+ val passwordFontFamily = getFontFamily("SFProText", FontWeight.Normal)
272
270
  val passwordFontSize = scaleSize(24.sp)
273
271
  val visualTransformation = remember(secureTextEntry, inputState.passHidden, passwordFontFamily) {
274
272
  if (secureTextEntry && !inputState.passHidden)
@@ -0,0 +1,16 @@
1
+ package vn.momo.kits.const
2
+
3
+ import androidx.compose.runtime.Composable
4
+ import androidx.compose.ui.text.font.FontFamily
5
+
6
+ /**
7
+ * Nạp font từ tài nguyên native của app host thay vì đóng gói bản copy riêng trong SDK.
8
+ *
9
+ * App host (MoMo Platform) đã bundle sẵn toàn bộ font từ `font-source`:
10
+ * - Android: `assets/fonts/<fileName>` (gradle task `syncMomoFonts`)
11
+ * - iOS: file rời ở bundle root (pbxproj fileRef được `post_install.rb` trỏ về font-source)
12
+ *
13
+ * Trả về `null` nếu host không có font đó — caller tự fallback [FontFamily.Default].
14
+ */
15
+ @Composable
16
+ internal expect fun hostFontFamily(fileName: String): FontFamily?
@@ -8,12 +8,8 @@ import androidx.compose.ui.text.font.FontFamily
8
8
  import androidx.compose.ui.text.font.FontWeight
9
9
  import androidx.compose.ui.text.style.TextDecoration
10
10
  import androidx.compose.ui.unit.*
11
- import org.jetbrains.compose.resources.Font
12
- import org.jetbrains.compose.resources.FontResource
13
- import org.jetbrains.compose.resources.InternalResourceApi
14
11
  import vn.momo.kits.application.LocalContext
15
12
  import vn.momo.kits.platform.getScreenDimensions
16
- import vn.momo.uikits.resources.*
17
13
  import kotlin.math.max
18
14
  import kotlin.math.min
19
15
 
@@ -87,48 +83,39 @@ fun scaleSize(textStyle: TextStyle): TextStyle {
87
83
  }
88
84
 
89
85
 
90
- @OptIn(InternalResourceApi::class)
91
- @Composable
92
- internal fun getFont(font: FontResource): FontFamily {
93
- return FontFamily(Font(font))
86
+ /**
87
+ * Tên file font trong tài nguyên native của app host (xem [hostFontFamily]).
88
+ *
89
+ * SDK không đóng gói font riêng nữa: app host đã bundle sẵn toàn bộ font từ `font-source`
90
+ * cho cả React Native lẫn native, nên bản copy trong `composeResources` chỉ làm phình app.
91
+ */
92
+ private const val DEFAULT_FONT_FILE = "SFProText-Regular.ttf"
93
+
94
+ private val hostFontFiles: Map<String, String> = mapOf(
95
+ "SFProText-100" to "SFProText-Thin.ttf",
96
+ "SFProText-200" to "SFProText-Ultralight.ttf",
97
+ "SFProText-300" to "SFProText-Light.ttf",
98
+ "SFProText-400" to DEFAULT_FONT_FILE,
99
+ "SFProText-500" to "SFProText-Medium.ttf",
100
+ "SFProText-600" to "SFProText-Semibold.ttf",
101
+ "SFProText-700" to "SFProText-Bold.ttf",
102
+ "SFProText-800" to "SFProText-Heavy.ttf",
103
+ "SFProText-900" to "SFProText-Black.ttf",
104
+ ) + (1..9).flatMap { step ->
105
+ val weight = step * 100
106
+ listOf(
107
+ "MoMoSignature-$weight" to "MoMoSignature.otf",
108
+ "MoMoTrustDisplay-$weight" to "MoMoTrustDisplay.otf",
109
+ )
94
110
  }
95
111
 
96
112
  @Composable
97
113
  fun getFontFamily(fontFamily: String, fontWeight: FontWeight? = FontWeight.Normal): FontFamily {
98
114
  val key = "$fontFamily-${fontWeight?.weight}"
99
- val fontMap = mapOf(
100
- "SFProText-100" to Res.font.sfprotext_thin,
101
- "SFProText-200" to Res.font.sfprotext_ultralight,
102
- "SFProText-300" to Res.font.sfprotext_light,
103
- "SFProText-400" to Res.font.sfprotext_regular,
104
- "SFProText-500" to Res.font.sfprotext_medium,
105
- "SFProText-600" to Res.font.sfprotext_semibold,
106
- "SFProText-700" to Res.font.sfprotext_bold,
107
- "SFProText-800" to Res.font.sfprotext_heavy,
108
- "SFProText-900" to Res.font.sfprotext_black,
109
-
110
- "MoMoSignature-100" to Res.font.momosignature,
111
- "MoMoSignature-200" to Res.font.momosignature,
112
- "MoMoSignature-300" to Res.font.momosignature,
113
- "MoMoSignature-400" to Res.font.momosignature,
114
- "MoMoSignature-500" to Res.font.momosignature,
115
- "MoMoSignature-600" to Res.font.momosignature,
116
- "MoMoSignature-700" to Res.font.momosignature,
117
- "MoMoSignature-800" to Res.font.momosignature,
118
- "MoMoSignature-900" to Res.font.momosignature,
119
-
120
- "MoMoTrustDisplay-100" to Res.font.momotrustdisplay,
121
- "MoMoTrustDisplay-200" to Res.font.momotrustdisplay,
122
- "MoMoTrustDisplay-300" to Res.font.momotrustdisplay,
123
- "MoMoTrustDisplay-400" to Res.font.momotrustdisplay,
124
- "MoMoTrustDisplay-500" to Res.font.momotrustdisplay,
125
- "MoMoTrustDisplay-600" to Res.font.momotrustdisplay,
126
- "MoMoTrustDisplay-700" to Res.font.momotrustdisplay,
127
- "MoMoTrustDisplay-800" to Res.font.momotrustdisplay,
128
- "MoMoTrustDisplay-900" to Res.font.momotrustdisplay,
129
- )
130
- val font = fontMap[key] ?: Res.font.sfprotext_regular
131
- return getFont(font)
115
+ val fileName = hostFontFiles[key] ?: DEFAULT_FONT_FILE
116
+ return hostFontFamily(fileName)
117
+ ?: hostFontFamily(DEFAULT_FONT_FILE)
118
+ ?: FontFamily.Default
132
119
  }
133
120
 
134
121
  @Immutable
@@ -0,0 +1,40 @@
1
+ @file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
2
+
3
+ package vn.momo.kits.const
4
+
5
+ import androidx.compose.runtime.Composable
6
+ import androidx.compose.runtime.remember
7
+ import androidx.compose.ui.text.font.FontFamily
8
+ import androidx.compose.ui.text.platform.Font
9
+ import kotlinx.cinterop.ExperimentalForeignApi
10
+ import kotlinx.cinterop.addressOf
11
+ import kotlinx.cinterop.usePinned
12
+ import platform.Foundation.NSBundle
13
+ import platform.Foundation.NSData
14
+ import platform.Foundation.dataWithContentsOfFile
15
+ import platform.posix.memcpy
16
+
17
+ @Composable
18
+ internal actual fun hostFontFamily(fileName: String): FontFamily? = remember(fileName) {
19
+ val name = fileName.substringBeforeLast('.')
20
+ val ext = fileName.substringAfterLast('.', "")
21
+ // Font từ font-source nằm rời ở bundle root, không nằm trong compose-resources.
22
+ val path = NSBundle.mainBundle.pathForResource(name, ext) ?: return@remember null
23
+ FontFamily(
24
+ Font(
25
+ identity = fileName,
26
+ getData = {
27
+ NSData.dataWithContentsOfFile(path)?.toByteArray() ?: ByteArray(0)
28
+ },
29
+ ),
30
+ )
31
+ }
32
+
33
+ @OptIn(ExperimentalForeignApi::class)
34
+ private fun NSData.toByteArray(): ByteArray {
35
+ val size = length.toInt()
36
+ if (size == 0) return ByteArray(0)
37
+ return ByteArray(size).apply {
38
+ usePinned { pinned -> memcpy(pinned.addressOf(0), bytes, length) }
39
+ }
40
+ }
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.162.32
21
+ version=0.162.33
22
22
 
23
23
  repo=GitLab
24
24
  url=https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKits'
3
- s.version = '0.164.1-beta.1'
3
+ s.version = '0.164.1-beta.2'
4
4
  s.summary = 'MoMoUIKits for iOS'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKitsDemo'
3
- s.version = '0.164.1-beta.1'
3
+ s.version = '0.164.1-beta.2'
4
4
  s.summary = 'Demo browser for MoMoUIKits SwiftUI components'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.162.32-debug",
3
+ "version": "0.162.33-debug",
4
4
  "private": false,
5
5
  "dependeNavigationncies": {},
6
6
  "devDependencies": {},