@momo-kits/native-kits 0.168.1-beta.37-debug → 0.168.1-beta.38-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 (47) hide show
  1. package/CLAUDE.md +2 -3
  2. package/compose/build.gradle.kts +1 -1
  3. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
  4. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +81 -72
  5. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +13 -8
  6. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +163 -54
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +12 -17
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +4 -7
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +18 -11
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +34 -27
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +319 -167
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +79 -71
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +93 -326
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +104 -0
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +3 -2
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -2
  18. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +3 -2
  19. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +3 -9
  20. package/ios/Input/Input.swift +1 -3
  21. package/ios/Input/InputTextArea.swift +1 -3
  22. package/ios/Layout/ScreenLayout.swift +24 -28
  23. package/ios/Navigation/BottomSheet.swift +157 -29
  24. package/ios/Navigation/BottomTab/BottomTab.swift +48 -67
  25. package/ios/Navigation/BottomTab/BottomTabBar.swift +280 -132
  26. package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
  27. package/ios/Navigation/BottomTab/DuoTabBar.swift +72 -292
  28. package/ios/Navigation/BottomTab/TabBarMetrics.swift +84 -0
  29. package/ios/Navigation/Component/HeaderRight.swift +1 -1
  30. package/ios/Navigation/ModalScreen.swift +7 -18
  31. package/ios/Navigation/StackScreen.swift +3 -1
  32. package/ios/Popup/PopupDisplay.swift +2 -4
  33. package/ios/Popup/PopupInput.swift +2 -4
  34. package/ios/Popup/PopupLayout.swift +9 -10
  35. package/ios/Popup/PopupNotify.swift +23 -26
  36. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  37. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  38. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +272 -59
  39. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -103
  40. package/package.json +1 -1
  41. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +0 -187
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoLiquidSelection.kt +0 -380
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
  45. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
  46. package/ios/Layout/ModalLayout.swift +0 -152
  47. package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +0 -364
@@ -1,106 +1,68 @@
1
1
  package vn.momo.kits.navigation.bottomtab
2
2
 
3
- import androidx.compose.foundation.background
4
- import androidx.compose.foundation.border
5
3
  import androidx.compose.foundation.clickable
6
- import androidx.compose.foundation.combinedClickable
7
- import androidx.compose.foundation.interaction.MutableInteractionSource
8
4
  import androidx.compose.foundation.layout.Arrangement
9
5
  import androidx.compose.foundation.layout.Box
10
6
  import androidx.compose.foundation.layout.BoxScope
11
7
  import androidx.compose.foundation.layout.Column
12
- import androidx.compose.foundation.layout.Row
13
- import androidx.compose.foundation.layout.absolutePadding
14
- import androidx.compose.foundation.layout.fillMaxHeight
15
- import androidx.compose.foundation.layout.fillMaxSize
16
- import androidx.compose.foundation.layout.fillMaxWidth
17
8
  import androidx.compose.foundation.layout.height
18
9
  import androidx.compose.foundation.layout.offset
19
10
  import androidx.compose.foundation.layout.padding
20
11
  import androidx.compose.foundation.layout.size
21
12
  import androidx.compose.foundation.layout.width
22
- import androidx.compose.foundation.layout.widthIn
23
- import androidx.compose.foundation.layout.wrapContentSize
13
+ import androidx.compose.foundation.layout.absolutePadding
14
+ import androidx.compose.foundation.layout.wrapContentWidth
24
15
  import androidx.compose.foundation.shape.CircleShape
25
16
  import androidx.compose.foundation.shape.RoundedCornerShape
26
17
  import androidx.compose.runtime.Composable
27
- import androidx.compose.runtime.CompositionLocalProvider
28
18
  import androidx.compose.runtime.compositionLocalOf
29
- import androidx.compose.runtime.getValue
30
- import androidx.compose.runtime.mutableStateOf
31
- import androidx.compose.runtime.remember
32
- import androidx.compose.runtime.setValue
33
19
  import androidx.compose.ui.AbsoluteAlignment
