jtrivedi / Wave

Wave is a spring-based animation engine for iOS and macOS that makes it easy to create fluid, interruptible animations that feel great.
https://jtrivedi.github.io/Wave/
MIT License
2.02k stars 55 forks source link

Support for macOS and AppKit #25

Closed jtrivedi closed 1 year ago

jtrivedi commented 1 year ago

This PR adds macOS as a supported platform for Wave, and enables first-class animation support for AppKit.

AppKit apps can now use both the block-based and property-based animation APIs. There's also a tiny sample app for reference, which I'll add more to in the future.

For example, you can now do this:

let button = NSButton()
// configure it...

Wave.animate(withSpring: Spring(dampingRatio: 0.8, response: 1.2)) {
  button.layer?.animator.cornerRadius    = 24.0
  button.layer?.animator.backgroundColor = NSColor.systemGreen.cgColor
  button.layer?.animator.opacity         = 0.5
}

In a separate patch, I'll add NSView support, so you can animate frame, bounds, etc., and not just properties on CALayer.