小说绘上架版本
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// TFAudioDetailViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFAudioDetailViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,assign) NSInteger audio_id;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+368
@@ -0,0 +1,368 @@
|
||||
//
|
||||
// TFAudioDetailViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAudioDetailViewController.h"
|
||||
#import "WXYZ_AudioDownloadViewController.h"
|
||||
#import "TFAudioDetailHeaderView.h"
|
||||
#import "TFAudioDetailFooterView.h"
|
||||
#import "WXYZ_CompositeEmbeddedTableView.h"
|
||||
#import "WXYZ_TouchAssistantView.h"
|
||||
#import "TFAudioDetailModel.h"
|
||||
#import "TFShareManager.h"
|
||||
#import "UIView+BorderLine.h"
|
||||
|
||||
@interface TFAudioDetailViewController ()<UITableViewDelegate, UITableViewDataSource, UIScrollViewDelegate>
|
||||
|
||||
@property (nonatomic ,strong) UIView *gradientColorView;
|
||||
|
||||
@property (nonatomic ,assign) BOOL canScroll;
|
||||
|
||||
@property (nonatomic ,assign) CGFloat lastContentOffset; // 滑动距离
|
||||
|
||||
@property (nonatomic ,assign) BOOL slidingUp; // 滑动方向
|
||||
|
||||
@property (nonatomic ,strong) TFAudioDetailModel *detailModel;
|
||||
|
||||
@property (nonatomic ,strong) UIButton *shareButton;
|
||||
|
||||
@property (nonatomic ,strong) UIButton *downloadButton;
|
||||
|
||||
@property (nonatomic ,strong) WXYZ_CompositeEmbeddedTableView *mallTableView;
|
||||
|
||||
@property (nonatomic ,strong) TFAudioDetailHeaderView *headerView;
|
||||
|
||||
@property (nonatomic ,strong) TFAudioDetailFooterView *footerView;
|
||||
|
||||
@property (nonatomic ,assign) CGFloat headerViewHeight;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFAudioDetailViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarLightContentStyle];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Hidden_Tabbar object:nil];
|
||||
|
||||
if (self.headerView) {
|
||||
[self.headerView reloadCollectionButtonState];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self hiddenSeparator];
|
||||
|
||||
self.navigationBar.backgroundColor = [UIColor clearColor];
|
||||
self.navigationBar.navTitleLabel.alpha = 0;
|
||||
self.navigationBar.navTitleLabel.textColor = kWhiteColor;
|
||||
[self.navigationBar setLightLeftButton];
|
||||
|
||||
self.canScroll = YES;
|
||||
self.headerViewHeight = 0;
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeScrollStatus:) name:Notification_Audio_Can_Leave_Top object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadAudioDetail:) name:Notification_Audio_Check_Recommend object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netRequest) name:Notification_Recharge_Success object:nil];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
self.shareButton.adjustsImageWhenHighlighted = NO;
|
||||
self.shareButton.tintColor = kWhiteColor;
|
||||
self.shareButton.hidden = YES;
|
||||
[self.shareButton setImage:[[UIImage imageNamed:@"public_share"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
|
||||
[self.shareButton setImageEdgeInsets:UIEdgeInsetsMake(6, 12, 6, 0)];
|
||||
[self.shareButton addTarget:self action:@selector(shareButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.navigationBar addSubview:self.shareButton];
|
||||
|
||||
[self.shareButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.navigationBar.mas_right).with.offset(- kMargin);
|
||||
make.bottom.mas_equalTo(self.navigationBar.mas_bottom).with.offset(- 7);
|
||||
make.width.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
|
||||
#if TF_Download_Mode
|
||||
|
||||
self.downloadButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
self.downloadButton.hidden = YES;
|
||||
self.downloadButton.adjustsImageWhenHighlighted = NO;
|
||||
self.downloadButton.tintColor = kWhiteColor;
|
||||
[self.downloadButton setImage:[[UIImage imageNamed:@"public_download"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
|
||||
[self.downloadButton setImageEdgeInsets:UIEdgeInsetsMake(6, 12, 6, 0)];
|
||||
[self.downloadButton addTarget:self action:@selector(downloadClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.navigationBar addSubview:self.downloadButton];
|
||||
|
||||
[self.downloadButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.shareButton.mas_left).with.offset(- kHalfMargin);
|
||||
make.bottom.mas_equalTo(self.navigationBar.mas_bottom).with.offset(- 7);
|
||||
make.width.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
#endif
|
||||
|
||||
self.navigationBar.touchEnabled = YES;
|
||||
|
||||
self.gradientColorView = [[UIView alloc] init];
|
||||
self.gradientColorView.backgroundColor = kGrayViewColor;
|
||||
[self.view addSubview:self.gradientColorView];
|
||||
|
||||
[self.gradientColorView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.view);
|
||||
}];
|
||||
|
||||
self.mallTableView = [[WXYZ_CompositeEmbeddedTableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStylePlain];
|
||||
self.mallTableView.delegate = self;
|
||||
self.mallTableView.dataSource = self;
|
||||
self.mallTableView.bounces = NO;
|
||||
[self.mallTableView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil];
|
||||
[self.view addSubview:self.mallTableView];
|
||||
|
||||
WS(weakSelf)
|
||||
self.headerView = [[TFAudioDetailHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH)];
|
||||
self.headerView.changeIntroductionBlock = ^(CGFloat headerViewHeight, BOOL viewEnable) {
|
||||
weakSelf.headerViewHeight = headerViewHeight;
|
||||
weakSelf.mallTableView.scrollEnabled = viewEnable;
|
||||
// 重置headerView高度
|
||||
[UIView animateWithDuration:kAnimatedDurationFast animations:^{
|
||||
UIView *t_headerView = weakSelf.headerView;
|
||||
t_headerView.height = headerViewHeight;
|
||||
[weakSelf.mallTableView beginUpdates];
|
||||
[weakSelf.mallTableView setTableHeaderView:t_headerView];
|
||||
[weakSelf.mallTableView endUpdates];
|
||||
}];
|
||||
};
|
||||
|
||||
[self.mallTableView setTableHeaderView:self.headerView];
|
||||
|
||||
self.footerView = [[TFAudioDetailFooterView alloc] init];
|
||||
self.footerView.view.hidden = YES;
|
||||
self.footerView.view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
self.footerView.audio_id = self.audio_id;
|
||||
[self.footerView.view addRoundingCornersWithRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight)];
|
||||
[self.mallTableView setTableFooterView:self.footerView.view];
|
||||
[self addChildViewController:self.footerView];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return [[UITableViewCell alloc] init];
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context
|
||||
{
|
||||
if ([keyPath isEqualToString:@"contentOffset"]) {
|
||||
CGPoint point = [((NSValue *)[self.mallTableView valueForKey:@"contentOffset"]) CGPointValue];
|
||||
if (self.canScroll) {
|
||||
self.footerView.contentOffSetY = point.y;
|
||||
self.headerView.contentOffSetY = point.y;
|
||||
} else {
|
||||
self.footerView.contentOffSetY = self.headerViewHeight - PUB_NAVBAR_HEIGHT;
|
||||
self.headerView.contentOffSetY = self.headerViewHeight - PUB_NAVBAR_HEIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)changeScrollStatus:(NSNotification *)noti
|
||||
{
|
||||
self.canScroll = [noti.object boolValue];
|
||||
}
|
||||
|
||||
- (void)reloadAudioDetail:(NSNotification *)noti
|
||||
{
|
||||
self.audio_id = [noti.object integerValue];
|
||||
self.footerView.audio_id = self.audio_id;
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
|
||||
{
|
||||
self.lastContentOffset = scrollView.contentOffset.y; //判断上下滑动时
|
||||
}
|
||||
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
||||
{
|
||||
if (scrollView.contentOffset.y <= self.headerViewHeight - PUB_NAVBAR_HEIGHT) {
|
||||
|
||||
if (self.canScroll) {
|
||||
self.canScroll = YES;
|
||||
self.footerView.canScroll = NO;
|
||||
if (scrollView.contentOffset.y <= 0) {
|
||||
scrollView.contentOffset = CGPointMake(0, 0);
|
||||
}
|
||||
} else {
|
||||
scrollView.contentOffset = CGPointMake(0, self.headerViewHeight - PUB_NAVBAR_HEIGHT);
|
||||
}
|
||||
|
||||
if (scrollView.contentOffset.y < self.lastContentOffset ){
|
||||
self.slidingUp = NO;
|
||||
} else if (scrollView.contentOffset.y > self.lastContentOffset ){
|
||||
self.slidingUp = YES;
|
||||
}
|
||||
|
||||
} else {
|
||||
self.canScroll = NO;
|
||||
scrollView.contentOffset = CGPointMake(0, self.headerViewHeight - PUB_NAVBAR_HEIGHT);
|
||||
self.footerView.canScroll = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
|
||||
{
|
||||
if (self.footerView.canScroll || scrollView.contentOffset.y == 0) {
|
||||
return;
|
||||
}
|
||||
if (self.slidingUp) {
|
||||
if (fabs(scrollView.contentOffset.y - self.lastContentOffset) > self.headerViewHeight * 0.2) {
|
||||
[scrollView setContentOffset:CGPointMake(0, self.headerViewHeight - PUB_NAVBAR_HEIGHT) animated:YES];
|
||||
} else {
|
||||
[scrollView setContentOffset:CGPointMake(0, 0) animated:YES];
|
||||
}
|
||||
} else {
|
||||
if (fabs(scrollView.contentOffset.y - self.lastContentOffset) > self.headerViewHeight * 0.2) {
|
||||
[scrollView setContentOffset:CGPointMake(0, 0) animated:YES];
|
||||
} else {
|
||||
[scrollView setContentOffset:CGPointMake(0, self.headerViewHeight - PUB_NAVBAR_HEIGHT) animated:YES];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
|
||||
{
|
||||
if (self.canScroll) {
|
||||
if (self.slidingUp) {
|
||||
if (fabs(scrollView.contentOffset.y - self.lastContentOffset) > self.headerViewHeight * 0.2) {
|
||||
[scrollView setContentOffset:CGPointMake(0, self.headerViewHeight - PUB_NAVBAR_HEIGHT) animated:YES];
|
||||
} else {
|
||||
[scrollView setContentOffset:CGPointMake(0, 0) animated:YES];
|
||||
}
|
||||
} else {
|
||||
if (fabs(scrollView.contentOffset.y - self.lastContentOffset) > self.headerViewHeight * 0.2) {
|
||||
[scrollView setContentOffset:CGPointMake(0, 0) animated:YES];
|
||||
} else {
|
||||
[scrollView setContentOffset:CGPointMake(0, self.headerViewHeight - PUB_NAVBAR_HEIGHT) animated:YES];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)shareButtonClick
|
||||
{
|
||||
[TFShareManager shareWithProduction_id:NSStringFromInteger(self.detailModel.audio.production_id) chapter_id:nil type:TFShareTypeAudio];
|
||||
}
|
||||
|
||||
- (void)downloadClick
|
||||
{
|
||||
if (!self.audio_id || self.audio_id == 0) {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"书籍获取失败")];
|
||||
return;
|
||||
}
|
||||
|
||||
if (!self.footerView.directoryModel.chapter_list || self.footerView.directoryModel.chapter_list.count == 0) {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"书籍获取失败")];
|
||||
return;
|
||||
}
|
||||
|
||||
WXYZ_AudioDownloadViewController *vc = [[WXYZ_AudioDownloadViewController alloc] init];
|
||||
vc.production_id = self.audio_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
if ([TFNetworkManager networkingStatus] == NO) {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"当前无网络连接")];
|
||||
return;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Audio_Info parameters:@{@"audio_id":[TFUtilsHelper formatStringWithInteger:self.audio_id]} model:nil success:^(BOOL isSuccess, id _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
if (isSuccess) {
|
||||
NSMutableDictionary *t_dic = [t_model mutableCopy];
|
||||
NSMutableDictionary *t_data_dic = [[t_dic objectForKey:@"data"] mutableCopy];
|
||||
|
||||
NSMutableDictionary *t_production_dic = [NSMutableDictionary dictionaryWithDictionary:[t_data_dic objectForKey:@"audio"]];
|
||||
NSMutableDictionary *t_ad_dic = [NSMutableDictionary dictionaryWithDictionary:[t_data_dic objectForKey:@"advert"]];
|
||||
|
||||
[t_production_dic addEntriesFromDictionary:t_ad_dic];
|
||||
|
||||
[t_data_dic setObject:t_production_dic forKey:@"audio"];
|
||||
|
||||
TFAudioDetailModel *t_model = [TFAudioDetailModel modelWithDictionary:t_data_dic];
|
||||
|
||||
weakSelf.headerView.audioModel = t_model.audio;
|
||||
weakSelf.detailModel = t_model;
|
||||
if (t_model.color.count > 1) {
|
||||
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
|
||||
gradientLayer.frame = weakSelf.view.frame;
|
||||
gradientLayer.colors = @[(__bridge id)[UIColor colorWithHexString:[t_model.color firstObject]?:@""].CGColor,(__bridge id)[UIColor colorWithHexString:[t_model.color objectAtIndex:1]?:@""].CGColor];
|
||||
gradientLayer.startPoint = CGPointMake(0, 0);
|
||||
gradientLayer.endPoint = CGPointMake(0, 1.0);
|
||||
[weakSelf.gradientColorView.layer addSublayer:gradientLayer];
|
||||
}
|
||||
}
|
||||
|
||||
weakSelf.shareButton.hidden = NO;
|
||||
weakSelf.downloadButton.hidden = NO;
|
||||
weakSelf.footerView.view.hidden = NO;
|
||||
} failure:nil];
|
||||
|
||||
[TFNetworkTools POST:Audio_Catalog parameters:@{@"audio_id":[TFUtilsHelper formatStringWithInteger:self.audio_id]} model:TFProductionModel.class success:^(BOOL isSuccess, TFProductionModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
if (isSuccess) {
|
||||
weakSelf.footerView.directoryModel = t_model;
|
||||
[weakSelf.mallTableView reloadData];
|
||||
}
|
||||
} failure:nil];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
@try {
|
||||
[self.mallTableView removeObserver:self forKeyPath:@"contentOffset" context:NULL];
|
||||
} @catch (NSException *exception) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFAudioDirectoryViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFAudioDirectoryViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,assign) NSInteger audio_id;
|
||||
@property (nonatomic ,assign) BOOL canScroll;
|
||||
@property (nonatomic ,strong) TFProductionModel *directoryModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+416
@@ -0,0 +1,416 @@
|
||||
//
|
||||
// TFAudioDirectoryViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAudioDirectoryViewController.h"
|
||||
#import "TFAudioPlayViewController.h"
|
||||
#import "TFTaskViewController.h"
|
||||
#import "TFAudioDirectoryViewCell.h"
|
||||
#import "WXYZ_AudioPlayPageMenuView.h"
|
||||
#import "WXYZ_ChapterBottomPayBar.h"
|
||||
#import "WXYZ_AudioDownloadManager.h"
|
||||
#import "TFReadRecordManager.h"
|
||||
#import "TFCollectionManager.h"
|
||||
|
||||
@interface TFAudioDirectoryViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) UIView *headerSectionView;
|
||||
@property (nonatomic ,strong) UILabel *headerSectionLabel;
|
||||
@property (nonatomic ,assign) BOOL toolSelect; // 工具栏状态选择
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFAudioDirectoryViewController
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self.mainTableView reloadData];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self hiddenNavigationBar:YES];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeChapterList:) name:NSNotification_Auto_Buy_Audio_Chapter object:nil];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.view);
|
||||
}];
|
||||
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"暂无目录列表") buttonTitle:@"" tapBlock:^{
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
||||
{
|
||||
if (self.toolSelect) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ([scrollView isEqual:self.mainTableView]) {
|
||||
if (!self.canScroll) {
|
||||
scrollView.contentOffset = CGPointZero;
|
||||
}
|
||||
|
||||
if (scrollView.contentOffset.y > 0) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Audio_Can_Leave_Top object:@NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
|
||||
{
|
||||
self.toolSelect = NO;
|
||||
}
|
||||
|
||||
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
|
||||
{
|
||||
if (scrollView.contentOffset.y <= 0) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Audio_Can_Leave_Top object:@YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.directoryModel.chapter_list.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
WS(weakSelf)
|
||||
TFProductionChapterModel *t_chapterList = [self.directoryModel.chapter_list objectOrNilAtIndex:indexPath.row];
|
||||
TFAudioDirectoryViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFAudioDirectoryViewCell"];
|
||||
|
||||
if (!cell) {
|
||||
cell = [[TFAudioDirectoryViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFAudioDirectoryViewCell"];
|
||||
}
|
||||
cell.audioDirectoryModel = t_chapterList;
|
||||
cell.index = indexPath;
|
||||
cell.cellDownloadState = [[WXYZ_AudioDownloadManager sharedManager] getChapterDownloadStateWithProduction_id:t_chapterList.production_id chapter_id:t_chapterList.chapter_id];
|
||||
cell.hiddenEndLine = self.directoryModel.chapter_list.count - 1 == indexPath.row;
|
||||
cell.downloadChapterBlock = ^(NSInteger audio_id, NSInteger chapter_id, NSIndexPath *cellIndexPath) {
|
||||
[weakSelf requestChapterDownloadDataWithAudio_id:audio_id chapter_ids:@[[TFUtilsHelper formatStringWithInteger:chapter_id]] indexPath:cellIndexPath];
|
||||
};
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Reset_Player_Inof object:nil];
|
||||
|
||||
WS(weakSelf)
|
||||
TFProductionChapterModel *t_chapterListModel = [self.directoryModel.chapter_list objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
TFAudioPlayViewController *vc = [TFAudioPlayViewController sharedManager];
|
||||
vc.chapter_list = self.directoryModel.chapter_list;
|
||||
[vc loadDataWithAudio_id:t_chapterListModel.production_id chapter_id:t_chapterListModel.chapter_id];
|
||||
|
||||
for (UIViewController *vc in weakSelf.navigationController.viewControllers) {
|
||||
if ([vc isKindOfClass:[TFAudioPlayViewController class]]) {
|
||||
[weakSelf popViewController];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[weakSelf closeContinuePlayButton];
|
||||
[TFTaskViewController taskReadRequestWithProduction_id:self.audio_id];
|
||||
|
||||
TFNavigationController *nav = [[TFNavigationController alloc] initWithRootViewController:vc];
|
||||
[[TFViewHelper getWindowRootController] presentViewController:nav animated:YES completion:^{
|
||||
[weakSelf.mainTableView reloadData];
|
||||
}];
|
||||
|
||||
[[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] moveCollectionToTopWithProductionModel:self.directoryModel];
|
||||
}
|
||||
|
||||
//section头间距
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
if (self.directoryModel.chapter_list.count > 0) {
|
||||
return 60;
|
||||
}
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
//section头视图
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return self.headerSectionView;
|
||||
}
|
||||
|
||||
//section底部间距
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
//section底部视图
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (UIView *)headerSectionView
|
||||
{
|
||||
if (!_headerSectionView) {
|
||||
_headerSectionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 60)];
|
||||
_headerSectionView.backgroundColor = kWhiteColor;
|
||||
|
||||
[_headerSectionView addSubview:self.headerSectionLabel];
|
||||
|
||||
if (![[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeAudio]
|
||||
isCurrentPlayingProductionWithProduction_id:self.audio_id] // 不是正在播放的作品
|
||||
&&
|
||||
([[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeAudio]
|
||||
getReadingRecordChapter_idWithProduction_id:self.audio_id] > 0) // 记录章节id存在
|
||||
&&
|
||||
([[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeAudio]
|
||||
getReadingRecordChapterTitleWithProduction_id:self.audio_id].length > 0) // 记录的章节名称存在
|
||||
) {
|
||||
|
||||
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString: [NSString stringWithFormat:@"%@|%@", TFLocalizedString(@"续播"), [[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeAudio] getReadingRecordChapterTitleWithProduction_id:self.audio_id]]];
|
||||
CGFloat width = [TFViewHelper getDynamicWidthWithLabelFont:kFont10 labelHeight:30.0 labelText:text.string maxWidth:SCREEN_WIDTH / 2.0];
|
||||
width += kHalfMargin;
|
||||
|
||||
UIButton *continuePlay = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
continuePlay.frame = CGRectMake(kMargin, kHalfMargin + 5, 20.0 + kQuarterMargin + width, 30);
|
||||
continuePlay.tag = 1123;
|
||||
continuePlay.backgroundColor = kWhiteColor;
|
||||
continuePlay.layer.cornerRadius = 15;
|
||||
continuePlay.layer.borderColor = kMainColor.CGColor;
|
||||
continuePlay.layer.borderWidth = 1;
|
||||
continuePlay.clipsToBounds = YES;
|
||||
[continuePlay addTarget:self action:@selector(continueButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_headerSectionView addSubview:continuePlay];
|
||||
|
||||
UIImageView *icon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"audio_play"]];
|
||||
icon.frame = CGRectMake(5, 5, continuePlay.height - 10, continuePlay.height - 10);
|
||||
[continuePlay addSubview:icon];
|
||||
|
||||
|
||||
|
||||
text.font = kFont10;
|
||||
text.color = kMainColor;
|
||||
[text addAttribute:NSFontAttributeName value:kBoldFont10 range:NSMakeRange(0, 2)];
|
||||
|
||||
UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(icon.right + 5, 0, width, continuePlay.height)];
|
||||
title.attributedText = text;
|
||||
[continuePlay addSubview:title];
|
||||
|
||||
UIButton *closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
closeButton.frame = CGRectMake(continuePlay.right - continuePlay.height / 2 + 5, continuePlay.top - 5, continuePlay.height / 2 + 10, continuePlay.height / 2 + 10);
|
||||
closeButton.layer.cornerRadius = continuePlay.height / 4;
|
||||
closeButton.clipsToBounds = YES;
|
||||
closeButton.tag = 1123;
|
||||
closeButton.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
|
||||
closeButton.contentHorizontalAlignment = UIControlContentVerticalAlignmentFill;
|
||||
[closeButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 10, 10)];
|
||||
[closeButton setImage:[UIImage imageNamed:@"audio_continue_close"] forState:UIControlStateNormal];
|
||||
[closeButton addTarget:self action:@selector(closeContinuePlayButton) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_headerSectionView addSubview:closeButton];
|
||||
|
||||
}
|
||||
|
||||
TFButton *selectionButton = [[TFButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 40 - kHalfMargin, 10, 40, 40) buttonTitle:TFLocalizedString(@"选章标题") buttonImageName:@"audio_selection" buttonIndicator:TFButtonIndicatorTitleBottom];
|
||||
selectionButton.tag = 0;
|
||||
selectionButton.buttonTintColor = kBlackColor;
|
||||
selectionButton.buttonTitleFont = kFont10;
|
||||
selectionButton.graphicDistance = 2;
|
||||
selectionButton.buttonImageScale = 0.4;
|
||||
[selectionButton addTarget:self action:@selector(toolBarButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_headerSectionView addSubview:selectionButton];
|
||||
|
||||
TFButton *sortButton = [[TFButton alloc] initWithFrame:CGRectMake(selectionButton.left - 40 - kHalfMargin, selectionButton.top, selectionButton.width, selectionButton.height) buttonTitle:TFLocalizedString(@"排序") buttonImageName:@"audio_order_sequence" buttonIndicator:TFButtonIndicatorTitleBottom];
|
||||
sortButton.selected = NO;
|
||||
sortButton.tag = 1;
|
||||
sortButton.buttonTintColor = kBlackColor;
|
||||
sortButton.buttonTitleFont = kFont10;
|
||||
sortButton.graphicDistance = 2;
|
||||
sortButton.buttonImageScale = 0.4;
|
||||
[sortButton addTarget:self action:@selector(toolBarButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_headerSectionView addSubview:sortButton];
|
||||
|
||||
}
|
||||
return _headerSectionView;
|
||||
}
|
||||
|
||||
- (UILabel *)headerSectionLabel
|
||||
{
|
||||
if (!_headerSectionLabel) {
|
||||
_headerSectionLabel = [[UILabel alloc] initWithFrame:CGRectMake(kMargin, 0, SCREEN_WIDTH / 2, 60)];
|
||||
_headerSectionLabel.textColor = kGrayTextDeepColor;
|
||||
_headerSectionLabel.font = kFont12;
|
||||
_headerSectionLabel.textAlignment = NSTextAlignmentLeft;
|
||||
}
|
||||
return _headerSectionLabel;
|
||||
}
|
||||
|
||||
- (void)setDirectoryModel:(TFProductionModel *)directoryModel
|
||||
{
|
||||
_directoryModel = directoryModel;
|
||||
self.headerSectionLabel.text = [NSString stringWithFormat:TFLocalizedString(@"共%@章"), [TFUtilsHelper formatStringWithInteger:directoryModel.chapter_list.count]];
|
||||
[self.mainTableView reloadData];
|
||||
self.emptyView.contentViewY = kHalfMargin;
|
||||
[self.mainTableView endRefreshing];
|
||||
[self.mainTableView xtfei_endLoading];
|
||||
}
|
||||
|
||||
- (void)continueButtonClick
|
||||
{
|
||||
WS(weakSelf)
|
||||
TFAudioPlayViewController *vc = [TFAudioPlayViewController sharedManager];
|
||||
vc.chapter_list = self.directoryModel.chapter_list;
|
||||
[vc loadDataWithAudio_id:self.audio_id chapter_id:[[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeAudio] getReadingRecordChapter_idWithProduction_id:self.audio_id]];
|
||||
TFNavigationController *nav = [[TFNavigationController alloc] initWithRootViewController:vc];
|
||||
[[TFViewHelper getWindowRootController] presentViewController:nav animated:YES completion:^{
|
||||
[weakSelf closeContinuePlayButton];
|
||||
[weakSelf.mainTableView reloadData];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)closeContinuePlayButton
|
||||
{
|
||||
[self.headerSectionView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if (obj.tag == 1123) {
|
||||
[obj removeAllSubviews];
|
||||
[obj removeFromSuperview];
|
||||
obj = nil;
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)toolBarButtonClick:(TFButton *)sender
|
||||
{
|
||||
switch (sender.tag) {
|
||||
case 0: // 选章
|
||||
{
|
||||
WS(weakSelf)
|
||||
WXYZ_AudioPlayPageMenuView *chooseMenuView = [[WXYZ_AudioPlayPageMenuView alloc] init];
|
||||
chooseMenuView.menuListArray = self.directoryModel.chapter_list;
|
||||
chooseMenuView.totalChapter = self.directoryModel.total_chapters;
|
||||
chooseMenuView.chooseMenuBlock = ^(WXYZ_MenuType menuType, NSInteger chooseIndex) {
|
||||
/* 滚动指定段的指定row 到 指定位置*/
|
||||
weakSelf.toolSelect = YES;
|
||||
[weakSelf.mainTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:chooseIndex * 30 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];
|
||||
};
|
||||
[chooseMenuView showWithMenuType:WXYZ_MenuTypeAudioSelection];
|
||||
}
|
||||
break;
|
||||
case 1: // 排序
|
||||
{
|
||||
if (sender.selected) {
|
||||
sender.selected = NO;
|
||||
sender.buttonImageName = @"audio_order_sequence";
|
||||
} else {
|
||||
sender.selected = YES;
|
||||
sender.buttonImageName = @"audio_orider_reversed";
|
||||
}
|
||||
self.directoryModel.chapter_list = [[self.directoryModel.chapter_list reverseObjectEnumerator] allObjects];
|
||||
[self.mainTableView reloadData];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)changeChapterList:(NSNotification *)noti
|
||||
{
|
||||
// 需要改变状态的chapter的is_preview状态
|
||||
if ([noti.object isKindOfClass:[NSString class]]) {
|
||||
NSInteger t_chapter_id = [noti.object integerValue];
|
||||
|
||||
for (TFProductionChapterModel *t_chapterModel in self.directoryModel.chapter_list) {
|
||||
if (t_chapter_id == t_chapterModel.chapter_id) {
|
||||
t_chapterModel.is_preview = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)requestChapterDownloadDataWithAudio_id:(NSInteger)audio_id chapter_ids:(NSArray <NSString *>*)chapter_ids indexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
WS(weakSelf)
|
||||
WXYZ_AudioDownloadManager *audioDownloadManager = [WXYZ_AudioDownloadManager sharedManager];
|
||||
[audioDownloadManager downloadChaptersWithProductionModel:self.directoryModel production_id:audio_id chapter_ids:chapter_ids];
|
||||
audioDownloadManager.downloadChapterStateChangeBlock = ^(WXYZ_DownloadChapterState state, NSInteger production_id, NSInteger chapter_id) {
|
||||
|
||||
TFAudioDirectoryViewCell *cell = [self.mainTableView cellForRowAtIndexPath:indexPath];
|
||||
switch (state) {
|
||||
case WXYZ_DownloadStateChapterDownloadStart:
|
||||
cell.cellDownloadState = WXYZ_ProductionDownloadStateDownloading;
|
||||
break;
|
||||
case WXYZ_DownloadStateChapterDownloadFinished:
|
||||
cell.cellDownloadState = WXYZ_ProductionDownloadStateDownloaded;
|
||||
break;
|
||||
case WXYZ_DownloadStateChapterDownloadFail:
|
||||
cell.cellDownloadState = WXYZ_ProductionDownloadStateFail;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
audioDownloadManager.downloadMissionStateChangeBlock = ^(WXYZ_DownloadMissionState state, NSInteger production_id, NSArray * _Nonnull chapter_ids) {
|
||||
switch (state) {
|
||||
case WXYZ_DownloadStateMissionShouldPay:
|
||||
{
|
||||
TFProductionChapterModel *t_chapterList = [weakSelf.directoryModel.chapter_list objectOrNilAtIndex:indexPath.row];
|
||||
t_chapterList.chapter_ids = @[[TFUtilsHelper formatStringWithInteger:t_chapterList.chapter_id]];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
WXYZ_ChapterBottomPayBar *payBar = [[WXYZ_ChapterBottomPayBar alloc] initWithChapterModel:t_chapterList barType:WXYZ_BottomPayBarTypeDownload productionType:TFProductionTypeAudio];
|
||||
payBar.paySuccessChaptersBlock = ^(NSArray<NSString *> * _Nonnull success_chapter_ids) {
|
||||
[weakSelf requestChapterDownloadDataWithAudio_id:audio_id chapter_ids:chapter_ids indexPath:indexPath];
|
||||
};
|
||||
payBar.payFailChaptersBlock = ^(NSArray<NSString *> * _Nonnull fail_chapter_ids) {
|
||||
TFAudioDirectoryViewCell *cell = [self.mainTableView cellForRowAtIndexPath:indexPath];
|
||||
cell.audioDirectoryModel = cell.audioDirectoryModel;
|
||||
cell.cellDownloadState = WXYZ_ProductionDownloadStateNormal;
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"购买失败")];
|
||||
};
|
||||
payBar.payCancleChapterBlock = ^(NSArray<NSString *> * _Nonnull fail_chapter_ids) {
|
||||
TFAudioDirectoryViewCell *cell = [self.mainTableView cellForRowAtIndexPath:indexPath];
|
||||
cell.audioDirectoryModel = cell.audioDirectoryModel;
|
||||
cell.cellDownloadState = WXYZ_ProductionDownloadStateNormal;
|
||||
};
|
||||
[payBar showBottomPayBar];
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFAudioRecommendedViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFAudioRecommendedViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,assign) BOOL canScroll;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
//
|
||||
// TFAudioRecommendedViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAudioRecommendedViewController.h"
|
||||
#import "TFAudioRecommendedViewCell.h"
|
||||
#import "TFAudioRecommendedModel.h"
|
||||
|
||||
@interface TFAudioRecommendedViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFAudioRecommendedViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self hiddenNavigationBar:YES];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.view);
|
||||
}];
|
||||
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"暂无数据") buttonTitle:nil tapBlock:^{
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber = 1;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
|
||||
self.mainTableView.mj_footer = [TFRefreshFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber ++;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
static NSString *cellName = @"TFAudioRecommendedViewCell";
|
||||
TFAudioRecommendedViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFAudioRecommendedViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.productionType = self.productionType;
|
||||
[cell setListModel:[self.dataSourceArray objectOrNilAtIndex:indexPath.row]];
|
||||
cell.hiddenEndLine = (indexPath.row == self.dataSourceArray.count - 1);
|
||||
WS(weakSelf)
|
||||
cell.clickBlock = ^(NSInteger production_id) {
|
||||
TFAudioDetailViewController *vc = [[TFAudioDetailViewController alloc] init];
|
||||
vc.audio_id = production_id;
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
};
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
TFAudioDetailViewController *vc = [[TFAudioDetailViewController alloc] init];
|
||||
vc.audio_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
||||
{
|
||||
if ([scrollView isEqual:self.mainTableView]) {
|
||||
if (!self.canScroll) {
|
||||
scrollView.contentOffset = CGPointZero;
|
||||
}
|
||||
|
||||
if (scrollView.contentOffset.y > 0) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Audio_Can_Leave_Top object:@NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
|
||||
{
|
||||
if (scrollView.contentOffset.y <= 0) {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Audio_Can_Leave_Top object:@YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Audio_Info_Recommend parameters:@{@"page_num":[TFUtilsHelper formatStringWithInteger:self.currentPageNumber]} model:TFAudioRecommendedModel.class success:^(BOOL isSuccess, TFAudioRecommendedModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
|
||||
if (isSuccess) {
|
||||
if (weakSelf.currentPageNumber == 1) {
|
||||
[weakSelf.mainTableView showRefreshFooter];
|
||||
[weakSelf.dataSourceArray removeAllObjects];
|
||||
weakSelf.dataSourceArray = [NSMutableArray arrayWithArray:t_model.list];
|
||||
} else {
|
||||
[weakSelf.dataSourceArray addObjectsFromArray:t_model.list];
|
||||
}
|
||||
if (t_model.total_page <= t_model.current_page) {
|
||||
[weakSelf.mainTableView hideRefreshFooter];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[weakSelf.mainTableView reloadData];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
[weakSelf.mainTableView reloadData];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFAudioDetailModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFAudioDetailModel : NSObject
|
||||
|
||||
@property (nonatomic ,strong) TFProductionModel *audio;
|
||||
@property (nonatomic ,strong) NSArray <NSString *> *color;
|
||||
@property (nonatomic ,assign) NSInteger is_vip;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// TFAudioDetailModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAudioDetailModel.h"
|
||||
|
||||
@implementation TFAudioDetailModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{
|
||||
@"audio" : [TFProductionModel class]
|
||||
};
|
||||
}
|
||||
|
||||
+ (NSDictionary *)modelCustomPropertyMapper
|
||||
{
|
||||
return @{
|
||||
@"color" :@"audio.color",
|
||||
@"is_vip" :@"user.is_vip"
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// TFAudioRecommendedModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TFAudioContentModel, TFPagingModel;
|
||||
|
||||
@interface TFAudioRecommendedModel : TFPagingModel
|
||||
|
||||
@property (nonatomic ,strong) NSArray <TFAudioContentModel *>*list;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface TFAudioContentModel : TFProductionModel
|
||||
|
||||
@property (nonatomic ,assign) BOOL is_vip; // 是否是vip章节
|
||||
@property (nonatomic ,assign) BOOL is_finish; // 是否已完结
|
||||
@property (nonatomic ,assign) NSInteger views; // 观看数
|
||||
@property (nonatomic ,assign) NSInteger total_views;
|
||||
|
||||
@end
|
||||
NS_ASSUME_NONNULL_END
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// TFAudioRecommendedModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAudioRecommendedModel.h"
|
||||
|
||||
@implementation TFAudioRecommendedModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{@"list" : [TFAudioContentModel class]};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation TFAudioContentModel
|
||||
|
||||
@end
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// TFAudioDetailFooterView.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef void(^PushToComicDetailBlock)(NSInteger production_id);
|
||||
|
||||
@interface TFAudioDetailFooterView : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,assign) BOOL canScroll;
|
||||
|
||||
@property (nonatomic ,assign) CGFloat contentOffSetY;
|
||||
|
||||
@property (nonatomic ,assign) NSInteger audio_id;
|
||||
|
||||
@property (nonatomic ,strong) TFProductionModel *directoryModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
//
|
||||
// TFAudioDetailFooterView.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAudioDetailFooterView.h"
|
||||
#import "TFAudioRecommendedViewController.h"
|
||||
#import "TFAudioDirectoryViewController.h"
|
||||
|
||||
@interface TFAudioDetailFooterView ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
|
||||
{
|
||||
TFAudioRecommendedViewController *rightVC;
|
||||
TFAudioDirectoryViewController *leftVC;
|
||||
}
|
||||
|
||||
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
|
||||
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentCollectionView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFAudioDetailFooterView
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self hiddenNavigationBar:YES];
|
||||
[self createSubViews];
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
leftVC = [[TFAudioDirectoryViewController alloc] init];
|
||||
leftVC.directoryModel = self.directoryModel;
|
||||
[self addChildViewController:leftVC];
|
||||
|
||||
rightVC = [[TFAudioRecommendedViewController alloc] init];
|
||||
rightVC.productionType = TFProductionTypeAudio;
|
||||
[self addChildViewController:rightVC];
|
||||
|
||||
NSArray *childArr = @[leftVC, rightVC];
|
||||
NSArray *titleArr = @[TFLocalizedString(@"目录"), TFLocalizedString(@"推荐")];
|
||||
|
||||
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, 44.6, self.view.width, SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - 44) parentVC:self childVCs:childArr];
|
||||
self.pageContentCollectionView.delegatePageContentCollectionView = self;
|
||||
[self.view addSubview:self.pageContentCollectionView];
|
||||
|
||||
self.pageConfigure.bottomSeparatorColor = kGrayLineColor;
|
||||
self.pageConfigure.titleFont = kMainFont;
|
||||
self.pageConfigure.titleSelectedColor = kBlackColor;
|
||||
|
||||
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 44) delegate:self titleNames:titleArr configure:self.pageConfigure];
|
||||
self.pageTitleView.backgroundColor = [UIColor whiteColor];
|
||||
[self.pageTitleView addRoundingCornersWithRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight)];
|
||||
[self.view addSubview:self.pageTitleView];
|
||||
}
|
||||
|
||||
- (void)setDirectoryModel:(TFProductionModel *)directoryModel
|
||||
{
|
||||
_directoryModel = directoryModel;
|
||||
leftVC.directoryModel = directoryModel;
|
||||
}
|
||||
|
||||
- (void)setAudio_id:(NSInteger)audio_id
|
||||
{
|
||||
_audio_id = audio_id;
|
||||
leftVC.audio_id = self.audio_id;
|
||||
}
|
||||
|
||||
- (void)setCanScroll:(BOOL)canScroll
|
||||
{
|
||||
rightVC.canScroll = canScroll;
|
||||
leftVC.canScroll = canScroll;
|
||||
}
|
||||
|
||||
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
|
||||
[self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex {
|
||||
[self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
|
||||
}
|
||||
|
||||
@end
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// TFAudioDetailHeaderView.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFAudioDetailHeaderView : UIView
|
||||
|
||||
@property (nonatomic ,strong) TFProductionModel *audioModel;
|
||||
|
||||
@property (nonatomic ,copy) void (^changeIntroductionBlock)(CGFloat headerViewHeight, BOOL viewEnable);
|
||||
@property (nonatomic ,assign) CGFloat contentOffSetY;
|
||||
|
||||
- (void)reloadCollectionButtonState;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+642
@@ -0,0 +1,642 @@
|
||||
//
|
||||
// TFAudioDetailHeaderView.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAudioDetailHeaderView.h"
|
||||
#import "TFUpgradeMemberController.h"
|
||||
#import "TFCollectionManager.h"
|
||||
#import "TFReadRecordManager.h"
|
||||
#import "TFAdvertisementManager.h"
|
||||
|
||||
#import "UIView+AZGradient.h"
|
||||
#import "UILabel+LineBreak.h"
|
||||
#import "UIView+BorderLine.h"
|
||||
|
||||
@interface TFAudioDetailHeaderView ()
|
||||
{
|
||||
UIView *contentView;
|
||||
|
||||
UILabel *navTitleLabel;
|
||||
|
||||
UIImageView *coverImageView;
|
||||
|
||||
UILabel *audioTitleLabel;
|
||||
UILabel *hotLabel;
|
||||
|
||||
UIImageView *authorIcon;
|
||||
UILabel *authorLabel;
|
||||
UILabel *collectNumLabel;
|
||||
|
||||
TFButton *collectButton;
|
||||
|
||||
UILabel *tagView;
|
||||
|
||||
UIView *introductionView;
|
||||
UILabel *introductionLabel;
|
||||
TFButton *moreButton;
|
||||
|
||||
UIButton *vipButton;
|
||||
|
||||
// 展开详情后视图样式
|
||||
UILabel *introductionBottomLabel;
|
||||
|
||||
TFButton *packUpButton;
|
||||
|
||||
TFButton *bottomPackUpButton;
|
||||
|
||||
TFAdvertisementManager *adView;
|
||||
}
|
||||
@property (nonatomic ,strong) YYTextView *introductionTextView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFAudioDetailHeaderView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
self.frame = frame;
|
||||
[self createSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
contentView = [[UIView alloc] init];
|
||||
contentView.backgroundColor = [UIColor clearColor];
|
||||
[self addSubview:contentView];
|
||||
|
||||
[contentView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.mas_left);
|
||||
make.top.mas_equalTo(self.mas_top);
|
||||
make.width.mas_equalTo(self.mas_width);
|
||||
make.height.mas_equalTo(self.mas_height);
|
||||
}];
|
||||
|
||||
navTitleLabel = [[UILabel alloc] init];
|
||||
navTitleLabel.alpha = 0;
|
||||
navTitleLabel.textColor = kWhiteColor;
|
||||
navTitleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
navTitleLabel.font = kBoldMainFont;
|
||||
[contentView addSubview:navTitleLabel];
|
||||
|
||||
[navTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kHalfMargin + 44);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT - 44);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH / 2 - 44);
|
||||
make.height.mas_equalTo(44);
|
||||
}];
|
||||
|
||||
coverImageView = [[UIImageView alloc] initWithCornerRadiusAdvance:4 rectCornerType:UIRectCornerAllCorners];
|
||||
coverImageView.image = HoldImage;
|
||||
coverImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
[contentView addSubview:coverImageView];
|
||||
|
||||
[coverImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT + kHalfMargin);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH / 4 + kMargin);
|
||||
make.height.mas_equalTo(kGeometricHeight((SCREEN_WIDTH / 4 + kMargin), 3, 4));
|
||||
}];
|
||||
|
||||
audioTitleLabel = [[UILabel alloc] init];
|
||||
audioTitleLabel.textColor = kWhiteColor;
|
||||
audioTitleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
audioTitleLabel.font = kBoldFont22;
|
||||
[contentView addSubview:audioTitleLabel];
|
||||
|
||||
[audioTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(coverImageView.mas_right).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(coverImageView.mas_top);
|
||||
make.right.mas_equalTo(contentView.mas_right).with.offset(- kHalfMargin);
|
||||
make.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
tagView = [[UILabel alloc] init];
|
||||
tagView.backgroundColor = [UIColor clearColor];
|
||||
tagView.textColor = kColorRGBA(255, 255, 255, 0.9);
|
||||
tagView.textAlignment = NSTextAlignmentLeft;
|
||||
tagView.font = kFont12;
|
||||
[contentView addSubview:tagView];
|
||||
|
||||
[tagView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(audioTitleLabel.mas_left);
|
||||
make.top.mas_equalTo(audioTitleLabel.mas_bottom).with.offset(kQuarterMargin);
|
||||
make.right.mas_equalTo(audioTitleLabel.mas_right);
|
||||
make.height.mas_equalTo(25);
|
||||
}];
|
||||
|
||||
hotLabel = [[UILabel alloc] init];
|
||||
hotLabel.backgroundColor = [UIColor clearColor];
|
||||
hotLabel.textColor = kColorRGBA(255, 255, 255, 0.9);
|
||||
hotLabel.textAlignment = NSTextAlignmentLeft;
|
||||
hotLabel.font = kFont12;
|
||||
[contentView addSubview:hotLabel];
|
||||
|
||||
[hotLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(audioTitleLabel.mas_left);
|
||||
make.top.mas_equalTo(tagView.mas_bottom);
|
||||
make.right.mas_equalTo(audioTitleLabel.mas_right);
|
||||
make.height.mas_equalTo(tagView.mas_height);
|
||||
}];
|
||||
|
||||
collectNumLabel = [[UILabel alloc] init];
|
||||
collectNumLabel.backgroundColor = [UIColor clearColor];
|
||||
collectNumLabel.textColor = kColorRGBA(255, 255, 255, 0.9);
|
||||
collectNumLabel.textAlignment = NSTextAlignmentLeft;
|
||||
collectNumLabel.font = kFont12;
|
||||
[contentView addSubview:collectNumLabel];
|
||||
|
||||
[collectNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(audioTitleLabel.mas_left);
|
||||
make.top.mas_equalTo(hotLabel.mas_bottom);
|
||||
make.right.mas_equalTo(audioTitleLabel.mas_right);
|
||||
make.height.mas_equalTo(tagView.mas_height);
|
||||
}];
|
||||
|
||||
collectButton = [[TFButton alloc] initWithFrame:CGRectMake(1, 1, 1, 1) buttonTitle:TFLocalizedString(@"收藏") buttonImageName:@"audio_collection_heart" buttonIndicator:TFButtonIndicatorTitleRight];
|
||||
collectButton.buttonImageScale = 0.4;
|
||||
collectButton.buttonTitleFont = kFont12;
|
||||
collectButton.graphicDistance = 2;
|
||||
collectButton.buttonTitleColor = kWhiteColor;
|
||||
collectButton.hidden = YES;
|
||||
collectButton.layer.cornerRadius = 14;
|
||||
collectButton.clipsToBounds = YES;
|
||||
[collectButton addTarget:self action:@selector(collectionButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[contentView addSubview:collectButton];
|
||||
|
||||
[collectButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(contentView.mas_right).with.offset(-kMargin);
|
||||
make.bottom.mas_equalTo(coverImageView.mas_bottom);
|
||||
make.height.mas_equalTo(28);
|
||||
make.width.mas_equalTo(80);
|
||||
}];
|
||||
|
||||
authorIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"audio_detail_author"]];
|
||||
authorIcon.hidden = YES;
|
||||
[contentView addSubview:authorIcon];
|
||||
|
||||
[authorIcon mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(collectNumLabel.mas_left);
|
||||
make.bottom.mas_equalTo(coverImageView.mas_bottom).with.offset(- 2);
|
||||
make.width.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
authorLabel = [[UILabel alloc] init];
|
||||
authorLabel.backgroundColor = [UIColor clearColor];
|
||||
authorLabel.textColor = kWhiteColor;
|
||||
authorLabel.textAlignment = NSTextAlignmentLeft;
|
||||
authorLabel.font = kMainFont;
|
||||
[contentView addSubview:authorLabel];
|
||||
|
||||
[authorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(authorIcon.mas_right).with.offset(kHalfMargin);
|
||||
make.bottom.mas_equalTo(authorIcon.mas_bottom);
|
||||
make.right.mas_equalTo(collectButton.mas_left).with.offset(- kHalfMargin);
|
||||
make.height.mas_equalTo(authorIcon.mas_height);
|
||||
}];
|
||||
|
||||
introductionView = [[UIView alloc] init];
|
||||
introductionView.backgroundColor = kColorRGBA(0, 0, 0, 0.2);
|
||||
introductionView.layer.cornerRadius = 6;
|
||||
introductionView.hidden = YES;
|
||||
introductionView.userInteractionEnabled = YES;
|
||||
[contentView addSubview:introductionView];
|
||||
|
||||
introductionLabel = [[UILabel alloc] init];
|
||||
introductionLabel.textColor = kColorRGBA(255, 255, 255, 0.9);
|
||||
introductionLabel.font = kFont12;
|
||||
introductionLabel.backgroundColor = [UIColor clearColor];
|
||||
introductionLabel.numberOfLines = 0;
|
||||
introductionLabel.userInteractionEnabled = YES;
|
||||
[contentView addSubview:introductionLabel];
|
||||
|
||||
[introductionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin + kHalfMargin);
|
||||
make.right.mas_equalTo(contentView.mas_right).with.offset(- kMargin - kHalfMargin);
|
||||
make.top.mas_equalTo(coverImageView.mas_bottom).with.offset(kMargin + kHalfMargin);
|
||||
make.height.mas_equalTo(80);
|
||||
}];
|
||||
|
||||
[introductionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(introductionLabel.mas_left).with.offset(- kHalfMargin);
|
||||
make.right.mas_equalTo(introductionLabel.mas_right).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(introductionLabel.mas_top).with.offset(- kQuarterMargin);
|
||||
make.bottom.mas_equalTo(introductionLabel.mas_bottom).with.offset(kQuarterMargin);
|
||||
}];
|
||||
|
||||
moreButton = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:TFLocalizedString(@"展开简介") buttonImageName:@"public_down_arrow" buttonIndicator:TFButtonIndicatorTitleLeft];
|
||||
moreButton.buttonTitleFont = kFont10;
|
||||
moreButton.buttonImageScale = 0.5;
|
||||
moreButton.graphicDistance = 3;
|
||||
moreButton.buttonTintColor = kWhiteColor;
|
||||
moreButton.backgroundColor = kColorRGBA(255, 255, 255, 0.2);
|
||||
moreButton.layer.cornerRadius = 10;
|
||||
[moreButton addTarget:self action:@selector(spreadClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[contentView addSubview:moreButton];
|
||||
|
||||
[moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(introductionLabel.mas_right).with.offset(- kQuarterMargin);
|
||||
make.bottom.mas_equalTo(introductionLabel.mas_bottom).with.offset(- 2.5);
|
||||
make.width.mas_equalTo(80);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
vipButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
vipButton.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
|
||||
vipButton.contentHorizontalAlignment = UIControlContentVerticalAlignmentFill;
|
||||
[vipButton setImage:[UIImage imageNamed:TFLocalizedString(@"audio_detail_member")] forState:UIControlStateNormal];
|
||||
[vipButton addTarget:self action:@selector(vipButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[contentView addSubview:vipButton];
|
||||
|
||||
[vipButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.top.mas_equalTo(introductionView.mas_bottom).with.offset(kMargin);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH - 2 * kMargin);
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
|
||||
adView = [[TFAdvertisementManager alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH - kMargin * 2, kGeometricHeight(SCREEN_WIDTH - kMargin * 2, 3, 1)) advertisementType:TFAdvertisementTypeNovel advertisementPosition:TFAdvertisementPositionNone];
|
||||
adView.backgroundColor = [UIColor clearColor];
|
||||
adView.userInteractionEnabled = YES;
|
||||
[contentView addSubview:adView];
|
||||
|
||||
[adView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH - 2 * kMargin);
|
||||
make.height.mas_equalTo(kGeometricHeight(SCREEN_WIDTH - kMargin, 3, 1));
|
||||
make.top.mas_equalTo(vipButton.mas_bottom).with.offset(kMargin);
|
||||
make.bottom.mas_equalTo(contentView.mas_bottom).with.offset(- kMargin).priorityLow();
|
||||
}];
|
||||
|
||||
// 展开详情后视图
|
||||
introductionBottomLabel = [[UILabel alloc] init];
|
||||
introductionBottomLabel.text = TFLocalizedString(@"简介");
|
||||
introductionBottomLabel.textColor = kWhiteColor;
|
||||
introductionBottomLabel.textAlignment = NSTextAlignmentLeft;
|
||||
introductionBottomLabel.font = kBoldFont22;
|
||||
introductionBottomLabel.alpha = 0;
|
||||
[contentView addSubview:introductionBottomLabel];
|
||||
|
||||
[introductionBottomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.top.mas_equalTo(coverImageView.mas_bottom).with.offset(kMargin);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH / 2);
|
||||
make.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
packUpButton = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:TFLocalizedString(@"收起简介") buttonImageName:@"public_down_arrow" buttonIndicator:TFButtonIndicatorTitleLeft];
|
||||
packUpButton.alpha = 0;
|
||||
packUpButton.transformImageView = YES;
|
||||
packUpButton.buttonTitleFont = kFont10;
|
||||
packUpButton.buttonImageScale = 0.5;
|
||||
packUpButton.graphicDistance = 3;
|
||||
packUpButton.buttonTintColor = kWhiteColor;
|
||||
packUpButton.backgroundColor = kColorRGBA(255, 255, 255, 0.2);
|
||||
packUpButton.layer.cornerRadius = 10;
|
||||
[packUpButton addTarget:self action:@selector(packUpClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[contentView addSubview:packUpButton];
|
||||
|
||||
[packUpButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(contentView.mas_right).with.offset(- kMargin);
|
||||
make.centerY.mas_equalTo(introductionBottomLabel.mas_centerY);
|
||||
make.width.mas_equalTo(80);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
self.introductionTextView = [[YYTextView alloc] init];
|
||||
self.introductionTextView.editable = NO;
|
||||
self.introductionTextView.textColor = kWhiteColor;
|
||||
self.introductionTextView.font = kMainFont;
|
||||
self.introductionTextView.alpha = 0;
|
||||
self.introductionTextView.showsVerticalScrollIndicator = NO;
|
||||
self.introductionTextView.showsHorizontalScrollIndicator = NO;
|
||||
[contentView addSubview:self.introductionTextView];
|
||||
|
||||
[self.introductionTextView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(introductionBottomLabel.mas_left);
|
||||
make.right.mas_equalTo(packUpButton.mas_right);
|
||||
make.top.mas_equalTo(introductionBottomLabel.mas_bottom).with.offset(kHalfMargin);
|
||||
make.bottom.mas_equalTo(contentView.mas_bottom).priorityLow();
|
||||
}];
|
||||
|
||||
bottomPackUpButton = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:TFLocalizedString(@"点击收起") buttonImageName:@"public_down_arrow" buttonIndicator:TFButtonIndicatorTitleLeft];
|
||||
bottomPackUpButton.alpha = 0;
|
||||
bottomPackUpButton.transformImageView = YES;
|
||||
bottomPackUpButton.buttonTitleFont = kMainFont;
|
||||
bottomPackUpButton.buttonImageScale = 0.4;
|
||||
bottomPackUpButton.graphicDistance = 5;
|
||||
bottomPackUpButton.buttonTintColor = kWhiteColor;
|
||||
bottomPackUpButton.backgroundColor = kBlackTransparentColor;
|
||||
bottomPackUpButton.layer.cornerRadius = 20;
|
||||
[bottomPackUpButton addTarget:self action:@selector(packUpClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[contentView addSubview:bottomPackUpButton];
|
||||
|
||||
[bottomPackUpButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(contentView.mas_centerX);
|
||||
make.bottom.mas_equalTo(contentView.mas_bottom).with.offset(- 2 * kMargin);
|
||||
make.width.mas_equalTo(135);
|
||||
make.height.mas_equalTo(40);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (void)setAudioModel:(TFProductionModel *)audioModel
|
||||
{
|
||||
_audioModel = audioModel;
|
||||
|
||||
collectButton.hidden = NO;
|
||||
|
||||
[coverImageView setImageWithURL:[NSURL URLWithString:audioModel.cover] placeholder:HoldImage options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
|
||||
|
||||
navTitleLabel.text = audioModel.name?:@"";
|
||||
audioTitleLabel.text = audioModel.name?:@"";
|
||||
hotLabel.text = audioModel.hot_num?:@"";
|
||||
collectNumLabel.text = audioModel.total_favors?:@"";
|
||||
|
||||
authorIcon.hidden = NO;
|
||||
authorLabel.text = audioModel.author.length > 0 ?audioModel.author:@"--";
|
||||
|
||||
NSMutableArray *tagArray = [NSMutableArray array];
|
||||
for (TFTagModel *tagModel in audioModel.tag) {
|
||||
[tagArray addObject:tagModel.tab];
|
||||
}
|
||||
tagView.text = [tagArray componentsJoinedByString:@"|"]?:@"";
|
||||
|
||||
[self reloadCollectionButtonState];
|
||||
|
||||
[vipButton mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
if ([TFUserInfoManager shareInstance].isVip) {
|
||||
make.top.mas_equalTo(introductionView.mas_bottom).with.offset(CGFLOAT_MIN);
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
} else if (!audioModel.is_baoyue) {
|
||||
make.top.mas_equalTo(introductionView.mas_bottom).with.offset(CGFLOAT_MIN);
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
} else {
|
||||
make.top.mas_equalTo(introductionView.mas_bottom).with.offset(kMargin);
|
||||
make.height.mas_equalTo(kGeometricHeight(SCREEN_WIDTH - 2 * kMargin, 800, 90));
|
||||
}
|
||||
}];
|
||||
|
||||
adView.advertModel = audioModel;
|
||||
[adView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
if (audioModel.ad_type == 0) {
|
||||
make.top.mas_equalTo(vipButton.mas_bottom).with.offset(CGFLOAT_MIN);
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
} else {
|
||||
make.top.mas_equalTo(vipButton.mas_bottom).with.offset(kMargin);
|
||||
make.height.mas_equalTo(kGeometricHeight(SCREEN_WIDTH - kMargin, audioModel.ad_width?:3, audioModel.ad_height?:1));
|
||||
}
|
||||
}];
|
||||
|
||||
[introductionBottomLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
if (audioModel.ad_type == 0) {
|
||||
make.top.mas_equalTo(coverImageView.mas_bottom).with.offset(kMargin);
|
||||
} else {
|
||||
make.top.mas_equalTo(coverImageView.mas_bottom).with.offset(kHalfMargin + kMargin + kGeometricHeight(SCREEN_WIDTH - kMargin, audioModel.ad_width?:3, audioModel.ad_height?:1));
|
||||
}
|
||||
}];
|
||||
|
||||
introductionView.hidden = NO;
|
||||
{
|
||||
if (audioModel.production_descirption.length > 0) {
|
||||
// 截取简介
|
||||
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:audioModel.production_descirption?:@""];
|
||||
attributedString.lineSpacing = 6;
|
||||
attributedString.font = kFont12;
|
||||
attributedString.color = kWhiteColor;
|
||||
|
||||
CGFloat maxWidth = SCREEN_WIDTH - 2 * (kMargin + kHalfMargin) - 120.0;
|
||||
NSAttributedString *separatedString = [TFViewHelper getSubContentWithOriginalContent:attributedString labelWidth:maxWidth labelMaxLine:3];
|
||||
introductionLabel.attributedText = separatedString;
|
||||
[introductionLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(coverImageView.mas_bottom).with.offset(kMargin + kHalfMargin);
|
||||
make.height.mas_equalTo([TFViewHelper boundsWithFont:kFont12 attributedText:separatedString needWidth:(SCREEN_WIDTH - 2 * (kMargin + kHalfMargin)) lineSpacing:6] + kHalfMargin);
|
||||
}];
|
||||
|
||||
[introductionView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(introductionLabel.mas_top).with.offset(- kQuarterMargin);
|
||||
make.bottom.mas_equalTo(introductionLabel.mas_bottom).with.offset(kQuarterMargin);
|
||||
}];
|
||||
|
||||
moreButton.hidden = NO;
|
||||
} else {
|
||||
|
||||
moreButton.hidden = YES;
|
||||
|
||||
[introductionLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(coverImageView.mas_bottom).with.offset(CGFLOAT_MIN);
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
|
||||
[introductionView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(introductionLabel.mas_top).with.offset(CGFLOAT_MIN);
|
||||
make.bottom.mas_equalTo(introductionLabel.mas_bottom).with.offset(CGFLOAT_MIN);
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NSMutableAttributedString __block *attributedString = [[NSMutableAttributedString alloc] initWithString:audioModel.production_descirption?:@""];
|
||||
attributedString.lineSpacing = 8;
|
||||
attributedString.font = kMainFont;
|
||||
attributedString.color = kWhiteColor;
|
||||
[attributedString appendString:@"\n"];
|
||||
|
||||
if (audioModel.horizontal_cover.length > 0) {
|
||||
WS(weakSelf)
|
||||
[[YYWebImageManager sharedManager] requestImageWithURL:[NSURL URLWithString:audioModel.horizontal_cover?:@""] options:YYWebImageOptionSetImageWithFadeAnimation progress:nil transform:nil completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
YYAnimatedImageView *imageView = nil;
|
||||
if (image) {
|
||||
imageView = [[YYAnimatedImageView alloc] initWithImage:image];
|
||||
imageView.frame = CGRectMake(0, 0, SCREEN_WIDTH - 2 * kMargin, kGeometricHeight(SCREEN_WIDTH - 2 * kMargin, image.size.width, image.size.height));
|
||||
}
|
||||
NSMutableAttributedString *attachText = [NSMutableAttributedString attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:imageView.frame.size alignToFont:kMainFont alignment:YYTextVerticalAlignmentCenter];
|
||||
[attributedString appendAttributedString:attachText];
|
||||
|
||||
weakSelf.introductionTextView.attributedText = attributedString;
|
||||
});
|
||||
}];
|
||||
} else {
|
||||
self.introductionTextView.attributedText = attributedString;
|
||||
}
|
||||
|
||||
[self layoutIfNeeded];
|
||||
|
||||
if (self.changeIntroductionBlock) {
|
||||
if ([[TFUserInfoManager shareInstance] isVip] || !audioModel.is_baoyue) {
|
||||
self.changeIntroductionBlock(adView.bottom + kHalfMargin, YES);
|
||||
} else {
|
||||
self.changeIntroductionBlock(adView.bottom + kHalfMargin, YES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setContentOffSetY:(CGFloat)contentOffSetY
|
||||
{
|
||||
_contentOffSetY = contentOffSetY;
|
||||
|
||||
if (contentOffSetY < self.bottom - PUB_NAVBAR_HEIGHT) {
|
||||
navTitleLabel.alpha = 0;
|
||||
[collectButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(contentView.mas_right).with.offset(- kMargin);
|
||||
make.bottom.mas_equalTo(coverImageView.mas_bottom);
|
||||
make.height.mas_equalTo(28);
|
||||
make.width.mas_equalTo(80);
|
||||
}];
|
||||
} else if (contentOffSetY > 0){
|
||||
navTitleLabel.alpha = 1;
|
||||
[collectButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
//#if TF_Download_Mode && (TF_FB_Share_Mode || TF_Twitter_Share_Mode)
|
||||
make.right.mas_equalTo(contentView.mas_right).with.offset(-2 *kHalfMargin - kMargin - 60);
|
||||
//#elif TF_Download_Mode || TF_FB_Share_Mode || TF_Twitter_Share_Mode
|
||||
// make.right.mas_equalTo(contentView.mas_right).with.offset(- kHalfMargin - kMargin - 30);
|
||||
//#else
|
||||
// make.right.mas_equalTo(contentView.mas_right).with.offset(- kMargin);
|
||||
//#endif
|
||||
make.centerY.mas_equalTo(navTitleLabel.mas_centerY);
|
||||
make.height.mas_equalTo(28);
|
||||
make.width.mas_equalTo(80);
|
||||
}];
|
||||
}
|
||||
|
||||
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] isCollectedWithProductionModel:self.audioModel]) {
|
||||
[collectButton mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabelFont:kFont12 labelHeight:28 labelText:collectButton.buttonTitle] + 20);
|
||||
}];
|
||||
|
||||
} else {
|
||||
[collectButton mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabelFont:kFont12 labelHeight:28 labelText:collectButton.buttonTitle] + 30);
|
||||
}];
|
||||
}
|
||||
|
||||
[contentView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.mas_top).with.offset(contentOffSetY);
|
||||
make.height.mas_equalTo(self.mas_height).with.offset(contentOffSetY);
|
||||
}];
|
||||
}
|
||||
|
||||
// 展开详情
|
||||
- (void)spreadClick
|
||||
{
|
||||
[UIView animateWithDuration:kAnimatedDurationFast animations:^{
|
||||
moreButton.alpha = 0;
|
||||
introductionLabel.alpha = 0;
|
||||
introductionView.alpha = 0;
|
||||
vipButton.alpha = 0;
|
||||
|
||||
packUpButton.alpha = 1;
|
||||
bottomPackUpButton.alpha = 1;
|
||||
introductionBottomLabel.alpha = 1;
|
||||
self.introductionTextView.alpha = 1;
|
||||
}];
|
||||
|
||||
[adView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH - 2 * kMargin);
|
||||
if (self.audioModel.ad_type == 0) {
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
} else {
|
||||
make.height.mas_equalTo(kGeometricHeight(SCREEN_WIDTH - kMargin, self.audioModel.ad_width?:3, self.audioModel.ad_height?:1));
|
||||
}
|
||||
make.top.mas_equalTo(coverImageView.mas_bottom).with.offset(kMargin);
|
||||
make.bottom.mas_equalTo(contentView.mas_bottom).with.offset(- kMargin).priorityLow();
|
||||
}];
|
||||
|
||||
if (self.changeIntroductionBlock) {
|
||||
self.changeIntroductionBlock(SCREEN_HEIGHT, NO);
|
||||
}
|
||||
}
|
||||
|
||||
// 收起详情
|
||||
- (void)packUpClick
|
||||
{
|
||||
packUpButton.alpha = 0;
|
||||
bottomPackUpButton.alpha = 0;
|
||||
|
||||
[UIView animateWithDuration:kAnimatedDurationFast animations:^{
|
||||
moreButton.alpha = 1;
|
||||
introductionLabel.alpha = 1;
|
||||
introductionView.alpha = 1;
|
||||
vipButton.alpha = 1;
|
||||
|
||||
introductionBottomLabel.alpha = 0;
|
||||
self.introductionTextView.alpha = 0;
|
||||
|
||||
} completion:^(BOOL finished) {
|
||||
if (self.changeIntroductionBlock) {
|
||||
self.changeIntroductionBlock(adView.bottom + kHalfMargin, YES);
|
||||
}
|
||||
}];
|
||||
|
||||
[adView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH - 2 * kMargin);
|
||||
if (self.audioModel.ad_type == 0) {
|
||||
make.top.mas_equalTo(vipButton.mas_bottom).with.offset(CGFLOAT_MIN);
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
} else {
|
||||
make.top.mas_equalTo(vipButton.mas_bottom).with.offset(kMargin);
|
||||
make.height.mas_equalTo(kGeometricHeight(SCREEN_WIDTH - kMargin, self.audioModel.ad_width?:3, self.audioModel.ad_height?:1));
|
||||
}
|
||||
make.bottom.mas_equalTo(contentView.mas_bottom).with.offset(- kMargin).priorityLow();
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (void)vipButtonClick
|
||||
{
|
||||
WS(weakSelf)
|
||||
TFUpgradeMemberController *vc = [[TFUpgradeMemberController alloc] init];
|
||||
vc.paySuccessBlock = ^{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Audio_Check_Recommend object:[TFUtilsHelper formatStringWithInteger:[[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeAudio] getReadingRecordChapter_idWithProduction_id:weakSelf.audioModel.production_id]]];
|
||||
};
|
||||
[[TFViewHelper getWindowRootController] presentViewController:vc animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)collectionButtonClick:(TFButton *)sender
|
||||
{
|
||||
if (![[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] isCollectedWithProductionModel:self.audioModel]) {
|
||||
[[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] addCollectionWithProductionModel:self.audioModel];
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"已加入书架")];
|
||||
[self reloadCollectionButtonState];
|
||||
}
|
||||
|
||||
[TFUtilsHelper synchronizationRackProductionWithProduction_id:self.audioModel.production_id productionType:TFProductionTypeAudio complete:nil];
|
||||
}
|
||||
|
||||
- (void)reloadCollectionButtonState
|
||||
{
|
||||
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] isCollectedWithProductionModel:self.audioModel]) {
|
||||
collectButton.buttonImageScale = 0;
|
||||
collectButton.buttonTitle = TFLocalizedString(@"已收藏");
|
||||
collectButton.horizontalMigration = - 3;
|
||||
[collectButton selectBackgroundColor];
|
||||
collectButton.tag = 2;
|
||||
|
||||
[collectButton mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabelFont:kFont12 labelHeight:28 labelText:collectButton.buttonTitle] + 20);
|
||||
}];
|
||||
} else {
|
||||
collectButton.buttonImageScale = 0.4;
|
||||
collectButton.buttonTitle = TFLocalizedString(@"收藏");
|
||||
collectButton.horizontalMigration = 0;
|
||||
[collectButton normalBackgroundColor];
|
||||
collectButton.tag = 1;
|
||||
|
||||
[collectButton mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabelFont:kFont12 labelHeight:28 labelText:collectButton.buttonTitle] + 30);
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// TFAudioDirectoryViewCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "WXYZ_DownloadManagerEnumProtocol.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFAudioDirectoryViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,copy) void (^downloadChapterBlock)(NSInteger audio_id, NSInteger chapter_id, NSIndexPath *cellIndexPath);
|
||||
|
||||
@property (nonatomic ,strong) TFProductionChapterModel *audioDirectoryModel;
|
||||
@property (nonatomic ,assign) WXYZ_ProductionDownloadState cellDownloadState;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+229
@@ -0,0 +1,229 @@
|
||||
//
|
||||
// TFAudioDirectoryViewCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAudioDirectoryViewCell.h"
|
||||
#import "TFReadRecordManager.h"
|
||||
#import "WXYZ_AudioDownloadManager.h"
|
||||
|
||||
@interface TFAudioDirectoryViewCell ()
|
||||
|
||||
@property (nonatomic ,strong) UILabel *titleLabel;
|
||||
@property (nonatomic ,strong) UIImageView *playAmountIconView;
|
||||
@property (nonatomic ,strong) UILabel *playAmountLabel;
|
||||
@property (nonatomic ,strong) UIImageView *updateTimeIconView;
|
||||
@property (nonatomic ,strong) UILabel *updateTimeLabel;
|
||||
@property (nonatomic ,strong) UIButton *downloadBtn;
|
||||
@end
|
||||
|
||||
@implementation TFAudioDirectoryViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.titleLabel.textColor = kBlackColor;
|
||||
self.titleLabel.font = kMainFont;
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top);
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(-2 * kHalfMargin - 40);
|
||||
make.height.mas_equalTo(kLabelHeight);
|
||||
}];
|
||||
|
||||
|
||||
self.downloadBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[self.downloadBtn setAdjustsImageWhenHighlighted:NO];
|
||||
[self.downloadBtn setImageEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
|
||||
[self.downloadBtn setImage:[UIImage imageNamed:@"audio_download"] forState:UIControlStateNormal];
|
||||
[self.downloadBtn addTarget:self action:@selector(downloadBtnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.contentView addSubview:self.downloadBtn];
|
||||
|
||||
[self.downloadBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
|
||||
make.centerY.mas_equalTo(self.contentView.mas_centerY);
|
||||
make.height.width.mas_equalTo(40);
|
||||
}];
|
||||
|
||||
|
||||
self.playAmountIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"audio_directory_readtime"]];
|
||||
[self.contentView addSubview:self.playAmountIconView];
|
||||
|
||||
[self.playAmountIconView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.titleLabel.mas_left);
|
||||
make.top.mas_equalTo(self.titleLabel.mas_bottom).with.offset(kHalfMargin);
|
||||
make.height.mas_equalTo(12);
|
||||
make.width.mas_equalTo(CGFLOAT_MIN);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kMargin).priorityLow();
|
||||
}];
|
||||
|
||||
|
||||
self.playAmountLabel = [[UILabel alloc] init];
|
||||
self.playAmountLabel.font = kFont11;
|
||||
self.playAmountLabel.textColor = kGrayTextColor;
|
||||
[self.contentView addSubview:self.playAmountLabel];
|
||||
|
||||
[self.playAmountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.playAmountIconView.mas_right).with.offset(kQuarterMargin);
|
||||
make.centerY.mas_equalTo(self.playAmountIconView.mas_centerY);
|
||||
make.height.mas_equalTo(self.playAmountIconView.mas_height);
|
||||
make.width.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
|
||||
|
||||
self.updateTimeIconView = [[UIImageView alloc] init];
|
||||
self.updateTimeIconView.image = [UIImage imageNamed:@"audio_directory_updatetime"];
|
||||
[self.contentView addSubview:self.updateTimeIconView];
|
||||
|
||||
[self.updateTimeIconView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.playAmountLabel.mas_right).with.offset(kHalfMargin);
|
||||
make.centerY.mas_equalTo(self.playAmountLabel.mas_centerY);
|
||||
make.height.mas_equalTo(self.playAmountIconView.mas_height);
|
||||
make.width.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
|
||||
|
||||
self.updateTimeLabel = [[UILabel alloc] init];
|
||||
self.updateTimeLabel.font = kFont11;
|
||||
self.updateTimeLabel.textColor = kGrayTextColor;
|
||||
[self.contentView addSubview:self.updateTimeLabel];
|
||||
|
||||
[self.updateTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.updateTimeIconView.mas_right).with.offset(kQuarterMargin);
|
||||
make.right.mas_equalTo(self.downloadBtn.mas_left);
|
||||
make.centerY.mas_equalTo(self.updateTimeIconView.mas_centerY);
|
||||
make.height.mas_equalTo(self.updateTimeIconView.mas_height);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setAudioDirectoryModel:(TFProductionChapterModel *)audioDirectoryModel
|
||||
{
|
||||
if (_audioDirectoryModel != audioDirectoryModel) {
|
||||
|
||||
_audioDirectoryModel = audioDirectoryModel;
|
||||
|
||||
self.titleLabel.text = audioDirectoryModel.chapter_title ? : @"";
|
||||
|
||||
if (audioDirectoryModel.play_num > 0) {
|
||||
|
||||
self.playAmountIconView.hidden = NO;
|
||||
[self.playAmountIconView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(12);
|
||||
}];
|
||||
|
||||
self.playAmountLabel.text = audioDirectoryModel.play_num ? : @"";
|
||||
self.playAmountLabel.hidden = NO;
|
||||
[self.playAmountLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.playAmountLabel]);
|
||||
}];
|
||||
} else {
|
||||
|
||||
self.playAmountIconView.hidden = YES;
|
||||
[self.playAmountIconView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.titleLabel.mas_left);
|
||||
make.width.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
|
||||
self.playAmountLabel.hidden = YES;
|
||||
[self.playAmountLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.playAmountIconView.mas_right);
|
||||
make.width.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
}
|
||||
|
||||
if (audioDirectoryModel.update_time.length > 0) {
|
||||
self.updateTimeIconView.hidden = NO;
|
||||
[self.updateTimeIconView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(12);
|
||||
}];
|
||||
self.updateTimeLabel.text = audioDirectoryModel.update_time ? : @"";
|
||||
self.updateTimeLabel.hidden = NO;
|
||||
} else {
|
||||
|
||||
self.updateTimeIconView.hidden = YES;
|
||||
[self.updateTimeIconView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
|
||||
self.updateTimeLabel.hidden = YES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ([[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeAudio] isCurrentPlayingChapterWithProduction_id:audioDirectoryModel.production_id chapter_id:audioDirectoryModel.chapter_id] &&
|
||||
[[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeAudio] isCurrentPlayingProductionWithProduction_id:audioDirectoryModel.production_id]) {
|
||||
|
||||
self.titleLabel.textColor = kMainColor;
|
||||
|
||||
} else if ([[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeAudio] chapterHasReadedWithProduction_id:audioDirectoryModel.production_id chapter_id:audioDirectoryModel.chapter_id]) {
|
||||
|
||||
self.titleLabel.textColor = kGrayTextColor;
|
||||
} else {
|
||||
self.titleLabel.textColor = kBlackColor;
|
||||
}
|
||||
|
||||
[self changeDownloadButtonState];
|
||||
}
|
||||
|
||||
- (void)setCellDownloadState:(WXYZ_ProductionDownloadState)cellDownloadState
|
||||
{
|
||||
if (_cellDownloadState != cellDownloadState) {
|
||||
_cellDownloadState = cellDownloadState;
|
||||
|
||||
[self changeDownloadButtonState];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)changeDownloadButtonState
|
||||
{
|
||||
switch (_cellDownloadState) {
|
||||
case WXYZ_ProductionDownloadStateNormal: {
|
||||
if (self.audioDirectoryModel.is_preview == 1) {
|
||||
[self.downloadBtn setImage:[UIImage imageNamed:TFLocalizedString(@"audio_download_vip")] forState:UIControlStateNormal];
|
||||
} else {
|
||||
[self.downloadBtn setImage:[UIImage imageNamed:@"audio_download"] forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WXYZ_ProductionDownloadStateDownloading: {
|
||||
[self.downloadBtn setImage:[UIImage imageNamed:@"audio_downloading"] forState:UIControlStateNormal];
|
||||
}
|
||||
break;
|
||||
|
||||
case WXYZ_ProductionDownloadStateDownloaded: {
|
||||
[self.downloadBtn setImage:[UIImage imageNamed:@"audio_downloaded"] forState:UIControlStateNormal];
|
||||
}
|
||||
break;
|
||||
|
||||
case WXYZ_ProductionDownloadStateFail: {
|
||||
[self.downloadBtn setImage:[UIImage imageNamed:@"audio_download_fail"] forState:UIControlStateNormal];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)downloadBtnClick:(UIButton *)sender
|
||||
{
|
||||
if (([[WXYZ_AudioDownloadManager sharedManager] getChapterDownloadStateWithProduction_id:self.audioDirectoryModel.production_id chapter_id:self.audioDirectoryModel.chapter_id] == WXYZ_ProductionDownloadStateDownloading) || ([[WXYZ_AudioDownloadManager sharedManager] getChapterDownloadStateWithProduction_id:self.audioDirectoryModel.production_id chapter_id:self.audioDirectoryModel.chapter_id] == WXYZ_ProductionDownloadStateDownloaded)) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.downloadChapterBlock) {
|
||||
self.downloadChapterBlock(self.audioDirectoryModel.production_id, self.audioDirectoryModel.chapter_id, self.index);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// TFAudioRecommendedViewCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFProductionListViewCell.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TFAudioContentModel;
|
||||
|
||||
@interface TFAudioRecommendedViewCell : TFProductionListViewCell
|
||||
|
||||
@property (nonatomic ,copy) void(^clickBlock)(NSInteger production_id);
|
||||
|
||||
- (void)setListModel:(TFAudioContentModel *)listModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
//
|
||||
// TFAudioRecommendedViewCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/25.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAudioRecommendedViewCell.h"
|
||||
#import "TFCollectionManager.h"
|
||||
#import "TFAudioRecommendedModel.h"
|
||||
|
||||
@interface TFAudioRecommendedViewCell ()
|
||||
|
||||
@property (nonatomic ,strong) UILabel *playAmountLabel;
|
||||
@property (nonatomic ,strong) UIButton *collectionBtn;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFAudioRecommendedViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
self.tagboardView.hidden = YES;
|
||||
self.authorLabel.textColor = kMainColor;
|
||||
|
||||
UIImageView *playAmountIconView = [[UIImageView alloc] init];
|
||||
playAmountIconView.image = [UIImage imageNamed:@"audio_directory_readtime"];
|
||||
[self.contentView addSubview:playAmountIconView];
|
||||
|
||||
[playAmountIconView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.authorLabel.mas_right).with.offset(kHalfMargin);
|
||||
make.centerY.mas_equalTo(self.authorLabel.mas_centerY);
|
||||
make.height.mas_equalTo(10);
|
||||
make.width.mas_equalTo(10);
|
||||
}];
|
||||
|
||||
self.playAmountLabel = [[UILabel alloc] init];
|
||||
self.playAmountLabel.font = kFont12;
|
||||
self.playAmountLabel.textColor = kGrayTextColor;
|
||||
[self.contentView addSubview:self.playAmountLabel];
|
||||
|
||||
[self.playAmountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(playAmountIconView.mas_right).with.offset(kQuarterMargin);
|
||||
make.centerY.mas_equalTo(playAmountIconView.mas_centerY);
|
||||
make.height.mas_equalTo(30);
|
||||
make.width.mas_equalTo(CGFLOAT_MIN);
|
||||
}];
|
||||
|
||||
self.collectionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
self.collectionBtn.layer.cornerRadius = 10;
|
||||
self.collectionBtn.layer.borderColor = kMainColor.CGColor;
|
||||
self.collectionBtn.layer.borderWidth = 0.4;
|
||||
[self.collectionBtn addTarget:self action:@selector(collectionBtnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.collectionBtn setTitle:TFLocalizedString(@"收藏") forState:UIControlStateNormal];
|
||||
[self.collectionBtn setTitleColor:kMainColor forState:UIControlStateNormal];
|
||||
[self.collectionBtn.titleLabel setFont:kFont11];
|
||||
[self.contentView addSubview:self.collectionBtn];
|
||||
|
||||
[self.collectionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
|
||||
make.centerY.mas_equalTo(playAmountIconView.mas_centerY);
|
||||
make.width.mas_equalTo(60);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setListModel:(TFAudioContentModel *)listModel
|
||||
{
|
||||
[super setProductionModel:listModel];
|
||||
|
||||
self.authorLabel.text = listModel.finished ? : @"";
|
||||
[self.authorLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.authorLabel]);
|
||||
}];
|
||||
|
||||
self.playAmountLabel.text = [NSString stringWithFormat:@"%zd", listModel.total_views];
|
||||
[self.playAmountLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.playAmountLabel]);
|
||||
}];
|
||||
|
||||
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] isCollectedWithProduction_id:self.productionModel.production_id]) {
|
||||
[self.collectionBtn setTitle:TFLocalizedString(@"已收藏") forState:UIControlStateNormal];
|
||||
} else {
|
||||
[self.collectionBtn setTitle:TFLocalizedString(@"收藏") forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)collectionBtnClick:(UIButton *)sender
|
||||
{
|
||||
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] isCollectedWithProduction_id:self.productionModel.production_id]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] addCollectionWithProductionModel:self.productionModel]) {
|
||||
[self.collectionBtn setTitle:TFLocalizedString(@"已收藏") forState:UIControlStateNormal];
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"已加入书架")];
|
||||
} else {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"加入书架失败")];
|
||||
}
|
||||
|
||||
[TFUtilsHelper synchronizationRackProductionWithProduction_id:self.productionModel.production_id productionType:TFProductionTypeAudio complete:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user