-
-
Save sturdysturge/f5f8f45464f746d8cb876cc4d4188382 to your computer and use it in GitHub Desktop.
GaugeView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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