Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Last active June 26, 2020 17:49
Show Gist options
  • Save sturdysturge/f5f8f45464f746d8cb876cc4d4188382 to your computer and use it in GitHub Desktop.
Save sturdysturge/f5f8f45464f746d8cb876cc4d4188382 to your computer and use it in GitHub Desktop.
GaugeView
import SwiftUI
struct GaugeView: View {
let sliderValue: Double
var body: some View {
VStack {
Gauge(value: sliderValue, in: 0...1) {
Text("Gauge")
}
.frame(maxHeight: .infinity)
}
}
}
struct ContentView: View {
@State var isCircular = false
@State var sliderValue = Double()
var body: some View {
VStack {
Toggle(isOn: $isCircular) {
Text("Circular")
}
if isCircular {
GaugeView(sliderValue: sliderValue)
.gaugeStyle(CircularGaugeStyle())
}
else {
GaugeView(sliderValue: sliderValue)
.gaugeStyle(LinearGaugeStyle())
}
Text("\(sliderValue)")
Slider(value: $sliderValue, in: 0...1) {
Text("Slider")
}
}
.padding()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment