@momo-kits/native-kits 0.300.7-debug → 0.300.8-beta.1-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 (202) hide show
  1. package/CLAUDE.md +12 -8
  2. package/README.md +8 -7
  3. package/compose/build.gradle.kts +2 -4
  4. package/compose/build.gradle.kts.backup +1 -3
  5. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +1 -2
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +1 -1
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +2 -3
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsBinding.kt +60 -0
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsHost.kt +32 -0
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +20 -24
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +5 -6
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +7 -17
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +18 -18
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +2 -2
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +15 -18
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +4 -2
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +13 -73
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +1 -1
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +1 -8
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -53
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +3 -8
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +2 -3
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +12 -15
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +11 -9
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +17 -12
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +20 -5
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +3 -5
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +7 -8
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +1 -2
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -2
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +1 -2
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +83 -82
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -3
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +6 -10
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +9 -9
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -2
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +13 -35
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +2 -4
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +5 -22
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -2
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -3
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +6 -24
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +55 -5
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +1 -7
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +3 -6
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +1 -1
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +22 -50
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -7
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +11 -7
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +18 -9
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +5 -3
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +123 -64
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +24 -8
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +11 -9
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +16 -19
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +59 -41
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +69 -51
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +14 -10
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +5 -10
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +43 -32
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +330 -149
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +87 -70
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +1 -5
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +92 -261
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -2
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +31 -40
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +3 -1
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +46 -72
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +8 -12
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +29 -24
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +8 -11
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +9 -9
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +26 -3
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +1 -3
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +4 -3
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +2 -3
  84. package/compose/src/commonTest/kotlin/vn/momo/kits/application/KitsHostTest.kt +44 -0
  85. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +2 -7
  86. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +9 -18
  87. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +1 -1
  88. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +3 -6
  89. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +5 -6
  90. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +12 -12
  91. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
  92. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +11 -6
  93. package/gradle/libs.versions.toml +1 -3
  94. package/gradle.properties +1 -3
  95. package/ios/Application/ApplicationEnvironment.swift +6 -4
  96. package/ios/Application/DesignSystemKits.swift +59 -13
  97. package/ios/Application/DesignSystemKitsPayload.swift +0 -8
  98. package/ios/Application/LanguageSource.swift +2 -11
  99. package/ios/Application/Localize.swift +8 -35
  100. package/ios/Application/LocalizeModifier.swift +2 -11
  101. package/ios/Application/MaxApi.swift +3 -11
  102. package/ios/Avatar/Avatar.swift +0 -1
  103. package/ios/Badge/Badge.swift +5 -8
  104. package/ios/Badge/BadgeRibbon.swift +2 -5
  105. package/ios/Button/Button.swift +4 -8
  106. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +5 -7
  107. package/ios/Carousel/Carousel.swift +4 -17
  108. package/ios/Checkbox/Checkbox.swift +0 -2
  109. package/ios/Collapse/Collapse.swift +17 -11
  110. package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
  111. package/ios/DateTimePicker/DateTimePicker.swift +4 -10
  112. package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
  113. package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
  114. package/ios/DateTimePicker/WheelPicker.swift +2 -4
  115. package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
  116. package/ios/Extensions/Color++.swift +2 -4
  117. package/ios/Extensions/SkeletonUICompat.swift +0 -8
  118. package/ios/Icon/Icon.swift +3 -6
  119. package/ios/IconButton/IconButton.swift +2 -5
  120. package/ios/Input/ErrorView.swift +0 -7
  121. package/ios/Input/Input.swift +9 -20
  122. package/ios/Input/InputPhoneNumber.swift +37 -20
  123. package/ios/Input/InputSearch.swift +23 -12
  124. package/ios/Input/InputTextArea.swift +4 -13
  125. package/ios/InputDropDown/InputDropDown.swift +1 -11
  126. package/ios/InputMoney/InputMoney.swift +9 -28
  127. package/ios/InputOTP/InputOTP.swift +2 -9
  128. package/ios/Layout/HeaderLayout.swift +72 -0
  129. package/ios/Layout/Item.swift +1 -2
  130. package/ios/Layout/ModalLayout.swift +144 -0
  131. package/ios/Layout/ScreenLayout.swift +48 -31
  132. package/ios/Layout/Section.swift +2 -3
  133. package/ios/Loader/Loader.swift +3 -12
  134. package/ios/Lottie/LottieView.swift +0 -11
  135. package/ios/Navigation/BottomSheet.swift +73 -94
  136. package/ios/Navigation/BottomTab/BottomTab.swift +58 -73
  137. package/ios/Navigation/BottomTab/BottomTabBar.swift +286 -121
  138. package/ios/Navigation/BottomTab/CurvedContainer.swift +52 -54
  139. package/ios/Navigation/BottomTab/DuoBarCompression.swift +5 -12
  140. package/ios/Navigation/BottomTab/DuoTabBar.swift +67 -202
  141. package/ios/Navigation/BottomTab/TabBarMetrics.swift +97 -0
  142. package/ios/Navigation/Component/FloatingButton.swift +4 -11
  143. package/ios/Navigation/Component/Header.swift +35 -54
  144. package/ios/Navigation/Component/HeaderBackground.swift +2 -8
  145. package/ios/Navigation/Component/HeaderJourney.swift +4 -8
  146. package/ios/Navigation/Component/HeaderLocation.swift +4 -8
  147. package/ios/Navigation/Component/HeaderRight.swift +20 -22
  148. package/ios/Navigation/Component/HeaderTitle.swift +1 -6
  149. package/ios/Navigation/Component/HeaderUser.swift +4 -10
  150. package/ios/Navigation/Component/SideBar.swift +6 -21
  151. package/ios/Navigation/Component/SnackBar.swift +9 -13
  152. package/ios/Navigation/HostBackGestureBridge.swift +2 -9
  153. package/ios/Navigation/ModalScreen.swift +24 -13
  154. package/ios/Navigation/Navigation.swift +35 -19
  155. package/ios/Navigation/NavigationContainer.swift +4 -15
  156. package/ios/Navigation/Navigator.swift +21 -39
  157. package/ios/Navigation/StackScreen.swift +64 -51
  158. package/ios/Navigation/StackTransition.swift +7 -14
  159. package/ios/Navigation/SwipeBackHaptic.swift +2 -7
  160. package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
  161. package/ios/Pagination/PaginationDot.swift +0 -9
  162. package/ios/Pagination/PaginationNumber.swift +1 -9
  163. package/ios/Pagination/PaginationScroll.swift +2 -14
  164. package/ios/Pagination/PaginationWhiteDot.swift +1 -10
  165. package/ios/Popup/PopupDisplay.swift +7 -5
  166. package/ios/Popup/PopupInput.swift +6 -4
  167. package/ios/Popup/PopupLayout.swift +17 -9
  168. package/ios/Popup/PopupNotify.swift +32 -25
  169. package/ios/PopupView/FullscreenPopup.swift +3 -4
  170. package/ios/PopupView/PopupView.swift +2 -2
  171. package/ios/PopupView/Utils++.swift +1 -2
  172. package/ios/ProgressInfo/ProgressInfo.swift +2 -13
  173. package/ios/Skeleton/Skeleton.swift +5 -16
  174. package/ios/Slider/Slider.swift +5 -12
  175. package/ios/StatusBarTap/StatusBarTap.h +2 -3
  176. package/ios/StatusBarTap/StatusBarTap.m +3 -16
  177. package/ios/Stepper/Stepper.swift +8 -27
  178. package/ios/Steps/Steps.swift +29 -26
  179. package/ios/Swipeable/SwipeCell.swift +2 -2
  180. package/ios/Swipeable/SwipeCellModel.swift +3 -6
  181. package/ios/TabView/TabView.swift +14 -28
  182. package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
  183. package/ios/Title/Title.swift +1 -3
  184. package/ios/Tooltip/Tooltip.swift +4 -9
  185. package/ios/Typography/FontScale.swift +79 -24
  186. package/ios/Typography/Text.swift +6 -12
  187. package/ios/Typography/Typography.swift +8 -11
  188. package/ios/Uploader/Uploader.swift +2 -17
  189. package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
  190. package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
  191. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +11 -2
  192. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +296 -59
  193. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +15 -4
  194. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
  195. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +114 -0
  196. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
  197. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +16 -0
  198. package/package.json +1 -1
  199. package/publish.sh +8 -2
  200. package/scripts/ci/build-swiftui.sh +22 -0
  201. package/scripts/ci/resolve-version.mjs +144 -0
  202. package/settings.gradle.kts +0 -1
