Add extension of UIlabel for adding line spacing with the method of n…#438
Add extension of UIlabel for adding line spacing with the method of n…#438osama10 wants to merge 16 commits intoEsqarrouth:masterfrom
Conversation
…ame setLineSpacing
Generated by 🚫 Danger |
…ame setLineSpacing
| } | ||
|
|
||
| // Set lineSpacing for UILabel | ||
| public func setLineSpacing(lineSpacing: CGFloat) { |
There was a problem hiding this comment.
Is it possible to write a unit test for this ?
|
Could you also add a changelog entry for this. ? |
|
Can you please guide me how to do this I am doing.my first contribution . I'll be very thankful to you if you guide me about thisOn 11-Jul-2017 10:16 pm, Arunav Sanyal <notifications@github.com> wrote:Could you also add a changelog entry for this. ?
—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.
|
| public func setLineSpacing(lineSpacing: CGFloat) { | ||
| let paragraphStyle = NSMutableParagraphStyle() | ||
| paragraphStyle.lineSpacing = 1.0 | ||
| paragraphStyle.lineHeightMultiple = lineSpacing |
There was a problem hiding this comment.
This is confusing. Does this mean your spacing = 1.0 * lineHeight = lineSpacing. If so, you could just call the method arg as lineHeightMultiple.
| paragraphStyle.lineHeightMultiple = lineSpacing | ||
| paragraphStyle.alignment = self.textAlignment | ||
|
|
||
| let attrString = NSMutableAttributedString(string: self.text!) |
There was a problem hiding this comment.
This could actually live as its own var. Otherwise its unnecessary allocation of the attr string per call.
| paragraphStyle.alignment = self.textAlignment | ||
|
|
||
| let attrString = NSMutableAttributedString(string: self.text!) | ||
| attrString.addAttribute(NSFontAttributeName, value: self.font, range: NSMakeRange(0, attrString.length)) |
There was a problem hiding this comment.
NSMakeRange is repeated, you can abstract that away as a single call.
| - `validateDigits()` in [[PR]](https://github.com/goktugyil/EZSwiftExtensions/pull/429) by *Vic-L* | ||
|
|
||
| 12. **UILabelExtensions** | ||
| - `setLineSpacing(lineSpacing : CGFloat)` in [[PR]](https://github.com/goktugyil/EZSwiftExtensions/pull/438) by *osama10* |
There was a problem hiding this comment.
Erm not under v1.10. Under unreleased. V 1.10 is already released as a pod.
Codecov Report
@@ Coverage Diff @@
## master #438 +/- ##
=========================================
Coverage ? 41.93%
=========================================
Files ? 50
Lines ? 2258
Branches ? 0
=========================================
Hits ? 947
Misses ? 1311
Partials ? 0
Continue to review full report at Codecov.
|
|
|
||
| ## Unreleased | ||
|
|
||
| **UILabelExtensions** |
There was a problem hiding this comment.
Minor : With a number (in this case 1).
There was a problem hiding this comment.
So do I need removed this spacing ??
There was a problem hiding this comment.
have a 1 prior to that. Like a numbering thing. But that is really cosmetic, I would suggest taking a look at writing unit tests for the same.
|
I am new to swift development and don't know yet about writing unit test yet ... what should I do and is it necessary to write unit test for ensuring the acceptance of my contributionOn 13-Jul-2017 10:56 pm, Arunav Sanyal <notifications@github.com> wrote:@Khalian commented on this pull request.
In CHANGELOG.md:
@@ -2,7 +2,8 @@
All notable changes to this project will be documented in this file.
## Unreleased
-
+ **UILabelExtensions**
have a 1 prior to that. Like a numbering thing. But that is really cosmetic, I would suggest taking a look at writing unit tests for the same.
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.
|
|
"I am new to swift development and don't know yet about writing unit test yet ... what should I do" In order to write unit tests you would have to edit the unit test file, in your case https://github.com/goktugyil/EZSwiftExtensions/blob/master/EZSwiftExtensionsTests/UILabelTests.swift and run that against travis ci build (you can locally test the change on xcode by running the test target we wrote). "is it necessary to write unit test for ensuring the acceptance of my contributionOn" A unit test is a contract that gives reasonable confidence on the veracity of your changes. It also provides documentation in the form of self explanatary code, and also what said extension is meant to achieve. Unless its impossible to achieve writing a unit tests (an example would be UIDevice tests were write based mocks are blocked by swifts runtime), we should have unit tests. |
|
@Khalian It's not possible to write the unit test of my extension as it gives the line spacing between the lines of label and can on be witnessed visually. |
|
so what should i do now to get my contribution accepted. @Khalian |
The purpose of the test is to make the method not brittle to change. "so what should i do now to get my contribution accepted. @Khalian"
|
|
@Khalian i have added the test . Now what should i do ?? |
| label.setLineSpacing(lineSpacing: 1.5) | ||
|
|
||
| label.attributedText?.enumerateAttribute(NSParagraphStyleAttributeName , in: NSMakeRange(0, (label.attributedText?.length)!), options: [.longestEffectiveRangeNotRequired]) { value, range, isStop in | ||
|
|
There was a problem hiding this comment.
nitpick : too many empty lines here are there that do not serve a purpose.
|
I have quite a few comments across the files. Can you take a look at those? |
# Conflicts: # EZSwiftExtensionsTests/UILabelTests.swift
| // | ||
|
|
||
| #if os(iOS) || os(tvOS) | ||
| <<<<<<< HEAD |
There was a problem hiding this comment.
You have unresolved merge commits here.
| XCTAssertEqual(label2.font.pointSize, 20) | ||
| XCTAssertEqual(label.font.pointSize, 17) | ||
| } | ||
| >>>>>>> 638c47200b16776d978dc4598237109396915878 |
There was a problem hiding this comment.
This looks like an unresolved merge, please collapse your commits into one idempotent change.
I cannot even begin to tell you how much I despise non fast forward merges. Rebase your changes and replay them on top of the current HEAD commit.
| @testable import EZSwiftExtensions | ||
| class UILabelTests: XCTestCase { | ||
|
|
||
| let label = UILabel(x: 0, y: 0, w: 200, h: 50) |
There was a problem hiding this comment.
Are there any changes in these parts? Please make the code change idempotent to only the changes you are making. This looks like an indentation change which is unnecessary. The code already was properly indented.
Another important part of making this change idempotent is to ensure it appears as one single commit in the PR. I do not want to manually merge 12 commits with a couple of merge commits in it.
|
@Khalian Can you please tell me what is the issue with my commit |
|
I have added the extension of UILabel for adding linespacing between line of UILabel , it takes CGFloat as input and add that spacing to the UILabel
Checklist