Skip to content

Rebuilds the sample app in the WWDC 2019 Session 223 using SwiftUI

Notifications You must be signed in to change notification settings

PBBB/CoreHapticsPalette

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Core Haptics Palette

Rebuilds the sample app in the WWDC 2019 Session 223 using SwiftUI.

A screenshot of the HapticPalette interface, showing a labeled circle and the meaning of coordinate axes controlling intensity and sharpness.

Currently WIP

  • Building UI
  • Adding drag interaction
  • Adding bounds to the drag interaction
  • Calculating parameters using the position of the circle
  • Adding Core Haptics
  • Dark mode support

Discussion

I could not figure out how to add bounds to the drag interaction properly. I came up with two options:

  1. Save gesture data as @State, and calculate the offset of the circle using the frame data of GeometryReader. However, when the circle is dragged out of the rectangle, though the circle stays inside the rectangle near the edge, the gesture data still includes part of the offset which exceeeds the frame of the rectangle (because the calculation is inside the "body"). When dragging the circle back to the center of the rectangle, the circle doesn't move at all at first.
  2. Calculate offset inside gesture's "updating" modifier. But you simply cannot get the frame of the rectangle outside of the "body". And the frame can change dramatically, like when rotating the device or using split screen etc. This means you have to listen to the layout event, which in my opinion doesn't comply with what SwiftUI is all about.

So maybe it's time to pause the project, and learn more about SwiftUI now.

About

Rebuilds the sample app in the WWDC 2019 Session 223 using SwiftUI

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages