Skip to content

Conversation

Jayxiang
Copy link
Member

@Jayxiang Jayxiang commented Jul 13, 2020

Update UITextField extensions,fixed UITextField addPaddingLeftIcon doesn't work on iOS 13(#876 ),Also I added addPaddingRight,addPaddingRightIcon;and testAddPaddingRight,testAddPaddingImageRightIcon

Checklist

  • I checked the Contributing Guidelines before creating this request.
  • New extensions are written in Swift 5.0.
  • New extensions support iOS 10.0+ / tvOS 9.0+ / macOS 10.10+ / watchOS 2.0+, or use @available if not.
  • 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 entry describing my changes.

Update UITextField extensions,fixed UITextField addPaddingLeftIcon doesn't work on iOS 13,add addPaddingRight,addPaddingRightIcon
@codecov
Copy link

codecov bot commented Jul 13, 2020

Codecov Report

Merging #878 into master will increase coverage by 2.78%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #878      +/-   ##
==========================================
+ Coverage   92.82%   95.61%   +2.78%     
==========================================
  Files         100       97       -3     
  Lines        3415     3328      -87     
==========================================
+ Hits         3170     3182      +12     
+ Misses        245      146      -99     
Flag Coverage Δ
#ios 95.61% <100.00%> (+0.01%) ⬆️
#macos ?
#tvos 93.60% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ces/SwifterSwift/UIKit/UITextFieldExtensions.swift 100.00% <100.00%> (ø)
...ources/SwifterSwift/AppKit/NSImageExtensions.swift
...ources/SwifterSwift/AppKit/NSColorExtensions.swift
Sources/SwifterSwift/AppKit/NSViewExtensions.swift
...ces/SwifterSwift/Shared/EdgeInsetsExtensions.swift 100.00% <0.00%> (+13.51%) ⬆️
.../SwifterSwift/CoreGraphics/CGColorExtensions.swift 100.00% <0.00%> (+50.00%) ⬆️

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 055732c...33ba375. Read the comment docs.

Copy link
Contributor

@guykogus guykogus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for fixing this. Left you a few notes.
Also, don't forget to add a CHANGELOG entry.

Comment on lines 151 to 152
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: padding, height: frame.height))
rightView = paddingView
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to do this in 2 steps. Also, you should be using bounds, not frame.

Suggested change
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: padding, height: frame.height))
rightView = paddingView
rightView = UIView(frame: CGRect(x: 0, y: 0, width: padding, height: bounds.height))

Feel free to fix the function above too.

Jayxiang and others added 2 commits July 17, 2020 18:24
Co-authored-by: Guy Kogus <guy.kogus@gmail.com>
Co-authored-by: Guy Kogus <guy.kogus@gmail.com>
@SwifterSwiftBot
Copy link

SwifterSwiftBot commented Jul 17, 2020

4 Messages
📖 Thank you for submitting a pull request to SwifterSwift. The team will review your submission as soon as possible.
📖 iOS: Executed 687 tests, with 0 failures (0 unexpected) in 22.138 (23.839) seconds
📖 tvOS: Executed 649 tests, with 0 failures (0 unexpected) in 4.526 (5.246) seconds
📖 macOS: Executed 512 tests, with 0 failures (0 unexpected) in 3.905 (4.183) seconds

Generated by 🚫 Danger

textfield.frame = CGRect(x: 0, y: 0, width: 100, height: 44)

let bundle = Bundle(for: UIImageExtensionsTests.self)
let image = UIImage(named: "TestImage", in: bundle)!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I thought the parameter was optional.

Suggested change
let image = UIImage(named: "TestImage", in: bundle)!
let image = UIImage(named: "TestImage", in: bundle, compatibleWith: nil)!

rightView = paddingView
rightViewMode = .always
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can set your Xcode Editing settings to trim whitespace lines. This will help avoid SwiftLint errors.

Suggested change

leftViewMode = .always
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

textfield.addPaddingRight(40)
XCTAssertEqual(textfield.rightView?.frame.width, 40)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@guykogus
Copy link
Contributor

@Jayxiang please see the issues and my comments regarding the SwiftLint warnings

@LucianoPAlmeida LucianoPAlmeida merged commit 59522d7 into SwifterSwift:master Jul 17, 2020
@SD10
Copy link
Member

SD10 commented Jul 17, 2020

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! 😃

nasircsms pushed a commit to nasircsms/SwifterSwift that referenced this pull request Aug 26, 2020
* 'master' of https://github.com/SwifterSwift/SwifterSwift: (79 commits)
  Helper functions for scrolling to the edges or by page of a scroll view (SwifterSwift#888)
  Add XCTest extension for comparing Color objects (SwifterSwift#889)
  Fix swiftlint error (SwifterSwift#894)
  Bump kramdown from 2.1.0 to 2.3.0 (SwifterSwift#891)
  Added note for UIView.addShadow() (SwifterSwift#890)
  loadFromNib(withClass) (SwifterSwift#885)
  constraint finders (widthConstraint, heightConstraint, leadingConstraint, trailingConstraint, topConstraint, bottomConstraint) (SwifterSwift#886)
  added String.regexEscaped (SwifterSwift#883)
  Make √ generic for FloatingPoint values (SwifterSwift#880)
  Update UITextField extensions (SwifterSwift#878)
  Added `masksToBounds` (IBInspectable) extension (SwifterSwift#877)
  Reinstate debounce function (SwifterSwift#869)
  `RandomAccessCollection`/`Collection` generalisations (SwifterSwift#863)
  Added HKActivitySummary extensions (SwifterSwift#875)
  Added new method for easily instantiating a view controller from a storyboard (SwifterSwift#860)
  Clean up code (SwifterSwift#864)
  fixed "".truncated crashed (SwifterSwift#866)
  Deprecated map(by:), compactMap(by:), filter(by:) (SwifterSwift#862)
  Overloaded 'contains' operator for string regex matching (SwifterSwift#858)
  Added convenient wrapper to asyncAfter (SwifterSwift#859)
  ...

# Conflicts:
#	Sources/SwifterSwift/AppKit/NSColorExtensions.swift
#	Sources/SwifterSwift/AppKit/NSImageExtensions.swift
#	Sources/SwifterSwift/AppKit/NSViewExtensions.swift
#	Sources/SwifterSwift/CoreGraphics/CGColorExtensions.swift
#	Sources/SwifterSwift/CoreGraphics/CGFloatExtensions.swift
#	Sources/SwifterSwift/CoreGraphics/CGPointExtensions.swift
#	Sources/SwifterSwift/CoreGraphics/CGSizeExtensions.swift
#	Sources/SwifterSwift/Foundation/NSAttributedStringExtensions.swift
#	Sources/SwifterSwift/SwiftStdlib/StringExtensions.swift
#	SwifterSwift.xcodeproj/project.pbxproj
#	Tests/AppKitTests/NSColorExtensionsTests.swift
#	Tests/SwiftStdlibTests/StringExtensionsTests.swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants