@momo-kits/native-kits 0.168.1-beta.25-debug → 0.168.1-beta.25

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 (139) hide show
  1. package/package.json +1 -1
  2. package/build.gradle.kts +0 -11
  3. package/compose/build.gradle.kts +0 -198
  4. package/compose/build.gradle.kts.backup +0 -198
  5. package/compose/compose.podspec +0 -47
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -20
  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 -153
  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 -62
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -370
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -17
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -287
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -321
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -499
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -148
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -732
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -232
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -237
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoLiquidSelection.kt +0 -380
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -436
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -399
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -20
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  124. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  125. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -218
  130. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  131. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -138
  132. package/gradle/libs.versions.toml +0 -69
  133. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  134. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  135. package/gradle.properties +0 -26
  136. package/gradlew +0 -252
  137. package/gradlew.bat +0 -94
  138. package/ios-demo/README.md +0 -120
  139. package/settings.gradle.kts +0 -64
@@ -1,560 +0,0 @@
1
- package vn.momo.kits.components
2
-
3
- import androidx.compose.animation.core.animateDpAsState
4
- import androidx.compose.animation.core.tween
5
- import androidx.compose.foundation.*
6
- import androidx.compose.foundation.layout.*
7
- import androidx.compose.foundation.pager.HorizontalPager
8
- import androidx.compose.foundation.pager.rememberPagerState
9
- import androidx.compose.foundation.shape.RoundedCornerShape
10
- import androidx.compose.runtime.*
11
- import androidx.compose.ui.Alignment
12
- import androidx.compose.ui.Modifier
13
- import androidx.compose.ui.draw.clipToBounds
14
- import androidx.compose.ui.geometry.Offset
15
- import androidx.compose.ui.graphics.Color
16
- import androidx.compose.ui.graphics.drawscope.withTransform
17
- import androidx.compose.ui.graphics.Path
18
- import androidx.compose.ui.layout.onGloballyPositioned
19
- import androidx.compose.ui.layout.positionInParent
20
- import androidx.compose.ui.platform.LocalDensity
21
- import androidx.compose.ui.text.style.TextOverflow
22
- import androidx.compose.ui.unit.Dp
23
- import androidx.compose.ui.unit.dp
24
- import kotlinx.coroutines.launch
25
- import vn.momo.kits.application.IsShowBaseLineDebug
26
- import vn.momo.kits.const.*
27
- import vn.momo.kits.modifier.activeOpacityClickable
28
- import vn.momo.kits.modifier.conditional
29
-
30
- data class TabViewItem(
31
- val title: String,
32
- val icon: String? = null,
33
- val renderIcon: (@Composable (active: Boolean) -> Unit)? = null,
34
- val showDot: Boolean = false,
35
- val dotSize: DotSize = DotSize.Small,
36
- val badgeValue: String? = null,
37
- val accessibilityLabel: String? = null,
38
- val content: @Composable () -> Unit = {},
39
- )
40
-
41
- enum class TabViewType { DEFAULT, CARD }
42
-
43
- enum class TabViewDirection { ROW, COLUMN }
44
-
45
- @Composable
46
- fun TabView(
47
- modifier: Modifier = Modifier,
48
- tabs: List<TabViewItem>,
49
- initialPage: Int = 0,
50
- type: TabViewType = TabViewType.DEFAULT,
51
- scrollable: Boolean = false,
52
- fitContent: Boolean = false,
53
- selectedColor: Color? = null,
54
- unselectedColor: Color? = null,
55
- direction: TabViewDirection = TabViewDirection.ROW,
56
- userScrollEnabled: Boolean = true,
57
- onPressTabItem: (Int) -> Unit = {},
58
- onPageSelected: (Int) -> Unit = {},
59
- ) {
60
- if (tabs.isEmpty()) return
61
-
62
- val theme = AppTheme.current
63
- val resolvedSelectedColor = selectedColor ?: theme.colors.primary
64
- val resolvedUnselectedColor = unselectedColor ?: theme.colors.text.default
65
-
66
- val startPage = initialPage.coerceIn(0, tabs.lastIndex)
67
- var selectedIndex by remember { mutableStateOf(startPage) }
68
-
69
- // Track which pages have already been visited for lazy rendering
70
- val lazyRendered = remember { mutableStateListOf(startPage) }
71
-
72
- val pagerState = if (!fitContent) {
73
- rememberPagerState(initialPage = startPage) { tabs.size }
74
- } else null
75
-
76
- val coroutineScope = rememberCoroutineScope()
77
- // The collector below outlives recompositions; read the latest callback, not the first one.
78
- val currentOnPageSelected by rememberUpdatedState(onPageSelected)
79
-
80
- // Keep selectedIndex in sync when user swipes the pager
81
- if (pagerState != null) {
82
- LaunchedEffect(pagerState) {
83
- snapshotFlow { pagerState.currentPage }.collect { page ->
84
- if (!lazyRendered.contains(page)) lazyRendered.add(page)
85
- selectedIndex = page
86
- currentOnPageSelected(page)
87
- }
88
- }
89
- }
90
-
91
- val onTabPressed: (Int) -> Unit = { index ->
92
- onPressTabItem(index)
93
- if (!lazyRendered.contains(index)) lazyRendered.add(index)
94
- selectedIndex = index
95
- if (pagerState != null) {
96
- coroutineScope.launch { pagerState.animateScrollToPage(index) }
97
- }
98
- if (fitContent) {
99
- onPageSelected(index)
100
- }
101
- }
102
-
103
- Column(
104
- modifier = modifier
105
- .fillMaxWidth()
106
- .conditional(IsShowBaseLineDebug) { border(1.dp, Colors.blue_03) },
107
- ) {
108
- // Tab bar
109
- when {
110
- type == TabViewType.CARD -> CardTabBar(
111
- tabs = tabs,
112
- selectedIndex = selectedIndex,
113
- selectedColor = resolvedSelectedColor,
114
- unselectedColor = resolvedUnselectedColor,
115
- direction = direction,
116
- onPressTabItem = onTabPressed,
117
- )
118
-
119
- scrollable -> ScrollableTabBar(
120
- tabs = tabs,
121
- selectedIndex = selectedIndex,
122
- selectedColor = resolvedSelectedColor,
123
- unselectedColor = resolvedUnselectedColor,
124
- direction = direction,
125
- onPressTabItem = onTabPressed,
126
- )
127
-
128
- else -> DefaultTabBar(
129
- tabs = tabs,
130
- selectedIndex = selectedIndex,
131
- selectedColor = resolvedSelectedColor,
132
- unselectedColor = resolvedUnselectedColor,
133
- direction = direction,
134
- onPressTabItem = onTabPressed,
135
- )
136
- }
137
-
138
- // Content area
139
- if (fitContent) {
140
- Box(modifier = Modifier.fillMaxWidth()) {
141
- tabs.getOrNull(selectedIndex)?.content?.invoke()
142
- }
143
- } else if (pagerState != null) {
144
- HorizontalPager(
145
- state = pagerState,
146
- modifier = Modifier
147
- .fillMaxWidth()
148
- .weight(1f),
149
- userScrollEnabled = userScrollEnabled,
150
- ) { page ->
151
- Box(modifier = Modifier.fillMaxWidth()) {
152
- if (lazyRendered.contains(page)) {
153
- tabs[page].content()
154
- }
155
- }
156
- }
157
- }
158
- }
159
- }
160
-
161
- @Composable
162
- private fun DefaultTabBar(
163
- tabs: List<TabViewItem>,
164
- selectedIndex: Int,
165
- selectedColor: Color,
166
- unselectedColor: Color,
167
- direction: TabViewDirection,
168
- onPressTabItem: (Int) -> Unit,
169
- ) {
170
- val theme = AppTheme.current
171
- val density = LocalDensity.current
172
- var totalWidthPx by remember { mutableStateOf(0) }
173
-
174
- val itemWidth: Dp = if (totalWidthPx > 0 && tabs.isNotEmpty()) {
175
- with(density) { (totalWidthPx / tabs.size).toDp() }
176
- } else 0.dp
177
-
178
- val indicatorOffsetX: Dp by animateDpAsState(
179
- targetValue = itemWidth * selectedIndex + Spacing.XS,
180
- animationSpec = tween(durationMillis = 200),
181
- label = "DefaultIndicatorX",
182
- )
183
- val indicatorWidth: Dp = (itemWidth - Spacing.XS * 2).coerceAtLeast(0.dp)
184
-
185
- Box(
186
- modifier = Modifier
187
- .fillMaxWidth()
188
- .onGloballyPositioned { totalWidthPx = it.size.width }
189
- .background(theme.colors.background.surface)
190
- .border(
191
- width = 0.5.dp,
192
- color = theme.colors.border.default,
193
- shape = RoundedCornerShape(0.dp),
194
- ),
195
- ) {
196
- Row(modifier = Modifier.fillMaxWidth()) {
197
- tabs.forEachIndexed { index, tab ->
198
- TabItemView(
199
- modifier = Modifier.weight(1f),
200
- tab = tab,
201
- active = selectedIndex == index,
202
- selectedColor = selectedColor,
203
- unselectedColor = unselectedColor,
204
- direction = direction,
205
- onPress = { onPressTabItem(index) },
206
- )
207
- }
208
- }
209
-
210
- // Animated underline indicator
211
- TabUnderlineIndicator(offsetX = indicatorOffsetX, width = indicatorWidth, color = selectedColor)
212
- }
213
- }
214
-
215
- @Composable
216
- private fun ScrollableTabBar(
217
- tabs: List<TabViewItem>,
218
- selectedIndex: Int,
219
- selectedColor: Color,
220
- unselectedColor: Color,
221
- direction: TabViewDirection,
222
- onPressTabItem: (Int) -> Unit,
223
- ) {
224
- val theme = AppTheme.current
225
- val density = LocalDensity.current
226
- val scrollState: ScrollState = rememberScrollState()
227
- val coroutineScope = rememberCoroutineScope()
228
-
229
- // Per-item (widthPx, xPx) measured relative to the scrollable row
230
- val itemMeasures = remember { mutableStateListOf<Pair<Float, Float>>() }
231
-
232
- val rawWidth = itemMeasures.getOrNull(selectedIndex)?.first ?: 0f
233
- val rawX = itemMeasures.getOrNull(selectedIndex)?.second ?: 0f
234
-
235
- val animatedWidth: Dp by animateDpAsState(
236
- targetValue = with(density) { rawWidth.toDp() },
237
- animationSpec = tween(250),
238
- label = "ScrollableIndicatorWidth",
239
- )
240
- val animatedX: Dp by animateDpAsState(
241
- targetValue = with(density) { rawX.toDp() },
242
- animationSpec = tween(250),
243
- label = "ScrollableIndicatorX",
244
- )
245
-
246
- // Auto-scroll bar to keep selected item visible
247
- LaunchedEffect(selectedIndex, itemMeasures.size) {
248
- val x = itemMeasures.getOrNull(selectedIndex)?.second ?: return@LaunchedEffect
249
- val target = (x - with(density) { Spacing.S.toPx() }).coerceAtLeast(0f).toInt()
250
- coroutineScope.launch { scrollState.animateScrollTo(target) }
251
- }
252
-
253
- val scrollOffsetDp = with(density) { scrollState.value.toDp() }
254
-
255
- Box(
256
- modifier = Modifier
257
- .fillMaxWidth()
258
- .background(theme.colors.background.surface)
259
- .border(
260
- width = 0.5.dp,
261
- color = theme.colors.border.default,
262
- shape = RoundedCornerShape(0.dp),
263
- ),
264
- ) {
265
- Row(
266
- modifier = Modifier
267
- .fillMaxWidth()
268
- .horizontalScroll(scrollState),
269
- ) {
270
- tabs.forEachIndexed { index, tab ->
271
- Box(
272
- modifier = Modifier
273
- .wrapContentWidth()
274
- .onGloballyPositioned { coords ->
275
- val w = coords.size.width.toFloat()
276
- val x = coords.positionInParent().x
277
- while (itemMeasures.size <= index) itemMeasures.add(0f to 0f)
278
- itemMeasures[index] = w to x
279
- },
280
- ) {
281
- TabItemView(
282
- tab = tab,
283
- active = selectedIndex == index,
284
- selectedColor = selectedColor,
285
- unselectedColor = unselectedColor,
286
- direction = direction,
287
- scrollable = true,
288
- onPress = { onPressTabItem(index) },
289
- )
290
- }
291
- }
292
- }
293
-
294
- // Animated underline indicator aligned to bottom of the bar
295
- TabUnderlineIndicator(
296
- offsetX = animatedX - scrollOffsetDp + Spacing.XS,
297
- width = (animatedWidth - Spacing.XS * 2).coerceAtLeast(0.dp),
298
- color = selectedColor,
299
- )
300
- }
301
- }
302
-
303
- @Composable
304
- private fun CardTabBar(
305
- tabs: List<TabViewItem>,
306
- selectedIndex: Int,
307
- selectedColor: Color,
308
- unselectedColor: Color,
309
- direction: TabViewDirection,
310
- onPressTabItem: (Int) -> Unit,
311
- ) {
312
- val theme = AppTheme.current
313
- val surface = theme.colors.background.surface
314
-
315
- // react-kits `CardTabBar` draws the bar in TWO layers: a flat strip where every
316
- // tab looks unselected, and one raised card laid OVER it for the active tab.
317
- // The card is 4dp taller, sits `Spacing.XS` higher, and is joined to the strip
318
- // on each side by a curved "ear" — the browser-tab silhouette that gives this
319
- // variant its name. Rendering the active tab in place (just taller) loses both
320
- // the overlap and the ears, and the strip used the theme's `tonal` pink where
321
- // react-kits uses `Colors.black_02`, so the bar came out pink and flat.
322
- val pathWidth = if (tabs.size > 2) 22.dp else 28.dp
323
- val isFirst = selectedIndex == 0
324
- val isLast = selectedIndex == tabs.lastIndex
325
-
326
- // The bar is exactly as tall as the FLAT strip — react-kits' raised card is
327
- // `position: absolute`, so it never adds height; it just overflows upward into
328
- // the 4dp margin. Letting the 44dp card size this box instead left a 4dp band of
329
- // background showing between the tabs and the panel they sit on.
330
- BoxWithConstraints(
331
- modifier = Modifier
332
- .fillMaxWidth()
333
- .padding(top = Spacing.XS)
334
- .height(CARD_TAB_HEIGHT),
335
- ) {
336
- val itemWidth = maxWidth / tabs.size
337
-
338
- Row(modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.Bottom) {
339
- tabs.forEachIndexed { index, tab ->
340
- Box(
341
- modifier = Modifier
342
- .width(itemWidth)
343
- .height(CARD_TAB_HEIGHT)
344
- .background(
345
- color = Colors.black_02,
346
- shape = RoundedCornerShape(topStart = Radius.M, topEnd = Radius.M),
347
- )
348
- .activeOpacityClickable { onPressTabItem(index) }
349
- .padding(horizontal = Spacing.S),
350
- contentAlignment = Alignment.Center,
351
- ) {
352
- Row(verticalAlignment = Alignment.CenterVertically) {
353
- TabLeadingIcon(tab = tab, active = false, color = unselectedColor)
354
- Text(
355
- text = tab.title,
356
- style = Typography.bodyDefaultRegular,
357
- color = unselectedColor,
358
- maxLines = 1,
359
- overflow = TextOverflow.Ellipsis,
360
- modifier = Modifier.weight(1f, fill = false),
361
- )
362
- TabTrailingBadge(tab)
363
- }
364
- }
365
- }
366
- }
367
-
368
- val active = tabs.getOrNull(selectedIndex) ?: return@BoxWithConstraints
369
- Row(
370
- modifier = Modifier
371
- // Pinned to the strip's BOTTOM edge so the two always end on the same
372
- // pixel; `requiredHeight` then grows it upward into the 4dp margin.
373
- // Offsetting it up by hand instead left a sub-dp sliver of strip
374
- // showing under the card once rounding got involved.
375
- .align(Alignment.BottomStart)
376
- .offset(x = itemWidth * selectedIndex - (if (isFirst) 0.dp else pathWidth))
377
- // `requiredHeight`, not `height`: the bar box is only as tall as the
378
- // flat strip, so a plain height would be coerced down to 40 and the
379
- // raised card would stop 4dp short of the panel below, leaving a grey
380
- // sliver. react-kits gets this free — its card is absolutely
381
- // positioned and ignores the parent box entirely.
382
- .requiredHeight(CARD_TAB_ACTIVE_HEIGHT),
383
- verticalAlignment = Alignment.Bottom,
384
- ) {
385
- // react-kits nudges each ear 8pt UNDER the card so the join has no seam.
386
- if (!isFirst) CardTabEar(pathWidth, mirrored = true, color = surface, nudge = 8.dp)
387
- Box(
388
- modifier = Modifier
389
- .width(itemWidth)
390
- .fillMaxHeight()
391
- .background(
392
- color = surface,
393
- shape = RoundedCornerShape(topStart = Radius.M, topEnd = Radius.M),
394
- )
395
- .activeOpacityClickable { onPressTabItem(selectedIndex) }
396
- .padding(horizontal = if (tabs.size == 3) Spacing.S else Spacing.M),
397
- contentAlignment = Alignment.Center,
398
- ) {
399
- Row(verticalAlignment = Alignment.CenterVertically) {
400
- TabLeadingIcon(tab = active, active = true, color = selectedColor)
401
- Text(
402
- text = active.title,
403
- style = Typography.headerSSemibold,
404
- color = selectedColor,
405
- maxLines = 1,
406
- overflow = TextOverflow.Ellipsis,
407
- modifier = Modifier.weight(1f, fill = false),
408
- )
409
- TabTrailingBadge(active)
410
- }
411
- }
412
- if (!isLast) CardTabEar(pathWidth, mirrored = false, color = surface, nudge = -8.dp)
413
- }
414
- }
415
- }
416
-
417
- private val CARD_TAB_HEIGHT = 40.dp
418
- private val CARD_TAB_ACTIVE_HEIGHT = 44.dp
419
- @Composable
420
- private fun CardTabEar(width: Dp, mirrored: Boolean, color: Color, nudge: Dp) {
421
- // Clipped like react-kits' Svg, whose 28-wide path is cut at a 22pt `pathWidth`.
422
- Canvas(modifier = Modifier.offset(x = nudge).width(width).height(CARD_TAB_ACTIVE_HEIGHT).clipToBounds()) {
423
- val path = Path().apply {
424
- moveTo(0f, 0f)
425
- lineTo(0.60765f, 0f)
426
- cubicTo(6.47582f, 0f, 11.4819f, 4.23831f, 12.4602f, 10.0244f)
427
- cubicTo(13.9248f, 18.6872f, 15.9294f, 30.37f, 16.6925f, 34f)
428
- cubicTo(17.9536f, 40f, 22.259f, 44f, 27.9996f, 44f)
429
- lineTo(0f, 44f)
430
- close()
431
- }
432
- // Path coordinates are dp (react-kits viewBox), but DrawScope draws in px.
433
- val pxPerDp = density
434
- withTransform({
435
- if (mirrored) scale(-1f, 1f)
436
- scale(pxPerDp, pxPerDp, pivot = Offset.Zero)
437
- }) { drawPath(path = path, color = color) }
438
- }
439
- }
440
-
441
- @Composable
442
- private fun TabItemView(
443
- modifier: Modifier = Modifier,
444
- tab: TabViewItem,
445
- active: Boolean,
446
- selectedColor: Color,
447
- unselectedColor: Color,
448
- direction: TabViewDirection,
449
- scrollable: Boolean = false,
450
- onPress: () -> Unit,
451
- ) {
452
- val textColor = if (active) selectedColor else unselectedColor
453
- val textStyle = if (active) Typography.headerSSemibold else Typography.bodyDefaultRegular
454
-
455
- if (direction == TabViewDirection.COLUMN) {
456
- Column(
457
- modifier = modifier
458
- .height(68.dp)
459
- .activeOpacityClickable { onPress() }
460
- .padding(horizontal = Spacing.S),
461
- horizontalAlignment = Alignment.CenterHorizontally,
462
- verticalArrangement = Arrangement.Center,
463
- ) {
464
- // Icon area with badge/dot overlay
465
- Box(contentAlignment = Alignment.TopEnd) {
466
- if (tab.renderIcon != null) {
467
- tab.renderIcon.invoke(active)
468
- } else if (tab.icon != null) {
469
- Icon(
470
- source = tab.icon,
471
- size = 24.dp,
472
- color = textColor,
473
- )
474
- }
475
- if (tab.showDot) {
476
- BadgeDot(
477
- size = tab.dotSize,
478
- modifier = Modifier
479
- .align(Alignment.TopEnd)
480
- .offset(x = 4.dp, y = (-4).dp),
481
- )
482
- } else if (!tab.badgeValue.isNullOrEmpty()) {
483
- Badge(
484
- label = tab.badgeValue,
485
- modifier = Modifier
486
- .align(Alignment.TopEnd)
487
- .offset(x = 4.dp, y = (-4).dp),
488
- )
489
- }
490
- }
491
- if (tab.icon != null || tab.renderIcon != null) {
492
- Spacer(modifier = Modifier.height(Spacing.XXS))
493
- }
494
- Text(
495
- text = tab.title,
496
- style = textStyle,
497
- color = textColor,
498
- maxLines = 1,
499
- overflow = TextOverflow.Ellipsis,
500
- )
501
- }
502
- } else {
503
- Row(
504
- modifier = modifier
505
- .height(48.dp)
506
- .activeOpacityClickable { onPress() }
507
- .padding(horizontal = Spacing.M),
508
- horizontalArrangement = Arrangement.Center,
509
- verticalAlignment = Alignment.CenterVertically,
510
- ) {
511
- TabLeadingIcon(tab = tab, active = active, color = textColor)
512
- Text(
513
- text = tab.title,
514
- style = textStyle,
515
- color = textColor,
516
- maxLines = 1,
517
- overflow = TextOverflow.Ellipsis,
518
- modifier = if (scrollable) Modifier else Modifier.weight(1f, fill = false),
519
- )
520
- TabTrailingBadge(tab)
521
- }
522
- }
523
- }
524
-
525
- @Composable
526
- private fun BoxScope.TabUnderlineIndicator(offsetX: Dp, width: Dp, color: Color) {
527
- Box(
528
- modifier = Modifier
529
- .align(Alignment.BottomStart)
530
- .offset(x = offsetX)
531
- .width(width)
532
- .height(2.dp)
533
- .background(
534
- color = color,
535
- shape = RoundedCornerShape(topStart = Radius.XXS, topEnd = Radius.XXS),
536
- ),
537
- )
538
- }
539
-
540
- @Composable
541
- private fun TabLeadingIcon(tab: TabViewItem, active: Boolean, color: Color) {
542
- if (tab.renderIcon != null) {
543
- tab.renderIcon.invoke(active)
544
- Spacer(modifier = Modifier.width(Spacing.XS))
545
- } else if (tab.icon != null) {
546
- Icon(source = tab.icon, size = 18.dp, color = color)
547
- Spacer(modifier = Modifier.width(Spacing.XS))
548
- }
549
- }
550
-
551
- @Composable
552
- private fun TabTrailingBadge(tab: TabViewItem) {
553
- if (tab.showDot) {
554
- Spacer(modifier = Modifier.width(Spacing.XS))
555
- BadgeDot(size = tab.dotSize)
556
- } else if (!tab.badgeValue.isNullOrEmpty()) {
557
- Spacer(modifier = Modifier.width(Spacing.XS))
558
- Badge(label = tab.badgeValue, modifier = Modifier)
559
- }
560
- }
@@ -1,86 +0,0 @@
1
- package vn.momo.kits.components
2
-
3
- import androidx.compose.foundation.background
4
- import androidx.compose.foundation.border
5
- import androidx.compose.foundation.layout.Box
6
- import androidx.compose.foundation.layout.Row
7
- import androidx.compose.foundation.layout.height
8
- import androidx.compose.foundation.layout.padding
9
- import androidx.compose.foundation.shape.RoundedCornerShape
10
- import androidx.compose.runtime.Composable
11
- import androidx.compose.ui.Alignment
12
- import androidx.compose.ui.Modifier
13
- import androidx.compose.ui.graphics.Color
14
- import androidx.compose.ui.unit.dp
15
- import vn.momo.kits.application.IsShowBaseLineDebug
16
- import vn.momo.kits.const.*
17
- import vn.momo.kits.modifier.conditional
18
-
19
- enum class TagSize(val height: Float) {
20
- Large(24.toFloat()),
21
- Medium(18.toFloat())
22
- }
23
-
24
- enum class TagColor(val backgroundColor: Color, val textColor: Color) {
25
- Default(Colors.black_04, Colors.black_17),
26
- Orange(Colors.orange_08, Colors.orange_03),
27
- Green(Colors.green_08, Colors.green_03),
28
- Red(Colors.red_08, Colors.red_03),
29
- Blue(Colors.blue_08, Colors.blue_03),
30
- Grey(Colors.black_04, Colors.black_12),
31
- }
32
-
33
- // RN only accepts the `_03` palette as a custom tag color.
34
- private val tagCustomColors = listOf(
35
- Colors.black_03,
36
- Colors.pink_03,
37
- Colors.violet_03,
38
- Colors.indigo_03,
39
- Colors.blue_03,
40
- Colors.mint_03,
41
- Colors.green_03,
42
- Colors.lime_03,
43
- Colors.yellow_03,
44
- Colors.gold_03,
45
- Colors.orange_03,
46
- Colors.red_03,
47
- )
48
-
49
- @Composable
50
- fun Tag(
51
- label: String = "Label",
52
- icon: String? = null,
53
- color: TagColor = TagColor.Default,
54
- size: TagSize = TagSize.Large,
55
- customColor: Color? = null,
56
- ) {
57
- val custom = customColor?.takeIf { it in tagCustomColors }
58
- val tagColor = custom ?: color.backgroundColor
59
- val labelColor = if (custom != null) Colors.black_01 else color.textColor
60
-
61
- Box(
62
- modifier = Modifier
63
- .height(scaleSize(size.height).dp)
64
- .background(tagColor, shape = RoundedCornerShape(Radius.S))
65
- .conditional(IsShowBaseLineDebug) {
66
- border(1.dp, Colors.blue_03)
67
- }
68
- .padding(horizontal = Spacing.S),
69
- contentAlignment = Alignment.Center
70
- ) {
71
- Row(verticalAlignment = Alignment.CenterVertically) {
72
- if (icon != null) {
73
- Icon(
74
- source = icon,
75
- size = 16.dp,
76
- color = labelColor
77
- )
78
- }
79
- Text(
80
- text = label,
81
- color = labelColor,
82
- style = Typography.labelSMedium
83
- )
84
- }
85
- }
86
- }