@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,86 +1,103 @@
|
|
|
1
1
|
package vn.momo.kits.navigation.bottomtab
|
|
2
2
|
|
|
3
|
-
import androidx.compose.foundation.Canvas
|
|
4
|
-
import androidx.compose.foundation.layout.Box
|
|
5
|
-
import androidx.compose.foundation.layout.height
|
|
6
|
-
import androidx.compose.foundation.layout.offset
|
|
7
|
-
import androidx.compose.foundation.layout.width
|
|
8
|
-
import androidx.compose.runtime.Composable
|
|
9
|
-
import androidx.compose.ui.Alignment
|
|
10
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
|
|
11
13
|
import androidx.compose.ui.graphics.Path
|
|
12
|
-
import androidx.compose.ui.
|
|
14
|
+
import androidx.compose.ui.graphics.Shape
|
|
15
|
+
import androidx.compose.ui.graphics.shadow.Shadow
|
|
16
|
+
import androidx.compose.ui.unit.Density
|
|
13
17
|
import androidx.compose.ui.unit.Dp
|
|
14
|
-
import androidx.compose.ui.unit.
|
|
18
|
+
import androidx.compose.ui.unit.DpOffset
|
|
19
|
+
import androidx.compose.ui.unit.LayoutDirection
|
|
15
20
|
import androidx.compose.ui.unit.dp
|
|
16
|
-
import androidx.compose.
|
|
21
|
+
import androidx.compose.foundation.background
|
|
22
|
+
import androidx.compose.foundation.border
|
|
23
|
+
import androidx.compose.runtime.Composable
|
|
17
24
|
import vn.momo.kits.const.AppTheme
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
internal
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
val circleSizePx = with(density) { circleSize.toPx() }
|
|
32
|
-
val tabBarItemIconSizePx = with(density) { tabBarItemIconSize.toPx() }
|
|
33
|
-
val circleOverSizePx = with(density) { circleOverSize.toPx() }
|
|
34
|
-
|
|
35
|
-
val circlePositionTop = circleSizePx - tabBarItemIconSizePx - 10f
|
|
36
|
-
val circleOverTop = circlePositionTop + circleOverSizePx
|
|
37
|
-
val circleR = circleSizePx / 2
|
|
38
|
-
val circleOverR = circleR + circleOverSizePx
|
|
39
|
-
|
|
40
|
-
val centerX = widthPx / 2
|
|
41
|
-
|
|
42
|
-
val curvedPath = getPath(
|
|
43
|
-
circleOverTop = circleOverTop,
|
|
44
|
-
centerX = centerX,
|
|
45
|
-
circleOverR = circleOverR,
|
|
46
|
-
widthPx = widthPx
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
Box(
|
|
50
|
-
contentAlignment = Alignment.BottomCenter
|
|
51
|
-
){
|
|
52
|
-
Canvas(
|
|
53
|
-
modifier = Modifier
|
|
54
|
-
.width(width)
|
|
55
|
-
.height(height)
|
|
56
|
-
.offset{ IntOffset(x = 0, y = 24) }
|
|
57
|
-
.zIndex(-1f)
|
|
58
|
-
) {
|
|
59
|
-
drawPath(path = curvedPath, color = theme.colors.background.surface)
|
|
26
|
+
// Rounded container, with the notch dipped into the top edge around `notchCenterX` (from the left).
|
|
27
|
+
internal class NotchedBarShape(
|
|
28
|
+
private val radius: Dp,
|
|
29
|
+
private val notchCenterX: Dp? = null,
|
|
30
|
+
) : Shape {
|
|
31
|
+
override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
|
|
32
|
+
val r = minOf(with(density) { radius.toPx() }, size.height / 2, size.width / 2)
|
|
33
|
+
val path = Path()
|
|
34
|
+
if (notchCenterX == null) {
|
|
35
|
+
path.addRoundRect(RoundRect(Rect(0f, 0f, size.width, size.height), CornerRadius(r)))
|
|
36
|
+
return Outline.Generic(path)
|
|
60
37
|
}
|
|
38
|
+
val cx = with(density) { notchCenterX.toPx() }
|
|
39
|
+
val unit = density.density
|
|
40
|
+
path.apply {
|
|
41
|
+
moveTo(r, 0f)
|
|
42
|
+
lineTo(cx - NOTCH_HALF_WIDTH * unit, 0f)
|
|
43
|
+
NOTCH_CURVES.forEach { (c1, c2, end) ->
|
|
44
|
+
cubicTo(
|
|
45
|
+
cx + c1.first * unit, c1.second * unit,
|
|
46
|
+
cx + c2.first * unit, c2.second * unit,
|
|
47
|
+
cx + end.first * unit, end.second * unit,
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
lineTo(size.width - r, 0f)
|
|
51
|
+
arcTo(Rect(size.width - 2 * r, 0f, size.width, 2 * r), -90f, 90f, false)
|
|
52
|
+
lineTo(size.width, size.height - r)
|
|
53
|
+
arcTo(Rect(size.width - 2 * r, size.height - 2 * r, size.width, size.height), 0f, 90f, false)
|
|
54
|
+
lineTo(r, size.height)
|
|
55
|
+
arcTo(Rect(0f, size.height - 2 * r, 2 * r, size.height), 90f, 90f, false)
|
|
56
|
+
lineTo(0f, r)
|
|
57
|
+
arcTo(Rect(0f, 0f, 2 * r, 2 * r), 180f, 90f, false)
|
|
58
|
+
close()
|
|
59
|
+
}
|
|
60
|
+
return Outline.Generic(path)
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
// The shape shrunk by `inset` on every side. A shadow cast from it with no spread is a shadow of the
|
|
65
|
+
// shape with spread -inset; dropShadow's own negative spread clips the blur of path outlines.
|
|
66
|
+
internal class InsetShape(private val shape: Shape, private val inset: Dp) : Shape {
|
|
67
|
+
override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
|
|
68
|
+
val insetPx = with(density) { inset.toPx() }
|
|
69
|
+
val inner = Size((size.width - 2 * insetPx).coerceAtLeast(0f), (size.height - 2 * insetPx).coerceAtLeast(0f))
|
|
70
|
+
val path = Path().apply {
|
|
71
|
+
addOutline(shape.createOutline(inner, layoutDirection, density))
|
|
72
|
+
translate(Offset(insetPx, insetPx))
|
|
73
|
+
}
|
|
74
|
+
return Outline.Generic(path)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
68
77
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
// Shadow with a negative spread, cast from the shrunk shape.
|
|
79
|
+
internal fun Modifier.spreadShadow(shape: Shape, shadow: Shadow): Modifier {
|
|
80
|
+
if (shadow.spread < 0.dp) {
|
|
81
|
+
return dropShadow(
|
|
82
|
+
InsetShape(shape, -shadow.spread),
|
|
83
|
+
Shadow(radius = shadow.radius, color = shadow.color, offset = shadow.offset, alpha = shadow.alpha),
|
|
73
84
|
)
|
|
85
|
+
}
|
|
86
|
+
return dropShadow(shape, shadow)
|
|
87
|
+
}
|
|
74
88
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
89
|
+
// Floating shadow follows the shape (Figma Shadow/floating: 12% blur 24, 4% y12 blur 32 spread -16).
|
|
90
|
+
@Composable
|
|
91
|
+
internal fun Modifier.tabBarContainer(shape: Shape): Modifier {
|
|
92
|
+
return dropShadow(shape, Shadow(radius = 24.dp, color = Color.Black, alpha = 0.12f))
|
|
93
|
+
.spreadShadow(
|
|
94
|
+
shape,
|
|
95
|
+
Shadow(radius = 32.dp, spread = (-16).dp, color = Color.Black, alpha = 0.04f, offset = DpOffset(0.dp, 12.dp)),
|
|
79
96
|
)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
97
|
+
.background(
|
|
98
|
+
AppTheme.current.colors.background.surface.copy(alpha = TabBarMetrics.backgroundOpacity),
|
|
99
|
+
shape,
|
|
100
|
+
)
|
|
101
|
+
// Figma .Nav/Background: 1px light-gray hairline defining the pill edge
|
|
102
|
+
.border(1.dp, AppTheme.current.colors.border.default, shape)
|
|
103
|
+
}
|
package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt
CHANGED
|
@@ -40,11 +40,7 @@ private val DEFAULT_TOOLBAR_HEIGHT = DuoMetrics.controlSize + Spacing.M + DuoMet
|
|
|
40
40
|
// Back, then the single button the toolbar folds into
|
|
41
41
|
private val COMPRESSED_TOOLBAR_HEIGHT = DuoMetrics.controlSize * 2 + Spacing.M
|
|
42
42
|
|
|
43
|
-
// Port of RN DuoBarCompression (HIG,
|
|
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)
|
|
43
|
+
// Port of RN DuoBarCompression (HIG Vertical controls): both whole, else one compressed (tap swaps), else both.
|
|
48
44
|
@Composable
|
|
49
45
|
internal fun rememberDuoBarCompression(
|
|
50
46
|
behavior: DuoBarCompressionBehavior,
|
|
@@ -1,109 +1,70 @@
|
|
|
1
1
|
package vn.momo.kits.navigation.bottomtab
|
|
2
2
|
|
|
3
|
-
import androidx.compose.animation.core.Spring
|
|
4
|
-
import androidx.compose.animation.core.animateDpAsState
|
|
5
|
-
import androidx.compose.animation.core.animateFloatAsState
|
|
6
|
-
import androidx.compose.animation.core.spring
|
|
7
|
-
import androidx.compose.foundation.background
|
|
8
3
|
import androidx.compose.foundation.clickable
|
|
9
|
-
import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
10
|
-
import androidx.compose.foundation.interaction.collectIsPressedAsState
|
|
11
|
-
import androidx.compose.foundation.border
|
|
12
4
|
import androidx.compose.foundation.layout.Arrangement
|
|
13
5
|
import androidx.compose.foundation.layout.Box
|
|
14
6
|
import androidx.compose.foundation.layout.BoxScope
|
|
15
|
-
import androidx.compose.foundation.layout.BoxWithConstraints
|
|
16
7
|
import androidx.compose.foundation.layout.Column
|
|
17
|
-
import androidx.compose.foundation.layout.Row
|
|
18
|
-
import androidx.compose.foundation.layout.RowScope
|
|
19
|
-
import androidx.compose.foundation.layout.absolutePadding
|
|
20
|
-
import androidx.compose.foundation.layout.fillMaxHeight
|
|
21
|
-
import androidx.compose.foundation.layout.fillMaxSize
|
|
22
|
-
import androidx.compose.foundation.layout.fillMaxWidth
|
|
23
8
|
import androidx.compose.foundation.layout.height
|
|
24
9
|
import androidx.compose.foundation.layout.offset
|
|
25
10
|
import androidx.compose.foundation.layout.padding
|
|
26
11
|
import androidx.compose.foundation.layout.size
|
|
27
12
|
import androidx.compose.foundation.layout.width
|
|
13
|
+
import androidx.compose.foundation.layout.absolutePadding
|
|
14
|
+
import androidx.compose.foundation.layout.wrapContentWidth
|
|
28
15
|
import androidx.compose.foundation.shape.CircleShape
|
|
29
16
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
30
17
|
import androidx.compose.runtime.Composable
|
|
31
|
-
import androidx.compose.runtime.CompositionLocalProvider
|
|
32
|
-
import androidx.compose.runtime.LaunchedEffect
|
|
33
|
-
import androidx.compose.runtime.MutableState
|
|
34
18
|
import androidx.compose.runtime.compositionLocalOf
|
|
35
|
-
import androidx.compose.runtime.getValue
|
|
36
|
-
import androidx.compose.runtime.mutableStateOf
|
|
37
|
-
import androidx.compose.runtime.remember
|
|
38
19
|
import androidx.compose.ui.AbsoluteAlignment
|
|
39
20
|
import androidx.compose.ui.Alignment
|
|
40
21
|
import androidx.compose.ui.Modifier
|
|
41
|
-
import androidx.compose.ui.draw.clip
|
|
42
|
-
import androidx.compose.ui.draw.shadow
|
|
43
|
-
import androidx.compose.ui.graphics.graphicsLayer
|
|
44
22
|
import androidx.compose.ui.graphics.Color
|
|
45
|
-
import androidx.compose.ui.
|
|
23
|
+
import androidx.compose.ui.platform.LocalDensity
|
|
46
24
|
import androidx.compose.ui.semantics.Role
|
|
47
|
-
import androidx.compose.ui.
|
|
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
|
|
48
30
|
import androidx.compose.ui.unit.Dp
|
|
49
31
|
import androidx.compose.ui.unit.dp
|
|
50
|
-
import vn.momo.kits.application.LocalContext
|
|
51
|
-
import vn.momo.kits.application.MiniAppContext
|
|
52
|
-
import vn.momo.kits.components.Badge
|
|
53
|
-
import vn.momo.kits.components.BadgeDot
|
|
54
|
-
import vn.momo.kits.components.DotSize
|
|
55
32
|
import vn.momo.kits.components.Icon
|
|
56
|
-
import vn.momo.kits.components.Text
|
|
57
33
|
import vn.momo.kits.const.AppTheme
|
|
34
|
+
import vn.momo.kits.const.Colors
|
|
35
|
+
import vn.momo.kits.const.Radius
|
|
58
36
|
import vn.momo.kits.const.Spacing
|
|
59
|
-
import vn.momo.kits.const.Typography
|
|
60
37
|
import vn.momo.kits.layout.DuoMetrics
|
|
61
38
|
import vn.momo.kits.layout.ScreenLayout
|
|
62
39
|
import vn.momo.kits.layout.SideBarEdge
|
|
63
40
|
import vn.momo.kits.modifier.noFeedbackClickable
|
|
64
41
|
import vn.momo.kits.modifier.setAutomationId
|
|
65
42
|
|
|
66
|
-
// Figma
|
|
67
|
-
private val
|
|
68
|
-
private val ICON_SIZE = 28.dp
|
|
69
|
-
private val QR_ICON_SIZE = 24.dp
|
|
70
|
-
private val RAIL_PADDING = 6.dp
|
|
71
|
-
private val RAIL_GAP = Spacing.XXS
|
|
72
|
-
// selection bubble overflows the 48 rail cell by 5 above and below
|
|
73
|
-
private val RAIL_BUBBLE_WIDTH = 44.dp
|
|
74
|
-
private val RAIL_BUBBLE_HEIGHT = 58.dp
|
|
75
|
-
private val FLOATING_HEIGHT = DuoMetrics.floatingTabBarHeight
|
|
76
|
-
private val FLOATING_PADDING = Spacing.XS
|
|
77
|
-
// the system bar sizes its pill to the tabs instead of stretching it across the display
|
|
78
|
-
private val FLOATING_ITEM_WIDTH = 80.dp
|
|
79
|
-
// while pressed the selection bubble grows into a lens past the pill's edges
|
|
80
|
-
private const val LENS_SCALE_X = 1.2f
|
|
81
|
-
private const val LENS_SCALE_Y = 1.3f
|
|
82
|
-
// Figma Home-2026 tab bar "Selection": brand pink at 8%
|
|
83
|
-
private const val SELECTION_TINT_ALPHA = 0x14 / 255f
|
|
84
|
-
// RN reanimated spring { damping: 18, stiffness: 220, mass: 0.8 }
|
|
85
|
-
private val BUBBLE_SPRING = spring<Dp>(dampingRatio = 0.68f, stiffness = 275f, visibilityThreshold = Dp(0.5f))
|
|
86
|
-
private val LENS_SPRING = spring<Float>(dampingRatio = 0.68f, stiffness = 275f)
|
|
43
|
+
// Figma "Specs Navigation" (DS-984) Vertical type, mirrored from RN DuoTabBar.tsx.
|
|
44
|
+
private val COMPACT_SIZE = DuoMetrics.controlSize
|
|
87
45
|
|
|
88
46
|
// Space from the window bottom the rail stack and its gap take, so the header side bar stays above it.
|
|
89
47
|
internal val LocalDuoRailReserve = compositionLocalOf { 0.dp }
|
|
90
48
|
|
|
91
|
-
// Rail plus the
|
|
49
|
+
// Rail container plus the center action under it; compressed, the rail is a single button.
|
|
92
50
|
internal fun duoRailHeight(itemCount: Int, hasQr: Boolean, compressed: Boolean = false): Dp {
|
|
93
|
-
val rail = if (compressed)
|
|
94
|
-
else
|
|
95
|
-
return rail + if (hasQr)
|
|
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
|
|
96
54
|
}
|
|
97
55
|
|
|
98
|
-
//
|
|
99
|
-
|
|
100
|
-
|
|
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) return 0.dp
|
|
60
|
+
val ctaLift = if (hasCenterAction) TabBarMetrics.ctaLift else 0.dp
|
|
61
|
+
return TabBarMetrics.height + tabBarBottomGap(layout.insetBottom) + ctaLift
|
|
62
|
+
}
|
|
101
63
|
|
|
102
|
-
//
|
|
103
|
-
internal
|
|
104
|
-
if (layout.isIPhoneDuo && layout.sideBar == null) FLOATING_HEIGHT + floatingTabBarBottom(layout.insetBottom) else 0.dp
|
|
64
|
+
// Whether the tabs' bar shows the center action, whose button rises ctaLift above the container.
|
|
65
|
+
internal val LocalTabBarHasCenterAction = compositionLocalOf { false }
|
|
105
66
|
|
|
106
|
-
// iPhone Duo tab bar: rail in the side bar, or
|
|
67
|
+
// iPhone Duo tab bar: rail in the side bar, or the horizontal bar when unfolded portrait.
|
|
107
68
|
@Composable
|
|
108
69
|
internal fun BoxScope.DuoTabBar(
|
|
109
70
|
layout: ScreenLayout,
|
|
@@ -116,13 +77,26 @@ internal fun BoxScope.DuoTabBar(
|
|
|
116
77
|
if (layout.sideBar != null) {
|
|
117
78
|
DuoRailTabBar(layout, items, floatingButton, selectedIndex, onTabSelected, compression)
|
|
118
79
|
} else {
|
|
119
|
-
|
|
80
|
+
HorizontalTabBar(
|
|
81
|
+
items = items,
|
|
82
|
+
floatingButton = floatingButton,
|
|
83
|
+
selectedIndex = selectedIndex,
|
|
84
|
+
onTabSelected = onTabSelected,
|
|
85
|
+
modifier = Modifier
|
|
86
|
+
.align(Alignment.BottomCenter)
|
|
87
|
+
.padding(bottom = tabBarBottomGap(layout.insetBottom))
|
|
88
|
+
.width(
|
|
89
|
+
horizontalBarWidth(
|
|
90
|
+
layout.width, layout.height, layout.insetLeft, layout.insetRight,
|
|
91
|
+
items.size, hasCenterAction(floatingButton, items.size),
|
|
92
|
+
),
|
|
93
|
+
),
|
|
94
|
+
)
|
|
120
95
|
}
|
|
121
96
|
}
|
|
122
97
|
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
// tapping it expands the rail and compresses the toolbar.
|
|
98
|
+
// Rail at the bottom of the side bar, center action below. A short side bar shrinks it to the current
|
|
99
|
+
// tab's button (HIG "Tab bar compressed"); tapping it expands the rail and compresses the toolbar.
|
|
126
100
|
@Composable
|
|
127
101
|
private fun BoxScope.DuoRailTabBar(
|
|
128
102
|
layout: ScreenLayout,
|
|
@@ -135,26 +109,31 @@ private fun BoxScope.DuoRailTabBar(
|
|
|
135
109
|
val sideBar = layout.sideBar ?: return
|
|
136
110
|
val isRight = sideBar.edge == SideBarEdge.RIGHT
|
|
137
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
|
|
138
114
|
Column(
|
|
139
115
|
modifier = Modifier
|
|
140
116
|
.align(if (isRight) AbsoluteAlignment.BottomRight else AbsoluteAlignment.BottomLeft)
|
|
141
117
|
.width(sideBar.width)
|
|
142
118
|
.padding(bottom = sideBar.bottom)
|
|
143
|
-
.absolutePadding(left = if (isRight) Spacing.M else 0.dp, right = if (isRight) 0.dp else Spacing.M)
|
|
144
|
-
|
|
145
|
-
|
|
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),
|
|
146
124
|
) {
|
|
147
125
|
val current = items.getOrNull(selectedIndex)
|
|
148
126
|
if (compression.tabBarCompressed && current != null) {
|
|
149
|
-
|
|
127
|
+
Column(
|
|
150
128
|
modifier = Modifier
|
|
151
|
-
.size(
|
|
152
|
-
.
|
|
129
|
+
.size(COMPACT_SIZE)
|
|
130
|
+
.tabBarContainer(CircleShape)
|
|
153
131
|
.noFeedbackClickable(onClick = compression.expandTabBar)
|
|
154
132
|
.setAutomationId("bottom_tab_bar"),
|
|
155
|
-
|
|
133
|
+
horizontalAlignment = Alignment.CenterHorizontally,
|
|
134
|
+
verticalArrangement = Arrangement.Center,
|
|
156
135
|
) {
|
|
157
|
-
|
|
136
|
+
TabIcon(current, AppTheme.current.colors.primary, vertical = true)
|
|
158
137
|
}
|
|
159
138
|
} else {
|
|
160
139
|
Rail(items, selectedIndex) {
|
|
@@ -163,215 +142,67 @@ private fun BoxScope.DuoRailTabBar(
|
|
|
163
142
|
}
|
|
164
143
|
}
|
|
165
144
|
if (floatingButton != null) {
|
|
166
|
-
|
|
145
|
+
RailCenterAction(floatingButton)
|
|
167
146
|
}
|
|
168
147
|
}
|
|
169
148
|
}
|
|
170
149
|
|
|
171
|
-
// Column of
|
|
150
|
+
// Column of rail items (.Nav/Duo/Item) with the sliding active indicator.
|
|
172
151
|
@Composable
|
|
173
152
|
private fun Rail(items: List<BottomTabItem>, selectedIndex: Int, onItemClick: (Int) -> Unit) {
|
|
174
|
-
val
|
|
175
|
-
val bubbleOffset by animateDpAsState(
|
|
176
|
-
targetValue = (ITEM_SIZE + RAIL_GAP) * (pressedIndex.value ?: selectedIndex).coerceAtLeast(0),
|
|
177
|
-
animationSpec = BUBBLE_SPRING,
|
|
178
|
-
label = "DuoRailBubble",
|
|
179
|
-
)
|
|
153
|
+
val density = LocalDensity.current
|
|
180
154
|
Box(
|
|
181
155
|
Modifier
|
|
182
|
-
.
|
|
183
|
-
.
|
|
156
|
+
.wrapContentWidth(unbounded = true)
|
|
157
|
+
.width(TabBarMetrics.railContainerWidth)
|
|
158
|
+
.tabBarContainer(RoundedCornerShape(Radius.XL))
|
|
159
|
+
.padding(horizontal = TabBarMetrics.railPaddingHorizontal)
|
|
160
|
+
.padding(bottom = TabBarMetrics.railPaddingBottom)
|
|
184
161
|
.setAutomationId("bottom_tab_bar")
|
|
185
162
|
) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
)
|
|
192
|
-
.size(RAIL_BUBBLE_WIDTH, RAIL_BUBBLE_HEIGHT)
|
|
193
|
-
.selectionLens(pressedIndex.value != null)
|
|
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,
|
|
194
168
|
)
|
|
195
|
-
Column
|
|
196
|
-
modifier = Modifier.padding(vertical = RAIL_PADDING),
|
|
197
|
-
verticalArrangement = Arrangement.spacedBy(RAIL_GAP),
|
|
198
|
-
) {
|
|
169
|
+
Column {
|
|
199
170
|
items.forEachIndexed { index, item ->
|
|
200
|
-
|
|
171
|
+
Column(
|
|
201
172
|
modifier = Modifier
|
|
202
|
-
.size(
|
|
203
|
-
.
|
|
204
|
-
|
|
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,
|
|
205
182
|
) {
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// Floating labelled bar for the unfolded portrait display, QR pinned in its own platter beside it.
|
|
214
|
-
@Composable
|
|
215
|
-
private fun BoxScope.DuoFloatingTabBar(
|
|
216
|
-
layout: ScreenLayout,
|
|
217
|
-
items: List<BottomTabItem>,
|
|
218
|
-
floatingButton: BottomTabFloatingButton?,
|
|
219
|
-
selectedIndex: Int,
|
|
220
|
-
onTabSelected: (Int) -> Unit,
|
|
221
|
-
) {
|
|
222
|
-
val pressedIndex = remember { mutableStateOf<Int?>(null) }
|
|
223
|
-
|
|
224
|
-
Row(
|
|
225
|
-
modifier = Modifier
|
|
226
|
-
.align(Alignment.BottomCenter)
|
|
227
|
-
.fillMaxWidth()
|
|
228
|
-
.absolutePadding(
|
|
229
|
-
left = layout.insetLeft + DuoMetrics.floatingTabBarMargin,
|
|
230
|
-
right = layout.insetRight + DuoMetrics.floatingTabBarMargin,
|
|
231
|
-
)
|
|
232
|
-
.padding(bottom = floatingTabBarBottom(layout.insetBottom)),
|
|
233
|
-
horizontalArrangement = Arrangement.spacedBy(Spacing.S, Alignment.CenterHorizontally),
|
|
234
|
-
) {
|
|
235
|
-
Box(
|
|
236
|
-
modifier = Modifier
|
|
237
|
-
.weight(1f, fill = false)
|
|
238
|
-
.width(FLOATING_ITEM_WIDTH * items.size + FLOATING_PADDING * 2)
|
|
239
|
-
.height(FLOATING_HEIGHT)
|
|
240
|
-
.tabBarMaterial(RoundedCornerShape(FLOATING_HEIGHT / 2))
|
|
241
|
-
.padding(FLOATING_PADDING)
|
|
242
|
-
.setAutomationId("bottom_tab_bar")
|
|
243
|
-
) {
|
|
244
|
-
BoxWithConstraints(Modifier.fillMaxSize()) {
|
|
245
|
-
val cellWidth = maxWidth / items.size.coerceAtLeast(1)
|
|
246
|
-
val bubbleOffset by animateDpAsState(
|
|
247
|
-
targetValue = cellWidth * (pressedIndex.value ?: selectedIndex).coerceAtLeast(0),
|
|
248
|
-
animationSpec = BUBBLE_SPRING,
|
|
249
|
-
label = "DuoFloatingBubble",
|
|
250
|
-
)
|
|
251
|
-
Box(
|
|
252
|
-
Modifier
|
|
253
|
-
.offset(x = bubbleOffset)
|
|
254
|
-
.width(cellWidth)
|
|
255
|
-
.fillMaxHeight()
|
|
256
|
-
.selectionLens(pressedIndex.value != null)
|
|
257
|
-
)
|
|
258
|
-
Row(Modifier.fillMaxSize()) {
|
|
259
|
-
items.forEachIndexed { index, item ->
|
|
260
|
-
FloatingCell(item, selected = index == selectedIndex, index, pressedIndex) {
|
|
261
|
-
onTabSelected(index)
|
|
262
|
-
}
|
|
263
|
-
}
|
|
183
|
+
TabItemContent(item, selected = index == selectedIndex, vertical = true)
|
|
264
184
|
}
|
|
265
185
|
}
|
|
266
186
|
}
|
|
267
|
-
if (floatingButton != null) {
|
|
268
|
-
QrButton(floatingButton, size = FLOATING_HEIGHT, Modifier.shadow(3.dp, CircleShape))
|
|
269
|
-
}
|
|
270
187
|
}
|
|
271
188
|
}
|
|
272
189
|
|
|
190
|
+
// Center action of the rail: round button with its label, under the container.
|
|
273
191
|
@Composable
|
|
274
|
-
private fun
|
|
275
|
-
|
|
276
|
-
selected: Boolean,
|
|
277
|
-
index: Int,
|
|
278
|
-
pressedIndex: MutableState<Int?>,
|
|
279
|
-
onClick: () -> Unit,
|
|
280
|
-
) {
|
|
281
|
-
val colors = AppTheme.current.colors
|
|
192
|
+
private fun RailCenterAction(data: BottomTabFloatingButton) {
|
|
193
|
+
val (interactionSource, pressed) = rememberCenterActionPress()
|
|
282
194
|
Column(
|
|
283
195
|
modifier = Modifier
|
|
284
|
-
.
|
|
285
|
-
.
|
|
286
|
-
.
|
|
196
|
+
.wrapContentWidth(unbounded = true)
|
|
197
|
+
.size(TabBarMetrics.railCtaWidth, TabBarMetrics.railCtaHeight)
|
|
198
|
+
.clickable(interactionSource = interactionSource, indication = null, onClick = data.onPress)
|
|
199
|
+
.setAutomationId(data.label),
|
|
287
200
|
horizontalAlignment = Alignment.CenterHorizontally,
|
|
288
|
-
verticalArrangement = Arrangement.spacedBy(
|
|
201
|
+
verticalArrangement = Arrangement.spacedBy(TabBarMetrics.railCtaLabelGap, Alignment.CenterVertically),
|
|
289
202
|
) {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
val context = LocalContext.current
|
|
293
|
-
val fixedScale = remember(context) {
|
|
294
|
-
(context ?: MiniAppContext()).copy(userScaleRate = 1f, useOSScaleRate = false)
|
|
295
|
-
}
|
|
296
|
-
CompositionLocalProvider(LocalContext provides fixedScale) {
|
|
297
|
-
Text(
|
|
298
|
-
text = item.label,
|
|
299
|
-
style = Typography.labelXsMedium,
|
|
300
|
-
color = if (selected) colors.primary else colors.text.hint,
|
|
301
|
-
maxLines = 1,
|
|
302
|
-
overflow = TextOverflow.Ellipsis,
|
|
303
|
-
)
|
|
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)
|
|
304
205
|
}
|
|
206
|
+
CenterActionLabel(data.label, data.labelContent, vertical = true)
|
|
305
207
|
}
|
|
306
208
|
}
|
|
307
|
-
|
|
308
|
-
// Tracks the finger so the selection lens jumps to the pressed tab before it is selected.
|
|
309
|
-
@Composable
|
|
310
|
-
private fun Modifier.tabClickable(index: Int, pressedIndex: MutableState<Int?>, onClick: () -> Unit): Modifier {
|
|
311
|
-
val interactionSource = remember { MutableInteractionSource() }
|
|
312
|
-
val pressed by interactionSource.collectIsPressedAsState()
|
|
313
|
-
LaunchedEffect(pressed) {
|
|
314
|
-
if (pressed) pressedIndex.value = index
|
|
315
|
-
else if (pressedIndex.value == index) pressedIndex.value = null
|
|
316
|
-
}
|
|
317
|
-
return clickable(interactionSource = interactionSource, indication = null, role = Role.Tab, onClick = onClick)
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
// Selection bubble; while pressed it grows into a lens (80x54 to about 96x70).
|
|
321
|
-
@Composable
|
|
322
|
-
private fun Modifier.selectionLens(pressed: Boolean): Modifier {
|
|
323
|
-
val lens by animateFloatAsState(if (pressed) 1f else 0f, LENS_SPRING, label = "DuoSelectionLens")
|
|
324
|
-
val tint = AppTheme.current.colors.primary.copy(alpha = SELECTION_TINT_ALPHA)
|
|
325
|
-
return graphicsLayer {
|
|
326
|
-
scaleX = 1 + lens * (LENS_SCALE_X - 1)
|
|
327
|
-
scaleY = 1 + lens * (LENS_SCALE_Y - 1)
|
|
328
|
-
}.background(tint, CircleShape)
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
@Composable
|
|
332
|
-
private fun DuoTabIcon(item: BottomTabItem, selected: Boolean) {
|
|
333
|
-
val colors = AppTheme.current.colors
|
|
334
|
-
val badgeLabel = item.badgeLabel?.takeUnless { it.toIntOrNull() == 0 }
|
|
335
|
-
Box {
|
|
336
|
-
Icon(
|
|
337
|
-
source = item.icon,
|
|
338
|
-
size = ICON_SIZE,
|
|
339
|
-
color = if (selected) colors.primary else colors.text.hint,
|
|
340
|
-
)
|
|
341
|
-
when {
|
|
342
|
-
badgeLabel == null && !item.showDot -> Unit
|
|
343
|
-
badgeLabel.isNullOrEmpty() -> BadgeDot(
|
|
344
|
-
size = DotSize.Small,
|
|
345
|
-
modifier = Modifier.align(Alignment.TopEnd),
|
|
346
|
-
)
|
|
347
|
-
else -> Badge(
|
|
348
|
-
badgeLabel,
|
|
349
|
-
modifier = Modifier.align(Alignment.TopStart).offset(x = ICON_SIZE / 2, y = -Spacing.XS),
|
|
350
|
-
)
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
@Composable
|
|
356
|
-
private fun QrButton(data: BottomTabFloatingButton, size: Dp, modifier: Modifier = Modifier) {
|
|
357
|
-
Box(
|
|
358
|
-
modifier = modifier
|
|
359
|
-
.size(size)
|
|
360
|
-
.clip(CircleShape)
|
|
361
|
-
.background(AppTheme.current.colors.primary)
|
|
362
|
-
.noFeedbackClickable(onClick = data.onPress)
|
|
363
|
-
.setAutomationId(data.label),
|
|
364
|
-
contentAlignment = Alignment.Center,
|
|
365
|
-
) {
|
|
366
|
-
Icon(source = data.icon, color = Color.White, size = QR_ICON_SIZE)
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// RN BarMaterial: surface with a 1dp border.
|
|
371
|
-
@Composable
|
|
372
|
-
private fun Modifier.tabBarMaterial(shape: Shape): Modifier {
|
|
373
|
-
val colors = AppTheme.current.colors
|
|
374
|
-
return shadow(3.dp, shape)
|
|
375
|
-
.background(colors.background.surface)
|
|
376
|
-
.border(1.dp, colors.border.default, shape)
|
|
377
|
-
}
|