@momo-kits/native-kits 0.169.15-beta.4-debug → 0.169.15-beta.5

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