Commit c848f239 cgx

完成音频列表

1 个父辈 0537e42c
正在显示 20 个修改的文件 包含 231 行增加28 行删除
......@@ -6,12 +6,13 @@
//
#import <UIKit/UIKit.h>
#import "SubAudioModel.h"
NS_ASSUME_NONNULL_BEGIN
/// 音频课程列表cell
@interface AudioCourseCell : UITableViewCell
- (void)updateUI:(SubAudioModel *)model indexPath:(NSIndexPath *)indexPath;
@end
NS_ASSUME_NONNULL_END
......@@ -7,14 +7,135 @@
#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.bigView addSubview:self.pleyerBtn];
[self.pleyerBtn addTarget:self action:@selector(playerBtnClick:) forControlEvents:UIControlEventTouchUpInside];
[self.pleyerBtn dk_setImage:DKImagePickerWithNames(@"ic_list_play_normal", @"dk_ic_list_play_normal", @"dk_ic_list_play_normal") forState:UIControlStateNormal];
[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.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;
self.titleLb.dk_textColorPicker = DKColorPickerWithColors(normalTitleColor, ColorFromHex(0xE8E9E9), DSWhite);
if (model.is_lock == 0 && indexPath.row == 0) {
self.pleyerBtn.hidden = YES;
self.tryLab.hidden = NO;
}
}
@end
......@@ -20,7 +20,7 @@
- (instancetype)initWithModel:(CourseModel *)model {
if (self = [super initWithFrame:CGRectMake(0, 0, kScreenWidth, 250)]) {
self.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[self debugViewShowBorder];
self.clipsToBounds = YES;
[self addSubview:self.bgIV];
[self addSubview:self.audioIV];
......@@ -52,16 +52,12 @@
[self.cornerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self);
make.bottom.equalTo(self).offset(20);
make.height.equalTo(@35);
make.height.equalTo(@40);
}];
}
return self;
}
- (void)updateHeadView:(CourseModel *)model {
}
#pragma mark - lazy
- (UIImageView *)bgIV {
if (!_bgIV) {
......
......@@ -12,7 +12,7 @@
@interface CourseDetailController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *audioListView;
@property (nonatomic,strong) NSMutableArray *subAudioArr;
@property (nonatomic,strong) NSArray *subAudioArr;
@property (nonatomic,strong) UIButton *unlockBtn;
@end
......@@ -33,9 +33,13 @@
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
self.titleLab.text = self.courseModel.audio_name;
[self getAudiosData];
}
- (void)getAudiosData {
[SafeSleepRequestModel queryRelaxMeditationAudiosWithTypeID:self.courseModel.course_id completion:^(SafeSleepRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
[self.subAudioArr addObjectsFromArray:requestModel.subAudioListData];
self.subAudioArr = requestModel.subAudioListData;
[self.audioListView reloadData];
}
}];
......@@ -63,11 +67,8 @@
}
- (void)unlockAction {
// 判断是否登录成功
if ([LoginUtils getUserLoginData]) {
} else {
// 跳转到登录页面
[LoginUtils jumpToLoginControllerWithTarget:self];
}
}
......@@ -83,19 +84,10 @@
if (!cell) {
cell = [[AudioCourseCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
// cell.delegate = self;
// cell.selectionStyle = UITableViewCellSelectionStyleNone;
// subAudioModel *model;
// if(self.subAudioArr.count > indexPath.row){
//
// model = [self.subAudioArr objectAtIndex:indexPath.row];
// cell.numberLb.text = [NSString stringWithFormat:@"%ld",indexPath.row + 1];
// cell.timeLb.text = model.play_time;
// cell.titleLb.text = model.audio_name;
// cell.titleLb.textColor = [UIColor colorWithHexString:@"#333333"];
// cell.playVedioImgV.hidden = YES;
// }
if (self.subAudioArr.count > indexPath.row) {
SubAudioModel *model = self.subAudioArr[indexPath.row];
[cell updateUI:model indexPath:indexPath];
}
return cell;
}
......@@ -116,9 +108,9 @@
}
#pragma mark - lazy
- (NSMutableArray *)subAudioArr {
- (NSArray *)subAudioArr {
if(!_subAudioArr) {
_subAudioArr = [NSMutableArray array];
_subAudioArr = [NSArray array];
}
return _subAudioArr;
}
......@@ -129,11 +121,12 @@
_audioListView.delegate = self;
_audioListView.dataSource = self;
_audioListView.bounces = NO;
[_audioListView debugViewShowBorder];
_audioListView.showsVerticalScrollIndicator = NO;
_audioListView.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
_audioListView.separatorStyle = UITableViewCellSeparatorStyleNone;
_audioListView.tableHeaderView = [[AudioDetailHeaderView alloc] initWithModel:self.courseModel];
UIView *footView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 100)];
_audioListView.tableFooterView = footView;
_audioListView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
return _audioListView;
......
{
"images" : [
{
"filename" : "dk_ic_list_play_normal.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_ic_list_play_normal@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_ic_list_play_normal@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dk_muse_time_icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_muse_time_icon@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_muse_time_icon@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_list_play_normal.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_list_play_normal@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_list_play_normal@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "muse_time_icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "muse_time_icon@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "muse_time_icon@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!