Skip to content

Instantly share code, notes, and snippets.

@emin-grbo
Created August 19, 2021 20:03
Show Gist options
  • Save emin-grbo/490449980d795d4b2b0e2254cfcdac9f to your computer and use it in GitHub Desktop.
Save emin-grbo/490449980d795d4b2b0e2254cfcdac9f to your computer and use it in GitHub Desktop.
Watch Haptics preview
import SwiftUI
struct ContentViewWatch: View {
@State var selection = 0
var body: some View {
VStack {
Picker("Haptic Type", selection: $selection) {
Text("notification").tag(0)
Text("directionUp").tag(1)
Text("directionDown").tag(2)
Text("success").tag(3)
Text("failure").tag(4)
Text("retry").tag(5)
Text("start").tag(6)
Text("stop").tag(7)
Text("click").tag(8)
}
}
.onTapGesture {
WKInterfaceDevice.current().play(WKHapticType(rawValue: selection)!)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentViewWatch()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment