@momo-kits/native-kits 0.162.51-debug → 0.162.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/build.gradle.kts +0 -11
- package/compose/build.gradle.kts +0 -198
- package/compose/build.gradle.kts.backup +0 -198
- package/compose/compose.podspec +0 -47
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -20
- package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -153
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -370
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -287
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -321
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -499
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -148
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -732
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -228
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -217
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -377
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -399
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -20
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -218
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -138
- package/gradle/libs.versions.toml +0 -69
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +0 -8
- package/gradle.properties +0 -26
- package/gradlew +0 -252
- package/gradlew.bat +0 -94
- package/ios-demo/README.md +0 -120
- package/settings.gradle.kts +0 -64
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
package vn.momo.kits.modifier
|
|
2
|
-
|
|
3
|
-
import androidx.compose.runtime.Composable
|
|
4
|
-
import androidx.compose.runtime.State
|
|
5
|
-
import androidx.compose.ui.Modifier
|
|
6
|
-
import androidx.compose.ui.layout.Measurable
|
|
7
|
-
import androidx.compose.ui.layout.MeasureResult
|
|
8
|
-
import androidx.compose.ui.layout.MeasureScope
|
|
9
|
-
import androidx.compose.ui.node.LayoutModifierNode
|
|
10
|
-
import androidx.compose.ui.node.ModifierNodeElement
|
|
11
|
-
import androidx.compose.ui.unit.Constraints
|
|
12
|
-
import androidx.compose.ui.unit.IntOffset
|
|
13
|
-
|
|
14
|
-
@Composable
|
|
15
|
-
fun Modifier.dynamicSize(
|
|
16
|
-
widthState: State<Int>? = null,
|
|
17
|
-
heightState: State<Int>? = null,
|
|
18
|
-
) = this then DynamicSizeElement(widthState, heightState)
|
|
19
|
-
|
|
20
|
-
private data class DynamicSizeElement(
|
|
21
|
-
val widthState: State<Int>?,
|
|
22
|
-
val heightState: State<Int>?,
|
|
23
|
-
) : ModifierNodeElement<DynamicSizeNode>() {
|
|
24
|
-
override fun create(): DynamicSizeNode {
|
|
25
|
-
return DynamicSizeNode(widthState, heightState)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
override fun update(node: DynamicSizeNode) {
|
|
29
|
-
node.widthState = widthState
|
|
30
|
-
node.heightState = heightState
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
private class DynamicSizeNode(
|
|
36
|
-
var widthState: State<Int>?,
|
|
37
|
-
var heightState: State<Int>?,
|
|
38
|
-
) : Modifier.Node(), LayoutModifierNode {
|
|
39
|
-
override fun MeasureScope.measure(
|
|
40
|
-
measurable: Measurable,
|
|
41
|
-
constraints: Constraints
|
|
42
|
-
): MeasureResult {
|
|
43
|
-
val p = measurable.measure(constraints)
|
|
44
|
-
return layout(
|
|
45
|
-
width = widthState?.value ?: p.width,
|
|
46
|
-
height = heightState?.value ?: p.height,
|
|
47
|
-
) {
|
|
48
|
-
p.place(IntOffset.Zero)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,499 +0,0 @@
|
|
|
1
|
-
package vn.momo.kits.navigation
|
|
2
|
-
|
|
3
|
-
import androidx.compose.animation.core.Animatable
|
|
4
|
-
import androidx.compose.animation.core.CubicBezierEasing
|
|
5
|
-
import androidx.compose.animation.core.tween
|
|
6
|
-
import androidx.compose.foundation.background
|
|
7
|
-
import androidx.compose.foundation.border
|
|
8
|
-
import androidx.compose.foundation.gestures.detectDragGestures
|
|
9
|
-
import androidx.compose.foundation.layout.Arrangement
|
|
10
|
-
import androidx.compose.foundation.layout.Box
|
|
11
|
-
import androidx.compose.foundation.layout.BoxScope
|
|
12
|
-
import androidx.compose.foundation.layout.BoxWithConstraints
|
|
13
|
-
import androidx.compose.foundation.layout.Column
|
|
14
|
-
import androidx.compose.foundation.layout.Row
|
|
15
|
-
import androidx.compose.foundation.layout.Spacer
|
|
16
|
-
import androidx.compose.foundation.layout.fillMaxHeight
|
|
17
|
-
import androidx.compose.foundation.layout.fillMaxSize
|
|
18
|
-
import androidx.compose.foundation.layout.fillMaxWidth
|
|
19
|
-
import androidx.compose.foundation.layout.height
|
|
20
|
-
import androidx.compose.foundation.layout.heightIn
|
|
21
|
-
import androidx.compose.foundation.layout.offset
|
|
22
|
-
import androidx.compose.foundation.layout.PaddingValues
|
|
23
|
-
import androidx.compose.foundation.layout.padding
|
|
24
|
-
import androidx.compose.foundation.layout.size
|
|
25
|
-
import androidx.compose.foundation.layout.width
|
|
26
|
-
import androidx.compose.foundation.layout.absolutePadding
|
|
27
|
-
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
28
|
-
import androidx.compose.runtime.Composable
|
|
29
|
-
import androidx.compose.runtime.DisposableEffect
|
|
30
|
-
import androidx.compose.runtime.LaunchedEffect
|
|
31
|
-
import androidx.compose.runtime.getValue
|
|
32
|
-
import androidx.compose.runtime.mutableStateOf
|
|
33
|
-
import androidx.compose.runtime.remember
|
|
34
|
-
import androidx.compose.runtime.setValue
|
|
35
|
-
import androidx.compose.runtime.rememberCoroutineScope
|
|
36
|
-
import androidx.compose.ui.AbsoluteAlignment
|
|
37
|
-
import androidx.compose.ui.Alignment
|
|
38
|
-
import androidx.compose.ui.Modifier
|
|
39
|
-
import androidx.compose.ui.graphics.Brush
|
|
40
|
-
import androidx.compose.ui.graphics.Color
|
|
41
|
-
import androidx.compose.ui.input.pointer.pointerInput
|
|
42
|
-
import androidx.compose.ui.layout.layout
|
|
43
|
-
import androidx.compose.ui.platform.LocalDensity
|
|
44
|
-
import androidx.compose.ui.unit.Dp
|
|
45
|
-
import androidx.compose.ui.unit.IntOffset
|
|
46
|
-
import androidx.compose.ui.unit.constrainHeight
|
|
47
|
-
import androidx.compose.ui.unit.dp
|
|
48
|
-
import kotlinx.coroutines.launch
|
|
49
|
-
import vn.momo.kits.components.Divider
|
|
50
|
-
import vn.momo.kits.components.Icon
|
|
51
|
-
import vn.momo.kits.components.Text
|
|
52
|
-
import vn.momo.kits.const.AppTheme
|
|
53
|
-
import vn.momo.kits.const.Colors
|
|
54
|
-
import vn.momo.kits.const.Radius
|
|
55
|
-
import vn.momo.kits.const.Spacing
|
|
56
|
-
import vn.momo.kits.application.LocalContext
|
|
57
|
-
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
58
|
-
import vn.momo.kits.const.AppNavigationBar
|
|
59
|
-
import vn.momo.kits.const.Typography
|
|
60
|
-
import vn.momo.kits.navigation.tracking.ScreenTracker
|
|
61
|
-
import vn.momo.kits.modifier.conditional
|
|
62
|
-
import vn.momo.kits.modifier.noFeedbackClickable
|
|
63
|
-
import vn.momo.kits.platform.BackHandler
|
|
64
|
-
import vn.momo.kits.platform.getScreenHeight
|
|
65
|
-
import vn.momo.kits.layout.DuoMetrics
|
|
66
|
-
import vn.momo.kits.layout.SideBarEdge
|
|
67
|
-
import vn.momo.kits.layout.SideBarLayout
|
|
68
|
-
import vn.momo.kits.layout.getScreenLayout
|
|
69
|
-
import vn.momo.kits.modifier.setAutomationId
|
|
70
|
-
import vn.momo.kits.navigation.component.HeaderType
|
|
71
|
-
import vn.momo.kits.navigation.component.SideBarButton
|
|
72
|
-
import vn.momo.kits.navigation.component.getHeaderColor
|
|
73
|
-
|
|
74
|
-
// iPhone Duo inner display: center the sheet instead of spanning the width (RN BottomSheet).
|
|
75
|
-
private val DUO_REGULAR_MIN_WIDTH = 600.dp
|
|
76
|
-
|
|
77
|
-
private val INDICATOR_HEIGHT = 16.dp
|
|
78
|
-
private val HEADER_ROW_HEIGHT = 56.dp
|
|
79
|
-
|
|
80
|
-
// Side column controls line up with the header row while the sheet is short.
|
|
81
|
-
private val SIDE_COLUMN_OFFSET = INDICATOR_HEIGHT + (HEADER_ROW_HEIGHT - DuoMetrics.controlSize) / 2
|
|
82
|
-
|
|
83
|
-
@Composable
|
|
84
|
-
internal fun BottomSheet(
|
|
85
|
-
content: @Composable () -> Unit,
|
|
86
|
-
header: BottomHeader,
|
|
87
|
-
isSurface: Boolean = false,
|
|
88
|
-
barrierDismissible: Boolean = true,
|
|
89
|
-
draggable: Boolean = true,
|
|
90
|
-
useBottomInset: Boolean = true,
|
|
91
|
-
footerComponent: (@Composable () -> Unit)? = null,
|
|
92
|
-
onDismiss: (() -> Unit)?
|
|
93
|
-
) {
|
|
94
|
-
val layout = getScreenLayout()
|
|
95
|
-
val isDuo = layout.isIPhoneDuoDevice
|
|
96
|
-
val isDuoCentered = isDuo && minOf(layout.width, layout.height) >= DUO_REGULAR_MIN_WIDTH
|
|
97
|
-
val isDuoFloating = isDuo && !isDuoCentered
|
|
98
|
-
val title = header as? BottomHeader.Title
|
|
99
|
-
val sideColumn = layout.sideBar?.takeIf {
|
|
100
|
-
isDuoFloating && title != null && it.width - Spacing.M >= DuoMetrics.controlSize + Spacing.M
|
|
101
|
-
}
|
|
102
|
-
// the floating sheet spans the side safe area, its content stays clear of it
|
|
103
|
-
val sidePadding = if (isDuoFloating) {
|
|
104
|
-
PaddingValues.Absolute(
|
|
105
|
-
left = (layout.insetLeft - Spacing.M).coerceAtLeast(0.dp),
|
|
106
|
-
right = (layout.insetRight - Spacing.M).coerceAtLeast(0.dp),
|
|
107
|
-
)
|
|
108
|
-
} else {
|
|
109
|
-
PaddingValues()
|
|
110
|
-
}
|
|
111
|
-
// the screen is the outer display on iPhone Duo, even when unfolded
|
|
112
|
-
val screenHeightDp = if (isDuo) layout.height else getScreenHeight()
|
|
113
|
-
val screenHeightPx = with(LocalDensity.current) { screenHeightDp.toPx() }
|
|
114
|
-
val sheetOffset = remember { Animatable(screenHeightPx) }
|
|
115
|
-
|
|
116
|
-
val backgroundAlpha = remember { Animatable(0f) }
|
|
117
|
-
val dynamicAlpha = ((1f - (sheetOffset.value / screenHeightPx)).coerceIn(0f, 1f)) * 0.3f
|
|
118
|
-
val alpha = backgroundAlpha.value + dynamicAlpha
|
|
119
|
-
|
|
120
|
-
val sheetCloseOffset = with(LocalDensity.current) { 100.dp.toPx() }
|
|
121
|
-
|
|
122
|
-
val coroutineScope = rememberCoroutineScope()
|
|
123
|
-
|
|
124
|
-
val maxApi = LocalMaxApi.current
|
|
125
|
-
val context = LocalContext.current
|
|
126
|
-
|
|
127
|
-
DisposableEffect(Unit) {
|
|
128
|
-
ScreenTracker.trackPopupDisplayed(
|
|
129
|
-
maxApi = maxApi,
|
|
130
|
-
context = context,
|
|
131
|
-
parentScreenName = ScreenTracker.getLastScreenName()
|
|
132
|
-
)
|
|
133
|
-
onDispose { }
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// a closing sheet keeps going: a second close, the open slide or a drag would cancel its animation
|
|
137
|
-
var isClosing by remember { mutableStateOf(false) }
|
|
138
|
-
// runs once the sheet has closed itself, after its onDismiss
|
|
139
|
-
var afterDismiss by remember { mutableStateOf<(() -> Unit)?>(null) }
|
|
140
|
-
|
|
141
|
-
suspend fun openEvent(){
|
|
142
|
-
backgroundAlpha.animateTo(
|
|
143
|
-
targetValue = 0.3f,
|
|
144
|
-
animationSpec = tween(
|
|
145
|
-
durationMillis = 100,
|
|
146
|
-
easing = CubicBezierEasing(0.05f, 0.7f, 0.1f, 1f)
|
|
147
|
-
)
|
|
148
|
-
)
|
|
149
|
-
if (isClosing) return
|
|
150
|
-
sheetOffset.animateTo(
|
|
151
|
-
targetValue = 0f,
|
|
152
|
-
animationSpec = tween(
|
|
153
|
-
durationMillis = 350,
|
|
154
|
-
easing = CubicBezierEasing(0.05f, 0.7f, 0.1f, 1f)
|
|
155
|
-
)
|
|
156
|
-
)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
fun closeEvent(then: (() -> Unit)? = null){
|
|
160
|
-
if (isClosing) return
|
|
161
|
-
isClosing = true
|
|
162
|
-
coroutineScope.launch {
|
|
163
|
-
sheetOffset.animateTo(
|
|
164
|
-
targetValue = screenHeightPx,
|
|
165
|
-
animationSpec = tween(
|
|
166
|
-
durationMillis = 200,
|
|
167
|
-
easing = CubicBezierEasing(0.3f, 0.0f, 0.8f, 0.15f)
|
|
168
|
-
)
|
|
169
|
-
)
|
|
170
|
-
backgroundAlpha.animateTo(
|
|
171
|
-
targetValue = 0f,
|
|
172
|
-
animationSpec = tween(
|
|
173
|
-
durationMillis = 100,
|
|
174
|
-
easing = CubicBezierEasing(0.3f, 0.0f, 0.8f, 0.15f)
|
|
175
|
-
)
|
|
176
|
-
)
|
|
177
|
-
// not reached when a newer overlay replaced this one, so its back is dropped
|
|
178
|
-
afterDismiss = then
|
|
179
|
-
OverplayComponentRegistry.hardClearAfterDismiss()
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// RN `leftOptions.onPressIconLeft`: the sheet closes first, then the back runs
|
|
184
|
-
val onBack = title?.onBack?.let { back -> { closeEvent(then = back) } }
|
|
185
|
-
|
|
186
|
-
LaunchedEffect(Unit) {
|
|
187
|
-
openEvent()
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
DisposableEffect(Unit) {
|
|
191
|
-
OverplayComponentRegistry.bindClose { closeEvent() }
|
|
192
|
-
onDispose {
|
|
193
|
-
onDismiss?.invoke()
|
|
194
|
-
afterDismiss?.invoke()
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
BackHandler(true){
|
|
199
|
-
closeEvent()
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
BoxWithConstraints(
|
|
203
|
-
modifier = Modifier
|
|
204
|
-
.fillMaxSize()
|
|
205
|
-
.background(Color.Black.copy(alpha = alpha))
|
|
206
|
-
.noFeedbackClickable {
|
|
207
|
-
if(barrierDismissible) closeEvent()
|
|
208
|
-
}
|
|
209
|
-
) {
|
|
210
|
-
val parentHeight = with(LocalDensity.current) { constraints.maxHeight.toDp() }
|
|
211
|
-
val maxHeight = if (isDuo) {
|
|
212
|
-
parentHeight - maxOf(layout.duoTopInset, Spacing.XL)
|
|
213
|
-
} else {
|
|
214
|
-
parentHeight - 90.dp
|
|
215
|
-
}
|
|
216
|
-
val radius = if (isDuo) Radius.XL else Radius.M
|
|
217
|
-
|
|
218
|
-
Box(
|
|
219
|
-
modifier = Modifier
|
|
220
|
-
.align(Alignment.BottomCenter)
|
|
221
|
-
.offset { IntOffset(x = 0, y = sheetOffset.value.toInt()) }
|
|
222
|
-
.then(
|
|
223
|
-
when {
|
|
224
|
-
// keeps the portrait width in landscape, like system sheets
|
|
225
|
-
isDuoCentered -> Modifier.width(
|
|
226
|
-
minOf(
|
|
227
|
-
minOf(layout.width, layout.height) - Spacing.L * 2,
|
|
228
|
-
layout.width - maxOf(layout.insetLeft, layout.insetRight, Spacing.L) * 2,
|
|
229
|
-
)
|
|
230
|
-
)
|
|
231
|
-
isDuoFloating -> Modifier.fillMaxWidth().padding(horizontal = Spacing.M)
|
|
232
|
-
else -> Modifier.fillMaxWidth()
|
|
233
|
-
}
|
|
234
|
-
)
|
|
235
|
-
.heightIn(max = maxHeight)
|
|
236
|
-
.background(
|
|
237
|
-
color = if (isSurface) AppTheme.current.colors.background.surface else AppTheme.current.colors.background.default,
|
|
238
|
-
shape = RoundedCornerShape(topStart = radius, topEnd = radius)
|
|
239
|
-
)
|
|
240
|
-
.conditional(IsShowBaseLineDebug) {
|
|
241
|
-
border(1.dp, Colors.blue_03)
|
|
242
|
-
}
|
|
243
|
-
.noFeedbackClickable { },
|
|
244
|
-
contentAlignment = Alignment.BottomCenter
|
|
245
|
-
) {
|
|
246
|
-
val bottomInset = if (useBottomInset) {
|
|
247
|
-
(AppNavigationBar.current - keyboardSizeState().value).coerceAtLeast(0.dp)
|
|
248
|
-
} else 0.dp
|
|
249
|
-
Column(Modifier.padding(bottom = bottomInset)) {
|
|
250
|
-
Box(
|
|
251
|
-
modifier = Modifier
|
|
252
|
-
.height(INDICATOR_HEIGHT + HEADER_ROW_HEIGHT)
|
|
253
|
-
.fillMaxWidth()
|
|
254
|
-
.conditional(draggable) {
|
|
255
|
-
pointerInput(Unit) {
|
|
256
|
-
detectDragGestures(
|
|
257
|
-
onDrag = { change, dragAmount ->
|
|
258
|
-
change.consume()
|
|
259
|
-
if (isClosing) return@detectDragGestures
|
|
260
|
-
coroutineScope.launch {
|
|
261
|
-
val newOffset = (sheetOffset.value + dragAmount.y).coerceAtLeast(0f)
|
|
262
|
-
sheetOffset.snapTo(newOffset)
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
onDragEnd = {
|
|
266
|
-
if (isClosing) return@detectDragGestures
|
|
267
|
-
coroutineScope.launch {
|
|
268
|
-
if (sheetOffset.value > sheetCloseOffset) {
|
|
269
|
-
closeEvent()
|
|
270
|
-
} else {
|
|
271
|
-
sheetOffset.animateTo(0f)
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
)
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
) {
|
|
279
|
-
Column(
|
|
280
|
-
modifier = Modifier
|
|
281
|
-
.fillMaxSize()
|
|
282
|
-
.padding(sidePadding)
|
|
283
|
-
.padding(horizontal = Spacing.M),
|
|
284
|
-
horizontalAlignment = Alignment.CenterHorizontally
|
|
285
|
-
) {
|
|
286
|
-
Spacer(Modifier.height(8.dp))
|
|
287
|
-
Box(
|
|
288
|
-
modifier = Modifier
|
|
289
|
-
.height(4.dp)
|
|
290
|
-
.width(40.dp)
|
|
291
|
-
.background(
|
|
292
|
-
color = Colors.black_06,
|
|
293
|
-
shape = RoundedCornerShape(Radius.S)
|
|
294
|
-
)
|
|
295
|
-
)
|
|
296
|
-
Spacer(Modifier.height(4.dp))
|
|
297
|
-
Box(Modifier.fillMaxWidth().height(HEADER_ROW_HEIGHT), contentAlignment = Alignment.Center){
|
|
298
|
-
when (header) {
|
|
299
|
-
is BottomHeader.Title -> BottomSheetTitle(
|
|
300
|
-
text = header.data,
|
|
301
|
-
backIcon = header.backIcon,
|
|
302
|
-
// the side column holds back and close, the row keeps only the title
|
|
303
|
-
showButtons = sideColumn == null,
|
|
304
|
-
onBack = onBack,
|
|
305
|
-
onClose = { closeEvent() },
|
|
306
|
-
)
|
|
307
|
-
is BottomHeader.Custom -> {
|
|
308
|
-
header.content()
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
Box(Modifier.padding(sidePadding)) {
|
|
315
|
-
Divider()
|
|
316
|
-
}
|
|
317
|
-
if (footerComponent != null) {
|
|
318
|
-
Box(Modifier.weight(1f, fill = false).padding(sidePadding)) {
|
|
319
|
-
content()
|
|
320
|
-
}
|
|
321
|
-
BottomSheetFooter(footerComponent, sidePadding)
|
|
322
|
-
} else if (isDuo) {
|
|
323
|
-
// content shrinks so a tall sheet keeps its header
|
|
324
|
-
Box(Modifier.weight(1f, fill = false).padding(sidePadding)) {
|
|
325
|
-
content()
|
|
326
|
-
}
|
|
327
|
-
} else {
|
|
328
|
-
content()
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
if (sideColumn != null && title != null) {
|
|
332
|
-
BottomSheetSideColumn(
|
|
333
|
-
sideBar = sideColumn,
|
|
334
|
-
parentHeight = parentHeight,
|
|
335
|
-
backIcon = title.backIcon,
|
|
336
|
-
onBack = onBack,
|
|
337
|
-
onClose = { closeEvent() },
|
|
338
|
-
)
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
@Composable
|
|
345
|
-
private fun BottomSheetTitle(
|
|
346
|
-
text: String,
|
|
347
|
-
backIcon: String,
|
|
348
|
-
showButtons: Boolean,
|
|
349
|
-
onBack: (() -> Unit)?,
|
|
350
|
-
onClose: () -> Unit,
|
|
351
|
-
) {
|
|
352
|
-
Row(modifier = Modifier.fillMaxSize(), verticalAlignment = Alignment.CenterVertically) {
|
|
353
|
-
if (showButtons) {
|
|
354
|
-
if (onBack != null) {
|
|
355
|
-
BottomSheetHeaderButton(icon = backIcon, automationId = "btn_bottom_sheet_back", onClick = onBack)
|
|
356
|
-
} else {
|
|
357
|
-
Box(Modifier.size(24.dp))
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
Box(
|
|
361
|
-
Modifier
|
|
362
|
-
.fillMaxHeight()
|
|
363
|
-
.weight(1f)
|
|
364
|
-
.conditional(!showButtons) { padding(horizontal = Spacing.M) },
|
|
365
|
-
contentAlignment = Alignment.Center
|
|
366
|
-
) {
|
|
367
|
-
Text(
|
|
368
|
-
text = text,
|
|
369
|
-
color = Colors.black_17,
|
|
370
|
-
style = Typography.headerDefaultBold
|
|
371
|
-
)
|
|
372
|
-
}
|
|
373
|
-
if (showButtons) {
|
|
374
|
-
BottomSheetHeaderButton(icon = "navigation_close", automationId = "btn_bottom_sheet_close", onClick = onClose)
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
@Composable
|
|
380
|
-
private fun BottomSheetHeaderButton(icon: String, automationId: String, onClick: () -> Unit) {
|
|
381
|
-
Box(
|
|
382
|
-
Modifier
|
|
383
|
-
.size(24.dp)
|
|
384
|
-
.noFeedbackClickable(onClick = onClick)
|
|
385
|
-
.setAutomationId(automationId),
|
|
386
|
-
contentAlignment = Alignment.Center
|
|
387
|
-
) {
|
|
388
|
-
Icon(source = icon)
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
// iPhone Duo outer display: back and close sit on the part of the sheet under the side safe area,
|
|
393
|
-
// 12pt from the strip's inner edge like the screen side bar. They follow the header row while the
|
|
394
|
-
// sheet is short and stay below the status bar cluster while it is tall.
|
|
395
|
-
@Composable
|
|
396
|
-
private fun BoxScope.BottomSheetSideColumn(
|
|
397
|
-
sideBar: SideBarLayout,
|
|
398
|
-
parentHeight: Dp,
|
|
399
|
-
backIcon: String,
|
|
400
|
-
onBack: (() -> Unit)?,
|
|
401
|
-
onClose: () -> Unit,
|
|
402
|
-
) {
|
|
403
|
-
val isRight = sideBar.edge == SideBarEdge.RIGHT
|
|
404
|
-
val headerColor = getHeaderColor(HeaderType.None, 1f, null, AppTheme.current.colors.text.default)
|
|
405
|
-
|
|
406
|
-
Box(Modifier.matchParentSize()) {
|
|
407
|
-
Column(
|
|
408
|
-
modifier = Modifier
|
|
409
|
-
.align(if (isRight) AbsoluteAlignment.TopRight else AbsoluteAlignment.TopLeft)
|
|
410
|
-
.width(sideBar.width - Spacing.M)
|
|
411
|
-
.layout { measurable, constraints ->
|
|
412
|
-
val placeable = measurable.measure(constraints.copy(minHeight = 0))
|
|
413
|
-
val sheetHeight = constraints.maxHeight
|
|
414
|
-
// the sheet rests on the bottom of the overlay, which starts at the window top
|
|
415
|
-
val sheetTop = parentHeight.roundToPx() - sheetHeight
|
|
416
|
-
// clear of a camera at the bottom end of the strip when it can
|
|
417
|
-
val lowest = sheetHeight - sideBar.bottom.roundToPx() - placeable.height
|
|
418
|
-
val y = maxOf(sideBar.top.roundToPx() - sheetTop, SIDE_COLUMN_OFFSET.roundToPx())
|
|
419
|
-
.coerceAtMost(lowest)
|
|
420
|
-
.coerceAtLeast(0)
|
|
421
|
-
layout(placeable.width, constraints.constrainHeight(y + placeable.height)) {
|
|
422
|
-
placeable.place(0, y)
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
.absolutePadding(left = if (isRight) Spacing.M else 0.dp, right = if (isRight) 0.dp else Spacing.M),
|
|
426
|
-
horizontalAlignment = if (isRight) AbsoluteAlignment.Left else AbsoluteAlignment.Right,
|
|
427
|
-
verticalArrangement = Arrangement.spacedBy(Spacing.M),
|
|
428
|
-
) {
|
|
429
|
-
if (onBack != null) {
|
|
430
|
-
SideBarButton(
|
|
431
|
-
icon = backIcon,
|
|
432
|
-
headerColor = headerColor,
|
|
433
|
-
automationId = "btn_bottom_sheet_back",
|
|
434
|
-
onClick = onBack,
|
|
435
|
-
)
|
|
436
|
-
}
|
|
437
|
-
SideBarButton(
|
|
438
|
-
icon = "navigation_close",
|
|
439
|
-
headerColor = headerColor,
|
|
440
|
-
automationId = "btn_bottom_sheet_close",
|
|
441
|
-
onClick = onClose,
|
|
442
|
-
)
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
@Composable
|
|
448
|
-
private fun BottomSheetFooter(footerComponent: @Composable () -> Unit, sidePadding: PaddingValues) {
|
|
449
|
-
val shadowBrush = remember {
|
|
450
|
-
Brush.verticalGradient(
|
|
451
|
-
colors = listOf(Color.Transparent, Color.Black.copy(alpha = 0.05f))
|
|
452
|
-
)
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
Box {
|
|
456
|
-
Box(
|
|
457
|
-
Modifier
|
|
458
|
-
.fillMaxWidth()
|
|
459
|
-
.background(AppTheme.current.colors.background.surface)
|
|
460
|
-
.conditional(IsShowBaseLineDebug) {
|
|
461
|
-
border(1.dp, Colors.blue_03)
|
|
462
|
-
}
|
|
463
|
-
.padding(sidePadding)
|
|
464
|
-
.padding(vertical = Spacing.S)
|
|
465
|
-
) {
|
|
466
|
-
footerComponent()
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
Box(
|
|
470
|
-
modifier = Modifier
|
|
471
|
-
.fillMaxWidth()
|
|
472
|
-
.height(6.dp)
|
|
473
|
-
.offset(x = 0.dp, y = (-6).dp)
|
|
474
|
-
.background(shadowBrush)
|
|
475
|
-
)
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
sealed class BottomHeader {
|
|
480
|
-
data class Title(
|
|
481
|
-
val data: String = "Bottom Sheet Title",
|
|
482
|
-
) : BottomHeader() {
|
|
483
|
-
// Outside the primary constructor so code built against older kits keeps Title() and copy().
|
|
484
|
-
// onBack shows a back button: the sheet closes (onDismiss fires), then it runs.
|
|
485
|
-
var onBack: (() -> Unit)? = null
|
|
486
|
-
private set
|
|
487
|
-
var backIcon: String = "arrow-back"
|
|
488
|
-
private set
|
|
489
|
-
|
|
490
|
-
constructor(data: String, onBack: (() -> Unit)?, backIcon: String = "arrow-back") : this(data) {
|
|
491
|
-
this.onBack = onBack
|
|
492
|
-
this.backIcon = backIcon
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
data class Custom(
|
|
497
|
-
val content: @Composable () -> Unit
|
|
498
|
-
) : BottomHeader()
|
|
499
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
package vn.momo.kits.navigation
|
|
2
|
-
|
|
3
|
-
interface HostBackTarget {
|
|
4
|
-
fun canPop(): Boolean
|
|
5
|
-
|
|
6
|
-
fun onBack()
|
|
7
|
-
|
|
8
|
-
fun backStarted()
|
|
9
|
-
fun backProgressed(progress: Float)
|
|
10
|
-
fun backCompleted()
|
|
11
|
-
fun backCancelled()
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
object HostBackGestureBridge {
|
|
15
|
-
private val targets = mutableListOf<HostBackTarget>()
|
|
16
|
-
private var gestureTarget: HostBackTarget? = null
|
|
17
|
-
|
|
18
|
-
var shouldUseFloatingArrowBack: Boolean = false
|
|
19
|
-
|
|
20
|
-
fun checkCanPop(): Boolean = targets.isNotEmpty()
|
|
21
|
-
|
|
22
|
-
fun canPopInner(): Boolean = top()?.canPop() == true
|
|
23
|
-
|
|
24
|
-
fun pop() {
|
|
25
|
-
top()?.onBack()
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
fun started() {
|
|
29
|
-
val target = top() ?: return
|
|
30
|
-
gestureTarget = target
|
|
31
|
-
target.backStarted()
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
fun progressed(progress: Float) {
|
|
35
|
-
gestureTarget?.backProgressed(progress.coerceIn(0f, 1f))
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
fun completed() {
|
|
39
|
-
(gestureTarget ?: top())?.backCompleted()
|
|
40
|
-
gestureTarget = null
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
fun cancelled() {
|
|
44
|
-
gestureTarget?.backCancelled()
|
|
45
|
-
gestureTarget = null
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
fun attach(target: HostBackTarget) {
|
|
49
|
-
targets += target
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
fun detach(target: HostBackTarget) {
|
|
53
|
-
targets -= target
|
|
54
|
-
if (gestureTarget === target) gestureTarget = null
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private fun top(): HostBackTarget? = targets.lastOrNull()
|
|
58
|
-
}
|