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