@momo-kits/native-kits 0.152.4-beta.7 → 0.152.4-beta.8
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.
|
@@ -335,15 +335,18 @@ val LocalScreenHelper = staticCompositionLocalOf<ScreenHelper> {
|
|
|
335
335
|
fun ScreenSnackBarHost(footerHeightPx: Int) {
|
|
336
336
|
val helper = LocalScreenHelper.current
|
|
337
337
|
val snackBarData = helper.snackBarState ?: return
|
|
338
|
+
val density = LocalDensity.current
|
|
338
339
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
340
|
+
val footerHeight = if (footerHeightPx > 0) {
|
|
341
|
+
with(LocalDensity.current) {
|
|
342
|
+
footerHeightPx.toDp()
|
|
343
|
+
}
|
|
344
|
+
} else {
|
|
345
|
+
min(AppNavigationBar.current, 21.dp)
|
|
343
346
|
}
|
|
344
347
|
|
|
345
|
-
val startPosition =
|
|
346
|
-
val targetPosition =
|
|
348
|
+
val startPosition = with(density) {200.dp.toPx()}
|
|
349
|
+
val targetPosition = 0f
|
|
347
350
|
|
|
348
351
|
val offsetY = remember { Animatable(startPosition) }
|
|
349
352
|
|
|
@@ -375,6 +378,7 @@ fun ScreenSnackBarHost(footerHeightPx: Int) {
|
|
|
375
378
|
Box(
|
|
376
379
|
modifier = Modifier
|
|
377
380
|
.offset { IntOffset(0, offsetY.value.toInt()) }
|
|
381
|
+
.padding(bottom = footerHeight)
|
|
378
382
|
.fillMaxWidth()
|
|
379
383
|
) {
|
|
380
384
|
when (val type = snackBarData.type) {
|
|
@@ -21,7 +21,6 @@ import androidx.compose.ui.unit.min
|
|
|
21
21
|
import kotlinx.coroutines.delay
|
|
22
22
|
import kotlinx.coroutines.launch
|
|
23
23
|
import vn.momo.kits.const.AppNavigationBar
|
|
24
|
-
import vn.momo.kits.const.Spacing
|
|
25
24
|
import vn.momo.kits.navigation.LocalFooterHeightPx
|
|
26
25
|
import vn.momo.kits.navigation.LocalNavigator
|
|
27
26
|
import vn.momo.kits.navigation.LocalOptions
|
|
@@ -30,7 +29,6 @@ import vn.momo.kits.navigation.OverplayComponentRegistry
|
|
|
30
29
|
sealed class SnackBar(open val duration: Long? = null) {
|
|
31
30
|
data class Custom(
|
|
32
31
|
val content: @Composable () -> Unit,
|
|
33
|
-
val heightContent: Float = 300f,
|
|
34
32
|
override val duration: Long? = 3000L
|
|
35
33
|
) : SnackBar(duration)
|
|
36
34
|
|
|
@@ -46,27 +44,26 @@ fun SnackBar(
|
|
|
46
44
|
) {
|
|
47
45
|
val navigator = LocalNavigator.current
|
|
48
46
|
val options = LocalOptions.current
|
|
47
|
+
val density = LocalDensity.current
|
|
49
48
|
val footerHeightPxState = LocalFooterHeightPx.current
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
val startPosition = if (options.footerComponent != null) 0f else -snackBarHeight
|
|
57
|
-
val targetPosition = if (options.footerComponent != null) {
|
|
58
|
-
footerHeightPxState.intValue.toFloat()
|
|
49
|
+
val footerHeight = if (options.footerComponent != null) {
|
|
50
|
+
with(LocalDensity.current) {
|
|
51
|
+
footerHeightPxState.value.toDp()
|
|
52
|
+
}
|
|
59
53
|
} else {
|
|
60
|
-
|
|
54
|
+
min(AppNavigationBar.current, 21.dp)
|
|
61
55
|
}
|
|
62
56
|
|
|
57
|
+
val startPosition = with(density) {200.dp.toPx()}
|
|
58
|
+
val targetPosition = 0f
|
|
59
|
+
|
|
63
60
|
val offsetY by remember { mutableStateOf(Animatable(startPosition)) }
|
|
64
61
|
val coroutineScope = rememberCoroutineScope()
|
|
65
62
|
|
|
66
63
|
suspend fun openEvent() {
|
|
67
64
|
offsetY.snapTo(startPosition)
|
|
68
65
|
offsetY.animateTo(
|
|
69
|
-
targetValue =
|
|
66
|
+
targetValue = targetPosition,
|
|
70
67
|
animationSpec = tween(
|
|
71
68
|
durationMillis = 350,
|
|
72
69
|
)
|
|
@@ -109,7 +106,7 @@ fun SnackBar(
|
|
|
109
106
|
Box(
|
|
110
107
|
modifier = Modifier
|
|
111
108
|
.offset { IntOffset(0, offsetY.value.toInt()) }
|
|
112
|
-
.padding(bottom =
|
|
109
|
+
.padding(bottom = footerHeight)
|
|
113
110
|
.fillMaxWidth()
|
|
114
111
|
) {
|
|
115
112
|
when (data) {
|
|
@@ -117,7 +114,4 @@ fun SnackBar(
|
|
|
117
114
|
is SnackBar.Toast -> {}
|
|
118
115
|
}
|
|
119
116
|
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
117
|
+
}
|