Skip to content

Commit

Permalink
Add delegate method to tranform token before added
Browse files Browse the repository at this point in the history
  • Loading branch information
rcdilorenzo committed Sep 3, 2013
1 parent 3f6167a commit 7ad153c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion RMSTokenView.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "RMSTokenView"
s.version = "1.0.1"
s.version = "1.0.2"
s.summary = "RMSTokenView is a text-field like view that handles tokens as seen in the Mail app."
s.homepage = "https://github.com/RoleModel/RMSTokenView"
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down
1 change: 1 addition & 0 deletions RMSTokenView/RMSTokenView.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
- (void)tokenView:(RMSTokenView *)tokenView didRemoveTokenWithText:(NSString *)text;

- (BOOL)tokenView:(RMSTokenView *)tokenView shouldAddTokenWithText:(NSString *)text;
- (NSString *)tokenView:(RMSTokenView *)tokenView willPresentTokenWithText:(NSString *)text;

- (void)tokenView:(RMSTokenView *)tokenView didChangeText:(NSString *)text;
- (void)tokenView:(RMSTokenView *)tokenView didUpdateSummary:(NSString *)summary;
Expand Down
9 changes: 8 additions & 1 deletion RMSTokenView/RMSTokenView.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,14 @@ - (void)addTokenWithText:(NSString *)tokenText {
return;
}
}


if ([self.tokenDelegate respondsToSelector:@selector(tokenView:willPresentTokenWithText:)]) {
NSString *transformedText = [self.tokenDelegate tokenView:self willPresentTokenWithText:tokenText];
if (transformedText) {
tokenText = transformedText;
}
}

UIButton *tokenView = [UIButton buttonWithType:UIButtonTypeCustom];
tokenView.contentEdgeInsets = UIEdgeInsetsMake(0, 4, 0, 4);
tokenView.adjustsImageWhenHighlighted = NO;
Expand Down

0 comments on commit 7ad153c

Please sign in to comment.