ReadyItemCell.m
1.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
//
// ReadyItemCell.m
// DreamSleep
//
// Created by peter on 2022/7/14.
//
#import "ReadyItemCell.h"
@interface ReadyItemCell ()
@property (nonatomic, strong) UIImageView *icon;
@property (nonatomic, strong) UILabel *timeLab;
@property (nonatomic, strong) UILabel *nameLab;
@end
@implementation ReadyItemCell
- (instancetype)initWithFrame:(CGRect)frame itemCellType:(ItemCellType)type {
if (self = [super initWithFrame:frame]) {
[self addSubview:self.icon];
[self addSubview:self.timeLab];
if (type == ItemCellTypeStart) {
[self addSubview:self.nameLab];
}
[self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(self);
make.width.height.equalTo(@40);
}];
[self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.left.right.equalTo(self);
}];
}
return self;
}
- (void)setItem:(ReadyItem *)item {
_item = item;
[self.icon yy_setImageWithURL:[NSURL URLWithString:item.icon] options:YYWebImageOptionShowNetworkActivity];
self.timeLab.text = [NSString stringWithFormat:@"%dmin", item.time];
}
- (void)adjustTime {
self.timeLab.text = [NSString stringWithFormat:@"%dmin", self.item.time];
}
#pragma mark - lazy
- (UIImageView *)icon {
if (!_icon) {
_icon = [UIImageView new];
}
return _icon;
}
- (UILabel *)timeLab {
if (!_timeLab) {
_timeLab = [UILabel labWithFont:SysFont(12.0)];
_timeLab.textAlignment = NSTextAlignmentCenter;
_timeLab.dk_textColorPicker = DKColorPickerWithColors(MainTextColor, ColorFromHexA(0xFFFFFF, .3));
}
return _timeLab;
}
@end