Skip to content

Implement CAKeyframeAnimation and CAAnimationGroup - #434

Open
michaelknoch wants to merge 4 commits into
masterfrom
keyframe-animations-and-groups
Open

Implement CAKeyframeAnimation and CAAnimationGroup#434
michaelknoch wants to merge 4 commits into
masterfrom
keyframe-animations-and-groups

Conversation

@michaelknoch

Copy link
Copy Markdown
Member

Brings keyframe animations and animation groups to UIKit-SDL, matching the iOS API so shared player code can drop its #if os(iOS) fork (the reward message's checkmark → medal flip stayed frozen on Android because these types didn't exist).

What's in here

  • CAKeyframeAnimationvalues, keyTimes, timingFunctions. Segments are picked from keyTimes (evenly spaced when omitted) and eased with the matching entry of timingFunctions; a timingFunction set on the animation itself still acts as overall pacing, as on iOS.
  • CAAnimationGroupanimations, duration. CALayer.add flattens a group into its children under "<key>.<index>", clipping each child to the group's duration and adding the group's delay, so the existing per-animation progress and completion handling applies unchanged.
  • transform.scale / transform.scale.x key paths — applied multiplicatively onto the presentation transform, so two parallel scale animations compose instead of the last one winning.
  • CAMediaTimingFunctionNameCAMediaTimingFunction(name: .easeOut) now compiles here too.
  • CALayer.add uses animation.copy() instead of hardcoding CABasicAnimation(from:), so subclasses keep their own fields.

values/keyTimes are [CGFloat]? rather than iOS's [Any]?/[NSNumber]? — the literal call sites are identical either way, and this avoids NSNumber on Android.

Tests

Five tests in UIKitTests/Animations/CAKeyframeAnimationTests.swift cover keyframe interpolation, keyTimes-driven segment durations, parallel children in a group, duration clipping, and that children are copied on add. Full UIKit suite passes; FlowkeyPlayer Mac and FlowkeyPlayer iOS build.

🤖 Generated with Claude Code

michaelknoch and others added 3 commits August 31, 2026 15:26
Mirrors the iOS API so shared player code (the reward message's medal
flip) no longer needs an `#if os(iOS)` fork.

* CAKeyframeAnimation with values, keyTimes and per-segment timingFunctions
* CAAnimationGroup, flattened into its children on add, clipped to the
  group's duration
* transform.scale and transform.scale.x key paths, applied multiplicatively
  so parallel scale animations compose instead of overwriting each other
* CAMediaTimingFunctionName, so CAMediaTimingFunction(name: .easeOut) works

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@michaelknoch
michaelknoch requested a review from ephemer August 31, 2026 15:06
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@ephemer ephemer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't used CAKeyframeAnimation or CAAnimationGroup so API-wise I'm taking your word for it. Code-wise it looks sound to me 🙏🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants