@momo-kits/native-kits 0.300.6-debug → 0.300.6

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 (139) hide show
  1. package/package.json +1 -1
  2. package/build.gradle.kts +0 -13
  3. package/compose/build.gradle.kts +0 -197
  4. package/compose/build.gradle.kts.backup +0 -197
  5. package/compose/compose.podspec +0 -47
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -20
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
  8. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
  10. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -153
  11. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -65
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -361
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -17
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -287
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -306
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -338
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -137
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -215
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -404
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -732
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -40
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -233
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -217
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -377
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -103
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -413
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +0 -37
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +0 -41
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -135
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -20
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
  123. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +0 -44
  124. package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +0 -62
  125. package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
  126. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
  127. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -34
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
  130. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -217
  131. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -138
  132. package/gradle/libs.versions.toml +0 -68
  133. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  134. package/gradle/wrapper/gradle-wrapper.properties +0 -8
  135. package/gradle.properties +0 -26
  136. package/gradlew +0 -252
  137. package/gradlew.bat +0 -94
  138. package/ios-demo/README.md +0 -120
  139. package/settings.gradle.kts +0 -64
@@ -1,86 +0,0 @@
1
- package vn.momo.kits.navigation.bottomtab
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
- import androidx.compose.ui.Modifier
11
- import androidx.compose.ui.graphics.Path
12
- import androidx.compose.ui.platform.LocalDensity
13
- import androidx.compose.ui.unit.Dp
14
- import androidx.compose.ui.unit.IntOffset
15
- import androidx.compose.ui.unit.dp
16
- import androidx.compose.ui.zIndex
17
- import vn.momo.kits.const.AppTheme
18
-
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)
60
- }
61
- }
62
- }
63
-
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)
68
-
69
- cubicTo(
70
- centerX - circleOverR, circleOverTop,
71
- centerX - circleOverR, 0f,
72
- centerX, 0f
73
- )
74
-
75
- cubicTo(
76
- centerX + circleOverR, 0f,
77
- centerX + circleOverR, circleOverTop,
78
- centerX + circleOverR + 40f, circleOverTop
79
- )
80
-
81
- lineTo(widthPx, circleOverTop)
82
- lineTo(widthPx, 60f)
83
- lineTo(0f, 60f)
84
- close()
85
- }
86
- }
@@ -1,97 +0,0 @@
1
- package vn.momo.kits.navigation.bottomtab
2
-
3
- import androidx.compose.runtime.Composable
4
- import androidx.compose.runtime.Stable
5
- import androidx.compose.runtime.compositionLocalOf
6
- import androidx.compose.runtime.getValue
7
- import androidx.compose.runtime.mutableStateOf
8
- import androidx.compose.runtime.remember
9
- import androidx.compose.runtime.setValue
10
- import androidx.compose.ui.unit.Dp
11
- import vn.momo.kits.const.Spacing
12
- import vn.momo.kits.layout.DuoMetrics
13
- import vn.momo.kits.layout.ScreenLayout
14
-
15
- // iPhone Duo: which side bar bar starts compressed when the strip cannot hold both whole.
16
- enum class DuoBarCompressionBehavior { TOOLBAR, TAB_BAR }
17
-
18
- private enum class DuoBar { TOOLBAR, TAB_BAR }
19
-
20
- @Stable
21
- internal class DuoBarCompression(
22
- val toolbarCompressed: Boolean = false,
23
- val tabBarCompressed: Boolean = false,
24
- // the open rail needs the toolbar button slot too: only Back stays
25
- val toolbarHidden: Boolean = false,
26
- val expandToolbar: () -> Unit = {},
27
- val expandTabBar: () -> Unit = {},
28
- // a rail opened from the compressed state closes once a tab is picked
29
- val onTabSelected: () -> Unit = {},
30
- // side bar columns report their full height so the tab bar knows what is left
31
- val setToolbarHeight: (Dp) -> Unit = {},
32
- )
33
-
34
- internal val LocalDuoBarCompression = compositionLocalOf { DuoBarCompression() }
35
-
36
- // space kept between the top and the bottom groups (HIG Vertical controls)
37
- internal val DUO_GROUP_GAP = Spacing.M
38
- // Back, then the right toolkit: help + home capsule
39
- private val DEFAULT_TOOLBAR_HEIGHT = DuoMetrics.controlSize + Spacing.M + DuoMetrics.itemPitch * 2
40
- // Back, then the single button the toolbar folds into
41
- private val COMPRESSED_TOOLBAR_HEIGHT = DuoMetrics.controlSize * 2 + Spacing.M
42
-
43
- // Port of RN DuoBarCompression (HIG, Designing for iPhone Duo: Vertical controls):
44
- // - both fit: both stay whole
45
- // - one fits whole beside the other compressed: one is compressed, tapping it swaps them
46
- // - otherwise both rest compressed; tapping one opens it for a moment (the rail closes
47
- // again once a tab is picked)
48
- @Composable
49
- internal fun rememberDuoBarCompression(
50
- behavior: DuoBarCompressionBehavior,
51
- tabCount: Int,
52
- hasQr: Boolean,
53
- layout: ScreenLayout,
54
- ): DuoBarCompression {
55
- var toolbarHeight by remember { mutableStateOf(DEFAULT_TOOLBAR_HEIGHT) }
56
- var expanded by remember(behavior) {
57
- mutableStateOf(if (behavior == DuoBarCompressionBehavior.TOOLBAR) DuoBar.TAB_BAR else DuoBar.TOOLBAR)
58
- }
59
- var opened by remember { mutableStateOf<DuoBar?>(null) }
60
- val setToolbarHeight = remember { { height: Dp -> toolbarHeight = height } }
61
- val sideBar = layout.sideBar
62
-
63
- return remember(sideBar, layout.height, tabCount, hasQr, toolbarHeight, expanded, opened) {
64
- if (sideBar == null) return@remember DuoBarCompression()
65
- val room = layout.height - sideBar.bottom - sideBar.top - DUO_GROUP_GAP
66
- val tabBar = duoRailHeight(tabCount, hasQr)
67
- val compressedTabBar = duoRailHeight(1, hasQr, compressed = true)
68
- fun fits(toolbar: Dp, tabs: Dp) = toolbar + tabs <= room
69
-
70
- when {
71
- fits(toolbarHeight, tabBar) -> DuoBarCompression(setToolbarHeight = setToolbarHeight)
72
- fits(COMPRESSED_TOOLBAR_HEIGHT, tabBar) && fits(toolbarHeight, compressedTabBar) -> DuoBarCompression(
73
- toolbarCompressed = expanded == DuoBar.TAB_BAR,
74
- tabBarCompressed = expanded == DuoBar.TOOLBAR,
75
- expandToolbar = { expanded = DuoBar.TOOLBAR },
76
- expandTabBar = { expanded = DuoBar.TAB_BAR },
77
- setToolbarHeight = setToolbarHeight,
78
- )
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(
81
- toolbarCompressed = true,
82
- toolbarHidden = true,
83
- expandToolbar = { opened = DuoBar.TOOLBAR },
84
- expandTabBar = { opened = DuoBar.TAB_BAR },
85
- onTabSelected = { opened = null },
86
- setToolbarHeight = setToolbarHeight,
87
- )
88
- else -> DuoBarCompression(
89
- toolbarCompressed = opened != DuoBar.TOOLBAR,
90
- tabBarCompressed = true,
91
- expandToolbar = { opened = DuoBar.TOOLBAR },
92
- expandTabBar = { opened = DuoBar.TAB_BAR },
93
- setToolbarHeight = setToolbarHeight,
94
- )
95
- }
96
- }
97
- }
@@ -1,377 +0,0 @@
1
- package vn.momo.kits.navigation.bottomtab
2
-
3
- import androidx.compose.animation.core.Spring
4
- import androidx.compose.animation.core.animateDpAsState
5
- import androidx.compose.animation.core.animateFloatAsState
6
- import androidx.compose.animation.core.spring
7
- import androidx.compose.foundation.background
8
- import androidx.compose.foundation.clickable
9
- import androidx.compose.foundation.interaction.MutableInteractionSource
10
- import androidx.compose.foundation.interaction.collectIsPressedAsState
11
- import androidx.compose.foundation.border
12
- import androidx.compose.foundation.layout.Arrangement
13
- import androidx.compose.foundation.layout.Box
14
- import androidx.compose.foundation.layout.BoxScope
15
- import androidx.compose.foundation.layout.BoxWithConstraints
16
- import androidx.compose.foundation.layout.Column
17
- import androidx.compose.foundation.layout.Row
18
- import androidx.compose.foundation.layout.RowScope
19
- import androidx.compose.foundation.layout.absolutePadding
20
- import androidx.compose.foundation.layout.fillMaxHeight
21
- import androidx.compose.foundation.layout.fillMaxSize
22
- import androidx.compose.foundation.layout.fillMaxWidth
23
- import androidx.compose.foundation.layout.height
24
- import androidx.compose.foundation.layout.offset
25
- import androidx.compose.foundation.layout.padding
26
- import androidx.compose.foundation.layout.size
27
- import androidx.compose.foundation.layout.width
28
- import androidx.compose.foundation.shape.CircleShape
29
- import androidx.compose.foundation.shape.RoundedCornerShape
30
- import androidx.compose.runtime.Composable
31
- import androidx.compose.runtime.CompositionLocalProvider
32
- import androidx.compose.runtime.LaunchedEffect
33
- import androidx.compose.runtime.MutableState
34
- import androidx.compose.runtime.compositionLocalOf
35
- import androidx.compose.runtime.getValue
36
- import androidx.compose.runtime.mutableStateOf
37
- import androidx.compose.runtime.remember
38
- import androidx.compose.ui.AbsoluteAlignment
39
- import androidx.compose.ui.Alignment
40
- import androidx.compose.ui.Modifier
41
- import androidx.compose.ui.draw.clip
42
- import androidx.compose.ui.draw.shadow
43
- import androidx.compose.ui.graphics.graphicsLayer
44
- import androidx.compose.ui.graphics.Color
45
- import androidx.compose.ui.graphics.Shape
46
- import androidx.compose.ui.semantics.Role
47
- import androidx.compose.ui.text.style.TextOverflow
48
- import androidx.compose.ui.unit.Dp
49
- import androidx.compose.ui.unit.dp
50
- import vn.momo.kits.application.LocalContext
51
- import vn.momo.kits.application.MiniAppContext
52
- import vn.momo.kits.components.Badge
53
- import vn.momo.kits.components.BadgeDot
54
- import vn.momo.kits.components.DotSize
55
- import vn.momo.kits.components.Icon
56
- import vn.momo.kits.components.Text
57
- import vn.momo.kits.const.AppTheme
58
- import vn.momo.kits.const.Spacing
59
- import vn.momo.kits.const.Typography
60
- import vn.momo.kits.layout.DuoMetrics
61
- import vn.momo.kits.layout.ScreenLayout
62
- import vn.momo.kits.layout.SideBarEdge
63
- import vn.momo.kits.modifier.noFeedbackClickable
64
- import vn.momo.kits.modifier.setAutomationId
65
-
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
- // while pressed the selection bubble grows into a lens past the pill's edges
80
- private const val LENS_SCALE_X = 1.2f
81
- private const val LENS_SCALE_Y = 1.3f
82
- // Figma Home-2026 tab bar "Selection": brand pink at 8%
83
- private const val SELECTION_TINT_ALPHA = 0x14 / 255f
84
- // RN reanimated spring { damping: 18, stiffness: 220, mass: 0.8 }
85
- private val BUBBLE_SPRING = spring<Dp>(dampingRatio = 0.68f, stiffness = 275f, visibilityThreshold = Dp(0.5f))
86
- private val LENS_SPRING = spring<Float>(dampingRatio = 0.68f, stiffness = 275f)
87
-
88
- // Space from the window bottom the rail stack and its gap take, so the header side bar stays above it.
89
- internal val LocalDuoRailReserve = compositionLocalOf { 0.dp }
90
-
91
- // Rail plus the QR button under it; compressed, the rail is a single button.
92
- internal fun duoRailHeight(itemCount: Int, hasQr: Boolean, compressed: Boolean = false): Dp {
93
- val rail = if (compressed) ITEM_SIZE
94
- else RAIL_PADDING * 2 + ITEM_SIZE * itemCount + RAIL_GAP * (itemCount - 1).coerceAtLeast(0)
95
- return rail + if (hasQr) Spacing.M + ITEM_SIZE else 0.dp
96
- }
97
-
98
- // Overlaps the home indicator inset like the system tab bar (21pt above the bottom with a 34pt inset).
99
- private fun floatingTabBarBottom(insetBottom: Dp): Dp =
100
- maxOf(insetBottom - DuoMetrics.floatingTabBarInsetOverlap, Spacing.S)
101
-
102
- // Space tab content leaves under the floating bar; 0 when the rail sits in the side strip or off Duo.
103
- internal fun duoFloatingTabBarInset(layout: ScreenLayout): Dp =
104
- if (layout.isIPhoneDuo && layout.sideBar == null) FLOATING_HEIGHT + floatingTabBarBottom(layout.insetBottom) else 0.dp
105
-
106
- // iPhone Duo tab bar: rail in the side bar, or a floating bar when unfolded portrait.
107
- @Composable
108
- internal fun BoxScope.DuoTabBar(
109
- layout: ScreenLayout,
110
- items: List<BottomTabItem>,
111
- floatingButton: BottomTabFloatingButton?,
112
- selectedIndex: Int,
113
- onTabSelected: (Int) -> Unit,
114
- compression: DuoBarCompression = DuoBarCompression(),
115
- ) {
116
- if (layout.sideBar != null) {
117
- DuoRailTabBar(layout, items, floatingButton, selectedIndex, onTabSelected, compression)
118
- } else {
119
- DuoFloatingTabBar(layout, items, floatingButton, selectedIndex, onTabSelected)
120
- }
121
- }
122
-
123
- // Vertical bar anchored to the bottom of the side bar, QR button below it (Figma MT1-C/E). When the
124
- // side bar is short it can shrink to one button showing the current tab (HIG "Tab bar compressed");
125
- // tapping it expands the rail and compresses the toolbar.
126
- @Composable
127
- private fun BoxScope.DuoRailTabBar(
128
- layout: ScreenLayout,
129
- items: List<BottomTabItem>,
130
- floatingButton: BottomTabFloatingButton?,
131
- selectedIndex: Int,
132
- onTabSelected: (Int) -> Unit,
133
- compression: DuoBarCompression,
134
- ) {
135
- val sideBar = layout.sideBar ?: return
136
- val isRight = sideBar.edge == SideBarEdge.RIGHT
137
-
138
- Column(
139
- modifier = Modifier
140
- .align(if (isRight) AbsoluteAlignment.BottomRight else AbsoluteAlignment.BottomLeft)
141
- .width(sideBar.width)
142
- .padding(bottom = sideBar.bottom)
143
- .absolutePadding(left = if (isRight) Spacing.M else 0.dp, right = if (isRight) 0.dp else Spacing.M),
144
- horizontalAlignment = if (isRight) AbsoluteAlignment.Left else AbsoluteAlignment.Right,
145
- verticalArrangement = Arrangement.spacedBy(Spacing.M),
146
- ) {
147
- val current = items.getOrNull(selectedIndex)
148
- if (compression.tabBarCompressed && current != null) {
149
- Box(
150
- modifier = Modifier
151
- .size(ITEM_SIZE)
152
- .tabBarMaterial(CircleShape)
153
- .noFeedbackClickable(onClick = compression.expandTabBar)
154
- .setAutomationId("bottom_tab_bar"),
155
- contentAlignment = Alignment.Center,
156
- ) {
157
- DuoTabIcon(current, selected = true)
158
- }
159
- } else {
160
- Rail(items, selectedIndex) {
161
- onTabSelected(it)
162
- compression.onTabSelected()
163
- }
164
- }
165
- if (floatingButton != null) {
166
- QrButton(floatingButton, size = ITEM_SIZE)
167
- }
168
- }
169
- }
170
-
171
- // Column of icon-only tab items with the sliding selection bubble.
172
- @Composable
173
- private fun Rail(items: List<BottomTabItem>, selectedIndex: Int, onItemClick: (Int) -> Unit) {
174
- val pressedIndex = remember { mutableStateOf<Int?>(null) }
175
- val bubbleOffset by animateDpAsState(
176
- targetValue = (ITEM_SIZE + RAIL_GAP) * (pressedIndex.value ?: selectedIndex).coerceAtLeast(0),
177
- animationSpec = BUBBLE_SPRING,
178
- label = "DuoRailBubble",
179
- )
180
- Box(
181
- Modifier
182
- .width(ITEM_SIZE)
183
- .tabBarMaterial(CircleShape)
184
- .setAutomationId("bottom_tab_bar")
185
- ) {
186
- Box(
187
- Modifier
188
- .offset(
189
- x = (ITEM_SIZE - RAIL_BUBBLE_WIDTH) / 2,
190
- y = RAIL_PADDING - (RAIL_BUBBLE_HEIGHT - ITEM_SIZE) / 2 + bubbleOffset,
191
- )
192
- .size(RAIL_BUBBLE_WIDTH, RAIL_BUBBLE_HEIGHT)
193
- .selectionLens(pressedIndex.value != null)
194
- )
195
- Column(
196
- modifier = Modifier.padding(vertical = RAIL_PADDING),
197
- verticalArrangement = Arrangement.spacedBy(RAIL_GAP),
198
- ) {
199
- items.forEachIndexed { index, item ->
200
- Box(
201
- modifier = Modifier
202
- .size(ITEM_SIZE)
203
- .tabClickable(index, pressedIndex) { onItemClick(index) },
204
- contentAlignment = Alignment.Center,
205
- ) {
206
- DuoTabIcon(item, selected = index == selectedIndex)
207
- }
208
- }
209
- }
210
- }
211
- }
212
-
213
- // Floating labelled bar for the unfolded portrait display, QR pinned in its own platter beside it.
214
- @Composable
215
- private fun BoxScope.DuoFloatingTabBar(
216
- layout: ScreenLayout,
217
- items: List<BottomTabItem>,
218
- floatingButton: BottomTabFloatingButton?,
219
- selectedIndex: Int,
220
- onTabSelected: (Int) -> Unit,
221
- ) {
222
- val pressedIndex = remember { mutableStateOf<Int?>(null) }
223
-
224
- Row(
225
- modifier = Modifier
226
- .align(Alignment.BottomCenter)
227
- .fillMaxWidth()
228
- .absolutePadding(
229
- left = layout.insetLeft + DuoMetrics.floatingTabBarMargin,
230
- right = layout.insetRight + DuoMetrics.floatingTabBarMargin,
231
- )
232
- .padding(bottom = floatingTabBarBottom(layout.insetBottom)),
233
- horizontalArrangement = Arrangement.spacedBy(Spacing.S, Alignment.CenterHorizontally),
234
- ) {
235
- Box(
236
- modifier = Modifier
237
- .weight(1f, fill = false)
238
- .width(FLOATING_ITEM_WIDTH * items.size + FLOATING_PADDING * 2)
239
- .height(FLOATING_HEIGHT)
240
- .tabBarMaterial(RoundedCornerShape(FLOATING_HEIGHT / 2))
241
- .padding(FLOATING_PADDING)
242
- .setAutomationId("bottom_tab_bar")
243
- ) {
244
- BoxWithConstraints(Modifier.fillMaxSize()) {
245
- val cellWidth = maxWidth / items.size.coerceAtLeast(1)
246
- val bubbleOffset by animateDpAsState(
247
- targetValue = cellWidth * (pressedIndex.value ?: selectedIndex).coerceAtLeast(0),
248
- animationSpec = BUBBLE_SPRING,
249
- label = "DuoFloatingBubble",
250
- )
251
- Box(
252
- Modifier
253
- .offset(x = bubbleOffset)
254
- .width(cellWidth)
255
- .fillMaxHeight()
256
- .selectionLens(pressedIndex.value != null)
257
- )
258
- Row(Modifier.fillMaxSize()) {
259
- items.forEachIndexed { index, item ->
260
- FloatingCell(item, selected = index == selectedIndex, index, pressedIndex) {
261
- onTabSelected(index)
262
- }
263
- }
264
- }
265
- }
266
- }
267
- if (floatingButton != null) {
268
- QrButton(floatingButton, size = FLOATING_HEIGHT, Modifier.shadow(3.dp, CircleShape))
269
- }
270
- }
271
- }
272
-
273
- @Composable
274
- private fun RowScope.FloatingCell(
275
- item: BottomTabItem,
276
- selected: Boolean,
277
- index: Int,
278
- pressedIndex: MutableState<Int?>,
279
- onClick: () -> Unit,
280
- ) {
281
- val colors = AppTheme.current.colors
282
- Column(
283
- modifier = Modifier
284
- .weight(1f)
285
- .fillMaxHeight()
286
- .tabClickable(index, pressedIndex, onClick),
287
- horizontalAlignment = Alignment.CenterHorizontally,
288
- verticalArrangement = Arrangement.spacedBy(Spacing.XXS, Alignment.CenterVertically),
289
- ) {
290
- DuoTabIcon(item, selected)
291
- // like the system tab bar the label keeps its design size; Text grows it up to 5pt on the wide Duo displays
292
- val context = LocalContext.current
293
- val fixedScale = remember(context) {
294
- (context ?: MiniAppContext()).copy(userScaleRate = 1f, useOSScaleRate = false)
295
- }
296
- CompositionLocalProvider(LocalContext provides fixedScale) {
297
- Text(
298
- text = item.label,
299
- style = Typography.labelXsMedium,
300
- color = if (selected) colors.primary else colors.text.hint,
301
- maxLines = 1,
302
- overflow = TextOverflow.Ellipsis,
303
- )
304
- }
305
- }
306
- }
307
-
308
- // Tracks the finger so the selection lens jumps to the pressed tab before it is selected.
309
- @Composable
310
- private fun Modifier.tabClickable(index: Int, pressedIndex: MutableState<Int?>, onClick: () -> Unit): Modifier {
311
- val interactionSource = remember { MutableInteractionSource() }
312
- val pressed by interactionSource.collectIsPressedAsState()
313
- LaunchedEffect(pressed) {
314
- if (pressed) pressedIndex.value = index
315
- else if (pressedIndex.value == index) pressedIndex.value = null
316
- }
317
- return clickable(interactionSource = interactionSource, indication = null, role = Role.Tab, onClick = onClick)
318
- }
319
-
320
- // Selection bubble; while pressed it grows into a lens (80x54 to about 96x70).
321
- @Composable
322
- private fun Modifier.selectionLens(pressed: Boolean): Modifier {
323
- val lens by animateFloatAsState(if (pressed) 1f else 0f, LENS_SPRING, label = "DuoSelectionLens")
324
- val tint = AppTheme.current.colors.primary.copy(alpha = SELECTION_TINT_ALPHA)
325
- return graphicsLayer {
326
- scaleX = 1 + lens * (LENS_SCALE_X - 1)
327
- scaleY = 1 + lens * (LENS_SCALE_Y - 1)
328
- }.background(tint, CircleShape)
329
- }
330
-
331
- @Composable
332
- private fun DuoTabIcon(item: BottomTabItem, selected: Boolean) {
333
- val colors = AppTheme.current.colors
334
- val badgeLabel = item.badgeLabel?.takeUnless { it.toIntOrNull() == 0 }
335
- Box {
336
- Icon(
337
- source = item.icon,
338
- size = ICON_SIZE,
339
- color = if (selected) colors.primary else colors.text.hint,
340
- )
341
- when {
342
- badgeLabel == null && !item.showDot -> Unit
343
- badgeLabel.isNullOrEmpty() -> BadgeDot(
344
- size = DotSize.Small,
345
- modifier = Modifier.align(Alignment.TopEnd),
346
- )
347
- else -> Badge(
348
- badgeLabel,
349
- modifier = Modifier.align(Alignment.TopStart).offset(x = ICON_SIZE / 2, y = -Spacing.XS),
350
- )
351
- }
352
- }
353
- }
354
-
355
- @Composable
356
- private fun QrButton(data: BottomTabFloatingButton, size: Dp, modifier: Modifier = Modifier) {
357
- Box(
358
- modifier = modifier
359
- .size(size)
360
- .clip(CircleShape)
361
- .background(AppTheme.current.colors.primary)
362
- .noFeedbackClickable(onClick = data.onPress)
363
- .setAutomationId(data.label),
364
- contentAlignment = Alignment.Center,
365
- ) {
366
- Icon(source = data.icon, color = Color.White, size = QR_ICON_SIZE)
367
- }
368
- }
369
-
370
- // RN BarMaterial: surface with a 1dp border.
371
- @Composable
372
- private fun Modifier.tabBarMaterial(shape: Shape): Modifier {
373
- val colors = AppTheme.current.colors
374
- return shadow(3.dp, shape)
375
- .background(colors.background.surface)
376
- .border(1.dp, colors.border.default, shape)
377
- }