@momo-kits/native-kits 0.169.8-beta.6-debug → 0.169.8-beta.7

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 (146) hide show
  1. package/ios/Navigation/BottomTab/BottomTabBar.swift +9 -0
  2. package/ios/Navigation/Navigation.swift +25 -0
  3. package/ios/Navigation/StackScreen.swift +18 -5
  4. package/ios/native-kits.podspec +1 -1
  5. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  6. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +13 -1
  7. package/package.json +1 -1
  8. package/build.gradle.kts +0 -11
  9. package/compose/build.gradle.kts +0 -198
  10. package/compose/compose.podspec +0 -47
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -19
  12. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  13. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  14. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  15. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -154
  16. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  17. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1067
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -267
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -82
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -356
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -482
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -224
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -195
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -473
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -113
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -263
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -228
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -280
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -183
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -40
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -82
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -39
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -363
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -307
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -88
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -306
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -457
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -205
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -89
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -542
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -120
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -201
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -498
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -210
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -12
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -292
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +0 -63
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -184
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -316
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -397
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -153
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -118
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -746
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -242
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -391
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -100
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -207
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +0 -132
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -167
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -446
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -398
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -197
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -114
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -76
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -22
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  128. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  129. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  130. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  131. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  132. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  133. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
  134. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  135. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  136. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -218
  137. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  138. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -144
  139. package/gradle/libs.versions.toml +0 -67
  140. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  141. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  142. package/gradle.properties +0 -24
  143. package/gradlew +0 -252
  144. package/gradlew.bat +0 -94
  145. package/ios-demo/README.md +0 -120
  146. package/settings.gradle.kts +0 -64
