summaryrefslogtreecommitdiff
path: root/Juick/Views
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-03-21 16:20:26 +0300
committerGravatar Vitaly Takmazov2019-03-21 16:20:26 +0300
commitd86cbbf76ad40e9859df129656825086baa5fea9 (patch)
tree8bbbdf043b040da3be9add376e1a90bb18bd19c0 /Juick/Views
parent2640c7fcb81e5900ea25e5b79a395052dd6814c0 (diff)
Drop TagListView
Diffstat (limited to 'Juick/Views')
-rw-r--r--Juick/Views/MessageCell.h1
-rw-r--r--Juick/Views/MessageCell.m53
-rw-r--r--Juick/Views/MessageCell.xib42
3 files changed, 37 insertions, 59 deletions
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 @@
<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@@ -51,51 +51,22 @@
</stackView>
</subviews>
</stackView>
- <view contentMode="scaleToFill" verticalCompressionResistancePriority="749" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="N08-my-2Lr" customClass="TagListView">
- <rect key="frame" x="0.0" y="60" width="562" height="0.0"/>
- <userDefinedRuntimeAttributes>
- <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
- <real key="value" value="1"/>
- </userDefinedRuntimeAttribute>
- <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
- <color key="value" red="0.93333333333333335" green="0.93333333333333335" blue="0.93333333333333335" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
- </userDefinedRuntimeAttribute>
- <userDefinedRuntimeAttribute type="number" keyPath="paddingY">
- <real key="value" value="6"/>
- </userDefinedRuntimeAttribute>
- <userDefinedRuntimeAttribute type="number" keyPath="paddingX">
- <real key="value" value="12"/>
- </userDefinedRuntimeAttribute>
- <userDefinedRuntimeAttribute type="number" keyPath="marginY">
- <real key="value" value="7"/>
- </userDefinedRuntimeAttribute>
- <userDefinedRuntimeAttribute type="number" keyPath="marginX">
- <real key="value" value="7"/>
- </userDefinedRuntimeAttribute>
- <userDefinedRuntimeAttribute type="color" keyPath="textColor">
- <color key="value" red="0.53333333333333333" green="0.53333333333333333" blue="0.53333333333333333" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
- </userDefinedRuntimeAttribute>
- <userDefinedRuntimeAttribute type="color" keyPath="tagBackgroundColor">
- <color key="value" red="0.93333333333333335" green="0.93333333333333335" blue="0.93333333333333335" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
- </userDefinedRuntimeAttribute>
- </userDefinedRuntimeAttributes>
- </view>
- <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" verticalCompressionResistancePriority="1000" ambiguous="YES" scrollEnabled="NO" editable="NO" textAlignment="natural" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nZn-a4-oSt">
- <rect key="frame" x="0.0" y="72" width="562" height="71.5"/>
+ <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" verticalCompressionResistancePriority="1000" scrollEnabled="NO" editable="NO" textAlignment="natural" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nZn-a4-oSt">
+ <rect key="frame" x="0.0" y="60" width="562" height="192"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<string key="text">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.</string>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Uha-ow-kFJ">
- <rect key="frame" x="0.0" y="155.5" width="562" height="256"/>
+ <rect key="frame" x="0.0" y="264" width="562" height="149.5"/>
<constraints>
<constraint firstAttribute="height" priority="999" constant="256" identifier="attachHeight" id="Cuq-dQ-VYU"/>
<constraint firstAttribute="width" priority="999" constant="256" id="oJg-1R-jp3"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aJE-mZ-MCS">
- <rect key="frame" x="0.0" y="423.5" width="562" height="2"/>
+ <rect key="frame" x="0.0" y="425.5" width="562" height="0.0"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
@@ -116,7 +87,6 @@
<outlet property="attachmentHeight" destination="Cuq-dQ-VYU" id="5DR-sP-vQI"/>
<outlet property="avatar" destination="CZk-Q8-JqS" id="0Jh-5F-W9D"/>
<outlet property="summary" destination="aJE-mZ-MCS" id="lWR-A2-40d"/>
- <outlet property="tags" destination="N08-my-2Lr" id="MwG-ij-n7e"/>
<outlet property="text" destination="nZn-a4-oSt" id="Bee-gX-BGk"/>
<outlet property="timestamp" destination="AVu-qV-q84" id="Cyn-0y-V0R"/>
<outlet property="title" destination="CHd-h0-hPk" id="BuC-dv-0sU"/>