From 383758d779562d440dd5e56dd93f24750c5615cc Mon Sep 17 00:00:00 2001 From: HuanCheng65 <22636177+HuanCheng65@users.noreply.github.com> Date: Thu, 26 Jan 2023 13:10:20 +0800 Subject: [PATCH] =?UTF-8?q?pref:=20=E8=B0=83=E6=95=B4=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../huanchengfly/tieba/post/MainActivityV2.kt | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/huanchengfly/tieba/post/MainActivityV2.kt b/app/src/main/java/com/huanchengfly/tieba/post/MainActivityV2.kt index cae9ce78..37aae044 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/MainActivityV2.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/MainActivityV2.kt @@ -13,12 +13,16 @@ import android.os.Handler import android.os.Looper import androidx.compose.animation.AnimatedContentScope import androidx.compose.animation.ExperimentalAnimationApi +import androidx.compose.animation.core.Spring +import androidx.compose.animation.core.VisibilityThreshold +import androidx.compose.animation.core.spring import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Surface import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.Alignment +import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.dp import androidx.core.content.ContextCompat import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen @@ -174,33 +178,46 @@ class MainActivityV2 : BaseComposeActivity() { Surface( color = ExtendedTheme.colors.background ) { + val animationSpec = spring( + stiffness = Spring.StiffnessMediumLow, + visibilityThreshold = IntOffset.VisibilityThreshold + ) val engine = rememberAnimatedNavHostEngine( navHostContentAlignment = Alignment.TopStart, rootDefaultAnimations = RootNavGraphDefaultAnimations( enterTransition = { slideIntoContainer( AnimatedContentScope.SlideDirection.Start, - initialOffset = { it }) + animationSpec = animationSpec, + initialOffset = { it } + ) }, exitTransition = { slideOutOfContainer( AnimatedContentScope.SlideDirection.End, - targetOffset = { -it }) + animationSpec = animationSpec, + targetOffset = { -it } + ) }, popEnterTransition = { slideIntoContainer( AnimatedContentScope.SlideDirection.Start, - initialOffset = { -it }) + animationSpec = animationSpec, + initialOffset = { -it } + ) }, popExitTransition = { slideOutOfContainer( AnimatedContentScope.SlideDirection.End, - targetOffset = { it }) + animationSpec = animationSpec, + targetOffset = { it } + ) }, ), ) val navController = rememberAnimatedNavController() - val bottomSheetNavigator = rememberBottomSheetNavigator() + val bottomSheetNavigator = + rememberBottomSheetNavigator(animationSpec = spring(stiffness = Spring.StiffnessMediumLow)) navController.navigatorProvider += bottomSheetNavigator ModalBottomSheetLayout( bottomSheetNavigator = bottomSheetNavigator,