@@ -1,207 +0,0 @@
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) 0.dp
60
- else TabBarMetrics.height + tabBarBottomGap(layout.insetBottom) + if (hasCenterAction) TabBarMetrics.ctaLift else 0.dp
61
-
62
- // Whether the tabs' bar shows the center action, whose button rises ctaLift above the container.
63
- internal val LocalTabBarHasCenterAction = compositionLocalOf { false }
64
-
65
- // iPhone Duo tab bar: rail in the side bar, or the horizontal bar when unfolded portrait.
66
- @Composable
67
- internal fun BoxScope.DuoTabBar(
68
- layout: ScreenLayout,
69
- items: List<BottomTabItem>,
70
- floatingButton: BottomTabFloatingButton?,
71
- selectedIndex: Int,
72
- onTabSelected: (Int) -> Unit,
73
- compression: DuoBarCompression = DuoBarCompression(),
74
- ) {
75
- if (layout.sideBar != null) {
76
- DuoRailTabBar(layout, items, floatingButton, selectedIndex, onTabSelected, compression)
77
- } else {
78
- HorizontalTabBar(
79
- items = items,
80
- floatingButton = floatingButton,
81
- selectedIndex = selectedIndex,
82
- onTabSelected = onTabSelected,
83
- modifier = Modifier
84
- .align(Alignment.BottomCenter)
85
- .padding(bottom = tabBarBottomGap(layout.insetBottom))
86
- .width(
87
- horizontalBarWidth(
88
- layout.width, layout.height, layout.insetLeft, layout.insetRight,
89
- items.size, hasCenterAction(floatingButton, items.size),
90
- ),
91
- ),
92
- )
93
- }
94
- }
95
-
96
- // Vertical bar anchored to the bottom of the side bar, center action below it. When the side bar is
97
- // short it can shrink to one button showing the current tab (HIG "Tab bar compressed"); tapping it
98
- // expands the rail and compresses the toolbar.
99
- @Composable
100
- private fun BoxScope.DuoRailTabBar(
101
- layout: ScreenLayout,
102
- items: List<BottomTabItem>,
103
- floatingButton: BottomTabFloatingButton?,
104
- selectedIndex: Int,
105
- onTabSelected: (Int) -> Unit,
106
- compression: DuoBarCompression,
107
- ) {
108
- val sideBar = layout.sideBar ?: return
109
- val isRight = sideBar.edge == SideBarEdge.RIGHT
110
-
111
- // the rail lines up with the header buttons in the side bar: centered on a 48 lane kept Spacing.M
112
- // from the strip's inner edge; the wider rail and center action overflow the lane evenly
113
- Column(
114
- modifier = Modifier
115
- .align(if (isRight) AbsoluteAlignment.BottomRight else AbsoluteAlignment.BottomLeft)
116
- .width(sideBar.width)
117
- .padding(bottom = sideBar.bottom)
118
- .absolutePadding(left = if (isRight) Spacing.M else 0.dp, right = if (isRight) 0.dp else Spacing.M)
119
- .wrapContentWidth(if (isRight) AbsoluteAlignment.Left else AbsoluteAlignment.Right)
120
- .width(COMPACT_SIZE),
121
- horizontalAlignment = Alignment.CenterHorizontally,
122
- verticalArrangement = Arrangement.spacedBy(TabBarMetrics.railCtaGap),
123
- ) {
124
- val current = items.getOrNull(selectedIndex)
125
- if (compression.tabBarCompressed && current != null) {
126
- Column(
127
- modifier = Modifier
128
- .size(COMPACT_SIZE)
129
- .tabBarContainer(CircleShape)
130
- .noFeedbackClickable(onClick = compression.expandTabBar)
131
- .setAutomationId("bottom_tab_bar"),
132
- horizontalAlignment = Alignment.CenterHorizontally,
133
- verticalArrangement = Arrangement.Center,
134
- ) {
135
- TabIcon(current, AppTheme.current.colors.primary, vertical = true)
136
- }
137
- } else {
138
- Rail(items, selectedIndex) {
139
- onTabSelected(it)
140
- compression.onTabSelected()
141
- }
142
- }
143
- if (floatingButton != null) {
144
- RailCenterAction(floatingButton)
145
- }
146
- }
147
- }
148
-
149
- // Column of rail items (.Nav/Duo/Item) with the sliding active indicator.
150
- @Composable
151
- private fun Rail(items: List<BottomTabItem>, selectedIndex: Int, onItemClick: (Int) -> Unit) {
152
- val density = LocalDensity.current
153
- Box(
154
- Modifier
155
- .wrapContentWidth(unbounded = true)
156
- .width(TabBarMetrics.railContainerWidth)
157
- .tabBarContainer(RoundedCornerShape(Radius.XL))
158
- .padding(horizontal = TabBarMetrics.railPaddingHorizontal)
159
- .padding(bottom = TabBarMetrics.railPaddingBottom)
160
- .setAutomationId("bottom_tab_bar")
161
- ) {
162
- ActiveIndicator(
163
- offset = with(density) { (Spacing.XS + TabBarMetrics.railItemHeight * selectedIndex.coerceAtLeast(0)).toPx() },
164
- modifier = Modifier.size(TabBarMetrics.railItemWidth, TabBarMetrics.railIndicatorHeight),
165
- shape = RoundedCornerShape(TabBarMetrics.railIndicatorRadius),
166
- axisX = false,
167
- )
168
- Column {
169
- items.forEachIndexed { index, item ->
170
- Column(
171
- modifier = Modifier
172
- .size(TabBarMetrics.railItemWidth, TabBarMetrics.railItemHeight)
173
- .activeOpacityClickable { onItemClick(index) }
174
- .semantics {
175
- role = Role.Tab
176
- selected = index == selectedIndex
177
- contentDescription = item.label
178
- },
179
- horizontalAlignment = Alignment.CenterHorizontally,
180
- verticalArrangement = Arrangement.Center,
181
- ) {
182
- TabItemContent(item, selected = index == selectedIndex, vertical = true)
183
- }
184
- }
185
- }
186
- }
187
- }
188
-
189
- // Center action of the rail: round button with its label, under the container.
190
- @Composable
191
- private fun RailCenterAction(data: BottomTabFloatingButton) {
192
- val (interactionSource, pressed) = rememberCenterActionPress()
193
- Column(
194
- modifier = Modifier
195
- .wrapContentWidth(unbounded = true)
196
- .size(TabBarMetrics.railCtaWidth, TabBarMetrics.railCtaHeight)
197
- .clickable(interactionSource = interactionSource, indication = null, onClick = data.onPress)
198
- .setAutomationId(data.label),
199
- horizontalAlignment = Alignment.CenterHorizontally,
200
- verticalArrangement = Arrangement.spacedBy(TabBarMetrics.railCtaLabelGap, Alignment.CenterVertically),
201
- ) {
202
- Box(Modifier.centerActionButton(TabBarMetrics.railCtaSize, pressed), contentAlignment = Alignment.Center) {
203
- data.iconContent?.invoke() ?: Icon(source = data.icon, color = Colors.black_01, size = TabBarMetrics.ctaIconSize)
204
- }
205
- CenterActionLabel(data.label, data.labelContent, vertical = true)
206
- }
207
- }
@@ -1,132 +0,0 @@
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
- // Navigation bar measurements (Figma "Specs Navigation", DS-984), mirrored from RN BottomTab/metrics.ts.
15
- // Horizontal: floating container with items split evenly, center action in a notch.
16
- // Vertical: iPhone Duo rail, center action under the container.
17
- internal object TabBarMetrics {
18
- val height = 60.dp
19
- val margin = Spacing.S
20
- val paddingVertical = Spacing.XS
21
- val paddingHorizontal = Spacing.M
22
- val itemGap = 1.dp
23
- // gap between the icon slot and the label inside a tab (Figma: none)
24
- val itemIconLabelGap = 0.dp
25
- // .Nav/Background: Compose has no backdrop blur, so use the Figma Blur=Off spec (opacity 95%, no blur)
26
- // — nearly solid, matching the frosted sample — plus the 1px border below; surface keeps dark-mode support.
27
- val backgroundOpacity = 0.95f
28
- // white 60% hairline around the center action button (Figma Icon Button border)
29
- val ctaBorderOpacity = 0.6f
30
- val iconSize = 24.dp
31
- val indicatorHeight = 32.dp
32
- // label_s_medium / label_xs_medium line heights: the label slot keeps this height so a scaled
33
- // label overflows downward instead of pushing the icon up
34
- val labelHeight = 18.dp
35
- val railLabelHeight = 14.dp
36
- // font scale cap for the whole bar (RN ScaleSizeProvider around renderTabBar): its text follows the
37
- // OS/host scale up to 1.2× so the fixed-height container and the notch stay aligned
38
- const val LABEL_MAX_SCALE = 1.2f
39
- // active indicator behind the icon: 24 icon + XS·M padding
40
- val indicatorPaddingHorizontal = Spacing.M
41
- val indicatorRadius = Radius.XL
42
- // home indicator / gesture bar area under the container
43
- val systemIndicatorHeight = 24.dp
44
- // unfolded foldables (short side from 600, the smallest in the spec) use 65% of the short side,
45
- // centered; phones and folded outer displays fill the window
46
- val foldableMinShortSide = 600.dp
47
- const val FOLDABLE_WIDTH_RATIO = 0.65f
48
- // a 2-tab bar doesn't stretch to the full width: each item is this fixed width and the bar is sized
49
- // to its content, centered (Figma Navigation · 2 Tab: item 100, bar ~225)
50
- val twoTabItemWidth = 100.dp
51
- val ctaSlotWidth = 92.dp
52
- val ctaSize = 48.dp
53
- // the icon sits 10 inside the 48 button (prototype .cta: 28 icon), 12 inside the 52 rail one
54
- val ctaIconSize = 28.dp
55
- // the button rises 22 above the container top edge
56
- val ctaLift = 22.dp
57
- val ctaLabelGap = Spacing.M
58
- val ctaLabelHeight = 18.dp
59
- val railContainerWidth = 56.dp
60
- val railPaddingHorizontal = Spacing.XS
61
- val railPaddingBottom = Spacing.S
62
- val railItemWidth = 48.dp
63
- val railItemHeight = 62.dp
64
- val railIndicatorHeight = 40.dp
65
- val railIndicatorRadius = 20.dp
66
- val railCtaGap = Spacing.L
67
- val railCtaSize = 52.dp
68
- val railCtaLabelGap = Spacing.XS
69
- val railCtaWidth = 68.dp
70
- val railCtaHeight = 70.dp
71
- val badgeMaxWidth = 58.dp
72
- }
73
-
74
- // Motion of the navigation bar (MoMo Navigation Prototype): one active indicator slides to the
75
- // selected item overshooting a little, icon and label tint cross-fade, the center action shrinks while held.
76
- internal object TabBarMotion {
77
- val indicator = tween<Float>(durationMillis = 550, easing = CubicBezierEasing(0.34f, 1.4f, 0.5f, 1f))
78
- const val TINT_MILLIS = 250
79
- const val CTA_PRESS_MILLIS = 150
80
- const val CTA_PRESSED_SCALE = 0.92f
81
- }
82
-
83
- // Figma Effect/Popover on the center action button.
84
- internal val CtaShadows = listOf(
85
- Shadow(radius = 24.dp, spread = (-12).dp, color = Color.Black, alpha = 0.08f, offset = DpOffset(0.dp, 8.dp)),
86
- Shadow(radius = 32.dp, spread = (-16).dp, color = Color.Black, alpha = 0.04f, offset = DpOffset(0.dp, 12.dp)),
87
- )
88
-
89
- // Inner light and tint of the active indicator: white 12% from below, primary 12% from above.
90
- internal fun indicatorInnerShadows(primary: Color) = listOf(
91
- Shadow(radius = 2.dp, color = Color.White, alpha = 0.12f, offset = DpOffset(0.dp, (-2).dp)),
92
- Shadow(radius = 2.dp, color = primary, alpha = 0.12f, offset = DpOffset(0.dp, 1.dp)),
93
- )
94
-
95
- // Notch dipped into the container top edge under the center action (Figma "Backgroud" path): starts
96
- // NOTCH_HALF_WIDTH left of the center, then cubic segments of control1, control2, end, each point as
97
- // (dx from the center, dy below the top edge) in dp.
98
- internal const val NOTCH_HALF_WIDTH = 50.758f
99
- internal val NOTCH_CURVES = listOf(
100
- listOf(-39.749f to 0f, -31.231f to 9.765f, -24.563f to 18.526f),
101
- listOf(-18.928f to 25.93f, -10.022f to 30.709f, 0f to 30.709f),
102
- listOf(10.022f to 30.709f, 18.928f to 25.93f, 24.563f to 18.526f),
103
- listOf(31.231f to 9.765f, 39.749f to 0f, NOTCH_HALF_WIDTH to 0f),
104
- )
105
-
106
- // Width of the horizontal bar: 65% of the short side on an unfolded foldable, otherwise the window minus
107
- // the side safe areas and margins.
108
- internal fun horizontalBarWidth(
109
- width: Dp,
110
- height: Dp,
111
- insetLeft: Dp,
112
- insetRight: Dp,
113
- itemCount: Int,
114
- hasCta: Boolean,
115
- ): Dp {
116
- // 2 tabs (no center action) stay content-sized and centered instead of filling the window
117
- if (itemCount == 2 && !hasCta) {
118
- return TabBarMetrics.twoTabItemWidth * 2 + TabBarMetrics.paddingHorizontal * 2 + TabBarMetrics.itemGap
119
- }
120
- val shortSide = minOf(width, height)
121
- if (shortSide >= TabBarMetrics.foldableMinShortSide) return shortSide * TabBarMetrics.FOLDABLE_WIDTH_RATIO
122
- return width - insetLeft - insetRight - TabBarMetrics.margin * 2
123
- }
124
-
125
- // Gap under the container: the home indicator / gesture bar area.
126
- internal fun tabBarBottomGap(navigationBar: Dp): Dp =
127
- (if (getPlatformName() == "iOS") minOf(navigationBar, TabBarMetrics.systemIndicatorHeight) else navigationBar)
128
- .coerceAtLeast(Spacing.S)
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
- floatingButton != null && tabCount % 2 == 0
@@ -1,167 +0,0 @@
1
- package vn.momo.kits.navigation.component
2
-
3
- import androidx.compose.animation.*
4
- import androidx.compose.animation.core.CubicBezierEasing
5
- import androidx.compose.animation.core.LinearEasing
6
- import androidx.compose.animation.core.animateDpAsState
7
- import androidx.compose.animation.core.tween
8
- import androidx.compose.foundation.ScrollState
9
- import androidx.compose.foundation.background
10
- import androidx.compose.foundation.border
11
- import androidx.compose.foundation.interaction.MutableInteractionSource
12
- import androidx.compose.foundation.layout.*
13
- import androidx.compose.material3.AlertDialogDefaults
14
- import androidx.compose.material3.FloatingActionButton
15
- import androidx.compose.material3.FloatingActionButtonDefaults
16
- import androidx.compose.material3.FloatingActionButtonElevation
17
- import androidx.compose.runtime.*
18
- import androidx.compose.runtime.saveable.rememberSaveable
19
- import androidx.compose.ui.Alignment
20
- import androidx.compose.ui.Modifier
21
- import androidx.compose.ui.graphics.Color
22
- import androidx.compose.ui.unit.Dp
23
- import androidx.compose.ui.unit.dp
24
- import kotlinx.coroutines.delay
25
- import kotlinx.coroutines.flow.MutableStateFlow
26
- import kotlinx.coroutines.flow.collectLatest
27
- import kotlinx.coroutines.launch
28
- import vn.momo.kits.application.IsShowBaseLineDebug
29
- import vn.momo.kits.components.Icon
30
- import vn.momo.kits.components.Text
31
- import vn.momo.kits.const.Colors
32
- import vn.momo.kits.const.Typography
33
- import vn.momo.kits.modifier.conditional
34
- import kotlin.time.Duration.Companion.milliseconds
35
-
36
- enum class FABSize { SMALL, DEFAULT }
37
- enum class FABPosition { END, CENTER }
38
-
39
- data class FloatingButtonProps(
40
- val icon: String,
41
- val iconColor: Color? = null,
42
- val label: String? = null,
43
- val onClick: () -> Unit,
44
- val size: FABSize = FABSize.DEFAULT,
45
- val bottom: Dp? = null,
46
- val scrollState: ScrollState? = null,
47
- val position: FABPosition? = FABPosition.END,
48
- )
49
-
50
- private val FabSmallSize = 36.dp
51
- private val FabDefaultSize = 48.dp
52
- private val FabExpandedWidth = 80.dp
53
- private val FabIconSizeSmall = 12.dp
54
- private val FabIconSizeDefault = 24.dp
55
- private val FabPaddingHorizontal = 12.dp
56
-
57
- @Composable
58
- internal fun FloatingButton(
59
- scrollPosition: Int,
60
- bottom: Dp,
61
- onClick: () -> Unit,
62
- containerColor: Color,
63
- contentColor: Color = containerColor,
64
- icon: String,
65
- iconColor: Color? = null,
66
- text: String? = null,
67
- elevation: FloatingActionButtonElevation = FloatingActionButtonDefaults.elevation(4.dp),
68
- size: FABSize = FABSize.DEFAULT,
69
- position: FABPosition = FABPosition.END,
70
- keyboardSize: Dp = 0.dp,
71
- ) {
72
- val scrollStateFlow = remember { MutableStateFlow(scrollPosition) }
73
- var lastScrollPosition by rememberSaveable { mutableStateOf(0) }
74
- var isExpanded by rememberSaveable { mutableStateOf(false) }
75
-
76
- val coroutineScope = rememberCoroutineScope()
77
-
78
- val baseSize = if (size == FABSize.SMALL) FabSmallSize else FabDefaultSize
79
- val width by animateDpAsState(
80
- targetValue = if (isExpanded && text != null) FabExpandedWidth else baseSize,
81
- animationSpec = tween(100, easing = CubicBezierEasing(0.2f, 0.2f, 0.2f, 0.2f))
82
- )
83
-
84
- LaunchedEffect(text) {
85
- if (text != null) {
86
- coroutineScope.launch {
87
- scrollStateFlow.collectLatest { newScroll ->
88
- isExpanded = newScroll <= lastScrollPosition
89
- delay(100.milliseconds)
90
- lastScrollPosition = newScroll
91
- }
92
- }
93
- }
94
- }
95
-
96
- LaunchedEffect(scrollPosition) {
97
- scrollStateFlow.value = scrollPosition
98
- }
99
-
100
- Box(
101
- modifier = Modifier
102
- .fillMaxSize()
103
- .padding(end = 12.dp, bottom = bottom)
104
- .offset(y = -keyboardSize)
105
- .background(Color.Transparent),
106
- contentAlignment = if (position == FABPosition.END) Alignment.BottomEnd else Alignment.BottomCenter,
107
- ) {
108
- FloatingActionButton(
109
- onClick = onClick,
110
- shape = AlertDialogDefaults.shape,
111
- containerColor = containerColor,
112
- contentColor = contentColor,
113
- elevation = elevation,
114
- interactionSource = remember { MutableInteractionSource() },
115
- modifier = Modifier
116
- .sizeIn(minWidth = width)
117
- .height(baseSize)
118
- .conditional(IsShowBaseLineDebug) {
119
- border(1.dp, Colors.blue_03)
120
- }
121
- ) {
122
- Row(
123
- modifier = Modifier.padding(
124
- start = if (isExpanded) FabPaddingHorizontal else 0.dp,
125
- end = if (isExpanded) FabPaddingHorizontal else 0.dp,
126
- ),
127
- verticalAlignment = Alignment.CenterVertically,
128
- horizontalArrangement = if (isExpanded) Arrangement.Start else Arrangement.Center
129
- ) {
130
- Icon(
131
- source = icon,
132
- size = if (size == FABSize.SMALL) FabIconSizeSmall else FabIconSizeDefault,
133
- color = iconColor ?: Color.White
134
- )
135
-
136
- AnimatedVisibility(
137
- visible = isExpanded,
138
- enter = fadeInExpandAnimation,
139
- exit = fadeOutShrinkAnimation,
140
- ) {
141
- Row {
142
- Spacer(Modifier.width(12.dp))
143
- Text(
144
- text = text ?: "",
145
- color = Color.White,
146
- style = Typography.actionDefaultBold
147
- )
148
- }
149
- }
150
- }
151
- }
152
- }
153
- }
154
-
155
- private val fadeOutShrinkAnimation = fadeOut(
156
- animationSpec = tween(100, easing = LinearEasing)
157
- ) + shrinkHorizontally(
158
- animationSpec = tween(100, easing = LinearEasing),
159
- shrinkTowards = Alignment.Start
160
- )
161
-
162
- private val fadeInExpandAnimation = fadeIn(
163
- animationSpec = tween(100, easing = LinearEasing)
164
- ) + expandHorizontally(
165
- animationSpec = tween(100, easing = LinearEasing),
166
- expandFrom = Alignment.Start
167
- )