@momo-kits/native-kits 0.168.1-beta.4-debug → 0.168.1-beta.40-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 +15 -10
- package/README.md +2 -10
- package/build.gradle.kts +1 -3
- package/compose/build.gradle.kts +20 -19
- package/compose/build.gradle.kts.backup +19 -18
- package/compose/compose.podspec +1 -1
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +4 -3
- 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/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -14
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +62 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +14 -23
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +21 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +84 -82
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +18 -14
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +187 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +20 -13
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +117 -62
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +22 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +4 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +16 -26
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +54 -36
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +18 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +1 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +35 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +321 -149
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +79 -71
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +2 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +89 -198
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +104 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +1 -1
- 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 +30 -44
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +32 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +3 -2
- 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 +12 -3
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +3 -1
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +2 -6
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +12 -10
- 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 +60 -10
- package/gradle/libs.versions.toml +4 -11
- package/gradle/wrapper/gradle-wrapper.properties +1 -3
- package/gradle.properties +3 -3
- package/ios/Application/ApplicationEnvironment.swift +7 -6
- package/ios/Application/DesignSystemKits.swift +163 -0
- package/ios/Application/DesignSystemKitsPayload.swift +68 -0
- package/ios/Badge/BadgeRibbon.swift +8 -1
- package/ios/Extensions/Color++.swift +2 -4
- package/ios/Input/Input.swift +16 -4
- package/ios/Input/InputPhoneNumber.swift +1 -3
- package/ios/Input/InputSearch.swift +1 -2
- package/ios/Input/InputTextArea.swift +8 -4
- package/ios/InputMoney/InputMoney.swift +6 -7
- package/ios/Layout/ModalLayout.swift +152 -0
- package/ios/Layout/ScreenLayout.swift +77 -18
- package/ios/Navigation/BottomSheet.swift +56 -53
- package/ios/Navigation/BottomTab/BottomTab.swift +46 -52
- package/ios/Navigation/BottomTab/BottomTabBar.swift +281 -115
- package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +2 -3
- package/ios/Navigation/BottomTab/DuoTabBar.swift +64 -172
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +84 -0
- package/ios/Navigation/Component/HeaderBackground.swift +22 -1
- package/ios/Navigation/Component/HeaderRight.swift +1 -1
- package/ios/Navigation/Component/SnackBar.swift +4 -0
- package/ios/Navigation/ModalScreen.swift +20 -5
- package/ios/Navigation/StackScreen.swift +6 -8
- package/ios/Popup/PopupDisplay.swift +6 -4
- package/ios/Popup/PopupInput.swift +6 -4
- package/ios/Popup/PopupLayout.swift +17 -11
- package/ios/Popup/PopupNotify.swift +32 -25
- package/ios/Stepper/Stepper.swift +1 -2
- package/ios/Template/TrustBanner/TrustBanner.swift +4 -2
- package/ios/Typography/FontScale.swift +29 -15
- package/ios/Typography/Text.swift +88 -14
- package/ios/Typography/Typography.swift +2 -2
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- 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/BottomTabDemo.swift +272 -59
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +103 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
- package/package.json +1 -1
- package/publish.sh +2 -33
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +0 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +0 -22
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +0 -37
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +0 -41
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +0 -44
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +0 -62
- package/ios/Typography/FontScaleStore.swift +0 -58
- package/ios/Typography/KitDesignSystem.swift +0 -17
|
@@ -1,86 +1,94 @@
|
|
|
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.runtime.Composable
|
|
17
23
|
import vn.momo.kits.const.AppTheme
|
|
18
24
|
|
|
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)
|
|
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)
|
|
60
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)
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
+
}
|
|
68
76
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
)
|
|
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)
|
|
74
84
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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)),
|
|
79
93
|
)
|
|
80
|
-
|
|
81
|
-
lineTo(widthPx, circleOverTop)
|
|
82
|
-
lineTo(widthPx, 60f)
|
|
83
|
-
lineTo(0f, 60f)
|
|
84
|
-
close()
|
|
85
|
-
}
|
|
86
|
-
}
|
|
94
|
+
.background(AppTheme.current.colors.background.surface, shape)
|
package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt
CHANGED
|
@@ -39,8 +39,6 @@ internal val DUO_GROUP_GAP = Spacing.M
|
|
|
39
39
|
private val DEFAULT_TOOLBAR_HEIGHT = DuoMetrics.controlSize + Spacing.M + DuoMetrics.itemPitch * 2
|
|
40
40
|
// Back, then the single button the toolbar folds into
|
|
41
41
|
private val COMPRESSED_TOOLBAR_HEIGHT = DuoMetrics.controlSize * 2 + Spacing.M
|
|
42
|
-
// Back alone, while a rail opened from the compressed state takes the toolbar slot
|
|
43
|
-
private val BACK_ONLY_HEIGHT = DuoMetrics.controlSize
|
|
44
42
|
|
|
45
43
|
// Port of RN DuoBarCompression (HIG, Designing for iPhone Duo: Vertical controls):
|
|
46
44
|
// - both fit: both stay whole
|
|
@@ -78,7 +76,8 @@ internal fun rememberDuoBarCompression(
|
|
|
78
76
|
expandTabBar = { expanded = DuoBar.TAB_BAR },
|
|
79
77
|
setToolbarHeight = setToolbarHeight,
|
|
80
78
|
)
|
|
81
|
-
opened
|
|
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(
|
|
82
81
|
toolbarCompressed = true,
|
|
83
82
|
toolbarHidden = true,
|
|
84
83
|
expandToolbar = { opened = DuoBar.TOOLBAR },
|
|
@@ -1,88 +1,68 @@
|
|
|
1
1
|
package vn.momo.kits.navigation.bottomtab
|
|
2
2
|
|
|
3
|
-
import androidx.compose.
|
|
4
|
-
import androidx.compose.animation.core.animateDpAsState
|
|
5
|
-
import androidx.compose.animation.core.spring
|
|
6
|
-
import androidx.compose.foundation.background
|
|
7
|
-
import androidx.compose.foundation.border
|
|
3
|
+
import androidx.compose.foundation.clickable
|
|
8
4
|
import androidx.compose.foundation.layout.Arrangement
|
|
9
5
|
import androidx.compose.foundation.layout.Box
|
|
10
6
|
import androidx.compose.foundation.layout.BoxScope
|
|
11
|
-
import androidx.compose.foundation.layout.BoxWithConstraints
|
|
12
7
|
import androidx.compose.foundation.layout.Column
|
|
13
|
-
import androidx.compose.foundation.layout.Row
|
|
14
|
-
import androidx.compose.foundation.layout.RowScope
|
|
15
|
-
import androidx.compose.foundation.layout.absolutePadding
|
|
16
|
-
import androidx.compose.foundation.layout.fillMaxHeight
|
|
17
|
-
import androidx.compose.foundation.layout.fillMaxSize
|
|
18
8
|
import androidx.compose.foundation.layout.height
|
|
19
9
|
import androidx.compose.foundation.layout.offset
|
|
20
10
|
import androidx.compose.foundation.layout.padding
|
|
21
11
|
import androidx.compose.foundation.layout.size
|
|
22
12
|
import androidx.compose.foundation.layout.width
|
|
13
|
+
import androidx.compose.foundation.layout.absolutePadding
|
|
14
|
+
import androidx.compose.foundation.layout.wrapContentWidth
|
|
23
15
|
import androidx.compose.foundation.shape.CircleShape
|
|
24
16
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
25
17
|
import androidx.compose.runtime.Composable
|
|
26
18
|
import androidx.compose.runtime.compositionLocalOf
|
|
27
|
-
import androidx.compose.runtime.getValue
|
|
28
19
|
import androidx.compose.ui.AbsoluteAlignment
|
|
29
20
|
import androidx.compose.ui.Alignment
|
|
30
21
|
import androidx.compose.ui.Modifier
|
|
31
|
-
import androidx.compose.ui.draw.clip
|
|
32
|
-
import androidx.compose.ui.draw.shadow
|
|
33
22
|
import androidx.compose.ui.graphics.Color
|
|
34
|
-
import androidx.compose.ui.
|
|
35
|
-
import androidx.compose.ui.
|
|
23
|
+
import androidx.compose.ui.platform.LocalDensity
|
|
24
|
+
import androidx.compose.ui.semantics.Role
|
|
25
|
+
import androidx.compose.ui.semantics.contentDescription
|
|
26
|
+
import androidx.compose.ui.semantics.role
|
|
27
|
+
import androidx.compose.ui.semantics.selected
|
|
28
|
+
import androidx.compose.ui.semantics.semantics
|
|
29
|
+
import vn.momo.kits.modifier.activeOpacityClickable
|
|
36
30
|
import androidx.compose.ui.unit.Dp
|
|
37
31
|
import androidx.compose.ui.unit.dp
|
|
38
|
-
import vn.momo.kits.components.Badge
|
|
39
|
-
import vn.momo.kits.components.BadgeDot
|
|
40
|
-
import vn.momo.kits.components.DotSize
|
|
41
32
|
import vn.momo.kits.components.Icon
|
|
42
|
-
import vn.momo.kits.components.Text
|
|
43
33
|
import vn.momo.kits.const.AppTheme
|
|
34
|
+
import vn.momo.kits.const.Colors
|
|
44
35
|
import vn.momo.kits.const.Radius
|
|
45
36
|
import vn.momo.kits.const.Spacing
|
|
46
|
-
import vn.momo.kits.const.Typography
|
|
47
37
|
import vn.momo.kits.layout.DuoMetrics
|
|
48
38
|
import vn.momo.kits.layout.ScreenLayout
|
|
49
39
|
import vn.momo.kits.layout.SideBarEdge
|
|
50
40
|
import vn.momo.kits.modifier.noFeedbackClickable
|
|
51
41
|
import vn.momo.kits.modifier.setAutomationId
|
|
52
42
|
|
|
53
|
-
// Figma
|
|
54
|
-
private val
|
|
55
|
-
private val ICON_SIZE = 28.dp
|
|
56
|
-
private val QR_ICON_SIZE = 24.dp
|
|
57
|
-
private val RAIL_PADDING = 6.dp
|
|
58
|
-
private val RAIL_GAP = Spacing.XXS
|
|
59
|
-
// selection bubble overflows the 48 rail cell by 5 above and below
|
|
60
|
-
private val RAIL_BUBBLE_WIDTH = 44.dp
|
|
61
|
-
private val RAIL_BUBBLE_HEIGHT = 58.dp
|
|
62
|
-
private val FLOATING_HEIGHT = 62.dp
|
|
63
|
-
private val FLOATING_PADDING = Spacing.XS
|
|
64
|
-
private val FLOATING_QR_SIZE = 44.dp
|
|
65
|
-
// floating bar spans 6 of the 8 portrait grid columns, like the content
|
|
66
|
-
private const val GRID_COLUMNS = 8
|
|
67
|
-
private const val GRID_SPAN = 6
|
|
68
|
-
// RN reanimated spring { damping: 18, stiffness: 220, mass: 0.8 }
|
|
69
|
-
private val BUBBLE_SPRING = spring<Dp>(dampingRatio = 0.68f, stiffness = 275f, visibilityThreshold = Dp(0.5f))
|
|
43
|
+
// Figma "Specs Navigation" (DS-984) Vertical type, mirrored from RN DuoTabBar.tsx.
|
|
44
|
+
private val COMPACT_SIZE = DuoMetrics.controlSize
|
|
70
45
|
|
|
71
46
|
// Space from the window bottom the rail stack and its gap take, so the header side bar stays above it.
|
|
72
47
|
internal val LocalDuoRailReserve = compositionLocalOf { 0.dp }
|
|
73
48
|
|
|
74
|
-
// Rail plus the
|
|
49
|
+
// Rail container plus the center action under it; compressed, the rail is a single button.
|
|
75
50
|
internal fun duoRailHeight(itemCount: Int, hasQr: Boolean, compressed: Boolean = false): Dp {
|
|
76
|
-
val rail = if (compressed)
|
|
77
|
-
else
|
|
78
|
-
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
|
|
79
54
|
}
|
|
80
55
|
|
|
81
|
-
// Space tab content leaves under the floating bar
|
|
82
|
-
|
|
83
|
-
|
|
56
|
+
// Space tab content leaves under the floating horizontal bar (phone and unfolded Duo), the rising center
|
|
57
|
+
// action included; 0 when the Duo rail sits in the side strip.
|
|
58
|
+
internal fun duoFloatingTabBarInset(layout: ScreenLayout, hasCenterAction: Boolean = false): Dp =
|
|
59
|
+
if (layout.isIPhoneDuo && layout.sideBar != null) 0.dp
|
|
60
|
+
else TabBarMetrics.height + tabBarBottomGap(layout.insetBottom) + if (hasCenterAction) TabBarMetrics.ctaLift else 0.dp
|
|
61
|
+
|
|
62
|
+
// Whether the tabs' bar shows the center action, whose button rises ctaLift above the container.
|
|
63
|
+
internal val LocalTabBarHasCenterAction = compositionLocalOf { false }
|
|
84
64
|
|
|
85
|
-
// iPhone Duo tab bar:
|
|
65
|
+
// iPhone Duo tab bar: rail in the side bar, or the horizontal bar when unfolded portrait.
|
|
86
66
|
@Composable
|
|
87
67
|
internal fun BoxScope.DuoTabBar(
|
|
88
68
|
layout: ScreenLayout,
|
|
@@ -95,13 +75,23 @@ internal fun BoxScope.DuoTabBar(
|
|
|
95
75
|
if (layout.sideBar != null) {
|
|
96
76
|
DuoRailTabBar(layout, items, floatingButton, selectedIndex, onTabSelected, compression)
|
|
97
77
|
} else {
|
|
98
|
-
|
|
78
|
+
HorizontalTabBar(
|
|
79
|
+
items = items,
|
|
80
|
+
floatingButton = floatingButton,
|
|
81
|
+
selectedIndex = selectedIndex,
|
|
82
|
+
onTabSelected = onTabSelected,
|
|
83
|
+
fixedFontScale = true,
|
|
84
|
+
modifier = Modifier
|
|
85
|
+
.align(Alignment.BottomCenter)
|
|
86
|
+
.padding(bottom = tabBarBottomGap(layout.insetBottom))
|
|
87
|
+
.width(horizontalBarWidth(layout.width, layout.height, layout.insetLeft, layout.insetRight)),
|
|
88
|
+
)
|
|
99
89
|
}
|
|
100
90
|
}
|
|
101
91
|
|
|
102
|
-
// Vertical bar anchored to the bottom of the side bar,
|
|
103
|
-
//
|
|
104
|
-
//
|
|
92
|
+
// Vertical bar anchored to the bottom of the side bar, center action below it. When the side bar is
|
|
93
|
+
// short it can shrink to one button showing the current tab (HIG "Tab bar compressed"); tapping it
|
|
94
|
+
// expands the rail and compresses the toolbar.
|
|
105
95
|
@Composable
|
|
106
96
|
private fun BoxScope.DuoRailTabBar(
|
|
107
97
|
layout: ScreenLayout,
|
|
@@ -114,26 +104,31 @@ private fun BoxScope.DuoRailTabBar(
|
|
|
114
104
|
val sideBar = layout.sideBar ?: return
|
|
115
105
|
val isRight = sideBar.edge == SideBarEdge.RIGHT
|
|
116
106
|
|
|
107
|
+
// the rail lines up with the header buttons in the side bar: centered on a 48 lane kept Spacing.M
|
|
108
|
+
// from the strip's inner edge; the wider rail and center action overflow the lane evenly
|
|
117
109
|
Column(
|
|
118
110
|
modifier = Modifier
|
|
119
111
|
.align(if (isRight) AbsoluteAlignment.BottomRight else AbsoluteAlignment.BottomLeft)
|
|
120
112
|
.width(sideBar.width)
|
|
121
113
|
.padding(bottom = sideBar.bottom)
|
|
122
|
-
.absolutePadding(left = if (isRight) Spacing.M else 0.dp, right = if (isRight) 0.dp else Spacing.M)
|
|
123
|
-
|
|
124
|
-
|
|
114
|
+
.absolutePadding(left = if (isRight) Spacing.M else 0.dp, right = if (isRight) 0.dp else Spacing.M)
|
|
115
|
+
.wrapContentWidth(if (isRight) AbsoluteAlignment.Left else AbsoluteAlignment.Right)
|
|
116
|
+
.width(COMPACT_SIZE),
|
|
117
|
+
horizontalAlignment = Alignment.CenterHorizontally,
|
|
118
|
+
verticalArrangement = Arrangement.spacedBy(TabBarMetrics.railCtaGap),
|
|
125
119
|
) {
|
|
126
120
|
val current = items.getOrNull(selectedIndex)
|
|
127
121
|
if (compression.tabBarCompressed && current != null) {
|
|
128
|
-
|
|
122
|
+
Column(
|
|
129
123
|
modifier = Modifier
|
|
130
|
-
.size(
|
|
131
|
-
.
|
|
124
|
+
.size(COMPACT_SIZE)
|
|
125
|
+
.tabBarContainer(CircleShape)
|
|
132
126
|
.noFeedbackClickable(onClick = compression.expandTabBar)
|
|
133
127
|
.setAutomationId("bottom_tab_bar"),
|
|
134
|
-
|
|
128
|
+
horizontalAlignment = Alignment.CenterHorizontally,
|
|
129
|
+
verticalArrangement = Arrangement.Center,
|
|
135
130
|
) {
|
|
136
|
-
|
|
131
|
+
TabIcon(current, AppTheme.current.colors.primary, vertical = true)
|
|
137
132
|
}
|
|
138
133
|
} else {
|
|
139
134
|
Rail(items, selectedIndex) {
|
|
@@ -142,171 +137,67 @@ private fun BoxScope.DuoRailTabBar(
|
|
|
142
137
|
}
|
|
143
138
|
}
|
|
144
139
|
if (floatingButton != null) {
|
|
145
|
-
|
|
140
|
+
RailCenterAction(floatingButton)
|
|
146
141
|
}
|
|
147
142
|
}
|
|
148
143
|
}
|
|
149
144
|
|
|
150
|
-
//
|
|
145
|
+
// Column of rail items (.Nav/Duo/Item) with the sliding active indicator.
|
|
151
146
|
@Composable
|
|
152
147
|
private fun Rail(items: List<BottomTabItem>, selectedIndex: Int, onItemClick: (Int) -> Unit) {
|
|
153
|
-
val
|
|
154
|
-
targetValue = (ITEM_SIZE + RAIL_GAP) * selectedIndex.coerceAtLeast(0),
|
|
155
|
-
animationSpec = BUBBLE_SPRING,
|
|
156
|
-
label = "DuoRailBubble",
|
|
157
|
-
)
|
|
148
|
+
val density = LocalDensity.current
|
|
158
149
|
Box(
|
|
159
150
|
Modifier
|
|
160
|
-
.
|
|
161
|
-
.
|
|
151
|
+
.wrapContentWidth(unbounded = true)
|
|
152
|
+
.width(TabBarMetrics.railContainerWidth)
|
|
153
|
+
.tabBarContainer(RoundedCornerShape(Radius.XL))
|
|
154
|
+
.padding(horizontal = TabBarMetrics.railPaddingHorizontal)
|
|
155
|
+
.padding(bottom = TabBarMetrics.railPaddingBottom)
|
|
162
156
|
.setAutomationId("bottom_tab_bar")
|
|
163
157
|
) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
)
|
|
170
|
-
.size(RAIL_BUBBLE_WIDTH, RAIL_BUBBLE_HEIGHT)
|
|
171
|
-
.background(AppTheme.current.colors.background.selected, CircleShape)
|
|
158
|
+
ActiveIndicator(
|
|
159
|
+
offset = with(density) { (Spacing.XS + TabBarMetrics.railItemHeight * selectedIndex.coerceAtLeast(0)).toPx() },
|
|
160
|
+
modifier = Modifier.size(TabBarMetrics.railItemWidth, TabBarMetrics.railIndicatorHeight),
|
|
161
|
+
shape = RoundedCornerShape(TabBarMetrics.railIndicatorRadius),
|
|
162
|
+
axisX = false,
|
|
172
163
|
)
|
|
173
|
-
Column
|
|
174
|
-
modifier = Modifier.padding(vertical = RAIL_PADDING),
|
|
175
|
-
verticalArrangement = Arrangement.spacedBy(RAIL_GAP),
|
|
176
|
-
) {
|
|
164
|
+
Column {
|
|
177
165
|
items.forEachIndexed { index, item ->
|
|
178
|
-
|
|
166
|
+
Column(
|
|
179
167
|
modifier = Modifier
|
|
180
|
-
.size(
|
|
181
|
-
.
|
|
182
|
-
|
|
168
|
+
.size(TabBarMetrics.railItemWidth, TabBarMetrics.railItemHeight)
|
|
169
|
+
.activeOpacityClickable { onItemClick(index) }
|
|
170
|
+
.semantics {
|
|
171
|
+
role = Role.Tab
|
|
172
|
+
selected = index == selectedIndex
|
|
173
|
+
contentDescription = item.label
|
|
174
|
+
},
|
|
175
|
+
horizontalAlignment = Alignment.CenterHorizontally,
|
|
176
|
+
verticalArrangement = Arrangement.Center,
|
|
183
177
|
) {
|
|
184
|
-
|
|
178
|
+
TabItemContent(item, selected = index == selectedIndex, vertical = true, fixedFontScale = true)
|
|
185
179
|
}
|
|
186
180
|
}
|
|
187
181
|
}
|
|
188
182
|
}
|
|
189
183
|
}
|
|
190
184
|
|
|
185
|
+
// Center action of the rail: round button with its label, under the container.
|
|
191
186
|
@Composable
|
|
192
|
-
private fun
|
|
193
|
-
|
|
194
|
-
items: List<BottomTabItem>,
|
|
195
|
-
floatingButton: BottomTabFloatingButton?,
|
|
196
|
-
selectedIndex: Int,
|
|
197
|
-
onTabSelected: (Int) -> Unit,
|
|
198
|
-
) {
|
|
199
|
-
val columnWidth = (layout.width - Spacing.M * 2 - Spacing.M * (GRID_COLUMNS - 1)) / GRID_COLUMNS
|
|
200
|
-
val barWidth = columnWidth * GRID_SPAN + Spacing.M * (GRID_SPAN - 1)
|
|
201
|
-
val useQr = floatingButton != null && items.size % 2 == 0
|
|
202
|
-
val middle = items.size / 2
|
|
203
|
-
val cellCount = items.size + if (useQr) 1 else 0
|
|
204
|
-
val visualIndex = if (useQr && selectedIndex >= middle) selectedIndex + 1 else selectedIndex
|
|
205
|
-
|
|
206
|
-
Box(
|
|
207
|
-
modifier = Modifier
|
|
208
|
-
.align(Alignment.BottomCenter)
|
|
209
|
-
.padding(bottom = layout.insetBottom + Spacing.M)
|
|
210
|
-
.width(barWidth)
|
|
211
|
-
.height(FLOATING_HEIGHT)
|
|
212
|
-
.tabBarMaterial(RoundedCornerShape(FLOATING_HEIGHT / 2))
|
|
213
|
-
.padding(FLOATING_PADDING)
|
|
214
|
-
.setAutomationId("bottom_tab_bar")
|
|
215
|
-
) {
|
|
216
|
-
BoxWithConstraints(Modifier.fillMaxSize()) {
|
|
217
|
-
val cellWidth = maxWidth / cellCount
|
|
218
|
-
val bubbleOffset by animateDpAsState(
|
|
219
|
-
targetValue = cellWidth * visualIndex.coerceAtLeast(0),
|
|
220
|
-
animationSpec = BUBBLE_SPRING,
|
|
221
|
-
label = "DuoFloatingBubble",
|
|
222
|
-
)
|
|
223
|
-
Box(
|
|
224
|
-
Modifier
|
|
225
|
-
.offset(x = bubbleOffset)
|
|
226
|
-
.width(cellWidth)
|
|
227
|
-
.fillMaxHeight()
|
|
228
|
-
.background(AppTheme.current.colors.background.selected, CircleShape)
|
|
229
|
-
)
|
|
230
|
-
Row(Modifier.fillMaxSize()) {
|
|
231
|
-
items.forEachIndexed { index, item ->
|
|
232
|
-
if (useQr && index == middle) {
|
|
233
|
-
Box(Modifier.weight(1f).fillMaxHeight(), contentAlignment = Alignment.Center) {
|
|
234
|
-
QrButton(floatingButton, size = FLOATING_QR_SIZE)
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
FloatingCell(item, selected = index == selectedIndex) { onTabSelected(index) }
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
@Composable
|
|
245
|
-
private fun RowScope.FloatingCell(item: BottomTabItem, selected: Boolean, onClick: () -> Unit) {
|
|
246
|
-
val colors = AppTheme.current.colors
|
|
187
|
+
private fun RailCenterAction(data: BottomTabFloatingButton) {
|
|
188
|
+
val (interactionSource, pressed) = rememberCenterActionPress()
|
|
247
189
|
Column(
|
|
248
190
|
modifier = Modifier
|
|
249
|
-
.
|
|
250
|
-
.
|
|
251
|
-
.
|
|
191
|
+
.wrapContentWidth(unbounded = true)
|
|
192
|
+
.size(TabBarMetrics.railCtaWidth, TabBarMetrics.railCtaHeight)
|
|
193
|
+
.clickable(interactionSource = interactionSource, indication = null, onClick = data.onPress)
|
|
194
|
+
.setAutomationId(data.label),
|
|
252
195
|
horizontalAlignment = Alignment.CenterHorizontally,
|
|
253
|
-
verticalArrangement = Arrangement.spacedBy(
|
|
196
|
+
verticalArrangement = Arrangement.spacedBy(TabBarMetrics.railCtaLabelGap, Alignment.CenterVertically),
|
|
254
197
|
) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
text = item.label,
|
|
258
|
-
style = Typography.labelXsMedium,
|
|
259
|
-
color = if (selected) colors.primary else colors.text.default,
|
|
260
|
-
maxLines = 1,
|
|
261
|
-
overflow = TextOverflow.Ellipsis,
|
|
262
|
-
)
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
@Composable
|
|
267
|
-
private fun DuoTabIcon(item: BottomTabItem, selected: Boolean) {
|
|
268
|
-
val colors = AppTheme.current.colors
|
|
269
|
-
val badgeLabel = item.badgeLabel?.takeUnless { it.toIntOrNull() == 0 }
|
|
270
|
-
Box {
|
|
271
|
-
Icon(
|
|
272
|
-
source = item.icon,
|
|
273
|
-
size = ICON_SIZE,
|
|
274
|
-
color = if (selected) colors.primary else colors.text.default,
|
|
275
|
-
)
|
|
276
|
-
when {
|
|
277
|
-
badgeLabel == null && !item.showDot -> Unit
|
|
278
|
-
badgeLabel.isNullOrEmpty() -> BadgeDot(
|
|
279
|
-
size = DotSize.Small,
|
|
280
|
-
modifier = Modifier.align(Alignment.TopEnd),
|
|
281
|
-
)
|
|
282
|
-
else -> Badge(
|
|
283
|
-
badgeLabel,
|
|
284
|
-
modifier = Modifier.align(Alignment.TopStart).offset(x = ICON_SIZE / 2, y = -Spacing.XS),
|
|
285
|
-
)
|
|
198
|
+
Box(Modifier.centerActionButton(TabBarMetrics.railCtaSize, pressed), contentAlignment = Alignment.Center) {
|
|
199
|
+
data.iconContent?.invoke() ?: Icon(source = data.icon, color = Colors.black_01, size = TabBarMetrics.ctaIconSize)
|
|
286
200
|
}
|
|
201
|
+
CenterActionLabel(data.label, data.labelContent, vertical = true, fixedFontScale = true)
|
|
287
202
|
}
|
|
288
203
|
}
|
|
289
|
-
|
|
290
|
-
@Composable
|
|
291
|
-
private fun QrButton(data: BottomTabFloatingButton, size: Dp) {
|
|
292
|
-
Box(
|
|
293
|
-
modifier = Modifier
|
|
294
|
-
.size(size)
|
|
295
|
-
.clip(CircleShape)
|
|
296
|
-
.background(AppTheme.current.colors.primary)
|
|
297
|
-
.noFeedbackClickable(onClick = data.onPress)
|
|
298
|
-
.setAutomationId(data.label),
|
|
299
|
-
contentAlignment = Alignment.Center,
|
|
300
|
-
) {
|
|
301
|
-
Icon(source = data.icon, color = Color.White, size = QR_ICON_SIZE)
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// RN falls back to this when native glass is missing; Compose has no backdrop blur, so it always does.
|
|
306
|
-
@Composable
|
|
307
|
-
private fun Modifier.tabBarMaterial(shape: Shape): Modifier {
|
|
308
|
-
val colors = AppTheme.current.colors
|
|
309
|
-
return shadow(3.dp, shape)
|
|
310
|
-
.background(colors.background.surface)
|
|
311
|
-
.border(1.dp, colors.border.default, shape)
|
|
312
|
-
}
|