Skip to content
Snippets Groups Projects
Commit babe5581 authored by Joscha's avatar Joscha
Browse files

Using VENTokenFiled in ReadView; adapted VENTokenField to be able to be read only

parent 53e3420a
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (weak, nonatomic) id<VENTokenFieldDataSource> dataSource;
@property (strong, nonatomic, nonnull) NSMutableArray<NSString *> *textTokens;
@property (strong, nonatomic, nonnull) NSMutableArray<NSString *> *mailTokens;
@property (atomic) BOOL readOnly;
- (void)reloadData;
- (void)collapse;
......
......@@ -85,6 +85,7 @@ static const CGFloat VENTokenFieldDefaultMaxHeight = 2000.0;//150.0;
- (void)setUpInit
{
_readOnly = false;
_textTokens = [NSMutableArray array];
_mailTokens = [NSMutableArray array];
_enter = false;
......@@ -318,8 +319,11 @@ static const CGFloat VENTokenFieldDefaultMaxHeight = 2000.0;//150.0;
token.didTapTokenBlock = ^{
[weakSelf didTapToken:weakToken];
};
[token setTitleText:[NSString stringWithFormat:@"%@,", title]];
if (_tokens.count > 1) {
[token setTitleText:[NSString stringWithFormat:@"%@,", title]];
} else {
[token setTitleText:[NSString stringWithFormat:@"%@", title]];
}
token.colorScheme = [self colorSchemeForTokenAtIndex:i];
[self.tokens addObject:token];
......@@ -412,6 +416,9 @@ static const CGFloat VENTokenFieldDefaultMaxHeight = 2000.0;//150.0;
- (VENBackspaceTextField *)inputTextField
{
if (_readOnly) {
return nil;
}
if (!_inputTextField) {
_inputTextField = [[VENBackspaceTextField alloc] init];
[_inputTextField setKeyboardType:self.inputTextFieldKeyboardType];
......@@ -477,6 +484,12 @@ static const CGFloat VENTokenFieldDefaultMaxHeight = 2000.0;//150.0;
- (void)didTapToken:(VENToken *)token
{
if (_readOnly) {
token.highlighted = YES;
[self.delegate tokenField:self didTappedTokenTwice:[self.tokens indexOfObject:token]];
token.highlighted = NO;
return;
}
VENToken * tempToken = nil;
for (VENToken *aToken in self.tokens) {
if (aToken == token) {
......@@ -512,7 +525,7 @@ static const CGFloat VENTokenFieldDefaultMaxHeight = 2000.0;//150.0;
BOOL visible = [highlightedTokens count] == 0;
if (visible) {
[self inputTextFieldBecomeFirstResponder];
} else {
} else if (!_readOnly) {
[self.invisibleTextField becomeFirstResponder];
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment