@momo-kits/native-kits 0.169.8-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 (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/compose.podspec +0 -47
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1067
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -267
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -82
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -356
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -482
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -224
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -137
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -473
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -113
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -263
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -228
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -183
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -40
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -82
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -39
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -363
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -307
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -88
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -306
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -457
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -205
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -89
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -542
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -175
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -201
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -210
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -12
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -292
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -184
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -316
  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 -397
  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 -153
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -113
  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 -727
  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 -242
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -391
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -100
  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/DuoTabBar.kt +0 -207
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -132
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -167
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -456
  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 -204
  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 -114
  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 -76
  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 -22
  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 -144
  132. package/gradle/libs.versions.toml +0 -67
  133. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  134. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  135. package/gradle.properties +0 -24
  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,391 +0,0 @@
1
- package vn.momo.kits.navigation.bottomtab
2
-
3
- import androidx.compose.runtime.getValue
4
- import androidx.compose.animation.animateColorAsState
5
- import androidx.compose.animation.core.Animatable
6
- import androidx.compose.animation.core.animateFloatAsState
7
- import androidx.compose.animation.core.tween
8
- import androidx.compose.foundation.clickable
9
- import androidx.compose.foundation.interaction.MutableInteractionSource
10
- import androidx.compose.foundation.interaction.collectIsPressedAsState
11
- import androidx.compose.runtime.LaunchedEffect
12
- import androidx.compose.runtime.mutableStateMapOf
13
- import androidx.compose.ui.draw.clip
14
- import androidx.compose.ui.draw.dropShadow
15
- import androidx.compose.ui.draw.innerShadow
16
- import androidx.compose.ui.graphics.Color
17
- import androidx.compose.ui.graphics.Shape
18
- import androidx.compose.ui.graphics.graphicsLayer
19
- import androidx.compose.ui.layout.onPlaced
20
- import androidx.compose.ui.layout.positionInParent
21
- import androidx.compose.ui.platform.LocalDensity
22
- import androidx.compose.ui.semantics.Role
23
- import androidx.compose.ui.semantics.contentDescription
24
- import androidx.compose.ui.semantics.role
25
- import androidx.compose.ui.semantics.selected
26
- import androidx.compose.ui.semantics.semantics
27
- import androidx.compose.foundation.background
28
- import androidx.compose.foundation.border
29
- import androidx.compose.foundation.layout.*
30
- import androidx.compose.foundation.shape.CircleShape
31
- import androidx.compose.foundation.shape.RoundedCornerShape
32
- import androidx.compose.runtime.Composable
33
- import androidx.compose.runtime.remember
34
- import androidx.compose.ui.Alignment
35
- import androidx.compose.ui.Modifier
36
- import androidx.compose.ui.text.style.TextAlign
37
- import androidx.compose.ui.text.style.TextOverflow
38
- import androidx.compose.ui.unit.dp
39
- import vn.momo.kits.application.IsShowBaseLineDebug
40
- import vn.momo.kits.components.*
41
- import vn.momo.kits.const.*
42
- import vn.momo.kits.layout.getScreenLayout
43
- import vn.momo.kits.modifier.InternalApi
44
- import vn.momo.kits.modifier.activeOpacityClickable
45
- import vn.momo.kits.modifier.conditional
46
- import vn.momo.kits.modifier.setAutomationId
47
-
48
- @InternalApi
49
- const val BOTTOM_TAB_BAR_HEIGHT = 68
50
-
51
- // Phone tab bar: the horizontal navigation bar filling the window, above the home indicator.
52
- @Composable
53
- internal fun BottomTabBar(
54
- items: List<BottomTabItem>,
55
- floatingButton: BottomTabFloatingButton? = null,
56
- selectedIndex: Int,
57
- onTabSelected: (Int) -> Unit,
58
- ) {
59
- val layout = getScreenLayout()
60
- Box(
61
- modifier = Modifier
62
- .fillMaxWidth()
63
- .padding(bottom = tabBarBottomGap(layout.insetBottom)),
64
- contentAlignment = Alignment.BottomCenter,
65
- ) {
66
- HorizontalTabBar(
67
- items = items,
68
- floatingButton = floatingButton,
69
- selectedIndex = selectedIndex,
70
- onTabSelected = onTabSelected,
71
- modifier = Modifier
72
- .offset(x = (layout.insetLeft - layout.insetRight) / 2)
73
- .width(
74
- horizontalBarWidth(
75
- layout.width, layout.height, layout.insetLeft, layout.insetRight,
76
- items.size, hasCenterAction(floatingButton, items.size),
77
- ),
78
- ),
79
- )
80
- }
81
- }
82
-
83
- // Horizontal navigation bar: floating container, items split evenly; Special type puts the center
84
- // action in a notch in the middle, rising ctaLift above the container. One active indicator slides
85
- // behind the selected item.
86
- @Composable
87
- internal fun HorizontalTabBar(
88
- items: List<BottomTabItem>,
89
- floatingButton: BottomTabFloatingButton?,
90
- selectedIndex: Int,
91
- onTabSelected: (Int) -> Unit,
92
- modifier: Modifier = Modifier,
93
- ) {
94
- val cta = floatingButton?.takeIf { hasCenterAction(it, items.size) }
95
- val mid = items.size / 2
96
- val density = LocalDensity.current
97
- val itemBounds = remember(items.size) { mutableStateMapOf<Int, Pair<Float, Float>>() }
98
-
99
- BoxWithConstraints(modifier = modifier) {
100
- val shape = remember(maxWidth, cta != null) {
101
- NotchedBarShape(TabBarMetrics.height / 2, if (cta != null) maxWidth / 2 else null)
102
- }
103
- Box(
104
- modifier = Modifier
105
- .padding(top = if (cta != null) TabBarMetrics.ctaLift else 0.dp)
106
- .fillMaxWidth()
107
- .height(TabBarMetrics.height)
108
- .tabBarContainer(shape)
109
- .padding(horizontal = TabBarMetrics.paddingHorizontal, vertical = TabBarMetrics.paddingVertical)
110
- .setAutomationId("bottom_tab_bar"),
111
- ) {
112
- itemBounds[selectedIndex]?.let { (x, width) ->
113
- ActiveIndicator(
114
- offset = x,
115
- modifier = Modifier
116
- .width(with(density) { width.toDp() })
117
- .height(TabBarMetrics.indicatorHeight),
118
- shape = RoundedCornerShape(TabBarMetrics.indicatorRadius),
119
- axisX = true,
120
- )
121
- }
122
- Row(
123
- modifier = Modifier.fillMaxSize(),
124
- horizontalArrangement = Arrangement.spacedBy(TabBarMetrics.itemGap),
125
- verticalAlignment = Alignment.CenterVertically,
126
- ) {
127
- items.forEachIndexed { index, item ->
128
- if (cta != null && index == mid) {
129
- Spacer(Modifier.width(TabBarMetrics.ctaSlotWidth))
130
- }
131
- TabBarItem(
132
- item = item,
133
- selected = index == selectedIndex,
134
- modifier = Modifier.onPlaced {
135
- itemBounds[index] = it.positionInParent().x to it.size.width.toFloat()
136
- },
137
- onClick = { onTabSelected(index) },
138
- )
139
- }
140
- }
141
- }
142
- cta?.let { CenterAction(it, Modifier.align(Alignment.TopCenter)) }
143
- }
144
- }
145
-
146
- // One active indicator per bar (Background/tonal with its inner shadows) sliding to the selected item
147
- // along x (horizontal bar) or y (rail); it lands in place on the first measure and slides from then on.
148
- @Composable
149
- internal fun ActiveIndicator(offset: Float, modifier: Modifier, shape: Shape, axisX: Boolean) {
150
- val colors = AppTheme.current.colors
151
- val position = remember { Animatable(offset) }
152
- LaunchedEffect(offset) {
153
- if (position.value != offset) position.animateTo(offset, TabBarMotion.indicator)
154
- }
155
- Box(
156
- modifier
157
- .graphicsLayer {
158
- if (axisX) translationX = position.value else translationY = position.value
159
- }
160
- .background(colors.background.tonal, shape)
161
- .then(
162
- indicatorInnerShadows(colors.primary).fold(Modifier as Modifier) { acc, shadow ->
163
- acc.innerShadow(shape, shadow)
164
- }
165
- )
166
- )
167
- }
168
-
169
- @Composable
170
- private fun RowScope.TabBarItem(
171
- item: BottomTabItem,
172
- selected: Boolean,
173
- modifier: Modifier,
174
- onClick: () -> Unit,
175
- ) {
176
- Column(
177
- modifier = modifier
178
- .weight(1f)
179
- .conditional(IsShowBaseLineDebug) {
180
- border(1.dp, Colors.blue_03)
181
- }
182
- .activeOpacityClickable { onClick() }
183
- .semantics {
184
- role = Role.Tab
185
- this.selected = selected
186
- contentDescription = item.label
187
- },
188
- horizontalAlignment = Alignment.CenterHorizontally,
189
- verticalArrangement = Arrangement.spacedBy(TabBarMetrics.itemIconLabelGap),
190
- ) {
191
- TabItemContent(item, selected)
192
- }
193
- }
194
-
195
- // Icon in its indicator slot, label under it. The bar slides one shared active indicator behind the
196
- // slots; the icon and label tint cross-fade on focus.
197
- @Composable
198
- internal fun ColumnScope.TabItemContent(
199
- item: BottomTabItem,
200
- selected: Boolean,
201
- vertical: Boolean = false,
202
- showLabel: Boolean = true,
203
- ) {
204
- val colors = AppTheme.current.colors
205
- val tint by animateColorAsState(
206
- if (selected) colors.primary else colors.text.secondary,
207
- tween(TabBarMotion.TINT_MILLIS, easing = inOutQuad),
208
- label = "TabTint",
209
- )
210
-
211
- Box(
212
- modifier = Modifier
213
- .then(if (vertical) Modifier else Modifier.fillMaxWidth())
214
- .height(if (vertical) TabBarMetrics.railIndicatorHeight else TabBarMetrics.indicatorHeight)
215
- .padding(horizontal = TabBarMetrics.indicatorPaddingHorizontal),
216
- contentAlignment = Alignment.Center,
217
- ) {
218
- TabIcon(item, tint, vertical)
219
- }
220
- if (showLabel) {
221
- // fixed slot so a capped-scale label overflows downward and the icon above it stays put
222
- Box(
223
- modifier = Modifier.height(
224
- if (vertical) TabBarMetrics.railLabelHeight else TabBarMetrics.labelHeight
225
- ),
226
- contentAlignment = Alignment.TopCenter,
227
- ) {
228
- Text(
229
- text = item.label,
230
- color = tint,
231
- style = if (vertical) Typography.labelXsMedium else Typography.labelSMedium,
232
- textAlign = TextAlign.Center,
233
- maxLines = 1,
234
- overflow = TextOverflow.Ellipsis,
235
- modifier = (if (vertical) Modifier else Modifier.fillMaxWidth())
236
- .wrapContentHeight(Alignment.Top, unbounded = true),
237
- )
238
- }
239
- }
240
- }
241
-
242
- // Badge value shown on a tab: null hides it, "" is a dot, numbers cap at 99+ ("0" hides it, RN parity).
243
- internal fun tabBadgeLabel(item: BottomTabItem): String? {
244
- val label = item.badgeLabel ?: return if (item.showDot) "" else null
245
- if (label.isEmpty()) return ""
246
- if (label.all { it in '0'..'9' }) {
247
- val value = label.toLongOrNull() ?: Long.MAX_VALUE
248
- if (value == 0L) return if (item.showDot) "" else null
249
- return if (value > 99) "99+" else label
250
- }
251
- return label
252
- }
253
-
254
- // 24 icon; badges hang off it unclipped: dot at 16/-2, label badge at 12/-7 growing right, or
255
- // centered over the icon at -10 on the rail.
256
- @Composable
257
- internal fun TabIcon(item: BottomTabItem, tint: androidx.compose.ui.graphics.Color, vertical: Boolean) {
258
- val badge = tabBadgeLabel(item)
259
- Box(Modifier.size(TabBarMetrics.iconSize)) {
260
- Icon(source = item.icon, size = TabBarMetrics.iconSize, color = tint)
261
- when {
262
- badge == null -> Unit
263
- badge.isEmpty() -> BadgeDot(
264
- size = DotSize.Small,
265
- modifier = Modifier.offset(x = 16.dp, y = -Spacing.XXS),
266
- )
267
- vertical -> TabBadge(
268
- badge,
269
- Modifier.matchParentSize()
270
- .wrapContentSize(Alignment.TopCenter, unbounded = true)
271
- .offset(y = (-10).dp),
272
- )
273
- else -> TabBadge(
274
- badge,
275
- Modifier.matchParentSize()
276
- .wrapContentSize(Alignment.TopStart, unbounded = true)
277
- .offset(x = Spacing.M, y = (-7).dp),
278
- )
279
- }
280
- }
281
- }
282
-
283
- // Numbers use the error color, text the warning color (Figma Badge round numeric / text); the text keeps
284
- // its design size so it fits the 16 height on the Duo displays too.
285
- @Composable
286
- private fun TabBadge(label: String, modifier: Modifier) {
287
- val colors = AppTheme.current.colors
288
- val isNumber = label.trimEnd('+').let { it.isNotEmpty() && it.all { c -> c in '0'..'9' } }
289
- Box(
290
- modifier = modifier
291
- .height(16.dp)
292
- .widthIn(min = 16.dp, max = TabBarMetrics.badgeMaxWidth)
293
- .background(if (isNumber) colors.error.primary else colors.warning.primary, CircleShape)
294
- .border(1.dp, colors.background.surface, CircleShape)
295
- .padding(horizontal = Spacing.XS),
296
- contentAlignment = Alignment.Center,
297
- ) {
298
- ScaleSizeScope(1f) {
299
- Text(
300
- text = label,
301
- style = Typography.actionXxsBold,
302
- color = Colors.black_01,
303
- maxLines = 1,
304
- overflow = TextOverflow.Ellipsis,
305
- )
306
- }
307
- }
308
- }
309
-
310
- // Center action press: the button shrinks while held; the label stays plain text.
311
- @Composable
312
- internal fun rememberCenterActionPress(): Pair<MutableInteractionSource, Boolean> {
313
- val interactionSource = remember { MutableInteractionSource() }
314
- val pressed by interactionSource.collectIsPressedAsState()
315
- return interactionSource to pressed
316
- }
317
-
318
- @Composable
319
- internal fun Modifier.centerActionPressScale(pressed: Boolean): Modifier {
320
- val scale by animateFloatAsState(
321
- if (pressed) TabBarMotion.CTA_PRESSED_SCALE else 1f,
322
- tween(TabBarMotion.CTA_PRESS_MILLIS, easing = inOutQuad),
323
- label = "CenterActionPress",
324
- )
325
- return graphicsLayer {
326
- scaleX = scale
327
- scaleY = scale
328
- }
329
- }
330
-
331
- @Composable
332
- internal fun Modifier.centerActionButton(size: androidx.compose.ui.unit.Dp, pressed: Boolean): Modifier {
333
- return centerActionPressScale(pressed)
334
- .size(size)
335
- .then(CtaShadows.fold(Modifier as Modifier) { acc, shadow -> acc.spreadShadow(CircleShape, shadow) })
336
- .background(AppTheme.current.colors.primary, CircleShape)
337
- .border(1.dp, Color.White.copy(alpha = TabBarMetrics.ctaBorderOpacity), CircleShape)
338
- }
339
-
340
- @Composable
341
- internal fun CenterActionLabel(label: String, overlay: (@Composable () -> Unit)?, vertical: Boolean) {
342
- val colors = AppTheme.current.colors
343
- Box(
344
- modifier = Modifier
345
- .then(if (vertical) Modifier else Modifier.heightIn(min = TabBarMetrics.ctaLabelHeight))
346
- .padding(horizontal = if (vertical) Spacing.XS else Spacing.XXS),
347
- contentAlignment = Alignment.Center,
348
- ) {
349
- Text(
350
- text = label,
351
- style = if (vertical) Typography.labelXsMedium else Typography.labelSMedium,
352
- color = colors.text.secondary,
353
- textAlign = TextAlign.Center,
354
- maxLines = 1,
355
- overflow = TextOverflow.Ellipsis,
356
- )
357
- overlay?.let {
358
- Box(Modifier.matchParentSize().wrapContentSize(Alignment.Center, unbounded = true)) { it() }
359
- }
360
- }
361
- }
362
-
363
- // Center action (.Nav/CTA): button rising out of the notch, label under it.
364
- @Composable
365
- private fun CenterAction(data: BottomTabFloatingButton, modifier: Modifier) {
366
- val (interactionSource, pressed) = rememberCenterActionPress()
367
- Column(
368
- modifier = modifier
369
- .width(TabBarMetrics.ctaSlotWidth)
370
- .conditional(IsShowBaseLineDebug) {
371
- border(1.dp, Colors.blue_03)
372
- }
373
- .clickable(interactionSource = interactionSource, indication = null, onClick = data.onPress)
374
- .setAutomationId(data.label),
375
- horizontalAlignment = Alignment.CenterHorizontally,
376
- verticalArrangement = Arrangement.spacedBy(TabBarMetrics.ctaLabelGap),
377
- ) {
378
- Box(Modifier.centerActionButton(TabBarMetrics.ctaSize, pressed), contentAlignment = Alignment.Center) {
379
- val iconContent = data.iconContent
380
- if (iconContent != null) {
381
- // custom content (e.g. an oversized Lottie) is clipped to the round button
382
- Box(Modifier.size(TabBarMetrics.ctaSize).clip(CircleShape), contentAlignment = Alignment.Center) {
383
- iconContent()
384
- }
385
- } else {
386
- Icon(source = data.icon, color = Colors.black_01, size = TabBarMetrics.ctaIconSize)
387
- }
388
- }
389
- CenterActionLabel(data.label, data.labelContent, vertical = false)
390
- }
391
- }
@@ -1,100 +0,0 @@
1
- package vn.momo.kits.navigation.bottomtab
2
-
3
- import androidx.compose.ui.Modifier
4
- import androidx.compose.ui.draw.dropShadow
5
- import androidx.compose.ui.geometry.Rect
6
- import androidx.compose.ui.geometry.RoundRect
7
- import androidx.compose.ui.geometry.Size
8
- import androidx.compose.ui.geometry.CornerRadius
9
- import androidx.compose.ui.geometry.Offset
10
- import androidx.compose.ui.graphics.addOutline
11
- import androidx.compose.ui.graphics.Color
12
- import androidx.compose.ui.graphics.Outline
13
- import androidx.compose.ui.graphics.Path
14
- import androidx.compose.ui.graphics.Shape
15
- import androidx.compose.ui.graphics.shadow.Shadow
16
- import androidx.compose.ui.unit.Density
17
- import androidx.compose.ui.unit.Dp
18
- import androidx.compose.ui.unit.DpOffset
19
- import androidx.compose.ui.unit.LayoutDirection
20
- import androidx.compose.ui.unit.dp
21
- import androidx.compose.foundation.background
22
- import androidx.compose.foundation.border
23
- import androidx.compose.runtime.Composable
24
- import vn.momo.kits.const.AppTheme
25
-
26
- // Rounded container, with the notch dipped into the top edge around `notchCenterX` (from the left).
27
- internal class NotchedBarShape(
28
- private val radius: Dp,
29
- private val notchCenterX: Dp? = null,
30
- ) : Shape {
31
- override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
32
- val r = minOf(with(density) { radius.toPx() }, size.height / 2, size.width / 2)
33
- val path = Path()
34
- if (notchCenterX == null) {
35
- path.addRoundRect(RoundRect(Rect(0f, 0f, size.width, size.height), CornerRadius(r)))
36
- return Outline.Generic(path)
37
- }
38
- val cx = with(density) { notchCenterX.toPx() }
39
- val unit = density.density
40
- path.apply {
41
- moveTo(r, 0f)
42
- lineTo(cx - NOTCH_HALF_WIDTH * unit, 0f)
43
- NOTCH_CURVES.forEach { (c1, c2, end) ->
44
- cubicTo(
45
- cx + c1.first * unit, c1.second * unit,
46
- cx + c2.first * unit, c2.second * unit,
47
- cx + end.first * unit, end.second * unit,
48
- )
49
- }
50
- lineTo(size.width - r, 0f)
51
- arcTo(Rect(size.width - 2 * r, 0f, size.width, 2 * r), -90f, 90f, false)
52
- lineTo(size.width, size.height - r)
53
- arcTo(Rect(size.width - 2 * r, size.height - 2 * r, size.width, size.height), 0f, 90f, false)
54
- lineTo(r, size.height)
55
- arcTo(Rect(0f, size.height - 2 * r, 2 * r, size.height), 90f, 90f, false)
56
- lineTo(0f, r)
57
- arcTo(Rect(0f, 0f, 2 * r, 2 * r), 180f, 90f, false)
58
- close()
59
- }
60
- return Outline.Generic(path)
61
- }
62
- }
63
-
64
- // The shape shrunk by `inset` on every side. A shadow cast from it with no spread is a shadow of the
65
- // shape with spread -inset; dropShadow's own negative spread clips the blur of path outlines.
66
- internal class InsetShape(private val shape: Shape, private val inset: Dp) : Shape {
67
- override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
68
- val insetPx = with(density) { inset.toPx() }
69
- val inner = Size((size.width - 2 * insetPx).coerceAtLeast(0f), (size.height - 2 * insetPx).coerceAtLeast(0f))
70
- val path = Path().apply {
71
- addOutline(shape.createOutline(inner, layoutDirection, density))
72
- translate(Offset(insetPx, insetPx))
73
- }
74
- return Outline.Generic(path)
75
- }
76
- }
77
-
78
- // Shadow with a negative spread, cast from the shrunk shape.
79
- internal fun Modifier.spreadShadow(shape: Shape, shadow: Shadow): Modifier =
80
- if (shadow.spread < 0.dp) dropShadow(
81
- InsetShape(shape, -shadow.spread),
82
- Shadow(radius = shadow.radius, color = shadow.color, offset = shadow.offset, alpha = shadow.alpha),
83
- )
84
- else dropShadow(shape, shadow)
85
-
86
- // Navigation bar container: translucent glass fill with the floating shadow following the shape (Figma
87
- // Shadow/floating: 12% blur 24, 4% y12 blur 32 spread -16; .Nav/Background: white 86%, Blur=On).
88
- @Composable
89
- internal fun Modifier.tabBarContainer(shape: Shape): Modifier =
90
- dropShadow(shape, Shadow(radius = 24.dp, color = Color.Black, alpha = 0.12f))
91
- .spreadShadow(
92
- shape,
93
- Shadow(radius = 32.dp, spread = (-16).dp, color = Color.Black, alpha = 0.04f, offset = DpOffset(0.dp, 12.dp)),
94
- )
95
- .background(
96
- AppTheme.current.colors.background.surface.copy(alpha = TabBarMetrics.backgroundOpacity),
97
- shape,
98
- )
99
- // Figma .Nav/Background: 1px light-gray hairline defining the pill edge
100
- .border(1.dp, AppTheme.current.colors.border.default, shape)
@@ -1,97 +0,0 @@
1
- package vn.momo.kits.navigation.bottomtab
2
-
3
- import androidx.compose.runtime.Composable
4
- import androidx.compose.runtime.Stable
5
- import androidx.compose.runtime.compositionLocalOf
6
- import androidx.compose.runtime.getValue
7
- import androidx.compose.runtime.mutableStateOf
8
- import androidx.compose.runtime.remember
9
- import androidx.compose.runtime.setValue
10
- import androidx.compose.ui.unit.Dp
11
- import vn.momo.kits.const.Spacing
12
- import vn.momo.kits.layout.DuoMetrics
13
- import vn.momo.kits.layout.ScreenLayout
14
-
15
- // iPhone Duo: which side bar bar starts compressed when the strip cannot hold both whole.
16
- enum class DuoBarCompressionBehavior { TOOLBAR, TAB_BAR }
17
-
18
- private enum class DuoBar { TOOLBAR, TAB_BAR }
19
-
20
- @Stable
21
- internal class DuoBarCompression(
22
- val toolbarCompressed: Boolean = false,
23
- val tabBarCompressed: Boolean = false,
24
- // the open rail needs the toolbar button slot too: only Back stays
25
- val toolbarHidden: Boolean = false,
26
- val expandToolbar: () -> Unit = {},
27
- val expandTabBar: () -> Unit = {},
28
- // a rail opened from the compressed state closes once a tab is picked
29
- val onTabSelected: () -> Unit = {},
30
- // side bar columns report their full height so the tab bar knows what is left
31
- val setToolbarHeight: (Dp) -> Unit = {},
32
- )
33
-
34
- internal val LocalDuoBarCompression = compositionLocalOf { DuoBarCompression() }
35
-
36
- // space kept between the top and the bottom groups (HIG Vertical controls)
37
- internal val DUO_GROUP_GAP = Spacing.M
38
- // Back, then the right toolkit: help + home capsule
39
- private val DEFAULT_TOOLBAR_HEIGHT = DuoMetrics.controlSize + Spacing.M + DuoMetrics.itemPitch * 2
40
- // Back, then the single button the toolbar folds into
41
- private val COMPRESSED_TOOLBAR_HEIGHT = DuoMetrics.controlSize * 2 + Spacing.M
42
-
43
- // Port of RN DuoBarCompression (HIG, Designing for iPhone Duo: Vertical controls):
44
- // - both fit: both stay whole
45
- // - one fits whole beside the other compressed: one is compressed, tapping it swaps them
46
- // - otherwise both rest compressed; tapping one opens it for a moment (the rail closes
47
- // again once a tab is picked)
48
- @Composable
49
- internal fun rememberDuoBarCompression(
50
- behavior: DuoBarCompressionBehavior,
51
- tabCount: Int,
52
- hasQr: Boolean,
53
- layout: ScreenLayout,
54
- ): DuoBarCompression {
55
- var toolbarHeight by remember { mutableStateOf(DEFAULT_TOOLBAR_HEIGHT) }
56
- var expanded by remember(behavior) {
57
- mutableStateOf(if (behavior == DuoBarCompressionBehavior.TOOLBAR) DuoBar.TAB_BAR else DuoBar.TOOLBAR)
58
- }
59
- var opened by remember { mutableStateOf<DuoBar?>(null) }
60
- val setToolbarHeight = remember { { height: Dp -> toolbarHeight = height } }
61
- val sideBar = layout.sideBar
62
-
63
- return remember(sideBar, layout.height, tabCount, hasQr, toolbarHeight, expanded, opened) {
64
- if (sideBar == null) return@remember DuoBarCompression()
65
- val room = layout.height - sideBar.bottom - sideBar.top - DUO_GROUP_GAP
66
- val tabBar = duoRailHeight(tabCount, hasQr)
67
- val compressedTabBar = duoRailHeight(1, hasQr, compressed = true)
68
- fun fits(toolbar: Dp, tabs: Dp) = toolbar + tabs <= room
69
-
70
- when {
71
- fits(toolbarHeight, tabBar) -> DuoBarCompression(setToolbarHeight = setToolbarHeight)
72
- fits(COMPRESSED_TOOLBAR_HEIGHT, tabBar) && fits(toolbarHeight, compressedTabBar) -> DuoBarCompression(
73
- toolbarCompressed = expanded == DuoBar.TAB_BAR,
74
- tabBarCompressed = expanded == DuoBar.TOOLBAR,
75
- expandToolbar = { expanded = DuoBar.TOOLBAR },
76
- expandTabBar = { expanded = DuoBar.TAB_BAR },
77
- setToolbarHeight = setToolbarHeight,
78
- )
79
- // an opened rail always shows, even when only the group gap is short: it closes once a tab is picked
80
- opened == DuoBar.TAB_BAR -> DuoBarCompression(
81
- toolbarCompressed = true,
82
- toolbarHidden = true,
83
- expandToolbar = { opened = DuoBar.TOOLBAR },
84
- expandTabBar = { opened = DuoBar.TAB_BAR },
85
- onTabSelected = { opened = null },
86
- setToolbarHeight = setToolbarHeight,
87
- )
88
- else -> DuoBarCompression(
89
- toolbarCompressed = opened != DuoBar.TOOLBAR,
90
- tabBarCompressed = true,
91
- expandToolbar = { opened = DuoBar.TOOLBAR },
92
- expandTabBar = { opened = DuoBar.TAB_BAR },
93
- setToolbarHeight = setToolbarHeight,
94
- )
95
- }
96
- }
97
- }