SignCollectionViewCell.m
4.3 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
//
// SignCollectionViewCell.m
// DreamSleep
//
// Created by peter on 2022/6/29.
//
#import "SignCollectionViewCell.h"
@interface SignCollectionViewCell ()
@property (nonatomic, strong) UIView *dayView;
@property (nonatomic, strong) UILabel *scoreLab;
@property (nonatomic, strong) UIImageView *doneIV;
@property (nonatomic, strong) UIImageView *giftIV;
@property (nonatomic, strong) UILabel *dayLab;
@property (nonatomic, strong) UIView *line;
@property (nonatomic, strong) UIView *bigDot;
@property (nonatomic, strong) UIView *smallDot;
@end
@implementation SignCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self debugViewShowBorderWithColor:[UIColor greenColor]];
[self.contentView addSubview:self.dayView];
[self.contentView addSubview:self.giftIV];
[self.contentView addSubview:self.scoreLab];
[self.contentView addSubview:self.doneIV];
[self.dayView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.equalTo(self.contentView);
make.size.mas_equalTo(CGSizeMake(40, 40));
}];
[self.giftIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self.dayView);
}];
[self.doneIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.dayView);
make.bottom.equalTo(self.dayView).offset(-6);
}];
}
return self;
}
- (void)refreshSignView:(ScoreTaskRequestModel *)requestModel indexPath:(NSIndexPath *)indexPath {
SignModel *signModel = requestModel.signList[indexPath.row];
BOOL is_cur_day = requestModel.cur_day == signModel.day;
// 背景小圆背景颜色显示
DKColorPicker day_dk_bg_color = is_cur_day ? DKColorPickerWithColors(ColorFromHex(0xFC7032), ColorFromHex(0xB5552E), DSWhite) : DKColorPickerWithColors(ColorFromHexA(0xFC7032, .1), ColorFromHexA(0xFC7032, .1), DSWhite);
self.dayView.dk_backgroundColorPicker = day_dk_bg_color;
// 礼物图标显示
if (signModel.state == 0) { // 未签到
if (signModel.day == 3) { // 小礼物
self.giftIV.hidden = NO;
self.giftIV.dk_imagePicker = DKImagePickerWithNames(@"ic_rw_jiangli1", @"dk_ic_rw_jiangli1", @"dk_ic_rw_jiangli1");
} else if (signModel.day == 7) { // 大礼物
self.giftIV.hidden = NO;
self.giftIV.dk_imagePicker = DKImagePickerWithNames(@"ic_rw_jiangli2", @"dk_ic_rw_jiangli2", @"dk_ic_rw_jiangli2");
} else {
self.giftIV.hidden = YES;
}
} else { // 已签到不显示礼物图标
self.giftIV.hidden = YES;
}
// 积分显示
if (signModel.state == 0 && (signModel.day == 3 || signModel.day == 7)) {
self.scoreLab.hidden = YES;
} else {
self.scoreLab.hidden = NO;
}
self.scoreLab.text = [NSString stringWithFormat:@"+%d", signModel.point];
self.scoreLab.font = signModel.state == 1 ? SysFont(12.0) : SysFont(14.0);
[self.scoreLab sizeToFit];
[self.scoreLab mas_makeConstraints:^(MASConstraintMaker *make) {
if (signModel.state == 1) {
make.centerX.equalTo(self.dayView);
make.top.equalTo(self.dayView).offset(6);
} else {
make.center.equalTo(self.dayView);
}
}];
DKColorPicker score_dk_text_color = is_cur_day ? DKColorPickerWithColors(DSWhite, DkTitleColor, DSWhite) : DKColorPickerWithColors(ColorFromHex(0xFC7032), ColorFromHex(0xFC7032), DSWhite);
self.scoreLab.dk_textColorPicker = score_dk_text_color;
// 完成图标显示
self.doneIV.hidden = signModel.state == 0;
}
#pragma mark - lazy
- (UIView *)dayView {
if (!_dayView) {
_dayView = [UIView new];
[_dayView cornerRadius:20.0];
}
return _dayView;
}
- (UIImageView *)giftIV {
if (!_giftIV) {
_giftIV = [UIImageView new];
}
return _giftIV;
}
- (UILabel *)scoreLab {
if (!_scoreLab) {
_scoreLab = [UILabel new];
_scoreLab.textAlignment = NSTextAlignmentCenter;
_scoreLab.backgroundColor = DSClearColor;
}
return _scoreLab;
}
- (UIImageView *)doneIV {
if (!_doneIV) {
_doneIV = [[UIImageView alloc] dk_initWithImagePicker:DKImagePickerWithNames(@"ic_rw_yiqiandao", @"dk_ic_rw_yiqiandao", @"ic_rw_yiqiandao")];
}
return _doneIV;
}
@end