AudioCourseCell.m
7.2 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
//
// AudioCourseCell.m
// DreamSleep
//
// Created by peter on 2022/5/6.
//
#import "AudioCourseCell.h"
@interface AudioCourseCell ()
@property (nonatomic,strong) UILabel *numberLb;
@property (nonatomic,strong) UIImageView *playVedioImgV;
@property (nonatomic,strong) UILabel *titleLb;
@property (nonatomic,strong) UIImageView *timeimgV;
@property (nonatomic,strong) UILabel *timeLb;
@property (nonatomic,strong) UIButton *pleyerBtn;
@property (nonatomic,strong) UIView *bigView;
@property (nonatomic,strong) UILabel *tryLab;
@end
@implementation AudioCourseCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.numberLb = [UILabel new];
[self.contentView addSubview:self.numberLb];
self.numberLb.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
self.numberLb.dk_backgroundColorPicker = DKColorPickerWithColors(ColorFromHex(0xDFEFF4), ColorFromHex(0x21364F), DSWhite);
self.numberLb.textAlignment = NSTextAlignmentCenter;
self.numberLb.textColor = BrandColor;
self.numberLb.layer.cornerRadius = 6;
self.numberLb.layer.masksToBounds = YES;
[self.numberLb mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.mas_left).offset(15);
make.top.equalTo(self.contentView.mas_top).offset(20);
make.width.equalTo(@30);
make.height.equalTo(@30);
}];
self.playVedioImgV = [UIImageView new];
[self.contentView addSubview:self.playVedioImgV];
[self.playVedioImgV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.mas_left).offset(15);
make.top.equalTo(self.contentView.mas_top).offset(20);
make.width.equalTo(@30);
make.height.equalTo(@30);
}];
self.bigView = [UIView new];
[self.contentView addSubview:self.bigView];
self.bigView.dk_backgroundColorPicker = DKColorPickerWithKey(CornerViewBG);
self.bigView.layer.cornerRadius = 12;
self.bigView.layer.masksToBounds = YES;
[self.bigView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.numberLb.mas_right).offset(12);
make.right.equalTo(self.contentView.mas_right).offset(-15);
make.top.equalTo(self.contentView.mas_top).offset(10);
make.bottom.equalTo(self.contentView.mas_bottom).offset(-10);
}];
self.titleLb = [UILabel new];
[self.bigView addSubview:self.titleLb];
self.titleLb.textAlignment = NSTextAlignmentLeft;
self.titleLb.text = @"第一天-睡前准备";
self.titleLb.font = [UIFont systemFontOfSize:15];
self.titleLb.layer.masksToBounds = YES;
[self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.bigView.mas_left).offset(15);
make.top.equalTo(self.bigView.mas_top).offset(15);
make.height.equalTo(@21);
make.width.equalTo(@190);
}];
self.timeimgV = [UIImageView new];
[self.bigView addSubview:self.timeimgV];
[self.timeimgV dk_setImagePicker:DKImagePickerWithNames(@"muse_time_icon", @"dk_muse_time_icon", @"muse_time_icon")];
[self.timeimgV mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.bigView.mas_left).offset(15);
make.bottom.equalTo(self.bigView.mas_bottom).offset(-17);
make.width.equalTo(@14);
make.height.equalTo(@14);
}];
self.timeLb = [UILabel new];
[self.bigView addSubview:self.timeLb];
self.timeLb.textAlignment = NSTextAlignmentLeft;
self.timeLb.text = @"00:01/25:00";
self.timeLb.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHex(0x626778), DSWhite);
self.timeLb.font = [UIFont systemFontOfSize:15];
self.timeLb.layer.masksToBounds = YES;
[self.timeLb mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.timeimgV.mas_right).offset(8);
make.centerY.equalTo(self.timeimgV.mas_centerY);
make.height.equalTo(@17);
make.width.equalTo(@100);
}];
self.pleyerBtn = [UIButton new];
self.pleyerBtn.userInteractionEnabled = NO;
[self.bigView addSubview:self.pleyerBtn];
[self.pleyerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.bigView.mas_right).offset(-15);
make.width.equalTo(@40);
make.height.equalTo(@40);
make.centerY.equalTo(self.bigView.mas_centerY);
}];
self.tryLab = [UILabel labWithText:@"试听" font:SysFont(12) fit:NO];
self.tryLab.dk_textColorPicker = DKColorPickerWithKey(TabBarBG);
self.tryLab.backgroundColor = BrandColor;
self.tryLab.hidden = YES;
[self.tryLab cornerRadius:9];
self.tryLab.textAlignment = NSTextAlignmentCenter;
[self.bigView addSubview:self.tryLab];
[self.tryLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.bigView);
make.right.equalTo(self.bigView).offset(-15);
make.size.mas_equalTo(CGSizeMake(40, 18));
}];
}
return self;
}
- (void)updateUI:(SubAudioModel *)model indexPath:(NSIndexPath *)indexPath {
self.numberLb.hidden = NO;
self.playVedioImgV.hidden = !self.numberLb.hidden;
self.numberLb.text = [NSString stringWithFormat:@"%ld", indexPath.row + 1];
self.timeLb.text = model.play_time;
self.titleLb.text = model.audio_name;
UIColor *normalTitleColor = model.is_lock == 1 ? ColorFromHex(0x848484) : MainTextColor;
UIColor *darkTitleColor = model.is_lock == 1 ? ColorFromHex(0xBBBBBB) : ColorFromHex(0xE8E9E9);
NSString *normalImgName = model.is_lock == 1 ? @"dk_ic_list_play_normal" : @"ic_list_play_normal";
NSString *darkImgName = model.is_lock == 1 ? @"dk_ic_list_play_normal" : @"dk_ic_list_play_normal_unlock";
self.titleLb.dk_textColorPicker = DKColorPickerWithColors(normalTitleColor, darkTitleColor, DSWhite);
[self.pleyerBtn dk_setImage:DKImagePickerWithNames(normalImgName, darkImgName, @"dk_ic_list_play_normal") forState:UIControlStateNormal];
// 音频未🔒
if (model.is_lock == 0) {
self.tryLab.hidden = [LoginUtils getUserLoginData];
} else {
self.tryLab.hidden = YES;
}
self.pleyerBtn.hidden = !self.tryLab.hidden;
}
- (void)updatePlayingAudio {
self.numberLb.hidden = YES;
self.playVedioImgV.hidden = !self.numberLb.hidden;
self.tryLab.hidden = YES;
self.pleyerBtn.hidden = !self.tryLab.hidden;
[self.playVedioImgV dk_setImagePicker:DKImagePickerWithNames(@"ic_list_playing_normal", @"dk_ic_list_playing_normal", @"ic_list_playing_normal")];
[self.pleyerBtn setImage:[UIImage imageNamed:@"ic_list_suspend_normal"] forState:UIControlStateNormal];
}
@end