-
Notifications
You must be signed in to change notification settings - Fork 57
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
Migrated to Swift 4 #199
Migrated to Swift 4 #199
Conversation
Example/Source/Theme.swift
Outdated
NSForegroundColorAttributeName: Theme.textColorForNavigationTitle, | ||
NSFontAttributeName: Theme.fontForNavigationTitle | ||
NSAttributedStringKey.foregroundColor: Theme.textColorForNavigationTitle, | ||
NSAttributedStringKey.font: Theme.fontForNavigationTitle |
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.
you should be able to remove the NSAttributedStringKey
and just use .foregroundColor
and .font
Example/Source/Theme.swift
Outdated
NSForegroundColorAttributeName: Theme.textColorForNavigationTitle, | ||
NSFontAttributeName: Theme.fontForNavigationTitle | ||
NSAttributedStringKey.foregroundColor: Theme.textColorForNavigationTitle, | ||
NSAttributedStringKey.font: Theme.fontForNavigationTitle |
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.
same here, remove the NSAttributedStringKey
type whenever possible
Source/Cells/BrickCell.swift
Outdated
@@ -257,7 +257,7 @@ open class BrickCell: BaseBrickCell { | |||
open func heightForBrickView(withWidth width: CGFloat) -> CGFloat { | |||
self.layoutIfNeeded() | |||
|
|||
let size = self.systemLayoutSizeFitting(CGSize(width: width, height: 0), withHorizontalFittingPriority: 1000, verticalFittingPriority: 10) | |||
let size = self.systemLayoutSizeFitting(CGSize(width: width, height: 0), withHorizontalFittingPriority: UILayoutPriority.required, verticalFittingPriority: UILayoutPriority(rawValue: 10)) |
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.
just use .required
XCTAssertEqual(cell2!.transform.scaleX, 5/6, accuracy: 0.01) | ||
XCTAssertEqual(cell2!.transform.scaleY, 5/6, accuracy: 0.01) | ||
XCTAssertEqual(cell3!.transform.scaleX, 5/6, accuracy: 0.01) | ||
XCTAssertEqual(cell3!.transform.scaleY, 5/6, accuracy: 0.01) |
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.
I think you might be able to use ?
instead of !
for these, so that if the cell is nil it wont crash the test runner. can you try changing that and seeing if it works?
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.
Nope, that gives a error, All the prams have to be not optional on XCTAssertEqual
when using accuracy
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.
My preference would be to do let cell1 = brickView.cellForItem(at: IndexPath(item: 0, section: 1))!
instead of adding cell!
over and over. The problem, however is that it would crash if there's no cell instead of triggering a test failure (which is arguably a bit more graceful). So even better would be to guard let cell1 = .. else { XCTFail() }
because you can provide a message.
XCTAssertEqual(cell2!.transform.scaleX, 5/6, accuracy: 0.01) | ||
XCTAssertEqual(cell2!.transform.scaleY, 5/6, accuracy: 0.01) | ||
XCTAssertEqual(cell3!.transform.scaleX, 0.5, accuracy: 0.01) | ||
XCTAssertEqual(cell3!.transform.scaleY, 0.5, accuracy: 0.01) |
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.
Ditto
thirdAttributes = layout.layoutAttributesForItem(at: IndexPath(item: 2, section: 0)) | ||
XCTAssertEqualWithAccuracy(thirdAttributes!.frame, CGRect(x: 0, y: 400, width: 320, height: 100), accuracy: CGRect(x: 1, y: 1, width: 1, height: 1)) | ||
XCTAssertEqual(thirdAttributes!.frame, CGRect(x: 0, y: 400, width: 320, height: 100), accuracy: CGRect(x: 1, y: 1, width: 1, height: 1)) |
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.
same in this file if you can use ?
Codecov Report
@@ Coverage Diff @@
## master #199 +/- ##
========================================
Coverage ? 92.7%
========================================
Files ? 40
Lines ? 4513
Branches ? 375
========================================
Hits ? 4184
Misses ? 328
Partials ? 1
Continue to review full report at Codecov.
|
Just make sure to squash this into a single "Migrated to Swift 4" commit before merging to make it cleaner. |
Migrated to swift 4.0
closes #198