Skip to content

Commit

Permalink
Added errors for unavailable structs and methods
Browse files Browse the repository at this point in the history
  • Loading branch information
PimCoumans committed Apr 27, 2023
1 parent 439f10b commit 4705b4a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Sources/AnimationPlanner/Animations/Loop.swift
Original file line number Diff line number Diff line change
@@ -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<S: Swift.Sequence>(
_ sequence: S,
@SequenceBuilder animations builder: (S.Element) -> [SequenceAnimatable]
) -> [SequenceAnimatable] {
[]
}

public static func through<S: Swift.Sequence>(
_ sequence: S,
@SequenceBuilder animations builder: (S.Element) -> [GroupAnimatable]
) -> [GroupAnimatable] {
[]
}
}
8 changes: 8 additions & 0 deletions Sources/AnimationPlanner/Animations/MapSequence.swift
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4705b4a

Please sign in to comment.