@momo-kits/native-kits 0.168.1-beta.30-debug → 0.168.1-beta.31

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 (150) hide show
  1. package/CLAUDE.md +2 -1
  2. package/ios/Input/Input.swift +3 -1
  3. package/ios/Input/InputTextArea.swift +3 -1
  4. package/ios/Navigation/BottomTab/BottomTab.swift +33 -14
  5. package/ios/Navigation/BottomTab/BottomTabBar.swift +131 -254
  6. package/ios/Navigation/BottomTab/CurvedContainer.swift +47 -51
  7. package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +364 -0
  8. package/ios/Navigation/BottomTab/DuoTabBar.swift +292 -71
  9. package/ios/Navigation/StackScreen.swift +1 -3
  10. package/ios/native-kits.podspec +1 -1
  11. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  12. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +59 -224
  13. package/package.json +1 -1
  14. package/build.gradle.kts +0 -11
  15. package/compose/build.gradle.kts +0 -198
  16. package/compose/build.gradle.kts.backup +0 -198
  17. package/compose/compose.podspec +0 -47
  18. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -20
  19. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  20. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  21. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  22. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -153
  23. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -370
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -17
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -287
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -321
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -502
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -148
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -732
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -224
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -383
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -94
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -203
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -106
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -399
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -20
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  131. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  132. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  133. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  135. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  138. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  139. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -218
  140. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -138
  141. package/gradle/libs.versions.toml +0 -69
  142. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  143. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  144. package/gradle.properties +0 -26
  145. package/gradlew +0 -252
  146. package/gradlew.bat +0 -94
  147. package/ios/Navigation/BottomTab/TabBarMetrics.swift +0 -88
  148. package/ios-demo/README.md +0 -120
  149. package/local.properties +0 -9
  150. package/settings.gradle.kts +0 -64
@@ -1,383 +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 and its label turns active (label in a
315
- // Background/primary pill, white text).
316
- @Composable
317
- internal fun rememberCenterActionPress(): Pair<MutableInteractionSource, Boolean> {
318
- val interactionSource = remember { MutableInteractionSource() }
319
- val pressed by interactionSource.collectIsPressedAsState()
320
- return interactionSource to pressed
321
- }
322
-
323
- @Composable
324
- internal fun Modifier.centerActionButton(size: androidx.compose.ui.unit.Dp, pressed: Boolean): Modifier {
325
- val scale by animateFloatAsState(
326
- if (pressed) TabBarMotion.CTA_PRESSED_SCALE else 1f,
327
- tween(TabBarMotion.CTA_PRESS_MILLIS, easing = inOutQuad),
328
- label = "CenterActionPress",
329
- )
330
- return graphicsLayer {
331
- scaleX = scale
332
- scaleY = scale
333
- }
334
- .size(size)
335
- .then(CtaShadows.fold(Modifier as Modifier) { acc, shadow -> acc.spreadShadow(CircleShape, shadow) })
336
- .background(AppTheme.current.colors.primary, CircleShape)
337
- }
338
-
339
- @Composable
340
- internal fun CenterActionLabel(label: String, pressed: Boolean, vertical: Boolean, fixedFontScale: Boolean) {
341
- val colors = AppTheme.current.colors
342
- val text = @Composable {
343
- Text(
344
- text = label,
345
- style = if (vertical) Typography.labelXsMedium else Typography.labelSMedium,
346
- color = if (pressed) Colors.black_01 else colors.text.secondary,
347
- textAlign = TextAlign.Center,
348
- maxLines = 1,
349
- overflow = TextOverflow.Ellipsis,
350
- )
351
- }
352
- Box(
353
- modifier = Modifier
354
- .then(if (vertical) Modifier else Modifier.heightIn(min = TabBarMetrics.ctaLabelHeight))
355
- .then(if (pressed) Modifier.background(colors.primary, RoundedCornerShape(Radius.XL)) else Modifier)
356
- .padding(horizontal = if (vertical) Spacing.XS else Spacing.XXS),
357
- contentAlignment = Alignment.Center,
358
- ) {
359
- if (fixedFontScale) FixedFontScale(text) else text()
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, fixedFontScale: Boolean, 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
- Icon(source = data.icon, color = Colors.black_01, size = TabBarMetrics.ctaIconSize)
380
- }
381
- CenterActionLabel(data.label, pressed, vertical = false, fixedFontScale = fixedFontScale)
382
- }
383
- }
@@ -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
- }