SleepStoryCell.m
5.0 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
//
// SleepStoryCell.m
// DreamSleep
//
// Created by peter on 2022/10/21.
//
#import "SleepStoryCell.h"
@interface SleepStoryCell ()
@property (nonatomic, strong) UIImageView *audioIV;
@property (nonatomic, strong) UILabel *audioLab;
@property (nonatomic, strong) UILabel *audioDescLab;
@property (nonatomic, strong) UIImageView *timeIcon;
@property (nonatomic, strong) UILabel *playTimeLab;
@property (nonatomic, strong) UIButton *playBtn;
@end
@implementation SleepStoryCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self.contentView addSubview:self.audioIV];
[self.contentView addSubview:self.audioLab];
[self.contentView addSubview:self.audioDescLab];
[self.contentView addSubview:self.timeIcon];
[self.contentView addSubview:self.playTimeLab];
[self.contentView addSubview:self.playBtn];
[self.audioIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.equalTo(self.contentView).offset(15);
make.size.mas_equalTo(CGSizeMake(76, 90));
}];
[self.audioLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.audioIV);
make.left.equalTo(self.audioIV.mas_right).offset(12);
make.right.equalTo(self.contentView).offset(-15);
}];
[self.audioDescLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView).offset(45);
make.left.equalTo(self.audioLab);
make.right.equalTo(self.contentView).offset(-62);
}];
[self.timeIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.audioLab);
make.size.mas_equalTo(CGSizeMake(14, 14));
make.bottom.equalTo(self.audioIV).offset(-2);
}];
[self.playTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.timeIcon.mas_right).offset(8);
make.centerY.equalTo(self.timeIcon);
make.right.equalTo(self.contentView).offset(-84);
}];
[self.playBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.contentView);
make.right.equalTo(self.contentView).offset(-15);
}];
}
return self;
}
- (void)setStoryModel:(SubAudioModel *)storyModel {
_storyModel = storyModel;
[self.audioIV yy_setImageWithURL:[NSURL URLWithString:storyModel.audio_pic] placeholder:[UIImage defaultPlaceholderWithSize:CGSizeMake(76, 90)]];
self.audioLab.text = storyModel.audio_name;
self.audioDescLab.text = storyModel.audio_desc;
self.playTimeLab.text = storyModel.play_time;
}
#pragma mark - lazy
- (UIImageView *)audioIV {
if (!_audioIV) {
_audioIV = [UIImageView new];
_audioIV.dk_alphaPicker = DKAlphaPickerWithAlphas(1, .5, 1);
[_audioIV cornerRadius:12];
}
return _audioIV;
}
- (UILabel *)audioLab {
if (!_audioLab) {
_audioLab = [UILabel labWithFont:BoldFont(16)];
_audioLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
}
return _audioLab;
}
- (UILabel *)audioDescLab {
if (!_audioDescLab) {
_audioDescLab = [UILabel labWithFont:SysFont(14)];
_audioDescLab.dk_textColorPicker = DKColorPickerWithColors(SubTitleColor, ColorFromHexA(0xFFFFFF, .5), DSWhite);
}
return _audioDescLab;
}
- (UIImageView *)timeIcon {
if (!_timeIcon) {
_timeIcon = [[UIImageView alloc] dk_initWithImagePicker:DKImagePickerWithNames(@"muse_time_icon", @"dk_muse_time_icon", @"muse_time_icon")];
}
return _timeIcon;
}
- (UILabel *)playTimeLab {
if (!_playTimeLab) {
_playTimeLab = [UILabel labWithFont:SysFont(12)];
_playTimeLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite);
}
return _playTimeLab;
}
- (UIButton *)playBtn {
if (!_playBtn) {
_playBtn = [UIButton btnWithTitle:@"播放" font:BoldFont(16)];
[_playBtn dk_setTitleColorPicker:DKColorPickerWithKey(Sub_Navi_TITLE) forState:UIControlStateNormal];
_playBtn.size = (CGSizeMake(64, 34));
[_playBtn cornerRadius:17];
CGPoint start = CGPointMake(0, 0.5);
CGPoint end = CGPointMake(0.5, 0.5);
UIView *normal_tmp_view = [_playBtn genGradientWithStart:start end:end colors:@[(__bridge id)ColorFromHex(0x9BE3EC).CGColor, (__bridge id)ColorFromHex(0x62C3D5).CGColor] locations:@[@(0), @(1.0f)]];
UIView *dk_tmp_view = [_playBtn genGradientWithStart:start end:end colors:@[(__bridge id)ColorFromHex(0x77A6AE).CGColor, (__bridge id)ColorFromHex(0x45A4B5).CGColor] locations:@[@(0), @(1.0f)]];
[_playBtn dk_setBackgroundImage:DKImagePickerWithImages([normal_tmp_view snapshotImage], [dk_tmp_view snapshotImage], [normal_tmp_view snapshotImage]) forState:UIControlStateNormal];
}
return _playBtn;
}
@end