Repository navigation
Remove sizeToFit() from SizeCalculable protocol - #164
Merged
Merged
Conversation
# Conflicts: # Podfile.lock # Sources/PinLayout+Size.swift
sizeToFit() from SizeCalculable protocol
lucdion
requested changes
Aug 14, 2018
| @discardableResult func aspectRatio() -> PinLayoutObjC | ||
| #endif | ||
|
|
||
| @discardableResult func sizeToFit() -> PinLayoutObjC |
Member
There was a problem hiding this comment.
Good catch 👍 We should eventually add more unit tests for objective-c.
| } else { | ||
| size.width = sizeThatFits.width | ||
| } | ||
| if case .fitTypeContent = adjustSizeType {} else { |
Member
There was a problem hiding this comment.
Icchh if case .fitTypeContent = adjustSizeType {} else { 😬. I would prefer a switch case here, even if it is longer, it is cleaner.
Member
|
@antoinelamy does this match also the size computed by UILabel.sizeToFit()? |
# Conflicts: # README.md # Sources/Impl/PinLayout+Layouting.swift # Sources/PinLayout+Size.swift
Contributor
Author
|
@lucdion sorry it took forever but I finally got the chance to make the requested changes. About your question wether or not it match the size computed by |
lucdion
approved these changes
Sep 15, 2018
Member
|
Thanks @antoinelamy 🙂 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As per the documentation, we should not directly override
sizeToFit()but rather always only implementsizeThatFits(_:)for auto-sizing needs. This PR aim to remove thesizeToFit()requirement in theSizeCalculableprotocol.Internally, UIView has a very basic implementation of the
sizeToFit()method which is the equivalent of callingsizeThatFitswith the view bounds so instead of calling it directly, we replicate its behaviour inside PinLayout (the implementation is not gonna change anytime soon anyway).The original class look like this in assembly pseudo-code:

Once converted into a more human readable form, the implementation source code look like this: