@momo-kits/native-kits 0.169.13-beta.4-debug → 0.169.13

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 (173) hide show
  1. package/CLAUDE.md +1 -4
  2. package/ios/Navigation/BottomTab/BottomTabBar.swift +14 -4
  3. package/ios/native-kits.podspec +1 -1
  4. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  5. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +16 -3
  6. package/package.json +1 -1
  7. package/build.gradle.kts +0 -11
  8. package/compose/build.gradle.kts +0 -202
  9. package/compose/compose.podspec +0 -47
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  13. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  14. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  15. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  16. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  17. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiActionsTest.kt +0 -647
  18. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiExprTest.kt +0 -1411
  19. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiHostTest.kt +0 -130
  20. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiKitArgsTest.kt +0 -524
  21. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiKitNodesTest.kt +0 -559
  22. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRenderPlanTest.kt +0 -741
  23. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRenderReuseTest.kt +0 -221
  24. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiRendererPropsTest.kt +0 -270
  25. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiStylePlanTest.kt +0 -849
  26. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiStyleTest.kt +0 -212
  27. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiTrackingTest.kt +0 -239
  28. package/compose/src/androidUnitTest/kotlin/vn/momo/kits/sdui/SduiViewTest.kt +0 -252
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -61
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1067
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -268
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -354
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -130
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -482
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -224
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -137
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -473
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -113
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -262
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -237
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -228
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -280
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -183
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -342
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -40
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -82
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -39
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -362
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -304
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -88
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -308
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -218
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -456
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -205
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -89
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -542
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -175
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -201
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -208
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -12
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -291
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -71
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -184
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -315
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -54
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -397
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -153
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -118
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -206
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -421
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -750
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -152
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -242
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -398
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -103
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -93
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -208
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -133
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -167
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -446
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -400
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -197
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -114
  134. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -7
  135. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -76
  136. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  137. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -21
  138. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiActions.kt +0 -154
  139. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiExpr.kt +0 -1038
  140. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiKitNodes.kt +0 -848
  141. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiLog.kt +0 -47
  142. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiModel.kt +0 -39
  143. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiPropsRenderer.kt +0 -463
  144. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiRenderer.kt +0 -1146
  145. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiStyle.kt +0 -667
  146. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiTracking.kt +0 -240
  147. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiValidate.kt +0 -185
  148. package/compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiView.kt +0 -200
  149. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  150. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  151. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  152. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -117
  153. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  154. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  155. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  156. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  157. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -65
  158. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  159. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  160. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -143
  161. package/gradle/libs.versions.toml +0 -69
  162. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  163. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  164. package/gradle.properties +0 -24
  165. package/gradlew +0 -252
  166. package/gradlew.bat +0 -94
  167. package/ios-demo/README.md +0 -120
  168. package/scripts/sdui-visual/README.md +0 -64
  169. package/scripts/sdui-visual/diff.py +0 -65
  170. package/scripts/sdui-visual/drive.py +0 -234
  171. package/scripts/sdui-visual/plan.json +0 -713
  172. package/scripts/sdui-visual/run.sh +0 -92
  173. package/settings.gradle.kts +0 -64
