@momo-kits/native-kits 0.300.8-beta.1-debug → 0.300.8-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.
Files changed (150) hide show
  1. package/package.json +1 -1
  2. package/build.gradle.kts +0 -13
  3. package/compose/build.gradle.kts +0 -195
  4. package/compose/build.gradle.kts.backup +0 -195
  5. package/compose/compose.podspec +0 -47
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -61
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsBinding.kt +0 -60
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsHost.kt +0 -32
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1067
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -268
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -55
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -354
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -130
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -482
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -224
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -137
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -473
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -113
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -262
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -237
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -228
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -280
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -183
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -342
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -40
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -82
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -39
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -362
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -304
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -88
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -308
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -218
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -456
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -205
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -89
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -542
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -175
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -201
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -208
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -12
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -291
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -71
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -184
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -315
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -54
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -397
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -153
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -118
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -212
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -750
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -152
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -244
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -398
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -103
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -93
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -208
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -133
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -167
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -446
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -387
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +0 -33
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -197
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +0 -38
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -135
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -114
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -7
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -76
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -21
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -117
  130. package/compose/src/commonTest/kotlin/vn/momo/kits/application/KitsHostTest.kt +0 -44
  131. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +0 -39
  132. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +0 -53
  133. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  135. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -31
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -65
  138. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  139. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  140. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -143
  141. package/gradle/libs.versions.toml +0 -66
  142. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  143. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  144. package/gradle.properties +0 -24
  145. package/gradlew +0 -252
  146. package/gradlew.bat +0 -94
  147. package/ios-demo/README.md +0 -120
  148. package/scripts/ci/build-swiftui.sh +0 -22
  149. package/scripts/ci/resolve-version.mjs +0 -144
  150. package/settings.gradle.kts +0 -63
