summaryrefslogtreecommitdiff
path: root/Juick/Views
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/Views')
-rw-r--r--Juick/Views/MessageCell.h21
-rw-r--r--Juick/Views/MessageCell.m49
-rw-r--r--Juick/Views/MessageCell.xib85
3 files changed, 155 insertions, 0 deletions
diff --git a/Juick/Views/MessageCell.h b/Juick/Views/MessageCell.h
new file mode 100644
index 0000000..c40a12c
--- /dev/null
+++ b/Juick/Views/MessageCell.h
@@ -0,0 +1,21 @@
+//
+// MessageCell.h
+// Juick
+//
+// Created by Vitaly Takmazov on 14/08/16.
+// Copyright © 2016 com.juick. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "Message.h"
+
+@interface MessageCell : UITableViewCell
+
+@property (weak, nonatomic) IBOutlet UILabel *title;
+@property (weak, nonatomic) IBOutlet UILabel *timestamp;
+@property (weak, nonatomic) IBOutlet UIImageView *avatar;
+@property (weak, nonatomic) IBOutlet UILabel *text;
+@property (weak, nonatomic) IBOutlet UIImageView *attach;
+@property (weak, nonatomic) IBOutlet UILabel *summary;
+@property (strong, nonatomic) Message * message;
+@end
diff --git a/Juick/Views/MessageCell.m b/Juick/Views/MessageCell.m
new file mode 100644
index 0000000..8759e63
--- /dev/null
+++ b/Juick/Views/MessageCell.m
@@ -0,0 +1,49 @@
+//
+// MessageCell.m
+// Juick
+//
+// Created by Vitaly Takmazov on 14/08/16.
+// Copyright © 2016 com.juick. All rights reserved.
+//
+
+#import "MessageCell.h"
+
+@implementation MessageCell
+
+- (void)awakeFromNib {
+ [super awakeFromNib];
+ // Initialization code
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+ [super setSelected:selected animated:animated];
+
+ // Configure the view for the selected state
+}
+
+- (void) setMessage:(Message *)msg {
+ _message = msg;
+ [self.avatar setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://i.juick.com/a/%d.png", [msg.userID intValue]]] placeholderImage:[UIImage imageNamed:@"0.png"] options:SDWebImageContinueInBackground];
+ self.title.text = msg.user;
+ NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
+ formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
+ [formatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
+
+ self.timestamp.text = [[formatter dateFromString:msg.timestamp] timeAgo];
+ if (msg.repliesCount > 0) {
+ if ([msg.repliesBy length] > 0) {
+ self.summary.text = [NSString stringWithFormat:@"%@ replies by %@", msg.repliesCount, msg.repliesBy];
+ } else {
+ self.summary.text = [NSString stringWithFormat:@"%@ replies", msg.repliesCount];
+ }
+ } else {
+ self.summary.text = nil;
+ }
+ self.text.text = [msg.text stringByDecodingHTMLEntities];
+ if ([msg.tags count] > 0) {
+ self.text.text = [[NSString alloc] initWithFormat:@"%@\n%@", [msg.tags componentsJoinedByString:@", "],
+ [msg.text stringByDecodingHTMLEntities]];
+ }
+}
+
+@end
diff --git a/Juick/Views/MessageCell.xib b/Juick/Views/MessageCell.xib
new file mode 100644
index 0000000..29f37fb
--- /dev/null
+++ b/Juick/Views/MessageCell.xib
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
+ <dependencies>
+ <deployment identifier="iOS"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
+ </dependencies>
+ <objects>
+ <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+ <tableViewCell contentMode="scaleToFill" horizontalHuggingPriority="1000" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" selectionStyle="default" indentationWidth="10" reuseIdentifier="MessageCell" rowHeight="343" id="KGk-i7-Jjw" customClass="MessageCell">
+ <rect key="frame" x="0.0" y="0.0" width="592" height="343"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
+ <rect key="frame" x="0.0" y="0.0" width="592" height="342.5"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <subviews>
+ <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" spacing="6" translatesAutoresizingMaskIntoConstraints="NO" id="rE3-Mc-Kov">
+ <rect key="frame" x="12" y="12" width="568" height="319"/>
+ <subviews>
+ <stackView opaque="NO" contentMode="scaleToFill" misplaced="YES" spacing="12" translatesAutoresizingMaskIntoConstraints="NO" id="lkI-Na-bF2">
+ <rect key="frame" x="0.0" y="0.0" width="102" height="48"/>
+ <subviews>
+ <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="kHx-jc-jaD">
+ <rect key="frame" x="0.0" y="0.0" width="48" height="48"/>
+ <constraints>
+ <constraint firstAttribute="width" constant="48" id="LYl-qV-pOl"/>
+ <constraint firstAttribute="height" constant="48" id="ebd-hi-9gJ"/>
+ </constraints>
+ </imageView>
+ <stackView opaque="NO" contentMode="scaleToFill" misplaced="YES" axis="vertical" spacing="6" translatesAutoresizingMaskIntoConstraints="NO" id="ttr-pF-8Zm">
+ <rect key="frame" x="60" y="0.0" width="42" height="48"/>
+ <subviews>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zVa-uf-1Mb">
+ <rect key="frame" x="0.0" y="0.0" width="42" height="28"/>
+ <fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
+ <color key="textColor" red="0.0" green="0.40000000000000002" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/>
+ <nil key="highlightedColor"/>
+ </label>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="252" horizontalCompressionResistancePriority="751" verticalCompressionResistancePriority="751" misplaced="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5IY-8Y-0W9">
+ <rect key="frame" x="0.0" y="34" width="42" height="15"/>
+ <fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
+ <color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/>
+ <nil key="highlightedColor"/>
+ </label>
+ </subviews>
+ </stackView>
+ </subviews>
+ </stackView>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0Q9-qY-nj2">
+ <rect key="frame" x="0.0" y="54" width="40" height="189"/>
+ <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
+ <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+ <nil key="highlightedColor"/>
+ </label>
+ <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="53j-SC-IXj">
+ <rect key="frame" x="0.0" y="249" width="50" height="50"/>
+ </imageView>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zDd-8E-ic8">
+ <rect key="frame" x="0.0" y="305" width="31" height="15"/>
+ <fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
+ <color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/>
+ <nil key="highlightedColor"/>
+ </label>
+ </subviews>
+ </stackView>
+ </subviews>
+ <constraints>
+ <constraint firstAttribute="top" secondItem="rE3-Mc-Kov" secondAttribute="top" constant="-12" id="Qoo-Ft-k2p"/>
+ <constraint firstItem="rE3-Mc-Kov" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="12" id="f8t-VJ-UHp"/>
+ <constraint firstAttribute="bottom" secondItem="rE3-Mc-Kov" secondAttribute="bottom" constant="12" id="hcr-Ch-wuN"/>
+ <constraint firstAttribute="trailing" secondItem="rE3-Mc-Kov" secondAttribute="trailing" constant="12" id="viV-Pm-6in"/>
+ </constraints>
+ </tableViewCellContentView>
+ <connections>
+ <outlet property="attach" destination="53j-SC-IXj" id="KJm-CX-dUB"/>
+ <outlet property="avatar" destination="kHx-jc-jaD" id="Fta-hP-KqC"/>
+ <outlet property="summary" destination="zDd-8E-ic8" id="8LF-Oz-1Co"/>
+ <outlet property="text" destination="0Q9-qY-nj2" id="9Qo-wq-TKX"/>
+ <outlet property="timestamp" destination="5IY-8Y-0W9" id="HBP-8W-F1a"/>
+ <outlet property="title" destination="zVa-uf-1Mb" id="uOQ-uv-r33"/>
+ </connections>
+ <point key="canvasLocation" x="204" y="424.5"/>
+ </tableViewCell>
+ </objects>
+</document>