From 4e34a0109bf736af17d621053bf382943cb44aff Mon Sep 17 00:00:00 2001 From: rrossinvicara Date: Mon, 17 Nov 2014 15:01:08 -0500 Subject: [PATCH 1/9] Fixed bug where screen would 'bounce' when presenting in a modal dialog on iPad with soft keyboard active in landscape. --- VENTokenField/VENTokenField.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/VENTokenField/VENTokenField.m b/VENTokenField/VENTokenField.m index 3c8597c..7bb1d9d 100644 --- a/VENTokenField/VENTokenField.m +++ b/VENTokenField/VENTokenField.m @@ -183,7 +183,11 @@ - (void)layoutTokensAndInputWithFrameAdjustment:(BOOL)shouldAdjustFrame { [self.collapsedLabel removeFromSuperview]; BOOL inputFieldShouldBecomeFirstResponder = self.inputTextField.isFirstResponder; - [self.scrollView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; + [self.scrollView.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + if (obj == self.inputTextField) return; + + [obj removeFromSuperview]; + }]; self.scrollView.hidden = NO; [self removeGestureRecognizer:self.tapGestureRecognizer]; From 94df6ee50c8ba02ffdd6ffa777f69ace55b25433 Mon Sep 17 00:00:00 2001 From: rrossinvicara Date: Fri, 21 Nov 2014 08:06:06 -0500 Subject: [PATCH 2/9] Updated code style. --- VENTokenField/VENTokenField.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/VENTokenField/VENTokenField.m b/VENTokenField/VENTokenField.m index 7bb1d9d..55361f9 100644 --- a/VENTokenField/VENTokenField.m +++ b/VENTokenField/VENTokenField.m @@ -184,9 +184,9 @@ - (void)layoutTokensAndInputWithFrameAdjustment:(BOOL)shouldAdjustFrame [self.collapsedLabel removeFromSuperview]; BOOL inputFieldShouldBecomeFirstResponder = self.inputTextField.isFirstResponder; [self.scrollView.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - if (obj == self.inputTextField) return; - - [obj removeFromSuperview]; + if (obj != self.inputTextField) { + [obj removeFromSuperview]; + } }]; self.scrollView.hidden = NO; [self removeGestureRecognizer:self.tapGestureRecognizer]; From c2b8e1df88c0dafafb0c09ace8665b9fad11fce4 Mon Sep 17 00:00:00 2001 From: rrossinvicara Date: Mon, 1 Dec 2014 13:33:57 -0500 Subject: [PATCH 3/9] Added support for return key type and a few other minor bugfixes[D --- VENTokenField/VENTokenField.h | 13 +++++---- VENTokenField/VENTokenField.m | 51 ++++++++++++++++++++++++++++------- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/VENTokenField/VENTokenField.h b/VENTokenField/VENTokenField.h index 657174e..fe557f4 100644 --- a/VENTokenField/VENTokenField.h +++ b/VENTokenField/VENTokenField.h @@ -22,13 +22,14 @@ #import -@class VENTokenField; +@class VENTokenField, VENBackspaceTextField; @protocol VENTokenFieldDelegate @optional - (void)tokenField:(VENTokenField *)tokenField didEnterText:(NSString *)text; - (void)tokenField:(VENTokenField *)tokenField didDeleteTokenAtIndex:(NSUInteger)index; - (void)tokenField:(VENTokenField *)tokenField didChangeText:(NSString *)text; - (void)tokenFieldDidBeginEditing:(VENTokenField *)tokenField; +- (void)tokenFieldDidEndEditing:(VENTokenField *) tokenField; @end @protocol VENTokenFieldDataSource @@ -41,13 +42,12 @@ @interface VENTokenField : UIView -@property (weak, nonatomic) id delegate; -@property (weak, nonatomic) id dataSource; +@property (weak, nonatomic) IBOutlet id delegate; +@property (weak, nonatomic) IBOutlet id dataSource; +@property (nonatomic) NSString *inputText; - (void)reloadData; - (void)collapse; -- (NSString *)inputText; - /**----------------------------------------------------------------------------- * @name Customization @@ -61,11 +61,14 @@ @property (assign, nonatomic) CGFloat minInputWidth; @property (assign, nonatomic) UIKeyboardType inputTextFieldKeyboardType; +@property (assign, nonatomic) UIReturnKeyType inputTextFieldReturnKeyType; @property (assign, nonatomic) UITextAutocorrectionType autocorrectionType; @property (strong, nonatomic) UIColor *toLabelTextColor; @property (strong, nonatomic) NSString *toLabelText; @property (strong, nonatomic) UIColor *inputTextFieldTextColor; +@property (strong, nonatomic) VENBackspaceTextField *inputTextField; + @property (strong, nonatomic) UILabel *toLabel; @property (copy, nonatomic) NSString *placeholderText; diff --git a/VENTokenField/VENTokenField.m b/VENTokenField/VENTokenField.m index 55361f9..87456a1 100644 --- a/VENTokenField/VENTokenField.m +++ b/VENTokenField/VENTokenField.m @@ -41,7 +41,7 @@ @interface VENTokenField () @property (assign, nonatomic) CGFloat originalHeight; @property (strong, nonatomic) UITapGestureRecognizer *tapGestureRecognizer; @property (strong, nonatomic) VENBackspaceTextField *invisibleTextField; -@property (strong, nonatomic) VENBackspaceTextField *inputTextField; +// @property (strong, nonatomic) VENBackspaceTextField *inputTextField; @property (strong, nonatomic) UIColor *colorScheme; @property (strong, nonatomic) UILabel *collapsedLabel; @@ -80,6 +80,7 @@ - (void)setUpInit { // Set up default values. _autocorrectionType = UITextAutocorrectionTypeNo; + self.maxHeight = VENTokenFieldDefaultMaxHeight; self.verticalInset = VENTokenFieldDefaultVerticalInset; self.horizontalInset = VENTokenFieldDefaultHorizontalInset; @@ -88,7 +89,7 @@ - (void)setUpInit self.colorScheme = [UIColor blueColor]; self.toLabelTextColor = [UIColor colorWithRed:112/255.0f green:124/255.0f blue:124/255.0f alpha:1.0f]; self.inputTextFieldTextColor = [UIColor colorWithRed:38/255.0f green:39/255.0f blue:41/255.0f alpha:1.0f]; - + self.inputTextFieldReturnKeyType = UIReturnKeyDefault; // Accessing bare value to avoid kicking off a premature layout run. _toLabelText = NSLocalizedString(@"To:", nil); @@ -150,6 +151,13 @@ - (NSString *)inputText return self.inputTextField.text; } +-(void) setInputText:(NSString *)inputText { + self.inputTextField.text = inputText; + + if ([self.delegate respondsToSelector:@selector(tokenField:didChangeText:)]) { + [self.delegate tokenField:self didChangeText:inputText]; + } +} #pragma mark - View Layout @@ -184,9 +192,9 @@ - (void)layoutTokensAndInputWithFrameAdjustment:(BOOL)shouldAdjustFrame [self.collapsedLabel removeFromSuperview]; BOOL inputFieldShouldBecomeFirstResponder = self.inputTextField.isFirstResponder; [self.scrollView.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - if (obj != self.inputTextField) { - [obj removeFromSuperview]; - } + if (obj == self.inputTextField) return; + + [obj removeFromSuperview]; }]; self.scrollView.hidden = NO; [self removeGestureRecognizer:self.tapGestureRecognizer]; @@ -244,7 +252,7 @@ - (void)layoutInputTextFieldWithCurrentX:(CGFloat *)currentX currentY:(CGFloat * } VENBackspaceTextField *inputTextField = self.inputTextField; - inputTextField.text = @""; + // inputTextField.text = @""; inputTextField.frame = CGRectMake(*currentX, *currentY + 1, inputTextFieldWidth, [self heightForToken] - 1); inputTextField.tintColor = self.colorScheme; [self.scrollView addSubview:inputTextField]; @@ -287,8 +295,9 @@ - (void)layoutTokensWithCurrentX:(CGFloat *)currentX currentY:(CGFloat *)current token.colorScheme = self.colorScheme; __weak VENToken *weakToken = token; + __weak VENTokenField *weakSelf = self; token.didTapTokenBlock = ^{ - [self didTapToken:weakToken]; + [weakSelf didTapToken:weakToken]; }; [token setTitleText:[NSString stringWithFormat:@"%@,", title]]; @@ -383,6 +392,9 @@ - (VENBackspaceTextField *)inputTextField _inputTextField.tintColor = self.colorScheme; _inputTextField.delegate = self; _inputTextField.placeholder = self.placeholderText; + _inputTextField.clearsOnBeginEditing = NO; + _inputTextField.returnKeyType = self.inputTextFieldReturnKeyType; + [_inputTextField addTarget:self action:@selector(inputTextFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; } return _inputTextField; @@ -400,6 +412,14 @@ - (void)setInputTextFieldKeyboardType:(UIKeyboardType)inputTextFieldKeyboardType [self.inputTextField setKeyboardType:self.inputTextFieldKeyboardType]; } + +-(void) setInputTextFieldReturnKeyType:(UIReturnKeyType)inputTextFieldReturnKeyType { + _inputTextFieldReturnKeyType = inputTextFieldReturnKeyType; + + [self.inputTextField setReturnKeyType:inputTextFieldReturnKeyType]; + [self.invisibleTextField setReturnKeyType:inputTextFieldReturnKeyType]; +} + - (void)inputTextFieldDidChange:(UITextField *)textField { if ([self.delegate respondsToSelector:@selector(tokenField:didChangeText:)]) { @@ -492,9 +512,9 @@ - (NSString *)collapsedText - (BOOL)textFieldShouldReturn:(UITextField *)textField { if ([self.delegate respondsToSelector:@selector(tokenField:didEnterText:)]) { - if ([textField.text length]) { + // if ([textField.text length]) { [self.delegate tokenField:self didEnterText:textField.text]; - } + // } } return NO; } @@ -503,9 +523,22 @@ - (void)textFieldDidBeginEditing:(UITextField *)textField { if (textField == self.inputTextField) { [self unhighlightAllTokens]; + + if ([self.delegate respondsToSelector:@selector(tokenFieldDidBeginEditing:)]) { + [self.delegate tokenFieldDidBeginEditing:self]; + } } } +-(void) textFieldDidEndEditing:(UITextField *)textField { + dispatch_async(dispatch_get_main_queue(), ^{ + if (!([self.inputTextField isFirstResponder] || [self.invisibleTextField isFirstResponder])) { + if ([self.delegate respondsToSelector:@selector(tokenFieldDidEndEditing:)]) { + [self.delegate tokenFieldDidEndEditing:self]; + } + } + }); +} - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { [self unhighlightAllTokens]; From 112d096188e4a2782c8a71aa21addaf79b7b9db3 Mon Sep 17 00:00:00 2001 From: rrossinvicara Date: Mon, 1 Dec 2014 13:38:09 -0500 Subject: [PATCH 4/9] Updated podspec for new version --- VENTokenField.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VENTokenField.podspec b/VENTokenField.podspec index 96e415f..b92e08a 100644 --- a/VENTokenField.podspec +++ b/VENTokenField.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'VENTokenField' - s.version = '2.2.3' + s.version = 'Invicara-2.0' s.summary = 'Token field used in the Venmo app.' s.description = <<-DESC An easy to use token field that in used in the Venmo app. From 588c0e024dffdf099709350edc047f3191686baf Mon Sep 17 00:00:00 2001 From: rrossinvicara Date: Mon, 1 Dec 2014 13:45:20 -0500 Subject: [PATCH 5/9] Updated podspec --- Podfile.lock | 8 ++++---- VENTokenField.podspec | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index f845f8f..35a5d16 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,9 +1,9 @@ PODS: - FrameAccessor (1.3.2) - KIF (3.0.8): - - KIF/XCTest + - KIF/XCTest (= 3.0.8) - KIF/XCTest (3.0.8) - - VENTokenField (2.2.3): + - VENTokenField (3.0): - FrameAccessor (~> 1.0) DEPENDENCIES: @@ -17,6 +17,6 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: FrameAccessor: 5eec95b29b5e9a3afe72a7a2e9ed25b000d3bcc3 KIF: 2db5e8cf59136dd1267d49cca0d55883389b09d3 - VENTokenField: 8b0f1fc56ac742414f65dd6a3e080cd107c3ae64 + VENTokenField: 30cee52f4142abbf4c1d7134d2ffd317053306a1 -COCOAPODS: 0.34.2 +COCOAPODS: 0.35.0 diff --git a/VENTokenField.podspec b/VENTokenField.podspec index b92e08a..5ac6ef6 100644 --- a/VENTokenField.podspec +++ b/VENTokenField.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'VENTokenField' - s.version = 'Invicara-2.0' + s.version = '3.0' s.summary = 'Token field used in the Venmo app.' s.description = <<-DESC An easy to use token field that in used in the Venmo app. @@ -9,7 +9,6 @@ Pod::Spec.new do |s| s.screenshot = 'http://i.imgur.com/a1FfEBi.gif' s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { 'Venmo' => 'ios@venmo.com'} - s.source = { :git => 'https://github.com/venmo/VENTokenField.git', :tag => "v#{s.version}" } s.source_files = 'VENTokenField/**/*.{h,m}' s.resources = ["VENTokenField/**/*.{xib,png}"] s.dependency 'FrameAccessor', '~> 1.0' From b4dee4bcc78bb3742be2ee81951a72aadfbdd960 Mon Sep 17 00:00:00 2001 From: rrossinvicara Date: Mon, 1 Dec 2014 14:50:28 -0500 Subject: [PATCH 6/9] Fixed bug that duplicated tokens --- VENTokenField/VENTokenField.m | 1 + 1 file changed, 1 insertion(+) diff --git a/VENTokenField/VENTokenField.m b/VENTokenField/VENTokenField.m index 87456a1..e0c16f3 100644 --- a/VENTokenField/VENTokenField.m +++ b/VENTokenField/VENTokenField.m @@ -109,6 +109,7 @@ - (void)collapse - (void)reloadData { + self.inputTextField.text = nil; [self layoutTokensAndInputWithFrameAdjustment:YES]; } From dc0df4a722d8f3a7f4dc0a3f88e0d0b610580d91 Mon Sep 17 00:00:00 2001 From: rrossinvicara Date: Mon, 1 Dec 2014 15:00:17 -0500 Subject: [PATCH 7/9] Added back in podspec info --- VENTokenField.podspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/VENTokenField.podspec b/VENTokenField.podspec index 5ac6ef6..96e415f 100644 --- a/VENTokenField.podspec +++ b/VENTokenField.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'VENTokenField' - s.version = '3.0' + s.version = '2.2.3' s.summary = 'Token field used in the Venmo app.' s.description = <<-DESC An easy to use token field that in used in the Venmo app. @@ -9,6 +9,7 @@ Pod::Spec.new do |s| s.screenshot = 'http://i.imgur.com/a1FfEBi.gif' s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { 'Venmo' => 'ios@venmo.com'} + s.source = { :git => 'https://github.com/venmo/VENTokenField.git', :tag => "v#{s.version}" } s.source_files = 'VENTokenField/**/*.{h,m}' s.resources = ["VENTokenField/**/*.{xib,png}"] s.dependency 'FrameAccessor', '~> 1.0' From 46dcc336943552a42738bbc33939d8807e1d0502 Mon Sep 17 00:00:00 2001 From: rrossinvicara Date: Mon, 1 Dec 2014 15:25:07 -0500 Subject: [PATCH 8/9] Removed unnecessary delegate callback --- VENTokenField/VENTokenField.m | 4 ---- 1 file changed, 4 deletions(-) diff --git a/VENTokenField/VENTokenField.m b/VENTokenField/VENTokenField.m index e0c16f3..f89122c 100644 --- a/VENTokenField/VENTokenField.m +++ b/VENTokenField/VENTokenField.m @@ -154,10 +154,6 @@ - (NSString *)inputText -(void) setInputText:(NSString *)inputText { self.inputTextField.text = inputText; - - if ([self.delegate respondsToSelector:@selector(tokenField:didChangeText:)]) { - [self.delegate tokenField:self didChangeText:inputText]; - } } #pragma mark - View Layout From 3152148d3e68b0a5c16cc575db1ad4b874431ac5 Mon Sep 17 00:00:00 2001 From: rrossinvicara Date: Thu, 12 Mar 2015 09:00:05 -0400 Subject: [PATCH 9/9] Update VENTokenField.podspec --- VENTokenField.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VENTokenField.podspec b/VENTokenField.podspec index 96e415f..f680bd4 100644 --- a/VENTokenField.podspec +++ b/VENTokenField.podspec @@ -5,11 +5,11 @@ Pod::Spec.new do |s| s.description = <<-DESC An easy to use token field that in used in the Venmo app. DESC - s.homepage = 'https://github.com/venmo/VENTokenField' + s.homepage = 'https://github.com/rrossinvicara/VENTokenField' s.screenshot = 'http://i.imgur.com/a1FfEBi.gif' s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { 'Venmo' => 'ios@venmo.com'} - s.source = { :git => 'https://github.com/venmo/VENTokenField.git', :tag => "v#{s.version}" } + s.source = { :git => 'https://github.com/rrossinvicara/VENTokenField.git', :tag => "v#{s.version}" } s.source_files = 'VENTokenField/**/*.{h,m}' s.resources = ["VENTokenField/**/*.{xib,png}"] s.dependency 'FrameAccessor', '~> 1.0'