import SwiftUI
struct VolumeControl: View {
@State private var value: Float = -30.0
var body: some View {
HStack {
Slider(value: $value, in: -48.0...0, step: 0.25)
Text("\(value, specifier: "%.2f") dB")
.font(.custom("", size: 18))
}
.onChange(of: value) { newValue in
// how can i detect if the slider is incrementing or decrementing?
}
}
}
}
My question
How can I detect, when the user moves the slider if the value is incrementing or decrementing?
If the user moves up the slider I need to call a method (for instance: volume up)
If the user moves down the slider I need to call another method (for instance: volume down)