🎬 恢复进度动画 (0.2s),value变化时平滑过渡,布局变化时瞬间响应

This commit is contained in:
JOJO 2026-05-05 21:47:41 +08:00
parent 794e23a178
commit d463189e39

View File

@ -66,6 +66,7 @@ struct StyledGauge: View {
) )
) )
.frame(width: max(geo.size.width * CGFloat(value / 100), 4), height: 8) .frame(width: max(geo.size.width * CGFloat(value / 100), 4), height: 8)
.animation(.easeOut(duration: 0.2), value: value)
} }
} }
.frame(height: 8) .frame(height: 8)
@ -91,6 +92,7 @@ struct StyledGauge: View {
Circle() Circle()
.stroke(Color.white.opacity(0.12), lineWidth: 5) .stroke(Color.white.opacity(0.12), lineWidth: 5)
.frame(width: 48, height: 48) .frame(width: 48, height: 48)
.animation(.easeOut(duration: 0.2), value: value)
Circle() Circle()
.trim(from: 0, to: CGFloat(value / 100)) .trim(from: 0, to: CGFloat(value / 100))
.stroke( .stroke(
@ -127,6 +129,7 @@ struct StyledGauge: View {
Text(String(format: "%.1f%@", value, unit)) Text(String(format: "%.1f%@", value, unit))
.font(.system(size: fontSize + 6, weight: .bold, design: .monospaced)) .font(.system(size: fontSize + 6, weight: .bold, design: .monospaced))
.foregroundColor(gaugeColor) .foregroundColor(gaugeColor)
.animation(.easeOut(duration: 0.2), value: value)
Spacer() Spacer()
Text(detail) Text(detail)
.font(.system(size: fontSize - 2)) .font(.system(size: fontSize - 2))
@ -148,6 +151,7 @@ struct StyledGauge: View {
.fill(gaugeColor.opacity(0.85)) .fill(gaugeColor.opacity(0.85))
.frame(width: 42, height: 42) .frame(width: 42, height: 42)
.clipShape(Circle()) .clipShape(Circle())
.animation(.easeOut(duration: 0.2), value: value)
Text(String(format: "%.0f", value)) Text(String(format: "%.0f", value))
.font(.system(size: fontSize - 2, weight: .bold, design: .monospaced)) .font(.system(size: fontSize - 2, weight: .bold, design: .monospaced))
@ -178,6 +182,7 @@ struct StyledGauge: View {
RoundedRectangle(cornerRadius: 4) RoundedRectangle(cornerRadius: 4)
.fill(gaugeColor) .fill(gaugeColor)
.frame(width: max(geo.size.width * CGFloat(value / 100), 3), height: 14) .frame(width: max(geo.size.width * CGFloat(value / 100), 3), height: 14)
.animation(.easeOut(duration: 0.2), value: value)
} }
} }
.frame(height: 14) .frame(height: 14)