@momo-kits/native-kits 0.300.7-debug → 0.300.8-beta.1-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +12 -8
- package/README.md +8 -7
- package/compose/build.gradle.kts +2 -4
- package/compose/build.gradle.kts.backup +1 -3
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +1 -2
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +3 -2
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsBinding.kt +60 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsHost.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +20 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +5 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +7 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +18 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +15 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +4 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +13 -73
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +1 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -53
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +3 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +12 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +17 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +20 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +3 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +7 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +83 -82
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +6 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +9 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +13 -35
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +2 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +5 -22
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +6 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +55 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +1 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +3 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +22 -50
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +11 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +18 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +5 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +123 -64
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +24 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +16 -19
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +59 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +69 -51
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +14 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +5 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +43 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +330 -149
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +87 -70
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +92 -261
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +31 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +46 -72
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +8 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +29 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +8 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +9 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +26 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +1 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +4 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +2 -3
- package/compose/src/commonTest/kotlin/vn/momo/kits/application/KitsHostTest.kt +44 -0
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +2 -7
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +9 -18
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +1 -1
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +3 -6
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +5 -6
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +12 -12
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +11 -6
- package/gradle/libs.versions.toml +1 -3
- package/gradle.properties +1 -3
- package/ios/Application/ApplicationEnvironment.swift +6 -4
- package/ios/Application/DesignSystemKits.swift +59 -13
- package/ios/Application/DesignSystemKitsPayload.swift +0 -8
- package/ios/Application/LanguageSource.swift +2 -11
- package/ios/Application/Localize.swift +8 -35
- package/ios/Application/LocalizeModifier.swift +2 -11
- package/ios/Application/MaxApi.swift +3 -11
- package/ios/Avatar/Avatar.swift +0 -1
- package/ios/Badge/Badge.swift +5 -8
- package/ios/Badge/BadgeRibbon.swift +2 -5
- package/ios/Button/Button.swift +4 -8
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +5 -7
- package/ios/Carousel/Carousel.swift +4 -17
- package/ios/Checkbox/Checkbox.swift +0 -2
- package/ios/Collapse/Collapse.swift +17 -11
- package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
- package/ios/DateTimePicker/DateTimePicker.swift +4 -10
- package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
- package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
- package/ios/DateTimePicker/WheelPicker.swift +2 -4
- package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
- package/ios/Extensions/Color++.swift +2 -4
- package/ios/Extensions/SkeletonUICompat.swift +0 -8
- package/ios/Icon/Icon.swift +3 -6
- package/ios/IconButton/IconButton.swift +2 -5
- package/ios/Input/ErrorView.swift +0 -7
- package/ios/Input/Input.swift +9 -20
- package/ios/Input/InputPhoneNumber.swift +37 -20
- package/ios/Input/InputSearch.swift +23 -12
- package/ios/Input/InputTextArea.swift +4 -13
- package/ios/InputDropDown/InputDropDown.swift +1 -11
- package/ios/InputMoney/InputMoney.swift +9 -28
- package/ios/InputOTP/InputOTP.swift +2 -9
- package/ios/Layout/HeaderLayout.swift +72 -0
- package/ios/Layout/Item.swift +1 -2
- package/ios/Layout/ModalLayout.swift +144 -0
- package/ios/Layout/ScreenLayout.swift +48 -31
- package/ios/Layout/Section.swift +2 -3
- package/ios/Loader/Loader.swift +3 -12
- package/ios/Lottie/LottieView.swift +0 -11
- package/ios/Navigation/BottomSheet.swift +73 -94
- package/ios/Navigation/BottomTab/BottomTab.swift +58 -73
- package/ios/Navigation/BottomTab/BottomTabBar.swift +286 -121
- package/ios/Navigation/BottomTab/CurvedContainer.swift +52 -54
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +5 -12
- package/ios/Navigation/BottomTab/DuoTabBar.swift +67 -202
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +97 -0
- package/ios/Navigation/Component/FloatingButton.swift +4 -11
- package/ios/Navigation/Component/Header.swift +35 -54
- package/ios/Navigation/Component/HeaderBackground.swift +2 -8
- package/ios/Navigation/Component/HeaderJourney.swift +4 -8
- package/ios/Navigation/Component/HeaderLocation.swift +4 -8
- package/ios/Navigation/Component/HeaderRight.swift +20 -22
- package/ios/Navigation/Component/HeaderTitle.swift +1 -6
- package/ios/Navigation/Component/HeaderUser.swift +4 -10
- package/ios/Navigation/Component/SideBar.swift +6 -21
- package/ios/Navigation/Component/SnackBar.swift +9 -13
- package/ios/Navigation/HostBackGestureBridge.swift +2 -9
- package/ios/Navigation/ModalScreen.swift +24 -13
- package/ios/Navigation/Navigation.swift +35 -19
- package/ios/Navigation/NavigationContainer.swift +4 -15
- package/ios/Navigation/Navigator.swift +21 -39
- package/ios/Navigation/StackScreen.swift +64 -51
- package/ios/Navigation/StackTransition.swift +7 -14
- package/ios/Navigation/SwipeBackHaptic.swift +2 -7
- package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
- package/ios/Pagination/PaginationDot.swift +0 -9
- package/ios/Pagination/PaginationNumber.swift +1 -9
- package/ios/Pagination/PaginationScroll.swift +2 -14
- package/ios/Pagination/PaginationWhiteDot.swift +1 -10
- package/ios/Popup/PopupDisplay.swift +7 -5
- package/ios/Popup/PopupInput.swift +6 -4
- package/ios/Popup/PopupLayout.swift +17 -9
- package/ios/Popup/PopupNotify.swift +32 -25
- package/ios/PopupView/FullscreenPopup.swift +3 -4
- package/ios/PopupView/PopupView.swift +2 -2
- package/ios/PopupView/Utils++.swift +1 -2
- package/ios/ProgressInfo/ProgressInfo.swift +2 -13
- package/ios/Skeleton/Skeleton.swift +5 -16
- package/ios/Slider/Slider.swift +5 -12
- package/ios/StatusBarTap/StatusBarTap.h +2 -3
- package/ios/StatusBarTap/StatusBarTap.m +3 -16
- package/ios/Stepper/Stepper.swift +8 -27
- package/ios/Steps/Steps.swift +29 -26
- package/ios/Swipeable/SwipeCell.swift +2 -2
- package/ios/Swipeable/SwipeCellModel.swift +3 -6
- package/ios/TabView/TabView.swift +14 -28
- package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
- package/ios/Title/Title.swift +1 -3
- package/ios/Tooltip/Tooltip.swift +4 -9
- package/ios/Typography/FontScale.swift +79 -24
- package/ios/Typography/Text.swift +6 -12
- package/ios/Typography/Typography.swift +8 -11
- package/ios/Uploader/Uploader.swift +2 -17
- package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
- package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +11 -2
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +296 -59
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +15 -4
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +114 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +16 -0
- package/package.json +1 -1
- package/publish.sh +8 -2
- package/scripts/ci/build-swiftui.sh +22 -0
- package/scripts/ci/resolve-version.mjs +144 -0
- package/settings.gradle.kts +0 -1
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
package vn.momo.kits.navigation.bottomtab
|
|
2
2
|
|
|
3
|
+
import androidx.compose.runtime.getValue
|
|
4
|
+
import androidx.compose.runtime.setValue
|
|
3
5
|
import androidx.compose.animation.core.Animatable
|
|
4
6
|
import androidx.compose.animation.core.AnimationVector1D
|
|
7
|
+
import androidx.compose.animation.core.CubicBezierEasing
|
|
5
8
|
import androidx.compose.animation.core.Easing
|
|
6
9
|
import androidx.compose.animation.core.tween
|
|
7
10
|
import androidx.compose.foundation.background
|
|
@@ -10,14 +13,12 @@ import androidx.compose.runtime.Composable
|
|
|
10
13
|
import androidx.compose.runtime.CompositionLocalProvider
|
|
11
14
|
import androidx.compose.runtime.DisposableEffect
|
|
12
15
|
import androidx.compose.runtime.LaunchedEffect
|
|
13
|
-
import androidx.compose.runtime.getValue
|
|
14
16
|
import androidx.compose.runtime.key
|
|
15
17
|
import androidx.compose.runtime.mutableIntStateOf
|
|
16
18
|
import androidx.compose.runtime.mutableStateOf
|
|
17
19
|
import androidx.compose.runtime.remember
|
|
18
20
|
import androidx.compose.runtime.saveable.rememberSaveable
|
|
19
21
|
import androidx.compose.runtime.saveable.rememberSaveableStateHolder
|
|
20
|
-
import androidx.compose.runtime.setValue
|
|
21
22
|
import androidx.compose.runtime.staticCompositionLocalOf
|
|
22
23
|
import androidx.compose.ui.Alignment
|
|
23
24
|
import androidx.compose.ui.Modifier
|
|
@@ -25,11 +26,11 @@ import androidx.compose.ui.graphics.graphicsLayer
|
|
|
25
26
|
import androidx.compose.ui.layout.layout
|
|
26
27
|
import androidx.compose.ui.unit.dp
|
|
27
28
|
import androidx.compose.ui.zIndex
|
|
28
|
-
import
|
|
29
|
+
import kotlin.math.abs
|
|
30
|
+
import vn.momo.kits.components.ScaleSizeScope
|
|
29
31
|
import vn.momo.kits.const.AppTheme
|
|
30
|
-
import vn.momo.kits.const.Spacing
|
|
31
32
|
import vn.momo.kits.navigation.KeyboardOptions
|
|
32
|
-
import vn.momo.kits.navigation.
|
|
33
|
+
import vn.momo.kits.navigation.LocalKitsBinding
|
|
33
34
|
import vn.momo.kits.navigation.LocalNavigation
|
|
34
35
|
import vn.momo.kits.navigation.LocalNavigator
|
|
35
36
|
import vn.momo.kits.navigation.NavigationOptions
|
|
@@ -40,11 +41,14 @@ import vn.momo.kits.platform.reportFloatingArrowBack
|
|
|
40
41
|
import vn.momo.kits.layout.getScreenLayout
|
|
41
42
|
import kotlinx.coroutines.launch
|
|
42
43
|
// AI-GENERATED START: use the typed tab haptic pattern
|
|
43
|
-
import vn.momo.maxapi.contract.device.vibration.model.VibrateStyle
|
|
44
44
|
// AI-GENERATED END: use the typed tab haptic pattern
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
internal val inOutQuad = Easing { t -> if (t < 0.5f) 2 * t * t else 1 - 2 * (1 - t) * (1 - t) }
|
|
47
|
+
// the tab screens slide in index order over 280ms, CSS `ease`
|
|
48
|
+
private val tabSwitchSpec = tween<Float>(durationMillis = 280, easing = CubicBezierEasing(0.25f, 0.1f, 0.25f, 1f))
|
|
49
|
+
|
|
50
|
+
// -1 for tabs before the selected one, 1 for tabs after it: they wait a full width off screen on their side
|
|
51
|
+
private fun tabPosition(index: Int, selected: Int) = (index - selected).coerceIn(-1, 1).toFloat()
|
|
48
52
|
|
|
49
53
|
internal val LocalBottomTabFocused = staticCompositionLocalOf { true }
|
|
50
54
|
|
|
@@ -78,7 +82,7 @@ fun BottomTab(
|
|
|
78
82
|
) {
|
|
79
83
|
val navigation = LocalNavigation.current
|
|
80
84
|
val navigator = LocalNavigator.current
|
|
81
|
-
val
|
|
85
|
+
val binding = LocalKitsBinding.current
|
|
82
86
|
val startIndex = remember { items.indexOfFirst { it.name == initialRouteName }.coerceAtLeast(0) }
|
|
83
87
|
|
|
84
88
|
remember(items) {
|
|
@@ -108,14 +112,21 @@ fun BottomTab(
|
|
|
108
112
|
var lastFocusedIndex by rememberSaveable { mutableStateOf<Int?>(null) }
|
|
109
113
|
val tabProgress = remember { mutableMapOf<Int, Animatable<Float, AnimationVector1D>>() }
|
|
110
114
|
fun progressOf(index: Int) = tabProgress.getOrPut(index) {
|
|
111
|
-
Animatable(
|
|
115
|
+
Animatable(tabPosition(index, lastFocusedIndex ?: index))
|
|
112
116
|
}
|
|
113
117
|
LaunchedEffect(selectedIndex) {
|
|
118
|
+
val previousIndex = lastFocusedIndex
|
|
114
119
|
lastFocusedIndex = selectedIndex
|
|
115
120
|
tabProgress.forEach { (index, progress) ->
|
|
116
|
-
|
|
121
|
+
val target = tabPosition(index, selectedIndex)
|
|
122
|
+
launch {
|
|
123
|
+
if (index == selectedIndex || index == previousIndex) {
|
|
124
|
+
progress.animateTo(target, tabSwitchSpec)
|
|
125
|
+
} else {
|
|
126
|
+
progress.snapTo(target)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
117
129
|
}
|
|
118
|
-
progressOf(selectedIndex).animateTo(1f, tabTimingSpec)
|
|
119
130
|
}
|
|
120
131
|
|
|
121
132
|
DisposableEffect(isFirstTab) {
|
|
@@ -135,9 +146,7 @@ fun BottomTab(
|
|
|
135
146
|
it.bottom + duoRailHeight(items.size, hasQr, compressed = compression.tabBarCompressed) + DUO_GROUP_GAP
|
|
136
147
|
} ?: 0.dp
|
|
137
148
|
val onTabSelected: (Int) -> Unit = { index ->
|
|
138
|
-
|
|
139
|
-
runCatching { maxApi?.vibrate(VibrateStyle.LIGHT) }
|
|
140
|
-
// AI-GENERATED END: preserve the light haptic on tab selection
|
|
149
|
+
runCatching { binding?.vibrateLight() }
|
|
141
150
|
val switchTab = {
|
|
142
151
|
if (index != selectedIndex) selectTab(index)
|
|
143
152
|
}
|
|
@@ -152,21 +161,20 @@ fun BottomTab(
|
|
|
152
161
|
CompositionLocalProvider(
|
|
153
162
|
LocalDuoRailReserve provides railReserve,
|
|
154
163
|
LocalDuoBarCompression provides compression,
|
|
164
|
+
LocalTabBarHasCenterAction provides hasCenterAction(floatingButton, items.size),
|
|
155
165
|
) {
|
|
156
166
|
loadedTabs.forEach { index ->
|
|
157
167
|
val item = items.getOrNull(index) ?: return@forEach
|
|
158
168
|
val focused = index == selectedIndex
|
|
159
169
|
val progress = progressOf(index)
|
|
170
|
+
// the leaving tab stays drawn until it has slid off screen
|
|
171
|
+
val visible = focused || abs(progress.value) < 1f
|
|
160
172
|
key(index) {
|
|
161
173
|
Box(
|
|
162
174
|
Modifier
|
|
163
175
|
.fillMaxSize()
|
|
164
176
|
.zIndex(if (focused) 0f else -1f)
|
|
165
|
-
.then(if (
|
|
166
|
-
alpha = 0.3f + 0.7f * progress.value
|
|
167
|
-
scaleX = 0.97f + 0.03f * progress.value
|
|
168
|
-
scaleY = scaleX
|
|
169
|
-
} else Hidden)
|
|
177
|
+
.then(if (visible) Modifier.graphicsLayer { translationX = progress.value * size.width } else Hidden)
|
|
170
178
|
) {
|
|
171
179
|
CompositionLocalProvider(LocalBottomTabFocused provides focused) {
|
|
172
180
|
tabStateHolder.SaveableStateProvider(index) {
|
|
@@ -192,24 +200,23 @@ fun BottomTab(
|
|
|
192
200
|
BackHandler(enabled = !onFirstTab) {
|
|
193
201
|
if (backToInitialTab) backToFirstTab() else navigator.pop()
|
|
194
202
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
203
|
+
ScaleSizeScope(TabBarMetrics.LABEL_MAX_SCALE) {
|
|
204
|
+
if (layout.isIPhoneDuo) {
|
|
205
|
+
DuoTabBar(
|
|
206
|
+
layout = layout,
|
|
207
|
+
items = items,
|
|
208
|
+
floatingButton = floatingButton,
|
|
209
|
+
selectedIndex = selectedIndex,
|
|
210
|
+
onTabSelected = onTabSelected,
|
|
211
|
+
compression = compression,
|
|
212
|
+
)
|
|
213
|
+
} else {
|
|
206
214
|
BottomTabBar(
|
|
207
215
|
items = items,
|
|
208
216
|
floatingButton = floatingButton,
|
|
209
217
|
selectedIndex = selectedIndex,
|
|
210
218
|
onTabSelected = onTabSelected,
|
|
211
219
|
)
|
|
212
|
-
Spacer(modifier = Modifier.fillMaxWidth().height(AppNavigationBar.current + Spacing.S).background(AppTheme.current.colors.background.surface))
|
|
213
220
|
}
|
|
214
221
|
}
|
|
215
222
|
}
|
|
@@ -230,4 +237,8 @@ data class BottomTabFloatingButton(
|
|
|
230
237
|
val icon: String,
|
|
231
238
|
val label: String,
|
|
232
239
|
val onPress: () -> Unit,
|
|
240
|
+
// replaces the icon inside the 48 button, e.g. the button part of a Lottie; centered, unclipped
|
|
241
|
+
val iconContent: (@Composable () -> Unit)? = null,
|
|
242
|
+
// drawn over the label text, which stays, e.g. the label part of a Lottie; centered, unclipped
|
|
243
|
+
val labelContent: (@Composable () -> Unit)? = null,
|
|
233
244
|
)
|