diff --git a/app/src/main/kotlin/li/songe/gkd/ui/theme/Theme.kt b/app/src/main/kotlin/li/songe/gkd/ui/theme/Theme.kt index 0e70dc0d8..bb9f5bf51 100644 --- a/app/src/main/kotlin/li/songe/gkd/ui/theme/Theme.kt +++ b/app/src/main/kotlin/li/songe/gkd/ui/theme/Theme.kt @@ -1,7 +1,10 @@ package li.songe.gkd.ui.theme import android.os.Build +import androidx.compose.animation.animateColorAsState +import androidx.compose.animation.core.tween import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.ColorScheme import androidx.compose.material3.MaterialTheme import androidx.compose.material3.darkColorScheme import androidx.compose.material3.dynamicDarkColorScheme @@ -11,6 +14,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue +import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.core.view.WindowInsetsControllerCompat import li.songe.gkd.MainActivity @@ -43,6 +47,56 @@ fun AppTheme( } } MaterialTheme( - colorScheme = colorScheme, content = content + colorScheme = colorScheme.animation(), + content = content, ) -} \ No newline at end of file +} + +@Composable +private fun Color.animation() = animateColorAsState( + targetValue = this, + animationSpec = tween(durationMillis = 500), + label = "animation" +).value + +@Composable +private fun ColorScheme.animation(): ColorScheme { + return copy( + primary = primary.animation(), + onPrimary = onPrimary.animation(), + primaryContainer = primaryContainer.animation(), + onPrimaryContainer = onPrimaryContainer.animation(), + inversePrimary = inversePrimary.animation(), + secondary = secondary.animation(), + onSecondary = onSecondary.animation(), + secondaryContainer = secondaryContainer.animation(), + onSecondaryContainer = onSecondaryContainer.animation(), + tertiary = tertiary.animation(), + onTertiary = onTertiary.animation(), + tertiaryContainer = tertiaryContainer.animation(), + onTertiaryContainer = onTertiaryContainer.animation(), + background = background.animation(), + onBackground = onBackground.animation(), + surface = surface.animation(), + onSurface = onSurface.animation(), + surfaceVariant = surfaceVariant.animation(), + onSurfaceVariant = onSurfaceVariant.animation(), + surfaceTint = surfaceTint.animation(), + inverseSurface = inverseSurface.animation(), + inverseOnSurface = inverseOnSurface.animation(), + error = error.animation(), + onError = onError.animation(), + errorContainer = errorContainer.animation(), + onErrorContainer = onErrorContainer.animation(), + outline = outline.animation(), + outlineVariant = outlineVariant.animation(), + scrim = scrim.animation(), + surfaceBright = surfaceBright.animation(), + surfaceDim = surfaceDim.animation(), + surfaceContainer = surfaceContainer.animation(), + surfaceContainerHigh = surfaceContainerHigh.animation(), + surfaceContainerHighest = surfaceContainerHighest.animation(), + surfaceContainerLow = surfaceContainerLow.animation(), + surfaceContainerLowest = surfaceContainerLowest.animation(), + ) +}