@momo-kits/native-kits 0.169.2-debug → 0.169.3-beta.1

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