@momo-kits/native-kits 0.168.1-beta.2 → 0.168.1-beta.3-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 (144) hide show
  1. package/CLAUDE.md +4 -4
  2. package/README.md +10 -2
  3. package/build.gradle.kts +13 -0
  4. package/compose/build.gradle.kts +197 -0
  5. package/compose/build.gradle.kts.backup +197 -0
  6. package/compose/compose.podspec +47 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -0
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +153 -0
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +124 -0
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1071 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +65 -0
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +357 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +128 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +542 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +231 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +189 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +478 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +114 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +265 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +235 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +223 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +265 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +185 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +343 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +84 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +361 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +308 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +90 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +330 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +220 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +473 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +207 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +92 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +560 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +125 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +207 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +501 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +236 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +16 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +18 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +22 -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 +16 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +283 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +309 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +52 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +338 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +137 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +116 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +215 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +404 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +732 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +148 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +40 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +233 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +217 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +98 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +312 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +169 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +455 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +103 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +413 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +37 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +192 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +41 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +135 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +91 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +74 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +13 -0
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +118 -0
  125. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +44 -0
  126. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +62 -0
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +40 -0
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +36 -0
  130. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
  131. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
  132. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +217 -0
  133. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +94 -0
  134. package/gradle/libs.versions.toml +76 -0
  135. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  136. package/gradle/wrapper/gradle-wrapper.properties +10 -0
  137. package/gradle.properties +26 -0
  138. package/gradlew +252 -0
  139. package/gradlew.bat +94 -0
  140. package/ios-demo/README.md +120 -0
  141. package/package.json +1 -1
  142. package/publish.sh +7 -2
  143. package/settings.gradle.kts +64 -0
  144. package/.claude/settings.local.json +0 -9
