forked from coding/Coding-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMRReviewerCell.m
More file actions
150 lines (137 loc) · 5.39 KB
/
Copy pathMRReviewerCell.m
File metadata and controls
150 lines (137 loc) · 5.39 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
//
// NSObject+PRReviewerCell.m
// Coding_iOS
//
// Created by hardac on 16/3/22.
// Copyright © 2016年 Coding. All rights reserved.
//
#import "MRReviewerCell.h"
@interface MRReviewerCell ()
@property (strong, nonatomic) UIImageView *imgView;
@property (strong, nonatomic) UILabel *titleLabel;
@property (strong, nonatomic) UILabel *rightLabel;
@property (strong, nonatomic) UIImageView *likeImgView;
@end
@implementation MRReviewerCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.backgroundColor = kColorTableBG;
if (!_imgView) {
_imgView = [UIImageView new];
[self.contentView addSubview:_imgView];
[_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(20, 20));
make.left.equalTo(self.contentView).offset(kPaddingLeftWidth);
make.centerY.equalTo(self.contentView);
}];
}
if (!_titleLabel) {
_titleLabel = [UILabel new];
_titleLabel.font = [UIFont systemFontOfSize:15];
_titleLabel.textColor = kColor222;
[self.contentView addSubview:_titleLabel];
[_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(_imgView.mas_right).offset(15);
make.right.equalTo(self.contentView).offset(-kPaddingLeftWidth);
make.centerY.height.equalTo(self.contentView);
}];
}
if (!self.rightLabel) {
self.rightLabel = [UILabel new];
self.rightLabel.text = @"添加";
self.rightLabel.font = [UIFont systemFontOfSize:15];
//[self.rightLabel setTextColor:kColor999];
[self.contentView addSubview:self.rightLabel];
[self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//make.left.equalTo(_imgView.mas_right).offset(15);
make.right.equalTo(self.contentView).offset(0);
make.centerY.height.equalTo(self.contentView);
}];
}
if (!self.likeImgView) {
self.likeImgView = [UIImageView new];
[self.contentView addSubview:self.likeImgView];
[self.likeImgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(20, 20));
make.right.equalTo(self.contentView).offset(-40);
make.centerY.equalTo(self.contentView);
}];
}
UIView *rightSideV = [UIView new];
[self.contentView addSubview:rightSideV];
[rightSideV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.right.bottom.equalTo(self.contentView);
make.width.equalTo(self.contentView).multipliedBy(1.0/4);
}];
__weak typeof(self) weakSelf = self;
[rightSideV bk_whenTapped:^{
if (weakSelf.rightSideClickedBlock) {
weakSelf.rightSideClickedBlock();
}
}];
}
return self;
}
- (void)prepareForReuse{
[self removeTip];
}
- (void)addTip:(NSString *)countStr{
CGFloat pointX = kScreen_Width - 25;
CGFloat pointY = [[self class] cellHeight]/2;
[self.contentView addBadgeTip:countStr withCenterPosition:CGPointMake(pointX, pointY)];
}
- (void)addTipIcon{
CGFloat pointX = kScreen_Width - 40;
CGFloat pointY = [[self class] cellHeight]/2;
[self.contentView addBadgeTip:kBadgeTipStr withCenterPosition:CGPointMake(pointX, pointY)];
}
- (void)addTipHeadIcon:(NSString *)IconString {
CGFloat pointX = kScreen_Width - 40;
CGFloat pointY = [[self class] cellHeight]/2;
[self.contentView addBadgeTip:IconString withCenterPosition:CGPointMake(pointX, pointY)];
}
- (void)removeTip{
[self.contentView removeBadgeTips];
}
- (void)setImageStr:(NSString *)imgStr
isowner:(BOOL)ower
hasLikeMr:(NSNumber *)hasLikeMr {
self.imgView.image = [UIImage imageNamed:imgStr];
self.titleLabel.text = @"评审者";
if(!ower) {
[self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//make.left.equalTo(_imgView.mas_right).offset(15);
make.right.equalTo(self.contentView).offset(-20);
make.centerY.height.equalTo(self.contentView);
}];
self.selectionStyle = UITableViewCellSelectionStyleNone;
if([hasLikeMr isEqual:@1]) {
self.rightLabel.text = @"+1";
[self.rightLabel setTextColor:kColorBrandGreen];
[self.likeImgView setHidden:NO];
self.likeImgView.image = [UIImage imageNamed:@"EPointLikeHead"];
} else {
[self.rightLabel setTextColor:kColorBrandGreen];
self.rightLabel.text = @"撤销 +1";
[self.likeImgView setHidden:YES];
}
} else {
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
self.rightLabel.text = @"添加";
[self.rightLabel setTextColor:kColor999];
[self.likeImgView setHidden:YES];
}
}
-(void) cantReviewer {
self.rightLabel.hidden = YES;
self.likeImgView.hidden = YES;
self.accessoryType = UITableViewCellAccessoryNone;
}
+ (CGFloat)cellHeight{
return 44.0;
}
@end