Skip to content
Snippets Groups Projects
Commit 7b7d3d90 authored by Oliver Wiese's avatar Oliver Wiese
Browse files

Merge remote-tracking branch 'origin/master'

parents 94c4e4b8 71b67bab
No related branches found
No related tags found
No related merge requests found
File deleted
......@@ -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;
......@@ -96,9 +97,9 @@ static const CGFloat VENTokenFieldDefaultMaxHeight = 2000.0;//150.0;
self.horizontalInset = VENTokenFieldDefaultHorizontalInset;
self.tokenPadding = VENTokenFieldDefaultTokenPadding;
self.minInputWidth = VENTokenFieldDefaultMinInputWidth;
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.colorScheme = [UIColor darkGrayColor];
self.toLabelTextColor = [UIColor darkGrayColor];
self.inputTextFieldTextColor = [UIColor blackColor];
//[self addTarget:self action:@selector(delegate:tokenFieldDidEndEditing:) forControlEvents:UIControlEventEditingChanged];
[_inputTextField addTarget:self action:@selector(inputTextFieldEditingEnd:) forControlEvents:UIControlEventEditingDidEnd];
......@@ -263,7 +264,7 @@ static const CGFloat VENTokenFieldDefaultMaxHeight = 2000.0;//150.0;
- (void)layoutInputTextFieldWithCurrentX:(CGFloat *)currentX currentY:(CGFloat *)currentY clearInput:(BOOL)clearInput
{
CGFloat inputTextFieldWidth = self.scrollView.contentSize.width - *currentX;
if (inputTextFieldWidth < self.minInputWidth) {
if (!_readOnly && inputTextFieldWidth < self.minInputWidth) {
inputTextFieldWidth = self.scrollView.contentSize.width;
*currentY += [self heightForToken];
*currentX = 0;
......@@ -318,10 +319,12 @@ static const CGFloat VENTokenFieldDefaultMaxHeight = 2000.0;//150.0;
token.didTapTokenBlock = ^{
[weakSelf didTapToken:weakToken];
};
[token setTitleText:[NSString stringWithFormat:@"%@,", title]];
if (i == [self numberOfTokens] - 1) {
[token setTitleText:[NSString stringWithFormat:@"%@", title]];
} else {
[token setTitleText:[NSString stringWithFormat:@"%@,", title]];
}
token.colorScheme = [self colorSchemeForTokenAtIndex:i];
[self.tokens addObject:token];
if (*currentX + token.width <= self.scrollView.contentSize.width) { // token fits in current line
......@@ -374,7 +377,7 @@ static const CGFloat VENTokenFieldDefaultMaxHeight = 2000.0;//150.0;
if (!_toLabel) {
_toLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_toLabel.textColor = self.toLabelTextColor;
_toLabel.font = [UIFont systemFontOfSize: 17.0];//[UIFont fontWithName:@"HelveticaNeue" size:15.5];
_toLabel.font = [UIFont systemFontOfSize: 15.0];//[UIFont fontWithName:@"HelveticaNeue" size:15.5];
_toLabel.x = 0;
[_toLabel sizeToFit];
[_toLabel setHeight:[self heightForToken]];
......@@ -412,6 +415,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 +483,10 @@ static const CGFloat VENTokenFieldDefaultMaxHeight = 2000.0;//150.0;
- (void)didTapToken:(VENToken *)token
{
if (_readOnly) {
[self.delegate tokenField:self didTappedTokenTwice:[self.tokens indexOfObject:token]];
return;
}
VENToken * tempToken = nil;
for (VENToken *aToken in self.tokens) {
if (aToken == token) {
......@@ -512,7 +522,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