Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created October 19, 2022 22:51
Show Gist options
  • Select an option

  • Save sturdysturge/aa58c37633fa97d05d7460482b10fdc4 to your computer and use it in GitHub Desktop.

Select an option

Save sturdysturge/aa58c37633fa97d05d7460482b10fdc4 to your computer and use it in GitHub Desktop.
import SwiftUI
import Introspect
struct ContentView: View {
@State var sliderValue = 0.0
@State var toggleValue = false
@State var stepperValue = 0.0
@State var textViewValue = ""
@State var colour = Color.clear
@State var textFieldValue = "Text"
@State var date = Date()
let stuff = ["one", "two", "three"]
var body: some View {
VStack {
Slider(value: $sliderValue, in: 0...1)
.introspectSlider { slider in
slider.minimumValueImage = UIImage(systemName: "pencil")
slider.minimumValueImage = UIImage(systemName: "house")
}
Toggle(isOn: $toggleValue) {
Text("Toggle")
}
.introspectSwitch { uiSwitch in
uiSwitch.offImage = UIImage(systemName: "pencil")
uiSwitch.onImage = UIImage(systemName: "house")
}
Stepper("Stepper: \(stepperValue)", value: $stepperValue, in: 0...10)
.introspectStepper { stepper in
stepper.wraps = true
stepper.isContinuous = false
}
TextEditor(text: $textViewValue)
.introspectTextView { textView in
textView.isSelectable = false
}
ColorPicker("Colour", selection: $colour, supportsOpacity: false)
.introspectColorWell { colorWell in
colorWell.supportsAlpha = true
}
List(stuff, id: \.self) { thing in
Text(thing)
}
.introspectTableView { tableView in
tableView.setEditing(true, animated: true)
}
TextField("", text: $textFieldValue)
.introspectTextField { textField in
textField.clearButtonMode = .unlessEditing
}
DatePicker("Date", selection: $date)
.introspectDatePicker{ datePicker in
datePicker.minimumDate = .init(timeIntervalSince1970: 971992542)
}
ScrollView {
ForEach(stuff, id: \.self) { thing in
Text(thing)
}
}
.introspectScrollView { scrollView in
scrollView.bounces = false
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment