digitalCrownRotation not updating value on text

Viewed 29

I am building a simple water tracking app, and I want to use the digital crown for increasing/decreasing the value of drunk water.

However .digitalCrownRotation won't update the value. I have tried everything but without any luck.

What am I doing wrong?

This is my code

struct ContentView: View {
    @State private var counter: Double = 0.0
    var body: some View {
        VStack {
            HStack {
                Text("\(counter, specifier: "%.1f") L")
                    .focusable().digitalCrownRotation(self.$counter, from: 0, through: 5, by: 0.1, sensitivity: .medium, isContinuous: true, isHapticFeedbackEnabled: true)
            }
            Spacer()
            Button("Confirm", action: {
                print("ciao confirm")
            })
        }
    }
}
0 Answers
Related