Skip to content

Commit d984c4e

Browse files
committed
Change availability for animation modifier #patch
1 parent 1086365 commit d984c4e

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

Sources/SwiftUIPager/Helpers/OnAnimationCompletedModifier.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import SwiftUI
1010

1111
/// `ViewModifier` used to observe the end of an animation
12-
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
12+
@available(iOS 13.2, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
1313
struct OnAnimationCompletedModifier<Value>: AnimatableModifier where Value: VectorArithmetic {
1414

1515
var animatableData: Value {
@@ -39,7 +39,7 @@ struct OnAnimationCompletedModifier<Value>: AnimatableModifier where Value: Vect
3939
}
4040
}
4141

42-
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
42+
@available(iOS 13.2, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
4343
extension View {
4444

4545
/// Calls the completion handler whenever an animation on the given value completes.

Sources/SwiftUIPager/Helpers/View+Helper.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ extension View {
1515
frame(width: size.width, height: size.height)
1616
}
1717

18+
func eraseToAny() -> AnyView {
19+
AnyView(self)
20+
}
21+
1822
}

Sources/SwiftUIPager/PagerContent.swift

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ extension Pager {
186186
let wrappedView = stack
187187
#endif
188188

189-
return wrappedView
189+
var resultView = wrappedView
190190
.rotation3DEffect((isHorizontal ? .zero : Angle(degrees: 90)) + scrollDirectionAngle,
191191
axis: (0, 0, 1))
192192
.onDeactivate(perform: {
@@ -196,16 +196,22 @@ extension Pager {
196196
#endif
197197
}
198198
})
199-
.onAnimationCompleted(for: CGFloat(pagerModel.index), completion: {
200-
// #194 AnimatableModifier symbol not found in iOS 13.0 and iOS 13.1
201-
if #available(iOS 13.2, macOS 10.15, tvOS 13.0, watchOS 6.0, *) {
199+
.eraseToAny()
200+
201+
if #available(iOS 13.2, macOS 10.15, tvOS 13.0, watchOS 6.0, *) {
202+
resultView = resultView
203+
.onAnimationCompleted(for: CGFloat(pagerModel.index), completion: {
204+
// #194 AnimatableModifier symbol not found in iOS 13.0 and iOS 13.1
205+
202206
if pagerModel.pageIncrement != 0 {
203207
pagerModel.pageIncrement = 0
204208
onPageChanged?(pagerModel.index)
205209
}
206-
}
207-
})
208-
.contentShape(Rectangle())
210+
})
211+
.eraseToAny()
212+
}
213+
214+
return resultView.contentShape(Rectangle())
209215
}
210216
}
211217
}

SwiftUIPager.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "SwiftUIPager"
4-
s.version = ENV['LIB_VERSION']
4+
s.version = "2.3.0"
55
s.summary = "Native pager for SwiftUI. Easily to use, easy to customize."
66

77
s.description = <<-DESC

0 commit comments

Comments
 (0)