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
Added UIView, NSView and CGRect extensions #38
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.
Looks good! I let you a few comments about the README, otherwise that's a cool add 👍
let rect = CGRect(x: 10, y: 20, width: 30, height: 40) | ||
let widerRect = rect.with(width: 100) | ||
let tallerRect = rect.with(height: 100) | ||
let rectAtAnotherPosition = rect.with(x: 100).with(y: 200) |
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.
Can you add a comment // result printed once changed
for each of them?
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.
What do you mean by "result printed once changed"? I didn't have any print statements.
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.
For example:
let widerRect = rect.with(width: 100) // x: 10, y: 20, width: 130, height: 140
aView.width -= 10 // make the view narrower | ||
aView.height -= 10 // make the view shorter | ||
``` | ||
|
||
It will iterate on all the subviews of the view, and use the text / placeholder as key in `NSLocalizedString`. |
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.
That comment must be below Automates your localizables
and above the new section.
@@ -1090,6 +1108,14 @@ mySwitch.toggle() | |||
aView.convertLocalizables() | |||
``` | |||
|
|||
**Change the frame of the view easily** | |||
```swift | |||
aView.x += 100 // move to right |
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.
Can you add a var aView: UIView
to make the example more concrete?
@@ -1221,6 +1247,14 @@ view.addGestureRecognizer(blockTapGesture) | |||
aView.convertLocalizables() | |||
``` | |||
|
|||
**Change the frame of the view easily** | |||
```swift | |||
aView.x += 100 // move to right |
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.
Can you add a var aView: NSView
to make the example more concrete?
aView.width -= 10 // make the view narrower | ||
aView.height -= 10 // make the view shorter | ||
``` | ||
|
||
It will iterate on all the subviews of the view, and use the text / placeholder as key in `NSLocalizedString`. |
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: that comment is for the above section / example
public func with(x: CGFloat) -> CGRect | ||
public func with(y: CGFloat) -> CGRect | ||
public func with(width: CGFloat) -> CGRect | ||
public func with(height: CGFloat) -> CGRect |
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.
What do you think to add func with(origin: CGPoint) -> CGRect
and func with(size: CGSize) -> CGRect
, can it be useful? 🤔
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.
Yeah, that's a good idea! I didn't think of that.
Also, can you add some tests? It's straight forward, should never fail, but we are never careful enough! |
Ok. I forgot about them! |
I have added everything (hopefully)! Can this merge? |
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 have a last request changes: can you duplicate the UIViewExtensionsTests
for macOS as well?
Done! |
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.
Perfect! Feel free to merge it once travis is green 🎉
Thanks for that PR!
There's a few SwiftLint
By the way, I suggest you ton install it, it's a nice linter and you will have the warnings / errors directly in xcode when building 😬 |
Is .swiftlint.yml a file I have to create? I can't find it in the repo. |
The configuration file for the core is there: |
I went ahead and fix it (+ bump a few others warnings due to the latest release) in #39 You will just have to rebase your PR once I merged the other, then, everything should be ok. |
Do you mean that once #39 is merged, I can press the bottom button there? Is that what rebase means? |
We have to ensure first that travis is passing as expected (should be no issue there), but in order to test that, you have to rebase without merging, which means pull the lasts commits from master in your branch. Using If you are using a terminal:
If you are using an application (tower, source tree...), they have generally an option build in to do it. Let me know if you need more information! |
Ok, seems easy. I'll do that once I get back! |
It is telling me that |
Yeah, should be that, my bad |
0a617f5
to
b77ad28
Compare
All good 👍 Feel free to merge that PR once travis is done. |
Seems to be an issue left:
Just in case you don't know: you can click on "Details" (like in the below screenshot) to see the travis status (current build, success, failure... and details about what did fail) |
I think I fixed it. I built the target and ran the test. They all succeeded so it should be alright. Right? |
Travis will tell us soon enough 😬 |
@Sweeper777 Side note for the next time (I pushed directly in your branch this time):
Otherwise 💯 |
Is it normal for Travis to take so long? Is something wrong? |
It can, that's depending how many build Travis is handling at the same time, and their structures status. Sometimes it's quite long... |
Oops! I was on my phone and I accidentally merged it! I'm so sorry! Travis seems to still fail saying that tests failed. |
The build failed of travis wasn't due to test but a timeout, it happened, the only solution in this case is to start again the build which has failed. I think you have the rights to do that since you are a contributor. For the next time if there's really a test which has failed and a PR is accidentally merged, the good move is just to rollback to the last master commit before the merge, you can find the command line on SO. For now, it's all good 👍 |
Maybe update to 0.7.0 now? |
👌Will do it this weekend or next week |
I added some things that make dealing with positions and sizes easier. e.g. you can easily change a view's position by setting its
x
andy
properties.