34
20
  import androidx.compose.ui.Alignment
35
21
  import androidx.compose.ui.Modifier
36
- import androidx.compose.ui.composed
37
- import androidx.compose.ui.draw.clip
38
- import androidx.compose.ui.draw.shadow
39
22
  import androidx.compose.ui.graphics.Color
40
- import androidx.compose.ui.graphics.Shape
41
- import androidx.compose.ui.graphics.graphicsLayer
42
- import androidx.compose.ui.layout.onSizeChanged
43
23
  import androidx.compose.ui.platform.LocalDensity
44
24
  import androidx.compose.ui.semantics.Role
45
- import androidx.compose.ui.semantics.clearAndSetSemantics
46
- import androidx.compose.ui.text.style.TextOverflow
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
47
30
  import androidx.compose.ui.unit.Dp
48
31
  import androidx.compose.ui.unit.dp
49
- import vn.momo.kits.application.LocalContext
50
- import vn.momo.kits.application.MiniAppContext
51
- import vn.momo.kits.components.Badge
52
- import vn.momo.kits.components.BadgeDot
53
- import vn.momo.kits.components.DotSize
54
32
  import vn.momo.kits.components.Icon
55
- import vn.momo.kits.components.Text
56
33
  import vn.momo.kits.const.AppTheme
34
+ import vn.momo.kits.const.Colors
35
+ import vn.momo.kits.const.Radius
57
36
  import vn.momo.kits.const.Spacing
58
- import vn.momo.kits.const.Typography
59
37
  import vn.momo.kits.layout.DuoMetrics
60
38
  import vn.momo.kits.layout.ScreenLayout
61
39
  import vn.momo.kits.layout.SideBarEdge
62
40
  import vn.momo.kits.modifier.noFeedbackClickable
63
41
  import vn.momo.kits.modifier.setAutomationId
64
- import vn.momo.kits.navigation.LocalMaxApi
65
42
 
66
- // Figma Fold-Design-System MT1/MT2, mirrored from RN DuoTabBar.tsx.
67
- private val ITEM_SIZE = DuoMetrics.controlSize
68
- private val ICON_SIZE = 28.dp
69
- private val QR_ICON_SIZE = 24.dp
70
- private val RAIL_PADDING = 6.dp
71
- private val RAIL_GAP = Spacing.XXS
72
- // selection bubble overflows the 48 rail cell by 5 above and below
73
- private val RAIL_BUBBLE_WIDTH = 44.dp
74
- private val RAIL_BUBBLE_HEIGHT = 58.dp
75
- private val FLOATING_HEIGHT = DuoMetrics.floatingTabBarHeight
76
- private val FLOATING_PADDING = Spacing.XS
77
- // the system bar sizes its pill to the tabs instead of stretching it across the display
78
- private val FLOATING_ITEM_WIDTH = 80.dp
79
- // the rail's badge stays inside the capsule: its end sits XXS off the cell's end edge
80
- private val RAIL_BADGE_MAX_WIDTH = ITEM_SIZE - Spacing.XXS * 2
81
- private val RAIL_BADGE_END_OFFSET = (ITEM_SIZE - ICON_SIZE) / 2 - Spacing.XXS
82
- // Figma Home-2026 tab bar "Selection": brand pink at 8%
83
- private const val SELECTION_TINT_ALPHA = 0x14 / 255f
43
+ // Figma "Specs Navigation" (DS-984) Vertical type, mirrored from RN DuoTabBar.tsx.
44
+ private val COMPACT_SIZE = DuoMetrics.controlSize
84
45
 
85
46
  // Space from the window bottom the rail stack and its gap take, so the header side bar stays above it.
86
47
  internal val LocalDuoRailReserve = compositionLocalOf { 0.dp }
87
48
 
