Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃殌 Wrap to the content (String / AttributedText) UITextView #New-Extension #458

Merged
merged 8 commits into from May 1, 2018

Conversation

Projects
None yet
6 participants
@ratulSharker
Copy link
Member

commented Apr 23, 2018

Checklist

  • I checked the Contributing Guidelines before creating this request.
  • New extensions are written in Swift 4.
  • New extensions support iOS 8.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+.
  • I have added tests for new extensions, and they passed.
  • All extensions have a clear comments explaining their functionality, all parameters and return type in English.
  • All extensions are declared as public.
  • I have added a changelog

While UITextView is used as a non-scrollable text container (i.e chat bubble) some inset, offset, padding required to set to zero as following

textView.contentInset = UIEdgeInsets.zero
textView.scrollIndicatorInsets = UIEdgeInsets.zero
textView.contentOffset = CGPoint.zero
textView.textContainerInset = UIEdgeInsets.zero
textView.textContainer.lineFragmentPadding = 0
textView.sizeToFit()

This extension wrapToContent wrap everything up into a nice little instance method.

@ratulSharker ratulSharker changed the title Wrap to the content (String / AttributedText) Wrap to the content (String / AttributedText) UITextView #New-Extension Apr 23, 2018

@SwifterSwiftBot

This comment has been minimized.

Copy link

commented Apr 23, 2018

1 Message
馃摉 Thank you for submitting a pull request to SwifterSwift. The team will review your submission as soon as possible.

Generated by 馃毇 Danger

@ratulSharker ratulSharker reopened this Apr 23, 2018

@ratulSharker ratulSharker changed the title Wrap to the content (String / AttributedText) UITextView #New-Extension :rocket: Wrap to the content (String / AttributedText) UITextView #New-Extension Apr 23, 2018

@ratulSharker ratulSharker changed the title :rocket: Wrap to the content (String / AttributedText) UITextView #New-Extension :rocket: Wrap to the content (String / AttributedText) UITextView #New-Extension Apr 23, 2018

@ratulSharker ratulSharker changed the title :rocket: Wrap to the content (String / AttributedText) UITextView #New-Extension 馃殌 Wrap to the content (String / AttributedText) UITextView #New-Extension Apr 23, 2018

@codecov

This comment has been minimized.

Copy link

commented Apr 23, 2018

Codecov Report

Merging #458 into master will increase coverage by 0.08%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #458      +/-   ##
==========================================
+ Coverage   91.69%   91.77%   +0.08%     
==========================================
  Files          58       60       +2     
  Lines        2684     2711      +27     
==========================================
+ Hits         2461     2488      +27     
  Misses        223      223
Flag Coverage 螖
#ios 91.77% <100%> (+0.08%) 猬嗭笍
#osx 91.77% <100%> (+0.08%) 猬嗭笍
#tvos 91.77% <100%> (+0.08%) 猬嗭笍
Impacted Files Coverage 螖
...ources/Extensions/UIKit/UITextViewExtensions.swift 100% <100%> (酶) 猬嗭笍
Sources/Extensions/Foundation/URLExtensions.swift 100% <0%> (酶) 猬嗭笍
Sources/Extensions/UIKit/UIImageExtensions.swift 95.55% <0%> (酶) 猬嗭笍
...rces/Extensions/UIKit/UIScrollViewExtensions.swift 100% <0%> (酶)
...tensions/UIKit/UIGestureRecognizerExtensions.swift 100% <0%> (酶)

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update 00e2308...fcdfbc5. Read the comment docs.

Ratul Sharker and others added some commits Apr 23, 2018

Ratul Sharker
@BennX
Copy link
Member

left a comment

@ratulSharker Thank you very much for submitting this extension. 馃憤

Can't find anything which could be missing. Nice and clean 馃憤

I'd personally remove the self. since they are not required. What do you think @omaralbeik?

@ratulSharker

This comment has been minimized.

Copy link
Member Author

commented Apr 24, 2018

Thanks @BennX .

I agree, i have removed self from the extension instance method.

let text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

// initial setting
textView.frame = CGRect.init(x: 0, y: 0, width: 100, height: 20)

This comment has been minimized.

Copy link
@guykogus

guykogus Apr 26, 2018

Contributor

Minor point, but you don't need .init here and in the instances below.

@BennX

BennX approved these changes May 1, 2018

Copy link
Member

left a comment

Thank you very much.
Looks good to me. @LucianoPAlmeida @SD10

@SD10

This comment has been minimized.

Copy link
Member

commented May 1, 2018

Ok merging this. My odds of getting it right have significantly improved 馃槄

@SD10 SD10 merged commit 0ba61d6 into SwifterSwift:master May 1, 2018

4 checks passed

codecov/changes No unexpected coverage changes found.
Details
codecov/patch 100% of diff hit (target 91.69%)
Details
codecov/project 91.77% (+0.08%) compared to 00e2308
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@SD10

This comment has been minimized.

Copy link
Member

commented May 1, 2018

Thank you for contributing to SwifterSwift! I've invited you to join the SwifterSwift GitHub organization - no pressure to accept! If you'd like more information on what that means, check out our contributing guidelines. Feel free to reach out if you have any questions! 馃槂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.