From d86cbbf76ad40e9859df129656825086baa5fea9 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 21 Mar 2019 16:20:26 +0300 Subject: Drop TagListView --- Juick.xcodeproj/project.pbxproj | 2 -- Juick/Supporting Files/Juick-Prefix.pch | 1 - Juick/Views/MessageCell.h | 1 - Juick/Views/MessageCell.m | 53 +++++++++++++++++++-------------- Juick/Views/MessageCell.xib | 42 ++++---------------------- Podfile | 1 - Podfile.lock | 6 +--- 7 files changed, 38 insertions(+), 68 deletions(-) diff --git a/Juick.xcodeproj/project.pbxproj b/Juick.xcodeproj/project.pbxproj index b0e9a95..43c1319 100644 --- a/Juick.xcodeproj/project.pbxproj +++ b/Juick.xcodeproj/project.pbxproj @@ -531,7 +531,6 @@ "${PODS_ROOT}/Target Support Files/Pods-Juick/Pods-Juick-resources.sh", "${PODS_ROOT}/DateTools/DateTools/DateTools/DateTools.bundle", "${PODS_ROOT}/SAMKeychain/Support/SAMKeychain.bundle", - "${PODS_CONFIGURATION_BUILD_DIR}/TagListView-ObjC/TagListView-ObjC.bundle", ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( @@ -539,7 +538,6 @@ outputPaths = ( "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/DateTools.bundle", "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/SAMKeychain.bundle", - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/TagListView-ObjC.bundle", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/Juick/Supporting Files/Juick-Prefix.pch b/Juick/Supporting Files/Juick-Prefix.pch index b2595f6..48932ba 100644 --- a/Juick/Supporting Files/Juick-Prefix.pch +++ b/Juick/Supporting Files/Juick-Prefix.pch @@ -22,7 +22,6 @@ #import #import #import - #import #import #import #endif diff --git a/Juick/Views/MessageCell.h b/Juick/Views/MessageCell.h index 846bf30..931146a 100644 --- a/Juick/Views/MessageCell.h +++ b/Juick/Views/MessageCell.h @@ -18,7 +18,6 @@ @property (weak, nonatomic) IBOutlet UILabel *title; @property (weak, nonatomic) IBOutlet UILabel *timestamp; -@property (weak, nonatomic) IBOutlet TagListView *tags; @property (weak, nonatomic) IBOutlet UITextView *text; @property (weak, nonatomic) IBOutlet UIImageView *attach; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *attachmentHeight; diff --git a/Juick/Views/MessageCell.m b/Juick/Views/MessageCell.m index 55e6054..6929436 100644 --- a/Juick/Views/MessageCell.m +++ b/Juick/Views/MessageCell.m @@ -11,6 +11,12 @@ #import "APIClient.h" #import "Entity.h" +@interface MessageCell() +@property(nonatomic, readonly) NSMutableParagraphStyle *quoteStyle; +@property(nonatomic, readonly) UIFont *boldFont; +@property(nonatomic, readonly) UIFont *italicFont; +@end + @implementation MessageCell - (void)awakeFromNib { @@ -21,11 +27,22 @@ self.title.textColor = [ColorScheme linkColor]; self.timestamp.textColor = [UIColor grayColor]; self.summary.textColor = [UIColor grayColor]; - self.tags.textFont = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]; UIGestureRecognizer *avatarTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarClicked:)]; [avatarTapRecognizer setEnabled:YES]; [self.avatar addGestureRecognizer:avatarTapRecognizer]; [self.avatar setUserInteractionEnabled:YES]; + _quoteStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; + _quoteStyle.firstLineHeadIndent = 12.0f; + _quoteStyle.headIndent = 12.0f; + _quoteStyle.paragraphSpacing = 6.0f; + UIFontDescriptor* fontDescriptor = [UIFontDescriptor + preferredFontDescriptorWithTextStyle:UIFontTextStyleBody]; + UIFontDescriptor* boldFontDescriptor = [fontDescriptor + fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold]; + _boldFont = [UIFont fontWithDescriptor:boldFontDescriptor size: 0.0]; + UIFontDescriptor* italicFontDescriptor = [fontDescriptor + fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitItalic]; + _italicFont = [UIFont fontWithDescriptor:italicFontDescriptor size: 0.0]; } - (void) configureWithMessage:(Message *)msg { @@ -88,28 +105,17 @@ } if ([entity.type isEqualToString:@"q"]) { [txt addAttribute:NSForegroundColorAttributeName value:[UIColor darkGrayColor] range:currentRange]; - NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; - paragraphStyle.firstLineHeadIndent = 12.0f; - paragraphStyle.headIndent = 12.0f; - paragraphStyle.paragraphSpacing = 6.0f; - [txt addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:currentRange]; + [txt addAttribute:NSParagraphStyleAttributeName value:_quoteStyle range:currentRange]; } if ([entity.type isEqualToString:@"u"]) { [txt addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:currentRange]; } - UIFontDescriptor* fontDescriptor = [UIFontDescriptor - preferredFontDescriptorWithTextStyle:UIFontTextStyleBody]; + if ([entity.type isEqualToString:@"b"]) { - UIFontDescriptor* boldFontDescriptor = [fontDescriptor - fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold]; - UIFont* boldFont = [UIFont fontWithDescriptor:boldFontDescriptor size: 0.0]; - [txt addAttribute:NSFontAttributeName value:boldFont range:currentRange]; + [txt addAttribute:NSFontAttributeName value:_boldFont range:currentRange]; } if ([entity.type isEqualToString:@"i"]) { - UIFontDescriptor* italicFontDescriptor = [fontDescriptor - fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitItalic]; - UIFont* italicFont = [UIFont fontWithDescriptor:italicFontDescriptor size: 0.0]; - [txt addAttribute:NSFontAttributeName value:italicFont range:currentRange]; + [txt addAttribute:NSFontAttributeName value:_italicFont range:currentRange]; } } [txt enumerateAttribute:@"displayText" inRange:NSMakeRange(0, [txt length]) options:0 usingBlock:^(id _Nullable value, NSRange range, BOOL * _Nonnull stop) { @@ -117,15 +123,18 @@ [txt replaceCharactersInRange:range withString:value]; } }]; + if ([msg.tags count] > 0) { + NSString *tagsList = [NSString stringWithFormat:@"%@\n", [msg.tags componentsJoinedByString:@", "]]; + [txt insertAttributedString:[[NSAttributedString alloc] + initWithString:tagsList + attributes:@{ + NSFontAttributeName:_italicFont, + NSForegroundColorAttributeName:[UIColor darkGrayColor] + }] atIndex:0]; + } [txt endEditing]; self.text.attributedText = txt; } - [self.tags removeAllTags]; - if ([msg.tags count] > 0) { - [msg.tags enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - [self.tags addTag:obj]; - }]; - } } -(void) avatarClicked:(UIGestureRecognizer *)gestureRecognizer { diff --git a/Juick/Views/MessageCell.xib b/Juick/Views/MessageCell.xib index 3b40cf6..82c283f 100644 --- a/Juick/Views/MessageCell.xib +++ b/Juick/Views/MessageCell.xib @@ -1,11 +1,11 @@ - + - + @@ -51,51 +51,22 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. - +