88
- // Rail plus the QR button under it; compressed, the rail is a single button.
49
+ // Rail container plus the center action under it; compressed, the rail is a single button.
89
50
  internal fun duoRailHeight(itemCount: Int, hasQr: Boolean, compressed: Boolean = false): Dp {
90
- val rail = if (compressed) ITEM_SIZE
91
- else RAIL_PADDING * 2 + ITEM_SIZE * itemCount + RAIL_GAP * (itemCount - 1).coerceAtLeast(0)
92
- return rail + if (hasQr) Spacing.M + ITEM_SIZE else 0.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
93
54
  }
94
55
 
95
- // Overlaps the home indicator inset like the system tab bar (21pt above the bottom with a 34pt inset).
96
- private fun floatingTabBarBottom(insetBottom: Dp): Dp =
97
- maxOf(insetBottom - DuoMetrics.floatingTabBarInsetOverlap, Spacing.S)
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
98
61
 
99
- // Space tab content leaves under the floating bar; 0 when the rail sits in the side strip or off Duo.
100
- internal fun duoFloatingTabBarInset(layout: ScreenLayout): Dp =
101
- if (layout.isIPhoneDuo && layout.sideBar == null) FLOATING_HEIGHT + floatingTabBarBottom(layout.insetBottom) else 0.dp
62
+ // Whether the tabs' bar shows the center action, whose button rises ctaLift above the container.
63
+ internal val LocalTabBarHasCenterAction = compositionLocalOf { false }
102
64
 
103
- // iPhone Duo tab bar: rail in the side bar, or a floating bar when unfolded portrait.
65
+ // iPhone Duo tab bar: rail in the side bar, or the horizontal bar when unfolded portrait.
104
66
  @Composable
105
67
  internal fun BoxScope.DuoTabBar(
106
68
  layout: ScreenLayout,
@@ -109,21 +71,27 @@ internal fun BoxScope.DuoTabBar(
109
71
  selectedIndex: Int,
110
72
  onTabSelected: (Int) -> Unit,
111
73
  compression: DuoBarCompression = DuoBarCompression(),
112
- onTabLongPress: ((Int) -> Unit)? = null,
113
74
  ) {
114
- val maxApi = LocalMaxApi.current
115
- // a tick per tab the lens enters while dragged
116
- val onTick = remember(maxApi) { { runCatching { maxApi?.triggerEventVibration("light", callback = null) }; Unit } }
117
75
  if (layout.sideBar != null) {
118
- DuoRailTabBar(layout, items, floatingButton, selectedIndex, onTabSelected, compression, onTabLongPress, onTick)
76
+ DuoRailTabBar(layout, items, floatingButton, selectedIndex, onTabSelected, compression)
119
77
  } else {
120
- DuoFloatingTabBar(layout, items, floatingButton, selectedIndex, onTabSelected, onTabLongPress, onTick)
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
+ )
121
89
  }
122
90
  }
123
91
 
124
- // Vertical bar anchored to the bottom of the side bar, QR button below it (Figma MT1-C/E). When the
125
- // side bar is short it can shrink to one button showing the current tab (HIG "Tab bar compressed");
126
- // tapping it expands the rail and compresses the toolbar.
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.
127
95
  @Composable
