From a3123694c391af5d958a57652de8d8216989c63e Mon Sep 17 00:00:00 2001 From: Joel Drotleff Date: Mon, 7 Nov 2016 20:30:48 -0800 Subject: [PATCH 1/5] Fix issue where tapping backspace to delete a single letter also selects the previous token --- .../CLBackspaceDetectingTextField.m | 4 ---- .../CLTokenInputView/CLTokenInputView.m | 17 ++++++----------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/CLTokenInputView/CLTokenInputView/CLBackspaceDetectingTextField.m b/CLTokenInputView/CLTokenInputView/CLBackspaceDetectingTextField.m index 9bfcb93..c713952 100644 --- a/CLTokenInputView/CLTokenInputView/CLBackspaceDetectingTextField.m +++ b/CLTokenInputView/CLTokenInputView/CLBackspaceDetectingTextField.m @@ -46,10 +46,6 @@ - (BOOL)keyboardInputShouldDelete:(UITextField *)textField { } } - if (![textField.text length] && [[[UIDevice currentDevice] systemVersion] intValue] >= 8) { - [self deleteBackward]; - } - return shouldDelete; } diff --git a/CLTokenInputView/CLTokenInputView/CLTokenInputView.m b/CLTokenInputView/CLTokenInputView/CLTokenInputView.m index 5077c14..ad4a782 100644 --- a/CLTokenInputView/CLTokenInputView/CLTokenInputView.m +++ b/CLTokenInputView/CLTokenInputView/CLTokenInputView.m @@ -307,18 +307,13 @@ - (void)layoutSubviews - (void)textFieldDidDeleteBackwards:(UITextField *)textField { - // Delay selecting the next token slightly, so that on iOS 8 - // the deleteBackward on CLTokenView is not called immediately, - // causing a double-delete - dispatch_async(dispatch_get_main_queue(), ^{ - if (textField.text.length == 0) { - CLTokenView *tokenView = self.tokenViews.lastObject; - if (tokenView) { - [self selectTokenView:tokenView animated:YES]; - [self.textField resignFirstResponder]; - } + if (textField.text.length == 0) { + CLTokenView *tokenView = self.tokenViews.lastObject; + if (tokenView) { + [self selectTokenView:tokenView animated:YES]; + [self.textField resignFirstResponder]; } - }); + } } From 998ce0787299cfe30e804fcceae72d3b05a03253 Mon Sep 17 00:00:00 2001 From: joeldrotleff Date: Mon, 10 Apr 2017 21:48:40 -0700 Subject: [PATCH 2/5] prevent extra space below token input view --- .../CLTokenInputView/CLTokenInputView.m | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/CLTokenInputView/CLTokenInputView/CLTokenInputView.m b/CLTokenInputView/CLTokenInputView/CLTokenInputView.m index ad4a782..d19d2b2 100644 --- a/CLTokenInputView/CLTokenInputView/CLTokenInputView.m +++ b/CLTokenInputView/CLTokenInputView/CLTokenInputView.m @@ -41,7 +41,7 @@ @implementation CLTokenInputView - (void)commonInit { self.textField = [[CLBackspaceDetectingTextField alloc] initWithFrame:self.bounds]; - self.textField.backgroundColor = [UIColor clearColor]; + self.textField.backgroundColor = [UIColor orangeColor]; self.textField.keyboardType = UIKeyboardTypeEmailAddress; self.textField.autocorrectionType = UITextAutocorrectionTypeNo; self.textField.autocapitalizationType = UITextAutocapitalizationTypeNone; @@ -274,8 +274,18 @@ - (void)repositionViews textFieldRect.size.height = STANDARD_ROW_HEIGHT; self.textField.frame = textFieldRect; + // Don't include text field in height calculation to prevent extra space from showing at the bottom + // But if we start typing in the text field then it should be included CGFloat oldContentHeight = self.intrinsicContentHeight; - self.intrinsicContentHeight = MAX(totalHeight, CGRectGetMaxY(textFieldRect)+PADDING_BOTTOM); + BOOL notFullWidth = availableWidthForTextField < bounds.size.width - PADDING_LEFT - PADDING_RIGHT - 50; + BOOL includeTextFieldHeight = notFullWidth || self.textField.text.length > 0 || self.textField.isFirstResponder; + + if (includeTextFieldHeight) { + self.intrinsicContentHeight = MAX(totalHeight, CGRectGetMaxY(textFieldRect)+PADDING_BOTTOM); + } else { + self.intrinsicContentHeight = totalHeight; + } + [self invalidateIntrinsicContentSize]; if (oldContentHeight != self.intrinsicContentHeight) { @@ -326,6 +336,7 @@ - (void)textFieldDidBeginEditing:(UITextField *)textField } self.tokenViews.lastObject.hideUnselectedComma = NO; [self unselectAllTokenViewsAnimated:YES]; + [self repositionViews]; } - (void)textFieldDidEndEditing:(UITextField *)textField @@ -334,6 +345,7 @@ - (void)textFieldDidEndEditing:(UITextField *)textField [self.delegate tokenInputViewDidEndEditing:self]; } self.tokenViews.lastObject.hideUnselectedComma = YES; + [self repositionViews]; } - (BOOL)textFieldShouldReturn:(UITextField *)textField @@ -363,6 +375,7 @@ - (BOOL) textField:(UITextField *)textField - (void)onTextFieldDidChange:(id)sender { + [self repositionViews]; if ([self.delegate respondsToSelector:@selector(tokenInputView:didChangeText:)]) { [self.delegate tokenInputView:self didChangeText:self.textField.text]; } From 91e746c8f25b27cf1ffc4f6f222db3d6a409d621 Mon Sep 17 00:00:00 2001 From: joeldrotleff Date: Mon, 10 Apr 2017 21:51:51 -0700 Subject: [PATCH 3/5] roll back unintended change --- CLTokenInputView/CLTokenInputView/CLTokenInputView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CLTokenInputView/CLTokenInputView/CLTokenInputView.m b/CLTokenInputView/CLTokenInputView/CLTokenInputView.m index d19d2b2..a77fe58 100644 --- a/CLTokenInputView/CLTokenInputView/CLTokenInputView.m +++ b/CLTokenInputView/CLTokenInputView/CLTokenInputView.m @@ -41,7 +41,7 @@ @implementation CLTokenInputView - (void)commonInit { self.textField = [[CLBackspaceDetectingTextField alloc] initWithFrame:self.bounds]; - self.textField.backgroundColor = [UIColor orangeColor]; + self.textField.backgroundColor = [UIColor clearColor]; self.textField.keyboardType = UIKeyboardTypeEmailAddress; self.textField.autocorrectionType = UITextAutocorrectionTypeNo; self.textField.autocapitalizationType = UITextAutocapitalizationTypeNone; From ff3fd657e50332d94aa2de2eacac03325d5684dd Mon Sep 17 00:00:00 2001 From: Joe DeCapo Date: Wed, 26 Jan 2022 14:53:46 -0600 Subject: [PATCH 4/5] Update gitignore --- .gitignore | 85 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 70 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 5897ce5..4bb236b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,72 @@ -# Xcode + +# Created by https://www.toptal.com/developers/gitignore/api/macos,synology,xcode,swiftpackagemanager,cocoapods +# Edit at https://www.toptal.com/developers/gitignore?templates=macos,synology,xcode,swiftpackagemanager,cocoapods + +### CocoaPods ### +## CocoaPods GitIgnore Template + +# CocoaPods - Only use to conserve bandwidth / Save time on Pushing +# - Also handy if you have a large number of dependant pods +# - AS PER https://guides.cocoapods.org/using/using-cocoapods.html NEVER IGNORE THE LOCK FILE +Pods/ + +### macOS ### +# General .DS_Store -build/ -*.pbxuser -!default.pbxuser -*.mode1v3 -!default.mode1v3 -*.mode2v3 -!default.mode2v3 -*.perspectivev3 -!default.perspectivev3 -*.xccheckout +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### SwiftPackageManager ### +Packages +.build/ xcuserdata -profile -*.moved-aside -DerivedData -.idea/ +DerivedData/ +*.xcodeproj + + +### Synology ### +# Thumbnails +@eaDir +# Recycle bin +\#recycle + +### Xcode ### +## User settings +xcuserdata/ + +## Xcode 8 and earlier +*.xcscmblueprint +*.xccheckout + +### Xcode Patch ### +*.xcodeproj/* +!*.xcodeproj/project.pbxproj +!*.xcodeproj/xcshareddata/ +!*.xcworkspace/contents.xcworkspacedata +/*.gcno +**/xcshareddata/WorkspaceSettings.xcsettings + +# End of https://www.toptal.com/developers/gitignore/api/macos,synology,xcode,swiftpackagemanager,cocoapods From b9b8ea4595355bff6112e2c2f54b2e03fbe5f8b1 Mon Sep 17 00:00:00 2001 From: Joe DeCapo Date: Wed, 26 Jan 2022 14:53:57 -0600 Subject: [PATCH 5/5] Add Package.swift --- Package.swift | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Package.swift diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..87d90ce --- /dev/null +++ b/Package.swift @@ -0,0 +1,20 @@ +// swift-tools-version:5.3 + +import PackageDescription + +let package = Package( + name: "CLTokenInputView", + platforms: [ + .iOS(.v11) + ], + products: [ + .library(name: "CLTokenInputView", targets: ["CLTokenInputView"]) + ], + targets: [ + .target( + name: "CLTokenInputView", + path: "CLTokenInputView/CLTokenInputView", + publicHeadersPath: "./" + ) + ] +)