@@ -1,40 +1,54 @@
1
1
  package vn.momo.kits.navigation.bottomtab
2
2
 
3
+ import androidx.compose.runtime.getValue
4
+ import androidx.compose.animation.animateColorAsState
3
5
  import androidx.compose.animation.core.Animatable
6
+ import androidx.compose.animation.core.animateFloatAsState
7
+ import androidx.compose.animation.core.tween
8
+ import androidx.compose.foundation.clickable
9
+ import androidx.compose.foundation.interaction.MutableInteractionSource
10
+ import androidx.compose.foundation.interaction.collectIsPressedAsState
11
+ import androidx.compose.runtime.LaunchedEffect
12
+ import androidx.compose.runtime.mutableStateMapOf
13
+ import androidx.compose.ui.draw.clip
14
+ import androidx.compose.ui.draw.dropShadow
15
+ import androidx.compose.ui.draw.innerShadow
16
+ import androidx.compose.ui.graphics.Color
17
+ import androidx.compose.ui.graphics.Shape
18
+ import androidx.compose.ui.graphics.graphicsLayer
19
+ import androidx.compose.ui.layout.onPlaced
20
+ import androidx.compose.ui.layout.positionInParent
21
+ import androidx.compose.ui.platform.LocalDensity
22
+ import androidx.compose.ui.semantics.Role
23
+ import androidx.compose.ui.semantics.contentDescription
24
+ import androidx.compose.ui.semantics.role
25
+ import androidx.compose.ui.semantics.selected
26
+ import androidx.compose.ui.semantics.semantics
4
27
  import androidx.compose.foundation.background
