11package love.forte.simbot.codegen
22
33import androidx.compose.animation.animateColorAsState
4- import androidx.compose.animation.core.tween
4+ import androidx.compose.animation.core.spring
5+ import androidx.compose.animation.core.Spring
56import androidx.compose.material3.*
67import androidx.compose.runtime.*
78import androidx.compose.ui.graphics.Color
@@ -81,9 +82,11 @@ fun rememberAnimatedColorScheme(colorMode: ColorMode): ColorScheme {
8182 ColorMode .DARK -> darkColors
8283 }
8384
84- // 为每个颜色添加动画过渡
85- val animationDuration = 300
86- val animationSpec = tween<Color >(durationMillis = animationDuration)
85+ // 为每个颜色添加动画过渡 - 使用弹性动画实现更自然的过渡效果
86+ val animationSpec = spring<Color >(
87+ dampingRatio = Spring .DampingRatioMediumBouncy ,
88+ stiffness = Spring .StiffnessMedium
89+ )
8790
8891 val animatedPrimary by animateColorAsState(targetColors.primary, animationSpec, label = " primary" )
8992 val animatedSecondary by animateColorAsState(targetColors.secondary, animationSpec, label = " secondary" )
@@ -100,36 +103,53 @@ fun rememberAnimatedColorScheme(colorMode: ColorMode): ColorScheme {
100103 val animatedPrimaryContainer by animateColorAsState(targetColors.primaryContainer, animationSpec, label = " primaryContainer" )
101104 val animatedSecondaryContainer by animateColorAsState(targetColors.secondaryContainer, animationSpec, label = " secondaryContainer" )
102105
106+ // 为剩余的颜色属性添加动画
107+ val animatedOnPrimaryContainer by animateColorAsState(targetColors.onPrimaryContainer, animationSpec, label = " onPrimaryContainer" )
108+ val animatedInversePrimary by animateColorAsState(targetColors.inversePrimary, animationSpec, label = " inversePrimary" )
109+ val animatedOnSecondaryContainer by animateColorAsState(targetColors.onSecondaryContainer, animationSpec, label = " onSecondaryContainer" )
110+ val animatedTertiaryContainer by animateColorAsState(targetColors.tertiaryContainer, animationSpec, label = " tertiaryContainer" )
111+ val animatedOnTertiaryContainer by animateColorAsState(targetColors.onTertiaryContainer, animationSpec, label = " onTertiaryContainer" )
112+ val animatedOnSurfaceVariant by animateColorAsState(targetColors.onSurfaceVariant, animationSpec, label = " onSurfaceVariant" )
113+ val animatedSurfaceTint by animateColorAsState(targetColors.surfaceTint, animationSpec, label = " surfaceTint" )
114+ val animatedInverseSurface by animateColorAsState(targetColors.inverseSurface, animationSpec, label = " inverseSurface" )
115+ val animatedInverseOnSurface by animateColorAsState(targetColors.inverseOnSurface, animationSpec, label = " inverseOnSurface" )
116+ val animatedOnError by animateColorAsState(targetColors.onError, animationSpec, label = " onError" )
117+ val animatedErrorContainer by animateColorAsState(targetColors.errorContainer, animationSpec, label = " errorContainer" )
118+ val animatedOnErrorContainer by animateColorAsState(targetColors.onErrorContainer, animationSpec, label = " onErrorContainer" )
119+ val animatedOutline by animateColorAsState(targetColors.outline, animationSpec, label = " outline" )
120+ val animatedOutlineVariant by animateColorAsState(targetColors.outlineVariant, animationSpec, label = " outlineVariant" )
121+ val animatedScrim by animateColorAsState(targetColors.scrim, animationSpec, label = " scrim" )
122+
103123 return ColorScheme (
104124 primary = animatedPrimary,
105125 onPrimary = animatedOnPrimary,
106126 primaryContainer = animatedPrimaryContainer,
107- onPrimaryContainer = targetColors.onPrimaryContainer ,
108- inversePrimary = targetColors.inversePrimary ,
127+ onPrimaryContainer = animatedOnPrimaryContainer ,
128+ inversePrimary = animatedInversePrimary ,
109129 secondary = animatedSecondary,
110130 onSecondary = animatedOnSecondary,
111131 secondaryContainer = animatedSecondaryContainer,
112- onSecondaryContainer = targetColors.onSecondaryContainer ,
132+ onSecondaryContainer = animatedOnSecondaryContainer ,
113133 tertiary = animatedTertiary,
114134 onTertiary = animatedOnTertiary,
115- tertiaryContainer = targetColors.tertiaryContainer ,
116- onTertiaryContainer = targetColors.onTertiaryContainer ,
135+ tertiaryContainer = animatedTertiaryContainer ,
136+ onTertiaryContainer = animatedOnTertiaryContainer ,
117137 background = animatedBackground,
118138 onBackground = animatedOnBackground,
119139 surface = animatedSurface,
120140 onSurface = animatedOnSurface,
121141 surfaceVariant = animatedSurfaceVariant,
122- onSurfaceVariant = targetColors.onSurfaceVariant ,
123- surfaceTint = targetColors.surfaceTint ,
124- inverseSurface = targetColors.inverseSurface ,
125- inverseOnSurface = targetColors.inverseOnSurface ,
142+ onSurfaceVariant = animatedOnSurfaceVariant ,
143+ surfaceTint = animatedSurfaceTint ,
144+ inverseSurface = animatedInverseSurface ,
145+ inverseOnSurface = animatedInverseOnSurface ,
126146 error = animatedError,
127- onError = targetColors.onError ,
128- errorContainer = targetColors.errorContainer ,
129- onErrorContainer = targetColors.onErrorContainer ,
130- outline = targetColors.outline ,
131- outlineVariant = targetColors.outlineVariant ,
132- scrim = targetColors.scrim ,
147+ onError = animatedOnError ,
148+ errorContainer = animatedErrorContainer ,
149+ onErrorContainer = animatedOnErrorContainer ,
150+ outline = animatedOutline ,
151+ outlineVariant = animatedOutlineVariant ,
152+ scrim = animatedScrim ,
133153 surfaceBright = targetColors.surfaceBright,
134154 surfaceDim = targetColors.surfaceDim,
135155 surfaceContainer = targetColors.surfaceContainer,
0 commit comments