@momo-kits/native-kits 0.169.15-beta.2 → 0.169.15-beta.3-debug

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 (145) hide show
  1. package/build.gradle.kts +11 -0
  2. package/compose/build.gradle.kts +198 -0
  3. package/compose/compose.podspec +47 -0
  4. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -0
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +154 -0
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +110 -0
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +61 -0
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1067 -0
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +268 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +354 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +130 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +482 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +224 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +137 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +473 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +113 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +262 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +237 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +228 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +280 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +183 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +342 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +40 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +82 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +39 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +362 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +304 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +88 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +308 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +218 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +456 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +205 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +89 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +542 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +175 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +201 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +498 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +208 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +12 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +291 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +315 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +54 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +397 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +153 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +118 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +206 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +421 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +758 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +152 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +260 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +406 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +111 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +93 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +208 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/LegacyBottomTabBar.kt +262 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/LegacyCurvedContainer.kt +86 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +167 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +446 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +105 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +400 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +197 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +114 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +7 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +76 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +21 -0
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +117 -0
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +42 -0
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
  130. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +65 -0
  131. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +217 -0
  132. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  133. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +143 -0
  134. package/gradle/libs.versions.toml +67 -0
  135. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  136. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  137. package/gradle.properties +24 -0
  138. package/gradlew +252 -0
  139. package/gradlew.bat +94 -0
  140. package/ios/Navigation/BottomTab/LegacyBottomTabBar.swift +1 -2
  141. package/ios/native-kits.podspec +1 -1
  142. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  143. package/ios-demo/README.md +120 -0
  144. package/package.json +1 -1
  145. package/settings.gradle.kts +64 -0
