-
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
Conversation
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.
Thanks for your contribution 👏 I really appreciate it 😄
I have some style comments you to address 👇
Is the default:
case required in Swift 5? Or are you adding it for logical completeness?
@@ -31,7 +31,10 @@ open class CenteredCollectionViewFlowLayout: UICollectionViewFlowLayout { | |||
return itemSize.width + minimumLineSpacing | |||
case .vertical: | |||
return itemSize.height + minimumLineSpacing | |||
} | |||
|
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
|
||
default: | ||
return 0 | ||
} |
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.
The spacing here doesn't match the rest of the code. Would you mind making the stacking consistent with the rest of the file?
|
||
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 comment
The 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?
@@ -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 comment
The 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?
|
||
default: | ||
proposedContentOffset = .zero | ||
shouldAnimate = false |
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.
The spacing here doesn't match the rest of the code. Would you mind making the stacking consistent with the rest of the file?
@@ -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 comment
The 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?
@@ -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 comment
The 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?
Below are excerpts from https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html :) "Every switch statement must be exhaustive. That is, every possible value of the type being considered must be matched by one of the switch cases. If it’s not appropriate to provide a case for every possible value, you can define a default case to cover any values that are not addressed explicitly. This default case is indicated by the default keyword, and must always appear last." |
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.
Awesome work 💯 Your contribution is greatly appreciated 👏
Update to Swift 5.0 :)