@@ -1,55 +0,0 @@
1
- package vn.momo.kits.utils
2
-
3
- import androidx.compose.runtime.*
4
- import org.jetbrains.compose.resources.DrawableResource
5
- import org.jetbrains.compose.resources.InternalResourceApi
6
- import org.jetbrains.compose.resources.ResourceItem
7
- import org.jetbrains.compose.resources.readResourceBytes
8
- @OptIn(InternalResourceApi::class)
9
- @Composable
10
- internal fun readJson(name: String): String {
11
- val path = name.plus(".json")
12
- val candidatePaths = listOf(
13
- path,
14
- "composeResources/vn.momo.compose.resources/$path",
15
- )
16
-
17
- val jsonContent by rememberState(path, { "" }) {
18
- val cached = resourceCache.getOrPut(path) {
19
- var content = ""
20
- for (candidate in candidatePaths) {
21
- try {
22
- content = readResourceBytes(candidate).decodeToString()
23
- break
24
- } catch (_: Exception) {
25
- // try next candidate
26
- }
27
- }
28
- ResourceCache.JSON(content)
29
- } as ResourceCache.JSON
30
-
31
- cached.json
32
- }
33
-
34
- return jsonContent
35
- }
36
-
37
-
38
- private val resourceCache = mutableMapOf<String, ResourceCache>()
39
-
40
- private sealed interface ResourceCache {
41
- class JSON(val json: String) : ResourceCache
42
- }
43
-
44
- @Composable
45
- fun <T> rememberState(
46
- key: Any,
47
- getDefault: () -> T,
48
- block: suspend () -> T
49
- ): MutableState<T> {
50
- val state = remember(key) { mutableStateOf(getDefault()) }
51
- LaunchedEffect(key) {
52
- state.value = block()
53
- }
54
- return state
55
- }
@@ -1,15 +0,0 @@
1
- package vn.momo.kits.utils
2
-
3
- import androidx.compose.runtime.Composable
4
- import vn.momo.kits.application.LocalComponentInformation
5
-
6
- @Composable
7
- internal fun getComponentId(
8
- componentName: String? = null,
9
- accessibilityLabel: String? = null,
10
- ): String {
11
- val componentInformation = LocalComponentInformation.current
12
- if (accessibilityLabel != null) return accessibilityLabel
13
- if (componentInformation?.componentId != null) return componentInformation.componentId
14
- return ""
15
- }
@@ -1,117 +0,0 @@
1
- package vn.momo.kits.utils
2
-
3
- import androidx.compose.foundation.layout.WindowInsets
4
- import androidx.compose.foundation.layout.WindowInsetsSides
5
- import androidx.compose.foundation.layout.displayCutout
6
- import androidx.compose.foundation.layout.only
7
- import androidx.compose.foundation.layout.union
8
- import androidx.compose.foundation.layout.windowInsetsPadding
9
- import androidx.compose.foundation.layout.asPaddingValues
10
- import androidx.compose.foundation.layout.systemBars
11
- import androidx.compose.runtime.Composable
12
- import androidx.compose.ui.Modifier
13
- import androidx.compose.ui.composed
14
- import androidx.compose.ui.draw.drawBehind
15
- import androidx.compose.ui.geometry.Offset
16
- import androidx.compose.ui.graphics.Color
17
- import androidx.compose.ui.platform.LocalDensity
18
- import androidx.compose.ui.unit.Dp
19
- import androidx.compose.ui.unit.dp
20
- import androidx.compose.ui.unit.min
21
- import vn.momo.kits.const.AppNavigationBar
22
- import vn.momo.kits.const.AppStatusBar
23
- import vn.momo.kits.platform.getPlatformName
24
- import kotlin.math.abs
25
-
26
-
27
- internal fun Modifier.bottomBorder(strokeWidth: Dp, color: Color) = composed(
28
- factory = {
29
- val density = LocalDensity.current
30
- val strokeWidthPx = density.run { strokeWidth.toPx() }
31
- if (strokeWidth > 0.dp) {
32
- Modifier.drawBehind {
33
- val width = size.width
34
- val height = size.height - strokeWidthPx / 2
35
-
36
- drawLine(
37
- color = color,
38
- start = Offset(x = 0f, y = height),
39
- end = Offset(x = width, y = height),
40
- strokeWidth = strokeWidthPx
41
- )
42
- }
43
- } else {
44
- Modifier
45
- }
46
- }
47
- )
48
-
49
- fun <T> Boolean.ifTrue(trueCase: T, falseCase: T): T = if (this) trueCase else falseCase
50
- fun <T> String.ifNotNull(trueCase: T, falseCase: T): T = if (this.isBlank()) falseCase else trueCase
51
-
52
- fun formatNumberToMoney(number: Long, currency: String = "đ"): String {
53
- if (number == 0L) {
54
- return "0$currency"
55
- }
56
- val array = mutableListOf<Char>()
57
- var result = ""
58
- var isNegative = false
59
-
60
- if (number < 0) {
61
- isNegative = true
62
- }
63
- val numberString = abs(number).toString()
64
- if (numberString.length < 3) {
65
- return numberString + currency
66
- }
67
- var count = 0
68
- for (i in numberString.length - 1 downTo 0) {
69
- count += 1
70
- array.add(numberString[i])
71
- if (count == 3 && i >= 1) {
72
- array.add('.')
73
- count = 0
74
- }
75
- }
76
-
77
- for (i in array.size - 1 downTo 0) {
78
- result += array[i]
79
- }
80
-
81
- if (isNegative) {
82
- result = "-$result"
83
- }
84
-
85
- return result + currency
86
- }
87
-
88
- @Composable
89
- fun getAppStatusBarHeight(): Dp {
90
- return if (AppStatusBar.current == 0.dp) {
91
- WindowInsets.systemBars.asPaddingValues().calculateTopPadding()
92
- } else {
93
- AppStatusBar.current
94
- }
95
- }
96
-
97
- internal val horizontalSafeAreaInsets: WindowInsets
98
- @Composable get() = WindowInsets.systemBars.union(WindowInsets.displayCutout).only(WindowInsetsSides.Horizontal)
99
-
100
- // Left/right safe area like SwiftUI (landscape camera/notch); consumed, so nested StackScreens don't pad twice.
101
- internal fun Modifier.horizontalSafeAreaPadding(): Modifier = composed {
102
- windowInsetsPadding(horizontalSafeAreaInsets)
103
- }
104
-
105
- @Composable
106
- internal fun getNavigationBarHeight(): Dp {
107
- return if (AppNavigationBar.current == 0.dp) {
108
- val systemBottomPadding = WindowInsets.systemBars.asPaddingValues().calculateBottomPadding()
109
- if (getPlatformName() == "iOS") {
110
- min(systemBottomPadding, 21.dp)
111
- } else {
112
- systemBottomPadding
113
- }
114
- } else {
115
- AppNavigationBar.current
116
- }
117
- }
@@ -1,44 +0,0 @@
1
- package vn.momo.kits.application
2
-
3
- import kotlinx.serialization.json.JsonObject
4
- import kotlin.test.AfterTest
5
- import kotlin.test.Test
6
- import kotlin.test.assertEquals
7
- import kotlin.test.assertSame
8
-
9
- class KitsHostTest {
10
- @AfterTest
11
- fun reset() = KitsHost.uninstall()
12
-
13
- @Test
14
- fun withoutAnInstallTheBindingDoesNothing() {
15
- val binding = KitsHost.binding
16
- binding.dismiss(KitsDismissTarget.Current)
17
- binding.trackEvent("event", JsonObject(emptyMap()))
18
- var called = false
19
- assertSame(KitsRequest.None, binding.getLanguage { called = true })
20
- assertEquals(false, called)
21
- }
22
-
23
- @Test
24
- fun theLastInstalledBindingIsUsedUntilUninstalled() {
25
- val first = RecordingBinding()
26
- val second = RecordingBinding()
27
- KitsHost.install(first)
28
- KitsHost.install(second)
29
- KitsHost.binding.dismiss(KitsDismissTarget.All)
30
- assertEquals(emptyList(), first.dismissed)
31
- assertEquals(listOf(KitsDismissTarget.All), second.dismissed)
32
- KitsHost.uninstall()
33
- assertSame(NoOpKitsBinding, KitsHost.binding)
34
- }
35
-
36
- private class RecordingBinding : KitsBinding {
37
- val dismissed = mutableListOf<KitsDismissTarget>()
38
- override fun dismiss(target: KitsDismissTarget) {
39
- dismissed += target
40
- }
41
- override fun trackEvent(eventName: String, attributes: JsonObject) = Unit
42
- override fun getLanguage(callback: (String) -> Unit): KitsRequest = KitsRequest.None
43
- }
44
- }
@@ -1,39 +0,0 @@
1
- // File: HelpCenterRequestTest.kt
2
- // Created At: 2026-10-19 +07:00
3
- // Created By: AI | AI Agent: Codex | Model: GPT-6
4
- package vn.momo.kits.navigation.component
5
-
6
- import kotlinx.serialization.json.JsonObject
7
- import kotlinx.serialization.json.JsonPrimitive
8
- import vn.momo.kits.application.MiniAppContext
9
- import kotlin.test.Test
10
- import kotlin.test.assertEquals
11
- import kotlin.test.assertNull
12
-
13
- class HelpCenterRequestTest {
14
- @Test
15
- fun preservesApplicationIdentityAndLocalizedObjects() {
16
- val context = MiniAppContext(
17
- appId = "app-id",
18
- appCode = "app-code",
19
- appIcon = "app-icon",
20
- appName = mapOf("vi" to "Tên ứng dụng", "en" to "App name"),
21
- description = mapOf("vi" to "Mô tả", "en" to "Description"),
22
- )
23
- val request = context.helpCenterRequest()
24
- assertEquals(context.appId, request.appId)
25
- assertEquals(context.appCode, request.code)
26
- assertEquals(context.appIcon, request.icon)
27
- assertEquals(JsonObject(mapOf("vi" to JsonPrimitive("Tên ứng dụng"),
28
- "en" to JsonPrimitive("App name"))), request.name)
29
- assertEquals(JsonObject(mapOf("vi" to JsonPrimitive("Mô tả"),
30
- "en" to JsonPrimitive("Description"))), request.description)
31
- }
32
-
33
- @Test
34
- fun preservesPlainStringsAndAbsentValues() {
35
- val request = MiniAppContext(appName = "App name").helpCenterRequest()
36
- assertEquals(JsonPrimitive("App name"), request.name)
37
- assertNull(request.description)
38
- }
39
- }
@@ -1,53 +0,0 @@
1
- // File: ToolkitRequestsTest.kt
2
- // Created At: 2026-10-12 +07:00 | Created By: AI | AI Agent: Codex | Model: GPT-6
3
- package vn.momo.kits.navigation.component
4
-
5
- import kotlin.test.Test
6
- import kotlin.test.assertEquals
7
- import vn.momo.kits.application.KitsRequest
8
-
9
- class ToolkitRequestsTest {
10
- @Test
11
- fun closingCancelsPendingRequestsAndSuppressesLateCallbacks() {
12
- val owner = ToolkitRequests()
13
- val handle = Handle()
14
- var callback: (Boolean) -> Unit = {}
15
- var results = 0
16
- owner.launch<Boolean>({ callback = it; handle }) { results++ }
17
- owner.close()
18
- owner.close()
19
- callback(true)
20
- assertEquals(1, handle.cancellations)
21
- assertEquals(0, results)
22
- }
23
-
24
- @Test
25
- fun completedRequestsAreReleasedAndClosedOwnersNeverStartNewRequests() {
26
- val owner = ToolkitRequests()
27
- val handle = Handle()
28
- var starts = 0
29
- var results = 0
30
- owner.launch<Boolean>({ callback -> starts++; callback(false); handle }) { results++ }
31
- owner.close()
32
- owner.launch<Boolean>({ starts++; handle }) { results++ }
33
- assertEquals(0, handle.cancellations)
34
- assertEquals(1, starts)
35
- assertEquals(1, results)
36
- }
37
-
38
- @Test
39
- fun subscriptionsStayOpenUntilTheOwnerCloses() {
40
- val owner = ToolkitRequests()
41
- val handle = Handle()
42
- owner.observe { handle }
43
- assertEquals(0, handle.cancellations)
44
- owner.close()
45
- owner.observe { handle }
46
- assertEquals(1, handle.cancellations)
47
- }
48
-
49
- private class Handle : KitsRequest {
50
- var cancellations = 0
51
- override fun cancel() { cancellations++ }
52
- }
53
- }
@@ -1,42 +0,0 @@
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.font.FontWeight
9
- import androidx.compose.ui.text.platform.Font
10
- import kotlinx.cinterop.ExperimentalForeignApi
11
- import kotlinx.cinterop.addressOf
12
- import kotlinx.cinterop.usePinned
13
- import platform.Foundation.NSBundle
14
- import platform.Foundation.NSData
15
- import platform.Foundation.dataWithContentsOfFile
16
- import platform.posix.memcpy
17
-
18
- @Composable
19
- internal actual fun hostFontFamily(fileName: String, weight: FontWeight): FontFamily? = remember(fileName, weight) {
20
- val name = fileName.substringBeforeLast('.')
21
- val ext = fileName.substringAfterLast('.', "")
22
- // Host fonts sit loose at the bundle root, not in compose-resources.
23
- val path = NSBundle.mainBundle.pathForResource(name, ext) ?: return@remember null
24
- FontFamily(
25
- Font(
26
- identity = fileName,
27
- getData = {
28
- NSData.dataWithContentsOfFile(path)?.toByteArray() ?: ByteArray(0)
29
- },
30
- weight = weight,
31
- ),
32
- )
33
- }
34
-
35
- @OptIn(ExperimentalForeignApi::class)
36
- private fun NSData.toByteArray(): ByteArray {
37
- val size = length.toInt()
38
- if (size == 0) return ByteArray(0)
39
- return ByteArray(size).apply {
40
- usePinned { pinned -> memcpy(pinned.addressOf(0), bytes, length) }
41
- }
42
- }
@@ -1,45 +0,0 @@
1
- package vn.momo.kits.navigation
2
-
3
- import androidx.compose.runtime.Composable
4
- import androidx.compose.runtime.DisposableEffect
5
- import androidx.compose.runtime.remember
6
- import androidx.navigationevent.NavigationEvent
7
- import androidx.navigationevent.NavigationEventDispatcher
8
- import androidx.navigationevent.NavigationEventInput
9
-
10
- @Suppress("ParamsComparedByRef")
11
- @Composable
12
- internal fun AttachHostBackGesture(dispatcher: NavigationEventDispatcher, navigator: Navigator) {
13
- val input = remember(dispatcher) { HostNavigationEventInput() }
14
- val target = remember(input, navigator) {
15
- object : HostBackTarget {
16
- override fun canPop() = navigator.canPop()
17
- override fun onBack() = navigator.onBackSafe()
18
- override fun backStarted() = input.backStarted()
19
- override fun backProgressed(progress: Float) = input.backProgressed(progress)
20
- override fun backCompleted() = input.backCompleted()
21
- override fun backCancelled() = input.backCancelled()
22
- }
23
- }
24
-
25
- DisposableEffect(dispatcher, target) {
26
- dispatcher.addInput(input)
27
- HostBackGestureBridge.attach(target)
28
- onDispose {
29
- HostBackGestureBridge.detach(target)
30
- dispatcher.removeInput(input)
31
- }
32
- }
33
- }
34
-
35
- internal class HostNavigationEventInput : NavigationEventInput() {
36
- fun backStarted() = dispatchOnBackStarted(NavigationEvent(swipeEdge = NavigationEvent.EDGE_LEFT))
37
-
38
- fun backProgressed(progress: Float) = dispatchOnBackProgressed(
39
- NavigationEvent(swipeEdge = NavigationEvent.EDGE_LEFT, progress = progress)
40
- )
41
-
42
- fun backCancelled() = dispatchOnBackCancelled()
43
-
44
- fun backCompleted() = dispatchOnBackCompleted()
45
- }
@@ -1,31 +0,0 @@
1
- package vn.momo.kits.navigation
2
-
3
- import androidx.compose.runtime.Composable
4
- import androidx.compose.runtime.DisposableEffect
5
- import platform.Foundation.NSNotification
6
- import platform.Foundation.NSNotificationCenter
7
- import platform.Foundation.NSOperationQueue
8
- import platform.darwin.NSObjectProtocol
9
-
10
- private const val STATUS_BAR_TAPPED_NOTIFICATION = "statusBarSelected"
11
-
12
- @Composable
13
- internal actual fun RegisterScrollToTop(callback: (() -> Unit)?) {
14
- val binding = LocalKitsBinding.current
15
- DisposableEffect(callback, binding) {
16
- val token: NSObjectProtocol? = if (callback != null) {
17
- NSNotificationCenter.defaultCenter.addObserverForName(
18
- name = STATUS_BAR_TAPPED_NOTIFICATION,
19
- `object` = null,
20
- queue = NSOperationQueue.mainQueue,
21
- ) { _: NSNotification? ->
22
- runCatching { callback() }.onFailure {
23
- binding?.logError("[ScrollToTop] callback failed")
24
- }
25
- }
26
- } else null
27
- onDispose {
28
- token?.let { NSNotificationCenter.defaultCenter.removeObserver(it) }
29
- }
30
- }
31
- }
@@ -1,38 +0,0 @@
1
- package vn.momo.kits.platform
2
-
3
- import androidx.compose.runtime.Composable
4
- import androidx.compose.runtime.LaunchedEffect
5
- import androidx.compose.runtime.State
6
- import androidx.compose.runtime.mutableStateOf
7
- import androidx.compose.runtime.remember
8
- import androidx.compose.ui.InternalComposeUiApi
9
- import androidx.compose.ui.backhandler.LocalCompatNavigationEventDispatcherOwner
10
- import androidx.navigationevent.NavigationEventTransitionState
11
- import vn.momo.kits.navigation.HostBackGestureBridge
12
-
13
- // transitionState is a passive observer; its progress is touch.x / view width.
14
- @OptIn(InternalComposeUiApi::class)
15
- @Composable
16
- actual fun rememberBackGestureProgress(): State<Float?> {
17
- val dispatcher = LocalCompatNavigationEventDispatcherOwner.current?.navigationEventDispatcher
18
- val progress = remember { mutableStateOf<Float?>(null) }
19
-
20
- LaunchedEffect(dispatcher) {
21
- if (dispatcher == null) {
22
- progress.value = null
23
- return@LaunchedEffect
24
- }
25
- dispatcher.transitionState.collect { state ->
26
- progress.value = (state as? NavigationEventTransitionState.InProgress)
27
- ?.takeIf { it.direction == NavigationEventTransitionState.TRANSITIONING_BACK }
28
- ?.latestEvent
29
- ?.progress
30
- }
31
- }
32
-
33
- return progress
34
- }
35
-
36
- actual fun reportFloatingArrowBack(shouldUse: Boolean) {
37
- HostBackGestureBridge.shouldUseFloatingArrowBack = shouldUse
38
- }
@@ -1,65 +0,0 @@
1
- package vn.momo.kits.platform
2
-
3
- import androidx.compose.runtime.Composable
4
- import androidx.compose.runtime.CompositionLocalProvider
5
- import androidx.compose.runtime.DisposableEffect
6
- import androidx.compose.runtime.mutableStateOf
7
- import androidx.compose.runtime.remember
8
- import androidx.compose.ui.platform.LocalDensity
9
- import androidx.compose.ui.unit.Density
10
- import kotlinx.cinterop.ExperimentalForeignApi
11
- import kotlinx.cinterop.ObjCAction
12
- import platform.Foundation.NSNotification
13
- import platform.Foundation.NSNotificationCenter
14
- import platform.Foundation.NSSelectorFromString
15
- import platform.UIKit.UIContentSizeCategoryDidChangeNotification
16
- import platform.UIKit.UIFont
17
- import platform.UIKit.UIFontTextStyleBody
18
- import platform.darwin.NSObject
19
-
20
- // Body point size / 17, as in the SwiftUI kit, so both iOS surfaces scale alike.
21
- private const val DEFAULT_BODY_POINT_SIZE = 17.0
22
-
23
- private fun currentOsFontScale(): Float {
24
- return (UIFont.preferredFontForTextStyle(UIFontTextStyleBody).pointSize / DEFAULT_BODY_POINT_SIZE).toFloat()
25
- }
26
-
27
- // Compose MP iOS reads fontScale only once, at ComposeUIViewController creation.
28
- @OptIn(ExperimentalForeignApi::class)
29
- @Composable
30
- actual fun ProvideOsFontScale(content: @Composable () -> Unit) {
31
- val osFontScale = remember { mutableStateOf(currentOsFontScale()) }
32
-
33
- val listener = remember {
34
- object : NSObject() {
35
- @Suppress("unused")
36
- @ObjCAction
37
- fun contentSizeChanged(arg: NSNotification) {
38
- osFontScale.value = currentOsFontScale()
39
- }
40
- }
41
- }
42
-
43
- DisposableEffect(Unit) {
44
- NSNotificationCenter.defaultCenter.addObserver(
45
- observer = listener,
46
- selector = NSSelectorFromString(listener::contentSizeChanged.name + ":"),
47
- name = UIContentSizeCategoryDidChangeNotification,
48
- `object` = null,
49
- )
50
- onDispose {
51
- NSNotificationCenter.defaultCenter.removeObserver(
52
- observer = listener,
53
- name = UIContentSizeCategoryDidChangeNotification,
54
- `object` = null,
55
- )
56
- }
57
- }
58
-
59
- val density = LocalDensity.current
60
- CompositionLocalProvider(
61
- LocalDensity provides Density(density.density, osFontScale.value),
62
- ) {
63
- content()
64
- }
65
- }