@@ -1,47 +0,0 @@
1
- // File: compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiLog.kt
2
- // Created At: 2026-10-27 19:00:00 +07:00
3
- // Created By: AI
4
- // AI Agent: Claude Code
5
- // Model: claude-sonnet-5-5
6
-
7
- package vn.momo.kits.sdui
8
-
9
- import kotlin.time.Clock
10
- import kotlin.time.TimeSource
11
-
12
- // AI-GENERATED START: per-view error sink + clocks for the SDUI renderer
13
- /**
14
- * One view's error sink: warnings go to the device log file through the view's MaxApi (`logFile`), as `[SDUI] <label>: <message>`.
15
- * Messages carry spec-level identifiers only (field names, action types, node types), never runtime values: the file stays on the device.
16
- * Never throws; with no MaxApi bound a line is dropped silently. The same message is written once per instance
17
- * (expressions are re-evaluated on every recomposition) and at most [MAX_LINES] distinct lines, so a bad spec cannot flood the file.
18
- */
19
- internal class SduiLog(private val api: SduiMaxApi?, private val label: String = "") {
20
- private val seen = HashSet<String>()
21
-
22
- fun w(message: String) {
23
- val a = api ?: return
24
- runCatching {
25
- if (seen.size >= MAX_LINES || !seen.add(message)) return
26
- a.logFile("[SDUI] $label: $message")
27
- }
28
- }
29
-
30
- companion object {
31
- const val MAX_LINES = 50
32
-
33
- /** No sink: every line is dropped (tests / helpers called without a view). */
34
- val NONE = SduiLog(null)
35
- }
36
- }
37
-
38
- internal object SduiClock {
39
- private val origin = TimeSource.Monotonic.markNow()
40
-
41
- /** Monotonic milliseconds since process start (replaces SystemClock.elapsedRealtime()). */
42
- fun nowMs(): Long = origin.elapsedNow().inWholeMilliseconds
43
-
44
- /** Wall clock in epoch milliseconds (replaces System.currentTimeMillis()). */
45
- fun epochMs(): Long = Clock.System.now().toEpochMilliseconds()
46
- }
47
- // AI-GENERATED END: per-view error sink + clocks for the SDUI renderer
@@ -1,39 +0,0 @@
1
- // File: compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiModel.kt
2
- // Created At: 2026-10-27 17:00:00 +07:00
3
- // Created By: AI
4
- // AI Agent: Claude Code
5
- // Model: claude-sonnet-5-5
6
-
7
- package vn.momo.kits.sdui
8
-
9
- // AI-GENERATED START: SDUI error model and constants
10
- internal const val RENDER_VERSION = SduiView.RENDER_VERSION
11
- /** Largest spec string SduiView accepts (UTF-8 bytes). */
12
- internal const val MAX_PAYLOAD_BYTES = 256 * 1024
13
- /** Deepest JSON nesting (`[` / `{`) SduiView accepts; checked before parsing so no recursive walk can overflow the stack. */
14
- internal const val MAX_JSON_NESTING = 256
15
-
16
- internal object ErrorCode {
17
- /** spec `meta.minRenderVersion` is above this renderer's RENDER_VERSION (an older app met a newer spec) */
18
- const val UNSUPPORTED_VERSION = "UNSUPPORTED_VERSION"
19
- /** spec `meta.mode` this view does not draw (`"screen"`) */
20
- const val UNSUPPORTED_MODE = "UNSUPPORTED_MODE"
21
- const val PARSE = "PARSE"
22
- const val PAYLOAD_TOO_LARGE = "PAYLOAD_TOO_LARGE"
23
- const val SPEC_SHAPE = "SPEC_SHAPE"
24
- }
25
-
26
- internal data class SduiError(
27
- val stage: String,
28
- val code: String,
29
- val retryable: Boolean,
30
- val detail: String? = null,
31
- )
32
-
33
- internal sealed interface SduiResult<out T> {
34
- data class Ok<T>(val value: T) : SduiResult<T>
35
- data class Err(val error: SduiError) : SduiResult<Nothing>
36
- }
37
-
38
- internal fun str(v: Any?, default: String): String = (v as? String)?.takeIf { it.isNotEmpty() } ?: default
39
- // AI-GENERATED END: SDUI error model and constants
@@ -1,463 +0,0 @@
1
- // File: compose/src/commonMain/kotlin/vn/momo/kits/sdui/SduiPropsRenderer.kt
2
- // Created At: 2026-11-03 10:00:00 +07:00
3
- // Created By: AI
4
- // AI Agent: Claude Code
5
- // Model: claude-sonnet-5-5
6
-
7
- package vn.momo.kits.sdui
8
-
9
- import androidx.compose.foundation.layout.Arrangement
10
- import androidx.compose.foundation.layout.PaddingValues
11
- import androidx.compose.ui.Alignment
12
- import androidx.compose.ui.graphics.Color
13
- import androidx.compose.ui.graphics.ColorFilter
14
- import androidx.compose.ui.layout.ContentScale
15
- import androidx.compose.ui.text.input.KeyboardType
16
- import androidx.compose.ui.text.style.TextAlign
17
- import androidx.compose.ui.text.style.TextDecoration
18
- import androidx.compose.ui.text.style.TextOverflow
19
- import androidx.compose.ui.unit.Dp
20
- import androidx.compose.ui.unit.TextUnit
21
- import androidx.compose.ui.unit.LayoutDirection
22
- import androidx.compose.ui.unit.dp
23
- import androidx.compose.ui.unit.sp
24
- import vn.momo.kits.components.ButtonSize
25
- import vn.momo.kits.components.ButtonType
26
- import vn.momo.kits.components.Size
27
- import vn.momo.kits.components.TitleSize
28
- import vn.momo.kits.components.DotSize
29
- import vn.momo.kits.components.IconAlign
30
- import vn.momo.kits.components.ImageState
31
- import vn.momo.kits.components.InputFontWeight
32
- import vn.momo.kits.components.TabViewType
33
- import vn.momo.kits.components.ChipSize
34
- import vn.momo.kits.components.RibbonPosition
35
- import vn.momo.kits.components.TagColor
36
- import vn.momo.kits.components.TagSize
37
- import vn.momo.kits.components.TabViewDirection
38
- import vn.momo.kits.components.TitleType
39
-
40
- // AI-GENERATED START: SDUI props that the kit exposes beyond the first mapping (spec prop name = kit parameter name)
41
- // Pure value mappers: an absent / unknown value falls back to the kit default (or the SDUI default noted per function).
42
-
43
- /** Enum constant -> lowercase snake_case spec value: `TopRight` -> "top_right", `LINE_THROUGH` -> "line_through". */
44
- internal fun snake(v: Any?): String? = (v as? String)?.trim()?.lowercase()?.replace('-', '_')?.replace(' ', '_')?.takeIf { it.isNotEmpty() }
45
-
46
- /** A String prop that may be absent: blank -> null (kit `String? = null`). */
47
- internal fun optStr(v: Any?): String? = v?.let(::str)?.takeIf { it.isNotEmpty() }
48
-
49
- /** Numeric props accept a number or a numeric string ("6"); anything else -> [default]. */
50
- internal fun intOr(v: Any?, default: Int): Int = intOf(v) ?: default
51
- internal fun floatOr(v: Any?, default: Float): Float = numOf(v)?.toFloat() ?: default
52
- internal fun longOr(v: Any?, default: Long): Long = numOf(v)?.toLong() ?: default
53
-
54
- // ---- Text -------------------------------------------------------------------------------------------------------------
55
-
56
- /** clip | ellipsis | visible; absent / unknown = the kit default (Clip). */
57
- /**
58
- * Kit default is Clip, with one owner-approved exception: a Text that limits its lines (`numberOfLines`) and sets no
59
- * `overflow` ends with "…", as every existing spec expects.
60
- */
61
- internal fun textOverflowOf(v: Any?, linesLimited: Boolean = false): TextOverflow = when (snake(v)) {
62
- "ellipsis" -> TextOverflow.Ellipsis
63
- "visible" -> TextOverflow.Visible
64
- "clip" -> TextOverflow.Clip
65
- else -> if (linesLimited) TextOverflow.Ellipsis else TextOverflow.Clip
66
- }
67
-
68
- /** "underline", "line_through" / "line-through", or both ("underline line-through"); "none"/unknown -> null (kit default). */
69
- internal fun textDecorationOf(v: Any?): TextDecoration? {
70
- val s = (v as? String)?.lowercase() ?: return null
71
- val under = s.contains("underline")
72
- val line = s.contains("line-through") || s.contains("line_through") || s.contains("linethrough")
73
- return when {
74
- under && line -> TextDecoration.combine(listOf(TextDecoration.Underline, TextDecoration.LineThrough))
75
- under -> TextDecoration.Underline
76
- line -> TextDecoration.LineThrough
77
- else -> null
78
- }
79
- }
80
-
81
- /** `numberOfLines` <= 0 / absent / not numeric = no limit. */
82
- internal fun maxLinesOf(v: Any?): Int = intOf(v)?.takeIf { it > 0 } ?: Int.MAX_VALUE
83
-
84
- /** `minLines` clamped to 1..maxLines (the kit Text throws when minLines > maxLines). */
85
- internal fun minLinesOf(v: Any?, maxLines: Int): Int = intOr(v, 1).coerceIn(1, maxLines)
86
-
87
- internal fun letterSpacingOf(v: Any?): TextUnit = (v as? Number)?.toFloat()?.sp ?: TextUnit.Unspecified
88
-
89
- // ---- Title ------------------------------------------------------------------------------------------------------------
90
-
91
- internal fun iconAlignOf(v: Any?) = when (snake(v)) { "center" -> IconAlign.Center; "bottom" -> IconAlign.Bottom; else -> IconAlign.Top }
92
- internal fun titleButtonSizeOf(v: Any?) = if (snake(v) == "large") ButtonSize.Large else ButtonSize.Small
93
-
94
- internal fun titleSizeOf(v: Any?) = when (snake(v)) { "small" -> TitleSize.Small; "large" -> TitleSize.Large; else -> TitleSize.Medium }
95
-
96
- // ---- Button -----------------------------------------------------------------------------------------------------------
97
-
98
- /** The kit's default label for Badge / BadgeRibbon / Tag / Chip. */
99
- internal const val KIT_LABEL = "Label"
100
-
101
- /** Button prop -> kit args; absent = kit default (isFull = true, title "Button", type PRIMARY, size LARGE). */
102
- internal data class ButtonArgs(
103
- val type: ButtonType, val size: Size, val title: String, val iconLeft: String, val iconRight: String,
104
- val loading: Boolean, val useTintColor: Boolean, val isFull: Boolean,
105
- )
106
-
107
- internal fun buttonArgsOf(p: Map<String, Any?>) = ButtonArgs(
108
- type = when (snake(p["type"])) {
109
- "outline" -> ButtonType.OUTLINE; "secondary" -> ButtonType.SECONDARY; "tonal" -> ButtonType.TONAL
110
- "danger" -> ButtonType.DANGER; "text" -> ButtonType.TEXT; "disabled" -> ButtonType.DISABLED
111
- else -> ButtonType.PRIMARY
112
- },
113
- size = when (snake(p["size"])) { "small" -> Size.SMALL; "medium" -> Size.MEDIUM; else -> Size.LARGE },
114
- title = p["title"]?.let(::str) ?: "Button",
115
- iconLeft = buttonIconOf(p["iconLeft"]),
116
- iconRight = buttonIconOf(p["iconRight"]),
117
- loading = p["loading"] == true,
118
- useTintColor = boolOr(p["useTintColor"], true),
119
- isFull = boolOr(p["full"], true),
120
- )
121
-
122
- // ---- Image ------------------------------------------------------------------------------------------------------------
123
-
124
- /** top_start | top_center | top_end | center_start | center | center_end | bottom_start | bottom_center | bottom_end. */
125
- internal fun alignmentOf(v: Any?, default: Alignment): Alignment = when (snake(v)) {
126
- "top_start" -> Alignment.TopStart; "top_center" -> Alignment.TopCenter; "top_end" -> Alignment.TopEnd
127
- "center_start" -> Alignment.CenterStart; "center" -> Alignment.Center; "center_end" -> Alignment.CenterEnd
128
- "bottom_start" -> Alignment.BottomStart; "bottom_center" -> Alignment.BottomCenter; "bottom_end" -> Alignment.BottomEnd
129
- else -> default
130
- }
131
-
132
- /** `colorFilter` is a colour: the image is tinted with it (SrcIn). */
133
- internal fun colorFilterOf(c: Color?): ColorFilter? = c?.let { ColorFilter.tint(it) }
134
-
135
- internal fun alphaOf(v: Any?): Float = ((v as? Number)?.toFloat() ?: 1f).coerceIn(0f, 1f)
136
-
137
- /** What `onStateChanged` hands the action: "loading" | "success" | "error". */
138
- internal fun imageStateName(s: ImageState): String = when (s) {
139
- ImageState.Loading -> "loading"; ImageState.Success -> "success"; ImageState.Error -> "error"
140
- }
141
-
142
- // ---- Section / Card ---------------------------------------------------------------------------------------------------
143
-
144
- /**
145
- * `contentPadding`: a number (all sides, dp) or {horizontal, vertical, top, bottom, start|left, end|right}. Absent / not a
146
- * number or map -> null (kit default). Unlisted sides are 0; negative sides are clamped to 0 (PaddingValues throws on them).
147
- */
148
- internal fun paddingValuesOf(v: Any?): PaddingValues? {
149
- parseDp(v as? Number)?.let { return PaddingValues(it.coerceAtLeast(0.dp)) }
150
- val m = v.asMap() ?: return null
151
- fun d(vararg k: String): Dp? = k.firstNotNullOfOrNull { parseDp(m[it]) }?.coerceAtLeast(0.dp)
152
- val h = d("horizontal"); val vt = d("vertical")
153
- return PaddingValues(
154
- start = d("start", "left") ?: h ?: 0.dp, top = d("top") ?: vt ?: 0.dp,
155
- end = d("end", "right") ?: h ?: 0.dp, bottom = d("bottom") ?: vt ?: 0.dp,
156
- )
157
- }
158
-
159
- // ---- Tab view ---------------------------------------------------------------------------------------------------------
160
-
161
- internal fun tabViewTypeOf(v: Any?) = if (snake(v) == "card") TabViewType.CARD else TabViewType.DEFAULT
162
- internal fun dotSizeOf(v: Any?) = if (snake(v) == "large") DotSize.Large else DotSize.Small
163
-
164
- // ---- Pagination -------------------------------------------------------------------------------------------------------
165
-
166
- internal enum class PaginationKind { DOT, WHITE_DOT, NUMBER, SCROLL }
167
-
168
- internal fun paginationKindOf(v: Any?) = when (snake(v)) {
169
- "white_dot" -> PaginationKind.WHITE_DOT; "number" -> PaginationKind.NUMBER; "scroll" -> PaginationKind.SCROLL
170
- else -> PaginationKind.DOT
171
- }
172
-
173
- // ---- ScrollView -------------------------------------------------------------------------------------------------------
174
-
175
- internal fun horizontalArrangementOf(v: Any?): Arrangement.Horizontal = when (snake(v)) {
176
- "end" -> Arrangement.End; "center" -> Arrangement.Center; "space_between" -> Arrangement.SpaceBetween
177
- "space_around" -> Arrangement.SpaceAround; "space_evenly" -> Arrangement.SpaceEvenly
178
- else -> Arrangement.Start
179
- }
180
-
181
- internal fun verticalArrangementOf(v: Any?): Arrangement.Vertical = when (snake(v)) {
182
- "bottom" -> Arrangement.Bottom; "center" -> Arrangement.Center; "space_between" -> Arrangement.SpaceBetween
183
- "space_around" -> Arrangement.SpaceAround; "space_evenly" -> Arrangement.SpaceEvenly
184
- else -> Arrangement.Top
185
- }
186
-
187
- // ---- Badge / BadgeRibbon / Tag / Chip ---------------------------------------------------------------------------------
188
-
189
- internal data class BadgeArgs(val label: String, val backgroundColor: Color?)
190
- internal fun badgeArgsOf(p: Map<String, Any?>) = BadgeArgs(p["label"]?.let(::str) ?: KIT_LABEL, parseColor(p["backgroundColor"]))
191
-
192
- /** top_left | top_right | bottom_left | bottom_right; absent / unknown = TopRight (kit default). */
193
- internal fun ribbonPositionOf(v: Any?) = when (snake(v)) {
194
- "bottom_left" -> RibbonPosition.BottomLeft
195
- "bottom_right" -> RibbonPosition.BottomRight
196
- "top_left" -> RibbonPosition.TopLeft
197
- else -> RibbonPosition.TopRight
198
- }
199
- internal data class RibbonArgs(val position: RibbonPosition, val label: String, val isRound: Boolean)
200
- internal fun ribbonArgsOf(p: Map<String, Any?>) =
201
- RibbonArgs(ribbonPositionOf(p["position"]), p["label"]?.let(::str) ?: KIT_LABEL, p["isRound"] == true)
202
-
203
- internal data class TagArgs(val label: String, val icon: String?, val customColor: Color?, val color: TagColor, val size: TagSize)
204
- internal fun tagArgsOf(p: Map<String, Any?>) = TagArgs(
205
- label = p["label"]?.let(::str) ?: KIT_LABEL, icon = optStr(p["icon"]), customColor = parseColor(p["customColor"]),
206
- color = tagColorOf(p["color"]), size = if (p["size"] == "medium") TagSize.Medium else TagSize.Large,
207
- )
208
-
209
- internal data class ChipArgs(
210
- val label: String, val iconLeft: String?, val iconRight: String?, val iconLeftTint: Color?, val iconRightTint: Color?,
211
- val backgroundColor: Color?, val selected: Boolean, val size: ChipSize, val accessibilityLabel: String?,
212
- )
213
- internal fun chipArgsOf(p: Map<String, Any?>) = ChipArgs(
214
- label = p["label"]?.let(::str) ?: KIT_LABEL, iconLeft = optStr(p["iconLeft"]), iconRight = optStr(p["iconRight"]),
215
- iconLeftTint = parseColor(p["iconLeftTint"]), iconRightTint = parseColor(p["iconRightTint"]),
216
- backgroundColor = parseColor(p["backgroundColor"]), selected = p["selected"] == true,
217
- size = if (p["size"] == "small") ChipSize.SMALL else ChipSize.LARGE, accessibilityLabel = optStr(p["accessibilityLabel"]),
218
- )
219
-
220
- // ---- Grid (Section / Card / Item) -------------------------------------------------------------------------------------
221
-
222
- internal const val GRID_COLS = 12
223
- internal fun gridGutter(card: Boolean): Dp = if (card) 8.dp else 12.dp
224
-
225
- /** Item: widthSpan 1..12 (absent / non-numeric = full width), heightSpan >= 0 (0 = no fixed height). */
226
- internal data class ItemArgs(val widthSpan: Int, val heightSpan: Int)
227
- internal fun itemArgsOf(p: Map<String, Any?>) =
228
- ItemArgs(intOr(p["widthSpan"], GRID_COLS).coerceIn(1, GRID_COLS), intOr(p["heightSpan"], 0).coerceAtLeast(0))
229
-
230
- /** Section keeps only useMargin + backgroundImage; Card also useShadow / backgroundColor / contentPadding (default 12dp, never negative). */
231
- internal data class GridArgs(
232
- val useMargin: Boolean, val backgroundImage: String?, val useShadow: Boolean, val backgroundColor: Color?,
233
- val contentPadding: PaddingValues,
234
- )
235
- internal fun gridArgsOf(p: Map<String, Any?>, card: Boolean) = GridArgs(
236
- useMargin = card || p["useMargin"] != false,
237
- backgroundImage = imageUrl(p["backgroundImage"]),
238
- useShadow = card && p["useShadow"] == true,
239
- backgroundColor = if (card) parseColor(p["backgroundColor"]) else null,
240
- contentPadding = if (card) paddingValuesOf(p["contentPadding"]) ?: PaddingValues(12.dp) else PaddingValues(0.dp),
241
- )
242
-
243
- /**
244
- * sizePerSpan: the width of one 12-column span. A Card's content sits inside its own contentPadding, so the
245
- * actual horizontal padding ([cardHorizontalPadding]) is subtracted (not an assumed 12dp per side). Never negative.
246
- */
247
- internal fun gridSizePerSpan(contentWidth: Dp, useMargin: Boolean, card: Boolean, cardHorizontalPadding: Dp): Dp {
248
- val margin = if (useMargin) 12.dp else 0.dp
249
- val inner = contentWidth - margin * 2 - (if (card) cardHorizontalPadding else 0.dp)
250
- return ((inner - gridGutter(card) * (GRID_COLS - 1)) / GRID_COLS - (1f / GRID_COLS).dp).coerceAtLeast(0.dp)
251
- }
252
-
253
- internal fun PaddingValues.horizontal(): Dp =
254
- calculateLeftPadding(LayoutDirection.Ltr) + calculateRightPadding(LayoutDirection.Ltr)
255
-
256
- // ---- Carousel ---------------------------------------------------------------------------------------------------------
257
-
258
- /** Autoplay period in ms: default 3000, never below 1000 (a tiny value would spin the pager). */
259
- internal fun autoplayIntervalOf(v: Any?): Long = longOr(v, 3000L).coerceAtLeast(1000L)
260
-
261
- // ---- InputSearch ------------------------------------------------------------------------------------------------------
262
-
263
- /** Callbacks that mean "the user types in this field". */
264
- internal val SEARCH_TYPING_CALLBACKS = listOf("onChangeText", "onFocus", "onBlur", "onPressButtonText", "onClearPress", "onRightIconPressed")
265
-
266
- /** onPress (an action, or a prop-form action) is present; where typing callbacks also exist it fires on focus instead of an overlay. */
267
- internal fun searchHasPress(node: Node) = actionsFor(node, "onPress").isNotEmpty()
268
- internal fun searchHasTyping(node: Node) = SEARCH_TYPING_CALLBACKS.any { actionsFor(node, it).isNotEmpty() }
269
-
270
- /** Tap overlay (swallows typing, fires onPress) only for a pure pressable search box: onPress and no typing callbacks. */
271
- internal fun searchShowsOverlay(node: Node) = searchHasPress(node) && !searchHasTyping(node)
272
-
273
- /** onPress AND typing callbacks: no overlay, onPress fires when the field gains focus. */
274
- internal fun searchPressOnFocus(node: Node) = searchHasPress(node) && searchHasTyping(node)
275
-
276
- // ---- Per-node argument plans (pure: the composables only read these and call the kit) ----------------------------------
277
-
278
- /** Text: everything the kit Text is called with; [defaultColor] is the theme text colour, [screenWidth] the screen width in dp. */
279
- internal data class TextArgs(
280
- val text: String, val color: Color, val align: TextAlign, val typography: String?, val lineHeightSp: Float?,
281
- val maxLines: Int, val overflow: TextOverflow, val decoration: TextDecoration?, val fontFamily: String?,
282
- val minLines: Int, val letterSpacing: TextUnit, val softWrap: Boolean, val accessibilityId: String?,
283
- )
284
- internal fun textArgsOf(p: Map<String, Any?>, sty: Sty, defaultColor: Color, screenWidth: Float): TextArgs {
285
- val text = ((p["children"] ?: p["text"])?.let(::str) ?: "").let {
286
- if (sty.str("textTransform") == "uppercase") it.uppercase() else it
287
- }
288
- val align = when (sty.str("textAlign")) {
289
- "center" -> TextAlign.Center
290
- "right" -> TextAlign.End
291
- else -> TextAlign.Start
292
- }
293
- val maxLines = maxLinesOf(p["numberOfLines"])
294
- return TextArgs(
295
- text = text,
296
- color = parseColor(p["color"]) ?: defaultColor,
297
- align = align,
298
- typography = p["typography"] as? String,
299
- // line height scaled by screenWidth/375 instead of the kit's unscaled one
300
- lineHeightSp = specLineHeight(p["typography"] as? String, screenWidth),
301
- maxLines = maxLines,
302
- overflow = textOverflowOf(p["overflow"], linesLimited = maxLinesOf(p["numberOfLines"]) != Int.MAX_VALUE),
303
- decoration = textDecorationOf(p["textDecoration"]),
304
- fontFamily = optStr(p["fontFamily"]),
305
- minLines = minLinesOf(p["minLines"], maxLines),
306
- letterSpacing = letterSpacingOf(p["letterSpacing"]),
307
- softWrap = boolOr(p["softWrap"], true),
308
- accessibilityId = optStr(p["accessibilityId"]),
309
- )
310
- }
311
-
312
- internal data class TitleArgs(
313
- val title: String, val type: TitleType, val size: TitleSize, val icon: String?, val iconColor: Color?, val iconAlign: IconAlign,
314
- val showRightAction: Boolean, val showTrailingAction: Boolean, val badgeLabel: String?, val buttonTitle: String?,
315
- val buttonSize: ButtonSize, val textOnly: Boolean, val description: String?,
316
- )
317
- internal fun titleArgsOf(p: Map<String, Any?>) = TitleArgs(
318
- title = p["title"]?.let(::str) ?: "",
319
- type = if (p["type"] == "card") TitleType.Card else TitleType.Section,
320
- size = titleSizeOf(p["size"]),
321
- icon = optStr(p["icon"]),
322
- iconColor = parseColor(p["iconColor"]),
323
- iconAlign = iconAlignOf(p["iconAlign"]),
324
- showRightAction = p["showRightAction"] == true,
325
- showTrailingAction = p["showTrailingAction"] == true,
326
- badgeLabel = optStr(p["badgeLabel"]),
327
- buttonTitle = optStr(p["buttonTitle"]),
328
- buttonSize = titleButtonSizeOf(p["buttonSize"]),
329
- textOnly = p["textOnly"] == true,
330
- description = optStr(p["description"]),
331
- )
332
-
333
- /** Image: a null result = no usable `source`, nothing is drawn. An absent `resizeMode` is Crop (same as an unknown one). */
334
- internal data class ImageArgs(
335
- val url: String, val alignment: Alignment, val contentScale: ContentScale, val colorFilter: ColorFilter?,
336
- val alpha: Float, val loading: Boolean,
337
- )
338
- internal fun imageArgsOf(p: Map<String, Any?>): ImageArgs? {
339
- val url = imageUrl(p["source"]) ?: return null
340
- return ImageArgs(
341
- url = url,
342
- alignment = alignmentOf(p["alignment"], Alignment.TopStart),
343
- contentScale = if (p["resizeMode"] == null) ContentScale.Crop else contentScale(p["resizeMode"]),
344
- colorFilter = colorFilterOf(parseColor(p["colorFilter"])),
345
- alpha = alphaOf(p["alpha"]),
346
- loading = p["loading"] != false,
347
- )
348
- }
349
-
350
- internal data class IconArgs(val source: String, val size: Dp, val color: Color)
351
- internal fun iconArgsOf(p: Map<String, Any?>, defaultColor: Color) = IconArgs(
352
- source = p["source"]?.let(::str) ?: "",
353
- size = dpProp(p["size"], 24.dp),
354
- color = parseColor(p["color"]) ?: defaultColor,
355
- )
356
-
357
- /** Pagination: [numberLength] is the NUMBER kind's length (default 2 when `dataLength` is absent, unlike the others' 3). */
358
- internal data class PaginationArgs(val kind: PaginationKind, val active: Int, val length: Int, val numberLength: Int)
359
- internal fun paginationArgsOf(p: Map<String, Any?>): PaginationArgs {
360
- val active = intOr(p["activeIndex"], 0)
361
- val length = intOr(p["dataLength"], 3).coerceAtMost(MAX_SPEC_COUNT)
362
- return PaginationArgs(paginationKindOf(p["type"]), active, length, if (p["dataLength"] == null) 2 else length)
363
- }
364
-
365
- internal data class ScrollArgs(
366
- val horizontal: Boolean, val enabled: Boolean, val reverse: Boolean,
367
- val horizontalArrangement: Arrangement.Horizontal, val verticalArrangement: Arrangement.Vertical,
368
- )
369
- internal fun scrollArgsOf(p: Map<String, Any?>) = ScrollArgs(
370
- horizontal = p["horizontal"] == true,
371
- enabled = boolOr(p["enabled"], true),
372
- reverse = p["reverseScrolling"] == true,
373
- horizontalArrangement = horizontalArrangementOf(p["horizontalArrangement"]),
374
- verticalArrangement = verticalArrangementOf(p["verticalArrangement"]),
375
- )
376
-
377
- /**
378
- * InputSearch: [focusEvents] = the callbacks fired in order when the field gains focus (onPress joins them when the node has
379
- * both onPress and typing callbacks); [overlay] = a tap overlay is drawn (pure pressable only).
380
- */
381
- internal data class SearchArgs(
382
- val buttonText: String, val showButtonText: Boolean, val placeholder: String, val disabled: Boolean, val icon: String,
383
- val iconColor: Color, val loading: Boolean, val fontWeight: InputFontWeight, val keyboardType: KeyboardType,
384
- val backgroundColor: Color, val leftPosition: Dp?, val focusEvents: List<String>, val overlay: Boolean,
385
- )
386
- internal fun searchArgsOf(node: Node, p: Map<String, Any?>): SearchArgs {
387
- val placeholder = p["typingData"].asList()?.firstOrNull()?.let(::str) ?: p["placeholder"]?.let(::str) ?: ""
388
- val pressOnFocus = searchPressOnFocus(node)
389
- return SearchArgs(
390
- buttonText = p["buttonText"]?.let(::str) ?: "",
391
- showButtonText = p["showButtonText"] == true,
392
- placeholder = placeholder,
393
- disabled = p["disabled"] == true,
394
- icon = p["icon"]?.let(::str) ?: "",
395
- iconColor = parseColor(p["iconColor"]) ?: Color.Unspecified,
396
- loading = p["loading"] == true,
397
- fontWeight = inputFontWeightOf(p["fontWeight"], InputFontWeight.REGULAR),
398
- keyboardType = keyboardTypeOf(p["keyboardType"]),
399
- backgroundColor = parseColor(p["backgroundColor"]) ?: Color.Unspecified,
400
- leftPosition = parseDp(p["leftPosition"])?.coerceAtLeast(0.dp),
401
- focusEvents = if (pressOnFocus) listOf("onFocus", "onPress") else listOf("onFocus"),
402
- overlay = searchShowsOverlay(node),
403
- )
404
- }
405
-
406
- /** One strip tab: [isUrl] = a CDN picture (drawn as a 24x24 untinted image), else [icon] is a glyph name. */
407
- internal data class TabItemArgs(
408
- val title: String, val icon: String, val isUrl: Boolean, val showDot: Boolean, val dotSize: DotSize,
409
- val badge: String?, val accessibilityLabel: String?,
410
- )
411
- internal data class TabViewArgs(
412
- val tabs: List<TabItemArgs>, val selected: Int, val type: TabViewType, val scrollable: Boolean, val fitContent: Boolean,
413
- val selectedColor: Color?, val unselectedColor: Color?, val direction: TabViewDirection, val userScrollEnabled: Boolean,
414
- )
415
- /** null = no tabs (nothing is drawn). At most 12 tabs; `selectedIndex` is clamped into the tab range. */
416
- internal fun tabViewArgsOf(p: Map<String, Any?>): TabViewArgs? {
417
- val tabs = p["tabs"].asList().orEmpty().mapNotNull { it.asMap() }.take(12)
418
- val selected = ((p["selectedIndex"] as? Number)?.toInt() ?: 0).coerceIn(0, (tabs.size - 1).coerceAtLeast(0))
419
- if (tabs.isEmpty()) return null
420
- val items = tabs.map { t ->
421
- val icon = t["icon"]?.let(::str) ?: ""
422
- TabItemArgs(
423
- title = t["title"]?.let(::str) ?: "",
424
- icon = icon,
425
- isUrl = icon.startsWith("http"),
426
- showDot = t["showDot"] == true,
427
- dotSize = dotSizeOf(t["dotSize"]),
428
- badge = optStr(t["badgeValue"]),
429
- accessibilityLabel = optStr(t["accessibilityLabel"]),
430
- )
431
- }
432
- return TabViewArgs(
433
- tabs = items,
434
- selected = selected,
435
- type = tabViewTypeOf(p["type"]),
436
- scrollable = p["scrollable"] == true,
437
- fitContent = p["fitContent"] == true,
438
- selectedColor = parseColor(p["selectedColor"]),
439
- unselectedColor = parseColor(p["unselectedColor"]),
440
- direction = if (p["direction"] == "column") TabViewDirection.COLUMN else TabViewDirection.ROW,
441
- userScrollEnabled = boolOr(p["userScrollEnabled"], true),
442
- )
443
- }
444
-
445
- internal data class CarouselArgs(
446
- val target: Int, val loop: Boolean, val autoplay: Boolean, val autoplayInterval: Long, val scrollEnabled: Boolean,
447
- val inactiveSlideOpacity: Float, val inactiveSlideScale: Float, val contentPadding: PaddingValues,
448
- )
449
- /** null = no slides (nothing is drawn). `index` is clamped into 0..slides-1. */
450
- internal fun carouselArgsOf(p: Map<String, Any?>, itemCount: Int): CarouselArgs? {
451
- if (itemCount == 0) return null
452
- return CarouselArgs(
453
- target = ((p["index"] as? Number)?.toInt() ?: 0).coerceIn(0, itemCount - 1),
454
- loop = p["loop"] == true,
455
- autoplay = p["autoplay"] == true,
456
- autoplayInterval = autoplayIntervalOf(p["autoplayInterval"]),
457
- scrollEnabled = p["scrollEnabled"] != false,
458
- inactiveSlideOpacity = floatOr(p["inactiveSlideOpacity"], 1f),
459
- inactiveSlideScale = floatOr(p["inactiveSlideScale"], 1f),
460
- contentPadding = paddingValuesOf(p["contentPadding"]) ?: PaddingValues(0.dp),
461
- )
462
- }
463
- // AI-GENERATED END: SDUI props that the kit exposes beyond the first mapping