@@ -0,0 +1,217 @@
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.CompositionLocalProvider
10
+ import androidx.compose.runtime.LaunchedEffect
11
+ import androidx.compose.runtime.getValue
12
+ import androidx.compose.runtime.mutableStateOf
13
+ import androidx.compose.runtime.remember
14
+ import androidx.compose.runtime.rememberUpdatedState
15
+ import androidx.compose.runtime.setValue
16
+ import androidx.compose.ui.ExperimentalComposeUiApi
17
+ import androidx.compose.ui.InternalComposeUiApi
18
+ import androidx.compose.ui.Modifier
19
+ import androidx.compose.ui.backhandler.LocalCompatNavigationEventDispatcherOwner
20
+ import androidx.compose.ui.backhandler.BackHandler as ComposeBackHandler
21
+ import androidx.compose.ui.graphics.Color
22
+ import androidx.compose.ui.graphics.NativePaint
23
+ import androidx.compose.ui.graphics.toArgb
24
+ import androidx.compose.ui.unit.Dp
25
+ import androidx.compose.ui.unit.dp
26
+ import androidx.compose.ui.viewinterop.UIKitInteropProperties
27
+ import androidx.compose.ui.viewinterop.UIKitView
28
+ import cocoapods.lottie_ios.CompatibleAnimation
29
+ import cocoapods.lottie_ios.CompatibleAnimationKeypath
30
+ import cocoapods.lottie_ios.CompatibleAnimationView
31
+ import kotlinx.cinterop.ExperimentalForeignApi
32
+ import kotlinx.cinterop.get
33
+ import kotlinx.cinterop.memScoped
34
+ import androidx.navigationevent.NavigationEventDispatcher
35
+ import androidx.navigationevent.NavigationEventDispatcherOwner
36
+ import org.jetbrains.skia.FilterBlurMode
37
+ import org.jetbrains.skia.MaskFilter
38
+ import platform.Foundation.NSBundle
39
+ import platform.UIKit.UIColor
40
+ import platform.UIKit.UIDevice
41
+ import platform.UIKit.UIScreen
42
+ import platform.UIKit.UIUserInterfaceIdiomPhone
43
+ import vn.momo.kits.navigation.AttachHostBackGesture
44
+ import vn.momo.kits.navigation.Navigator
45
+
46
+ actual fun getPlatformName(): String = "iOS"
47
+
48
+ actual fun isPhoneIdiom(): Boolean =
49
+ UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone
50
+
51
+ @OptIn(ExperimentalForeignApi::class)
52
+ @Composable
53
+ actual fun getScreenDimensions(): ScreenDimension = memScoped {
54
+ val config = UIScreen.mainScreen.bounds.ptr[0]
55
+ return ScreenDimension(
56
+ config.size.width.toInt(),
57
+ config.size.height.toInt()
58
+ )
59
+ }
60
+
61
+ actual fun NativePaint.setMaskFilter(blurRadius: Float) {
62
+ this.maskFilter = MaskFilter.makeBlur(FilterBlurMode.NORMAL, blurRadius / 2, true)
63
+ }
64
+
65
+ @Composable
66
+ actual fun getStatusBarHeight(): Dp {
67
+ return WindowInsets.systemBars.asPaddingValues().calculateTopPadding()
68
+ }
69
+
70
+ @Suppress("DEPRECATION")
71
+ @OptIn(ExperimentalComposeUiApi::class)
72
+ @Composable
73
+ actual fun BackHandler(enabled: Boolean, onBack: () -> Unit) {
74
+ ComposeBackHandler(enabled = enabled, onBack = onBack)
75
+ }
76
+
77
+ @OptIn(InternalComposeUiApi::class)
78
+ @Composable
79
+ actual fun ProvideNavigationEventDispatcherOwner(navigator: Navigator, content: @Composable () -> Unit) {
80
+ val navigationEventDispatcherOwner = remember {
81
+ object : NavigationEventDispatcherOwner {
82
+ override val navigationEventDispatcher = NavigationEventDispatcher()
83
+ }
84
+ }
85
+
86
+ AttachHostBackGesture(navigationEventDispatcherOwner.navigationEventDispatcher, navigator)
87
+
88
+ CompositionLocalProvider(
89
+ LocalCompatNavigationEventDispatcherOwner provides navigationEventDispatcherOwner,
90
+ content = content
91
+ )
92
+ }
93
+
94
+ @Composable
95
+ actual fun getScreenHeight(): Dp {
96
+ return getScreenDimensions().height.dp
97
+ }
98
+
99
+ actual fun getOSVersion(): OSVersion = OSVersion.IOS(
100
+ major = UIDevice.currentDevice.systemVersion.substringBefore(".").toIntOrNull() ?: 0
101
+ )
102
+
103
+ @OptIn(ExperimentalForeignApi::class, ExperimentalComposeUiApi::class)
104
+ @Composable
105
+ actual fun LottieAnimation(
106
+ path: String,
107
+ tintColor: Color?,
108
+ bgColor: Color?,
109
+ placedAsOverlay: Boolean,
110
+ iterations: Int,
111
+ isPlaying: Boolean,
112
+ onEvent: ((String) -> Unit)?,
113
+ modifier: Modifier,
114
+ useCompose: Boolean
115
+ ) {
116
+ if (useCompose) {
117
+ ComposeLottieAnimation(path, tintColor, bgColor, iterations, isPlaying, onEvent, modifier)
118
+ return
119
+ }
120
+
121
+ val loopCount = if (iterations == LottieIterateForever) -1.0 else iterations.toDouble()
122
+
123
+ var animation by remember { mutableStateOf<CompatibleAnimation?>(null) }
124
+ val animationView = remember { mutableStateOf<CompatibleAnimationView?>(null) }
125
+
126
+ LaunchedEffect(Unit) {
127
+ animation = CompatibleAnimation(name = "compose-resources/composeResources/vn.momo.compose.resources/".plus(path), subdirectory = null, NSBundle.mainBundle)
128
+ }
129
+
130
+ val currentOnEvent by rememberUpdatedState(onEvent)
131
+
132
+ LaunchedEffect(isPlaying) {
133
+ currentOnEvent?.invoke(if (isPlaying) LottieEvent.Start else LottieEvent.Pause)
134
+ }
135
+
136
+ LaunchedEffect(animationView.value, isPlaying) {
137
+ val view = animationView.value ?: return@LaunchedEffect
138
+ if (isPlaying) {
139
+ view.playWithCompletion(completion = { finished -> if (finished) currentOnEvent?.invoke(LottieEvent.Finish) })
140
+ } else {
141
+ view.pause()
142
+ }
143
+ }
144
+
145
+ when (val value = animation) {
146
+ null -> {
147
+ Box(modifier)
148
+ }
149
+
150
+ else -> {
151
+ Box(modifier) {
152
+ UIKitView(
153
+ modifier = Modifier.fillMaxSize(),
154
+ properties = UIKitInteropProperties(placedAsOverlay = placedAsOverlay),
155
+ factory = {
156
+ CompatibleAnimationView(value).apply {
157
+ translatesAutoresizingMaskIntoConstraints = true
158
+
159
+ setBackgroundColor(bgColor?.toUIColor() ?: UIColor.clearColor)
160
+
161
+ setLoopAnimationCount(loopCount)
162
+ setAnimationSpeed(1.0)
163
+
164
+ if (tintColor != null) {
165
+ val uiColor = tintColor.toUIColor()
166
+ setColorValue(uiColor,
167
+ CompatibleAnimationKeypath("**.Fill 1.Color")
168
+ )
169
+ setColorValue(uiColor, CompatibleAnimationKeypath("**.Fill.Color"))
170
+ setColorValue(uiColor, CompatibleAnimationKeypath("**.Color"))
171
+ setColorValue(uiColor, CompatibleAnimationKeypath("**.Stroke 1.Color"))
172
+ setColorValue(uiColor, CompatibleAnimationKeypath("**.Stroke.Color"))
173
+ }
174
+
175
+ animationView.value = this
176
+ }
177
+ },
178
+
179
+ update = { view ->
180
+ view.setBackgroundColor(bgColor?.toUIColor() ?: UIColor.clearColor)
181
+ view.setLoopAnimationCount(loopCount)
182
+
183
+ if (tintColor != null) {
184
+ val uiColor = tintColor.toUIColor()
185
+
186
+ view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Fill 1.Color"))
187
+ view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Fill.Color"))
188
+ view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Color"))
189
+ view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Stroke 1.Color"))
190
+ view.setColorValue(uiColor, CompatibleAnimationKeypath("**.Stroke.Color"))
191
+ }
192
+ }
193
+ )
194
+ }
195
+ }
196
+ }
197
+ }
198
+
199
+ fun Color.toUIColor(): UIColor {
200
+ val argb = this.toArgb()
201
+
202
+ val a = ((argb shr 24) and 0xFF) / 255.0
203
+ val r = ((argb shr 16) and 0xFF) / 255.0
204
+ val g = ((argb shr 8) and 0xFF) / 255.0
205
+ val b = (argb and 0xFF) / 255.0
206
+
207
+ return UIColor(
208
+ red = r,
209
+ green = g,
210
+ blue = b,
211
+ alpha = a
212
+ )
213
+ }
214
+
215
+ actual fun NativePaint.setColor(color: Color){
216
+ this.color = color.toArgb()
217
+ }
@@ -0,0 +1,94 @@
1
+ package vn.momo.kits.platform
2
+
3
+ import androidx.compose.runtime.Composable
4
+ import androidx.compose.runtime.DisposableEffect
5
+ import androidx.compose.runtime.getValue
6
+ import androidx.compose.runtime.mutableStateOf
7
+ import androidx.compose.runtime.remember
8
+ import androidx.compose.runtime.setValue
9
+ import androidx.compose.ui.uikit.LocalUIViewController
10
+ import androidx.compose.ui.unit.dp
11
+ import kotlinx.cinterop.BetaInteropApi
12
+ import kotlinx.cinterop.ExperimentalForeignApi
13
+ import kotlinx.cinterop.interpretObjCPointer
14
+ import kotlinx.cinterop.objcPtr
15
+ import kotlinx.cinterop.readValue
16
+ import kotlinx.cinterop.useContents
17
+ import platform.CoreGraphics.CGRectZero
18
+ import platform.Foundation.NSArray
19
+ import platform.Foundation.NSSelectorFromString
20
+ import platform.Foundation.NSValue
21
+ import platform.Foundation.valueForKey
22
+ import platform.UIKit.CGRectValue
23
+ import platform.UIKit.UIView
24
+ import platform.UIKit.UIViewAutoresizingFlexibleHeight
25
+ import platform.UIKit.UIViewAutoresizingFlexibleWidth
26
+ import platform.darwin.NSObject
27
+ import platform.Foundation.NSClassFromString
28
+
29
+ // The API is newer than the SDK Kotlin/Native binds, so it is reached through the runtime.
30
+ @OptIn(ExperimentalForeignApi::class)
31
+ private val regionsOfKind = NSSelectorFromString("reservedRegionsOfKind:")
32
+
33
+ @OptIn(ExperimentalForeignApi::class, BetaInteropApi::class)
34
+ private fun UIView.occlusionRegions(target: UIView): List<ReservedRegion> {
35
+ if (window == null || !respondsToSelector(regionsOfKind)) return emptyList()
36
+ // a class object fails `as? NSObjectProtocol` (K/N checks it as an instance), so it is reinterpreted
37
+ val kindClass = NSClassFromString("UIViewReservedRegionKind")
38
+ ?.let { interpretObjCPointer<NSObject>(it.objcPtr()) } ?: return emptyList()
39
+ val kind = kindClass.performSelector(NSSelectorFromString("occlusionRegionKind")) ?: return emptyList()
40
+ val regions = when (val result = performSelector(regionsOfKind, withObject = kind)) {
41
+ is List<*> -> result
42
+ is NSArray -> List(result.count.toInt()) { result.objectAtIndex(it.toULong()) }
43
+ else -> return emptyList()
44
+ }
45
+ return regions.mapNotNull { region ->
46
+ val frame = ((region as? NSObject)?.valueForKey("frame") as? NSValue)?.CGRectValue ?: return@mapNotNull null
47
+ convertRect(frame, toView = target).useContents {
48
+ ReservedRegion(origin.x.dp, origin.y.dp, size.width.dp, size.height.dp)
49
+ }
50
+ }
51
+ }
52
+
53
+ // Invisible full-size probe: reading the regions in layoutSubviews makes UIKit run it again
54
+ // when they change, so nothing polls.
55
+ @OptIn(ExperimentalForeignApi::class)
56
+ private class ReservedRegionsProbe(
57
+ private val onChange: (List<ReservedRegion>) -> Unit,
58
+ ) : UIView(frame = CGRectZero.readValue()) {
59
+ private var last: List<ReservedRegion>? = null
60
+
61
+ init {
62
+ userInteractionEnabled = false
63
+ autoresizingMask = UIViewAutoresizingFlexibleWidth or UIViewAutoresizingFlexibleHeight
64
+ }
65
+
66
+ override fun layoutSubviews() {
67
+ super.layoutSubviews()
68
+ val regions = superview?.let { occlusionRegions(it) } ?: emptyList()
69
+ if (regions != last) {
70
+ last = regions
71
+ onChange(regions)
72
+ }
73
+ }
74
+
75
+ override fun didMoveToWindow() {
76
+ super.didMoveToWindow()
77
+ setNeedsLayout()
78
+ }
79
+ }
80
+
81
+ @OptIn(ExperimentalForeignApi::class)
82
+ @Composable
83
+ internal actual fun rememberReservedRegions(): List<ReservedRegion> {
84
+ if (!isPhoneIdiom()) return emptyList()
85
+ val host = LocalUIViewController.current.view
86
+ var regions by remember { mutableStateOf(emptyList<ReservedRegion>()) }
87
+ DisposableEffect(host) {
88
+ val probe = ReservedRegionsProbe { regions = it }
89
+ probe.setFrame(host.bounds)
90
+ host.insertSubview(probe, atIndex = 0)
91
+ onDispose { probe.removeFromSuperview() }
92
+ }
93
+ return regions
94
+ }
@@ -0,0 +1,76 @@
1
+ [versions]
2
+ # AI-GENERATED START: align Kits and its samples with the approved SDK 36 toolchain
3
+ android-compileSdk = "36"
4
+ # AI-GENERATED END: align Kits and its samples with the approved SDK 36 toolchain
5
+ android-minSdk = "24"
6
+ android-targetSdk = "36"
7
+ ktor-version = "3.0.0-rc-1"
8
+ coroutines = "1.9.0"
9
+ kotlin = "2.3.10"
10
+ kSerialize = "1.7.1"
11
+ compose = "1.10.3"
12
+ navigation-multiplatform = "2.9.2"
13
+ coil3-multiplatform = "3.0.0-alpha10"
14
+ # AI-GENERATED START: align the Android toolchain with the integrating app
15
+ androidGradlePlugin = "9.2.1"
16
+ # AI-GENERATED END: align the Android toolchain with the integrating app
17
+ r8 = "8.9.35"
18
+ kotlinx-datetime = "0.7.1"
19
+ airbnb-lottie = "5.2.0"
20
+ compottie = "2.1.0"
21
+ androidx-activity = "1.9.1"
22
+ androidx-appcompat = "1.7.0"
23
+ material = "1.10.0"
24
+ vanniktechMavenPublish = "0.34.0"
25
+ kits = "0.167.1-duo.1"
26
+ nativemaxapi = "0.3.9"
27
+ gif-image = "0.1.2"
28
+
29
+ [libraries]
30
+ ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor-version" }
31
+ ktor-client-darwin = { group = "io.ktor", name = "ktor-client-darwin", version.ref = "ktor-version" }
32
+ ktor-client-okhttp = { group = "io.ktor", name = "ktor-client-okhttp", version.ref = "ktor-version" }
33
+ jetbrains-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "coroutines" }
34
+ jetbrains-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" }
35
+ jetbrains-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutines" }
36
+ jetbrains-serialization = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization", version.ref = "kSerialize" }
37
+ jetbrains-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kSerialize" }
38
+ kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinx-datetime" }
39
+ compose-ui-backhandler = { module = "org.jetbrains.compose.ui:ui-backhandler", version.ref = "compose" }
40
+ navigation-multiplatform = { module = "org.jetbrains.androidx.navigation:navigation-compose", version.ref = "navigation-multiplatform" }
41
+ coil-multiplatform-core = { module = "io.coil-kt.coil3:coil-core", version.ref = "coil3-multiplatform" }
42
+ coil-multiplatform-compose = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coil3-multiplatform" }
43
+ coil-multiplatform-network-ktor = { module = "io.coil-kt.coil3:coil-network-ktor3", version.ref = "coil3-multiplatform" }
44
+ r8 = { module = "com.android.tools:r8", version.ref = "r8" }
45
+ airbnb-lottie = { group = "com.airbnb.android", name = "lottie-compose", version.ref = "airbnb-lottie" }
46
+ # AI-GENERATED START
47
+ # Depend on compottie-core (not the `compottie` umbrella). The umbrella drags in the
48
+ # separate `keight` umbrella artifact, which collides with `keight-core` on the
49
+ # `findRoot__at__ScriptRuntime` symbol (duplicate symbol at the iOS `ld` link of
50
+ # shared.framework). compottie-core pulls only `keight-core` (which declares
51
+ # keight.js.JsAny, so the earlier unlinked-symbol error stays fixed too).
52
+ compottie = { module = "io.github.alexzhirkevich:compottie-core", version.ref = "compottie" }
53
+ # AI-GENERATED END
54
+ native-max-api = { group = "vn.momo.maxapi", name = "NativeMaxApi", version.ref = "nativemaxapi" }
55
+ kits = { module = "vn.momo.kits:kits", version.ref = "kits" }
56
+ androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
57
+ androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
58
+ material = { module = "com.google.android.material:material", version.ref = "material" }
59
+
60
+ gif-image = { module = "vn.momo.kits:gif-image", version.ref = "gif-image" }
61
+ [plugins]
62
+ jetbrains-kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
63
+ jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
64
+ jetbrains-kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
65
+ jetbrains-kotlin-cocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" }
66
+ jetbrains-kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
67
+ jetbrains-kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
68
+ kotlin-compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
69
+ compose = { id = "org.jetbrains.compose", version.ref = "compose" }
70
+ android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
71
+ android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
72
+ vanniktech-mavenPublish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktechMavenPublish" }
73
+
74
+ # AI-GENERATED START: use the AGP Android target for Kotlin Multiplatform libraries
75
+ android-kotlin-multiplatform-library = { id = "com.android.kotlin.multiplatform.library", version.ref = "androidGradlePlugin" }
76
+ # AI-GENERATED END: use the AGP Android target for Kotlin Multiplatform libraries
@@ -0,0 +1,10 @@
1
+ #Thu Jul 31 17:05:40 ICT 2025
2
+ distributionBase=GRADLE_USER_HOME
3
+ distributionPath=wrapper/dists
4
+ # AI-GENERATED START: align the Gradle wrapper with the integrating app
5
+ distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip
6
+ # AI-GENERATED END: align the Gradle wrapper with the integrating app
7
+ networkTimeout=10000
8
+ validateDistributionUrl=true
9
+ zipStoreBase=GRADLE_USER_HOME
10
+ 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.300.4
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
package/gradlew ADDED
@@ -0,0 +1,252 @@
1
+ #!/bin/sh
2
+
3
+ #
4
+ # Copyright © 2015-2021 the original authors.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ # SPDX-License-Identifier: Apache-2.0
19
+ #
20
+
21
+ ##############################################################################
22
+ #
23
+ # Gradle start up script for POSIX generated by Gradle.
24
+ #
25
+ # Important for running:
26
+ #
27
+ # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28
+ # noncompliant, but you have some other compliant shell such as ksh or
29
+ # bash, then to run this script, type that shell name before the whole
30
+ # command line, like:
31
+ #
32
+ # ksh Gradle
33
+ #
34
+ # Busybox and similar reduced shells will NOT work, because this script
35
+ # requires all of these POSIX shell features:
36
+ # * functions;
37
+ # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38
+ # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39
+ # * compound commands having a testable exit status, especially «case»;
40
+ # * various built-in commands including «command», «set», and «ulimit».
41
+ #
42
+ # Important for patching:
43
+ #
44
+ # (2) This script targets any POSIX shell, so it avoids extensions provided
45
+ # by Bash, Ksh, etc; in particular arrays are avoided.
46
+ #
47
+ # The "traditional" practice of packing multiple parameters into a
48
+ # space-separated string is a well documented source of bugs and security
49
+ # problems, so this is (mostly) avoided, by progressively accumulating
50
+ # options in "$@", and eventually passing that to Java.
51
+ #
52
+ # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53
+ # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54
+ # see the in-line comments for details.
55
+ #
56
+ # There are tweaks for specific operating systems such as AIX, CygWin,
57
+ # Darwin, MinGW, and NonStop.
58
+ #
59
+ # (3) This script is generated from the Groovy template
60
+ # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61
+ # within the Gradle project.
62
+ #
63
+ # You can find Gradle at https://github.com/gradle/gradle/.
64
+ #
65
+ ##############################################################################
66
+
67
+ # Attempt to set APP_HOME
68
+
69
+ # Resolve links: $0 may be a link
70
+ app_path=$0
71
+
72
+ # Need this for daisy-chained symlinks.
73
+ while
74
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75
+ [ -h "$app_path" ]
76
+ do
77
+ ls=$( ls -ld "$app_path" )
78
+ link=${ls#*' -> '}
79
+ case $link in #(
80
+ /*) app_path=$link ;; #(
81
+ *) app_path=$APP_HOME$link ;;
82
+ esac
83
+ done
84
+
85
+ # This is normally unused
86
+ # shellcheck disable=SC2034
87
+ APP_BASE_NAME=${0##*/}
88
+ # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89
+ APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90
+ ' "$PWD" ) || exit
91
+
92
+ # Use the maximum available, or set MAX_FD != -1 to use that value.
93
+ MAX_FD=maximum
94
+
95
+ warn () {
96
+ echo "$*"
97
+ } >&2
98
+
99
+ die () {
100
+ echo
101
+ echo "$*"
102
+ echo
103
+ exit 1
104
+ } >&2
105
+
106
+ # OS specific support (must be 'true' or 'false').
107
+ cygwin=false
108
+ msys=false
109
+ darwin=false
110
+ nonstop=false
111
+ case "$( uname )" in #(
112
+ CYGWIN* ) cygwin=true ;; #(
113
+ Darwin* ) darwin=true ;; #(
114
+ MSYS* | MINGW* ) msys=true ;; #(
115
+ NONSTOP* ) nonstop=true ;;
116
+ esac
117
+
118
+ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
119
+
120
+
121
+ # Determine the Java command to use to start the JVM.
122
+ if [ -n "$JAVA_HOME" ] ; then
123
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
124
+ # IBM's JDK on AIX uses strange locations for the executables
125
+ JAVACMD=$JAVA_HOME/jre/sh/java
126
+ else
127
+ JAVACMD=$JAVA_HOME/bin/java
128
+ fi
129
+ if [ ! -x "$JAVACMD" ] ; then
130
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
131
+
132
+ Please set the JAVA_HOME variable in your environment to match the
133
+ location of your Java installation."
134
+ fi
135
+ else
136
+ JAVACMD=java
137
+ if ! command -v java >/dev/null 2>&1
138
+ then
139
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
140
+
141
+ Please set the JAVA_HOME variable in your environment to match the
142
+ location of your Java installation."
143
+ fi
144
+ fi
145
+
146
+ # Increase the maximum file descriptors if we can.
147
+ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
148
+ case $MAX_FD in #(
149
+ max*)
150
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
151
+ # shellcheck disable=SC2039,SC3045
152
+ MAX_FD=$( ulimit -H -n ) ||
153
+ warn "Could not query maximum file descriptor limit"
154
+ esac
155
+ case $MAX_FD in #(
156
+ '' | soft) :;; #(
157
+ *)
158
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
159
+ # shellcheck disable=SC2039,SC3045
160
+ ulimit -n "$MAX_FD" ||
161
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
162
+ esac
163
+ fi
164
+
165
+ # Collect all arguments for the java command, stacking in reverse order:
166
+ # * args from the command line
167
+ # * the main class name
168
+ # * -classpath
169
+ # * -D...appname settings
170
+ # * --module-path (only if needed)
171
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
172
+
173
+ # For Cygwin or MSYS, switch paths to Windows format before running java
174
+ if "$cygwin" || "$msys" ; then
175
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
176
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
177
+
178
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
179
+
180
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
181
+ for arg do
182
+ if
183
+ case $arg in #(
184
+ -*) false ;; # don't mess with options #(
185
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
186
+ [ -e "$t" ] ;; #(
187
+ *) false ;;
188
+ esac
189
+ then
190
+ arg=$( cygpath --path --ignore --mixed "$arg" )
191
+ fi
192
+ # Roll the args list around exactly as many times as the number of
193
+ # args, so each arg winds up back in the position where it started, but
194
+ # possibly modified.
195
+ #
196
+ # NB: a `for` loop captures its iteration list before it begins, so
197
+ # changing the positional parameters here affects neither the number of
198
+ # iterations, nor the values presented in `arg`.
199
+ shift # remove old arg
200
+ set -- "$@" "$arg" # push replacement arg
201
+ done
202
+ fi
203
+
204
+
205
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
206
+ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
207
+
208
+ # Collect all arguments for the java command:
209
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
210
+ # and any embedded shellness will be escaped.
211
+ # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
212
+ # treated as '${Hostname}' itself on the command line.
213
+
214
+ set -- \
215
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
216
+ -classpath "$CLASSPATH" \
217
+ org.gradle.wrapper.GradleWrapperMain \
218
+ "$@"
219
+
220
+ # Stop when "xargs" is not available.
221
+ if ! command -v xargs >/dev/null 2>&1
222
+ then
223
+ die "xargs is not available"
224
+ fi
225
+
226
+ # Use "xargs" to parse quoted args.
227
+ #
228
+ # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
229
+ #
230
+ # In Bash we could simply go:
231
+ #
232
+ # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
233
+ # set -- "${ARGS[@]}" "$@"
234
+ #
235
+ # but POSIX shell has neither arrays nor command substitution, so instead we
236
+ # post-process each arg (as a line of input to sed) to backslash-escape any
237
+ # character that might be a shell metacharacter, then use eval to reverse
238
+ # that process (while maintaining the separation between arguments), and wrap
239
+ # the whole thing up as a single "set" statement.
240
+ #
241
+ # This will of course break if any of these variables contains a newline or
242
+ # an unmatched quote.
243
+ #
244
+
245
+ eval "set -- $(
246
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
247
+ xargs -n1 |
248
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
249
+ tr '\n' ' '
250
+ )" '"$@"'
251
+
252
+ exec "$JAVACMD" "$@"