From babe558120008fcceb90a42a073a81748837d773 Mon Sep 17 00:00:00 2001
From: Joscha <joscha@virtual-artz.de>
Date: Mon, 13 Mar 2017 15:59:16 +0100
Subject: [PATCH] Using VENTokenFiled in ReadView; adapted VENTokenField to be
 able to be read only

---
 .../VENTokenField/VENTokenField.h             |  1 +
 .../VENTokenField/VENTokenField.m             | 19 ++++++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/Pods/VENTokenField/VENTokenField/VENTokenField.h b/Pods/VENTokenField/VENTokenField/VENTokenField.h
index 45bf61a..040b844 100644
--- a/Pods/VENTokenField/VENTokenField/VENTokenField.h
+++ b/Pods/VENTokenField/VENTokenField/VENTokenField.h
@@ -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;
diff --git a/Pods/VENTokenField/VENTokenField/VENTokenField.m b/Pods/VENTokenField/VENTokenField/VENTokenField.m
index e3a2a4d..abc1027 100644
--- a/Pods/VENTokenField/VENTokenField/VENTokenField.m
+++ b/Pods/VENTokenField/VENTokenField/VENTokenField.m
@@ -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];
     }
 }
-- 
GitLab