@momo-kits/native-kits 0.168.1-beta.32 → 0.168.1-beta.32-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.
- package/build.gradle.kts +11 -0
- package/compose/build.gradle.kts +198 -0
- package/compose/build.gradle.kts.backup +198 -0
- package/compose/compose.podspec +47 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +20 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +154 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +110 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +62 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1071 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +357 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +128 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +542 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +231 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +189 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +478 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +114 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +265 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +235 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +223 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +265 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +185 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +343 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +84 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +370 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +308 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +90 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +330 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +220 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +473 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +207 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +92 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +560 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +125 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +207 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +501 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +236 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +17 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +287 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +321 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +52 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +502 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +148 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +116 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +205 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +422 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +732 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +148 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +240 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +389 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +94 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +97 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +203 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +106 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +169 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +455 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +105 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +399 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +192 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +92 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +20 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +118 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +42 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +219 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +138 -0
- package/gradle/libs.versions.toml +69 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/gradle.properties +26 -0
- package/gradlew +252 -0
- package/gradlew.bat +94 -0
- package/ios-demo/README.md +120 -0
- package/package.json +1 -1
- package/settings.gradle.kts +64 -0
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
package vn.momo.kits.navigation.bottomtab
|
|
2
|
+
|
|
3
|
+
import androidx.compose.runtime.getValue
|
|
4
|
+
import androidx.compose.animation.animateColorAsState
|
|
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.dropShadow
|
|
14
|
+
import androidx.compose.ui.draw.innerShadow
|
|
15
|
+
import androidx.compose.ui.graphics.Shape
|
|
16
|
+
import androidx.compose.ui.graphics.graphicsLayer
|
|
17
|
+
import androidx.compose.ui.layout.onPlaced
|
|
18
|
+
import androidx.compose.ui.layout.positionInParent
|
|
19
|
+
import androidx.compose.ui.platform.LocalDensity
|
|
20
|
+
import androidx.compose.ui.semantics.Role
|
|
21
|
+
import androidx.compose.ui.semantics.contentDescription
|
|
22
|
+
import androidx.compose.ui.semantics.role
|
|
23
|
+
import androidx.compose.ui.semantics.selected
|
|
24
|
+
import androidx.compose.ui.semantics.semantics
|
|
25
|
+
import androidx.compose.foundation.background
|
|
26
|
+
import androidx.compose.foundation.border
|
|
27
|
+
import androidx.compose.foundation.layout.*
|
|
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.remember
|
|
33
|
+
import androidx.compose.ui.Alignment
|
|
34
|
+
import androidx.compose.ui.Modifier
|
|
35
|
+
import androidx.compose.ui.text.style.TextAlign
|
|
36
|
+
import androidx.compose.ui.text.style.TextOverflow
|
|
37
|
+
import androidx.compose.ui.unit.dp
|
|
38
|
+
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
39
|
+
import vn.momo.kits.application.LocalContext
|
|
40
|
+
import vn.momo.kits.application.MiniAppContext
|
|
41
|
+
import vn.momo.kits.components.*
|
|
42
|
+
import vn.momo.kits.const.*
|
|
43
|
+
import vn.momo.kits.layout.getScreenLayout
|
|
44
|
+
import vn.momo.kits.modifier.InternalApi
|
|
45
|
+
import vn.momo.kits.modifier.activeOpacityClickable
|
|
46
|
+
import vn.momo.kits.modifier.conditional
|
|
47
|
+
import vn.momo.kits.modifier.setAutomationId
|
|
48
|
+
|
|
49
|
+
@InternalApi
|
|
50
|
+
const val BOTTOM_TAB_BAR_HEIGHT = 68
|
|
51
|
+
|
|
52
|
+
// Phone tab bar: the horizontal navigation bar filling the window, above the home indicator.
|
|
53
|
+
@Composable
|
|
54
|
+
internal fun BottomTabBar(
|
|
55
|
+
items: List<BottomTabItem>,
|
|
56
|
+
floatingButton: BottomTabFloatingButton? = null,
|
|
57
|
+
selectedIndex: Int,
|
|
58
|
+
onTabSelected: (Int) -> Unit,
|
|
59
|
+
) {
|
|
60
|
+
val layout = getScreenLayout()
|
|
61
|
+
Box(
|
|
62
|
+
modifier = Modifier
|
|
63
|
+
.fillMaxWidth()
|
|
64
|
+
.padding(bottom = tabBarBottomGap(layout.insetBottom)),
|
|
65
|
+
contentAlignment = Alignment.BottomCenter,
|
|
66
|
+
) {
|
|
67
|
+
HorizontalTabBar(
|
|
68
|
+
items = items,
|
|
69
|
+
floatingButton = floatingButton,
|
|
70
|
+
selectedIndex = selectedIndex,
|
|
71
|
+
onTabSelected = onTabSelected,
|
|
72
|
+
modifier = Modifier
|
|
73
|
+
.offset(x = (layout.insetLeft - layout.insetRight) / 2)
|
|
74
|
+
.width(horizontalBarWidth(layout.width, layout.height, layout.insetLeft, layout.insetRight)),
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Horizontal navigation bar: floating container, items split evenly; Special type puts the center
|
|
80
|
+
// action in a notch in the middle, rising ctaLift above the container. One active indicator slides
|
|
81
|
+
// behind the selected item.
|
|
82
|
+
@Composable
|
|
83
|
+
internal fun HorizontalTabBar(
|
|
84
|
+
items: List<BottomTabItem>,
|
|
85
|
+
floatingButton: BottomTabFloatingButton?,
|
|
86
|
+
selectedIndex: Int,
|
|
87
|
+
onTabSelected: (Int) -> Unit,
|
|
88
|
+
modifier: Modifier = Modifier,
|
|
89
|
+
fixedFontScale: Boolean = false,
|
|
90
|
+
) {
|
|
91
|
+
val cta = floatingButton?.takeIf { hasCenterAction(it, items.size) }
|
|
92
|
+
val mid = items.size / 2
|
|
93
|
+
val density = LocalDensity.current
|
|
94
|
+
val itemBounds = remember(items.size) { mutableStateMapOf<Int, Pair<Float, Float>>() }
|
|
95
|
+
|
|
96
|
+
BoxWithConstraints(modifier = modifier) {
|
|
97
|
+
val shape = remember(maxWidth, cta != null) {
|
|
98
|
+
NotchedBarShape(TabBarMetrics.height / 2, if (cta != null) maxWidth / 2 else null)
|
|
99
|
+
}
|
|
100
|
+
Box(
|
|
101
|
+
modifier = Modifier
|
|
102
|
+
.padding(top = if (cta != null) TabBarMetrics.ctaLift else 0.dp)
|
|
103
|
+
.fillMaxWidth()
|
|
104
|
+
.height(TabBarMetrics.height)
|
|
105
|
+
.tabBarContainer(shape)
|
|
106
|
+
.padding(horizontal = TabBarMetrics.paddingHorizontal, vertical = TabBarMetrics.paddingVertical)
|
|
107
|
+
.setAutomationId("bottom_tab_bar"),
|
|
108
|
+
) {
|
|
109
|
+
itemBounds[selectedIndex]?.let { (x, width) ->
|
|
110
|
+
ActiveIndicator(
|
|
111
|
+
offset = x,
|
|
112
|
+
modifier = Modifier
|
|
113
|
+
.width(with(density) { width.toDp() })
|
|
114
|
+
.height(TabBarMetrics.indicatorHeight),
|
|
115
|
+
shape = RoundedCornerShape(TabBarMetrics.indicatorRadius),
|
|
116
|
+
axisX = true,
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
Row(
|
|
120
|
+
modifier = Modifier.fillMaxSize(),
|
|
121
|
+
horizontalArrangement = Arrangement.spacedBy(TabBarMetrics.itemGap),
|
|
122
|
+
verticalAlignment = Alignment.CenterVertically,
|
|
123
|
+
) {
|
|
124
|
+
items.forEachIndexed { index, item ->
|
|
125
|
+
if (cta != null && index == mid) {
|
|
126
|
+
Spacer(Modifier.width(TabBarMetrics.ctaSlotWidth))
|
|
127
|
+
}
|
|
128
|
+
TabBarItem(
|
|
129
|
+
item = item,
|
|
130
|
+
selected = index == selectedIndex,
|
|
131
|
+
fixedFontScale = fixedFontScale,
|
|
132
|
+
modifier = Modifier.onPlaced {
|
|
133
|
+
itemBounds[index] = it.positionInParent().x to it.size.width.toFloat()
|
|
134
|
+
},
|
|
135
|
+
onClick = { onTabSelected(index) },
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
cta?.let { CenterAction(it, fixedFontScale, Modifier.align(Alignment.TopCenter)) }
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// One active indicator per bar (Background/tonal with its inner shadows) sliding to the selected item
|
|
145
|
+
// along x (horizontal bar) or y (rail); it lands in place on the first measure and slides from then on.
|
|
146
|
+
@Composable
|
|
147
|
+
internal fun ActiveIndicator(offset: Float, modifier: Modifier, shape: Shape, axisX: Boolean) {
|
|
148
|
+
val colors = AppTheme.current.colors
|
|
149
|
+
val position = remember { Animatable(offset) }
|
|
150
|
+
LaunchedEffect(offset) {
|
|
151
|
+
if (position.value != offset) position.animateTo(offset, TabBarMotion.indicator)
|
|
152
|
+
}
|
|
153
|
+
Box(
|
|
154
|
+
modifier
|
|
155
|
+
.graphicsLayer {
|
|
156
|
+
if (axisX) translationX = position.value else translationY = position.value
|
|
157
|
+
}
|
|
158
|
+
.background(colors.background.tonal, shape)
|
|
159
|
+
.then(
|
|
160
|
+
indicatorInnerShadows(colors.primary).fold(Modifier as Modifier) { acc, shadow ->
|
|
161
|
+
acc.innerShadow(shape, shadow)
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@Composable
|
|
168
|
+
private fun RowScope.TabBarItem(
|
|
169
|
+
item: BottomTabItem,
|
|
170
|
+
selected: Boolean,
|
|
171
|
+
fixedFontScale: Boolean,
|
|
172
|
+
modifier: Modifier,
|
|
173
|
+
onClick: () -> Unit,
|
|
174
|
+
) {
|
|
175
|
+
Column(
|
|
176
|
+
modifier = modifier
|
|
177
|
+
.weight(1f)
|
|
178
|
+
.conditional(IsShowBaseLineDebug) {
|
|
179
|
+
border(1.dp, Colors.blue_03)
|
|
180
|
+
}
|
|
181
|
+
.activeOpacityClickable { onClick() }
|
|
182
|
+
.semantics {
|
|
183
|
+
role = Role.Tab
|
|
184
|
+
this.selected = selected
|
|
185
|
+
contentDescription = item.label
|
|
186
|
+
},
|
|
187
|
+
horizontalAlignment = Alignment.CenterHorizontally,
|
|
188
|
+
verticalArrangement = Arrangement.spacedBy(Spacing.XXS),
|
|
189
|
+
) {
|
|
190
|
+
TabItemContent(item, selected, fixedFontScale = fixedFontScale)
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Icon in its indicator slot, label under it. The bar slides one shared active indicator behind the
|
|
195
|
+
// slots; the icon and label tint cross-fade on focus.
|
|
196
|
+
@Composable
|
|
197
|
+
internal fun ColumnScope.TabItemContent(
|
|
198
|
+
item: BottomTabItem,
|
|
199
|
+
selected: Boolean,
|
|
200
|
+
vertical: Boolean = false,
|
|
201
|
+
showLabel: Boolean = true,
|
|
202
|
+
fixedFontScale: Boolean = false,
|
|
203
|
+
) {
|
|
204
|
+
val colors = AppTheme.current.colors
|
|
205
|
+
val tint by animateColorAsState(
|
|
206
|
+
if (selected) colors.primary else colors.text.secondary,
|
|
207
|
+
tween(TabBarMotion.TINT_MILLIS, easing = inOutQuad),
|
|
208
|
+
label = "TabTint",
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
Box(
|
|
212
|
+
modifier = Modifier
|
|
213
|
+
.then(if (vertical) Modifier else Modifier.fillMaxWidth())
|
|
214
|
+
.height(if (vertical) TabBarMetrics.railIndicatorHeight else TabBarMetrics.indicatorHeight)
|
|
215
|
+
.padding(horizontal = TabBarMetrics.indicatorPaddingHorizontal),
|
|
216
|
+
contentAlignment = Alignment.Center,
|
|
217
|
+
) {
|
|
218
|
+
TabIcon(item, tint, vertical)
|
|
219
|
+
}
|
|
220
|
+
if (showLabel) {
|
|
221
|
+
val label = @Composable {
|
|
222
|
+
Text(
|
|
223
|
+
text = item.label,
|
|
224
|
+
color = tint,
|
|
225
|
+
style = if (vertical) Typography.labelXsMedium else Typography.labelSMedium,
|
|
226
|
+
textAlign = TextAlign.Center,
|
|
227
|
+
maxLines = 1,
|
|
228
|
+
overflow = TextOverflow.Ellipsis,
|
|
229
|
+
modifier = if (vertical) Modifier else Modifier.fillMaxWidth(),
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
if (fixedFontScale) FixedFontScale(label) else label()
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Like the system tab bar the label keeps its design size; Text grows it up to 5pt on the wide Duo displays.
|
|
237
|
+
@Composable
|
|
238
|
+
internal fun FixedFontScale(content: @Composable () -> Unit) {
|
|
239
|
+
val context = LocalContext.current
|
|
240
|
+
val fixedScale = remember(context) {
|
|
241
|
+
(context ?: MiniAppContext()).copy(userScaleRate = 1f, useOSScaleRate = false)
|
|
242
|
+
}
|
|
243
|
+
CompositionLocalProvider(LocalContext provides fixedScale, content = content)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Badge value shown on a tab: null hides it, "" is a dot, numbers cap at 99+ ("0" hides it, RN parity).
|
|
247
|
+
internal fun tabBadgeLabel(item: BottomTabItem): String? {
|
|
248
|
+
val label = item.badgeLabel ?: return if (item.showDot) "" else null
|
|
249
|
+
if (label.isEmpty()) return ""
|
|
250
|
+
if (label.all { it in '0'..'9' }) {
|
|
251
|
+
val value = label.toLongOrNull() ?: Long.MAX_VALUE
|
|
252
|
+
if (value == 0L) return if (item.showDot) "" else null
|
|
253
|
+
return if (value > 99) "99+" else label
|
|
254
|
+
}
|
|
255
|
+
return label
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// 24 icon; badges hang off it unclipped: dot at 16/-2, label badge at 12/-7 growing right, or
|
|
259
|
+
// centered over the icon at -10 on the rail.
|
|
260
|
+
@Composable
|
|
261
|
+
internal fun TabIcon(item: BottomTabItem, tint: androidx.compose.ui.graphics.Color, vertical: Boolean) {
|
|
262
|
+
val badge = tabBadgeLabel(item)
|
|
263
|
+
Box(Modifier.size(TabBarMetrics.iconSize)) {
|
|
264
|
+
Icon(source = item.icon, size = TabBarMetrics.iconSize, color = tint)
|
|
265
|
+
when {
|
|
266
|
+
badge == null -> Unit
|
|
267
|
+
badge.isEmpty() -> BadgeDot(
|
|
268
|
+
size = DotSize.Small,
|
|
269
|
+
modifier = Modifier.offset(x = 16.dp, y = -Spacing.XXS),
|
|
270
|
+
)
|
|
271
|
+
vertical -> TabBadge(
|
|
272
|
+
badge,
|
|
273
|
+
Modifier.matchParentSize()
|
|
274
|
+
.wrapContentSize(Alignment.TopCenter, unbounded = true)
|
|
275
|
+
.offset(y = (-10).dp),
|
|
276
|
+
)
|
|
277
|
+
else -> TabBadge(
|
|
278
|
+
badge,
|
|
279
|
+
Modifier.matchParentSize()
|
|
280
|
+
.wrapContentSize(Alignment.TopStart, unbounded = true)
|
|
281
|
+
.offset(x = Spacing.M, y = (-7).dp),
|
|
282
|
+
)
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Numbers use the error color, text the warning color (Figma Badge round numeric / text); the text keeps
|
|
288
|
+
// its design size so it fits the 16 height on the Duo displays too.
|
|
289
|
+
@Composable
|
|
290
|
+
private fun TabBadge(label: String, modifier: Modifier) {
|
|
291
|
+
val colors = AppTheme.current.colors
|
|
292
|
+
val isNumber = label.trimEnd('+').let { it.isNotEmpty() && it.all { c -> c in '0'..'9' } }
|
|
293
|
+
Box(
|
|
294
|
+
modifier = modifier
|
|
295
|
+
.height(16.dp)
|
|
296
|
+
.widthIn(min = 16.dp, max = TabBarMetrics.badgeMaxWidth)
|
|
297
|
+
.background(if (isNumber) colors.error.primary else colors.warning.primary, CircleShape)
|
|
298
|
+
.border(1.dp, colors.background.surface, CircleShape)
|
|
299
|
+
.padding(horizontal = Spacing.XS),
|
|
300
|
+
contentAlignment = Alignment.Center,
|
|
301
|
+
) {
|
|
302
|
+
FixedFontScale {
|
|
303
|
+
Text(
|
|
304
|
+
text = label,
|
|
305
|
+
style = Typography.actionXxsBold,
|
|
306
|
+
color = Colors.black_01,
|
|
307
|
+
maxLines = 1,
|
|
308
|
+
overflow = TextOverflow.Ellipsis,
|
|
309
|
+
)
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// Center action press: the button shrinks while held; the label stays plain text.
|
|
315
|
+
@Composable
|
|
316
|
+
internal fun rememberCenterActionPress(): Pair<MutableInteractionSource, Boolean> {
|
|
317
|
+
val interactionSource = remember { MutableInteractionSource() }
|
|
318
|
+
val pressed by interactionSource.collectIsPressedAsState()
|
|
319
|
+
return interactionSource to pressed
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
@Composable
|
|
323
|
+
internal fun Modifier.centerActionPressScale(pressed: Boolean): Modifier {
|
|
324
|
+
val scale by animateFloatAsState(
|
|
325
|
+
if (pressed) TabBarMotion.CTA_PRESSED_SCALE else 1f,
|
|
326
|
+
tween(TabBarMotion.CTA_PRESS_MILLIS, easing = inOutQuad),
|
|
327
|
+
label = "CenterActionPress",
|
|
328
|
+
)
|
|
329
|
+
return graphicsLayer {
|
|
330
|
+
scaleX = scale
|
|
331
|
+
scaleY = scale
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
@Composable
|
|
336
|
+
internal fun Modifier.centerActionButton(size: androidx.compose.ui.unit.Dp, pressed: Boolean): Modifier {
|
|
337
|
+
return centerActionPressScale(pressed)
|
|
338
|
+
.size(size)
|
|
339
|
+
.then(CtaShadows.fold(Modifier as Modifier) { acc, shadow -> acc.spreadShadow(CircleShape, shadow) })
|
|
340
|
+
.background(AppTheme.current.colors.primary, CircleShape)
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
@Composable
|
|
344
|
+
internal fun CenterActionLabel(label: String, overlay: (@Composable () -> Unit)?, vertical: Boolean, fixedFontScale: Boolean) {
|
|
345
|
+
val colors = AppTheme.current.colors
|
|
346
|
+
val text = @Composable {
|
|
347
|
+
Text(
|
|
348
|
+
text = label,
|
|
349
|
+
style = if (vertical) Typography.labelXsMedium else Typography.labelSMedium,
|
|
350
|
+
color = colors.text.secondary,
|
|
351
|
+
textAlign = TextAlign.Center,
|
|
352
|
+
maxLines = 1,
|
|
353
|
+
overflow = TextOverflow.Ellipsis,
|
|
354
|
+
)
|
|
355
|
+
}
|
|
356
|
+
Box(
|
|
357
|
+
modifier = Modifier
|
|
358
|
+
.then(if (vertical) Modifier else Modifier.heightIn(min = TabBarMetrics.ctaLabelHeight))
|
|
359
|
+
.padding(horizontal = if (vertical) Spacing.XS else Spacing.XXS),
|
|
360
|
+
contentAlignment = Alignment.Center,
|
|
361
|
+
) {
|
|
362
|
+
if (fixedFontScale) FixedFontScale(text) else text()
|
|
363
|
+
overlay?.let {
|
|
364
|
+
Box(Modifier.matchParentSize().wrapContentSize(Alignment.Center, unbounded = true)) { it() }
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// Center action (.Nav/CTA): button rising out of the notch, label under it.
|
|
370
|
+
@Composable
|
|
371
|
+
private fun CenterAction(data: BottomTabFloatingButton, fixedFontScale: Boolean, modifier: Modifier) {
|
|
372
|
+
val (interactionSource, pressed) = rememberCenterActionPress()
|
|
373
|
+
Column(
|
|
374
|
+
modifier = modifier
|
|
375
|
+
.width(TabBarMetrics.ctaSlotWidth)
|
|
376
|
+
.conditional(IsShowBaseLineDebug) {
|
|
377
|
+
border(1.dp, Colors.blue_03)
|
|
378
|
+
}
|
|
379
|
+
.clickable(interactionSource = interactionSource, indication = null, onClick = data.onPress)
|
|
380
|
+
.setAutomationId(data.label),
|
|
381
|
+
horizontalAlignment = Alignment.CenterHorizontally,
|
|
382
|
+
verticalArrangement = Arrangement.spacedBy(TabBarMetrics.ctaLabelGap),
|
|
383
|
+
) {
|
|
384
|
+
Box(Modifier.centerActionButton(TabBarMetrics.ctaSize, pressed), contentAlignment = Alignment.Center) {
|
|
385
|
+
data.iconContent?.invoke() ?: Icon(source = data.icon, color = Colors.black_01, size = TabBarMetrics.ctaIconSize)
|
|
386
|
+
}
|
|
387
|
+
CenterActionLabel(data.label, data.labelContent, vertical = false, fixedFontScale = fixedFontScale)
|
|
388
|
+
}
|
|
389
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
package vn.momo.kits.navigation.bottomtab
|
|
2
|
+
|
|
3
|
+
import androidx.compose.ui.Modifier
|
|
4
|
+
import androidx.compose.ui.draw.dropShadow
|
|
5
|
+
import androidx.compose.ui.geometry.Rect
|
|
6
|
+
import androidx.compose.ui.geometry.RoundRect
|
|
7
|
+
import androidx.compose.ui.geometry.Size
|
|
8
|
+
import androidx.compose.ui.geometry.CornerRadius
|
|
9
|
+
import androidx.compose.ui.geometry.Offset
|
|
10
|
+
import androidx.compose.ui.graphics.addOutline
|
|
11
|
+
import androidx.compose.ui.graphics.Color
|
|
12
|
+
import androidx.compose.ui.graphics.Outline
|
|
13
|
+
import androidx.compose.ui.graphics.Path
|
|
14
|
+
import androidx.compose.ui.graphics.Shape
|
|
15
|
+
import androidx.compose.ui.graphics.shadow.Shadow
|
|
16
|
+
import androidx.compose.ui.unit.Density
|
|
17
|
+
import androidx.compose.ui.unit.Dp
|
|
18
|
+
import androidx.compose.ui.unit.DpOffset
|
|
19
|
+
import androidx.compose.ui.unit.LayoutDirection
|
|
20
|
+
import androidx.compose.ui.unit.dp
|
|
21
|
+
import androidx.compose.foundation.background
|
|
22
|
+
import androidx.compose.runtime.Composable
|
|
23
|
+
import vn.momo.kits.const.AppTheme
|
|
24
|
+
|
|
25
|
+
// Rounded container, with the notch dipped into the top edge around `notchCenterX` (from the left).
|
|
26
|
+
internal class NotchedBarShape(
|
|
27
|
+
private val radius: Dp,
|
|
28
|
+
private val notchCenterX: Dp? = null,
|
|
29
|
+
) : Shape {
|
|
30
|
+
override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
|
|
31
|
+
val r = minOf(with(density) { radius.toPx() }, size.height / 2, size.width / 2)
|
|
32
|
+
val path = Path()
|
|
33
|
+
if (notchCenterX == null) {
|
|
34
|
+
path.addRoundRect(RoundRect(Rect(0f, 0f, size.width, size.height), CornerRadius(r)))
|
|
35
|
+
return Outline.Generic(path)
|
|
36
|
+
}
|
|
37
|
+
val cx = with(density) { notchCenterX.toPx() }
|
|
38
|
+
val unit = density.density
|
|
39
|
+
path.apply {
|
|
40
|
+
moveTo(r, 0f)
|
|
41
|
+
lineTo(cx - NOTCH_HALF_WIDTH * unit, 0f)
|
|
42
|
+
NOTCH_CURVES.forEach { (c1, c2, end) ->
|
|
43
|
+
cubicTo(
|
|
44
|
+
cx + c1.first * unit, c1.second * unit,
|
|
45
|
+
cx + c2.first * unit, c2.second * unit,
|
|
46
|
+
cx + end.first * unit, end.second * unit,
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
lineTo(size.width - r, 0f)
|
|
50
|
+
arcTo(Rect(size.width - 2 * r, 0f, size.width, 2 * r), -90f, 90f, false)
|
|
51
|
+
lineTo(size.width, size.height - r)
|
|
52
|
+
arcTo(Rect(size.width - 2 * r, size.height - 2 * r, size.width, size.height), 0f, 90f, false)
|
|
53
|
+
lineTo(r, size.height)
|
|
54
|
+
arcTo(Rect(0f, size.height - 2 * r, 2 * r, size.height), 90f, 90f, false)
|
|
55
|
+
lineTo(0f, r)
|
|
56
|
+
arcTo(Rect(0f, 0f, 2 * r, 2 * r), 180f, 90f, false)
|
|
57
|
+
close()
|
|
58
|
+
}
|
|
59
|
+
return Outline.Generic(path)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// The shape shrunk by `inset` on every side. A shadow cast from it with no spread is a shadow of the
|
|
64
|
+
// shape with spread -inset; dropShadow's own negative spread clips the blur of path outlines.
|
|
65
|
+
internal class InsetShape(private val shape: Shape, private val inset: Dp) : Shape {
|
|
66
|
+
override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
|
|
67
|
+
val insetPx = with(density) { inset.toPx() }
|
|
68
|
+
val inner = Size((size.width - 2 * insetPx).coerceAtLeast(0f), (size.height - 2 * insetPx).coerceAtLeast(0f))
|
|
69
|
+
val path = Path().apply {
|
|
70
|
+
addOutline(shape.createOutline(inner, layoutDirection, density))
|
|
71
|
+
translate(Offset(insetPx, insetPx))
|
|
72
|
+
}
|
|
73
|
+
return Outline.Generic(path)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Shadow with a negative spread, cast from the shrunk shape.
|
|
78
|
+
internal fun Modifier.spreadShadow(shape: Shape, shadow: Shadow): Modifier =
|
|
79
|
+
if (shadow.spread < 0.dp) dropShadow(
|
|
80
|
+
InsetShape(shape, -shadow.spread),
|
|
81
|
+
Shadow(radius = shadow.radius, color = shadow.color, offset = shadow.offset, alpha = shadow.alpha),
|
|
82
|
+
)
|
|
83
|
+
else dropShadow(shape, shadow)
|
|
84
|
+
|
|
85
|
+
// Navigation bar container: surface fill with the floating shadow following the shape (Figma
|
|
86
|
+
// Shadow/floating: 12% blur 24, 4% y12 blur 32 spread -16).
|
|
87
|
+
@Composable
|
|
88
|
+
internal fun Modifier.tabBarContainer(shape: Shape): Modifier =
|
|
89
|
+
dropShadow(shape, Shadow(radius = 24.dp, color = Color.Black, alpha = 0.12f))
|
|
90
|
+
.spreadShadow(
|
|
91
|
+
shape,
|
|
92
|
+
Shadow(radius = 32.dp, spread = (-16).dp, color = Color.Black, alpha = 0.04f, offset = DpOffset(0.dp, 12.dp)),
|
|
93
|
+
)
|
|
94
|
+
.background(AppTheme.current.colors.background.surface, shape)
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
}
|