pref: 调整动画速度

This commit is contained in:
HuanCheng65 2023-01-26 13:10:20 +08:00
parent 4b1a2e084b
commit 383758d779
No known key found for this signature in database
GPG Key ID: E9031EF91A805148
1 changed files with 22 additions and 5 deletions

View File

@ -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,