Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mayasaxena committed Jun 20, 2018
1 parent 522c16a commit f390a8a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
8 changes: 4 additions & 4 deletions SwiftWisdom.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
80D63D241C4F231C00C88D00 /* Synchronize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80D63D231C4F231C00C88D00 /* Synchronize.swift */; };
80D63D261C4F236F00C88D00 /* Not.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80D63D251C4F236F00C88D00 /* Not.swift */; };
80D63D2F1C4F251E00C88D00 /* UnsignedInteger+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 80D63D2C1C4F251E00C88D00 /* UnsignedInteger+Extensions.swift */; };
A4BB8A9420DAF35000F60485 /* String+Trimmed.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4BB8A9320DAF35000F60485 /* String+Trimmed.swift */; };
A53A4EE71EEF330100CC53C6 /* Rx+String.swift in Sources */ = {isa = PBXBuildFile; fileRef = A53A4EE61EEF330100CC53C6 /* Rx+String.swift */; };
A53A4EE91EF01F8000CC53C6 /* String+Trimmed.swift in Sources */ = {isa = PBXBuildFile; fileRef = A53A4EE81EF01F8000CC53C6 /* String+Trimmed.swift */; };
CD16463F1CC16A410049BBD5 /* UILabel+Typography.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD16463E1CC16A410049BBD5 /* UILabel+Typography.swift */; };
CDCDE2561E67A6EC007B3784 /* ResultTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDCDE2551E67A6EC007B3784 /* ResultTests.swift */; };
CDCDE2591E67C574007B3784 /* NSDateComparableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDCDE2581E67C574007B3784 /* NSDateComparableTests.swift */; };
Expand Down Expand Up @@ -233,8 +233,8 @@
80D63D2C1C4F251E00C88D00 /* UnsignedInteger+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UnsignedInteger+Extensions.swift"; sourceTree = "<group>"; };
94555EC02E932CF736415F8E /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; };
96E808C6BB3914E0E49C738D /* Pods_SwiftWisdom.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftWisdom.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A4BB8A9320DAF35000F60485 /* String+Trimmed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String+Trimmed.swift"; sourceTree = "<group>"; };
A53A4EE61EEF330100CC53C6 /* Rx+String.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Rx+String.swift"; sourceTree = "<group>"; };
A53A4EE81EF01F8000CC53C6 /* String+Trimmed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String+Trimmed.swift"; sourceTree = "<group>"; };
CD16463E1CC16A410049BBD5 /* UILabel+Typography.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UILabel+Typography.swift"; sourceTree = "<group>"; };
CDCDE2551E67A6EC007B3784 /* ResultTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResultTests.swift; sourceTree = "<group>"; };
CDCDE2581E67C574007B3784 /* NSDateComparableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NSDateComparableTests.swift; path = Date/NSDateComparableTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -633,14 +633,14 @@
80232BF71BF2F1BD00818B6E /* String */ = {
isa = PBXGroup;
children = (
A4BB8A9320DAF35000F60485 /* String+Trimmed.swift */,
13425F8A1DB0760400F446BE /* String+Validation.swift */,
13425F881DB075E000F446BE /* String+Indexing.swift */,
80D63D031C4F18FA00C88D00 /* String+Localization.swift */,
FFCA61AF1C8A1F1B00FD35A7 /* String+Empty.swift */,
1C99FB571DD51DEC009FC493 /* String+Data.swift */,
1C99FB5B1DD525FF009FC493 /* String+Numbers.swift */,
311178581E16CACF00294C25 /* String+Attributed.swift */,
A53A4EE81EF01F8000CC53C6 /* String+Trimmed.swift */,
);
path = String;
sourceTree = "<group>";
Expand Down Expand Up @@ -1068,7 +1068,6 @@
1C16E3031D27029D008A1001 /* NSLock+Extensions.swift in Sources */,
CD16463F1CC16A410049BBD5 /* UILabel+Typography.swift in Sources */,
80232C091BF2F1BD00818B6E /* UIColor+Hex.swift in Sources */,
A53A4EE91EF01F8000CC53C6 /* String+Trimmed.swift in Sources */,
80D63D021C4F16FE00C88D00 /* UIViewController+Nibs.swift in Sources */,
802C4BB41C1B6E4600C69D80 /* Downloader.swift in Sources */,
80D63D261C4F236F00C88D00 /* Not.swift in Sources */,
Expand All @@ -1089,6 +1088,7 @@
1C99FB561DD51DC0009FC493 /* Data+Extensions.swift in Sources */,
1C0438C41C751F2100069CE1 /* BasicVerticalGradientLayer.swift in Sources */,
8037D8731CADEE48008F324C /* Sequence+Utilities.swift in Sources */,
A4BB8A9420DAF35000F60485 /* String+Trimmed.swift in Sources */,
80232C041BF2F1BD00818B6E /* Array+Utilities.swift in Sources */,
311178591E16CACF00294C25 /* String+Attributed.swift in Sources */,
80232C031BF2F1BD00818B6E /* Geometry.swift in Sources */,
Expand Down
8 changes: 8 additions & 0 deletions SwiftWisdom.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
6 changes: 1 addition & 5 deletions SwiftWisdom/Core/StandardLibrary/String/String+Trimmed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import Foundation

extension String {
func ip_trimmed(toLength length: Int) -> String {
if ip_length > length {
return substring(to: index(startIndex, offsetBy: length))
} else {
return self
}
return String(prefix(length))
}
}
18 changes: 16 additions & 2 deletions SwiftWisdom/Rx/Rx+String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import RxSwift
import RxCocoa

extension ObservableType where E == String {
public func ip_limitLength(to limit: Int) -> Observable<E> {
Expand All @@ -21,14 +22,27 @@ extension ObservableType where E == String? {
}
}

extension ControlPropertyType where E == String {
public func ip_limited(toLength length: Int) -> ControlProperty<String> {
let values: Observable<String> = asObservable().map { $0.ip_trimmed(toLength: length) }
let valueSink: AnyObserver<String> = mapObserver { $0 }
return ControlProperty<String>(values: values, valueSink: valueSink)
}
}

extension Reactive where Base: UITextField {
/** Limit the length of input to a text field
Usage Example:
textField.rx.ip_limitLength(to: 5)
*/
public func ip_limitLength(to limit: Int) -> Disposable {
Note: This does not restrict length when the text property of the text field is modified directly e.g.
textField.text = "A string over the limit"
*/
public func ip_limitInputLength(to limit: Int) -> Disposable {
return text.ip_limitLength(to: limit).bind(to: text)
}
}

0 comments on commit f390a8a

Please sign in to comment.