@momo-kits/native-kits 0.168.1-beta.4-debug → 0.168.1-beta.40-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 (100) hide show
  1. package/CLAUDE.md +15 -10
  2. package/README.md +2 -10
  3. package/build.gradle.kts +1 -3
  4. package/compose/build.gradle.kts +20 -19
  5. package/compose/build.gradle.kts.backup +19 -18
  6. package/compose/compose.podspec +1 -1
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +4 -3
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +1 -1
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -14
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +62 -0
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +14 -23
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +21 -15
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +84 -82
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -3
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -1
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +18 -14
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +187 -0
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +20 -13
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +117 -62
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +22 -6
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +4 -7
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +16 -26
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +54 -36
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +18 -11
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +1 -6
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +35 -29
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +321 -149
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +79 -71
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +2 -3
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +89 -198
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +104 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +1 -1
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +3 -1
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +30 -44
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +2 -2
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +32 -40
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +3 -2
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +12 -3
  43. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +3 -1
  44. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +2 -6
  45. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +12 -10
  46. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  47. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +60 -10
  48. package/gradle/libs.versions.toml +4 -11
  49. package/gradle/wrapper/gradle-wrapper.properties +1 -3
  50. package/gradle.properties +3 -3
  51. package/ios/Application/ApplicationEnvironment.swift +7 -6
  52. package/ios/Application/DesignSystemKits.swift +163 -0
  53. package/ios/Application/DesignSystemKitsPayload.swift +68 -0
  54. package/ios/Badge/BadgeRibbon.swift +8 -1
  55. package/ios/Extensions/Color++.swift +2 -4
  56. package/ios/Input/Input.swift +16 -4
  57. package/ios/Input/InputPhoneNumber.swift +1 -3
  58. package/ios/Input/InputSearch.swift +1 -2
  59. package/ios/Input/InputTextArea.swift +8 -4
  60. package/ios/InputMoney/InputMoney.swift +6 -7
  61. package/ios/Layout/ModalLayout.swift +152 -0
  62. package/ios/Layout/ScreenLayout.swift +77 -18
  63. package/ios/Navigation/BottomSheet.swift +56 -53
  64. package/ios/Navigation/BottomTab/BottomTab.swift +46 -52
  65. package/ios/Navigation/BottomTab/BottomTabBar.swift +281 -115
  66. package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
  67. package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
  68. package/ios/Navigation/BottomTab/DuoTabBar.swift +64 -172
  69. package/ios/Navigation/BottomTab/TabBarMetrics.swift +84 -0
  70. package/ios/Navigation/Component/HeaderBackground.swift +22 -1
  71. package/ios/Navigation/Component/HeaderRight.swift +1 -1
  72. package/ios/Navigation/Component/SnackBar.swift +4 -0
  73. package/ios/Navigation/ModalScreen.swift +20 -5
  74. package/ios/Navigation/StackScreen.swift +6 -8
  75. package/ios/Popup/PopupDisplay.swift +6 -4
  76. package/ios/Popup/PopupInput.swift +6 -4
  77. package/ios/Popup/PopupLayout.swift +17 -11
  78. package/ios/Popup/PopupNotify.swift +32 -25
  79. package/ios/Stepper/Stepper.swift +1 -2
  80. package/ios/Template/TrustBanner/TrustBanner.swift +4 -2
  81. package/ios/Typography/FontScale.swift +29 -15
  82. package/ios/Typography/Text.swift +88 -14
  83. package/ios/Typography/Typography.swift +2 -2
  84. package/ios/native-kits.podspec +1 -1
  85. package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
  86. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  87. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  88. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +272 -59
  89. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +103 -0
  90. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
  91. package/package.json +1 -1
  92. package/publish.sh +2 -33
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +0 -37
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +0 -41
  97. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +0 -44
  98. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +0 -62
  99. package/ios/Typography/FontScaleStore.swift +0 -58
  100. package/ios/Typography/KitDesignSystem.swift +0 -17
