@momo-kits/native-kits 0.169.8-beta.7-debug → 0.169.8

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