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