5
28
  import androidx.compose.foundation.border
6
29
  import androidx.compose.foundation.layout.*
7
30
  import androidx.compose.foundation.shape.CircleShape
8
31
  import androidx.compose.foundation.shape.RoundedCornerShape
9
32
  import androidx.compose.runtime.Composable
10
- import androidx.compose.runtime.LaunchedEffect
11
- import androidx.compose.runtime.getValue
12
- import androidx.compose.runtime.mutableIntStateOf
13
33
  import androidx.compose.runtime.remember
14
- import androidx.compose.runtime.saveable.rememberSaveable
15
- import androidx.compose.runtime.setValue
16
34
  import androidx.compose.ui.Alignment
17
35
  import androidx.compose.ui.Modifier
18
- import androidx.compose.ui.draw.clip
19
- import androidx.compose.ui.graphics.Brush
20
- import androidx.compose.ui.graphics.Color
21
36
  import androidx.compose.ui.text.style.TextAlign
22
37
  import androidx.compose.ui.text.style.TextOverflow
23
- import androidx.compose.ui.unit.Dp
24
- import androidx.compose.ui.unit.IntOffset
25
38
  import androidx.compose.ui.unit.dp
26
39
  import vn.momo.kits.application.IsShowBaseLineDebug
27
40
  import vn.momo.kits.components.*
28
41
  import vn.momo.kits.const.*
42
+ import vn.momo.kits.layout.getScreenLayout
29
43
  import vn.momo.kits.modifier.InternalApi
30
- import vn.momo.kits.modifier.conditional
31
44
  import vn.momo.kits.modifier.activeOpacityClickable
32
- import vn.momo.kits.layout.getScreenLayout
33
- import vn.momo.kits.utils.horizontalSafeAreaPadding
45
+ import vn.momo.kits.modifier.conditional
46
+ import vn.momo.kits.modifier.setAutomationId
34
47
 
35
48
  @InternalApi
36
- const val BOTTOM_TAB_BAR_HEIGHT = 64
49
+ const val BOTTOM_TAB_BAR_HEIGHT = 68
37
50
 
51
+ // Phone tab bar: the horizontal navigation bar filling the window, above the home indicator.
38
52
  @Composable
