MessageComReplyCell.m
6.7 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
//
// MessageComReplyCell.m
// DreamSleep
//
// Created by peter on 2022/10/10.
//
#import "MessageComReplyCell.h"
@interface MessageComReplyCell ()
@property (nonatomic, strong) UIImageView *icon;
@property (nonatomic, strong) UILabel *nameLab;
@property (nonatomic, strong) UILabel *timeLab;
@property (nonatomic, strong) UILabel *detailLab;
@property (nonatomic, strong) UILabel *mesCountLab;
@property (nonatomic, strong) UILabel *contentLab;
@property (nonatomic, strong) UIView *lineView;
@property (nonatomic, strong) UILabel *preContentLab;
@property (nonatomic, strong) UIButton *replyBtn;
@end
@implementation MessageComReplyCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.backgroundColor = DSClearColor;
[self.contentView addSubview:self.icon];
[self.contentView addSubview:self.nameLab];
[self.contentView addSubview:self.timeLab];
[self.contentView addSubview:self.detailLab];
[self.contentView addSubview:self.mesCountLab];
[self.contentView addSubview:self.contentLab];
[self.contentView addSubview:self.lineView];
[self.contentView addSubview:self.preContentLab];
[self.contentView addSubview:self.replyBtn];
[self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(15);
make.top.equalTo(self.contentView);
make.size.mas_equalTo(CGSizeMake(40, 40));
}];
[self.detailLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.icon.mas_right).offset(12);
make.bottom.equalTo(self.icon);
make.right.equalTo(self.contentView).offset(-12);
}];
}
return self;
}
- (void)setComReplyModel:(MessageComReplyModel *)comReplyModel {
_comReplyModel = comReplyModel;
[self.icon yy_setImageWithURL:[NSURL URLWithString:comReplyModel.userProfile] placeholder:[UIImage defaultPlaceholderWithSize:CGSizeMake(40, 40)]];
self.nameLab.text = comReplyModel.nickName;
self.timeLab.text = comReplyModel.publishTime;
self.detailLab.text = comReplyModel.type == 0 ? @"评论了你的动态" : @"回复你的评论";
self.contentLab.text = comReplyModel.content;
self.preContentLab.text = comReplyModel.preContent;
[self.timeLab sizeToFit];
[self.timeLab mas_remakeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView).offset(-15);
make.top.equalTo(self.contentView).offset(3);
}];
[self.nameLab mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.detailLab);
make.top.equalTo(self.icon);
make.right.equalTo(self.timeLab.mas_left).offset(-12);
}];
[self.contentLab mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.icon.mas_bottom).offset(3);
make.left.equalTo(self.contentView).offset([MessageComReplyModel contentLeftMargin]);
make.right.equalTo(self.contentView).offset(-[MessageComReplyModel contentRightMargin]);
make.height.equalTo(@([comReplyModel contentHeight]));
}];
[self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentLab);
make.top.equalTo(self.contentLab.mas_bottom).offset(9);
make.size.mas_equalTo(CGSizeMake(2, 14));
}];
[self.preContentLab mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentLab.mas_bottom).offset(6);
make.left.equalTo(self.lineView.mas_right).offset(4);
make.right.equalTo(self.contentLab);
make.height.equalTo(@([comReplyModel preContentHeight]));
}];
[self.replyBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentLab);
make.size.mas_equalTo(CGSizeMake(116, 30));
make.bottom.equalTo(self.contentView).offset(-30);
}];
}
#pragma mark - private
- (void)replyAction {
if (self.tapReplyBtnBlock) { self.tapReplyBtnBlock(); }
}
#pragma mark - lazy
- (UIImageView *)icon {
if (!_icon) {
_icon = [UIImageView new];
_icon.dk_alphaPicker = DKAlphaPickerWithAlphas(1, .5, .5);
[_icon cornerRadius:20];
}
return _icon;
}
- (UILabel *)nameLab {
if (!_nameLab) {
_nameLab = [UILabel labWithFont:BoldFont(15)];
_nameLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
}
return _nameLab;
}
- (UILabel *)timeLab {
if (!_timeLab) {
_timeLab = [UILabel labWithFont:SysFont(12)];
_timeLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite);
_timeLab.textAlignment = NSTextAlignmentRight;
}
return _timeLab;
}
- (UILabel *)detailLab {
if (!_detailLab) {
_detailLab = [UILabel labWithFont:SysFont(12)];
_detailLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite);
}
return _detailLab;
}
- (UILabel *)contentLab {
if (!_contentLab) {
_contentLab = [UILabel labWithFont:[MessageComReplyModel contentFont]];
_contentLab.dk_textColorPicker = DKColorPickerWithColors(SubTitleColor, ColorFromHexA(0xFFFFFF, .5), DSWhite);
_contentLab.numberOfLines = 0;
}
return _contentLab;
}
- (UILabel *)preContentLab {
if (!_preContentLab) {
_preContentLab = [UILabel labWithFont:[MessageComReplyModel preContentFont]];
_preContentLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .4), DSWhite);
}
return _preContentLab;
}
- (UIView *)lineView {
if (!_lineView) {
_lineView = [UIView new];
_lineView.dk_backgroundColorPicker = DKColorPickerWithColors(ColorFromHex(0xF0F0F0), ColorFromHex(0x1F263F), DSWhite);
[_lineView cornerRadius:3];
}
return _lineView;
}
- (UIButton *)replyBtn {
if (!_replyBtn) {
_replyBtn = [UIButton btnWithTitle:@"回复评论" font:SysFont(12)];
[_replyBtn cornerRadius:15];
[_replyBtn dk_setImage:DKImagePickerWithNames(@"ic_shequ_pinlun", @"dk_ic_shequ_pinlun", @"ic_shequ_pinlun") forState:UIControlStateNormal];
[_replyBtn dk_setTitleColorPicker:DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite) forState:UIControlStateNormal];
_replyBtn.dk_backgroundColorPicker = DKColorPickerWithColors(BGColor, AlertDarkColor, DSWhite);
[_replyBtn addTarget:self action:@selector(replyAction) forControlEvents:UIControlEventTouchUpInside];
_replyBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 8);
}
return _replyBtn;
}
@end