diff options
Diffstat (limited to 'Juick/Views')
-rw-r--r-- | Juick/Views/BubbleMessageCell.h | 23 | ||||
-rw-r--r-- | Juick/Views/BubbleMessageCell.m | 43 | ||||
-rw-r--r-- | Juick/Views/BubbleMessageCell.xib | 29 | ||||
-rw-r--r-- | Juick/Views/FixedLabel.h | 13 | ||||
-rw-r--r-- | Juick/Views/FixedLabel.m | 21 |
5 files changed, 120 insertions, 9 deletions
diff --git a/Juick/Views/BubbleMessageCell.h b/Juick/Views/BubbleMessageCell.h new file mode 100644 index 0000000..1f5d2e9 --- /dev/null +++ b/Juick/Views/BubbleMessageCell.h @@ -0,0 +1,23 @@ +// +// BubbleMessageCell.h +// Juick +// +// Created by Vitaly Takmazov on 04/03/2018. +// Copyright © 2018 com.juick. All rights reserved. +// + +#import <UIKit/UIKit.h> +#import "Message.h" +#import "FixedLabel.h" + +@import TTTAttributedLabel; + +@interface BubbleMessageCell : UITableViewCell<TTTAttributedLabelDelegate> +@property (strong, nonatomic) IBOutlet UIImageView *avatarView; +@property (strong, nonatomic) IBOutlet UILabel *unreadMarker; +@property (strong, nonatomic) IBOutlet UILabel *name; +@property (strong, nonatomic) IBOutlet FixedLabel *message; + +-(void) configureWithMessage:(Message *) message; + +@end diff --git a/Juick/Views/BubbleMessageCell.m b/Juick/Views/BubbleMessageCell.m new file mode 100644 index 0000000..b201664 --- /dev/null +++ b/Juick/Views/BubbleMessageCell.m @@ -0,0 +1,43 @@ +// +// BubbleMessageCell.m +// Juick +// +// Created by Vitaly Takmazov on 04/03/2018. +// Copyright © 2018 com.juick. All rights reserved. +// + +#import "BubbleMessageCell.h" +#import "ColorScheme.h" +@import YYWebImage; + +@implementation BubbleMessageCell + +- (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) configureWithMessage:(Message *)message { + self.name.text = message.user.uname; + self.message.text = message.text; + self.unreadMarker.text = @""; + [self.avatarView yy_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://i.juick.com/a/%d.png", [message.user.uid intValue]]] options:YYWebImageOptionProgressiveBlur|YYWebImageOptionSetImageWithFadeAnimation]; + self.message.enabledTextCheckingTypes = NSTextCheckingTypeLink; + self.message.backgroundColor = [ColorScheme mainBackground]; + self.message.layer.cornerRadius = 4; + self.message.clipsToBounds = YES; + self.message.textInsets = UIEdgeInsetsMake(4.0f, 8.0f, 4.0f, 8.0f); +} + +-(void) attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url { + [[UIApplication sharedApplication] openURL:url options: + @{} completionHandler:nil]; +} + +@end diff --git a/Juick/Views/BubbleMessageCell.xib b/Juick/Views/BubbleMessageCell.xib index a2b6bc3..b88ab17 100644 --- a/Juick/Views/BubbleMessageCell.xib +++ b/Juick/Views/BubbleMessageCell.xib @@ -1,30 +1,38 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> + <device id="retina4_7" orientation="portrait"> + <adaptation id="fullscreen"/> + </device> <dependencies> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/> + <deployment identifier="iOS"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> - <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="bubbleMessageCell" rowHeight="192" id="8qR-do-bgA" customClass="BubbleMessageCell" customModule="SawIM" customModuleProvider="target"> + <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="bubbleMessageCell" rowHeight="192" id="8qR-do-bgA" customClass="BubbleMessageCell"> <rect key="frame" x="0.0" y="0.0" width="320" height="192"/> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="8qR-do-bgA" id="PhM-Oe-eqm"> - <frame key="frameInset" width="320" height="191.5"/> + <rect key="frame" x="0.0" y="0.0" width="320" height="191.5"/> <autoresizingMask key="autoresizingMask"/> <subviews> <stackView opaque="NO" contentMode="scaleToFill" distribution="fillProportionally" alignment="center" spacing="12" translatesAutoresizingMaskIntoConstraints="NO" id="W9k-Ah-WF5"> + <rect key="frame" x="6" y="6" width="308" height="179.5"/> <subviews> <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="6" translatesAutoresizingMaskIntoConstraints="NO" id="qtf-Wj-Irh"> + <rect key="frame" x="0.0" y="60.5" width="42" height="58.5"/> <subviews> <imageView contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ho8-hh-u3y"> + <rect key="frame" x="5" y="0.0" width="32" height="32"/> <constraints> <constraint firstAttribute="height" constant="32" id="9Sy-AS-4re"/> <constraint firstAttribute="width" constant="32" id="RrY-5f-4RF"/> </constraints> </imageView> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Y" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5rl-Qo-5oW"> + <rect key="frame" x="15.5" y="38" width="11" height="20.5"/> <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/> <color key="textColor" red="0.90980392160000001" green="0.098039215690000001" blue="0.21960784310000001" alpha="1" colorSpace="calibratedRGB"/> <nil key="highlightedColor"/> @@ -35,13 +43,16 @@ </constraints> </stackView> <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="12" translatesAutoresizingMaskIntoConstraints="NO" id="xm7-By-6oe"> + <rect key="frame" x="54" y="0.0" width="254" height="179.5"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="ermine" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UEj-yl-U0d"> + <rect key="frame" x="0.0" y="0.0" width="254" height="0.0"/> <fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/> <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> <nil key="highlightedColor"/> </label> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="751" verticalCompressionResistancePriority="1000" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yf3-FC-T1Y" customClass="FixedLabel" customModule="SawIM" customModuleProvider="target"> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="751" verticalCompressionResistancePriority="1000" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yf3-FC-T1Y" customClass="FixedLabel"> + <rect key="frame" x="0.0" y="12" width="254" height="167.5"/> <string key="text">Lorem sdsdasds sdsada ddas dsad asdsadas dasd asdsa sadsa dasdsad asd asdas dasd asdas dasd asdas dasdasdasd asdasdasdadasdasd asdasd asdas dasdsa dasdasdasdasdas dasdas</string> <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/> <color key="textColor" cocoaTouchSystemColor="darkTextColor"/> @@ -63,10 +74,10 @@ </tableViewCellContentView> <gestureRecognizers/> <connections> - <outlet property="avatarView" destination="ho8-hh-u3y" id="K5q-kz-70L"/> - <outlet property="message" destination="yf3-FC-T1Y" id="OjQ-pM-haS"/> - <outlet property="name" destination="UEj-yl-U0d" id="pow-Xt-INP"/> - <outlet property="unreadMarker" destination="5rl-Qo-5oW" id="jSH-ww-MO9"/> + <outlet property="avatarView" destination="ho8-hh-u3y" id="XnI-4Y-f3I"/> + <outlet property="message" destination="yf3-FC-T1Y" id="Iwg-L7-jm6"/> + <outlet property="name" destination="UEj-yl-U0d" id="unG-q9-Kwv"/> + <outlet property="unreadMarker" destination="5rl-Qo-5oW" id="an8-JJ-Gbb"/> </connections> <point key="canvasLocation" x="461" y="234"/> </tableViewCell> diff --git a/Juick/Views/FixedLabel.h b/Juick/Views/FixedLabel.h new file mode 100644 index 0000000..f05ac94 --- /dev/null +++ b/Juick/Views/FixedLabel.h @@ -0,0 +1,13 @@ +// +// FixedLabel.h +// Juick +// +// Created by Vitaly Takmazov on 04/03/2018. +// Copyright © 2018 com.juick. All rights reserved. +// + +#import <TTTAttributedLabel/TTTAttributedLabel.h> + +@interface FixedLabel : TTTAttributedLabel + +@end diff --git a/Juick/Views/FixedLabel.m b/Juick/Views/FixedLabel.m new file mode 100644 index 0000000..24d8648 --- /dev/null +++ b/Juick/Views/FixedLabel.m @@ -0,0 +1,21 @@ +// +// FixedLabel.m +// Juick +// +// Created by Vitaly Takmazov on 04/03/2018. +// Copyright © 2018 com.juick. All rights reserved. +// + +#import "FixedLabel.h" + +@implementation FixedLabel + +/* +// Only override drawRect: if you perform custom drawing. +// An empty implementation adversely affects performance during animation. +- (void)drawRect:(CGRect)rect { + // Drawing code +} +*/ + +@end |