diff --git a/Sources/AnimationPlanner/Animations/Loop.swift b/Sources/AnimationPlanner/Animations/Loop.swift new file mode 100644 index 0000000..55e5547 --- /dev/null +++ b/Sources/AnimationPlanner/Animations/Loop.swift @@ -0,0 +1,29 @@ +import Foundation + +@available( + *, unavailable, + message: "Loop convenience struct has been removed following type checking changes in Swift 5.8. Use a for-loops or the sequence extension method `mapSequence()` or `mapGroup()` instead" +) +/// Loop through a sequence or for a specified repeat count to easily repeat multiple animation. +/// - Warning: This struct is no longer available. The same functionality can be achieved by using `for`-loop or the methods `mapSequence()` and `mapGroup()` on any Swift Sequence. +public struct Loop: SequenceAnimatable, GroupAnimatable { + public var duration: TimeInterval = 0 + public init( + for repeatCount: Int, + @SequenceBuilder animations builder: (_ index: Int) -> [SequenceAnimatable] + ) { } + + public static func through( + _ sequence: S, + @SequenceBuilder animations builder: (S.Element) -> [SequenceAnimatable] + ) -> [SequenceAnimatable] { + [] + } + + public static func through( + _ sequence: S, + @SequenceBuilder animations builder: (S.Element) -> [GroupAnimatable] + ) -> [GroupAnimatable] { + [] + } +} diff --git a/Sources/AnimationPlanner/Animations/MapSequence.swift b/Sources/AnimationPlanner/Animations/MapSequence.swift index 113525a..58b3532 100644 --- a/Sources/AnimationPlanner/Animations/MapSequence.swift +++ b/Sources/AnimationPlanner/Animations/MapSequence.swift @@ -1,6 +1,12 @@ import Foundation extension Swift.Sequence { + @available(*, unavailable, renamed: "mapSequence", message: "use either mapSequence or mapGroup") + public func mapAnimations( + @SequenceBuilder animations builder: (Element) -> [SequenceAnimatable] + ) -> [SequenceAnimatable] { + flatMap(builder) + } /// Maps values from the sequence to animations /// - Parameter animations: Add each animation from within this closure. Animations should conform to ``GroupAnimatable`` /// - Returns: Sequence of all animations created in the `animation` closure @@ -9,7 +15,9 @@ extension Swift.Sequence { ) -> [SequenceAnimatable] { flatMap(builder) } +} +extension Swift.Sequence { /// Maps values from the sequence to animations /// - Parameter animations: Add each animation from within this closure. Animations added to this loop should conform to ``GroupAnimatable`` /// - Returns: Group of all animations created in the `animation` closure