@momo-kits/native-kits 0.156.6-beta.4 → 0.156.6-dialog.1-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 (128) hide show
  1. package/build.gradle.kts +11 -0
  2. package/compose/MoMoComposeKits.podspec +54 -0
  3. package/compose/build.gradle.kts +183 -0
  4. package/compose/build.gradle.kts.backup +183 -0
  5. package/compose/compose.podspec +48 -0
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +270 -0
  7. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  8. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  9. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  10. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  11. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  12. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  20. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +57 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +95 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +201 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +222 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +48 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +305 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +720 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +121 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +405 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +83 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +340 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +348 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +94 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +136 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +543 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +63 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +148 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +185 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +116 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +447 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +172 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +255 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +231 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +234 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +254 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +241 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +364 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +92 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +352 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +103 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +70 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +17 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +96 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +96 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +92 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +130 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +214 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +177 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +205 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +239 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +191 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +306 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +13 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +189 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +285 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +35 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +59 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +68 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +14 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +238 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +118 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +98 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +209 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +227 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +484 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +162 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +226 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +187 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +277 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +80 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +306 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +31 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +370 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +129 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +63 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +62 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +88 -0
  107. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +325 -0
  108. package/gradle/libs.versions.toml +57 -0
  109. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  110. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  111. package/gradle.properties +26 -0
  112. package/gradlew +252 -0
  113. package/gradlew.bat +94 -0
  114. package/ios/Image/Image.swift +1 -5
  115. package/local.properties +8 -0
  116. package/package.json +1 -1
  117. package/settings.gradle.kts +52 -0
  118. package/example/ios/Example.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
  119. package/example/ios/Example.xcworkspace/xcuserdata/sophia.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  120. package/example/ios/Example.xcworkspace/xcuserdata/sophia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -6
  121. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +0 -58
  122. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/Pods-Example.xcscheme +0 -58
  123. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/SDWebImage.xcscheme +0 -58
  124. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +0 -58
  125. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/SkeletonUI.xcscheme +0 -58
  126. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/lottie-ios-LottiePrivacyInfo.xcscheme +0 -58
  127. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/lottie-ios.xcscheme +0 -58
  128. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/xcschememanagement.plist +0 -46
