Skip to content

Commit

Permalink
iOS 13.2 Simplistic onPageChanged
Browse files Browse the repository at this point in the history
  • Loading branch information
fermoya committed Mar 6, 2021
1 parent e21e8b4 commit 1f91e01
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Sources/SwiftUIPager/PagerContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,11 @@ extension Pager {
}
})
.onAnimationCompleted(for: CGFloat(pagerModel.index), completion: {
if pagerModel.pageIncrement != 0 {
onPageChanged?(pagerModel.index)
// #194 AnimatableModifier symbol not found in iOS 13.0 and iOS 13.1
if #available(iOS 13.2, macOS 10.15, tvOS 13.0, watchOS 6.0, *) {
if pagerModel.pageIncrement != 0 {
onPageChanged?(pagerModel.index)
}
}
})
.contentShape(Rectangle())
Expand Down Expand Up @@ -286,6 +289,13 @@ extension Pager.PagerContent {
self.pagerModel.index = newPage
self.pagerModel.objectWillChange.send()
}

// #194 AnimatableModifier symbol not found in iOS 13.0 and iOS 13.1
if #available(iOS 13.2, macOS 10.15, tvOS 13.0, watchOS 6.0, *) {
// Do nothing
} else if page != newPage {
onPageChanged?(newPage)
}
}

var dragResult: (page: Int, increment: Int) {
Expand Down

0 comments on commit 1f91e01

Please sign in to comment.