fix(ui): 缩小卡片并还原设计稿紧凑排布
This commit is contained in:
@@ -4,17 +4,19 @@ import SwiftUI
|
||||
struct MetricProgressBar: View {
|
||||
let value: Double
|
||||
let color: Color
|
||||
var cornerRadius: CGFloat? = nil
|
||||
|
||||
private var fraction: Double { value.isFinite ? min(1, max(0, value)) : 0 }
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { proxy in
|
||||
let shape = RoundedRectangle(cornerRadius: cornerRadius ?? proxy.size.height / 2, style: .continuous)
|
||||
ZStack(alignment: .leading) {
|
||||
Capsule().fill(color.opacity(0.15))
|
||||
Capsule().fill(color).frame(width: proxy.size.width * fraction)
|
||||
shape.fill(color.opacity(0.15))
|
||||
shape.fill(color).frame(width: proxy.size.width * fraction)
|
||||
}
|
||||
.frame(width: proxy.size.width, height: proxy.size.height)
|
||||
.clipShape(Capsule())
|
||||
.clipShape(shape)
|
||||
.transaction { $0.animation = nil; $0.disablesAnimations = true }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user