39
53
  internal fun BottomTabBar(
40
54
  items: List<BottomTabItem>,
@@ -42,176 +56,343 @@ internal fun BottomTabBar(
42
56
  selectedIndex: Int,
43
57
  onTabSelected: (Int) -> Unit,
44
58
  ) {
45
-
46
59
  val layout = getScreenLayout()
47
- val mid = items.size / 2
48
-
49
- val floating = floatingButton?.takeIf { items.size % 2 == 0 }
50
- val slotWidth = layout.contentWidth / (items.size + if (floating != null) 1 else 0)
51
- fun slotOf(index: Int) = if (floating != null && index >= mid) index + 1 else index
52
-
53
- var indicatorSlot by rememberSaveable { mutableIntStateOf(0) }
54
- val indicatorX = remember { Animatable(indicatorSlot.toFloat()) }
55
- LaunchedEffect(selectedIndex) {
56
- val target = slotOf(selectedIndex)
57
- indicatorSlot = target
58
- indicatorX.animateTo(target.toFloat(), tabTimingSpec)
59
- }
60
-
61
60
  Box(
62
- contentAlignment = Alignment.BottomCenter
61
+ modifier = Modifier
62
+ .fillMaxWidth()
63
+ .padding(bottom = tabBarBottomGap(layout.insetBottom)),
64
+ contentAlignment = Alignment.BottomCenter,
63
65
  ) {
64
- Row(
66
+ HorizontalTabBar(
67
+ items = items,
68
+ floatingButton = floatingButton,
69
+ selectedIndex = selectedIndex,
70
+ onTabSelected = onTabSelected,
71
+ modifier = Modifier
72
+ .offset(x = (layout.insetLeft - layout.insetRight) / 2)
73
+ .width(
74
+ horizontalBarWidth(
75
+ layout.width, layout.height, layout.insetLeft, layout.insetRight,
76
+ items.size, hasCenterAction(floatingButton, items.size),
77
+ ),
78
+ ),
79
+ )
80
+ }
81
+ }
82
+
83
+ // Floating bar, items split evenly; Special type puts the center action in a notch, rising ctaLift above the bar.
84
+ @Composable
85
+ internal fun HorizontalTabBar(
86
+ items: List<BottomTabItem>,
87
+ floatingButton: BottomTabFloatingButton?,
88
+ selectedIndex: Int,
89
+ onTabSelected: (Int) -> Unit,
90
+ modifier: Modifier = Modifier,
91
+ ) {
92
+ val cta = floatingButton?.takeIf { hasCenterAction(it, items.size) }
93
+ val mid = items.size / 2
94
+ val density = LocalDensity.current
95
+ val itemBounds = remember(items.size) { mutableStateMapOf<Int, Pair<Float, Float>>() }
96
+
97
+ BoxWithConstraints(modifier = modifier) {
98
+ val shape = remember(maxWidth, cta != null) {
99
+ NotchedBarShape(TabBarMetrics.height / 2, if (cta != null) maxWidth / 2 else null)
100
+ }
101
+ Box(
65
102
  modifier = Modifier
103
+ .padding(top = if (cta != null) TabBarMetrics.ctaLift else 0.dp)
66
104
  .fillMaxWidth()
67
- .height(BOTTOM_TAB_BAR_HEIGHT.dp)
68
- .background(AppTheme.current.colors.background.surface)
69
- .conditional(IsShowBaseLineDebug) {
70
- border(1.dp, Colors.blue_03)
71
- }
72
- .horizontalSafeAreaPadding(),
73
- horizontalArrangement = Arrangement.SpaceAround,
105
+ .height(TabBarMetrics.height)
106
+ .tabBarContainer(shape)
107
+ .padding(horizontal = TabBarMetrics.paddingHorizontal, vertical = TabBarMetrics.paddingVertical)
108
+ .setAutomationId("bottom_tab_bar"),
74
109
  ) {
75
- if (floating == null) {
76
- RenderTabBarItem(items, 0, items.size, selectedIndex, onTabSelected)
77
- } else {
78
- RenderTabBarItem(items, 0, mid, selectedIndex, onTabSelected)
79
- Spacer(modifier = Modifier.width(slotWidth))
80
- RenderTabBarItem(items, mid, items.size, selectedIndex, onTabSelected)
110
+ itemBounds[selectedIndex]?.let { (x, width) ->
111
+ ActiveIndicator(
112
+ offset = x,
113
+ modifier = Modifier
114
+ .width(with(density) { width.toDp() })
115
+ .height(TabBarMetrics.indicatorHeight),
116
+ shape = RoundedCornerShape(TabBarMetrics.indicatorRadius),
117
+ axisX = true,
118
+ )
119
+ }
120
+ Row(
121
+ modifier = Modifier.fillMaxSize(),
122
+ horizontalArrangement = Arrangement.spacedBy(TabBarMetrics.itemGap),
123
+ verticalAlignment = Alignment.CenterVertically,
124
+ ) {
125
+ items.forEachIndexed { index, item ->
126
+ if (cta != null && index == mid) {
127
+ Spacer(Modifier.width(TabBarMetrics.ctaSlotWidth))
128
+ }
129
+ TabBarItem(
130
+ item = item,
131
+ selected = index == selectedIndex,
132
+ modifier = Modifier.onPlaced {
133
+ itemBounds[index] = it.positionInParent().x to it.size.width.toFloat()
134
+ },
135
+ onClick = { onTabSelected(index) },
136
+ )
137
+ }
81
138
  }
82
139
  }
140
+ cta?.let { CenterAction(it, Modifier.align(Alignment.TopCenter).offset(y = centerActionTop())) }
141
+ }
142
+ }
83
143
 
84
- Box(modifier = Modifier
85
- .offset { IntOffset((layout.insetLeft + slotWidth * (indicatorX.value + 0.5f) - layout.width / 2).roundToPx(), (-BOTTOM_TAB_BAR_HEIGHT + 2).dp.roundToPx()) }
86
- .height(2.dp)
87
- .width(44.dp)
88
- .background(
89
- color = AppTheme.current.colors.primary ,
90
- shape = RoundedCornerShape(bottomStart = 2.dp, bottomEnd = 2.dp)
91
- )
92
- )
144
+ // Offset of the center action column from the bar top: the items are centered in the container (which
145
+ // starts ctaLift down), so the column is placed for its label to start on the tab labels' line.
146
+ private fun centerActionTop() = with(TabBarMetrics) {
147
+ val itemHeight = indicatorHeight + itemIconLabelGap + labelHeight
148
+ val itemLabelTop = ctaLift + paddingVertical + (height - paddingVertical * 2 - itemHeight) / 2 +
149
+ indicatorHeight + itemIconLabelGap
150
+ itemLabelTop - ctaLabelGap - ctaSize
151
+ }
93
152
 
94
- Box(modifier = Modifier
95
- .fillMaxWidth()
96
- .height(6.dp)
97
- .offset(x = 0.dp, y = (-BOTTOM_TAB_BAR_HEIGHT).dp)
98
- .background(
99
- brush = Brush.verticalGradient(
100
- colors = listOf(Color.Transparent, Color.Black.copy(alpha = 0.05f))
101
- )
153
+ // One active indicator per bar (Background/tonal with its inner shadows) sliding to the selected item
154
+ // along x (horizontal bar) or y (rail); it lands in place on the first measure and slides from then on.
155
+ @Composable
156
+ internal fun ActiveIndicator(offset: Float, modifier: Modifier, shape: Shape, axisX: Boolean) {
157
+ val colors = AppTheme.current.colors
158
+ val position = remember { Animatable(offset) }
159
+ LaunchedEffect(offset) {
160
+ if (position.value != offset) position.animateTo(offset, TabBarMotion.indicator)
161
+ }
162
+ Box(
163
+ modifier
164
+ .graphicsLayer {
165
+ if (axisX) translationX = position.value else translationY = position.value
166
+ }
167
+ .background(colors.background.tonal, shape)
168
+ .then(
169
+ indicatorInnerShadows(colors.primary).fold(Modifier as Modifier) { acc, shadow ->
170
+ acc.innerShadow(shape, shadow)
171
+ }
102
172
  )
103
- )
104
- floating?.let {
105
- Box(Modifier.offset(x = (layout.insetLeft - layout.insetRight) / 2)) {
106
- FloatingButton(it, slotWidth)
173
+ )
174
+ }
175
+
176
+ @Composable
177
+ private fun RowScope.TabBarItem(
178
+ item: BottomTabItem,
179
+ selected: Boolean,
180
+ modifier: Modifier,
181
+ onClick: () -> Unit,
182
+ ) {
183
+ Column(
184
+ modifier = modifier
185
+ .weight(1f)
186
+ .conditional(IsShowBaseLineDebug) {
187
+ border(1.dp, Colors.blue_03)
107
188
  }
108
- }
189
+ .activeOpacityClickable { onClick() }
190
+ .semantics {
191
+ role = Role.Tab
192
+ this.selected = selected
193
+ contentDescription = item.label
194
+ },
195
+ horizontalAlignment = Alignment.CenterHorizontally,
196
+ verticalArrangement = Arrangement.spacedBy(TabBarMetrics.itemIconLabelGap),
197
+ ) {
198
+ TabItemContent(item, selected)
109
199
  }
110
200
  }
111
201
 
202
+ // Icon in its indicator slot, label under it. The bar slides one shared active indicator behind the
203
+ // slots; the icon and label tint cross-fade on focus.
112
204
  @Composable
113
- internal fun RowScope.RenderTabBarItem(
114
- items: List<BottomTabItem>,
115
- fromIndex: Int,
116
- toIndex: Int,
117
- selectedIndex: Int,
118
- onTabSelected: (Int) -> Unit
119
- ){
120
- for (index in fromIndex until toIndex) {
121
- Box(modifier = Modifier.weight(1f)) {
122
- TabBarItem(
123
- item = items[index],
124
- selected = index == selectedIndex,
125
- onClick = { onTabSelected(index) }
205
+ internal fun ColumnScope.TabItemContent(
206
+ item: BottomTabItem,
207
+ selected: Boolean,
208
+ vertical: Boolean = false,
209
+ showLabel: Boolean = true,
210
+ ) {
211
+ val colors = AppTheme.current.colors
212
+ val tint by animateColorAsState(
213
+ if (selected) colors.primary else colors.text.secondary,
214
+ tween(TabBarMotion.TINT_MILLIS, easing = inOutQuad),
215
+ label = "TabTint",
216
+ )
217
+
218
+ Box(
219
+ modifier = Modifier
220
+ .then(if (vertical) Modifier else Modifier.fillMaxWidth())
221
+ .height(if (vertical) TabBarMetrics.railIndicatorHeight else TabBarMetrics.indicatorHeight)
222
+ .padding(horizontal = TabBarMetrics.indicatorPaddingHorizontal),
223
+ contentAlignment = Alignment.Center,
224
+ ) {
225
+ TabIcon(item, tint, vertical)
226
+ }
227
+ if (showLabel) {
228
+ // fixed slot so a capped-scale label overflows downward and the icon above it stays put
229
+ Box(
230
+ modifier = Modifier.height(
231
+ if (vertical) TabBarMetrics.railLabelHeight else TabBarMetrics.labelHeight
232
+ ),
233
+ contentAlignment = Alignment.TopCenter,
234
+ ) {
235
+ Text(
236
+ text = item.label,
237
+ color = tint,
238
+ style = if (vertical) Typography.labelXsMedium else Typography.labelSMedium,
239
+ textAlign = TextAlign.Center,
240
+ maxLines = 1,
241
+ overflow = TextOverflow.Ellipsis,
242
+ modifier = (if (vertical) Modifier else Modifier.fillMaxWidth())
243
+ .wrapContentHeight(Alignment.Top, unbounded = true),
126
244
  )
127
245
  }
128
246
  }
129
247
  }
130
248
 
249
+ // Badge value shown on a tab: null hides it, "" is a dot, numbers cap at 99+ ("0" hides it, RN parity).
250
+ internal fun tabBadgeLabel(item: BottomTabItem): String? {
251
+ val label = item.badgeLabel ?: return if (item.showDot) "" else null
252
+ if (label.isEmpty()) return ""
253
+ if (label.all { it in '0'..'9' }) {
254
+ val value = label.toLongOrNull() ?: Long.MAX_VALUE
255
+ if (value == 0L) return if (item.showDot) "" else null
256
+ return if (value > 99) "99+" else label
257
+ }
258
+ return label
259
+ }
260
+
261
+ // 24 icon; badges hang off it unclipped: dot at 16/-2, label badge at 12/-7 growing right, or
262
+ // centered over the icon at -10 on the rail.
131
263
  @Composable
132
- internal fun TabBarItem(item: BottomTabItem, selected: Boolean, onClick: () -> Unit) {
133
- // RN parity: "0" hides the badge, "" renders a dot.
134
- val badgeLabel = item.badgeLabel?.takeUnless { it.toIntOrNull() == 0 }
135
- val isNumber = badgeLabel?.toIntOrNull() != null
136
- val showDot = badgeLabel?.isEmpty() ?: item.showDot
137
-
138
- Box(modifier = Modifier
139
- .fillMaxSize()
140
- .padding(horizontal = Spacing.XXS)
141
- .conditional(IsShowBaseLineDebug) {
142
- border(1.dp, Colors.blue_03)
264
+ internal fun TabIcon(item: BottomTabItem, tint: androidx.compose.ui.graphics.Color, vertical: Boolean) {
265
+ val badge = tabBadgeLabel(item)
266
+ Box(Modifier.size(TabBarMetrics.iconSize)) {
267
+ Icon(source = item.icon, size = TabBarMetrics.iconSize, color = tint)
268
+ when {
269
+ badge == null -> Unit
270
+ badge.isEmpty() -> BadgeDot(
271
+ size = DotSize.Small,
272
+ modifier = Modifier.offset(x = 16.dp, y = -Spacing.XXS),
273
+ )
274
+ vertical -> TabBadge(
275
+ badge,
276
+ Modifier.matchParentSize()
277
+ .wrapContentSize(Alignment.TopCenter, unbounded = true)
278
+ .offset(y = (-10).dp),
279
+ )
280
+ else -> TabBadge(
281
+ badge,
282
+ Modifier.matchParentSize()
283
+ .wrapContentSize(Alignment.TopStart, unbounded = true)
284
+ .offset(x = Spacing.M, y = (-7).dp),
285
+ )
143
286
  }
144
- .activeOpacityClickable {
145
- onClick()
146
- },
147
- contentAlignment = Alignment.BottomStart
148
- ){
149
- Column(
150
- modifier = Modifier
151
- .fillMaxSize()
152
- .padding(horizontal = Spacing.S, vertical = Spacing.S),
153
- horizontalAlignment = Alignment.CenterHorizontally,
154
- verticalArrangement = Arrangement.Center
155
- ) {
156
- Box(modifier = Modifier.padding(Spacing.XS)) {
157
- Icon(
158
- source = item.icon,
159
- size = 28.dp,
160
- color = if (selected) AppTheme.current.colors.primary else AppTheme.current.colors.text.hint)
161
- val badgeAnchor = Modifier.matchParentSize().wrapContentSize(Alignment.TopEnd, unbounded = true)
162
- if (showDot) {
163
- BadgeDot(size = DotSize.Small, modifier = badgeAnchor.offset(x = 4.dp, y = (-4).dp))
164
- } else if (!badgeLabel.isNullOrEmpty()) {
165
- Badge(badgeLabel, modifier = badgeAnchor.offset(x = if (isNumber) 8.dp else 12.dp, y = (-8).dp))
166
- }
167
- }
287
+ }
288
+ }
289
+
290
+ // Numbers use the error color, text the warning color (Figma Badge round numeric / text); the text keeps
291
+ // its design size so it fits the 16 height on the Duo displays too.
292
+ @Composable
293
+ private fun TabBadge(label: String, modifier: Modifier) {
294
+ val colors = AppTheme.current.colors
295
+ val isNumber = label.trimEnd('+').let { it.isNotEmpty() && it.all { c -> c in '0'..'9' } }
296
+ Box(
297
+ modifier = modifier
298
+ .height(16.dp)
299
+ .widthIn(min = 16.dp, max = TabBarMetrics.badgeMaxWidth)
300
+ .background(if (isNumber) colors.error.primary else colors.warning.primary, CircleShape)
301
+ .border(1.dp, colors.background.surface, CircleShape)
302
+ .padding(horizontal = Spacing.XS),
303
+ contentAlignment = Alignment.Center,
304
+ ) {
305
+ ScaleSizeScope(1f) {
168
306
  Text(
169
- text = item.label,
170
- color = if (selected) AppTheme.current.colors.primary else AppTheme.current.colors.text.hint,
171
- style = if (selected) Typography.labelXsMedium else Typography.descriptionXsRegular,
307
+ text = label,
308
+ style = Typography.actionXxsBold,
309
+ color = Colors.black_01,
172
310
  maxLines = 1,
173
- overflow = TextOverflow.Ellipsis
311
+ overflow = TextOverflow.Ellipsis,
174
312
  )
175
313
  }
176
314
  }
177
315
  }
178
316
 
317
+ // Center action press: the button shrinks while held; the label stays plain text.
179
318
  @Composable
180
- internal fun FloatingButton(data: BottomTabFloatingButton, width: Dp) {
181
- Column(
319
+ internal fun rememberCenterActionPress(): Pair<MutableInteractionSource, Boolean> {
320
+ val interactionSource = remember { MutableInteractionSource() }
321
+ val pressed by interactionSource.collectIsPressedAsState()
322
+ return interactionSource to pressed
323
+ }
324
+
325
+ @Composable
326
+ internal fun Modifier.centerActionPressScale(pressed: Boolean): Modifier {
327
+ val scale by animateFloatAsState(
328
+ if (pressed) TabBarMotion.CTA_PRESSED_SCALE else 1f,
329
+ tween(TabBarMotion.CTA_PRESS_MILLIS, easing = inOutQuad),
330
+ label = "CenterActionPress",
331
+ )
332
+ return graphicsLayer {
333
+ scaleX = scale
334
+ scaleY = scale
335
+ }
336
+ }
337
+
338
+ @Composable
339
+ internal fun Modifier.centerActionButton(size: androidx.compose.ui.unit.Dp, pressed: Boolean): Modifier {
340
+ return centerActionPressScale(pressed)
341
+ .size(size)
342
+ .then(CtaShadows.fold(Modifier as Modifier) { acc, shadow -> acc.spreadShadow(CircleShape, shadow) })
343
+ .background(AppTheme.current.colors.primary, CircleShape)
344
+ .border(1.dp, Color.White.copy(alpha = TabBarMetrics.ctaBorderOpacity), CircleShape)
345
+ }
346
+
347
+ @Composable
348
+ internal fun CenterActionLabel(label: String, overlay: (@Composable () -> Unit)?, vertical: Boolean) {
349
+ val colors = AppTheme.current.colors
350
+ Box(
182
351
  modifier = Modifier
183
- .width(width)
184
- .padding(horizontal = Spacing.XXS, vertical = Spacing.S)
352
+ .then(if (vertical) Modifier else Modifier.heightIn(min = TabBarMetrics.ctaLabelHeight))
353
+ .padding(horizontal = if (vertical) Spacing.XS else Spacing.XXS),
354
+ contentAlignment = Alignment.Center,
355
+ ) {
356
+ Text(
357
+ text = label,
358
+ style = if (vertical) Typography.labelXsMedium else Typography.labelSMedium,
359
+ color = colors.text.secondary,
360
+ textAlign = TextAlign.Center,
361
+ maxLines = 1,
362
+ overflow = TextOverflow.Ellipsis,
363
+ )
364
+ overlay?.let {
365
+ Box(Modifier.matchParentSize().wrapContentSize(Alignment.Center, unbounded = true)) { it() }
366
+ }
367
+ }
368
+ }
369
+
370
+ // Center action (.Nav/CTA): button rising out of the notch, label under it.
371
+ @Composable
372
+ private fun CenterAction(data: BottomTabFloatingButton, modifier: Modifier) {
373
+ val (interactionSource, pressed) = rememberCenterActionPress()
374
+ Column(
375
+ modifier = modifier
376
+ .width(TabBarMetrics.ctaSlotWidth)
185
377
  .conditional(IsShowBaseLineDebug) {
186
378
  border(1.dp, Colors.blue_03)
187
379
  }
188
- .activeOpacityClickable {
189
- data.onPress()
190
- },
191
- verticalArrangement = Arrangement.Bottom,
192
- horizontalAlignment = Alignment.CenterHorizontally
193
-
194
- ){
195
- CurvedContainer()
196
- Box(
197
- modifier = Modifier
198
- .size(48.dp)
199
- .clip(CircleShape)
200
- .background(AppTheme.current.colors.primary),
201
- contentAlignment = Alignment.Center
202
- ) {
203
- Icon(source = data.icon, color = Color.White, size = 28.dp)
380
+ .clickable(interactionSource = interactionSource, indication = null, onClick = data.onPress)
381
+ .setAutomationId(data.label),
382
+ horizontalAlignment = Alignment.CenterHorizontally,
383
+ verticalArrangement = Arrangement.spacedBy(TabBarMetrics.ctaLabelGap),
384
+ ) {
385
+ Box(Modifier.centerActionButton(TabBarMetrics.ctaSize, pressed), contentAlignment = Alignment.Center) {
386
+ val iconContent = data.iconContent
387
+ if (iconContent != null) {
388
+ // custom content (e.g. an oversized Lottie) is clipped to the round button
389
+ Box(Modifier.size(TabBarMetrics.ctaSize).clip(CircleShape), contentAlignment = Alignment.Center) {
390
+ iconContent()
391
+ }
392
+ } else {
393
+ Icon(source = data.icon, color = Colors.black_01, size = TabBarMetrics.ctaIconSize)
394
+ }
204
395
  }
205
- Spacer(modifier = Modifier.height(4.dp))
206
- Text(
207
- text = data.label,
208
- style = Typography.labelXsMedium,
209
- color = Colors.black_01,
210
- textAlign = TextAlign.Center,
211
- modifier = Modifier
212
- .height(14.dp)
213
- .fillMaxWidth()
214
- .background(AppTheme.current.colors.primary, shape = RoundedCornerShape(size = Radius.XL))
215
- )
396
+ CenterActionLabel(data.label, data.labelContent, vertical = false)
216
397
  }
217
398
  }