forked from coding/Coding-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemberCell.m
More file actions
executable file
·148 lines (137 loc) · 5.39 KB
/
MemberCell.m
File metadata and controls
executable file
·148 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
//
// MemberCell.m
// Coding_iOS
//
// Created by 王 原闯 on 14-8-20.
// Copyright (c) 2014年 Coding. All rights reserved.
//
#import "MemberCell.h"
#import "Login.h"
@interface MemberCell ()
@property (strong, nonatomic) UIImageView *memberIconView, *typeIconView;
@property (strong, nonatomic) UILabel *memberNameLabel, *memberAliasLabel;
@end
@implementation MemberCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.backgroundColor = [UIColor clearColor];
if (!_memberIconView) {
_memberIconView = [[UIImageView alloc] initWithFrame:CGRectMake(10, ([MemberCell cellHeight]-40)/2, 40, 40)];
[_memberIconView doCircleFrame];
[self.contentView addSubview:_memberIconView];
}
if (!_memberNameLabel) {
_memberNameLabel = [UILabel new];
_memberNameLabel.font = [UIFont systemFontOfSize:17];
_memberNameLabel.textColor = [UIColor colorWithHexString:@"0x222222"];
[self.contentView addSubview:_memberNameLabel];
[_memberNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.memberIconView.mas_right).offset(10);
make.height.mas_equalTo(20);
make.centerY.equalTo(self.contentView);
}];
}
if (!_memberAliasLabel) {
_memberAliasLabel = [UILabel new];
_memberAliasLabel.font = [UIFont systemFontOfSize:12];
_memberAliasLabel.textColor = [UIColor colorWithHexString:@"0x666666"];
[self.contentView addSubview:_memberAliasLabel];
[_memberAliasLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.memberNameLabel);
make.height.mas_equalTo(20);
make.centerY.equalTo(self.contentView).offset(10);
}];
}
if (!_leftBtn) {
_leftBtn = [UIButton new];
[_leftBtn addTarget:self action:@selector(leftBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:_leftBtn];
[_leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(80, 32));
make.centerY.equalTo(self.contentView);
make.right.equalTo(self.contentView).offset(-kPaddingLeftWidth);
}];
}
}
return self;
}
- (void)layoutSubviews{
[super layoutSubviews];
if (!_curMember) {
return;
}
[_memberIconView sd_setImageWithURL:[_curMember.user.avatar urlImageWithCodePathResizeToView:_memberIconView] placeholderImage:kPlaceholderMonkeyRoundView(_memberIconView)];
_memberNameLabel.text = _curMember.user.name;
if (_curMember.alias.length > 0) {
_memberAliasLabel.text = _curMember.alias;
_memberAliasLabel.hidden = NO;
[_memberNameLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.contentView).offset(-10);
}];
}else{
_memberAliasLabel.hidden = YES;
[_memberNameLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.contentView);
}];
}
switch (_curMember.type.integerValue) {
case 100://项目所有者
case 90://项目管理员
case 75://受限成员
{
if (!_typeIconView) {
_typeIconView = [UIImageView new];
[self.contentView addSubview:_typeIconView];
[_typeIconView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.memberNameLabel.mas_right).offset(10);
make.centerY.equalTo(self.memberNameLabel);
make.size.mas_equalTo(CGSizeMake(16, 16));
}];
}
[_typeIconView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"member_type_%ld", (long)_curMember.type.integerValue]]];
_typeIconView.hidden = NO;
}
break;
case 80://普通成员
default:
{
_typeIconView.hidden = YES;
}
break;
}
if (_type == ProMemTypeTaskWatchers) {//「添加、已添加」按钮
_leftBtn.hidden = NO;
}else if (_type == ProMemTypeProject){
if (_curMember.user_id.intValue != [Login curLoginUser].id.integerValue) {//「私信」按钮
// 别人
[_leftBtn configPriMsgBtnWithUser:_curMember.user fromCell:YES];
_leftBtn.hidden = NO;
}else{
// 自己
if (_curMember.type.intValue == 100) {//项目创建者不能「退出」
_leftBtn.hidden = YES;
}else{//「退出」按钮
[_leftBtn setImage:[UIImage imageNamed:@"btn_project_quit"] forState:UIControlStateNormal];
[_leftBtn setTitle:@"- 退出项目" forState:UIControlStateNormal];
_leftBtn.hidden = NO;
}
}
}else{
_leftBtn.hidden = YES;
}
}
- (void)leftBtnClicked:(id)sender{
if (self.leftBtnClickedBlock) {
self.leftBtnClickedBlock(sender);
}
}
+ (CGFloat)cellHeight{
return 57;
}
- (void)prepareForReuse{
[_leftBtn stopQueryAnimate];
}
@end