0

I'm trying to code a variable stride value for my digitalcrownrotation but can't get it to work. In this example here I'm using a conditional value in the "by" parameter: self.counterValue < 10.0 ? 1 : 20. Any idea what I'm doing wrong ?

struct AdjustTimeView: View {
    
    @State private var counterValue: Double = 1.0
    
    var body: some View {
        VStack {
            ZStack {
                Clockface()
                VStack {
                    Text("\(Int(counterValue))")
                        .font(.headline)
                        .fontWeight(.medium)
                        .foregroundColor(Color("MyBlueColor"))
                        .multilineTextAlignment(.center)
                        .focusable(true)
                        .digitalCrownRotation(self.$counterValue, from: 1.0, through: 180.0, by: self.counterValue < 10.0 ? 1 : 20, sensitivity: .medium, isContinuous: false, isHapticFeedbackEnabled: true)
                    
                    Text("min")
                        .font(.footnote)
                }
            }
        }
        .navigationBarTitle("Adjust time")
    }
}
Bjorn Morrhaye
  • 687
  • 9
  • 30
  • What do you mean by _"can't get it to work"_? Does the code compile? If not, please include the compiler error in your question. If it does compile, please specify how it's not working. – Dávid Pásztor Oct 19 '20 at 09:20
  • it compiles but the the stride keeps changing by 1, even if counter value > 10 – Bjorn Morrhaye Oct 19 '20 at 09:23

0 Answers0