-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathMRReviewerCell.m
128 lines (115 loc) · 4.28 KB
/
MRReviewerCell.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
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
//
// 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;
@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.contentView addSubview:self.rightLabel];
[self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView).offset(-kPaddingLeftWidth);
make.centerY.height.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{
[super 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.selectionStyle = UITableViewCellSelectionStyleNone;
if([hasLikeMr isEqual:@1]) {
self.rightLabel.text = @"允许合并";
} else {
self.rightLabel.text = @"撤销允许合并";
}
[self.rightLabel setTextColor:kColorLightBlue];
} else {
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
self.rightLabel.text = @"添加";
[self.rightLabel setTextColor:kColor999];
}
}
-(void) cantReviewer {
self.rightLabel.hidden = YES;
self.accessoryType = UITableViewCellAccessoryNone;
}
+ (CGFloat)cellHeight{
return 44.0;
}
@end