@@ -0,0 +1,208 @@
1
+ package vn.momo.kits.navigation.bottomtab
2
+
3
+ import androidx.compose.foundation.clickable
4
+ import androidx.compose.foundation.layout.Arrangement
5
+ import androidx.compose.foundation.layout.Box
6
+ import androidx.compose.foundation.layout.BoxScope
7
+ import androidx.compose.foundation.layout.Column
8
+ import androidx.compose.foundation.layout.height
9
+ import androidx.compose.foundation.layout.offset
10
+ import androidx.compose.foundation.layout.padding
11
+ import androidx.compose.foundation.layout.size
12
+ import androidx.compose.foundation.layout.width
13
+ import androidx.compose.foundation.layout.absolutePadding
14
+ import androidx.compose.foundation.layout.wrapContentWidth
15
+ import androidx.compose.foundation.shape.CircleShape
16
+ import androidx.compose.foundation.shape.RoundedCornerShape
17
+ import androidx.compose.runtime.Composable
18
+ import androidx.compose.runtime.compositionLocalOf
19
+ import androidx.compose.ui.AbsoluteAlignment
20
+ import androidx.compose.ui.Alignment
21
+ import androidx.compose.ui.Modifier
22
+ import androidx.compose.ui.graphics.Color
23
+ import androidx.compose.ui.platform.LocalDensity
24
+ import androidx.compose.ui.semantics.Role
25
+ import androidx.compose.ui.semantics.contentDescription
26
+ import androidx.compose.ui.semantics.role
27
+ import androidx.compose.ui.semantics.selected
28
+ import androidx.compose.ui.semantics.semantics
29
+ import vn.momo.kits.modifier.activeOpacityClickable
30
+ import androidx.compose.ui.unit.Dp
31
+ import androidx.compose.ui.unit.dp
32
+ import vn.momo.kits.components.Icon
33
+ import vn.momo.kits.const.AppTheme
34
+ import vn.momo.kits.const.Colors
35
+ import vn.momo.kits.const.Radius
36
+ import vn.momo.kits.const.Spacing
37
+ import vn.momo.kits.layout.DuoMetrics
38
+ import vn.momo.kits.layout.ScreenLayout
39
+ import vn.momo.kits.layout.SideBarEdge
40
+ import vn.momo.kits.modifier.noFeedbackClickable
41
+ import vn.momo.kits.modifier.setAutomationId
42
+
43
+ // Figma "Specs Navigation" (DS-984) Vertical type, mirrored from RN DuoTabBar.tsx.
44
+ private val COMPACT_SIZE = DuoMetrics.controlSize
45
+
46
+ // Space from the window bottom the rail stack and its gap take, so the header side bar stays above it.
47
+ internal val LocalDuoRailReserve = compositionLocalOf { 0.dp }
48
+
49
+ // Rail container plus the center action under it; compressed, the rail is a single button.
50
+ internal fun duoRailHeight(itemCount: Int, hasQr: Boolean, compressed: Boolean = false): Dp {
51
+ val rail = if (compressed) COMPACT_SIZE
52
+ else TabBarMetrics.railItemHeight * itemCount + TabBarMetrics.railPaddingBottom
53
+ return rail + if (hasQr) TabBarMetrics.railCtaGap + TabBarMetrics.railCtaHeight else 0.dp
54
+ }
55
+
56
+ // Space tab content leaves under the floating horizontal bar (phone and unfolded Duo), the rising center
57
+ // action included; 0 when the Duo rail sits in the side strip.
58
+ internal fun duoFloatingTabBarInset(layout: ScreenLayout, hasCenterAction: Boolean = false): Dp {
59
+ if (layout.isIPhoneDuo && layout.sideBar != null) return 0.dp
60
+ val ctaLift = if (hasCenterAction) TabBarMetrics.ctaLift else 0.dp
61
+ return TabBarMetrics.height + tabBarBottomGap(layout.insetBottom) + ctaLift
62
+ }
63
+
64
+ // Whether the tabs' bar shows the center action, whose button rises ctaLift above the container.
65
+ internal val LocalTabBarHasCenterAction = compositionLocalOf { false }
66
+
67
+ // iPhone Duo tab bar: rail in the side bar, or the horizontal bar when unfolded portrait.
68
+ @Composable
69
+ internal fun BoxScope.DuoTabBar(
70
+ layout: ScreenLayout,
71
+ items: List<BottomTabItem>,
72
+ floatingButton: BottomTabFloatingButton?,
73
+ selectedIndex: Int,
74
+ onTabSelected: (Int) -> Unit,
75
+ compression: DuoBarCompression = DuoBarCompression(),
76
+ ) {
77
+ if (layout.sideBar != null) {
78
+ DuoRailTabBar(layout, items, floatingButton, selectedIndex, onTabSelected, compression)
79
+ } else {
80
+ HorizontalTabBar(
81
+ items = items,
82
+ floatingButton = floatingButton,
83
+ selectedIndex = selectedIndex,
84
+ onTabSelected = onTabSelected,
85
+ modifier = Modifier
86
+ .align(Alignment.BottomCenter)
87
+ .padding(bottom = tabBarBottomGap(layout.insetBottom))
88
+ .width(
89
+ horizontalBarWidth(
90
+ layout.width, layout.height, layout.insetLeft, layout.insetRight,
91
+ items.size, hasCenterAction(floatingButton, items.size),
92
+ ),
93
+ ),
94
+ )
95
+ }
96
+ }
97
+
98
+ // Rail at the bottom of the side bar, center action below. A short side bar shrinks it to the current
99
+ // tab's button (HIG "Tab bar compressed"); tapping it expands the rail and compresses the toolbar.
100
+ @Composable
101
+ private fun BoxScope.DuoRailTabBar(
102
+ layout: ScreenLayout,
103
+ items: List<BottomTabItem>,
104
+ floatingButton: BottomTabFloatingButton?,
105
+ selectedIndex: Int,
106
+ onTabSelected: (Int) -> Unit,
107
+ compression: DuoBarCompression,
108
+ ) {
109
+ val sideBar = layout.sideBar ?: return
110
+ val isRight = sideBar.edge == SideBarEdge.RIGHT
111
+
112
+ // the rail lines up with the header buttons in the side bar: centered on a 48 lane kept Spacing.M
113
+ // from the strip's inner edge; the wider rail and center action overflow the lane evenly
114
+ Column(
115
+ modifier = Modifier
116
+ .align(if (isRight) AbsoluteAlignment.BottomRight else AbsoluteAlignment.BottomLeft)
117
+ .width(sideBar.width)
118
+ .padding(bottom = sideBar.bottom)
119
+ .absolutePadding(left = if (isRight) Spacing.M else 0.dp, right = if (isRight) 0.dp else Spacing.M)
120
+ .wrapContentWidth(if (isRight) AbsoluteAlignment.Left else AbsoluteAlignment.Right)
121
+ .width(COMPACT_SIZE),
122
+ horizontalAlignment = Alignment.CenterHorizontally,
123
+ verticalArrangement = Arrangement.spacedBy(TabBarMetrics.railCtaGap),
124
+ ) {
125
+ val current = items.getOrNull(selectedIndex)
126
+ if (compression.tabBarCompressed && current != null) {
127
+ Column(
128
+ modifier = Modifier
129
+ .size(COMPACT_SIZE)
130
+ .tabBarContainer(CircleShape)
131
+ .noFeedbackClickable(onClick = compression.expandTabBar)
132
+ .setAutomationId("bottom_tab_bar"),
133
+ horizontalAlignment = Alignment.CenterHorizontally,
134
+ verticalArrangement = Arrangement.Center,
135
+ ) {
136
+ TabIcon(current, AppTheme.current.colors.primary, vertical = true)
137
+ }
138
+ } else {
139
+ Rail(items, selectedIndex) {
140
+ onTabSelected(it)
141
+ compression.onTabSelected()
142
+ }
143
+ }
144
+ if (floatingButton != null) {
145
+ RailCenterAction(floatingButton)
146
+ }
147
+ }
148
+ }
149
+
150
+ // Column of rail items (.Nav/Duo/Item) with the sliding active indicator.
151
+ @Composable
152
+ private fun Rail(items: List<BottomTabItem>, selectedIndex: Int, onItemClick: (Int) -> Unit) {
153
+ val density = LocalDensity.current
154
+ Box(
155
+ Modifier
156
+ .wrapContentWidth(unbounded = true)
157
+ .width(TabBarMetrics.railContainerWidth)
158
+ .tabBarContainer(RoundedCornerShape(Radius.XL))
159
+ .padding(horizontal = TabBarMetrics.railPaddingHorizontal)
160
+ .padding(bottom = TabBarMetrics.railPaddingBottom)
161
+ .setAutomationId("bottom_tab_bar")
162
+ ) {
163
+ ActiveIndicator(
164
+ offset = with(density) { (Spacing.XS + TabBarMetrics.railItemHeight * selectedIndex.coerceAtLeast(0)).toPx() },
165
+ modifier = Modifier.size(TabBarMetrics.railItemWidth, TabBarMetrics.railIndicatorHeight),
166
+ shape = RoundedCornerShape(TabBarMetrics.railIndicatorRadius),
167
+ axisX = false,
168
+ )
169
+ Column {
170
+ items.forEachIndexed { index, item ->
171
+ Column(
172
+ modifier = Modifier
173
+ .size(TabBarMetrics.railItemWidth, TabBarMetrics.railItemHeight)
174
+ .activeOpacityClickable { onItemClick(index) }
175
+ .semantics {
176
+ role = Role.Tab
177
+ selected = index == selectedIndex
178
+ contentDescription = item.label
179
+ },
180
+ horizontalAlignment = Alignment.CenterHorizontally,
181
+ verticalArrangement = Arrangement.Center,
182
+ ) {
183
+ TabItemContent(item, selected = index == selectedIndex, vertical = true)
184
+ }
185
+ }
186
+ }
187
+ }
188
+ }
189
+
190
+ // Center action of the rail: round button with its label, under the container.
191
+ @Composable
192
+ private fun RailCenterAction(data: BottomTabFloatingButton) {
193
+ val (interactionSource, pressed) = rememberCenterActionPress()
194
+ Column(
195
+ modifier = Modifier
196
+ .wrapContentWidth(unbounded = true)
197
+ .size(TabBarMetrics.railCtaWidth, TabBarMetrics.railCtaHeight)
198
+ .clickable(interactionSource = interactionSource, indication = null, onClick = data.onPress)
199
+ .setAutomationId(data.label),
200
+ horizontalAlignment = Alignment.CenterHorizontally,
201
+ verticalArrangement = Arrangement.spacedBy(TabBarMetrics.railCtaLabelGap, Alignment.CenterVertically),
202
+ ) {
203
+ Box(Modifier.centerActionButton(TabBarMetrics.railCtaSize, pressed), contentAlignment = Alignment.Center) {
204
+ data.iconContent?.invoke() ?: Icon(source = data.icon, color = Colors.black_01, size = TabBarMetrics.ctaIconSize)
205
+ }
206
+ CenterActionLabel(data.label, data.labelContent, vertical = true)
207
+ }
208
+ }
@@ -0,0 +1,262 @@
1
+ package vn.momo.kits.navigation.bottomtab
2
+
3
+ import androidx.compose.animation.core.Animatable
4
+ import androidx.compose.animation.core.animateFloatAsState
5
+ import androidx.compose.animation.core.tween
6
+ import androidx.compose.foundation.background
7
+ import androidx.compose.foundation.border
8
+ import androidx.compose.foundation.combinedClickable
9
+ import androidx.compose.foundation.interaction.MutableInteractionSource
10
+ import androidx.compose.foundation.interaction.collectIsPressedAsState
11
+ import androidx.compose.foundation.layout.*
12
+ import androidx.compose.foundation.shape.CircleShape
13
+ import androidx.compose.foundation.shape.RoundedCornerShape
14
+ import androidx.compose.runtime.Composable
15
+ import androidx.compose.runtime.LaunchedEffect
16
+ import androidx.compose.runtime.getValue
17
+ import androidx.compose.runtime.mutableIntStateOf
18
+ import androidx.compose.runtime.remember
19
+ import androidx.compose.runtime.saveable.rememberSaveable
20
+ import androidx.compose.runtime.setValue
21
+ import androidx.compose.ui.Alignment
22
+ import androidx.compose.ui.Modifier
23
+ import androidx.compose.ui.graphics.Brush
24
+ import androidx.compose.ui.graphics.Color
25
+ import androidx.compose.ui.graphics.graphicsLayer
26
+ import androidx.compose.ui.semantics.Role
27
+ import androidx.compose.ui.text.style.TextAlign
28
+ import androidx.compose.ui.text.style.TextOverflow
29
+ import androidx.compose.ui.unit.Dp
30
+ import androidx.compose.ui.unit.IntOffset
31
+ import androidx.compose.ui.unit.dp
32
+ import vn.momo.kits.application.IsShowBaseLineDebug
33
+ import vn.momo.kits.components.*
34
+ import vn.momo.kits.const.*
35
+ import vn.momo.kits.modifier.conditional
36
+ import vn.momo.kits.modifier.activeOpacityClickable
37
+ import vn.momo.kits.layout.getScreenLayout
38
+ import vn.momo.kits.utils.horizontalSafeAreaPadding
39
+
40
+ // Height of the pre-redesign docked bar (DS-984 made it a floating pill), used by useLegacy.
41
+ internal const val LEGACY_BOTTOM_TAB_BAR_HEIGHT = 64
42
+
43
+ private val legacyTabTimingSpec = tween<Float>(durationMillis = 200, easing = inOutQuad)
44
+
45
+ @Composable
46
+ internal fun LegacyBottomTabBar(
47
+ items: List<BottomTabItem>,
48
+ floatingButton: BottomTabFloatingButton? = null,
49
+ selectedIndex: Int,
50
+ onTabSelected: (Int) -> Unit,
51
+ onTabLongPress: ((Int) -> Unit)? = null,
52
+ ) {
53
+
54
+ val layout = getScreenLayout()
55
+ val mid = items.size / 2
56
+
57
+ val floating = floatingButton?.takeIf { items.size % 2 == 0 }
58
+ val slotWidth = layout.contentWidth / (items.size + if (floating != null) 1 else 0)
59
+ fun slotOf(index: Int) = if (floating != null && index >= mid) index + 1 else index
60
+
61
+ var indicatorSlot by rememberSaveable { mutableIntStateOf(0) }
62
+ val indicatorX = remember { Animatable(indicatorSlot.toFloat()) }
63
+ LaunchedEffect(selectedIndex) {
64
+ val target = slotOf(selectedIndex)
65
+ indicatorSlot = target
66
+ indicatorX.animateTo(target.toFloat(), legacyTabTimingSpec)
67
+ }
68
+
69
+ Box(
70
+ contentAlignment = Alignment.BottomCenter
71
+ ) {
72
+ Row(
73
+ modifier = Modifier
74
+ .fillMaxWidth()
75
+ .height(LEGACY_BOTTOM_TAB_BAR_HEIGHT.dp)
76
+ .background(AppTheme.current.colors.background.surface)
77
+ .conditional(IsShowBaseLineDebug) {
78
+ border(1.dp, Colors.blue_03)
79
+ }
80
+ .horizontalSafeAreaPadding(),
81
+ horizontalArrangement = Arrangement.SpaceAround,
82
+ ) {
83
+ if (floating == null) {
84
+ LegacyRenderTabBarItem(items, 0, items.size, selectedIndex, onTabSelected, onTabLongPress)
85
+ } else {
86
+ LegacyRenderTabBarItem(items, 0, mid, selectedIndex, onTabSelected, onTabLongPress)
87
+ Spacer(modifier = Modifier.width(slotWidth))
88
+ LegacyRenderTabBarItem(items, mid, items.size, selectedIndex, onTabSelected, onTabLongPress)
89
+ }
90
+ }
91
+
92
+ Box(modifier = Modifier
93
+ .offset { IntOffset((layout.insetLeft + slotWidth * (indicatorX.value + 0.5f) - layout.width / 2).roundToPx(), (-LEGACY_BOTTOM_TAB_BAR_HEIGHT + 2).dp.roundToPx()) }
94
+ .height(2.dp)
95
+ .width(44.dp)
96
+ .background(
97
+ color = AppTheme.current.colors.primary ,
98
+ shape = RoundedCornerShape(bottomStart = 2.dp, bottomEnd = 2.dp)
99
+ )
100
+ )
101
+
102
+ Box(modifier = Modifier
103
+ .fillMaxWidth()
104
+ .height(6.dp)
105
+ .offset(x = 0.dp, y = (-LEGACY_BOTTOM_TAB_BAR_HEIGHT).dp)
106
+ .background(
107
+ brush = Brush.verticalGradient(
108
+ colors = listOf(Color.Transparent, Color.Black.copy(alpha = 0.05f))
109
+ )
110
+ )
111
+ )
112
+ floating?.let {
113
+ Box(Modifier.offset(x = (layout.insetLeft - layout.insetRight) / 2)) {
114
+ LegacyFloatingButton(it, slotWidth)
115
+ }
116
+ }
117
+ }
118
+ }
119
+
120
+ @Composable
121
+ internal fun RowScope.LegacyRenderTabBarItem(
122
+ items: List<BottomTabItem>,
123
+ fromIndex: Int,
124
+ toIndex: Int,
125
+ selectedIndex: Int,
126
+ onTabSelected: (Int) -> Unit,
127
+ onTabLongPress: ((Int) -> Unit)? = null,
128
+ ){
129
+ for (index in fromIndex until toIndex) {
130
+ Box(modifier = Modifier.weight(1f)) {
131
+ LegacyTabBarItem(
132
+ item = items[index],
133
+ selected = index == selectedIndex,
134
+ onClick = { onTabSelected(index) },
135
+ onLongClick = onTabLongPress?.let { { it(index) } },
136
+ )
137
+ }
138
+ }
139
+ }
140
+
141
+ @Composable
142
+ internal fun LegacyTabBarItem(item: BottomTabItem, selected: Boolean, onClick: () -> Unit, onLongClick: (() -> Unit)? = null) {
143
+ // RN parity: "0" hides the badge, "" renders a dot.
144
+ val badgeLabel = item.badgeLabel?.takeUnless { it.toIntOrNull() == 0 }
145
+ val showDot = badgeLabel?.isEmpty() ?: item.showDot
146
+ val interactionSource = remember { MutableInteractionSource() }
147
+ val pressed by interactionSource.collectIsPressedAsState()
148
+ val alpha by animateFloatAsState(if (pressed) 0.2f else 1f, label = "TabBarItemOpacity")
149
+
150
+ BoxWithConstraints(modifier = Modifier
151
+ .fillMaxSize()
152
+ .padding(horizontal = Spacing.XXS)
153
+ .conditional(IsShowBaseLineDebug) {
154
+ border(1.dp, Colors.blue_03)
155
+ }
156
+ .graphicsLayer { this.alpha = alpha }
157
+ .combinedClickable(
158
+ interactionSource = interactionSource,
159
+ indication = null,
160
+ role = Role.Tab,
161
+ onLongClick = onLongClick,
162
+ onClick = onClick,
163
+ ),
164
+ contentAlignment = Alignment.BottomStart
165
+ ){
166
+ // from the icon's center to the cell's end edge
167
+ val badgeMaxWidth = (maxWidth / 2 - Spacing.XXS).coerceAtLeast(0.dp)
168
+ Column(
169
+ modifier = Modifier
170
+ .fillMaxSize()
171
+ // no vertical padding: icon (36) + label (14) centered in the 64 bar; a fixed 8 top/bottom left
172
+ // the label 12 and cut its bottom
173
+ .padding(horizontal = Spacing.S),
174
+ horizontalAlignment = Alignment.CenterHorizontally,
175
+ verticalArrangement = Arrangement.Center
176
+ ) {
177
+ Box(modifier = Modifier.padding(Spacing.XS)) {
178
+ Icon(
179
+ source = item.icon,
180
+ size = 28.dp,
181
+ color = if (selected) AppTheme.current.colors.primary else AppTheme.current.colors.text.hint)
182
+ if (showDot) {
183
+ val dotAnchor = Modifier.matchParentSize().wrapContentSize(Alignment.TopEnd, unbounded = true)
184
+ BadgeDot(size = DotSize.Small, modifier = dotAnchor.offset(x = 4.dp, y = (-4).dp))
185
+ } else if (!badgeLabel.isNullOrEmpty()) {
186
+ // starts at the icon's center and grows toward the cell's end edge, ellipsized past it
187
+ val badgeAnchor = Modifier.matchParentSize().wrapContentSize(Alignment.TopStart, unbounded = true)
188
+ Badge(badgeLabel, modifier = badgeAnchor.offset(x = 14.dp, y = (-8).dp).widthIn(max = badgeMaxWidth))
189
+ }
190
+ }
191
+ Text(
192
+ text = item.label,
193
+ color = if (selected) AppTheme.current.colors.primary else AppTheme.current.colors.text.hint,
194
+ style = if (selected) Typography.labelXsMedium else Typography.descriptionXsRegular,
195
+ maxLines = 1,
196
+ overflow = TextOverflow.Ellipsis
197
+ )
198
+ }
199
+ }
200
+ }
201
+
202
+ @Composable
203
+ internal fun LegacyFloatingButton(data: BottomTabFloatingButton, width: Dp) {
204
+ Column(
205
+ modifier = Modifier
206
+ .width(width)
207
+ .padding(horizontal = Spacing.XXS, vertical = Spacing.S)
208
+ .conditional(IsShowBaseLineDebug) {
209
+ border(1.dp, Colors.blue_03)
210
+ }
211
+ .activeOpacityClickable {
212
+ data.onPress()
213
+ },
214
+ verticalArrangement = Arrangement.Bottom,
215
+ horizontalAlignment = Alignment.CenterHorizontally
216
+
217
+ ){
218
+ LegacyCurvedContainer()
219
+ Box(
220
+ modifier = Modifier
221
+ .size(48.dp)
222
+ .background(AppTheme.current.colors.primary, CircleShape),
223
+ contentAlignment = Alignment.Center
224
+ ) {
225
+ val iconContent = data.iconContent
226
+ if (iconContent != null) iconContent() else Icon(source = data.icon, color = Color.White, size = 28.dp)
227
+ }
228
+ Spacer(modifier = Modifier.height(4.dp))
229
+ Box(contentAlignment = Alignment.Center) {
230
+ Text(
231
+ text = data.label,
232
+ style = Typography.labelXsMedium,
233
+ color = Colors.black_01,
234
+ textAlign = TextAlign.Center,
235
+ modifier = Modifier
236
+ .height(14.dp)
237
+ .fillMaxWidth()
238
+ .background(AppTheme.current.colors.primary, shape = RoundedCornerShape(size = Radius.XL))
239
+ )
240
+ data.labelContent?.invoke()
241
+ }
242
+ }
243
+ }
244
+
245
+ /** Pre-redesign phone bar plus the surface filler under it down to the home indicator. */
246
+ @Composable
247
+ internal fun LegacyBottomTabBarWithFiller(
248
+ items: List<BottomTabItem>,
249
+ floatingButton: BottomTabFloatingButton?,
250
+ selectedIndex: Int,
251
+ onTabSelected: (Int) -> Unit,
252
+ ) {
253
+ Column {
254
+ LegacyBottomTabBar(
255
+ items = items,
256
+ floatingButton = floatingButton,
257
+ selectedIndex = selectedIndex,
258
+ onTabSelected = onTabSelected,
259
+ )
260
+ Spacer(modifier = Modifier.fillMaxWidth().height(AppNavigationBar.current + Spacing.S).background(AppTheme.current.colors.background.surface))
261
+ }
262
+ }
@@ -0,0 +1,86 @@
1
+ package vn.momo.kits.navigation.bottomtab
2
+
3
+ import androidx.compose.foundation.Canvas
4
+ import androidx.compose.foundation.layout.Box
5
+ import androidx.compose.foundation.layout.height
6
+ import androidx.compose.foundation.layout.offset
7
+ import androidx.compose.foundation.layout.width
8
+ import androidx.compose.runtime.Composable
9
+ import androidx.compose.ui.Alignment
10
+ import androidx.compose.ui.Modifier
11
+ import androidx.compose.ui.graphics.Path
12
+ import androidx.compose.ui.platform.LocalDensity
13
+ import androidx.compose.ui.unit.Dp
14
+ import androidx.compose.ui.unit.IntOffset
15
+ import androidx.compose.ui.unit.dp
16
+ import androidx.compose.ui.zIndex
17
+ import vn.momo.kits.const.AppTheme
18
+
19
+ @Composable
20
+ internal fun LegacyCurvedContainer(
21
+ circleSize: Dp = 48.dp,
22
+ tabBarItemIconSize: Dp = 28.dp,
23
+ circleOverSize: Dp = 2.dp,
24
+ width: Dp = 71.dp,
25
+ height: Dp = 16.dp
26
+ ) {
27
+ val theme = AppTheme.current
28
+ val density = LocalDensity.current
29
+ val widthPx = with(density) { width.toPx()}
30
+
31
+ val circleSizePx = with(density) { circleSize.toPx() }
32
+ val tabBarItemIconSizePx = with(density) { tabBarItemIconSize.toPx() }
33
+ val circleOverSizePx = with(density) { circleOverSize.toPx() }
34
+
35
+ val circlePositionTop = circleSizePx - tabBarItemIconSizePx - 10f
36
+ val circleOverTop = circlePositionTop + circleOverSizePx
37
+ val circleR = circleSizePx / 2
38
+ val circleOverR = circleR + circleOverSizePx
39
+
40
+ val centerX = widthPx / 2
41
+
42
+ val curvedPath = getLegacyCurvedPath(
43
+ circleOverTop = circleOverTop,
44
+ centerX = centerX,
45
+ circleOverR = circleOverR,
46
+ widthPx = widthPx
47
+ )
48
+
49
+ Box(
50
+ contentAlignment = Alignment.BottomCenter
51
+ ){
52
+ Canvas(
53
+ modifier = Modifier
54
+ .width(width)
55
+ .height(height)
56
+ .offset{ IntOffset(x = 0, y = 24) }
57
+ .zIndex(-1f)
58
+ ) {
59
+ drawPath(path = curvedPath, color = theme.colors.background.surface)
60
+ }
61
+ }
62
+ }
63
+
64
+ private fun getLegacyCurvedPath(circleOverTop: Float, centerX: Float, circleOverR: Float, widthPx: Float): Path{
65
+ return Path().apply {
66
+ moveTo(0f, circleOverTop)
67
+ lineTo(centerX - circleOverR - 40f, circleOverTop)
68
+
69
+ cubicTo(
70
+ centerX - circleOverR, circleOverTop,
71
+ centerX - circleOverR, 0f,
72
+ centerX, 0f
73
+ )
74
+
75
+ cubicTo(
76
+ centerX + circleOverR, 0f,
77
+ centerX + circleOverR, circleOverTop,
78
+ centerX + circleOverR + 40f, circleOverTop
79
+ )
80
+
81
+ lineTo(widthPx, circleOverTop)
82
+ lineTo(widthPx, 60f)
83
+ lineTo(0f, 60f)
84
+ close()
85
+ }
86
+ }
@@ -0,0 +1,133 @@
1
+ package vn.momo.kits.navigation.bottomtab
2
+
3
+ import androidx.compose.animation.core.CubicBezierEasing
4
+ import androidx.compose.animation.core.tween
5
+ import androidx.compose.ui.graphics.Color
6
+ import androidx.compose.ui.graphics.shadow.Shadow
7
+ import androidx.compose.ui.unit.Dp
8
+ import androidx.compose.ui.unit.DpOffset
9
+ import androidx.compose.ui.unit.dp
10
+ import vn.momo.kits.const.Radius
11
+ import vn.momo.kits.const.Spacing
12
+ import vn.momo.kits.platform.getPlatformName
13
+
14
+ // Mirrored from RN BottomTab/metrics.ts (Figma "Specs Navigation"); `rail*` is the iPhone Duo vertical bar.
15
+ internal object TabBarMetrics {
16
+ val height = 60.dp
17
+ val margin = Spacing.S
18
+ val paddingVertical = Spacing.XS
19
+ val paddingHorizontal = Spacing.M
20
+ val itemGap = 1.dp
21
+ // gap between the icon slot and the label inside a tab (Figma: none)
22
+ val itemIconLabelGap = 0.dp
23
+ // Compose has no backdrop blur: Figma .Nav/Background Blur=Off spec (95%, no blur)
24
+ val backgroundOpacity = 0.95f
25
+ // white 60% hairline around the center action button (Figma Icon Button border)
26
+ val ctaBorderOpacity = 0.6f
27
+ val iconSize = 24.dp
28
+ val indicatorHeight = 32.dp
29
+ // label_s_medium / label_xs_medium line heights: the label slot keeps this height so a scaled
30
+ // label overflows downward instead of pushing the icon up
31
+ val labelHeight = 18.dp
32
+ val railLabelHeight = 14.dp
33
+ // font scale cap for the whole bar (RN ScaleSizeProvider around renderTabBar): its text follows the
34
+ // OS/host scale up to 1.2× so the fixed-height container and the notch stay aligned
35
+ const val LABEL_MAX_SCALE = 1.2f
36
+ // active indicator behind the icon: 24 icon + XS·M padding
37
+ val indicatorPaddingHorizontal = Spacing.M
38
+ val indicatorRadius = Radius.XL
39
+ // home indicator / gesture bar area under the container
40
+ val systemIndicatorHeight = 24.dp
41
+ // unfolded foldables (short side from 600, the smallest in the spec) use 65% of the short side,
42
+ // centered; phones and folded outer displays fill the window
43
+ val foldableMinShortSide = 600.dp
44
+ const val FOLDABLE_WIDTH_RATIO = 0.65f
45
+ // a 2-tab bar doesn't stretch to the full width: each item is this fixed width and the bar is sized
46
+ // to its content, centered (Figma Navigation · 2 Tab: item 100, bar ~225)
47
+ val twoTabItemWidth = 100.dp
48
+ val ctaSlotWidth = 92.dp
49
+ val ctaSize = 48.dp
50
+ // the icon sits 10 inside the 48 button (prototype .cta: 28 icon), 12 inside the 52 rail one
51
+ val ctaIconSize = 28.dp
52
+ // the button rises 22 above the container top edge
53
+ val ctaLift = 22.dp
54
+ val ctaLabelGap = Spacing.M
55
+ val ctaLabelHeight = 18.dp
56
+ val railContainerWidth = 56.dp
57
+ val railPaddingHorizontal = Spacing.XS
58
+ val railPaddingBottom = Spacing.S
59
+ val railItemWidth = 48.dp
60
+ val railItemHeight = 62.dp
61
+ val railIndicatorHeight = 40.dp
62
+ val railIndicatorRadius = 20.dp
63
+ val railCtaGap = Spacing.L
64
+ val railCtaSize = 52.dp
65
+ val railCtaLabelGap = Spacing.XS
66
+ val railCtaWidth = 68.dp
67
+ val railCtaHeight = 70.dp
68
+ val badgeMaxWidth = 58.dp
69
+ }
70
+
71
+ // Motion of the navigation bar (MoMo Navigation Prototype): one active indicator slides to the
72
+ // selected item overshooting a little, icon and label tint cross-fade, the center action shrinks while held.
73
+ internal object TabBarMotion {
74
+ val indicator = tween<Float>(durationMillis = 550, easing = CubicBezierEasing(0.34f, 1.4f, 0.5f, 1f))
75
+ const val TINT_MILLIS = 250
76
+ const val CTA_PRESS_MILLIS = 150
77
+ const val CTA_PRESSED_SCALE = 0.92f
78
+ }
79
+
80
+ // Figma Effect/Popover on the center action button.
81
+ internal val CtaShadows = listOf(
82
+ Shadow(radius = 24.dp, spread = (-12).dp, color = Color.Black, alpha = 0.08f, offset = DpOffset(0.dp, 8.dp)),
83
+ Shadow(radius = 32.dp, spread = (-16).dp, color = Color.Black, alpha = 0.04f, offset = DpOffset(0.dp, 12.dp)),
84
+ )
85
+
86
+ // Inner light and tint of the active indicator: white 12% from below, primary 12% from above.
87
+ internal fun indicatorInnerShadows(primary: Color) = listOf(
88
+ Shadow(radius = 2.dp, color = Color.White, alpha = 0.12f, offset = DpOffset(0.dp, (-2).dp)),
89
+ Shadow(radius = 2.dp, color = primary, alpha = 0.12f, offset = DpOffset(0.dp, 1.dp)),
90
+ )
91
+
92
+ // Center-action notch (Figma "Backgroud" path) from NOTCH_HALF_WIDTH left of center: cubic segments of
93
+ // (control1, control2, end), each point (dx from center, dy below the top edge) in dp.
94
+ internal const val NOTCH_HALF_WIDTH = 50.758f
95
+ internal val NOTCH_CURVES = listOf(
96
+ listOf(-39.749f to 0f, -31.231f to 9.765f, -24.563f to 18.526f),
97
+ listOf(-18.928f to 25.93f, -10.022f to 30.709f, 0f to 30.709f),
98
+ listOf(10.022f to 30.709f, 18.928f to 25.93f, 24.563f to 18.526f),
99
+ listOf(31.231f to 9.765f, 39.749f to 0f, NOTCH_HALF_WIDTH to 0f),
100
+ )
101
+
102
+ // Width of the horizontal bar: 65% of the short side on an unfolded foldable, otherwise the window minus
103
+ // the side safe areas and margins.
104
+ internal fun horizontalBarWidth(
105
+ width: Dp,
106
+ height: Dp,
107
+ insetLeft: Dp,
108
+ insetRight: Dp,
109
+ itemCount: Int,
110
+ hasCta: Boolean,
111
+ ): Dp {
112
+ // 2 tabs (no center action) stay content-sized and centered instead of filling the window
113
+ if (itemCount == 2 && !hasCta) {
114
+ return TabBarMetrics.twoTabItemWidth * 2 + TabBarMetrics.paddingHorizontal * 2 + TabBarMetrics.itemGap
115
+ }
116
+ val shortSide = minOf(width, height)
117
+ if (shortSide >= TabBarMetrics.foldableMinShortSide) return shortSide * TabBarMetrics.FOLDABLE_WIDTH_RATIO
118
+ return width - insetLeft - insetRight - TabBarMetrics.margin * 2
119
+ }
120
+
121
+ // Gap under the container: the home indicator / gesture bar area.
122
+ internal fun tabBarBottomGap(navigationBar: Dp): Dp {
123
+ var gap = navigationBar
124
+ if (getPlatformName() == "iOS") {
125
+ gap = minOf(navigationBar, TabBarMetrics.systemIndicatorHeight)
126
+ }
127
+ return gap.coerceAtLeast(Spacing.S)
128
+ }
129
+
130
+ // The center action needs a tab on each side: Special type takes 2 or 4 tabs.
131
+ internal fun hasCenterAction(floatingButton: BottomTabFloatingButton?, tabCount: Int): Boolean {
132
+ return floatingButton != null && tabCount % 2 == 0
133
+ }