diff --git a/Sources/Private/CoreAnimation/Animations/RectangleAnimation.swift b/Sources/Private/CoreAnimation/Animations/RectangleAnimation.swift index 00420f6149..13379947bc 100644 --- a/Sources/Private/CoreAnimation/Animations/RectangleAnimation.swift +++ b/Sources/Private/CoreAnimation/Animations/RectangleAnimation.swift @@ -9,12 +9,17 @@ extension CAShapeLayer { func addAnimations( for rectangle: Rectangle, context: LayerAnimationContext, - pathMultiplier: PathMultiplier) + pathMultiplier: PathMultiplier, + roundedCorners: RoundedCorners?) throws { + let combinedKeyframes = try rectangle.combinedKeyframes( + context: context, + roundedCorners: roundedCorners) + try addAnimation( for: .path, - keyframes: try rectangle.combinedKeyframes(context: context).keyframes, + keyframes: combinedKeyframes.keyframes, value: { keyframe in BezierPath.rectangle( position: keyframe.position.pointValue, @@ -37,7 +42,12 @@ extension Rectangle { } /// Creates a single array of animatable keyframes from the separate arrays of keyframes in this Rectangle - func combinedKeyframes(context: LayerAnimationContext) throws-> KeyframeGroup { + func combinedKeyframes( + context: LayerAnimationContext, + roundedCorners: RoundedCorners?) throws + -> KeyframeGroup + { + let cornerRadius = roundedCorners?.radius ?? cornerRadius let combinedKeyframes = Keyframes.combinedIfPossible( size, position, cornerRadius, makeCombinedResult: Rectangle.Keyframe.init) diff --git a/Sources/Private/CoreAnimation/Animations/ShapeAnimation.swift b/Sources/Private/CoreAnimation/Animations/ShapeAnimation.swift index 9c0175e017..945eebe33e 100644 --- a/Sources/Private/CoreAnimation/Animations/ShapeAnimation.swift +++ b/Sources/Private/CoreAnimation/Animations/ShapeAnimation.swift @@ -12,12 +12,6 @@ extension CAShapeLayer { pathMultiplier: PathMultiplier, roundedCorners: RoundedCorners?) throws { - if roundedCorners != nil { - try context.compatibilityAssert(shape is Shape, """ - Rounded corners support is currently only implemented for Shape items - """) - } - switch shape { case let customShape as Shape: try addAnimations( @@ -28,15 +22,25 @@ extension CAShapeLayer { case let combinedShape as CombinedShapeItem: try addAnimations(for: combinedShape, context: context, pathMultiplier: pathMultiplier) + try context.compatibilityAssert(roundedCorners == nil, """ + Rounded corners support is not currently implemented for combined shape items + """) case let ellipse as Ellipse: try addAnimations(for: ellipse, context: context, pathMultiplier: pathMultiplier) case let rectangle as Rectangle: - try addAnimations(for: rectangle, context: context, pathMultiplier: pathMultiplier) + try addAnimations( + for: rectangle, + context: context, + pathMultiplier: pathMultiplier, + roundedCorners: roundedCorners) case let star as Star: try addAnimations(for: star, context: context, pathMultiplier: pathMultiplier) + try context.compatibilityAssert(roundedCorners == nil, """ + Rounded corners support is currently not implemented for polygon items + """) default: // None of the other `ShapeItem` subclasses draw a `path` diff --git a/Sources/Private/CoreAnimation/Extensions/KeyframeGroup+exactlyOneKeyframe.swift b/Sources/Private/CoreAnimation/Extensions/KeyframeGroup+exactlyOneKeyframe.swift index 4730913ab6..d20dc2d10f 100644 --- a/Sources/Private/CoreAnimation/Extensions/KeyframeGroup+exactlyOneKeyframe.swift +++ b/Sources/Private/CoreAnimation/Extensions/KeyframeGroup+exactlyOneKeyframe.swift @@ -17,6 +17,10 @@ extension KeyframeGroup { /// - In those sorts of cases, we currently choose one one `KeyframeGroup` to provide the /// timing information, and disallow simultaneous animations on the other properties. /// + /// - We could support animating all of the values simultaneously if we manually + /// interpolated the property for each individual frame, like we do in + /// `CombinedShapeItem.manuallyInterpolating` and `BezierPathKeyframe.combining` + /// func exactlyOneKeyframe( context: CompatibilityTrackerProviding, description: String,