pref: 调整动画速度
This commit is contained in:
parent
4b1a2e084b
commit
383758d779
|
|
@ -13,12 +13,16 @@ import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import androidx.compose.animation.AnimatedContentScope
|
import androidx.compose.animation.AnimatedContentScope
|
||||||
import androidx.compose.animation.ExperimentalAnimationApi
|
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.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.Surface
|
import androidx.compose.material.Surface
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.runtime.staticCompositionLocalOf
|
import androidx.compose.runtime.staticCompositionLocalOf
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.unit.IntOffset
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||||
|
|
@ -174,33 +178,46 @@ class MainActivityV2 : BaseComposeActivity() {
|
||||||
Surface(
|
Surface(
|
||||||
color = ExtendedTheme.colors.background
|
color = ExtendedTheme.colors.background
|
||||||
) {
|
) {
|
||||||
|
val animationSpec = spring(
|
||||||
|
stiffness = Spring.StiffnessMediumLow,
|
||||||
|
visibilityThreshold = IntOffset.VisibilityThreshold
|
||||||
|
)
|
||||||
val engine = rememberAnimatedNavHostEngine(
|
val engine = rememberAnimatedNavHostEngine(
|
||||||
navHostContentAlignment = Alignment.TopStart,
|
navHostContentAlignment = Alignment.TopStart,
|
||||||
rootDefaultAnimations = RootNavGraphDefaultAnimations(
|
rootDefaultAnimations = RootNavGraphDefaultAnimations(
|
||||||
enterTransition = {
|
enterTransition = {
|
||||||
slideIntoContainer(
|
slideIntoContainer(
|
||||||
AnimatedContentScope.SlideDirection.Start,
|
AnimatedContentScope.SlideDirection.Start,
|
||||||
initialOffset = { it })
|
animationSpec = animationSpec,
|
||||||
|
initialOffset = { it }
|
||||||
|
)
|
||||||
},
|
},
|
||||||
exitTransition = {
|
exitTransition = {
|
||||||
slideOutOfContainer(
|
slideOutOfContainer(
|
||||||
AnimatedContentScope.SlideDirection.End,
|
AnimatedContentScope.SlideDirection.End,
|
||||||
targetOffset = { -it })
|
animationSpec = animationSpec,
|
||||||
|
targetOffset = { -it }
|
||||||
|
)
|
||||||
},
|
},
|
||||||
popEnterTransition = {
|
popEnterTransition = {
|
||||||
slideIntoContainer(
|
slideIntoContainer(
|
||||||
AnimatedContentScope.SlideDirection.Start,
|
AnimatedContentScope.SlideDirection.Start,
|
||||||
initialOffset = { -it })
|
animationSpec = animationSpec,
|
||||||
|
initialOffset = { -it }
|
||||||
|
)
|
||||||
},
|
},
|
||||||
popExitTransition = {
|
popExitTransition = {
|
||||||
slideOutOfContainer(
|
slideOutOfContainer(
|
||||||
AnimatedContentScope.SlideDirection.End,
|
AnimatedContentScope.SlideDirection.End,
|
||||||
targetOffset = { it })
|
animationSpec = animationSpec,
|
||||||
|
targetOffset = { it }
|
||||||
|
)
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
val navController = rememberAnimatedNavController()
|
val navController = rememberAnimatedNavController()
|
||||||
val bottomSheetNavigator = rememberBottomSheetNavigator()
|
val bottomSheetNavigator =
|
||||||
|
rememberBottomSheetNavigator(animationSpec = spring(stiffness = Spring.StiffnessMediumLow))
|
||||||
navController.navigatorProvider += bottomSheetNavigator
|
navController.navigatorProvider += bottomSheetNavigator
|
||||||
ModalBottomSheetLayout(
|
ModalBottomSheetLayout(
|
||||||
bottomSheetNavigator = bottomSheetNavigator,
|
bottomSheetNavigator = bottomSheetNavigator,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue