I'm trying to create a custom linear gauge style, but I'm wondering on how is the best way to make the circle move following the value. As you can notice I have tried with offset but it stay in place.
struct LightBarGaugeStyle: GaugeStyle {
private var gradient = LinearGradient(colors: [.blue, .yellow, .orange, .red], startPoint: .leading, endPoint: .trailing)
func makeBody(configuration: Configuration) -> some View {
VStack(alignment: .leading, spacing: 0) {
Circle()
.frame(width: 20)
.foregroundColor(.blue)
.offset(x: configuration.value)
Capsule()
.fill(gradient)
.frame(width: 1000, height: 30)
.overlay {
Capsule()
.stroke(lineWidth: 2)
.frame(width: 1000, height: 30)
.foregroundColor(.black)
}
}
}
}