From 9945bee5d2c21cf3c09d7860f56812a097205a1f Mon Sep 17 00:00:00 2001 From: zzh Date: Thu, 27 Nov 2025 12:45:22 +0800 Subject: [PATCH] =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/smarthome/ui/MainScaffold.kt | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/example/smarthome/ui/MainScaffold.kt b/app/src/main/java/com/example/smarthome/ui/MainScaffold.kt index 9f0a6ae..b4659b3 100644 --- a/app/src/main/java/com/example/smarthome/ui/MainScaffold.kt +++ b/app/src/main/java/com/example/smarthome/ui/MainScaffold.kt @@ -592,7 +592,7 @@ fun WeatherCard(weatherInfo: WeatherInfo, isLoading: Boolean) { label = "gradient" ) - // 根据天气状况决定背景颜色 - 增加颜色差异让流动更明显 + // 根据天气状况决定背景颜色 val colors = if (isLoading) { listOf( Color(0xFF2C3E50).copy(alpha = 0.6f), @@ -601,12 +601,12 @@ fun WeatherCard(weatherInfo: WeatherInfo, isLoading: Boolean) { ) } else { when { - // 晴天:暗橙色流动 + // 晴天:深橙色流动 weatherInfo.weather.contains("晴") -> listOf( - Color(0xFFB8450A).copy(alpha = 0.55f), - Color(0xFFC06000).copy(alpha = 0.55f), - Color(0xFFB8450A).copy(alpha = 0.55f) + Color(0xFF8B3000).copy(alpha = 0.65f), + Color(0xFF9A4500).copy(alpha = 0.65f), + Color(0xFF8B3000).copy(alpha = 0.65f) ) // 雨天:深紫深蓝流动 weatherInfo.weather.contains("雨") -> @@ -644,7 +644,7 @@ fun WeatherCard(weatherInfo: WeatherInfo, isLoading: Boolean) { start = Offset(offsetAnim, offsetAnim), end = Offset(offsetAnim + 500f, offsetAnim + 500f) ) - + Box( modifier = Modifier .clip(RoundedCornerShape(16.dp)) @@ -1628,12 +1628,13 @@ fun WeatherEffectLayer(weather: String, modifier: Modifier = Modifier) { label = "sun_rotation" ) - // 雨雪下落动画 + // 雨雪下落动画 - 使用更长的周期避免明显停顿 val dropOffset by infiniteTransition.animateFloat( initialValue = 0f, targetValue = 1f, animationSpec = infiniteRepeatable( - animation = tween(1500, easing = LinearEasing) + animation = tween(8000, easing = LinearEasing), + repeatMode = RepeatMode.Restart ), label = "drop_offset" ) @@ -1688,18 +1689,21 @@ fun WeatherEffectLayer(weather: String, modifier: Modifier = Modifier) { // 雨天:绘制下落的雨滴 weather.contains("雨") -> { - val dropCount = 8 - val dropLength = 8.dp.toPx() + val dropCount = 20 + val dropLength = 10.dp.toPx() for (i in 0 until dropCount) { - val x = (i * width / dropCount) + (i * 17 % 30) - val startY = (i * 29 % height.toInt()).toFloat() - val currentY = (startY + dropOffset * height) % height + // 使用不同的起始位置和速度让雨滴错开 + val xOffset = (i * 37 % 100) / 100f + val x = width * xOffset + val speedFactor = 3f + (i % 5) * 0.5f // 更快的速度,一个周期内多次循环 + val startOffset = (i * 73 % 100) / 100f // 不同起始位置 + val currentY = ((startOffset + dropOffset * speedFactor) % 1f) * height drawLine( - color = Color.White.copy(alpha = 0.3f), + color = Color.White.copy(alpha = 0.35f), start = Offset(x, currentY), - end = Offset(x - 2.dp.toPx(), currentY + dropLength), + end = Offset(x, currentY + dropLength), // 垂直下落 strokeWidth = 1.5f.dp.toPx() ) } @@ -1707,12 +1711,15 @@ fun WeatherEffectLayer(weather: String, modifier: Modifier = Modifier) { // 雪天:绘制飘落的雪花(圆点) weather.contains("雪") -> { - val snowCount = 8 + val snowCount = 18 for (i in 0 until snowCount) { - val x = (i * width / snowCount) + (i * 23 % 40) - val startY = (i * 41 % height.toInt()).toFloat() - val currentY = (startY + dropOffset * height * 0.5f) % height + // 使用不同的起始位置和速度让雪花错开 + val xOffset = (i * 41 % 100) / 100f + val x = width * xOffset + val speedFactor = 1.5f + (i % 4) * 0.3f // 雪花下落更慢 + val startOffset = (i * 67 % 100) / 100f + val currentY = ((startOffset + dropOffset * speedFactor) % 1f) * height drawCircle( color = Color.White.copy(alpha = 0.5f),