From 8a79dcc214d525d1a59ee95173583976cd774287 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 14 Aug 2016 02:21:31 +0300 Subject: new message cell layout --- Juick/Views/MessageCell.h | 21 +++++++++++ Juick/Views/MessageCell.m | 49 ++++++++++++++++++++++++++ Juick/Views/MessageCell.xib | 85 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 155 insertions(+) create mode 100644 Juick/Views/MessageCell.h create mode 100644 Juick/Views/MessageCell.m create mode 100644 Juick/Views/MessageCell.xib (limited to 'Juick/Views') 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 +#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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3