@@ -1,86 +1,94 @@
1
1
  package vn.momo.kits.navigation.bottomtab
2
2
 
3
- import androidx.compose.foundation.Canvas
4
- import androidx.compose.foundation.layout.Box
5
- import androidx.compose.foundation.layout.height
6
- import androidx.compose.foundation.layout.offset
7
- import androidx.compose.foundation.layout.width
8
- import androidx.compose.runtime.Composable
9
- import androidx.compose.ui.Alignment
10
3
  import androidx.compose.ui.Modifier
4
+ import androidx.compose.ui.draw.dropShadow
5
+ import androidx.compose.ui.geometry.Rect
6
+ import androidx.compose.ui.geometry.RoundRect
7
+ import androidx.compose.ui.geometry.Size
8
+ import androidx.compose.ui.geometry.CornerRadius
9
+ import androidx.compose.ui.geometry.Offset
10
+ import androidx.compose.ui.graphics.addOutline
11
+ import androidx.compose.ui.graphics.Color
12
+ import androidx.compose.ui.graphics.Outline
11
13
  import androidx.compose.ui.graphics.Path
12
- import androidx.compose.ui.platform.LocalDensity
14
+ import androidx.compose.ui.graphics.Shape
15
+ import androidx.compose.ui.graphics.shadow.Shadow
16
+ import androidx.compose.ui.unit.Density
13
17
  import androidx.compose.ui.unit.Dp
14
- import androidx.compose.ui.unit.IntOffset
18
+ import androidx.compose.ui.unit.DpOffset
19
+ import androidx.compose.ui.unit.LayoutDirection
15
20
  import androidx.compose.ui.unit.dp
16
- import androidx.compose.ui.zIndex
21
+ import androidx.compose.foundation.background
22
+ import androidx.compose.runtime.Composable
17
23
  import vn.momo.kits.const.AppTheme
18
24
 