@@ -0,0 +1,62 @@
1
+ package vn.momo.kits.utils
2
+
3
+ import androidx.compose.runtime.Composable
4
+ import androidx.compose.runtime.LaunchedEffect
5
+ import androidx.compose.runtime.MutableState
6
+ import androidx.compose.runtime.getValue
7
+ import androidx.compose.runtime.mutableStateOf
8
+ import androidx.compose.runtime.remember
9
+ import org.jetbrains.compose.resources.DrawableResource
10
+ import org.jetbrains.compose.resources.InternalResourceApi
11
+ import org.jetbrains.compose.resources.ResourceItem
12
+ import org.jetbrains.compose.resources.readResourceBytes
13
+
14
+ @OptIn(InternalResourceApi::class)
15
+ @Composable
16
+ fun getResource(name: String): DrawableResource {
17
+ return DrawableResource(
18
+ "drawable:$name",
19
+ setOf(ResourceItem(setOf(), "drawable/$name", -1, -1))
20
+ )
21
+ }
22
+
23
+ @OptIn(InternalResourceApi::class)
24
+ @Composable
25
+ fun readJson(name: String): String {
26
+ val path = name.plus(".json")
27
+
28
+ val jsonContent by rememberState(path, { "" }) {
29
+ val cached = resourceCache.getOrPut(path) {
30
+ val content = try {
31
+ readResourceBytes(path).decodeToString()
32
+ } catch (_: Exception) {
33
+ ""
34
+ }
35
+ ResourceCache.JSON(content)
36
+ } as ResourceCache.JSON
37
+
38
+ cached.json
39
+ }
40
+
41
+ return jsonContent
42
+ }
43
+
44
+
45
+ private val resourceCache = mutableMapOf<String, ResourceCache>()
46
+
47
+ private sealed interface ResourceCache {
48
+ class JSON(val json: String) : ResourceCache
49
+ }
50
+
51
+ @Composable
52
+ fun <T> rememberState(
53
+ key: Any,
54
+ getDefault: () -> T,
55
+ block: suspend () -> T
56
+ ): MutableState<T> {
57
+ val state = remember(key) { mutableStateOf(getDefault()) }
58
+ LaunchedEffect(key) {
59
+ state.value = block()
60
+ }
61
+ return state
62
+ }
@@ -0,0 +1,88 @@
1
+ package vn.momo.kits.utils
2
+
3
+ import androidx.compose.foundation.layout.WindowInsets
4
+ import androidx.compose.foundation.layout.asPaddingValues
5
+ import androidx.compose.foundation.layout.systemBars
6
+ import androidx.compose.runtime.Composable
7
+ import androidx.compose.ui.Modifier
8
+ import androidx.compose.ui.composed
9
+ import androidx.compose.ui.draw.drawBehind
10
+ import androidx.compose.ui.geometry.Offset
11
+ import androidx.compose.ui.graphics.Color
12
+ import androidx.compose.ui.platform.LocalDensity
13
+ import androidx.compose.ui.unit.Dp
14
+ import androidx.compose.ui.unit.dp
15
+ import vn.momo.kits.const.AppStatusBar
16
+ import kotlin.math.abs
17
+
18
+
19
+ internal fun Modifier.bottomBorder(strokeWidth: Dp, color: Color) = composed(
20
+ factory = {
21
+ val density = LocalDensity.current
22
+ val strokeWidthPx = density.run { strokeWidth.toPx() }
23
+ if (strokeWidth > 0.dp) {
24
+ Modifier.drawBehind {
25
+ val width = size.width
26
+ val height = size.height - strokeWidthPx / 2
27
+
28
+ drawLine(
29
+ color = color,
30
+ start = Offset(x = 0f, y = height),
31
+ end = Offset(x = width, y = height),
32
+ strokeWidth = strokeWidthPx
33
+ )
34
+ }
35
+ } else {
36
+ Modifier
37
+ }
38
+ }
39
+ )
40
+
41
+ inline fun <T> Boolean.ifTrue(trueCase: T, falseCase: T): T = if (this) trueCase else falseCase
42
+ inline fun <T> String.ifNotNull(trueCase: T, falseCase: T): T =
43
+ if (this.isBlank()) falseCase else trueCase
44
+
45
+ fun formatNumberToMoney(number: Long, currency: String = "đ"): String {
46
+ if (number == 0L) {
47
+ return "0$currency"
48
+ }
49
+ val array = mutableListOf<Char>()
50
+ var result = ""
51
+ var isNegative = false
52
+
53
+ if (number < 0) {
54
+ isNegative = true
55
+ }
56
+ val numberString = abs(number).toString() // Convert to Int to avoid decimal places
57
+ if (numberString.length < 3) {
58
+ return numberString + currency
59
+ }
60
+ var count = 0
61
+ for (i in numberString.length - 1 downTo 0) {
62
+ count += 1
63
+ array.add(numberString[i])
64
+ if (count == 3 && i >= 1) {
65
+ array.add('.')
66
+ count = 0
67
+ }
68
+ }
69
+
70
+ for (i in array.size - 1 downTo 0) {
71
+ result += array[i]
72
+ }
73
+
74
+ if (isNegative) {
75
+ result = "-$result"
76
+ }
77
+
78
+ return result + currency
79
+ }
80
+
81
+ @Composable
82
+ fun getAppStatusBarHeight(): Dp {
83
+ return if (AppStatusBar.current == 0.dp) {
84
+ WindowInsets.systemBars.asPaddingValues().calculateTopPadding()
85
+ } else {
86
+ AppStatusBar.current
87
+ }
88
+ }
@@ -0,0 +1,325 @@
1
+ package vn.momo.kits.platform
2
+
3
+ import androidx.compose.foundation.layout.Box
4
+ import androidx.compose.foundation.layout.WindowInsets
5
+ import androidx.compose.foundation.layout.asPaddingValues
6
+ import androidx.compose.foundation.layout.fillMaxSize
7
+ import androidx.compose.foundation.layout.systemBars
8
+ import androidx.compose.runtime.Composable
9
+ import androidx.compose.runtime.LaunchedEffect
10
+ import androidx.compose.runtime.getValue
11
+ import androidx.compose.runtime.mutableStateOf
12
+ import androidx.compose.runtime.remember
13
+ import androidx.compose.runtime.setValue
14
+ import androidx.compose.ui.Modifier
15
+ import androidx.compose.ui.graphics.Color
16
+ import androidx.compose.ui.graphics.NativePaint
17
+ import androidx.compose.ui.graphics.toArgb
18
+ import androidx.compose.ui.unit.Dp
19
+ import androidx.compose.ui.unit.dp
20
+ import cocoapods.lottie_ios.CompatibleAnimation
21
+ import cocoapods.lottie_ios.CompatibleAnimationKeypath
22
+ import cocoapods.lottie_ios.CompatibleAnimationView
23
+ import androidx.compose.ui.Alignment
24
+ import androidx.compose.ui.ExperimentalComposeUiApi
25
+ import androidx.compose.ui.layout.ContentScale
26
+ import androidx.compose.ui.viewinterop.UIKitInteropProperties
27
+ import androidx.compose.ui.viewinterop.UIKitView
28
+ import cocoapods.SDWebImage.sd_setImageWithURL
29
+ import kotlinx.cinterop.ExperimentalForeignApi
30
+ import kotlinx.cinterop.get
31
+ import kotlinx.cinterop.memScoped
32
+ import kotlinx.cinterop.useContents
33
+ import org.jetbrains.skia.FilterBlurMode
34
+ import org.jetbrains.skia.MaskFilter
35
+ import platform.CoreGraphics.CGRectMake
36
+ import platform.Foundation.NSBundle
37
+ import platform.UIKit.UIColor
38
+ import platform.UIKit.UIImageRenderingMode
39
+ import platform.UIKit.UIScreen
40
+ import platform.Foundation.NSURL
41
+ import platform.UIKit.UIImageView
42
+ import platform.UIKit.UIViewContentMode
43
+ import platform.UIKit.UIView
44
+ import vn.momo.kits.components.Options
45
+
46
+ actual fun getPlatformName(): String = "iOS"
47
+
48
+ @OptIn(ExperimentalForeignApi::class)
49
+ @Composable
50
+ actual fun getScreenDimensions(): ScreenDimension = memScoped {
51
+ val config = UIScreen.mainScreen.bounds.ptr[0]
52
+ return ScreenDimension(
53
+ config.size.width.toInt(),
54
+ config.size.height.toInt()
55
+ )
56
+ }
57
+
58
+ actual fun NativePaint.setMaskFilter(blurRadius: Float) {
59
+ this.maskFilter = MaskFilter.makeBlur(FilterBlurMode.NORMAL, blurRadius / 2, true)
60
+ }
61
+
62
+ @Composable
63
+ actual fun getStatusBarHeight(): Dp {
64
+ return WindowInsets.systemBars.asPaddingValues().calculateTopPadding()
65
+ }
66
+
67
+ @Composable
68
+ actual fun BackHandler(enabled: Boolean, onBack: () -> Unit) {
69
+ }
70
+
71
+ @Composable
72
+ actual fun getScreenHeight(): Dp {
73
+ return getScreenDimensions().height.dp
74
+ }
75
+
76
+ actual fun getAndroidBuildVersion(): Int = 999
77
+
78
+ @OptIn(ExperimentalForeignApi::class)
79
+ @Composable
80
+ actual fun LottieAnimation(
81
+ path: String,
82
+ tintColor: Color?,
83
+ bgColor: Color?,
84
+ modifier: Modifier
85
+ ) {
86
+ var animation by remember { mutableStateOf<CompatibleAnimation?>(null) }
87
+
88
+ LaunchedEffect(Unit) {
89
+ animation = CompatibleAnimation(name = "compose-resources/composeResources/vn.momo.compose.resources/".plus(path), subdirectory = null, NSBundle.mainBundle)
90
+ }
91
+
92
+ when (val value = animation) {
93
+ null -> {
94
+ Box(modifier)
95
+ }
96
+
97
+ else -> {
98
+ Box(modifier) {
99
+ UIKitView(
100
+ modifier = Modifier.fillMaxSize(),
101
+ factory = {
102
+ CompatibleAnimationView(value).apply {
103
+ translatesAutoresizingMaskIntoConstraints = true
104
+
105
+ setBackgroundColor(bgColor?.toUIColor() ?: UIColor.whiteColor)
106
+
107
+ setLoopAnimationCount(-1.0)
108
+ setAnimationSpeed(1.0)
109
+
110
+ if (tintColor != null) {
111
+ val uiColor = tintColor.toUIColor()
112
+ setColorValue(uiColor,
113
+ CompatibleAnimationKeypath("**.Fill 1.Color")
114
+ )
115
+ setColorValue(uiColor, CompatibleAnimationKeypath("**.Fill.Color"))
116
+ setColorValue(uiColor, CompatibleAnimationKeypath("**.Color"))
117
+ setColorValue(uiColor, CompatibleAnimationKeypath("**.Stroke 1.Color"))
118
+ setColorValue(uiColor, CompatibleAnimationKeypath("**.Stroke.Color"))
119
+ }
120
+
121
+ play()
122
+ }
123
+ },
124
+
125
+ update = { view ->
126
+ view.setBackgroundColor(bgColor?.toUIColor() ?: UIColor.whiteColor)
127
+
128
+ if (tintColor != null) {
129
+ val uiColor = tintColor.toUIColor()
130
+
131
+ view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Fill 1.Color"))
132
+ view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Fill.Color"))
133
+ view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Color"))
134
+ view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Stroke 1.Color"))
135
+ view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Stroke.Color"))
136
+ }
137
+ }
138
+ )
139
+ }
140
+ }
141
+ }
142
+ }
143
+
144
+ fun Color.toUIColor(): UIColor {
145
+ val argb = this.toArgb()
146
+
147
+ val a = ((argb shr 24) and 0xFF) / 255.0
148
+ val r = ((argb shr 16) and 0xFF) / 255.0
149
+ val g = ((argb shr 8) and 0xFF) / 255.0
150
+ val b = (argb and 0xFF) / 255.0
151
+
152
+ return UIColor(
153
+ red = r,
154
+ green = g,
155
+ blue = b,
156
+ alpha = a
157
+ )
158
+ }
159
+
160
+ actual fun NativePaint.setColor(color: Color){
161
+ this.color = color.toArgb()
162
+ }
163
+ /**
164
+ * A container UIView that positions an inner UIImageView using the same
165
+ * scale + alignment math as the Android Matrix implementation.
166
+ */
167
+ @OptIn(ExperimentalForeignApi::class)
168
+ class ScaledAlignedImageView(
169
+ var contentScale: ContentScale,
170
+ var alignment: Alignment,
171
+ var imageTintColor: UIColor? = null,
172
+ ) : UIView(frame = CGRectMake(0.0, 0.0, 0.0, 0.0)) {
173
+
174
+ val imageView = UIImageView().apply {
175
+ backgroundColor = UIColor.clearColor()
176
+ clipsToBounds = false
177
+ contentMode = UIViewContentMode.UIViewContentModeScaleToFill
178
+ }
179
+
180
+ init {
181
+ clipsToBounds = true
182
+ addSubview(imageView)
183
+ }
184
+
185
+ fun applyTint() {
186
+ val img = imageView.image ?: return
187
+ val color = imageTintColor
188
+ if (color != null) {
189
+ imageView.tintColor = color
190
+ imageView.image = img.imageWithRenderingMode(UIImageRenderingMode.UIImageRenderingModeAlwaysTemplate)
191
+ } else {
192
+ imageView.tintColor = super.tintColor
193
+ imageView.image = img.imageWithRenderingMode(UIImageRenderingMode.UIImageRenderingModeAlwaysOriginal)
194
+ }
195
+ }
196
+
197
+ override fun layoutSubviews() {
198
+ super.layoutSubviews()
199
+ applyImageFrame()
200
+ }
201
+
202
+ @OptIn(ExperimentalForeignApi::class)
203
+ fun applyImageFrame() {
204
+ memScoped {
205
+ val img = imageView.image ?: return
206
+ val rect = this@ScaledAlignedImageView.bounds.ptr[0]
207
+ val vw: Double = rect.size.width
208
+ val vh: Double = rect.size.height
209
+ if (vw <= 0.0 || vh <= 0.0) return
210
+
211
+ val imgSize = img.size
212
+ val imgScale: Double = img.scale
213
+ val deviceScale: Double = UIScreen.mainScreen.scale
214
+ // Normalize: UIImage.size is in pts at img.scale, convert to dp-equivalent pts
215
+ // (img pixel count = img.size × img.scale → dp = pixels / deviceScale)
216
+ val dw: Double = (imgSize.useContents { width } * imgScale / deviceScale).takeIf { it > 0.0 } ?: return
217
+ val dh: Double = (imgSize.useContents { height } * imgScale / deviceScale).takeIf { it > 0.0 } ?: return
218
+
219
+ val sxFit: Double = vw / dw
220
+ val syFit: Double = vh / dh
221
+
222
+ val (sx: Double, sy: Double) = when (contentScale) {
223
+ ContentScale.Crop -> maxOf(sxFit, syFit).let { it to it }
224
+ ContentScale.Fit -> minOf(sxFit, syFit).let { it to it }
225
+ ContentScale.FillWidth -> sxFit to sxFit
226
+ ContentScale.FillHeight -> syFit to syFit
227
+ ContentScale.FillBounds -> sxFit to syFit
228
+ ContentScale.Inside -> minOf(1.0, minOf(sxFit, syFit)).let { it to it }
229
+ ContentScale.None -> 1.0 to 1.0
230
+ else -> maxOf(sxFit, syFit).let { it to it }
231
+ }
232
+
233
+ val (bx: Double, by: Double) = when (alignment) {
234
+ Alignment.TopStart -> -1.0 to -1.0
235
+ Alignment.TopCenter -> 0.0 to -1.0
236
+ Alignment.TopEnd -> 1.0 to -1.0
237
+ Alignment.CenterStart -> -1.0 to 0.0
238
+ Alignment.Center -> 0.0 to 0.0
239
+ Alignment.CenterEnd -> 1.0 to 0.0
240
+ Alignment.BottomStart -> -1.0 to 1.0
241
+ Alignment.BottomCenter -> 0.0 to 1.0
242
+ Alignment.BottomEnd -> 1.0 to 1.0
243
+ else -> 0.0 to 0.0
244
+ }
245
+
246
+ val scaledW: Double = dw * sx
247
+ val scaledH: Double = dh * sy
248
+ val tx: Double = (vw - scaledW) * (bx + 1.0) / 2.0
249
+ val ty: Double = (vh - scaledH) * (by + 1.0) / 2.0
250
+
251
+ imageView.setFrame(CGRectMake(tx, ty, scaledW, scaledH))
252
+ }
253
+ }
254
+ }
255
+
256
+ @OptIn(ExperimentalForeignApi::class, ExperimentalComposeUiApi::class)
257
+ @Composable
258
+ actual fun NativeImage(
259
+ source: Any,
260
+ options: Options,
261
+ loading: Boolean,
262
+ onLoading: () -> Unit,
263
+ onSuccess: () -> Unit,
264
+ onError: () -> Unit,
265
+ ) {
266
+ UIKitView(
267
+ modifier = Modifier.fillMaxSize(),
268
+ factory = {
269
+ ScaledAlignedImageView(
270
+ contentScale = options.contentScale,
271
+ alignment = options.alignment,
272
+ imageTintColor = options.tintColor?.toUIColor(),
273
+ ).apply {
274
+ backgroundColor = UIColor.clearColor()
275
+ alpha = options.alpha.toDouble().coerceIn(0.0, 1.0)
276
+ }
277
+ },
278
+ update = { container ->
279
+ container.contentScale = options.contentScale
280
+ container.alignment = options.alignment
281
+ container.imageTintColor = options.tintColor?.toUIColor()
282
+ container.alpha = options.alpha.toDouble().coerceIn(0.0, 1.0)
283
+ container.applyImageFrame()
284
+
285
+ val url = (source as? String)?.let { NSURL(string = it) } ?: run {
286
+ container.imageView.image = null
287
+ onError()
288
+ return@UIKitView
289
+ }
290
+
291
+ try {
292
+ onLoading()
293
+ container.imageView.sd_setImageWithURL(
294
+ url = url,
295
+ placeholderImage = null,
296
+ options = 0u,
297
+ completed = { _, error, _, _ ->
298
+ if (error == null) {
299
+ container.applyTint()
300
+ container.applyImageFrame()
301
+ onSuccess()
302
+ } else {
303
+ onError()
304
+ }
305
+ }
306
+ )
307
+ true
308
+ } catch (_: Throwable) {
309
+ onError()
310
+ }
311
+ },
312
+ properties = UIKitInteropProperties(
313
+ placedAsOverlay = true,
314
+ // Disable all touch handling on the interop host view so that
315
+ // Compose click handlers on parent composables (e.g. Icon, BackButton)
316
+ // receive touches correctly on iOS.
317
+ interactionMode = null,
318
+ )
319
+ )
320
+ }
321
+
322
+ @Composable
323
+ actual fun ConfigureDialogWindow(decorFitsSystemWindows: Boolean) {
324
+ // iOS: dialogs already render behind system bars — no additional setup needed.
325
+ }
@@ -0,0 +1,57 @@
1
+ [versions]
2
+ android-compileSdk = "35"
3
+ android-minSdk = "24"
4
+ android-targetSdk = "35"
5
+ ktor-version = "3.0.0-rc-1"
6
+ coroutines = "1.8.1"
7
+ kotlin = "2.3.0"
8
+ kSerialize = "1.7.1"
9
+ compose = "1.10.1"
10
+ navigation-multiplatform = "2.9.1"
11
+ coil3-multiplatform = "3.0.0-alpha10"
12
+ androidGradlePlugin = "8.6.0"
13
+ r8 = "8.13.19"
14
+ kotlinx-datetime = "0.7.1"
15
+ airbnb-lottie = "5.2.0"
16
+ androidx-activity = "1.9.1"
17
+ androidx-appcompat = "1.7.1"
18
+ material = "1.10.0"
19
+ maxapi = "0.1.1"
20
+ vanniktechMavenPublish = "0.34.0"
21
+ kits = "0.1.9"
22
+ nativemaxapi = "0.0.6"
23
+
24
+ [libraries]
25
+ ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor-version" }
26
+ ktor-client-darwin = { group = "io.ktor", name = "ktor-client-darwin", version.ref = "ktor-version" }
27
+ ktor-client-okhttp = { group = "io.ktor", name = "ktor-client-okhttp", version.ref = "ktor-version" }
28
+ jetbrains-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "coroutines" }
29
+ jetbrains-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" }
30
+ jetbrains-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutines" }
31
+ jetbrains-serialization = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization", version.ref = "kSerialize" }
32
+ jetbrains-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kSerialize" }
33
+ kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinx-datetime" }
34
+ navigation-multiplatform = { module = "org.jetbrains.androidx.navigation:navigation-compose", version.ref = "navigation-multiplatform" }
35
+ coil-multiplatform-core = { module = "io.coil-kt.coil3:coil-core", version.ref = "coil3-multiplatform" }
36
+ coil-multiplatform-compose = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coil3-multiplatform" }
37
+ coil-multiplatform-network-ktor = { module = "io.coil-kt.coil3:coil-network-ktor3", version.ref = "coil3-multiplatform" }
38
+ r8 = { module = "com.android.tools:r8", version.ref = "r8" }
39
+ airbnb-lottie = { group = "com.airbnb.android", name = "lottie-compose", version.ref = "airbnb-lottie" }
40
+ native-max-api = { group = "vn.momo.maxapi", name = "NativeMaxApi", version.ref = "nativemaxapi" }
41
+ kits = { module = "vn.momo.kits:kits", version.ref = "kits" }
42
+ androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
43
+ androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
44
+ material = { module = "com.google.android.material:material", version.ref = "material" }
45
+
46
+ [plugins]
47
+ jetbrains-kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
48
+ jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
49
+ jetbrains-kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
50
+ jetbrains-kotlin-cocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" }
51
+ jetbrains-kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
52
+ jetbrains-kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
53
+ kotlin-compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
54
+ compose = { id = "org.jetbrains.compose", version.ref = "compose" }
55
+ android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
56
+ android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
57
+ vanniktech-mavenPublish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktechMavenPublish" }
@@ -0,0 +1,8 @@
1
+ #Thu Jul 31 17:05:40 ICT 2025
2
+ distributionBase=GRADLE_USER_HOME
3
+ distributionPath=wrapper/dists
4
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
5
+ networkTimeout=10000
6
+ validateDistributionUrl=true
7
+ zipStoreBase=GRADLE_USER_HOME
8
+ zipStorePath=wrapper/dists
@@ -0,0 +1,26 @@
1
+ #Kotlin
2
+ kotlin.code.style=official
3
+ kotlin.daemon.jvmargs=-Xmx6144M
4
+
5
+ #Gradle
6
+ org.gradle.jvmargs=-Xmx8192M -Dfile.encoding=UTF-8
7
+ org.gradle.configuration-cache=false
8
+ org.gradle.caching=true
9
+
10
+ #Android
11
+ android.nonTransitiveRClass=true
12
+ android.useAndroidX=true
13
+
14
+ #KMP
15
+ kotlin.apple.xcodeCompatibility.nowarn=true
16
+
17
+ # Publishing
18
+ name="ComposeKits"
19
+ group=vn.momo.kits
20
+ artifact.id=kits
21
+ version=0.156.6-dialog.1
22
+
23
+ repo=GitLab
24
+ url=https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven
25
+ gitlab.user=upload_packages
26
+ gitlab.password=gldt-CtTSGmzz57sUL9cnjdaQ