-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSurveyViewCell.m
62 lines (49 loc) · 2.03 KB
/
SurveyViewCell.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// SurveyViewCell.m
// unnamed
//
// Created by Casing Chu on 2/20/15.
// Copyright (c) 2015 com.yahoo. All rights reserved.
//
#import "SurveyViewCell.h"
#import "AnswerCollectionView.h"
#import "CommentCollectionView.h"
#import "UIColor+AppColor.h"
#import "NSDate+MinimalTimeAgo.h"
@interface SurveyViewCell () <ProfileImageViewDelegate>
@property (weak, nonatomic) IBOutlet UIView *containerView;
@property (weak, nonatomic) IBOutlet UILabel *createdByLabel;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *questionLabel;
@property (weak, nonatomic) IBOutlet AnswerCollectionView *answerCollectionView;
@property (weak, nonatomic) IBOutlet CommentCollectionView *commentCollectionView;
@end
@implementation SurveyViewCell
- (void)awakeFromNib {
// Setup containerView
self.containerView.layer.cornerRadius = 10;
self.containerView.layer.masksToBounds = YES;
// In here to fix TableCell layout issue when using UITableViewAutomaticDimension
// But was this fix in the latest version?
self.questionLabel.preferredMaxLayoutWidth = self.questionLabel.frame.size.width;
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.backgroundColor = [UIColor appBgColor];
self.profileImageView.delegate = self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)setSurvey:(Survey *)survey {
_survey = survey;
self.profileImageView.user = survey.user;
self.nameLabel.text = survey.user.name;
self.createdByLabel.text = [survey.question.createdAt timeAgo];
self.questionLabel.text = survey.question.text;
[self.answerCollectionView setAnswers:survey.answers andTotal:survey.totalVotes];
[self.commentCollectionView setComments:[NSArray arrayWithObjects:nil]];
}
- (void)profileImageView:(ProfileImageView *)view tappedUser:(User *)user {
[self.delegate surveyViewCell:self didClickOnUser:user];
}
@end