19
- @Composable
20
- internal fun CurvedContainer(
21
- circleSize: Dp = 48.dp,
22
- tabBarItemIconSize: Dp = 28.dp,
23
- circleOverSize: Dp = 2.dp,
24
- width: Dp = 71.dp,
25
- height: Dp = 16.dp
26
- ) {
27
- val theme = AppTheme.current
28
- val density = LocalDensity.current
29
- val widthPx = with(density) { width.toPx()}
30
-
31
- val circleSizePx = with(density) { circleSize.toPx() }
32
- val tabBarItemIconSizePx = with(density) { tabBarItemIconSize.toPx() }
33
- val circleOverSizePx = with(density) { circleOverSize.toPx() }
34
-
35
- val circlePositionTop = circleSizePx - tabBarItemIconSizePx - 10f
36
- val circleOverTop = circlePositionTop + circleOverSizePx
37
- val circleR = circleSizePx / 2
38
- val circleOverR = circleR + circleOverSizePx
39
-
40
- val centerX = widthPx / 2
41
-
42
- val curvedPath = getPath(
43
- circleOverTop = circleOverTop,
44
- centerX = centerX,
45
- circleOverR = circleOverR,
46
- widthPx = widthPx
47
- )
48
-
49
- Box(
50
- contentAlignment = Alignment.BottomCenter
51
- ){
52
- Canvas(
53
- modifier = Modifier
54
- .width(width)
55
- .height(height)
56
- .offset{ IntOffset(x = 0, y = 24) }
57
- .zIndex(-1f)
58
- ) {
59
- drawPath(path = curvedPath, color = theme.colors.background.surface)
25
+ // Rounded container, with the notch dipped into the top edge around `notchCenterX` (from the left).
26
+ internal class NotchedBarShape(
27
+ private val radius: Dp,
28
+ private val notchCenterX: Dp? = null,
29
+ ) : Shape {
30
+ override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
31
+ val r = minOf(with(density) { radius.toPx() }, size.height / 2, size.width / 2)
32
+ val path = Path()
33
+ if (notchCenterX == null) {
34
+ path.addRoundRect(RoundRect(Rect(0f, 0f, size.width, size.height), CornerRadius(r)))
35
+ return Outline.Generic(path)
60
36
  }
37
+ val cx = with(density) { notchCenterX.toPx() }
38
+ val unit = density.density
39
+ path.apply {
40
+ moveTo(r, 0f)
41
+ lineTo(cx - NOTCH_HALF_WIDTH * unit, 0f)
42
+ NOTCH_CURVES.forEach { (c1, c2, end) ->
43
+ cubicTo(
44
+ cx + c1.first * unit, c1.second * unit,
45
+ cx + c2.first * unit, c2.second * unit,
46
+ cx + end.first * unit, end.second * unit,
47
+ )
48
+ }
49
+ lineTo(size.width - r, 0f)
50
+ arcTo(Rect(size.width - 2 * r, 0f, size.width, 2 * r), -90f, 90f, false)
51
+ lineTo(size.width, size.height - r)
52
+ arcTo(Rect(size.width - 2 * r, size.height - 2 * r, size.width, size.height), 0f, 90f, false)
53
+ lineTo(r, size.height)
54
+ arcTo(Rect(0f, size.height - 2 * r, 2 * r, size.height), 90f, 90f, false)
55
+ lineTo(0f, r)
56
+ arcTo(Rect(0f, 0f, 2 * r, 2 * r), 180f, 90f, false)
57
+ close()
58
+ }
59
+ return Outline.Generic(path)
61
60
  }
62
61
  }
63
62
 
64
- private fun getPath(circleOverTop: Float, centerX: Float, circleOverR: Float, widthPx: Float): Path{
65
- return Path().apply {
66
- moveTo(0f, circleOverTop)
67
- lineTo(centerX - circleOverR - 40f, circleOverTop)
63
+ // The shape shrunk by `inset` on every side. A shadow cast from it with no spread is a shadow of the
64
+ // shape with spread -inset; dropShadow's own negative spread clips the blur of path outlines.
65
+ internal class InsetShape(private val shape: Shape, private val inset: Dp) : Shape {
66
+ override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
67
+ val insetPx = with(density) { inset.toPx() }
68
+ val inner = Size((size.width - 2 * insetPx).coerceAtLeast(0f), (size.height - 2 * insetPx).coerceAtLeast(0f))
69
+ val path = Path().apply {
70
+ addOutline(shape.createOutline(inner, layoutDirection, density))
71
+ translate(Offset(insetPx, insetPx))
72
+ }
73
+ return Outline.Generic(path)
74
+ }
75
+ }
68
76
 
69
- cubicTo(
70
- centerX - circleOverR, circleOverTop,
71
- centerX - circleOverR, 0f,
72
- centerX, 0f
73
- )
77
+ // Shadow with a negative spread, cast from the shrunk shape.
78
+ internal fun Modifier.spreadShadow(shape: Shape, shadow: Shadow): Modifier =
79
+ if (shadow.spread < 0.dp) dropShadow(
80
+ InsetShape(shape, -shadow.spread),
81
+ Shadow(radius = shadow.radius, color = shadow.color, offset = shadow.offset, alpha = shadow.alpha),
82
+ )
83
+ else dropShadow(shape, shadow)
74
84
 
75
- cubicTo(
76
- centerX + circleOverR, 0f,
77
- centerX + circleOverR, circleOverTop,
78
- centerX + circleOverR + 40f, circleOverTop
85
+ // Navigation bar container: surface fill with the floating shadow following the shape (Figma
86
+ // Shadow/floating: 12% blur 24, 4% y12 blur 32 spread -16).
87
+ @Composable
88
+ internal fun Modifier.tabBarContainer(shape: Shape): Modifier =
89
+ dropShadow(shape, Shadow(radius = 24.dp, color = Color.Black, alpha = 0.12f))
90
+ .spreadShadow(
91
+ shape,
92
+ Shadow(radius = 32.dp, spread = (-16).dp, color = Color.Black, alpha = 0.04f, offset = DpOffset(0.dp, 12.dp)),
79
93
  )
80
-
81
- lineTo(widthPx, circleOverTop)
82
- lineTo(widthPx, 60f)
83
- lineTo(0f, 60f)
84
- close()
85
- }
86
- }
94
+ .background(AppTheme.current.colors.background.surface, shape)
@@ -39,8 +39,6 @@ internal val DUO_GROUP_GAP = Spacing.M
39
39
  private val DEFAULT_TOOLBAR_HEIGHT = DuoMetrics.controlSize + Spacing.M + DuoMetrics.itemPitch * 2
40
40
  // Back, then the single button the toolbar folds into
41
41
  private val COMPRESSED_TOOLBAR_HEIGHT = DuoMetrics.controlSize * 2 + Spacing.M
42
- // Back alone, while a rail opened from the compressed state takes the toolbar slot
43
- private val BACK_ONLY_HEIGHT = DuoMetrics.controlSize
44
42
 
45
43
  // Port of RN DuoBarCompression (HIG, Designing for iPhone Duo: Vertical controls):
46
44
  // - both fit: both stay whole
@@ -78,7 +76,8 @@ internal fun rememberDuoBarCompression(
78
76
  expandTabBar = { expanded = DuoBar.TAB_BAR },
79
77
  setToolbarHeight = setToolbarHeight,
80
78
  )
81
- opened == DuoBar.TAB_BAR && fits(BACK_ONLY_HEIGHT, tabBar) -> DuoBarCompression(
79
+ // an opened rail always shows, even when only the group gap is short: it closes once a tab is picked
80
+ opened == DuoBar.TAB_BAR -> DuoBarCompression(
82
81
  toolbarCompressed = true,
83
82
  toolbarHidden = true,
84
83
  expandToolbar = { opened = DuoBar.TOOLBAR },
@@ -1,88 +1,68 @@
1
1
  package vn.momo.kits.navigation.bottomtab
2
2
 
3
- import androidx.compose.animation.core.Spring
4
- import androidx.compose.animation.core.animateDpAsState
5
- import androidx.compose.animation.core.spring
6
- import androidx.compose.foundation.background
7
- import androidx.compose.foundation.border
3
+ import androidx.compose.foundation.clickable
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
- import androidx.compose.foundation.layout.BoxWithConstraints
12
7
  import androidx.compose.foundation.layout.Column
13
- import androidx.compose.foundation.layout.Row
14
- import androidx.compose.foundation.layout.RowScope
15
- import androidx.compose.foundation.layout.absolutePadding
16
- import androidx.compose.foundation.layout.fillMaxHeight
17
- import androidx.compose.foundation.layout.fillMaxSize
18
8
  import androidx.compose.foundation.layout.height
19
9
  import androidx.compose.foundation.layout.offset
20
10
  import androidx.compose.foundation.layout.padding
21
11
  import androidx.compose.foundation.layout.size
22
12
  import androidx.compose.foundation.layout.width
13
+ import androidx.compose.foundation.layout.absolutePadding
14
+ import androidx.compose.foundation.layout.wrapContentWidth
23
15
  import androidx.compose.foundation.shape.CircleShape
24
16
  import androidx.compose.foundation.shape.RoundedCornerShape
25
17
  import androidx.compose.runtime.Composable
26
18
  import androidx.compose.runtime.compositionLocalOf
27
- import androidx.compose.runtime.getValue
28
19
  import androidx.compose.ui.AbsoluteAlignment
29
20
  import androidx.compose.ui.Alignment
30
21
  import androidx.compose.ui.Modifier
31
- import androidx.compose.ui.draw.clip
32
- import androidx.compose.ui.draw.shadow
33
22
  import androidx.compose.ui.graphics.Color
34
- import androidx.compose.ui.graphics.Shape
35
- import androidx.compose.ui.text.style.TextOverflow
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
36
30
  import androidx.compose.ui.unit.Dp
37
31
  import androidx.compose.ui.unit.dp
38
- import vn.momo.kits.components.Badge
39
- import vn.momo.kits.components.BadgeDot
40
- import vn.momo.kits.components.DotSize
41
32
  import vn.momo.kits.components.Icon
42
- import vn.momo.kits.components.Text
43
33
  import vn.momo.kits.const.AppTheme
34
+ import vn.momo.kits.const.Colors
44
35
  import vn.momo.kits.const.Radius
45
36
  import vn.momo.kits.const.Spacing
46
- import vn.momo.kits.const.Typography
47
37
  import vn.momo.kits.layout.DuoMetrics
48
38
  import vn.momo.kits.layout.ScreenLayout
49
39
  import vn.momo.kits.layout.SideBarEdge
50
40
  import vn.momo.kits.modifier.noFeedbackClickable
51
41
  import vn.momo.kits.modifier.setAutomationId
52
42
 
53
- // Figma Fold-Design-System MT1/MT2, mirrored from RN DuoTabBar.tsx.
54
- private val ITEM_SIZE = DuoMetrics.controlSize
55
- private val ICON_SIZE = 28.dp
56
- private val QR_ICON_SIZE = 24.dp
57
- private val RAIL_PADDING = 6.dp
58
- private val RAIL_GAP = Spacing.XXS
59
- // selection bubble overflows the 48 rail cell by 5 above and below
60
- private val RAIL_BUBBLE_WIDTH = 44.dp
61
- private val RAIL_BUBBLE_HEIGHT = 58.dp
62
- private val FLOATING_HEIGHT = 62.dp
63
- private val FLOATING_PADDING = Spacing.XS
64
- private val FLOATING_QR_SIZE = 44.dp
65
- // floating bar spans 6 of the 8 portrait grid columns, like the content
66
- private const val GRID_COLUMNS = 8
67
- private const val GRID_SPAN = 6
68
- // RN reanimated spring { damping: 18, stiffness: 220, mass: 0.8 }
69
- private val BUBBLE_SPRING = spring<Dp>(dampingRatio = 0.68f, stiffness = 275f, visibilityThreshold = Dp(0.5f))
43
+ // Figma "Specs Navigation" (DS-984) Vertical type, mirrored from RN DuoTabBar.tsx.
44
+ private val COMPACT_SIZE = DuoMetrics.controlSize
70
45
 
71
46
  // Space from the window bottom the rail stack and its gap take, so the header side bar stays above it.
72
47
  internal val LocalDuoRailReserve = compositionLocalOf { 0.dp }
73
48
 
74
- // 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.
75
50
  internal fun duoRailHeight(itemCount: Int, hasQr: Boolean, compressed: Boolean = false): Dp {
76
- val rail = if (compressed) ITEM_SIZE
77
- else RAIL_PADDING * 2 + ITEM_SIZE * itemCount + RAIL_GAP * (itemCount - 1).coerceAtLeast(0)
78
- 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
79
54
  }
80
55
 
81
- // Space tab content leaves under the floating bar; 0 when the rail sits in the side strip or off Duo.
82
- internal fun duoFloatingTabBarInset(layout: ScreenLayout): Dp =
83
- if (layout.isIPhoneDuo && layout.sideBar == null) FLOATING_HEIGHT + Spacing.M + layout.insetBottom else 0.dp
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 }
84
64
 
85
- // iPhone Duo tab bar: glass rail in the side bar, or a floating glass bar when unfolded portrait.
65
+ // iPhone Duo tab bar: rail in the side bar, or the horizontal bar when unfolded portrait.
86
66
  @Composable
87
67
  internal fun BoxScope.DuoTabBar(
88
68
  layout: ScreenLayout,
@@ -95,13 +75,23 @@ internal fun BoxScope.DuoTabBar(
95
75
  if (layout.sideBar != null) {
96
76
  DuoRailTabBar(layout, items, floatingButton, selectedIndex, onTabSelected, compression)
97
77
  } else {
98
- DuoFloatingTabBar(layout, items, floatingButton, selectedIndex, onTabSelected)
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
+ )
99
89
  }
100
90
  }
101
91
 
102
- // Vertical bar anchored to the bottom of the side bar, QR button below it (Figma MT1-C/E). When the
103
- // side bar is short it can shrink to one button showing the current tab (HIG "Tab bar compressed");
104
- // 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.
105
95
  @Composable
106
96
  private fun BoxScope.DuoRailTabBar(
107
97
  layout: ScreenLayout,
@@ -114,26 +104,31 @@ private fun BoxScope.DuoRailTabBar(
114
104
  val sideBar = layout.sideBar ?: return
115
105
  val isRight = sideBar.edge == SideBarEdge.RIGHT
116
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
117
109
  Column(
118
110
  modifier = Modifier
119
111
  .align(if (isRight) AbsoluteAlignment.BottomRight else AbsoluteAlignment.BottomLeft)
120
112
  .width(sideBar.width)
121
113
  .padding(bottom = sideBar.bottom)
122
- .absolutePadding(left = if (isRight) Spacing.M else 0.dp, right = if (isRight) 0.dp else Spacing.M),
123
- horizontalAlignment = if (isRight) AbsoluteAlignment.Left else AbsoluteAlignment.Right,
124
- 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),
125
119
  ) {
126
120
  val current = items.getOrNull(selectedIndex)
127
121
  if (compression.tabBarCompressed && current != null) {
128
- Box(
122
+ Column(
129
123
  modifier = Modifier
130
- .size(ITEM_SIZE)
131
- .tabBarMaterial(CircleShape)
124
+ .size(COMPACT_SIZE)
125
+ .tabBarContainer(CircleShape)
132
126
  .noFeedbackClickable(onClick = compression.expandTabBar)
133
127
  .setAutomationId("bottom_tab_bar"),
134
- contentAlignment = Alignment.Center,
128
+ horizontalAlignment = Alignment.CenterHorizontally,
129
+ verticalArrangement = Arrangement.Center,
135
130
  ) {
136
- DuoTabIcon(current, selected = true)
131
+ TabIcon(current, AppTheme.current.colors.primary, vertical = true)
137
132
  }
138
133
  } else {
139
134
  Rail(items, selectedIndex) {
@@ -142,171 +137,67 @@ private fun BoxScope.DuoRailTabBar(
142
137
  }
143
138
  }
144
139
  if (floatingButton != null) {
145
- QrButton(floatingButton, size = ITEM_SIZE)
140
+ RailCenterAction(floatingButton)
146
141
  }
147
142
  }
148
143
  }
149
144
 
150
- // Glass column of tab items with the sliding selection bubble.
145
+ // Column of rail items (.Nav/Duo/Item) with the sliding active indicator.
151
146
  @Composable
152
147
  private fun Rail(items: List<BottomTabItem>, selectedIndex: Int, onItemClick: (Int) -> Unit) {
153
- val bubbleOffset by animateDpAsState(
154
- targetValue = (ITEM_SIZE + RAIL_GAP) * selectedIndex.coerceAtLeast(0),
155
- animationSpec = BUBBLE_SPRING,
156
- label = "DuoRailBubble",
157
- )
148
+ val density = LocalDensity.current
158
149
  Box(
159
150
  Modifier
160
- .width(ITEM_SIZE)
161
- .tabBarMaterial(RoundedCornerShape(Radius.XL))
151
+ .wrapContentWidth(unbounded = true)
152
+ .width(TabBarMetrics.railContainerWidth)
153
+ .tabBarContainer(RoundedCornerShape(Radius.XL))
154
+ .padding(horizontal = TabBarMetrics.railPaddingHorizontal)
155
+ .padding(bottom = TabBarMetrics.railPaddingBottom)
162
156
  .setAutomationId("bottom_tab_bar")
163
157
  ) {
164
- Box(
165
- Modifier
166
- .offset(
167
- x = (ITEM_SIZE - RAIL_BUBBLE_WIDTH) / 2,
168
- y = RAIL_PADDING - (RAIL_BUBBLE_HEIGHT - ITEM_SIZE) / 2 + bubbleOffset,
169
- )
170
- .size(RAIL_BUBBLE_WIDTH, RAIL_BUBBLE_HEIGHT)
171
- .background(AppTheme.current.colors.background.selected, CircleShape)
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,
172
163
  )
173
- Column(
174
- modifier = Modifier.padding(vertical = RAIL_PADDING),
175
- verticalArrangement = Arrangement.spacedBy(RAIL_GAP),
176
- ) {
164
+ Column {
177
165
  items.forEachIndexed { index, item ->
178
- Box(
166
+ Column(
179
167
  modifier = Modifier
180
- .size(ITEM_SIZE)
181
- .noFeedbackClickable { onItemClick(index) },
182
- contentAlignment = Alignment.Center,
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,
183
177
  ) {
184
- DuoTabIcon(item, selected = index == selectedIndex)
178
+ TabItemContent(item, selected = index == selectedIndex, vertical = true, fixedFontScale = true)
185
179
  }
186
180
  }
187
181
  }
188
182
  }
189
183
  }
190
184
 
185
+ // Center action of the rail: round button with its label, under the container.
191
186
  @Composable
192
- private fun BoxScope.DuoFloatingTabBar(
193
- layout: ScreenLayout,
194
- items: List<BottomTabItem>,
195
- floatingButton: BottomTabFloatingButton?,
196
- selectedIndex: Int,
197
- onTabSelected: (Int) -> Unit,
198
- ) {
199
- val columnWidth = (layout.width - Spacing.M * 2 - Spacing.M * (GRID_COLUMNS - 1)) / GRID_COLUMNS
200
- val barWidth = columnWidth * GRID_SPAN + Spacing.M * (GRID_SPAN - 1)
201
- val useQr = floatingButton != null && items.size % 2 == 0
202
- val middle = items.size / 2
203
- val cellCount = items.size + if (useQr) 1 else 0
204
- val visualIndex = if (useQr && selectedIndex >= middle) selectedIndex + 1 else selectedIndex
205
-
206
- Box(
207
- modifier = Modifier
208
- .align(Alignment.BottomCenter)
209
- .padding(bottom = layout.insetBottom + Spacing.M)
210
- .width(barWidth)
211
- .height(FLOATING_HEIGHT)
212
- .tabBarMaterial(RoundedCornerShape(FLOATING_HEIGHT / 2))
213
- .padding(FLOATING_PADDING)
214
- .setAutomationId("bottom_tab_bar")
215
- ) {
216
- BoxWithConstraints(Modifier.fillMaxSize()) {
217
- val cellWidth = maxWidth / cellCount
218
- val bubbleOffset by animateDpAsState(
219
- targetValue = cellWidth * visualIndex.coerceAtLeast(0),
220
- animationSpec = BUBBLE_SPRING,
221
- label = "DuoFloatingBubble",
222
- )
223
- Box(
224
- Modifier
225
- .offset(x = bubbleOffset)
226
- .width(cellWidth)
227
- .fillMaxHeight()
228
- .background(AppTheme.current.colors.background.selected, CircleShape)
229
- )
230
- Row(Modifier.fillMaxSize()) {
231
- items.forEachIndexed { index, item ->
232
- if (useQr && index == middle) {
233
- Box(Modifier.weight(1f).fillMaxHeight(), contentAlignment = Alignment.Center) {
234
- QrButton(floatingButton, size = FLOATING_QR_SIZE)
235
- }
236
- }
237
- FloatingCell(item, selected = index == selectedIndex) { onTabSelected(index) }
238
- }
239
- }
240
- }
241
- }
242
- }
243
-
244
- @Composable
245
- private fun RowScope.FloatingCell(item: BottomTabItem, selected: Boolean, onClick: () -> Unit) {
246
- val colors = AppTheme.current.colors
187
+ private fun RailCenterAction(data: BottomTabFloatingButton) {
188
+ val (interactionSource, pressed) = rememberCenterActionPress()
247
189
  Column(
248
190
  modifier = Modifier
249
- .weight(1f)
250
- .fillMaxHeight()
251
- .noFeedbackClickable(onClick = onClick),
191
+ .wrapContentWidth(unbounded = true)
192
+ .size(TabBarMetrics.railCtaWidth, TabBarMetrics.railCtaHeight)
193
+ .clickable(interactionSource = interactionSource, indication = null, onClick = data.onPress)
194
+ .setAutomationId(data.label),
252
195
  horizontalAlignment = Alignment.CenterHorizontally,
253
- verticalArrangement = Arrangement.spacedBy(Spacing.XXS, Alignment.CenterVertically),
196
+ verticalArrangement = Arrangement.spacedBy(TabBarMetrics.railCtaLabelGap, Alignment.CenterVertically),
254
197
  ) {
255
- DuoTabIcon(item, selected)
256
- Text(
257
- text = item.label,
258
- style = Typography.labelXsMedium,
259
- color = if (selected) colors.primary else colors.text.default,
260
- maxLines = 1,
261
- overflow = TextOverflow.Ellipsis,
262
- )
263
- }
264
- }
265
-
266
- @Composable
267
- private fun DuoTabIcon(item: BottomTabItem, selected: Boolean) {
268
- val colors = AppTheme.current.colors
269
- val badgeLabel = item.badgeLabel?.takeUnless { it.toIntOrNull() == 0 }
270
- Box {
271
- Icon(
272
- source = item.icon,
273
- size = ICON_SIZE,
274
- color = if (selected) colors.primary else colors.text.default,
275
- )
276
- when {
277
- badgeLabel == null && !item.showDot -> Unit
278
- badgeLabel.isNullOrEmpty() -> BadgeDot(
279
- size = DotSize.Small,
280
- modifier = Modifier.align(Alignment.TopEnd),
281
- )
282
- else -> Badge(
283
- badgeLabel,
284
- modifier = Modifier.align(Alignment.TopStart).offset(x = ICON_SIZE / 2, y = -Spacing.XS),
285
- )
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)
286
200
  }
201
+ CenterActionLabel(data.label, data.labelContent, vertical = true, fixedFontScale = true)
287
202
  }
288
203
  }
289
-
290
- @Composable
291
- private fun QrButton(data: BottomTabFloatingButton, size: Dp) {
292
- Box(
293
- modifier = Modifier
294
- .size(size)
295
- .clip(CircleShape)
296
- .background(AppTheme.current.colors.primary)
297
- .noFeedbackClickable(onClick = data.onPress)
298
- .setAutomationId(data.label),
299
- contentAlignment = Alignment.Center,
300
- ) {
301
- Icon(source = data.icon, color = Color.White, size = QR_ICON_SIZE)
302
- }
303
- }
304
-
305
- // RN falls back to this when native glass is missing; Compose has no backdrop blur, so it always does.
306
- @Composable
307
- private fun Modifier.tabBarMaterial(shape: Shape): Modifier {
308
- val colors = AppTheme.current.colors
309
- return shadow(3.dp, shape)
310
- .background(colors.background.surface)
311
- .border(1.dp, colors.border.default, shape)
312
- }