-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to Swift 5.0 #42
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ public extension UICollectionView { | |
/// - Parameters: | ||
/// - frame: The frame rectangle for the collection view, measured in points. The origin of the frame is relative to the superview in which you plan to add it. This frame is passed to the superclass during initialization. | ||
/// - centeredCollectionViewFlowLayout: The `CenteredCollectionViewFlowLayout` for the `UICollectionView` to be configured with. | ||
public convenience init(frame: CGRect = .zero, centeredCollectionViewFlowLayout: CenteredCollectionViewFlowLayout) { | ||
convenience init(frame: CGRect = .zero, centeredCollectionViewFlowLayout: CenteredCollectionViewFlowLayout) { | ||
self.init(frame: frame, collectionViewLayout: centeredCollectionViewFlowLayout) | ||
decelerationRate = UIScrollView.DecelerationRate.fast | ||
} | ||
|
@@ -31,7 +31,10 @@ open class CenteredCollectionViewFlowLayout: UICollectionViewFlowLayout { | |
return itemSize.width + minimumLineSpacing | ||
case .vertical: | ||
return itemSize.height + minimumLineSpacing | ||
} | ||
|
||
default: | ||
return 0 | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spacing here doesn't match the rest of the code. Would you mind making the stacking consistent with the rest of the file? |
||
} | ||
|
||
/// Calculates the current centered page. | ||
|
@@ -70,6 +73,10 @@ open class CenteredCollectionViewFlowLayout: UICollectionViewFlowLayout { | |
let inset = (currentCollectionViewSize.height - itemSize.height) / 2 | ||
collectionView.contentInset = UIEdgeInsets(top: inset, left: 0, bottom: inset, right: 0) | ||
collectionView.contentOffset = CGPoint(x: 0, y: -inset) | ||
|
||
default: | ||
collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) | ||
collectionView.contentOffset = .zero | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spacing here doesn't match the rest of the code. Would you mind making the stacking consistent with the rest of the file? |
||
} | ||
lastCollectionViewSize = currentCollectionViewSize | ||
lastScrollDirection = scrollDirection | ||
|
@@ -111,6 +118,9 @@ open class CenteredCollectionViewFlowLayout: UICollectionViewFlowLayout { | |
newOffset += velocity.y > 0 ? pageHeight : -pageHeight | ||
} | ||
return CGPoint(x: proposedContentOffset.x, y: newOffset) | ||
|
||
default: | ||
return .zero | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spacing here doesn't match the rest of the code. Would you mind making the stacking consistent with the rest of the file? |
||
} | ||
} | ||
|
||
|
@@ -133,6 +143,10 @@ open class CenteredCollectionViewFlowLayout: UICollectionViewFlowLayout { | |
let pageOffset = CGFloat(index) * pageWidth - collectionView.contentInset.top | ||
proposedContentOffset = CGPoint(x: collectionView.contentOffset.x, y: pageOffset) | ||
shouldAnimate = abs(collectionView.contentOffset.y - pageOffset) > 1 ? animated : false | ||
|
||
default: | ||
proposedContentOffset = .zero | ||
shouldAnimate = false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spacing here doesn't match the rest of the code. Would you mind making the stacking consistent with the rest of the file? |
||
} | ||
collectionView.setContentOffset(proposedContentOffset, animated: shouldAnimate) | ||
} | ||
|
@@ -148,6 +162,8 @@ private extension CenteredCollectionViewFlowLayout { | |
origin = CGPoint(x: proposedContentOffset.x, y: collectionView.contentOffset.y) | ||
case .vertical: | ||
origin = CGPoint(x: collectionView.contentOffset.x, y: proposedContentOffset.y) | ||
default: | ||
origin = .zero | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spacing here doesn't match the rest of the code. Would you mind making the stacking consistent with the rest of the file? |
||
} | ||
return CGRect(origin: origin, size: size) | ||
} | ||
|
@@ -166,6 +182,8 @@ private extension CenteredCollectionViewFlowLayout { | |
proposedCenterOffset = proposedContentOffset.x + collectionView.bounds.size.width / 2 | ||
case .vertical: | ||
proposedCenterOffset = proposedContentOffset.y + collectionView.bounds.size.height / 2 | ||
default: | ||
proposedCenterOffset = .zero | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spacing here doesn't match the rest of the code. Would you mind making the stacking consistent with the rest of the file? |
||
} | ||
|
||
for attributes in layoutAttributes { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: remove this extra newline