128
96
  private fun BoxScope.DuoRailTabBar(
129
97
  layout: ScreenLayout,
@@ -132,305 +100,104 @@ private fun BoxScope.DuoRailTabBar(
132
100
  selectedIndex: Int,
133
101
  onTabSelected: (Int) -> Unit,
134
102
  compression: DuoBarCompression,
135
- onTabLongPress: ((Int) -> Unit)?,
136
- onTick: () -> Unit,
137
103
  ) {
138
104
  val sideBar = layout.sideBar ?: return
139
105
  val isRight = sideBar.edge == SideBarEdge.RIGHT
140
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
141
109
  Column(
142
110
  modifier = Modifier
143
111
  .align(if (isRight) AbsoluteAlignment.BottomRight else AbsoluteAlignment.BottomLeft)
144
112
  .width(sideBar.width)
145
113
  .padding(bottom = sideBar.bottom)
146
- .absolutePadding(left = if (isRight) Spacing.M else 0.dp, right = if (isRight) 0.dp else Spacing.M),
147
- horizontalAlignment = if (isRight) AbsoluteAlignment.Left else AbsoluteAlignment.Right,
148
- verticalArrangement = Arrangement.spacedBy(Spacing.M),
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),
149
119
  ) {
150
120
  val current = items.getOrNull(selectedIndex)
151
121
  if (compression.tabBarCompressed && current != null) {
152
- val interactionSource = remember { MutableInteractionSource() }
153
- Box(
122
+ Column(
154
123
  modifier = Modifier
155
- .pressLift(interactionSource)
156
- .size(ITEM_SIZE)
157
- .tabBarMaterial(CircleShape)
158
- .clickable(interactionSource = interactionSource, indication = null, onClick = compression.expandTabBar)
124
+ .size(COMPACT_SIZE)
125
+ .tabBarContainer(CircleShape)
126
+ .noFeedbackClickable(onClick = compression.expandTabBar)
159
127
  .setAutomationId("bottom_tab_bar"),
160
- contentAlignment = Alignment.Center,
128
+ horizontalAlignment = Alignment.CenterHorizontally,
129
+ verticalArrangement = Arrangement.Center,
161
130
  ) {
162
- DuoTabIcon(current, selected = true, badgeMaxWidth = RAIL_BADGE_MAX_WIDTH, inRail = true)
131
+ TabIcon(current, AppTheme.current.colors.primary, vertical = true)
163
132
  }
164
133
  } else {
165
- Rail(items, selectedIndex, onTabLongPress, onTick) {
134
+ Rail(items, selectedIndex) {
166
135
  onTabSelected(it)
167
136
  compression.onTabSelected()
168
137
  }
169
138
  }
170
139
  if (floatingButton != null) {
171
- QrButton(floatingButton, size = ITEM_SIZE)
140
+ RailCenterAction(floatingButton)
172
141
  }
173
142
  }
174
143
  }
175
144
 
176
- // Column of icon-only tab items with the sliding selection lens.
145
+ // Column of rail items (.Nav/Duo/Item) with the sliding active indicator.
177
146
  @Composable
178
- private fun Rail(
179
- items: List<BottomTabItem>,
180
- selectedIndex: Int,
181
- onTabLongPress: ((Int) -> Unit)?,
182
- onTick: () -> Unit,
183
- onItemClick: (Int) -> Unit,
184
- ) {
185
- val selection = rememberDuoLiquidSelection(
186
- count = items.size,
187
- pitch = ITEM_SIZE + RAIL_GAP,
188
- firstCenter = RAIL_PADDING + ITEM_SIZE / 2,
189
- axis = LiquidAxis.Y,
190
- index = selectedIndex,
191
- onSelect = onItemClick,
192
- onTick = onTick,
193
- )
147
+ private fun Rail(items: List<BottomTabItem>, selectedIndex: Int, onItemClick: (Int) -> Unit) {
148
+ val density = LocalDensity.current
194
149
  Box(
195
150
  Modifier
196
- .then(selection.barTransform)
197
- .width(ITEM_SIZE)
198
- .tabBarMaterial(CircleShape)
151
+ .wrapContentWidth(unbounded = true)
152
+ .width(TabBarMetrics.railContainerWidth)
153
+ .tabBarContainer(RoundedCornerShape(Radius.XL))
154
+ .padding(horizontal = TabBarMetrics.railPaddingHorizontal)
155
+ .padding(bottom = TabBarMetrics.railPaddingBottom)
199
156
  .setAutomationId("bottom_tab_bar")
200
- .then(selection.dragGesture)
201
157
  ) {
202
- Box(
203
- Modifier
204
- .offset(
205
- x = (ITEM_SIZE - RAIL_BUBBLE_WIDTH) / 2,
206
- y = RAIL_PADDING - (RAIL_BUBBLE_HEIGHT - ITEM_SIZE) / 2,
207
- )
208
- .then(selection.bubbleTransform)
209
- .size(RAIL_BUBBLE_WIDTH, RAIL_BUBBLE_HEIGHT)
210
- .selectionTint()
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,
211
163
  )
212
- Column(
213
- modifier = Modifier.padding(vertical = RAIL_PADDING),
214
- verticalArrangement = Arrangement.spacedBy(RAIL_GAP),
215
- ) {
164
+ Column {
216
165
  items.forEachIndexed { index, item ->
217
- LiquidTab(
218
- selection = selection,
219
- index = index,
220
- onSelect = { onItemClick(index) },
221
- onLongPress = onTabLongPress?.let { { it(index) } },
222
- modifier = Modifier.size(ITEM_SIZE),
223
- ) { active ->
224
- DuoTabIcon(item, active, badgeMaxWidth = RAIL_BADGE_MAX_WIDTH, inRail = true)
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)
225
179
  }
226
180
  }
227
181
  }
228
182
  }
229
183
  }
230
184
 
231
- // Floating labelled bar for the unfolded portrait display, QR pinned in its own platter beside it.
232
- @Composable
233
- private fun BoxScope.DuoFloatingTabBar(
234
- layout: ScreenLayout,
235
- items: List<BottomTabItem>,
236
- floatingButton: BottomTabFloatingButton?,
237
- selectedIndex: Int,
238
- onTabSelected: (Int) -> Unit,
239
- onTabLongPress: ((Int) -> Unit)?,
240
- onTick: () -> Unit,
241
- ) {
242
- val density = LocalDensity.current
243
- var rowWidth by remember { mutableStateOf(0.dp) }
244
- val cellWidth = rowWidth / items.size.coerceAtLeast(1)
245
- val selection = rememberDuoLiquidSelection(
246
- count = items.size,
247
- pitch = cellWidth,
248
- firstCenter = cellWidth / 2,
249
- axis = LiquidAxis.X,
250
- index = selectedIndex,
251
- onSelect = onTabSelected,
252
- onTick = onTick,
253
- )
254
-
255
- Row(
256
- modifier = Modifier
257
- .align(Alignment.BottomCenter)
258
- .fillMaxWidth()
259
- .absolutePadding(
260
- left = layout.insetLeft + DuoMetrics.floatingTabBarMargin,
261
- right = layout.insetRight + DuoMetrics.floatingTabBarMargin,
262
- )
263
- .padding(bottom = floatingTabBarBottom(layout.insetBottom)),
264
- horizontalArrangement = Arrangement.spacedBy(Spacing.S, Alignment.CenterHorizontally),
265
- ) {
266
- Box(
267
- modifier = Modifier
268
- .weight(1f, fill = false)
269
- .width(FLOATING_ITEM_WIDTH * items.size + FLOATING_PADDING * 2)
270
- .height(FLOATING_HEIGHT)
271
- .then(selection.barTransform)
272
- .tabBarMaterial(RoundedCornerShape(FLOATING_HEIGHT / 2))
273
- .padding(FLOATING_PADDING)
274
- .setAutomationId("bottom_tab_bar")
275
- ) {
276
- Box(
277
- Modifier
278
- .fillMaxSize()
279
- .onSizeChanged { rowWidth = with(density) { it.width.toDp() } }
280
- .then(selection.dragGesture)
281
- ) {
282
- if (rowWidth > 0.dp) {
283
- Box(
284
- Modifier
285
- .then(selection.bubbleTransform)
286
- .width(cellWidth)
287
- .fillMaxHeight()
288
- .selectionTint()
289
- )
290
- }
291
- Row(Modifier.fillMaxSize()) {
292
- items.forEachIndexed { index, item ->
293
- LiquidTab(
294
- selection = selection,
295
- index = index,
296
- onSelect = { onTabSelected(index) },
297
- onLongPress = onTabLongPress?.let { { it(index) } },
298
- modifier = Modifier.weight(1f).fillMaxHeight(),
299
- ) { active ->
300
- FloatingCellContent(item, active, badgeMaxWidth = cellWidth / 2 - Spacing.XXS)
301
- }
302
- }
303
- }
304
- }
305
- }
306
- if (floatingButton != null) {
307
- QrButton(floatingButton, size = FLOATING_HEIGHT, Modifier.shadow(3.dp, CircleShape))
308
- }
309
- }
310
- }
311
-
312
- // A tab drawn twice, inactive with the active layer over it fading in as the lens passes; the tab
313
- // the lens lands on pops. A tap is the clickable's, a drag over the bar is the bar's.
185
+ // Center action of the rail: round button with its label, under the container.
314
186
  @Composable
315
- private fun LiquidTab(
316
- selection: DuoLiquidSelection,
317
- index: Int,
318
- onSelect: () -> Unit,
319
- onLongPress: (() -> Unit)?,
320
- modifier: Modifier = Modifier,
321
- content: @Composable (active: Boolean) -> Unit,
322
- ) {
323
- val interactionSource = remember { MutableInteractionSource() }
324
- val onLongClick = selection.rememberPressTracking(index, interactionSource, onSelect, onLongPress)
325
- val pop = selection.rememberIconPop(index)
326
- Box(
327
- modifier = modifier
328
- .combinedClickable(
329
- interactionSource = interactionSource,
330
- indication = null,
331
- role = Role.Tab,
332
- onLongClick = onLongClick,
333
- onClick = onSelect,
334
- )
335
- .graphicsLayer {
336
- scaleX = pop.value
337
- scaleY = pop.value
338
- },
339
- contentAlignment = Alignment.Center,
340
- ) {
341
- content(false)
342
- Box(
343
- Modifier
344
- .matchParentSize()
345
- .graphicsLayer { alpha = selection.activeAlpha(index) }
346
- .clearAndSetSemantics {},
347
- contentAlignment = Alignment.Center,
348
- ) {
349
- content(true)
350
- }
351
- }
352
- }
353
-
354
- @Composable
355
- private fun FloatingCellContent(item: BottomTabItem, active: Boolean, badgeMaxWidth: Dp) {
356
- val colors = AppTheme.current.colors
187
+ private fun RailCenterAction(data: BottomTabFloatingButton) {
188
+ val (interactionSource, pressed) = rememberCenterActionPress()
357
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),
358
195
  horizontalAlignment = Alignment.CenterHorizontally,
359
- verticalArrangement = Arrangement.spacedBy(Spacing.XXS),
196
+ verticalArrangement = Arrangement.spacedBy(TabBarMetrics.railCtaLabelGap, Alignment.CenterVertically),
360
197
  ) {
361
- DuoTabIcon(item, active, badgeMaxWidth)
362
- // like the system tab bar the label keeps its design size; Text grows it up to 5pt on the wide Duo displays
363
- val context = LocalContext.current
364
- val fixedScale = remember(context) {
365
- (context ?: MiniAppContext()).copy(userScaleRate = 1f, useOSScaleRate = false)
366
- }
367
- CompositionLocalProvider(LocalContext provides fixedScale) {
368
- Text(
369
- text = item.label,
370
- style = Typography.labelXsMedium,
371
- color = if (active) colors.primary else colors.text.hint,
372
- maxLines = 1,
373
- overflow = TextOverflow.Ellipsis,
374
- )
375
- }
376
- }
377
- }
378
-
379
- private fun Modifier.selectionTint(): Modifier = composed {
380
- background(AppTheme.current.colors.primary.copy(alpha = SELECTION_TINT_ALPHA), CircleShape)
381
- }
382
-
383
- // Floating bar: the badge starts at the icon's center and grows toward the cell's end edge.
384
- // Rail: the material clips to the capsule, so the badge ends just inside the rail and grows back
385
- // over the icon (RN TabBarIcon `end: -3`). Either way it never resizes the icon box.
386
- @Composable
387
- private fun DuoTabIcon(item: BottomTabItem, selected: Boolean, badgeMaxWidth: Dp, inRail: Boolean = false) {
388
- val colors = AppTheme.current.colors
389
- val badgeLabel = item.badgeLabel?.takeUnless { it.toIntOrNull() == 0 }
390
- Box {
391
- Icon(
392
- source = item.icon,
393
- size = ICON_SIZE,
394
- color = if (selected) colors.primary else colors.text.hint,
395
- )
396
- when {
397
- badgeLabel == null && !item.showDot -> Unit
398
- badgeLabel.isNullOrEmpty() -> BadgeDot(
399
- size = DotSize.Small,
400
- modifier = Modifier.align(Alignment.TopEnd),
401
- )
402
- else -> Badge(
403
- badgeLabel,
404
- modifier = Modifier
405
- .matchParentSize()
406
- .wrapContentSize(if (inRail) Alignment.TopEnd else Alignment.TopStart, unbounded = true)
407
- .offset(x = if (inRail) RAIL_BADGE_END_OFFSET else ICON_SIZE / 2, y = -Spacing.XS)
408
- .widthIn(max = badgeMaxWidth.coerceAtLeast(0.dp)),
409
- )
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)
410
200
  }
201
+ CenterActionLabel(data.label, data.labelContent, vertical = true, fixedFontScale = true)
411
202
  }
412
203
  }
413
-
414
- @Composable
415
- private fun QrButton(data: BottomTabFloatingButton, size: Dp, modifier: Modifier = Modifier) {
416
- Box(
417
- modifier = modifier
418
- .size(size)
419
- .clip(CircleShape)
420
- .background(AppTheme.current.colors.primary)
421
- .noFeedbackClickable(onClick = data.onPress)
422
- .setAutomationId(data.label),
423
- contentAlignment = Alignment.Center,
424
- ) {
425
- Icon(source = data.icon, color = Color.White, size = QR_ICON_SIZE)
426
- }
427
- }
428
-
429
- // RN BarMaterial: surface with a 1dp border.
430
- @Composable
431
- private fun Modifier.tabBarMaterial(shape: Shape): Modifier {
432
- val colors = AppTheme.current.colors
433
- return shadow(3.dp, shape)
434
- .background(colors.background.surface)
435
- .border(1.dp, colors.border.default, shape)
436
- }
@@ -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
@@ -29,6 +29,7 @@ internal fun ComposeLottieAnimation(
29
29
  isPlaying: Boolean,
30
30
  onEvent: ((String) -> Unit)?,
31
31
  modifier: Modifier,
32
+ progress: (() -> Float)? = null,
32
33
  ) {
33
34
  val json = readJson(path)
34
35
 
@@ -55,7 +56,7 @@ internal fun ComposeLottieAnimation(
55
56
  val lottieState = animateLottieCompositionAsState(
56
57
  composition = composition,
57
58
  iterations = iterations,
58
- isPlaying = isPlaying,
59
+ isPlaying = isPlaying && progress == null,
59
60
  restartOnPlay = false,
60
61
  )
61
62
 
@@ -77,7 +78,7 @@ internal fun ComposeLottieAnimation(
77
78
  Image(
78
79
  painter = rememberLottiePainter(
79
80
  composition = composition,
80
- progress = lottieState::value,
81
+ progress = progress ?: lottieState::value,
81
82
  dynamicProperties = dynamicProperties,
82
83
  enableExpressions = false,
83
84
  expressionEngineFactory = { _, _ ->
@@ -66,7 +66,9 @@ expect fun LottieAnimation(
66
66
  isPlaying: Boolean = true,
67
67
  onEvent: ((String) -> Unit)? = null,
68
68
  modifier: Modifier = Modifier,
69
- useCompose: Boolean = false
69
+ useCompose: Boolean = false,
70
+ // drives the animation instead of playing it, so several animations stay in sync; needs useCompose
71
+ progress: (() -> Float)? = null,
70
72
  )
71
73
 
72
74
  expect fun NativePaint.setColor(