小说绘上架版本
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// TFAudioPlayViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TFProductionChapterModel;
|
||||
@interface TFAudioPlayViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,strong) NSArray <TFProductionChapterModel *> *chapter_list;
|
||||
|
||||
@property (nonatomic ,assign ,readonly) BOOL speaking;
|
||||
|
||||
@property (nonatomic ,assign ,readonly) BOOL stoped; // 暂停不可播放状态
|
||||
|
||||
@property (nonatomic ,assign ,readonly) NSInteger chapter_id;
|
||||
|
||||
interface_singleton
|
||||
|
||||
- (void)loadDataWithAudio_id:(NSInteger)audio_id chapter_id:(NSInteger)chapter_id;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+863
@@ -0,0 +1,863 @@
|
||||
//
|
||||
// TFAudioPlayViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAudioPlayViewController.h"
|
||||
#import "WXYZ_BookAiPlayPageViewController.h"
|
||||
#import "TFCommentsViewController.h"
|
||||
#import "WXYZ_AudioDownloadViewController.h"
|
||||
#import "TFReadNovelViewController.h"
|
||||
|
||||
#import "TFAudioPlayHeaderView.h"
|
||||
#import "TFBookStoreNovelStyleOneCell.h"
|
||||
#import "TFCommentsViewCell.h"
|
||||
#import "TFPublicAdvertisementViewCell.h"
|
||||
|
||||
#import "WXYZ_PlayPageModel.h"
|
||||
#import "TFAudioDetailModel.h"
|
||||
|
||||
#import "CXTextView.h"
|
||||
#import "CXCustomTextView.h"
|
||||
#import "WXYZ_TouchAssistantView.h"
|
||||
|
||||
#import "TFShareManager.h"
|
||||
#import "TFKeyboardManager.h"
|
||||
#import "WXYZ_AudioDownloadManager.h"
|
||||
#import "WXYZ_AudioSettingHelper.h"
|
||||
#import "TFCollectionManager.h"
|
||||
#import "TFReadRecordManager.h"
|
||||
|
||||
#if __has_include(<iflyMSC/IFlyMSC.h>)
|
||||
#import "iflyMSC/IFlyMSC.h"
|
||||
#endif
|
||||
|
||||
@interface TFAudioPlayViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
{
|
||||
CXTextView *commentTextView;
|
||||
|
||||
UIButton *addAudioRack;
|
||||
TFKeyboardManager *keyboardManager;
|
||||
}
|
||||
|
||||
@property (nonatomic ,strong) TFAudioPlayHeaderView *headerView;
|
||||
|
||||
@property (nonatomic ,strong) WXYZ_PlayPageModel *playPageModel;
|
||||
|
||||
@property (nonatomic ,strong) TFProductionChapterModel *audioChapterModel;
|
||||
|
||||
@property (nonatomic ,assign) NSInteger audio_id;
|
||||
|
||||
@property (nonatomic ,assign) NSInteger chapter_id;
|
||||
|
||||
@property (nonatomic ,strong) UIView *bottomMenu;
|
||||
|
||||
@property (nonatomic ,strong) UIView *sectionHeaderView;
|
||||
|
||||
@property (nonatomic ,strong) UILabel *sectionTitleLabel;
|
||||
|
||||
@property (nonatomic ,strong) UIButton *sectionBottomCommentButton;
|
||||
|
||||
@property (nonatomic ,strong) UILabel *commentConnerLabel;
|
||||
|
||||
@property (nonatomic ,assign) BOOL needRefresh;
|
||||
|
||||
@property (nonatomic ,weak) TFButton *collectButton;
|
||||
|
||||
@property (nonatomic ,weak) TFButton *commentButton;
|
||||
|
||||
@property (nonatomic ,weak) TFButton *downloadButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFAudioPlayViewController
|
||||
|
||||
implementation_singleton(TFAudioPlayViewController)
|
||||
|
||||
- (void)loadDataWithAudio_id:(NSInteger)audio_id chapter_id:(NSInteger)chapter_id
|
||||
{
|
||||
if (audio_id > 0) {
|
||||
_audio_id = audio_id;
|
||||
}
|
||||
|
||||
// 查找阅读记录
|
||||
if (chapter_id == 0) {
|
||||
chapter_id = [[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeAudio] getReadingRecordChapter_idWithProduction_id:audio_id];
|
||||
}
|
||||
|
||||
// 查找收藏记录
|
||||
if (chapter_id == 0) {
|
||||
|
||||
TFProductionModel *productionModel = [[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] getCollectedProductionModelWithProduction_id:audio_id];
|
||||
|
||||
if ([productionModel.chapter_list firstObject]) {
|
||||
TFProductionChapterModel *chapterModel = [productionModel.chapter_list firstObject];
|
||||
chapter_id = chapterModel.chapter_id;
|
||||
}
|
||||
}
|
||||
|
||||
// 查找下载记录
|
||||
if (chapter_id == 0) {
|
||||
TFProductionModel *productionModel = [[WXYZ_DownloadHelper sharedManager] getDownloadProductionModelWithProduction_id:audio_id productionType:TFProductionTypeAudio];
|
||||
|
||||
if ([productionModel.chapter_list firstObject]) {
|
||||
TFProductionChapterModel *chapterModel = [productionModel.chapter_list firstObject];
|
||||
chapter_id = chapterModel.chapter_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (chapter_id > 0) {
|
||||
_chapter_id = chapter_id;
|
||||
}
|
||||
self.needRefresh = YES;
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self hiddenNavigationBar:YES];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeAudioChapter:) name:Notification_Change_Audio_Chapter object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeLanguage) name:Notification_Switch_Language object:nil];
|
||||
}
|
||||
|
||||
- (void)changeLanguage {
|
||||
commentTextView.placeholder = TFLocalizedString(@"我来说两句...");
|
||||
self.downloadButton.buttonTitle = TFLocalizedString(@"分享");
|
||||
self.collectButton.buttonTitle = TFLocalizedString(@"听书下载");
|
||||
self.commentButton.buttonTitle = TFLocalizedString(@"听书评论");
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
[self setStatusBarDefaultStyle];
|
||||
|
||||
[[WXYZ_TouchAssistantView sharedManager] hiddenAssistiveTouchView];
|
||||
[[WXYZ_TouchAssistantView sharedManager] setPlayerProductionType:TFProductionTypeAudio];
|
||||
[self.mainTableViewGroup scrollToTop];
|
||||
[[WXYZ_AudioSettingHelper sharedManager] playPageViewShow:YES productionType:TFProductionTypeAudio];
|
||||
|
||||
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] isCollectedWithProduction_id:self.audio_id]) {
|
||||
[addAudioRack setTitleColor:kGrayTextColor forState:UIControlStateNormal];
|
||||
[addAudioRack setTitle:TFLocalizedString(@"已加入书架") forState:UIControlStateNormal];
|
||||
[addAudioRack mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(addAudioRack.intrinsicContentSize.width);
|
||||
}];
|
||||
addAudioRack.tag = 2;
|
||||
} else {
|
||||
[addAudioRack setTitleColor:kBlackColor forState:UIControlStateNormal];
|
||||
[addAudioRack setTitle:TFLocalizedString(@"加入书架") forState:UIControlStateNormal];
|
||||
[addAudioRack mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(addAudioRack.intrinsicContentSize.width);
|
||||
}];
|
||||
addAudioRack.tag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
{
|
||||
if (![WXYZ_BookAiPlayPageViewController sharedManager].speaking) {
|
||||
[[WXYZ_TouchAssistantView sharedManager] showAssistiveTouchViewWithImageCover:self.audioChapterModel.cover productionType:TFProductionTypeAudio];
|
||||
} else {
|
||||
[[WXYZ_TouchAssistantView sharedManager] showAssistiveTouchView];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear:animated];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
backButton.frame = CGRectMake(10, PUB_NAVBAR_OFFSET + 20, 44, 44);
|
||||
backButton.backgroundColor = [UIColor clearColor];
|
||||
backButton.adjustsImageWhenHighlighted = NO;
|
||||
[backButton.titleLabel setFont:kMainFont];
|
||||
[backButton setTitleColor:kBlackColor forState:UIControlStateNormal];
|
||||
[backButton setImage:[[UIImage imageNamed:@"public_down_arrow"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
|
||||
[backButton setImageEdgeInsets:UIEdgeInsetsMake(12, 12, 12, 12)];
|
||||
[backButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
|
||||
[backButton setTintColor:kBlackColor];
|
||||
[backButton addTarget:self action:@selector(popViewController) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.view addSubview:backButton];
|
||||
|
||||
addAudioRack = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] isCollectedWithProduction_id:self.audio_id]) {
|
||||
[addAudioRack setTitleColor:kGrayTextColor forState:UIControlStateNormal];
|
||||
[addAudioRack setTitle:TFLocalizedString(@"已加入书架") forState:UIControlStateNormal];
|
||||
} else {
|
||||
[addAudioRack setTitleColor:kBlackColor forState:UIControlStateNormal];
|
||||
[addAudioRack setTitle:TFLocalizedString(@"加入书架") forState:UIControlStateNormal];
|
||||
}
|
||||
addAudioRack.enabled = YES;
|
||||
addAudioRack.backgroundColor = kWhiteColor;
|
||||
[addAudioRack.titleLabel setFont:kMainFont];
|
||||
[addAudioRack setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
|
||||
[addAudioRack addTarget:self action:@selector(addAudioClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.view addSubview:addAudioRack];
|
||||
|
||||
[addAudioRack mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.view.mas_right).with.offset(- kMargin);
|
||||
make.centerY.mas_equalTo(backButton.mas_centerY);
|
||||
make.width.mas_equalTo(addAudioRack.intrinsicContentSize.width);
|
||||
make.height.mas_equalTo(44);
|
||||
}];
|
||||
|
||||
self.mainTableViewGroup.delegate = self;
|
||||
self.mainTableViewGroup.dataSource = self;
|
||||
[self.view addSubview:self.mainTableViewGroup];
|
||||
|
||||
[self.mainTableViewGroup mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
make.height.mas_equalTo(self.view.mas_height).with.offset(- PUB_TABBAR_HEIGHT - PUB_NAVBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
[self.mainTableViewGroup setTableHeaderView:self.headerView];
|
||||
self.headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH);
|
||||
[self.headerView setNeedsLayout];
|
||||
[self.headerView layoutIfNeeded];
|
||||
self.mainTableViewGroup.tableHeaderView = self.headerView;
|
||||
|
||||
self.bottomMenu = [[UIView alloc] init];
|
||||
self.bottomMenu.backgroundColor = [UIColor whiteColor];
|
||||
self.bottomMenu.layer.shadowColor = kBlackColor.CGColor;
|
||||
self.bottomMenu.layer.shadowOpacity = 0.1;
|
||||
self.bottomMenu.layer.shadowRadius = 1;
|
||||
self.bottomMenu.layer.shadowOffset = CGSizeMake(0, - 1);
|
||||
[self.view addSubview:self.bottomMenu];
|
||||
|
||||
[self.bottomMenu mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.view.mas_left);
|
||||
make.bottom.mas_equalTo(self.view.mas_bottom).with.offset(- PUB_TABBAR_OFFSET);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET);
|
||||
}];
|
||||
|
||||
TFButton *downloadButton = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:TFLocalizedString(@"分享") buttonImageName:@"public_share" buttonIndicator:TFButtonIndicatorTitleBottom];
|
||||
self.downloadButton = downloadButton;
|
||||
downloadButton.tag = 0;
|
||||
downloadButton.buttonTitleFont = kFont12;
|
||||
downloadButton.graphicDistance = 5;
|
||||
downloadButton.buttonImageScale = 0.45;
|
||||
downloadButton.buttonTitleColor = kGrayTextLightColor;
|
||||
[downloadButton addTarget:self action:@selector(toolBarButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.bottomMenu addSubview:downloadButton];
|
||||
|
||||
[downloadButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.bottomMenu.mas_right).with.offset(- kHalfMargin);
|
||||
make.top.mas_equalTo(self.bottomMenu.mas_top).with.offset(5);
|
||||
make.width.height.mas_equalTo(40);
|
||||
}];
|
||||
|
||||
TFButton *collectButton = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:TFLocalizedString(@"听书下载") buttonImageName:@"public_download" buttonIndicator:TFButtonIndicatorTitleBottom];
|
||||
self.collectButton = collectButton;
|
||||
collectButton.tag = 1;
|
||||
collectButton.buttonTitleFont = kFont12;
|
||||
collectButton.graphicDistance = 5;
|
||||
collectButton.buttonImageScale = 0.45;
|
||||
collectButton.buttonTitleColor = kGrayTextLightColor;
|
||||
[collectButton addTarget:self action:@selector(toolBarButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.bottomMenu addSubview:collectButton];
|
||||
|
||||
[collectButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(downloadButton.mas_left).with.offset(- kHalfMargin);
|
||||
make.centerY.mas_equalTo(downloadButton.mas_centerY);
|
||||
make.width.height.mas_equalTo(downloadButton);
|
||||
}];
|
||||
|
||||
TFButton *commentButton = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:TFLocalizedString(@"听书评论") buttonImageName:@"audio_comment" buttonIndicator:TFButtonIndicatorTitleBottom];
|
||||
self.commentButton = commentButton;
|
||||
commentButton.tag = 2;
|
||||
commentButton.buttonTitleFont = kFont12;
|
||||
commentButton.graphicDistance = 5;
|
||||
commentButton.buttonImageScale = 0.45;
|
||||
commentButton.buttonTitleColor = kGrayTextLightColor;
|
||||
[commentButton addTarget:self action:@selector(toolBarButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.bottomMenu addSubview:commentButton];
|
||||
|
||||
[commentButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(collectButton.mas_left).with.offset(- kHalfMargin);
|
||||
make.centerY.mas_equalTo(downloadButton.mas_centerY);
|
||||
make.width.height.mas_equalTo(downloadButton);
|
||||
}];
|
||||
|
||||
self.commentConnerLabel = [[UILabel alloc] init];
|
||||
self.commentConnerLabel.text = @"0";
|
||||
self.commentConnerLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.commentConnerLabel.textColor = kMainColor;
|
||||
self.commentConnerLabel.backgroundColor = [UIColor whiteColor];
|
||||
self.commentConnerLabel.font = [UIFont systemFontOfSize:6];
|
||||
[commentButton addSubview:self.commentConnerLabel];
|
||||
|
||||
[self.commentConnerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(commentButton.mas_centerX).with.offset(1);
|
||||
make.right.mas_equalTo(commentButton.mas_right).with.offset(- 5);
|
||||
make.top.mas_equalTo(commentButton.mas_top).with.offset(- 1);
|
||||
make.height.mas_equalTo(6);
|
||||
}];
|
||||
|
||||
UIView *commentBottomView = [[UIView alloc] init];
|
||||
commentBottomView.backgroundColor = kGrayViewColor;
|
||||
commentBottomView.layer.cornerRadius = 20;
|
||||
[self.bottomMenu addSubview:commentBottomView];
|
||||
|
||||
[commentBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.bottomMenu.mas_left).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(self.bottomMenu.mas_top).with.offset(5);
|
||||
make.right.mas_equalTo(commentButton.mas_left).with.offset(- kHalfMargin);
|
||||
make.height.mas_equalTo(40);
|
||||
}];
|
||||
|
||||
UIImageView *leftView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"audio_pencil"]];
|
||||
[commentBottomView addSubview:leftView];
|
||||
|
||||
[leftView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMoreHalfMargin);
|
||||
make.top.mas_equalTo(commentBottomView.mas_top).with.offset(10);
|
||||
make.height.width.mas_equalTo(16);
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
commentTextView = [[CXTextView alloc] initWithFrame:CGRectMake(kMoreHalfMargin + 16 + kHalfMargin, 0, SCREEN_WIDTH - (kMoreHalfMargin + 16 + kHalfMargin + kHalfMargin + 3 * 40 + 5 * kHalfMargin), 40)];
|
||||
commentTextView.placeholder = TFLocalizedString(@"我来说两句...");
|
||||
commentTextView.maxLine = 5;
|
||||
commentTextView.maxLength = 200;
|
||||
commentTextView.v_margin = 10;
|
||||
commentTextView.font = kMainFont;
|
||||
commentTextView.backgroundColor = [UIColor clearColor];
|
||||
commentTextView.layer.cornerRadius = 15;
|
||||
commentTextView.textView.backgroundColor = [UIColor clearColor];
|
||||
commentTextView.textHeightChangeBlock = ^(CGFloat height) {
|
||||
[commentBottomView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(height);
|
||||
}];
|
||||
|
||||
[weakSelf.bottomMenu mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(10 + height);
|
||||
}];
|
||||
|
||||
[weakSelf.mainTableViewGroup mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(weakSelf.view.mas_height).with.offset(- PUB_TABBAR_OFFSET - PUB_NAVBAR_HEIGHT - height - 10);
|
||||
}];
|
||||
};
|
||||
commentTextView.returnHandlerBlock = ^{
|
||||
[weakSelf sendCommentNetRequest];
|
||||
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];
|
||||
};
|
||||
[commentBottomView addSubview:commentTextView];
|
||||
|
||||
keyboardManager = [[TFKeyboardManager alloc] initObserverWithAdaptiveMovementView:commentBottomView];
|
||||
keyboardManager.keyboardHeightChanged = ^(CGFloat keyboardHeight, CGFloat shouldMoveDistance, CGRect shouldMoveFrame) {
|
||||
[weakSelf.bottomMenu mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(weakSelf.view.mas_bottom).with.offset(keyboardHeight == 0 ? - PUB_TABBAR_OFFSET:- keyboardHeight);
|
||||
}];
|
||||
};
|
||||
}
|
||||
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
||||
{
|
||||
[TFKeyboardManager hideKeyboard];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - UITableViewDelegate
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
switch (section) {
|
||||
case 0:
|
||||
if (self.playPageModel.advert.ad_type != 0) {
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (self.playPageModel.list.count > 0) {
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (self.playPageModel.comment.list.count > 3) {
|
||||
return 3;
|
||||
} else {
|
||||
return self.playPageModel.comment.list.count;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
switch (indexPath.section) {
|
||||
case 0:
|
||||
return [self createAdCellWithTableView:tableView indexPath:indexPath];
|
||||
break;
|
||||
case 1:
|
||||
return [self createSingleStyleCellWithTableView:tableView indexPath:indexPath listArray:self.playPageModel.list];
|
||||
break;
|
||||
case 2:
|
||||
return [self createCommentCellWithTableView:tableView indexPath:indexPath labelModel:[self.playPageModel.comment.list objectOrNilAtIndex:indexPath.row]];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return [[UITableViewCell alloc] init];
|
||||
}
|
||||
|
||||
- (UITableViewCell *)createSingleStyleCellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath listArray:(NSArray *)listArray
|
||||
{
|
||||
WS(weakSelf)
|
||||
static NSString *cellName = @"TFBookStoreNovelStyleOneCell";
|
||||
|
||||
TFBookStoreLabelModel *labelModel = [[TFBookStoreLabelModel alloc] init];
|
||||
labelModel.list = listArray;
|
||||
labelModel.label = TFLocalizedString(@"猜你喜欢");
|
||||
for (TFProductionModel *t_model in labelModel.list) {
|
||||
t_model.productionType = TFProductionTypeAudio;
|
||||
}
|
||||
|
||||
TFBookStoreNovelStyleOneCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFBookStoreNovelStyleOneCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.labelModel = labelModel;
|
||||
cell.cellDidSelectItemBlock = ^(NSInteger production_id) {
|
||||
TFAudioDetailViewController *vc = [[TFAudioDetailViewController alloc] init];
|
||||
vc.audio_id = production_id;
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
};
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)createCommentCellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath labelModel:(TFCommentsListModel *)commentModel
|
||||
{
|
||||
static NSString *cellName = @"TFCommentsViewCell";
|
||||
TFCommentsViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFCommentsViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.commentModel = commentModel;
|
||||
[cell setIsPreview:YES lastRow:(self.playPageModel.comment.list.count - 1 == indexPath.row)];
|
||||
cell.hiddenEndLine = NO;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)createAdCellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
static NSString *cellName = @"TFPublicAdvertisementViewCell";
|
||||
TFPublicAdvertisementViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFPublicAdvertisementViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
[cell setAdModel:self.playPageModel.advert refresh:self.needRefresh];
|
||||
cell.mainTableView = tableView;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (indexPath.section == 2) {
|
||||
TFCommentsListModel *t_model = [self.playPageModel.comment.list objectOrNilAtIndex:indexPath.row];
|
||||
[self commentWithComment_id:t_model.comment_id];
|
||||
}
|
||||
}
|
||||
|
||||
//section头部间距
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
#if TF_Comments_Mode
|
||||
if (!self.playPageModel) {
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
if (section == 2) {// 评论头部高度
|
||||
return 54;
|
||||
}
|
||||
#endif
|
||||
|
||||
return kQuarterMargin;
|
||||
}
|
||||
|
||||
//section头部视图
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
if (section == 2) {
|
||||
UIView *sectionView = self.sectionHeaderView;
|
||||
self.sectionTitleLabel.text = [NSString stringWithFormat:@"%@(%@)", TFLocalizedString(@"本章评论"), [TFUtilsHelper formatStringWithInteger:self.playPageModel.comment_total_count]];
|
||||
return sectionView;
|
||||
}
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kHalfMargin)];
|
||||
view.backgroundColor = kGrayViewColor;
|
||||
return view;
|
||||
}
|
||||
|
||||
- (UIView *)sectionHeaderView
|
||||
{
|
||||
if (!_sectionHeaderView) {
|
||||
_sectionHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 54)];
|
||||
_sectionHeaderView.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
UIView *grayLine = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
|
||||
grayLine.backgroundColor = kGrayViewColor;
|
||||
[_sectionHeaderView addSubview:grayLine];
|
||||
|
||||
UIImageView *mainTitleHoldView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"book_label_hold"]];
|
||||
[_sectionHeaderView addSubview:mainTitleHoldView];
|
||||
|
||||
[mainTitleHoldView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kHalfMargin);
|
||||
make.centerY.mas_equalTo(_sectionHeaderView.mas_centerY).with.offset(5);
|
||||
make.width.height.mas_equalTo(kHalfMargin + kQuarterMargin);
|
||||
}];
|
||||
|
||||
[_sectionHeaderView addSubview:self.sectionTitleLabel];
|
||||
|
||||
}
|
||||
return _sectionHeaderView;
|
||||
}
|
||||
|
||||
- (UILabel *)sectionTitleLabel
|
||||
{
|
||||
if (!_sectionTitleLabel) {
|
||||
_sectionTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(kMargin + kHalfMargin, 10, SCREEN_WIDTH - kMargin, 44)];
|
||||
_sectionTitleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
_sectionTitleLabel.textColor = kBlackColor;
|
||||
_sectionTitleLabel.backgroundColor = [UIColor whiteColor];
|
||||
_sectionTitleLabel.font = kBoldFont16;
|
||||
}
|
||||
return _sectionTitleLabel;
|
||||
}
|
||||
|
||||
//section底部间距
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
#if TF_Comments_Mode
|
||||
if (!self.playPageModel) {
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
if (section == 2) {
|
||||
return 56;
|
||||
}
|
||||
#endif
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
//section底部视图
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 50)];
|
||||
view.backgroundColor = kWhiteColor;
|
||||
|
||||
if (section == 2) {
|
||||
if (self.playPageModel) {
|
||||
|
||||
if (self.playPageModel.comment.list.count == 0) {
|
||||
[self.sectionBottomCommentButton setTitle:TFLocalizedString(@"暂无评论,点击抢沙发") forState:UIControlStateNormal];
|
||||
} else {
|
||||
[self.sectionBottomCommentButton setTitle:[NSString stringWithFormat:@"%@(%@%@)", TFLocalizedString(@"查看全部评论"), [TFUtilsHelper formatStringWithInteger:self.playPageModel.comment_total_count], TFLocalizedString(@"条")] forState:UIControlStateNormal];
|
||||
}
|
||||
[view addSubview:self.sectionBottomCommentButton];
|
||||
}
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
- (UIButton *)sectionBottomCommentButton
|
||||
{
|
||||
if (!_sectionBottomCommentButton) {
|
||||
|
||||
_sectionBottomCommentButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
_sectionBottomCommentButton.frame = CGRectMake(SCREEN_WIDTH / 4, kHalfMargin, SCREEN_WIDTH / 2 + kMargin, 36);
|
||||
_sectionBottomCommentButton.backgroundColor = [UIColor whiteColor];
|
||||
_sectionBottomCommentButton.layer.cornerRadius = 18;
|
||||
_sectionBottomCommentButton.layer.borderColor = kMainColor.CGColor;
|
||||
_sectionBottomCommentButton.layer.borderWidth = 0.4f;
|
||||
[_sectionBottomCommentButton setTitleColor:kMainColor forState:UIControlStateNormal];
|
||||
[_sectionBottomCommentButton.titleLabel setFont:kFont12];
|
||||
[_sectionBottomCommentButton addTarget:self action:@selector(commentClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _sectionBottomCommentButton;
|
||||
}
|
||||
|
||||
- (TFAudioPlayHeaderView *)headerView
|
||||
{
|
||||
if (!_headerView) {
|
||||
WS(weakSelf)
|
||||
_headerView = [[TFAudioPlayHeaderView alloc] initWithProductionType:TFProductionTypeAudio];
|
||||
_headerView.checkRelationProductionBlock = ^(WXYZ_RelationModel * _Nonnull relationModel) {
|
||||
[TFNetworkTools POST:Book_Catalog parameters:@{@"book_id":[TFUtilsHelper formatStringWithInteger:relationModel.production_id]} model:TFProductionModel.class success:^(BOOL isSuccess, TFProductionModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
if (isSuccess) {
|
||||
WXYZ_BookAiPlayPageViewController *vc = [WXYZ_BookAiPlayPageViewController sharedManager];
|
||||
[vc loadDataWithBookModel:t_model chapterModel:nil];
|
||||
if (!vc.presentedViewController) {
|
||||
TFNavigationController *nav = [[TFNavigationController alloc] initWithRootViewController:vc];
|
||||
[[TFViewHelper getWindowRootController] presentViewController:nav animated:YES completion:nil];
|
||||
} else {
|
||||
[weakSelf popViewController];
|
||||
}
|
||||
}
|
||||
} failure:nil];
|
||||
};
|
||||
_headerView.checkOriginalBlock = ^(TFProductionChapterModel * _Nonnull chapterModel) {
|
||||
if (weakSelf.navigationController.view.tag == 2345) {
|
||||
[weakSelf popViewController];
|
||||
return;
|
||||
}
|
||||
|
||||
[TFNetworkTools POST:Book_Catalog parameters:@{@"book_id":[TFUtilsHelper formatStringWithInteger:chapterModel.relation_production_id]} model:TFProductionModel.class success:^(BOOL isSuccess, TFProductionModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
if (isSuccess) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
TFReadNovelViewController *vc = [[TFReadNovelViewController alloc] init];
|
||||
vc.book_id = t_model.production_id;
|
||||
vc.bookModel = t_model;
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
});
|
||||
}
|
||||
} failure:nil];
|
||||
};
|
||||
}
|
||||
return _headerView;
|
||||
}
|
||||
|
||||
- (BOOL)speaking
|
||||
{
|
||||
if (self.headerView.playerState == TFBasicVoicePlayerStatePlaying) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)stoped
|
||||
{
|
||||
if (self.headerView.playerState == TFBasicVoicePlayerStateStoped) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)commentClick
|
||||
{
|
||||
[self commentWithComment_id:0];
|
||||
}
|
||||
|
||||
- (void)commentWithComment_id:(NSInteger)comment_id
|
||||
{
|
||||
WS(weakSelf)
|
||||
TFCommentsViewController *vc = [[TFCommentsViewController alloc] init];
|
||||
vc.production_id = self.audio_id;
|
||||
vc.chapter_id = self.chapter_id;
|
||||
vc.comment_id = comment_id;
|
||||
vc.productionType = TFProductionTypeAudio;
|
||||
vc.commentsSuccessBlock = ^(TFCommentsListModel *commentModel) {
|
||||
|
||||
WXYZ_PlayPageModel *t_model = weakSelf.playPageModel;
|
||||
|
||||
// 评论数组model添加
|
||||
NSMutableArray *t_array = [NSMutableArray arrayWithArray:weakSelf.playPageModel.comment.list];
|
||||
[t_array insertObject:commentModel atIndex:0];
|
||||
weakSelf.playPageModel.comment.list = [t_array copy];
|
||||
|
||||
weakSelf.playPageModel = t_model;
|
||||
|
||||
weakSelf.playPageModel.comment_total_count ++;
|
||||
|
||||
[weakSelf.mainTableViewGroup reloadData];
|
||||
|
||||
weakSelf.commentConnerLabel.text = [NSString stringWithFormat:@"%@", weakSelf.playPageModel.comment_total_count > 99?@"99+":[TFUtilsHelper formatStringWithInteger:weakSelf.playPageModel.comment_total_count]];
|
||||
|
||||
};
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
- (void)toolBarButtonClick:(TFButton *)sender
|
||||
{
|
||||
if (sender.tag == 0) {
|
||||
[TFShareManager shareWithProduction_id:NSStringFromInteger(self.audioChapterModel.production_id) chapter_id:NSStringFromInteger(self.audioChapterModel.chapter_id) type:TFShareTypeAudio];
|
||||
}
|
||||
|
||||
if (sender.tag == 1) {
|
||||
|
||||
WXYZ_AudioDownloadViewController *vc = [[WXYZ_AudioDownloadViewController alloc] init];
|
||||
vc.production_id = self.audioChapterModel.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
if (sender.tag == 2) {
|
||||
[self commentWithComment_id:0];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addAudioClick:(UIButton *)sender
|
||||
{
|
||||
if (![[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] isCollectedWithProduction_id:self.audio_id]) {
|
||||
[TFUtilsHelper synchronizationRackProductionWithProduction_id:self.audio_id productionType:TFProductionTypeAudio complete:nil];
|
||||
|
||||
[TFNetworkTools POST:Audio_Info parameters:@{@"audio_id":[TFUtilsHelper formatStringWithInteger:self.audio_id]} model:TFAudioDetailModel.class success:^(BOOL isSuccess, TFAudioDetailModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
if (isSuccess) {
|
||||
[sender setTitleColor:kGrayTextColor forState:UIControlStateNormal];
|
||||
[sender setTitle:TFLocalizedString(@"已加入书架") forState:UIControlStateNormal];
|
||||
|
||||
[[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] addCollectionWithProductionModel:t_model.audio];
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"已加入书架")];
|
||||
}
|
||||
} failure:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)changeAudioChapter:(NSNotification *)noti
|
||||
{
|
||||
self.chapter_id = [[noti object] integerValue];
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
if ([TFNetworkManager networkingStatus] == NO) {
|
||||
|
||||
TFProductionModel *productionModel = [[WXYZ_DownloadHelper sharedManager] getDownloadProductionModelWithProduction_id:self.audio_id productionType:TFProductionTypeAudio];
|
||||
TFProductionChapterModel *chapterModel = [[WXYZ_AudioDownloadManager sharedManager] getDownloadChapterModelWithProduction_id:self.audio_id chapter_id:self.chapter_id];
|
||||
if (!chapterModel) {
|
||||
for (TFProductionChapterModel *t_chapterModel in productionModel.chapter_list) {
|
||||
if (self.chapter_id == t_chapterModel.chapter_id) {
|
||||
chapterModel = t_chapterModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
chapterModel.cover = productionModel.cover;
|
||||
self.audioChapterModel = chapterModel;
|
||||
self.headerView.chapter_list = productionModel.chapter_list;
|
||||
self.headerView.productionChapterModel = self.audioChapterModel;
|
||||
self.headerView.relationModel = [[WXYZ_RelationModel alloc] init];
|
||||
[self.mainTableViewGroup setTableHeaderView:self.headerView];
|
||||
[[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeAudio] addReadingRecordWithProduction_id:chapterModel.production_id chapter_id:chapterModel.chapter_id chapterTitle:chapterModel.chapter_title];
|
||||
return;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Audio_Chapter_Info parameters:@{@"audio_id":[TFUtilsHelper formatStringWithInteger:self.audio_id], @"chapter_id":[TFUtilsHelper formatStringWithInteger:self.chapter_id]} model:TFProductionChapterModel.class success:^(BOOL isSuccess, TFProductionChapterModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
if (isSuccess) {
|
||||
weakSelf.chapter_id = t_model.chapter_id;
|
||||
weakSelf.audioChapterModel = t_model;
|
||||
weakSelf.headerView.productionChapterModel = weakSelf.audioChapterModel;
|
||||
[weakSelf.mainTableViewGroup setTableHeaderView:weakSelf.headerView];
|
||||
[[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeAudio] addReadingRecordWithProduction_id:t_model.production_id chapter_id:t_model.chapter_id chapterTitle:t_model.chapter_title];
|
||||
|
||||
if (t_model.is_preview == 0) {
|
||||
// 如果是自动订阅后,将通知刷新目录内容
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:NSNotification_Auto_Buy_Audio_Chapter object:[TFUtilsHelper formatStringWithInteger:t_model.chapter_id]];
|
||||
}
|
||||
} else {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:requestModel.msg];
|
||||
}
|
||||
} failure:nil];
|
||||
|
||||
[TFNetworkTools POST:Audio_Chapter_Detail parameters:@{@"audio_id":[TFUtilsHelper formatStringWithInteger:self.audio_id], @"chapter_id":[TFUtilsHelper formatStringWithInteger:self.chapter_id]} model:WXYZ_PlayPageModel.class success:^(BOOL isSuccess, WXYZ_PlayPageModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
if (isSuccess) {
|
||||
weakSelf.playPageModel = t_model;
|
||||
weakSelf.commentConnerLabel.text = [NSString stringWithFormat:@"%@", weakSelf.playPageModel.comment_total_count > 99?@"99+":[TFUtilsHelper formatStringWithInteger:weakSelf.playPageModel.comment_total_count]];
|
||||
weakSelf.headerView.relationModel = weakSelf.playPageModel.relation;
|
||||
}
|
||||
weakSelf.needRefresh = YES;
|
||||
[weakSelf.mainTableViewGroup reloadData];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
weakSelf.needRefresh = NO;
|
||||
});
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
weakSelf.needRefresh = NO;
|
||||
[weakSelf.mainTableViewGroup reloadData];
|
||||
}];
|
||||
|
||||
[TFNetworkTools POST:Audio_Add_Read_Log parameters:@{@"audio_id":[TFUtilsHelper formatStringWithInteger:self.audio_id], @"chapter_id":[TFUtilsHelper formatStringWithInteger:self.chapter_id]} model:nil success:nil failure:nil];
|
||||
|
||||
if (!self.chapter_list || self.chapter_list.count == 0) {
|
||||
[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) {
|
||||
// 更新本地记录
|
||||
[[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] modificationCollectionWithProductionModel:t_model];
|
||||
|
||||
weakSelf.chapter_list = t_model.chapter_list;
|
||||
weakSelf.headerView.chapter_list = t_model.chapter_list;
|
||||
}
|
||||
} failure:nil];
|
||||
} else {
|
||||
self.headerView.chapter_list = [self.chapter_list copy];
|
||||
self.chapter_list = [NSArray array];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)sendCommentNetRequest
|
||||
{
|
||||
if (!TFUserInfoManager.isLogin) {
|
||||
TFAlertView *alert = [[TFAlertView alloc] init];
|
||||
alert.alertDetailContent = TFLocalizedString(@"登录后才可以进行评论");
|
||||
alert.confirmTitle = TFLocalizedString(@"去登录");
|
||||
alert.cancelTitle = TFLocalizedString(@"暂不");
|
||||
alert.confirmButtonClickBlock = ^{
|
||||
[TFLoginOptionsViewController presentLoginView:nil];
|
||||
};
|
||||
[alert showAlertView];
|
||||
return;
|
||||
}
|
||||
|
||||
if ([commentTextView.text isEqualToString:@""]) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *t_text = commentTextView.text;
|
||||
commentTextView.text = @"";
|
||||
|
||||
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:@{@"audio_id":[TFUtilsHelper formatStringWithInteger:self.audioChapterModel.production_id]?:@"", @"chapter_id":[TFUtilsHelper formatStringWithInteger:self.audioChapterModel.chapter_id], @"content":t_text}];
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Audio_Comment_Post parameters:parameters model:TFCommentsListModel.class success:^(BOOL isSuccess, TFCommentsListModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
if (isSuccess) {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"评论成功")];
|
||||
|
||||
// 评论数组model添加
|
||||
NSMutableArray<TFCommentsListModel *> *t_arr = [NSMutableArray arrayWithArray:weakSelf.playPageModel.comment.list];
|
||||
[t_arr insertObject:t_model atIndex:0];
|
||||
weakSelf.playPageModel.comment.list = [t_arr copy];
|
||||
weakSelf.playPageModel.comment_total_count++;
|
||||
|
||||
[weakSelf.mainTableViewGroup reloadSection:2 withRowAnimation:UITableViewRowAnimationNone];
|
||||
|
||||
weakSelf.commentConnerLabel.text = [NSString stringWithFormat:@"%@", weakSelf.playPageModel.comment_total_count > 99?@"99+":[TFUtilsHelper formatStringWithInteger:weakSelf.playPageModel.comment_total_count]];
|
||||
|
||||
} else if (Compare_Json_isEqualTo(requestModel.code, 315)) {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:requestModel.msg];
|
||||
} else {
|
||||
commentTextView.text = t_text;
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:requestModel.msg];
|
||||
}
|
||||
} failure:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFAudioPlayHeaderView.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicVoiceHeaderView.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFAudioPlayHeaderView : TFBasicVoiceHeaderView
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,248 @@
|
||||
//
|
||||
// TFAudioPlayHeaderView.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAudioPlayHeaderView.h"
|
||||
#import "WXYZ_BookAiPlayPageViewController.h"
|
||||
#import "WXYZ_AudioSettingHelper.h"
|
||||
#import "TFReadRecordManager.h"
|
||||
#import "WXYZ_AudioDownloadManager.h"
|
||||
|
||||
#import "WXYZ_ChapterBottomPayBar.h"
|
||||
#import "WXYZ_TouchAssistantView.h"
|
||||
#import "CKAudioProgressView.h"
|
||||
#import "WXYZ_PlayPageModel.h"
|
||||
|
||||
#if __has_include(<iflyMSC/IFlyMSC.h>)
|
||||
#import "iflyMSC/IFlyMSC.h"
|
||||
#endif
|
||||
#import "WXYZ_Player.h"
|
||||
|
||||
@interface TFAudioPlayHeaderView ()<WXYZ_PlayerDelegate, WXYZ_PlayerDataSource, CKAudioProgressViewDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFAudioPlayHeaderView
|
||||
|
||||
- (instancetype)initWithProductionType:(TFProductionType)productionType
|
||||
{
|
||||
[self initAVAudio];
|
||||
|
||||
return [super initWithProductionType:productionType];
|
||||
}
|
||||
|
||||
- (void)initAVAudio
|
||||
{
|
||||
[[WXYZ_Player sharedPlayer] initPlayerWithUserId:nil];
|
||||
[WXYZ_Player sharedPlayer].dataSource = self;
|
||||
[WXYZ_Player sharedPlayer].delegate = self;
|
||||
[WXYZ_Player sharedPlayer].playMode = WXYZ_PlayerModeOnlyOnce;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(relationViewTitleChange) name:Notification_Change_AiBook_Chapter object:nil];
|
||||
}
|
||||
|
||||
- (void)setProductionChapterModel:(TFProductionChapterModel *)productionChapterModel
|
||||
{
|
||||
[super setProductionChapterModel:productionChapterModel];
|
||||
|
||||
WS(weakSelf)
|
||||
[[WXYZ_AudioSettingHelper sharedManager] getCurrentTimingBlock:^(NSUInteger currentTime) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
weakSelf.timingButton.buttonTitle = [NSString stringWithFormat:@"%02zd:%02zd", (NSInteger)(currentTime / 60), (NSInteger)(currentTime % 60)];
|
||||
});
|
||||
} finishBlock:^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if ([[WXYZ_AudioSettingHelper sharedManager] getReadTiming] == 1) {
|
||||
weakSelf.timingButton.buttonTitle = TFLocalizedString(@"听完本章节");
|
||||
} else if ([[WXYZ_AudioSettingHelper sharedManager] getReadTiming] == 0) {
|
||||
weakSelf.timingButton.buttonTitle = TFLocalizedString(@"定时");
|
||||
if (weakSelf.playerState == TFBasicVoicePlayerStatePlaying) {
|
||||
[[WXYZ_Player sharedPlayer] pause];
|
||||
}
|
||||
}
|
||||
});
|
||||
}];
|
||||
|
||||
if ([TFNetworkManager networkingStatus] == NO) {
|
||||
|
||||
if (![[WXYZ_AudioDownloadManager sharedManager] isChapterDownloadedWithProduction_id:productionChapterModel.production_id chapter_id:productionChapterModel.chapter_id]) {
|
||||
|
||||
[[WXYZ_TouchAssistantView sharedManager] stopPlayerState];
|
||||
[[WXYZ_TouchAssistantView sharedManager] changePlayProgress:0];
|
||||
|
||||
[[WXYZ_Player sharedPlayer] deallocPlayer];
|
||||
self.playerState = TFBasicVoicePlayerStateStoped;
|
||||
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"当前为离线状态,只可查看缓存内容哦")];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是付费章节,弹出付费,停止播放
|
||||
if (self.temp_chapterModel.chapter_id == productionChapterModel.chapter_id && self.temp_chapterModel.is_preview == productionChapterModel.is_preview) {
|
||||
|
||||
if (productionChapterModel.is_preview == 1) {
|
||||
[self showPayView];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ([WXYZ_BookAiPlayPageViewController sharedManager].speaking && ![[WXYZ_AudioSettingHelper sharedManager] isPlayPageShowingWithProductionType:TFProductionTypeAi]) {
|
||||
#if __has_include(<iflyMSC/IFlyMSC.h>)
|
||||
[[IFlySpeechSynthesizer sharedInstance] pauseSpeaking];
|
||||
#endif
|
||||
[[WXYZ_Player sharedPlayer] play];
|
||||
}
|
||||
|
||||
if ([[WXYZ_AudioSettingHelper sharedManager] isPlayPageShowingWithProductionType:TFProductionTypeAi]) {
|
||||
[[WXYZ_AudioSettingHelper sharedManager] playPageViewShow:NO productionType:TFProductionTypeAi];
|
||||
if ([WXYZ_BookAiPlayPageViewController sharedManager].speaking) {
|
||||
self.playerState = TFBasicVoicePlayerStateStoped;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
self.temp_chapterModel = productionChapterModel;
|
||||
|
||||
[WXYZ_Player sharedPlayer].remoteCenterPreviousEnable = !(productionChapterModel.last_chapter == 0);
|
||||
[WXYZ_Player sharedPlayer].remoteCenterNextEnable = !(productionChapterModel.next_chapter == 0);
|
||||
|
||||
if (productionChapterModel.is_preview == 1) {
|
||||
|
||||
[[WXYZ_TouchAssistantView sharedManager] stopPlayerState];
|
||||
[[WXYZ_TouchAssistantView sharedManager] changePlayProgress:0];
|
||||
|
||||
[[WXYZ_Player sharedPlayer] deallocPlayer];
|
||||
self.playerState = TFBasicVoicePlayerStateStoped;
|
||||
|
||||
[self showPayView];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
[[WXYZ_Player sharedPlayer] reloadData]; // 需在传入数据源后调用
|
||||
[[WXYZ_Player sharedPlayer] playWithAudioId:0];
|
||||
}
|
||||
|
||||
- (void)relationViewTitleChange
|
||||
{
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self setRelationViewTitle:[[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeAi] getReadingRecordChapterTitleWithProduction_id:self.relationModel.production_id]?:self.relationModel.chapter_title?:@""];
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - WXYZ_PlayerDelegate
|
||||
|
||||
- (NSArray<WXYZ_PlayerModel *> *)audioDataForPlayer:(WXYZ_Player *)player
|
||||
{
|
||||
WXYZ_PlayerModel *playerModel = [[WXYZ_PlayerModel alloc] init];
|
||||
|
||||
NSString *localAudioFilePath = [[WXYZ_AudioDownloadManager sharedManager] chapterDownloadedFilePathWithProduction_id:self.productionChapterModel.production_id chapter_id:self.productionChapterModel.chapter_id chapter_update_time:self.productionChapterModel.update_time];
|
||||
// 使用本地环境播放
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:localAudioFilePath]) {
|
||||
playerModel.audioUrl = [NSURL fileURLWithPath:[[WXYZ_AudioDownloadManager sharedManager] chapterDownloadedFilePathWithProduction_id:self.productionChapterModel.production_id chapter_id:self.productionChapterModel.chapter_id chapter_update_time:self.productionChapterModel.update_time]];
|
||||
} else if ([TFNetworkManager networkingStatus] == YES) {
|
||||
playerModel.audioUrl = [NSURL URLWithString:self.productionChapterModel.content?:@""];
|
||||
} else {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"作品未下载")];
|
||||
self.playerState = TFBasicVoicePlayerStateStoped;
|
||||
return @[];
|
||||
}
|
||||
playerModel.audioId = 0;
|
||||
return @[playerModel];
|
||||
}
|
||||
|
||||
- (WXYZ_PlayerInfoModel *)audioInfoForPlayer:(WXYZ_Player *)player
|
||||
{
|
||||
WXYZ_PlayerInfoModel *infoModel = [[WXYZ_PlayerInfoModel alloc] init];
|
||||
infoModel.audioName = self.productionChapterModel.chapter_title;
|
||||
infoModel.audioAlbum = self.productionChapterModel.name;
|
||||
infoModel.audioImage = [[YYImageCache sharedCache] getImageForKey:self.productionChapterModel.cover];
|
||||
return infoModel;
|
||||
}
|
||||
|
||||
// 远程控制切换上一首
|
||||
- (void)audioPlayerRemoteCenterSwitchToPrevious
|
||||
{
|
||||
[self skipToLastChapter];
|
||||
}
|
||||
|
||||
// 远程控制切换下一首
|
||||
- (void)audioPlayerRemoteCenterSwitchToNext
|
||||
{
|
||||
[self skipToNextChapter];
|
||||
}
|
||||
|
||||
// 准备播放
|
||||
- (void)playerReadyToPlay:(WXYZ_Player *)player
|
||||
{
|
||||
[[WXYZ_Player sharedPlayer] setRate:[[[[WXYZ_AudioSettingHelper sharedManager] getReadSpeedValuesWithProducitionType:self.productionType] objectAtIndex:[[WXYZ_AudioSettingHelper sharedManager] getReadSpeedWithProducitionType:self.productionType]] floatValue]];
|
||||
|
||||
self.playerState = TFBasicVoicePlayerStateLoading;
|
||||
|
||||
if ([[WXYZ_AudioSettingHelper sharedManager] isPlayPageShowingWithProductionType:TFProductionTypeNovel] && [[WXYZ_AudioSettingHelper sharedManager] isPlayPageShowingWithProductionType:TFProductionTypeAudio] && [WXYZ_BookAiPlayPageViewController sharedManager].speaking) {
|
||||
[[WXYZ_Player sharedPlayer] pause];
|
||||
} else {
|
||||
if ([WXYZ_BookAiPlayPageViewController sharedManager].speaking) {
|
||||
#if __has_include(<iflyMSC/IFlyMSC.h>)
|
||||
[[IFlySpeechSynthesizer sharedInstance] pauseSpeaking];
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// 播放进度记录百分比 0 - 1
|
||||
CGFloat progress = [[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeAudio] getPlayingProgressWithProduction_id:self.productionChapterModel.production_id chapter_id:self.productionChapterModel.chapter_id];
|
||||
if (progress > 0.05) {
|
||||
[[WXYZ_Player sharedPlayer] seekToTime:progress completionBlock:nil];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 播放结束
|
||||
- (void)playerDidPlayToEndTime:(WXYZ_Player *)player
|
||||
{
|
||||
// 听完本章结束播放
|
||||
if ([[WXYZ_AudioSettingHelper sharedManager] getReadTiming] == 1) {
|
||||
[[WXYZ_AudioSettingHelper sharedManager] setReadTimingWithIndex:0];
|
||||
self.timingButton.buttonTitle = TFLocalizedString(@"定时");
|
||||
[[WXYZ_Player sharedPlayer] pause];
|
||||
|
||||
} else {
|
||||
if (self.productionChapterModel.next_chapter > 0 && self.productionChapterModel.next_chapter) {
|
||||
[self skipToNextChapter];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//播放进度代理
|
||||
- (void)player:(WXYZ_Player *)player progress:(CGFloat)progress currentTime:(CGFloat)currentTime totalTime:(CGFloat)totalTime
|
||||
{
|
||||
[[WXYZ_TouchAssistantView sharedManager] changePlayProgress:progress];
|
||||
[self.timelineProgress updateProgress:progress audioLength:totalTime];
|
||||
|
||||
// 记录阅读进度
|
||||
[[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeAudio] addPlayingProgress:progress production_id:self.productionChapterModel.production_id chapter_id:self.productionChapterModel.chapter_id];
|
||||
}
|
||||
|
||||
// 缓冲进度
|
||||
- (void)player:(WXYZ_Player *)player bufferProgress:(CGFloat)bufferProgress
|
||||
{
|
||||
[self.timelineProgress updateCacheProgress:bufferProgress];
|
||||
}
|
||||
|
||||
- (void)playerStateChange:(TFBasicVoicePlayerState)playerState
|
||||
{
|
||||
self.playerState = playerState;
|
||||
}
|
||||
|
||||
@end
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TFBookRackCommViewController.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFBookRackCommViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,copy) void (^pushToReaderViewControllerBlock)(UIView *transitionView, TFProductionModel *productionModel);
|
||||
|
||||
// 结束编辑状态
|
||||
- (void)endEdited;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+617
@@ -0,0 +1,617 @@
|
||||
//
|
||||
// TFBookRackCommViewController.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookRackCommViewController.h"
|
||||
|
||||
#if TF_Enable_Book
|
||||
#import "TFReadNovelViewController.h"
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
#import "TFComicBrowseViewController.h"
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
#import "TFAudioPlayViewController.h"
|
||||
#endif
|
||||
|
||||
#import "TFAnnouncementController.h"
|
||||
#import "TFTaskViewController.h"
|
||||
#import "TFBookRackCommCell.h"
|
||||
#import "TFBookRackAddMoreCell.h"
|
||||
#import "TFBookRackHeaderView.h"
|
||||
#import "TFCollectionManager.h"
|
||||
#import "TFReadRecordManager.h"
|
||||
#import "NSObject+Observer.h"
|
||||
|
||||
@interface TFBookRackCommViewController ()<UICollectionViewDelegate, UICollectionViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) TFBookRackHeaderView *headerView;
|
||||
@property (nonatomic ,strong) UIView *toolBarView;
|
||||
@property (nonatomic ,strong) UIButton *deleteBtn;
|
||||
@property (nonatomic ,strong) UIButton *checkAllBtn;
|
||||
@property (nonatomic ,strong) TFBookRackModel *bookRackModel;
|
||||
@property (nonatomic ,strong) NSMutableArray *deleteSourceArray;
|
||||
// 角标记录
|
||||
@property (nonatomic ,strong) NSMutableDictionary *badges;
|
||||
@property (nonatomic ,assign) BOOL editingProduction;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookRackCommViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
[self localSourceRequest];
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self hiddenNavigationBar:YES];
|
||||
|
||||
self.view.backgroundColor = kWhiteColor;
|
||||
self.deleteSourceArray = [NSMutableArray array];
|
||||
|
||||
// 签到加入书架
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(localSourceRequest) name:Notification_Reload_Rack_Production object:nil];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainCollectionViewFlowLayout.minimumLineSpacing = kMargin;
|
||||
self.mainCollectionViewFlowLayout.minimumInteritemSpacing = 0;
|
||||
self.mainCollectionViewFlowLayout.headerReferenceSize = CGSizeMake(SCREEN_WIDTH, Rack_Header_Height);
|
||||
self.mainCollectionViewFlowLayout.footerReferenceSize = CGSizeMake(SCREEN_WIDTH, kHalfMargin);
|
||||
self.mainCollectionViewFlowLayout.itemSize = CGSizeMake(BOOK_WIDTH, BOOK_HEIGHT + BOOK_CELL_TITLE_HEIGHT / 2);
|
||||
self.mainCollectionViewFlowLayout.sectionInset = UIEdgeInsetsMake(0, kHalfMargin, 0, kHalfMargin);
|
||||
|
||||
self.mainCollectionView.delegate = self;
|
||||
self.mainCollectionView.dataSource = self;
|
||||
[self.mainCollectionView registerClass:[TFBookRackCommCell class] forCellWithReuseIdentifier:@"TFBookRackCommCell"];
|
||||
[self.mainCollectionView registerClass:[TFBookRackAddMoreCell class] forCellWithReuseIdentifier:@"TFBookRackAddMoreCell"];
|
||||
[self.mainCollectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView"];
|
||||
[self.mainCollectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FooterView"];
|
||||
[self.view addSubview:self.mainCollectionView];
|
||||
|
||||
[self.mainCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
make.height.mas_equalTo(self.view.mas_height).with.offset(-PUB_NAVBAR_HEIGHT - PUB_TABBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
UILongPressGestureRecognizer *editLongPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(startEdited:)];
|
||||
editLongPressGesture.minimumPressDuration = 1.0f;
|
||||
editLongPressGesture.numberOfTouchesRequired = 1;
|
||||
[self.mainCollectionView addGestureRecognizer:editLongPressGesture];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainCollectionView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
[weakSelf localSourceRequest];
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
|
||||
{
|
||||
if (self.editingProduction) {
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
return self.dataSourceArray.count + 1;
|
||||
}
|
||||
|
||||
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (self.dataSourceArray.count == indexPath.row && !self.editingProduction) {
|
||||
|
||||
static NSString *CellIdentifier = @"TFBookRackAddMoreCell";
|
||||
TFBookRackAddMoreCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
|
||||
|
||||
return cell;
|
||||
} else {
|
||||
|
||||
static NSString *CellIdentifier = @"TFBookRackCommCell";
|
||||
TFBookRackCommCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
|
||||
TFProductionModel *t_bookModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
cell.productionModel = t_bookModel;
|
||||
cell.badgeNum = [TFUtilsHelper formatStringWithInteger:[[self.badges objectForKey:[TFUtilsHelper formatStringWithInteger:t_bookModel.production_id]] total_chapters]];
|
||||
cell.bookSeleced = NO;
|
||||
cell.startEditing = self.editingProduction;
|
||||
|
||||
for (TFProductionModel *t_model in self.deleteSourceArray) {
|
||||
if (t_model.production_id == t_bookModel.production_id) {
|
||||
cell.bookSeleced = YES;
|
||||
}
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
|
||||
|
||||
UICollectionReusableView *headerReusableView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView" forIndexPath:indexPath];
|
||||
headerReusableView.backgroundColor = [UIColor clearColor];
|
||||
|
||||
if (self.bookRackModel && self.bookRackModel.recommendList.count > 0 && !self.editingProduction) {
|
||||
self.headerView.rackModel = self.bookRackModel;
|
||||
[self showHeaderViewWithAnimated:NO];
|
||||
} else if (self.bookRackModel) {
|
||||
[self hiddenHeaderViewWithAnimated:NO];
|
||||
}
|
||||
[headerReusableView addSubview:self.headerView];
|
||||
|
||||
return headerReusableView;
|
||||
} else {
|
||||
|
||||
UICollectionReusableView *footerReusableView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"FooterView" forIndexPath:indexPath];
|
||||
|
||||
return footerReusableView;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (self.dataSourceArray.count == indexPath.row && !self.editingProduction) {
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Change_Tabbar_Index object:@"1"];
|
||||
switch (self.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel:
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:NSNotification_Rack_JumpToMallCenter object:@"novel"];
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic:
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:NSNotification_Rack_JumpToMallCenter object:@"comic"];
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio:
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:NSNotification_Rack_JumpToMallCenter object:@"audio"];
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
TFBookRackCommCell *cell = (TFBookRackCommCell *)[collectionView cellForItemAtIndexPath:indexPath];
|
||||
TFProductionModel *productionModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
if (!self.editingProduction) {
|
||||
[[TFCollectionManager shareManagerWithProductionType:self.productionType] moveCollectionToTopWithProductionModel:productionModel];
|
||||
|
||||
switch (self.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel: {
|
||||
if (self.pushToReaderViewControllerBlock) {
|
||||
self.pushToReaderViewControllerBlock(cell.coverView, productionModel);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicBrowseViewController *comicBrowse = [[TFComicBrowseViewController alloc] init];
|
||||
comicBrowse.comicProductionModel = productionModel;
|
||||
comicBrowse.chapter_id = [[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeComic] getReadingRecordChapter_idWithProduction_id:productionModel.production_id];
|
||||
|
||||
[self.navigationController pushViewController:comicBrowse animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
TFAudioPlayViewController *audioPlay = [[TFAudioPlayViewController alloc] init];
|
||||
[audioPlay loadDataWithAudio_id:productionModel.production_id chapter_id:0];
|
||||
|
||||
TFNavigationController *nav = [[TFNavigationController alloc] initWithRootViewController:audioPlay];
|
||||
[[TFViewHelper getWindowRootController] presentViewController:nav animated:YES completion:nil];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// 读书任务请求
|
||||
[TFTaskViewController taskReadRequestWithProduction_id:productionModel.production_id];
|
||||
|
||||
// 如果有更新则更新本地数据源
|
||||
if ([cell.badgeNum integerValue] > 0) {
|
||||
TFProductionModel *t_model = [self.badges objectForKey:[TFUtilsHelper formatStringWithInteger:productionModel.production_id]];
|
||||
if (t_model) {
|
||||
[[TFCollectionManager shareManagerWithProductionType:self.productionType] modificationCollectionWithProductionModel:t_model];
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (cell.bookSeleced) {
|
||||
cell.bookSeleced = NO;
|
||||
[self.deleteSourceArray removeObject:productionModel];
|
||||
} else {
|
||||
cell.bookSeleced = YES;
|
||||
[self.deleteSourceArray addObject:productionModel];
|
||||
}
|
||||
|
||||
[self reloadToolBarState];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - 点击事件
|
||||
- (void)showHeaderViewWithAnimated:(BOOL)animated
|
||||
{
|
||||
if (self.bookRackModel.recommendList.count == 0) return;
|
||||
|
||||
[self.mainCollectionView showRefreshHeader];
|
||||
|
||||
[UIView animateWithDuration:animated?kAnimatedDuration:0.0f animations:^{
|
||||
if (self.bookRackModel.announcement.count > 0) {
|
||||
self.headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, Rack_Header_Height);
|
||||
self.mainCollectionViewFlowLayout.headerReferenceSize = CGSizeMake(SCREEN_WIDTH, Rack_Header_Height);
|
||||
} else {
|
||||
self.headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, Rack_Header_Height_NoRecommend);
|
||||
self.mainCollectionViewFlowLayout.headerReferenceSize = CGSizeMake(SCREEN_WIDTH, Rack_Header_Height_NoRecommend);
|
||||
}
|
||||
[self.mainCollectionView setCollectionViewLayout:self.mainCollectionViewFlowLayout animated:animated];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)hiddenHeaderViewWithAnimated:(BOOL)animated
|
||||
{
|
||||
[self.mainCollectionView hideRefreshHeader];
|
||||
|
||||
[UIView animateWithDuration:animated?kAnimatedDuration:0.0f animations:^{
|
||||
self.headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 0);
|
||||
self.mainCollectionViewFlowLayout.headerReferenceSize = CGSizeMake(SCREEN_WIDTH, 10);
|
||||
[self.mainCollectionView setCollectionViewLayout:self.mainCollectionViewFlowLayout animated:animated];
|
||||
}];
|
||||
}
|
||||
|
||||
// 工具栏点击
|
||||
- (void)toolBarActionClick:(UIButton *)sender
|
||||
{
|
||||
switch (sender.tag) {
|
||||
case 11: // 取消操作
|
||||
[self endEdited];
|
||||
break;
|
||||
|
||||
case 22: { // 删除操作
|
||||
if (self.deleteSourceArray.count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableArray *t_deleteArray = [NSMutableArray array];
|
||||
for (TFProductionModel *t_model in self.deleteSourceArray) {
|
||||
[[TFCollectionManager shareManagerWithProductionType:self.productionType] removeCollectionWithProductionModel:t_model];
|
||||
[t_deleteArray addObject:[TFUtilsHelper formatStringWithInteger:t_model.production_id]];
|
||||
}
|
||||
|
||||
NSString *url = @"";
|
||||
NSString *production_key = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Delete_Collect;
|
||||
production_key = @"book_id";
|
||||
break;
|
||||
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Collect_Delete;
|
||||
production_key = @"comic_id";
|
||||
break;
|
||||
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Collection_Delete;
|
||||
production_key = @"audio_id";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
[TFNetworkTools POST:url parameters:@{production_key:[t_deleteArray componentsJoinedByString:@","]} model:nil success:nil failure:nil];
|
||||
|
||||
[self endEdited];
|
||||
[self localSourceRequest];
|
||||
}
|
||||
|
||||
case 33: { // 全选/取消操作
|
||||
|
||||
[self.deleteSourceArray removeAllObjects];
|
||||
|
||||
if (!sender.selected) {
|
||||
self.deleteSourceArray = [self.dataSourceArray mutableCopy];
|
||||
[sender setTitle:TFLocalizedString(@"取消全选") forState:UIControlStateNormal];
|
||||
} else {
|
||||
[sender setTitle:TFLocalizedString(@"全选") forState:UIControlStateNormal];
|
||||
[self.deleteSourceArray removeAllObjects];
|
||||
}
|
||||
|
||||
sender.selected = !sender.selected;
|
||||
|
||||
[self.mainCollectionView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if ([obj isKindOfClass:[TFBookRackCommCell class]]) {
|
||||
TFBookRackCommCell *cell = (TFBookRackCommCell *)obj;
|
||||
cell.bookSeleced = sender.selected;
|
||||
}
|
||||
}];
|
||||
|
||||
[self reloadToolBarState];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 开启编辑状态
|
||||
- (void)startEdited:(UILongPressGestureRecognizer *)gestureRecognizer
|
||||
{
|
||||
if (gestureRecognizer.state != UIGestureRecognizerStateBegan) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.editingProduction) {
|
||||
return;
|
||||
}
|
||||
self.editingProduction = YES;
|
||||
|
||||
[self.deleteSourceArray removeAllObjects];
|
||||
|
||||
CGPoint pointTouch = [gestureRecognizer locationInView:self.mainCollectionView];
|
||||
|
||||
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
|
||||
NSIndexPath *indexPath = [self.mainCollectionView indexPathForItemAtPoint:pointTouch];
|
||||
if ([[self.mainCollectionView cellForItemAtIndexPath:indexPath] isKindOfClass:[TFBookRackCommCell class]]) {
|
||||
|
||||
// 获取当前被点击的书籍,默认选中
|
||||
TFBookRackCommCell *t_cell = (TFBookRackCommCell *)[self.mainCollectionView cellForItemAtIndexPath:indexPath];
|
||||
[self.deleteSourceArray addObject:t_cell.productionModel];
|
||||
|
||||
// 隐藏推荐栏
|
||||
[self hiddenHeaderViewWithAnimated:YES];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)((kAnimatedDuration + 0.1) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self.mainCollectionView reloadData];
|
||||
});
|
||||
|
||||
[UIView animateWithDuration:kAnimatedDuration animations:^{
|
||||
self.toolBarView.frame = CGRectMake(0, SCREEN_HEIGHT - PUB_TABBAR_HEIGHT, SCREEN_WIDTH, PUB_TABBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
[self reloadToolBarState];
|
||||
} else {
|
||||
self.editingProduction = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)endEdited
|
||||
{
|
||||
self.editingProduction = NO;
|
||||
|
||||
[self showHeaderViewWithAnimated:YES];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kAnimatedDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self.mainCollectionView reloadData];
|
||||
});
|
||||
|
||||
[UIView animateWithDuration:kAnimatedDuration animations:^{
|
||||
self.toolBarView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, PUB_TABBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
[self reloadToolBarState];
|
||||
}
|
||||
|
||||
- (void)reloadToolBarState
|
||||
{
|
||||
if (self.deleteSourceArray.count == 0) {
|
||||
|
||||
self.deleteBtn.backgroundColor = kGrayLineColor;
|
||||
self.deleteBtn.enabled = NO;
|
||||
[self.deleteBtn setTitle:TFLocalizedString(@"删除(0)") forState:UIControlStateNormal];
|
||||
[self.deleteBtn setTitleColor:kGrayTextColor forState:UIControlStateNormal];
|
||||
|
||||
self.checkAllBtn.selected = NO;
|
||||
[self.checkAllBtn setTitle:TFLocalizedString(@"全选") forState:UIControlStateNormal];
|
||||
|
||||
} else {
|
||||
self.deleteBtn.backgroundColor = kRedColor;
|
||||
self.deleteBtn.enabled = YES;
|
||||
[self.deleteBtn setTitle:[NSString stringWithFormat:@"%@(%@)", TFLocalizedString(@"删除"), [TFUtilsHelper formatStringWithInteger:self.deleteSourceArray.count]] forState:UIControlStateNormal];
|
||||
[self.deleteBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
|
||||
|
||||
|
||||
if (self.deleteSourceArray.count == self.dataSourceArray.count) {
|
||||
self.checkAllBtn.selected = YES;
|
||||
[self.checkAllBtn setTitle:TFLocalizedString(@"取消全选") forState:UIControlStateNormal];
|
||||
} else {
|
||||
self.checkAllBtn.selected = NO;
|
||||
[self.checkAllBtn setTitle:TFLocalizedString(@"全选") forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (TFBookRackHeaderView *)headerView
|
||||
{
|
||||
if (!_headerView) {
|
||||
WS(weakSelf)
|
||||
_headerView = [[TFBookRackHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, Rack_Header_Height)];
|
||||
_headerView.backgroundColor = [UIColor whiteColor];
|
||||
_headerView.productionType = self.productionType;
|
||||
|
||||
_headerView.adBannerClickBlock = ^(NSString * _Nonnull title, NSString * _Nonnull content) {
|
||||
TFAnnouncementController *vc = [[TFAnnouncementController alloc] init];
|
||||
vc.titleText = title?:@"";
|
||||
vc.contentText = content?:@"";
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
};
|
||||
|
||||
_headerView.recommendBannerClickBlock = ^(NSInteger production_id) {
|
||||
switch (weakSelf.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel: {
|
||||
TFNovelDetailViewController *novelDetail = [[TFNovelDetailViewController alloc] init];
|
||||
novelDetail.book_id = production_id;
|
||||
[weakSelf.navigationController pushViewController:novelDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicDetailViewController *comicDetail = [[TFComicDetailViewController alloc] init];
|
||||
comicDetail.comic_id = production_id;
|
||||
[weakSelf.navigationController pushViewController:comicDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
TFAudioDetailViewController *audioDetail = [[TFAudioDetailViewController alloc] init];
|
||||
audioDetail.audio_id = production_id;
|
||||
[weakSelf.navigationController pushViewController:audioDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
_headerView.collectionClickBlock = ^{
|
||||
[weakSelf.navigationController pushViewController:[[TFTaskViewController alloc] init] animated:YES];
|
||||
};
|
||||
}
|
||||
return _headerView;
|
||||
}
|
||||
|
||||
- (UIView *)toolBarView
|
||||
{
|
||||
if (!_toolBarView) {
|
||||
_toolBarView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, PUB_TABBAR_HEIGHT)];
|
||||
_toolBarView.backgroundColor = kWhiteColor;
|
||||
WS(weakSelf)
|
||||
[_toolBarView addObserver:KEY_PATH(_toolBarView, frame) complete:^(UIView * _Nonnull toolBarView, id _Nullable oldVal, id _Nullable newVal) {
|
||||
CGRect frame = [newVal CGRectValue];
|
||||
if (CGRectGetMinY(frame) >= SCREEN_HEIGHT) {
|
||||
toolBarView.hidden = YES;
|
||||
weakSelf.tabBarController.tabBar.hidden = NO;
|
||||
} else {
|
||||
toolBarView.hidden = NO;
|
||||
weakSelf.tabBarController.tabBar.hidden = YES;
|
||||
}
|
||||
}];
|
||||
[self.view addSubview:_toolBarView];
|
||||
|
||||
UIButton *checkAllBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
checkAllBtn.tag = 33;
|
||||
checkAllBtn.selected = NO;
|
||||
checkAllBtn.frame = CGRectMake(0, 0, SCREEN_WIDTH / 3, PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET);
|
||||
checkAllBtn.adjustsImageWhenHighlighted = NO;
|
||||
[checkAllBtn setTitle:TFLocalizedString(@"全选") forState:UIControlStateNormal];
|
||||
[checkAllBtn setTitleColor:kBlackColor forState:UIControlStateNormal];
|
||||
[checkAllBtn.titleLabel setFont:kMainFont];
|
||||
[checkAllBtn addTarget:self action:@selector(toolBarActionClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_toolBarView addSubview:checkAllBtn];
|
||||
|
||||
self.checkAllBtn = checkAllBtn;
|
||||
|
||||
UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
deleteBtn.frame = CGRectMake(SCREEN_WIDTH / 3, 0, SCREEN_WIDTH / 3, PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET);
|
||||
deleteBtn.backgroundColor = kGrayLineColor;
|
||||
deleteBtn.tag = 22;
|
||||
[deleteBtn setTitleColor:kGrayTextColor forState:UIControlStateNormal];
|
||||
[deleteBtn setTitle:TFLocalizedString(@"删除") forState:UIControlStateNormal];
|
||||
[deleteBtn.titleLabel setFont:kMainFont];
|
||||
[deleteBtn addTarget:self action:@selector(toolBarActionClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_toolBarView addSubview:deleteBtn];
|
||||
|
||||
self.deleteBtn = deleteBtn;
|
||||
|
||||
UIButton *cancleButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
cancleButton.frame = CGRectMake(SCREEN_WIDTH / 3 * 2, 0, SCREEN_WIDTH / 3, PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET);
|
||||
cancleButton.tag = 11;
|
||||
[cancleButton setTitle:TFLocalizedString(@"取消") forState:UIControlStateNormal];
|
||||
[cancleButton setTitleColor:kBlackColor forState:UIControlStateNormal];
|
||||
[cancleButton.titleLabel setFont:kMainFont];
|
||||
[cancleButton addTarget:self action:@selector(toolBarActionClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_toolBarView addSubview:cancleButton];
|
||||
}
|
||||
return _toolBarView;
|
||||
}
|
||||
|
||||
// 加载本地书籍缓存
|
||||
- (void)localSourceRequest
|
||||
{
|
||||
NSArray *cacheArray = [[TFCollectionManager shareManagerWithProductionType:self.productionType] getAllCollection];
|
||||
if (![cacheArray isEqualToArray:self.dataSourceArray]) {
|
||||
self.dataSourceArray = [cacheArray mutableCopy];
|
||||
[self.mainCollectionView reloadData];
|
||||
}
|
||||
|
||||
[self.mainCollectionView scrollToTop];
|
||||
[self.mainCollectionView endRefreshing];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
// 书籍更新角标
|
||||
self.badges = [NSMutableDictionary dictionary];
|
||||
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Rack;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Rack;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Rack;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:url parameters:nil model:TFBookRackModel.class success:^(BOOL isSuccess, TFBookRackModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
if (isSuccess) {
|
||||
weakSelf.bookRackModel = t_model;
|
||||
for (TFProductionModel *t_model in weakSelf.bookRackModel.productionList) {
|
||||
[weakSelf.badges setObject:t_model forKey:[TFUtilsHelper formatStringWithInteger:t_model.production_id]];
|
||||
}
|
||||
}
|
||||
[weakSelf.mainCollectionView endRefreshing];
|
||||
[weakSelf.mainCollectionView reloadData];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainCollectionView endRefreshing];
|
||||
[weakSelf.mainCollectionView reloadData];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// TFBookRackViewController.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFBookRackViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,169 @@
|
||||
//
|
||||
// TFBookRackViewController.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookRackViewController.h"
|
||||
#import "TFTaskViewController.h"
|
||||
#import "TFBookRackCommViewController.h"
|
||||
|
||||
#if TF_Enable_Book
|
||||
#import "TFReadNovelViewController.h"
|
||||
#endif
|
||||
|
||||
#import "NSObject+DZM.h"
|
||||
#import "UINavigationController+TFExtension.h"
|
||||
|
||||
@interface TFBookRackViewController ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
|
||||
|
||||
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
|
||||
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentView;
|
||||
@property (nonatomic ,strong) NSMutableArray *childControllers;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookRackViewController
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Show_Tabbar object:nil];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self hiddenNavigationBarLeftButton];
|
||||
[self hiddenSeparator];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(synchronizationRack) name:Notification_Login_Success object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(synchronizationRack) name:Notification_Reload_Rack_Production object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(synchronizationRack) name:UIApplicationWillEnterForegroundNotification object:nil];
|
||||
}
|
||||
|
||||
- (void)synchronizationRack
|
||||
{
|
||||
[TFUtilsHelper synchronizationRack];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
#if TF_Enable_Book
|
||||
WS(weakSelf)
|
||||
TFBookRackCommViewController *novel = [[TFBookRackCommViewController alloc] init];
|
||||
novel.productionType = TFProductionTypeNovel;
|
||||
novel.pushToReaderViewControllerBlock = ^(UIView * _Nonnull transitionView, TFProductionModel * _Nonnull productionModel) {
|
||||
weakSelf.ATTarget = transitionView;
|
||||
TFReadNovelViewController *vc = [[TFReadNovelViewController alloc] init];
|
||||
vc.book_id = productionModel.production_id;
|
||||
[weakSelf.navigationController jumpNextViewController:vc animated:YES];
|
||||
};
|
||||
novel.view.backgroundColor = kWhiteColor;
|
||||
[self addChildViewController:novel];
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
TFBookRackCommViewController *comic = [[TFBookRackCommViewController alloc] init];
|
||||
comic.productionType = TFProductionTypeComic;
|
||||
comic.view.backgroundColor = kWhiteColor;
|
||||
[self addChildViewController:comic];
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
TFBookRackCommViewController *audio = [[TFBookRackCommViewController alloc] init];
|
||||
audio.productionType = TFProductionTypeAudio;
|
||||
audio.view.backgroundColor = kWhiteColor;
|
||||
[self addChildViewController:audio];
|
||||
#endif
|
||||
|
||||
NSMutableArray *titleArray = [NSMutableArray array];
|
||||
self.childControllers = [NSMutableArray array];
|
||||
|
||||
for (NSNumber *siteNumber in [TFUtilsHelper getSiteState]) {
|
||||
#if TF_Enable_Book
|
||||
if ([siteNumber integerValue] == 1) {
|
||||
[titleArray addObject:TFLocalizedString(@"小说")];
|
||||
[self.childControllers addObject:novel];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
if ([siteNumber integerValue] == 2) {
|
||||
[titleArray addObject:TFLocalizedString(@"漫画")];
|
||||
[self.childControllers addObject:comic];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
if ([siteNumber integerValue] == 3) {
|
||||
[titleArray addObject:TFLocalizedString(@"听书")];
|
||||
[self.childControllers addObject:audio];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if ([TFUtilsHelper getSiteState].count == 1) {
|
||||
[titleArray removeAllObjects];
|
||||
[titleArray addObject:TFLocalizedString(@"书架")];
|
||||
}
|
||||
|
||||
self.pageContentView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) parentVC:self childVCs:self.childControllers];
|
||||
self.pageContentView.delegatePageContentCollectionView = self;
|
||||
[self.view addSubview:self.pageContentView];
|
||||
|
||||
self.pageConfigure.indicatorStyle = SGIndicatorStyleDynamic;
|
||||
self.pageConfigure.indicatorDynamicWidth = 14;
|
||||
self.pageConfigure.indicatorHeight = 3;
|
||||
self.pageConfigure.indicatorFixedWidth = 10;
|
||||
self.pageConfigure.indicatorToBottomDistance = 3;
|
||||
self.pageConfigure.titleSelectedColor = kBlackColor;
|
||||
self.pageConfigure.titleFont = kBoldFont16;
|
||||
self.pageConfigure.titleTextZoom = YES;
|
||||
self.pageConfigure.titleGradientEffect = YES;
|
||||
self.pageConfigure.titleTextZoomRatio = 0.2;
|
||||
self.pageConfigure.showIndicator = YES;
|
||||
|
||||
CGFloat width = 0;
|
||||
for (NSString *obj in titleArray) {
|
||||
CGFloat t_width = [TFViewHelper getDynamicWidthWithLabelFont:kBoldFont16 labelHeight:43.0 labelText:obj maxWidth:140.0];
|
||||
width += t_width;
|
||||
width += kLabelHeight;
|
||||
}
|
||||
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(kHalfMargin, (is_iPhoneX ? kQuarterMargin : kHalfMargin) + kHalfMargin + PUB_NAVBAR_OFFSET, width, TFPageView_H) delegate:self titleNames:titleArray configure:self.pageConfigure];
|
||||
self.pageTitleView.backgroundColor = [UIColor clearColor];
|
||||
[self.navigationBar addSubview:self.pageTitleView];
|
||||
}
|
||||
|
||||
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex
|
||||
{
|
||||
[self.pageContentView setPageContentCollectionViewCurrentIndex:selectedIndex];
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex
|
||||
{
|
||||
[self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView index:(NSInteger)index
|
||||
{
|
||||
for (UIViewController *viewController in self.childControllers) {
|
||||
[viewController performSelector:@selector(endEdited)];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// TFBookRackModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/11.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TFBaseInfoModel, TFAnnouncementModel, TFProductionModel, WXYZ_TaskModel;
|
||||
|
||||
@interface TFBookRackModel : NSObject
|
||||
|
||||
@property (nonatomic ,strong) TFBaseInfoModel *base_info;
|
||||
@property (nonatomic ,strong) NSArray <TFAnnouncementModel *>* announcement; // 公告
|
||||
@property (nonatomic ,strong) NSArray <TFProductionModel *>* recommendList; // 推荐
|
||||
@property (nonatomic ,strong) NSArray <TFProductionModel *>* productionList; // 作品列表
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface TFBaseInfoModel : NSObject
|
||||
|
||||
@property (nonatomic ,assign) NSInteger sign_status;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface TFAnnouncementModel : NSObject
|
||||
|
||||
@property (nonatomic ,copy) NSString *title;
|
||||
@property (nonatomic ,copy) NSString *content;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// TFBookRackModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/11.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookRackModel.h"
|
||||
|
||||
@implementation TFBookRackModel
|
||||
|
||||
+ (NSDictionary *)modelCustomPropertyMapper
|
||||
{
|
||||
return @{
|
||||
@"rackDescription" : @"description",
|
||||
@"announcement" : @[@"announce", @"announcement"],
|
||||
@"recommendList" : @[@"recommend_list", @"recommend"],
|
||||
@"productionList" : @[@"list"]
|
||||
};
|
||||
}
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{
|
||||
@"announcement" : [TFAnnouncementModel class],
|
||||
@"recommendList" : [TFProductionModel class],
|
||||
@"productionList" : [TFProductionModel class]
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation TFBaseInfoModel
|
||||
@end
|
||||
|
||||
|
||||
@implementation TFAnnouncementModel
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFBookRackAddMoreCell.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFBookRackAddMoreCell : UICollectionViewCell
|
||||
|
||||
- (void)startEditState;
|
||||
|
||||
- (void)endEditState;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// TFBookRackAddMoreCell.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookRackAddMoreCell.h"
|
||||
|
||||
@implementation TFBookRackAddMoreCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
[self createSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
UIView *borderView = [[UIView alloc] init];
|
||||
borderView.backgroundColor = kGrayViewColor;
|
||||
borderView.layer.cornerRadius = 2;
|
||||
[self addSubview:borderView];
|
||||
|
||||
[borderView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.mas_centerX);
|
||||
make.top.mas_equalTo(self.mas_top);
|
||||
make.width.mas_equalTo(BOOK_WIDTH);
|
||||
make.height.mas_equalTo(BOOK_HEIGHT);
|
||||
}];
|
||||
|
||||
UIImageView *addImageView = [[UIImageView alloc] init];
|
||||
addImageView.image = [UIImage imageNamed:@"public_rack_add"];
|
||||
[borderView addSubview:addImageView];
|
||||
|
||||
[addImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(borderView.mas_centerX);
|
||||
make.centerY.mas_equalTo(borderView.mas_centerY);
|
||||
make.height.width.mas_equalTo(30);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)startEditState
|
||||
{
|
||||
self.hidden = YES;
|
||||
}
|
||||
|
||||
- (void)endEditState
|
||||
{
|
||||
self.hidden = NO;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// TFBookRackCommCell.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TFProductionModel;
|
||||
@interface TFBookRackCommCell : UICollectionViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFProductionModel *productionModel;
|
||||
|
||||
@property (nonatomic ,assign) BOOL bookSeleced;
|
||||
|
||||
@property (nonatomic ,strong) TFProductionCoverView *coverView;
|
||||
|
||||
@property (nonatomic ,strong) NSString *badgeNum;
|
||||
|
||||
@property (nonatomic ,assign) BOOL startEditing;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,180 @@
|
||||
//
|
||||
// TFBookRackCommCell.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookRackCommCell.h"
|
||||
|
||||
@interface TFBookRackCommCell ()
|
||||
|
||||
@property (nonatomic ,strong) UILabel *titleLabel;
|
||||
@property (nonatomic ,strong) UILabel *finishedLabel;
|
||||
@property (nonatomic ,strong) UIImageView *selectView;
|
||||
@property (nonatomic ,strong) UIImageView *recommendView;
|
||||
@property (nonatomic ,strong) UILabel *badgeLabel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookRackCommCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.backgroundColor = kWhiteColor;
|
||||
[self createSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.coverView = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
|
||||
self.coverView.userInteractionEnabled = YES;
|
||||
[self addSubview:self.coverView];
|
||||
|
||||
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.mas_centerX);
|
||||
make.top.mas_equalTo(self.mas_top);
|
||||
make.width.mas_equalTo(BOOK_WIDTH);
|
||||
make.height.mas_equalTo(BOOK_HEIGHT);
|
||||
}];
|
||||
|
||||
self.recommendView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:TFLocalizedString(@"book_rack_recommend_conner")]];
|
||||
self.recommendView.hidden = YES;
|
||||
[self.coverView addSubview:self.recommendView];
|
||||
|
||||
[self.recommendView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(0);
|
||||
make.width.mas_equalTo(BOOK_WIDTH / 3);
|
||||
make.height.mas_equalTo(kGeometricHeight((BOOK_WIDTH / 3), 102, 54));
|
||||
}];
|
||||
|
||||
self.badgeLabel = [[UILabel alloc] init];
|
||||
self.badgeLabel.hidden = YES;
|
||||
self.badgeLabel.textAlignment = NSTextAlignmentCenter;
|
||||
self.badgeLabel.textColor = kWhiteColor;
|
||||
self.badgeLabel.backgroundColor = kColorRGBA(229, 91, 94, 1);
|
||||
self.badgeLabel.font = kFont9;
|
||||
self.badgeLabel.numberOfLines = 1;
|
||||
self.badgeLabel.layer.cornerRadius = 8;
|
||||
self.badgeLabel.layer.borderColor = [UIColor whiteColor].CGColor;
|
||||
self.badgeLabel.layer.borderWidth = 2;
|
||||
self.badgeLabel.clipsToBounds = YES;
|
||||
[self.coverView addSubview:self.badgeLabel];
|
||||
|
||||
[self.badgeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.coverView.mas_right).with.offset(- 3);
|
||||
make.centerY.mas_equalTo(self.coverView.mas_top).with.offset(3);
|
||||
make.width.height.mas_equalTo(16);
|
||||
}];
|
||||
|
||||
self.selectView = [[UIImageView alloc] init];
|
||||
self.selectView.hidden = YES;
|
||||
self.selectView.userInteractionEnabled = YES;
|
||||
self.selectView.image = [UIImage imageNamed:@"audio_download_unselect"];
|
||||
[self addSubview:self.selectView];
|
||||
|
||||
[self.selectView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.coverView.mas_right).with.offset(- 5);
|
||||
make.bottom.mas_equalTo(self.coverView.mas_bottom).with.offset(- 5);
|
||||
make.height.width.mas_equalTo(18);
|
||||
}];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.numberOfLines = 1;
|
||||
self.titleLabel.backgroundColor = kGrayViewColor;
|
||||
self.titleLabel.font = kFont12;
|
||||
self.titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.titleLabel.textColor = kBlackColor;
|
||||
[self addSubview:self.titleLabel];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.coverView.mas_left);
|
||||
make.top.mas_equalTo(self.coverView.mas_bottom).with.offset(kHalfMargin);
|
||||
make.width.mas_equalTo(self.coverView.mas_width);
|
||||
make.height.mas_equalTo(BOOK_CELL_TITLE_HEIGHT / 2);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setProductionModel:(TFProductionModel *)productionModel
|
||||
{
|
||||
_productionModel = productionModel;
|
||||
|
||||
self.coverView.productionType = productionModel.productionType;
|
||||
|
||||
if (productionModel.cover.length > 0) {
|
||||
self.coverView.coverImageUrl = productionModel.cover;
|
||||
} else if (productionModel.vertical_cover.length > 0) {
|
||||
self.coverView.coverImageUrl = productionModel.vertical_cover;
|
||||
} else if (productionModel.horizontal_cover.length > 0) {
|
||||
self.coverView.coverImageUrl = productionModel.horizontal_cover;
|
||||
}
|
||||
|
||||
self.recommendView.hidden = !productionModel.is_recommend;
|
||||
self.titleLabel.backgroundColor = kWhiteColor;
|
||||
self.titleLabel.text = productionModel.name ? : @"";
|
||||
self.badgeLabel.hidden = YES;
|
||||
}
|
||||
|
||||
- (void)setBookSeleced:(BOOL)bookSeleced
|
||||
{
|
||||
_bookSeleced = bookSeleced;
|
||||
|
||||
if (bookSeleced) {
|
||||
self.selectView.image = [UIImage imageNamed:@"audio_download_select"];
|
||||
self.coverView.alpha = 1.0f;
|
||||
} else {
|
||||
self.selectView.image = [UIImage imageNamed:@"audio_download_unselect"];
|
||||
self.coverView.alpha = 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setBadgeNum:(NSString *)badgeNum
|
||||
{
|
||||
if ([badgeNum isEqualToString:@"0"]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_productionModel.total_chapters == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
badgeNum = [NSString stringWithFormat:@"%@", [TFUtilsHelper formatStringWithInteger:abs((int)_productionModel.total_chapters - [badgeNum intValue])]];
|
||||
|
||||
if (badgeNum && ![badgeNum isEqualToString:@"0"]) {
|
||||
|
||||
self.badgeLabel.hidden = NO;
|
||||
self.badgeLabel.text = badgeNum;
|
||||
if (badgeNum.length == 2) {
|
||||
[self.badgeLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(21);
|
||||
}];
|
||||
} else if (badgeNum.length >= 3) {
|
||||
[self.badgeLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(26);
|
||||
}];
|
||||
}
|
||||
} else {
|
||||
self.badgeLabel.hidden = YES;
|
||||
}
|
||||
|
||||
_badgeNum = badgeNum;
|
||||
}
|
||||
|
||||
- (void)setStartEditing:(BOOL)startEditing
|
||||
{
|
||||
_startEditing = startEditing;
|
||||
|
||||
if (startEditing) {
|
||||
self.coverView.alpha = 0.5f;
|
||||
self.selectView.hidden = NO;
|
||||
} else {
|
||||
self.coverView.alpha = 1.0f;
|
||||
self.selectView.hidden = YES;
|
||||
}
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFBookRackHeaderCell.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFBookRackHeaderCell : UICollectionViewCell
|
||||
|
||||
@property (nonatomic, strong) TFProductionModel *productionModel;
|
||||
|
||||
@property (nonatomic, assign) TFProductionType productionType;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// TFBookRackHeaderCell.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookRackHeaderCell.h"
|
||||
|
||||
@interface TFBookRackHeaderCell ()
|
||||
{
|
||||
UIView *bottomView;
|
||||
|
||||
TFProductionCoverView *bookImageView;
|
||||
|
||||
UILabel *titleLabel;
|
||||
YYLabel *bookDetailLabel;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TFBookRackHeaderCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.backgroundColor = kWhiteColor;
|
||||
[self createSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
bottomView = [[UIView alloc] init];
|
||||
bottomView.backgroundColor = kGrayViewColor;
|
||||
bottomView.layer.cornerRadius = 8;
|
||||
[self addSubview:bottomView];
|
||||
|
||||
[bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kHalfMargin + kQuarterMargin);
|
||||
make.right.mas_equalTo(self.mas_right).with.offset(- kHalfMargin - kQuarterMargin);
|
||||
make.top.mas_equalTo(self.mas_top).with.offset(kHalfMargin);
|
||||
make.height.mas_equalTo(self.mas_height).with.offset(- kMargin);
|
||||
}];
|
||||
|
||||
bookImageView = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
|
||||
[bottomView addSubview:bookImageView];
|
||||
|
||||
[bookImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(bottomView.mas_left).with.offset(kHalfMargin);
|
||||
make.centerY.mas_equalTo(bottomView.mas_centerY);
|
||||
make.height.mas_equalTo(bottomView.mas_height).with.offset(- kMargin);
|
||||
make.width.mas_equalTo(kGeometricWidth((self.height - 2 * kMargin), 3, 4));
|
||||
}];
|
||||
|
||||
titleLabel = [[UILabel alloc] init];
|
||||
titleLabel.textColor = kBlackColor;
|
||||
titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
titleLabel.numberOfLines = 1;
|
||||
titleLabel.font = kMainFont;
|
||||
[self addSubview:titleLabel];
|
||||
|
||||
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(bookImageView.mas_right).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(bookImageView.mas_top).with.offset(kQuarterMargin);
|
||||
make.right.mas_equalTo(bottomView.mas_right).with.offset(- kHalfMargin);
|
||||
make.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
bookDetailLabel = [[YYLabel alloc] init];
|
||||
bookDetailLabel.textColor = kGrayTextColor;
|
||||
bookDetailLabel.textAlignment = NSTextAlignmentLeft;
|
||||
bookDetailLabel.textVerticalAlignment = YYTextVerticalAlignmentCenter;
|
||||
bookDetailLabel.numberOfLines = 2;
|
||||
bookDetailLabel.font = kFont13;
|
||||
[self addSubview:bookDetailLabel];
|
||||
|
||||
[bookDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(titleLabel.mas_left);
|
||||
make.top.mas_equalTo(titleLabel.mas_bottom);
|
||||
make.bottom.mas_equalTo(bookImageView.mas_bottom).with.offset(- kHalfMargin);
|
||||
make.right.mas_equalTo(titleLabel.mas_right);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
- (void)setProductionModel:(TFProductionModel *)productionModel
|
||||
{
|
||||
_productionModel = productionModel;
|
||||
|
||||
if (productionModel.vertical_cover.length > 0) {
|
||||
bookImageView.coverImageUrl = productionModel.vertical_cover;
|
||||
} else if (productionModel.horizontal_cover.length > 0) {
|
||||
bookImageView.coverImageUrl = productionModel.horizontal_cover;
|
||||
} else {
|
||||
bookImageView.coverImageUrl = productionModel.cover;
|
||||
}
|
||||
|
||||
titleLabel.text = productionModel.name?:@"";
|
||||
|
||||
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString: productionModel.production_descirption?:@""];
|
||||
attributedString.lineSpacing = 3;
|
||||
attributedString.font = kFont13;
|
||||
attributedString.color = kGrayTextColor;
|
||||
bookDetailLabel.attributedText = attributedString;
|
||||
}
|
||||
|
||||
- (void)setProductionType:(TFProductionType)productionType
|
||||
{
|
||||
_productionType = productionType;
|
||||
bookImageView.productionType = productionType;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// TFBookRackHeaderView.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#define Rack_Header_Height (kGeometricHeight(SCREEN_WIDTH, 3, 1) + kLabelHeight + kMargin + kQuarterMargin)
|
||||
#define Rack_Header_Height_NoRecommend (kGeometricHeight(SCREEN_WIDTH, 3, 1) + kQuarterMargin)
|
||||
|
||||
typedef void(^RecommendBannerClickBlock)(NSInteger production_id);
|
||||
|
||||
typedef void(^AdBannerClickBlock)(NSString *title, NSString *content);
|
||||
|
||||
@interface TFBookRackHeaderView : UIView
|
||||
|
||||
@property (nonatomic, assign) TFProductionType productionType;
|
||||
|
||||
@property (nonatomic, strong) TFBookRackModel *rackModel;
|
||||
|
||||
@property (nonatomic, copy) RecommendBannerClickBlock recommendBannerClickBlock;
|
||||
|
||||
@property (nonatomic, copy) AdBannerClickBlock adBannerClickBlock;
|
||||
|
||||
@property (nonatomic, copy) void (^collectionClickBlock)(void);
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,221 @@
|
||||
//
|
||||
// TFBookRackHeaderView.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/1.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookRackHeaderView.h"
|
||||
#import "TFBookRackHeaderCell.h"
|
||||
|
||||
#import "TFSignModel.h"
|
||||
|
||||
#import "WXYZ_AnnouncementView.h"
|
||||
#import "YJBannerView.h"
|
||||
#import "TFSignAlertView.h"
|
||||
|
||||
@interface TFBookRackHeaderView () <YJBannerViewDelegate, YJBannerViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) YJBannerView *recommendBannerView;
|
||||
@property (nonatomic ,strong) WXYZ_AnnouncementView *announceBannerView;
|
||||
@property (nonatomic ,strong) NSMutableArray *bannerArray;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookRackHeaderView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.clipsToBounds = YES;
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
[self createSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.backgroundColor = kWhiteColor;
|
||||
|
||||
[self addSubview:self.recommendBannerView];
|
||||
[self.recommendBannerView reloadData];
|
||||
|
||||
[self addSubview:self.announceBannerView];
|
||||
|
||||
[self.announceBannerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kHalfMargin + kQuarterMargin);
|
||||
make.top.mas_equalTo(self.recommendBannerView.mas_bottom).with.offset(kHalfMargin);
|
||||
make.right.mas_equalTo(self.recommendBannerView.mas_right).with.offset(- kHalfMargin - kQuarterMargin);
|
||||
make.height.mas_equalTo(kLabelHeight);
|
||||
}];
|
||||
|
||||
#if TF_Sign_Mode
|
||||
TFButton *collectionButton = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:TFLocalizedString(@"签到") buttonImageName:@"public_sign_in" buttonIndicator:TFButtonIndicatorTitleRight];
|
||||
collectionButton.graphicDistance = 5;
|
||||
collectionButton.buttonImageScale = 0.45;
|
||||
collectionButton.buttonTintColor = kMainColor;
|
||||
[collectionButton addTarget:self action:@selector(rackCollectionClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:collectionButton];
|
||||
|
||||
[collectionButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.announceBannerView.mas_right).with.offset(- kQuarterMargin);
|
||||
make.centerY.mas_equalTo(self.announceBannerView.mas_centerY);
|
||||
make.height.mas_equalTo(self.announceBannerView.mas_height);
|
||||
make.width.mas_equalTo(80);
|
||||
}];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (WXYZ_AnnouncementView *)announceBannerView
|
||||
{
|
||||
if (!_announceBannerView) {
|
||||
WS(weakSelf)
|
||||
_announceBannerView = [[WXYZ_AnnouncementView alloc] init];
|
||||
_announceBannerView.layer.cornerRadius = kLabelHeight / 2;
|
||||
_announceBannerView.backgroundColor = kGrayViewColor;
|
||||
_announceBannerView.clickAdBlock = ^(NSString *path, NSUInteger index) {
|
||||
if (weakSelf.adBannerClickBlock) {
|
||||
TFAnnouncementModel *t_ann = [weakSelf.rackModel.announcement objectAtIndex:index];
|
||||
weakSelf.adBannerClickBlock(t_ann.title, t_ann.content);
|
||||
}
|
||||
};
|
||||
}
|
||||
return _announceBannerView;
|
||||
}
|
||||
|
||||
- (YJBannerView *)recommendBannerView
|
||||
{
|
||||
if (!_recommendBannerView) {
|
||||
_recommendBannerView = [YJBannerView bannerViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kGeometricHeight(SCREEN_WIDTH, 3, 1)) dataSource:self delegate:self emptyImage:nil placeholderImage:nil selectorString:NSStringFromSelector(@selector(setImageWithURL:placeholder:))];
|
||||
_recommendBannerView.backgroundColor = kWhiteColor;
|
||||
_recommendBannerView.repeatCount = 9999;
|
||||
_recommendBannerView.autoDuration = 5.0f;
|
||||
_recommendBannerView.pageControlAliment = PageControlAlimentRight;
|
||||
_recommendBannerView.pageControlStyle = PageControlCustom;
|
||||
_recommendBannerView.pageControlDotSize = CGSizeMake(5, 5);
|
||||
_recommendBannerView.pageControlBottomMargin = 20;
|
||||
_recommendBannerView.pageControlHorizontalEdgeMargin = 25;
|
||||
_recommendBannerView.pageControlPadding = 3;
|
||||
_recommendBannerView.customPageControlHighlightImage = [UIImage imageNamed:@"pageControl_H"];
|
||||
_recommendBannerView.customPageControlNormalImage = [UIImage imageNamed:@"pageControl_N"];
|
||||
}
|
||||
return _recommendBannerView;
|
||||
}
|
||||
|
||||
- (NSMutableArray *)bannerArray
|
||||
{
|
||||
if (!_bannerArray) {
|
||||
_bannerArray = [NSMutableArray array];
|
||||
[_bannerArray addObject:@""];
|
||||
}
|
||||
return _bannerArray;
|
||||
}
|
||||
|
||||
// 将网络图片或者本地图片 或者混合数组
|
||||
- (NSArray *)bannerViewImages:(YJBannerView *)bannerView
|
||||
{
|
||||
return self.bannerArray;
|
||||
}
|
||||
|
||||
- (NSArray *)bannerViewRegistCustomCellClass:(YJBannerView *)bannerView
|
||||
{
|
||||
return @[[TFBookRackHeaderCell class]];
|
||||
}
|
||||
|
||||
/** 根据 Index 选择使用哪个 reuseIdentifier */
|
||||
- (Class)bannerView:(YJBannerView *)bannerView reuseIdentifierForIndex:(NSInteger)index
|
||||
{
|
||||
return [TFBookRackHeaderCell class];
|
||||
}
|
||||
|
||||
/** 自定义 View 刷新数据或者其他配置 */
|
||||
- (UICollectionViewCell *)bannerView:(YJBannerView *)bannerView customCell:(UICollectionViewCell *)customCell index:(NSInteger)index
|
||||
{
|
||||
TFBookRackHeaderCell *cell = (TFBookRackHeaderCell *)customCell;
|
||||
cell.productionModel = [_rackModel.recommendList objectOrNilAtIndex:index];
|
||||
cell.productionType = self.productionType;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
// 代理方法 点击了哪个bannerView 的 第几个元素
|
||||
- (void)bannerView:(YJBannerView *)bannerView didSelectItemAtIndex:(NSInteger)index
|
||||
{
|
||||
if ([[self.bannerArray objectAtIndex:index] length] > 0) {
|
||||
WS(weakSelf)
|
||||
if (self.recommendBannerClickBlock) {
|
||||
self.recommendBannerClickBlock([weakSelf.rackModel.recommendList objectAtIndex:index].production_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)rackCollectionClick
|
||||
{
|
||||
if (!TFUserInfoManager.isLogin) {
|
||||
|
||||
[TFLoginOptionsViewController presentLoginView:nil];
|
||||
|
||||
return;
|
||||
}
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Sign_Click parameters:nil model:TFSignModel.class success:^(BOOL isSuccess, TFSignModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (isSuccess) {
|
||||
if ((t_model.book.count > 0 || t_model.comic.count > 0) && t_model.award.length > 0 && t_model.tomorrow_award.length > 0) {
|
||||
|
||||
NSMutableArray *t_arr = [NSMutableArray array];
|
||||
|
||||
for (TFProductionModel *t in t_model.book) {
|
||||
t.productionType = TFProductionTypeNovel;
|
||||
[t_arr addObject:t];
|
||||
}
|
||||
|
||||
for (TFProductionModel *t in t_model.comic) {
|
||||
t.productionType = TFProductionTypeComic;
|
||||
[t_arr addObject:t];
|
||||
}
|
||||
|
||||
for (TFProductionModel *t in t_model.audio) {
|
||||
t.productionType = TFProductionTypeAudio;
|
||||
[t_arr addObject:t];
|
||||
}
|
||||
|
||||
TFSignAlertView *alert = [[TFSignAlertView alloc] init];
|
||||
alert.alertTitle = t_model.award;
|
||||
alert.alertDetailContent = t_model.tomorrow_award;
|
||||
alert.bookList = [t_arr copy];
|
||||
[alert showAlertView];
|
||||
}
|
||||
} else {
|
||||
!weakSelf.collectionClickBlock ?: weakSelf.collectionClickBlock();
|
||||
}
|
||||
} failure:nil];
|
||||
}
|
||||
|
||||
- (void)setRackModel:(TFBookRackModel *)rackModel
|
||||
{
|
||||
if (_rackModel != rackModel) {
|
||||
_rackModel = rackModel;
|
||||
// 公告
|
||||
if (rackModel.announcement.count > 0) {
|
||||
self.announceBannerView.modelArr = rackModel.announcement;
|
||||
self.announceBannerView.hidden = NO;
|
||||
} else {
|
||||
self.announceBannerView.hidden = YES;
|
||||
}
|
||||
|
||||
// 设置推荐
|
||||
[self.bannerArray removeAllObjects];
|
||||
|
||||
for (TFProductionModel *model in rackModel.recommendList) {
|
||||
NSString *imageURL = (model.vertical_cover.length > 0?model.vertical_cover:model.horizontal_cover)?:model.cover?:@"";
|
||||
|
||||
[self.bannerArray addObject:imageURL];
|
||||
}
|
||||
|
||||
[self.recommendBannerView reloadData];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// TFReadNovelBackgroundController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFReadNovelBackgroundController : UIViewController
|
||||
|
||||
- (void)updateWithViewController:(UIViewController *)viewController;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// TFReadNovelBackgroundController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFReadNovelBackgroundController.h"
|
||||
#import "TFReaderSettingHelper.h"
|
||||
#import "TFAdvertisementManager.h"
|
||||
|
||||
@interface TFReadNovelBackgroundController ()
|
||||
|
||||
@property (nonatomic ,weak) UIImageView *backgroundImageView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFReadNovelBackgroundController
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
[self createSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.view.backgroundColor = [[TFReaderSettingHelper sharedManager] getReaderBackgroundColor];
|
||||
|
||||
UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
|
||||
backgroundImageView.backgroundColor = self.view.backgroundColor;
|
||||
self.backgroundImageView = backgroundImageView;
|
||||
[self.view addSubview:backgroundImageView];
|
||||
}
|
||||
|
||||
- (void)updateWithViewController:(UIViewController *)viewController
|
||||
{
|
||||
self.backgroundImageView.frame = viewController.view.bounds;
|
||||
self.backgroundImageView.image = [self captureView:viewController.view];
|
||||
self.backgroundImageView.alpha = 0.6;
|
||||
}
|
||||
|
||||
- (UIImage *)captureView:(UIView *)view
|
||||
{
|
||||
UIImage * __block image = nil;
|
||||
kCodeSync({
|
||||
CGRect rect = view.bounds;
|
||||
UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0f);
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
|
||||
CGAffineTransform transform = CGAffineTransformMake(-1.0, 0.0, 0.0, 1.0, rect.size.width, 0.0);
|
||||
CGContextConcatCTM(context,transform);
|
||||
[view.layer renderInContext:context];
|
||||
image = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
});
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
@end
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// TFReadNovelTextController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFReadNovelTextController : UIViewController
|
||||
|
||||
@property (nonatomic ,copy) NSAttributedString *contentString;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+269
@@ -0,0 +1,269 @@
|
||||
//
|
||||
// TFReadNovelTextController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFReadNovelTextController.h"
|
||||
#import "TYAttributedLabel.h"
|
||||
#import "TFReaderBookManager.h"
|
||||
#import "TFReaderSettingHelper.h"
|
||||
#import "WXYZ_BatteryView.h"
|
||||
#import "TFEmptyViewHeader.h"
|
||||
#import "WXYZ_BookReaderMenuPayView.h"
|
||||
#import "NSAttributedString+TReaderPage.h"
|
||||
#import "TFNetworkManager.h"
|
||||
|
||||
#import "TFReaderBookManager.h"
|
||||
|
||||
@interface TFReadNovelTextController ()
|
||||
{
|
||||
UILabel *emptyTitleLabel;
|
||||
UIButton *emptyButton;
|
||||
}
|
||||
|
||||
@property (nonatomic ,strong) UILabel *chapterTitleLabel;
|
||||
|
||||
@property (nonatomic ,strong) UILabel *bookNameLabel;
|
||||
|
||||
@property (nonatomic ,strong) UILabel *pageNumberLabel;
|
||||
|
||||
@property (nonatomic ,strong) TYAttributedLabel *chapterContentLabel;
|
||||
|
||||
@property (nonatomic ,strong) WXYZ_BatteryView *battery;
|
||||
|
||||
@property (nonatomic ,strong) WXYZ_BookReaderMenuPayView *payView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFReadNovelTextController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.view.backgroundColor = [[TFReaderSettingHelper sharedManager] getReaderBackgroundColor];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadFrame) name:Notification_Check_Setting_Update object:nil];
|
||||
|
||||
WS(weakSelf)
|
||||
[TFReaderSettingHelper sharedManager].readerBackgroundViewChanged = ^() {
|
||||
[weakSelf reloadSubviews];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:NSNotification_Retry_Chapter object:nil];
|
||||
};
|
||||
}
|
||||
|
||||
- (void)setContentString:(NSAttributedString *)contentString
|
||||
{
|
||||
if ([contentString.string isEqualToString:k_Chapter_RequstFail] || !contentString) {
|
||||
[self createEmptyView];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:NSNotification_EmptyView_Changed object:@1];
|
||||
return;
|
||||
}
|
||||
[self reloadSubviews];
|
||||
|
||||
if ([[TFReaderBookManager sharedManager] isPreviewChapter] && contentString.length > 1) {
|
||||
CGSize size = CGSizeMake(CGRectGetWidth(self.chapterContentLabel.bounds), CGRectGetHeight(self.chapterContentLabel.bounds) / 2.0);
|
||||
NSArray<NSValue *> *t_arr = [contentString pageRangeArrayWithConstrainedToSize:size];
|
||||
if (t_arr.count > 0) {
|
||||
NSRange range = [t_arr.firstObject rangeValue];
|
||||
contentString = [contentString attributedSubstringFromRange:range];
|
||||
}
|
||||
|
||||
[self payView];
|
||||
} else {
|
||||
TFReaderBookManager *manager = [TFReaderBookManager sharedManager];
|
||||
NSString *chapter_id = [NSString stringWithFormat:@"%zd", manager.chapter_id];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Production_Pay_Success object:@[chapter_id]];
|
||||
_payView.hidden = YES;
|
||||
}
|
||||
|
||||
_contentString = contentString;
|
||||
self.chapterContentLabel.attributedText = contentString;
|
||||
|
||||
// 总章节页数
|
||||
NSUInteger totalChapterPagerCount = [[TFReaderBookManager sharedManager] totalChapterPagerCount];
|
||||
NSUInteger readedPagerCount = ([[TFReaderBookManager sharedManager] currentPagerIndex] + 1) + (([[TFReaderBookManager sharedManager] currentChapterPagerCount]) * ([[TFReaderBookManager sharedManager] currentChapterIndex]));
|
||||
|
||||
float progressValue = [[NSNumber numberWithUnsignedInteger:readedPagerCount] floatValue] / [[NSNumber numberWithUnsignedInteger:totalChapterPagerCount] floatValue] * 100;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.pageNumberLabel.text = [NSString stringWithFormat:@"%.1lf%@", progressValue < 0.1?0.1f:progressValue, @"%"];
|
||||
});
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:NSNotification_EmptyView_Changed object:@0];
|
||||
}
|
||||
|
||||
- (void)reloadSubviews
|
||||
{
|
||||
kCodeSync({
|
||||
self.view.backgroundColor = [[TFReaderSettingHelper sharedManager] getReaderBackgroundColor];
|
||||
|
||||
UIColor *textColor = [[TFReaderSettingHelper sharedManager] getReaderTextColor];
|
||||
UIColor *titleTextColor = [[TFReaderSettingHelper sharedManager] getReaderTitleTextColor];
|
||||
|
||||
self.chapterContentLabel.font = [UIFont systemFontOfSize:[[TFReaderSettingHelper sharedManager] getReaderFontSize]];
|
||||
self.chapterContentLabel.linesSpacing = [[TFReaderSettingHelper sharedManager] getReaderLinesSpacing];
|
||||
|
||||
self.bookNameLabel.text = [[TFReaderBookManager sharedManager] getBookName];
|
||||
self.bookNameLabel.textColor = titleTextColor;
|
||||
|
||||
self.chapterTitleLabel.text = [[TFReaderBookManager sharedManager] getChapterTitle];
|
||||
self.chapterTitleLabel.textColor = titleTextColor;
|
||||
|
||||
self.chapterContentLabel.textColor = textColor;
|
||||
|
||||
self.battery.batteryTintColor = titleTextColor;
|
||||
|
||||
self.pageNumberLabel.textColor = [[TFReaderSettingHelper sharedManager] getReaderTitleTextColor];
|
||||
self.pageNumberLabel.hidden = NO;
|
||||
|
||||
emptyButton.hidden = YES;
|
||||
emptyTitleLabel.hidden = YES;
|
||||
|
||||
if ([TFReaderBookManager sharedManager].currentChapterIndex == 0 && [TFReaderBookManager sharedManager].currentPagerIndex == 0) {
|
||||
self.chapterTitleLabel.hidden = YES;
|
||||
self.battery.hidden = YES;
|
||||
self.pageNumberLabel.hidden = YES;
|
||||
self.bookNameLabel.hidden = YES;
|
||||
} else {
|
||||
self.chapterTitleLabel.hidden = NO;
|
||||
self.battery.hidden = NO;
|
||||
self.pageNumberLabel.hidden = NO;
|
||||
self.bookNameLabel.hidden = NO;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)reloadFrame
|
||||
{
|
||||
[self reloadSubviews];
|
||||
_pageNumberLabel.frame = CGRectMake(SCREEN_WIDTH / 2, [[TFReaderSettingHelper sharedManager] getReaderViewBottom] + kHalfMargin, (SCREEN_WIDTH - 2 * kMargin) / 2, kMargin);
|
||||
_battery.frame = CGRectMake(kMargin, [[TFReaderSettingHelper sharedManager] getReaderViewBottom] + kHalfMargin, SCREEN_WIDTH / 2, kMargin);
|
||||
_bookNameLabel.frame = CGRectMake(SCREEN_WIDTH / 3, [[TFReaderSettingHelper sharedManager] getReaderViewBottom] + kHalfMargin, SCREEN_WIDTH / 3, kMargin);
|
||||
_chapterContentLabel.frame = [[TFReaderSettingHelper sharedManager] getReaderViewFrame];
|
||||
}
|
||||
|
||||
- (UILabel *)pageNumberLabel
|
||||
{
|
||||
if (!_pageNumberLabel) {
|
||||
_pageNumberLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 2, [[TFReaderSettingHelper sharedManager] getReaderViewBottom] + kHalfMargin, (SCREEN_WIDTH - 2 * kMargin) / 2, kMargin)];
|
||||
_pageNumberLabel.text = @"0.1%";
|
||||
_pageNumberLabel.font = kFont12;
|
||||
_pageNumberLabel.hidden = YES;
|
||||
_pageNumberLabel.textAlignment = NSTextAlignmentRight;
|
||||
[self.view addSubview:_pageNumberLabel];
|
||||
}
|
||||
return _pageNumberLabel;
|
||||
}
|
||||
|
||||
- (WXYZ_BatteryView *)battery
|
||||
{
|
||||
if (!_battery) {
|
||||
_battery = [[WXYZ_BatteryView alloc] initWithFrame:CGRectMake(kMargin, [[TFReaderSettingHelper sharedManager] getReaderViewBottom] + kHalfMargin, SCREEN_WIDTH / 2, kMargin)];
|
||||
[self.view addSubview:_battery];
|
||||
}
|
||||
return _battery;
|
||||
}
|
||||
|
||||
- (UILabel *)bookNameLabel
|
||||
{
|
||||
if (!_bookNameLabel) {
|
||||
_bookNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 3, [[TFReaderSettingHelper sharedManager] getReaderViewBottom] + kHalfMargin, SCREEN_WIDTH / 3, kMargin)];
|
||||
_bookNameLabel.font = kFont12;
|
||||
_bookNameLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[self.view addSubview:_bookNameLabel];
|
||||
}
|
||||
return _bookNameLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)chapterTitleLabel
|
||||
{
|
||||
if (!_chapterTitleLabel) {
|
||||
_chapterTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(kMargin, kMargin + PUB_NAVBAR_OFFSET, (SCREEN_WIDTH - 2 * kMargin) / 2, kMargin)];
|
||||
_chapterTitleLabel.font = kFont12;
|
||||
_chapterTitleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
[self.view addSubview:_chapterTitleLabel];
|
||||
}
|
||||
return _chapterTitleLabel;
|
||||
}
|
||||
|
||||
- (TYAttributedLabel *)chapterContentLabel
|
||||
{
|
||||
if (!_chapterContentLabel) {
|
||||
_chapterContentLabel = nil;
|
||||
kCodeSync({
|
||||
_chapterContentLabel = [[TYAttributedLabel alloc] init];
|
||||
_chapterContentLabel.frame = [[TFReaderSettingHelper sharedManager] getReaderViewFrame];
|
||||
_chapterContentLabel.font = [UIFont systemFontOfSize:[[TFReaderSettingHelper sharedManager] getReaderFontSize]];
|
||||
_chapterContentLabel.backgroundColor = [UIColor clearColor];
|
||||
_chapterContentLabel.linesSpacing = [[TFReaderSettingHelper sharedManager] getReaderLinesSpacing];
|
||||
_chapterContentLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
||||
[self.view addSubview:_chapterContentLabel];
|
||||
});
|
||||
}
|
||||
return _chapterContentLabel;
|
||||
}
|
||||
|
||||
- (WXYZ_BookReaderMenuPayView *)payView
|
||||
{
|
||||
if (!_payView) {
|
||||
_payView = [[WXYZ_BookReaderMenuPayView alloc] init];
|
||||
[self.view addSubview:_payView];
|
||||
}
|
||||
_payView.hidden = NO;
|
||||
return _payView;
|
||||
}
|
||||
|
||||
- (void)createEmptyView
|
||||
{
|
||||
if (!emptyTitleLabel) {
|
||||
emptyTitleLabel = [[UILabel alloc] init];
|
||||
emptyTitleLabel.textColor = [TFReaderSettingHelper sharedManager].getReaderTextColor;
|
||||
emptyTitleLabel.font = kFont16;
|
||||
emptyTitleLabel.text = TFLocalizedString(@"内容加载失败");
|
||||
emptyTitleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[self.view addSubview:emptyTitleLabel];
|
||||
|
||||
[emptyTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.view.mas_centerY).with.offset(- kHalfMargin);
|
||||
make.left.mas_equalTo(0);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(kLabelHeight);
|
||||
}];
|
||||
}
|
||||
|
||||
if (!emptyButton) {
|
||||
emptyButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
emptyButton.backgroundColor = [UIColor clearColor];
|
||||
emptyButton.layer.cornerRadius = 15;
|
||||
emptyButton.layer.borderColor = [TFReaderSettingHelper sharedManager].getReaderTextColor.CGColor;
|
||||
emptyButton.layer.borderWidth = 1.0;
|
||||
[emptyButton setTitle:TFLocalizedString(@"重试") forState:UIControlStateNormal];
|
||||
[emptyButton setTitleColor:[TFReaderSettingHelper sharedManager].getReaderTextColor forState:UIControlStateNormal];
|
||||
[emptyButton.titleLabel setFont:kFont12];
|
||||
[emptyButton addTarget:self action:@selector(retryClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.view addSubview:emptyButton];
|
||||
|
||||
[emptyButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.view.mas_centerX);
|
||||
make.top.mas_equalTo(emptyTitleLabel.mas_bottom);
|
||||
make.width.mas_equalTo(80);
|
||||
make.height.mas_equalTo(kLabelHeight);
|
||||
}];
|
||||
}
|
||||
|
||||
emptyButton.hidden = NO;
|
||||
emptyTitleLabel.hidden = NO;
|
||||
}
|
||||
|
||||
- (void)retryClick:(UIButton *)sender
|
||||
{
|
||||
if (![TFNetworkManager networkingStatus] || [TFNetworkManager currentNetworkStatus] == kCTCellularDataRestrictedStateUnknown) {
|
||||
return;
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:NSNotification_Retry_Chapter object:@"1"];
|
||||
}
|
||||
|
||||
@end
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// TFReadNovelViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TFProductionModel;
|
||||
@interface TFReadNovelViewController : TFBasicViewController
|
||||
|
||||
- (instancetype)initWithSpecificIndex:(NSInteger)specificIndex chapterSort:(NSInteger)chapterSort;
|
||||
|
||||
- (instancetype)initWithChapterIndex:(NSInteger)specifiedChapter;
|
||||
|
||||
@property (nonatomic ,assign) NSInteger book_id;
|
||||
|
||||
@property (nonatomic ,strong) TFProductionModel *bookModel;
|
||||
|
||||
/// 跳转到指定章节
|
||||
@property (nonatomic ,assign) NSInteger specifiedChapter;
|
||||
|
||||
/// 跳转到指定页码
|
||||
@property (nonatomic ,assign) NSInteger specifiedPage;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+1228
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,116 @@
|
||||
//
|
||||
// TFReaderBookManager.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFReaderBookManager : NSObject
|
||||
// 当前阅读章节
|
||||
@property (nonatomic, assign) NSInteger currentChapterIndex;
|
||||
|
||||
// 当前页数
|
||||
@property (nonatomic, assign) NSInteger currentPagerIndex;
|
||||
|
||||
// 书籍id
|
||||
@property (nonatomic, assign) NSInteger book_id;
|
||||
|
||||
// 章节id
|
||||
@property (nonatomic, assign) NSInteger chapter_id;
|
||||
|
||||
// 下一页
|
||||
@property (nonatomic, assign) NSInteger nextPagerIndex;
|
||||
|
||||
// 上一页
|
||||
@property (nonatomic, assign) NSInteger previousPagerIndex;
|
||||
|
||||
// 当前章节页数
|
||||
@property (nonatomic, assign, readonly) NSInteger currentChapterPagerCount;
|
||||
|
||||
// 总章节数
|
||||
@property (nonatomic, assign, readonly) NSInteger totalChapterCount;
|
||||
|
||||
// 书籍总页数
|
||||
@property (nonatomic, assign, readonly) NSInteger totalChapterPagerCount;
|
||||
|
||||
@property (nonatomic, strong, readonly) TFProductionChapterModel *chapterModel;
|
||||
|
||||
@property (nonatomic, strong) TFProductionModel *bookModel;
|
||||
|
||||
/// 章节末尾投票数
|
||||
@property (nonatomic, copy, nullable) NSString *reward_num;
|
||||
|
||||
/// 章节末尾月票数
|
||||
@property (nonatomic, copy, nullable) NSString *ticket_num;
|
||||
|
||||
/// 书签标记位置
|
||||
@property (nonatomic, assign) NSInteger markIndex;
|
||||
|
||||
interface_singleton
|
||||
|
||||
// 获取书籍名称
|
||||
- (NSString *)getBookName;
|
||||
|
||||
// 获取章节名称
|
||||
- (NSString *)getChapterTitle;
|
||||
|
||||
// 是否是预览章节
|
||||
- (BOOL)isPreviewChapter;
|
||||
|
||||
// 是否有下章节
|
||||
- (BOOL)haveNextChapter;
|
||||
|
||||
// 是否有上章节
|
||||
- (BOOL)havePreChapter;
|
||||
|
||||
// 是否是最后一章最后一页
|
||||
- (BOOL)isTheLastPager;
|
||||
|
||||
// 是否是第一章第一页
|
||||
- (BOOL)isTheFormerPager;
|
||||
|
||||
// 是否有下一页
|
||||
- (BOOL)haveNextPager;
|
||||
|
||||
// 上一章是否有缓存
|
||||
- (BOOL)havePreCache;
|
||||
|
||||
// 下一章是否有缓存
|
||||
- (BOOL)haveNextCache;
|
||||
|
||||
// 获取下一页
|
||||
- (void)getNextPagerAttributedText:(void(^ _Nullable)(NSAttributedString *content))complete;
|
||||
|
||||
// 获取上一页
|
||||
- (void)getPrePagerAttributedText:(void(^ _Nullable)(NSAttributedString * _Nullable content))complete;
|
||||
|
||||
// 获取某一章节某一页
|
||||
- (void)getPagerAttributedTextWithChapterIndex:(NSInteger)chapterIndex pagerIndex:(NSInteger)pageIndex completionHandler:(void(^)(NSAttributedString *content))completionHandler;
|
||||
|
||||
// 获取某一章节全部内容
|
||||
- (void)getChapterTextWithBook_id:(NSInteger)book_id chapter_index:(NSInteger)chapter_index completionHandler:(void(^)(NSString *content))completionHandler;
|
||||
|
||||
// 书籍model请求
|
||||
- (void)requestBookModelWithBookId:(NSUInteger)book_id completionHandler:(void(^ _Nullable)(void))completionHandler;
|
||||
|
||||
// 获取章节所有内容
|
||||
- (NSString *)getChapterContent;
|
||||
|
||||
// 获取章节详细内容
|
||||
- (NSString *)getChapterDetailContent;
|
||||
|
||||
- (NSMutableArray *)chapterRangeArray;
|
||||
|
||||
// 预加载多个章节(不支持自动订阅 && 支持多章下载)
|
||||
- (void)downloadPrestrainChaptersWithProductionModel:(TFProductionModel *)productionModel production_id:(NSInteger)production_id chapter_id:(NSInteger)chapter_id prestrainNumber:(NSInteger)prestrainNumber;
|
||||
|
||||
// 预加载章节(支持自动订阅 && 仅支持单章下载)
|
||||
- (void)downloadPrestrainChapterWithProductionModel:(TFProductionModel *)productionModel production_id:(NSInteger)production_id chapter_id:(NSInteger)chapter_id completionHandler:(void(^ _Nullable)(NSString *chapterContentString, NSInteger production_id, NSInteger chapter_id))completionHandler;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,219 @@
|
||||
//
|
||||
// TFReaderSettingHelper.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(NSUInteger, TFReaderTransitionStyle) {
|
||||
|
||||
TFReaderTransitionStylePageCurl = 0,
|
||||
TFReaderTransitionStyleScroll = 1,
|
||||
TFReaderTransitionStyleCover = 2,
|
||||
TFReaderTransitionStyleNone = 3
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, TFReaderAutoReadState) {
|
||||
|
||||
TFReaderAutoReadStateStop = 0, // 停止
|
||||
TFReaderAutoReadStateStart = 1, // 开启
|
||||
TFReaderAutoReadStatePause = 2, // 暂停
|
||||
TFReaderAutoReadStateResume = 3, // 恢复
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, TFReaderLineSpacingState) {
|
||||
|
||||
TFReaderLineSpacingStateBig = 0,
|
||||
TFReaderLineSpacingStateMedium = 1,
|
||||
TFReaderLineSpacingStateSmall = 2
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, TFReaderPatternMode) {
|
||||
|
||||
TFReaderPatternModeDaytime = 0,
|
||||
TFReaderPatternModeNight = 1
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, TFReaderBackColorMode) {
|
||||
|
||||
TFReaderBackColorYellow,
|
||||
TFReaderBackColorGreen,
|
||||
TFReaderBackColorBlue,
|
||||
TFReaderBackColorPink,
|
||||
TFReaderBackColorWhite,
|
||||
TFReaderBackColorGray,
|
||||
TFReaderBackColorBlack
|
||||
};
|
||||
|
||||
static CGFloat line_spacing_small = 5.0f;
|
||||
static CGFloat line_spacing_medium = 10.0f;
|
||||
static CGFloat line_spacing_big = 20.0f;
|
||||
|
||||
typedef void(^ReaderFontChanged)(void);
|
||||
typedef void(^ReaderBackgroundViewChanged)(void);
|
||||
typedef void(^ReaderBrightnessChanged)(void);
|
||||
typedef void(^ReaderLinesSpacingChanged)(void);
|
||||
typedef void(^ReaderTransitionStyleChanged)(TFReaderTransitionStyle transitionStyle);
|
||||
typedef void(^ReaderAutoReaderStateChanged)(TFReaderAutoReadState state);
|
||||
typedef void(^ReaderAutoReadSpeedChanged)(NSInteger readSpeed);
|
||||
|
||||
@interface TFReaderSettingHelper : NSObject
|
||||
|
||||
// 字体改变
|
||||
@property (nonatomic, copy) ReaderFontChanged readerFontChanged;
|
||||
|
||||
// 背景改变
|
||||
@property (nonatomic, copy) ReaderBackgroundViewChanged readerBackgroundViewChanged;
|
||||
|
||||
// 亮度改变
|
||||
@property (nonatomic, copy) ReaderBrightnessChanged readerBrightnessChanged;
|
||||
|
||||
// 间距改变
|
||||
@property (nonatomic, copy) ReaderLinesSpacingChanged readerLinesSpacingChanged;
|
||||
|
||||
// 翻页样式改变
|
||||
@property (nonatomic, copy) ReaderTransitionStyleChanged readerTransitionStyleChanged;
|
||||
|
||||
// 自动阅读启动或者停止
|
||||
@property (nonatomic, copy) ReaderAutoReaderStateChanged readerAutoReaderStateChanged;
|
||||
|
||||
// 改变自动阅读时间
|
||||
@property (nonatomic, copy) ReaderAutoReadSpeedChanged readerAutoReadSpeedChanged;
|
||||
|
||||
/**
|
||||
单例方法
|
||||
|
||||
@return self
|
||||
*/
|
||||
interface_singleton
|
||||
|
||||
@property (nonatomic, assign) TFReaderAutoReadState state;
|
||||
|
||||
// 开启屏幕常亮
|
||||
- (void)openScreenKeep;
|
||||
|
||||
// 关闭屏幕常亮
|
||||
- (void)closeScreenKeep;
|
||||
|
||||
// 隐藏状态栏
|
||||
- (void)hiddenStatusBar;
|
||||
|
||||
// 显示状态栏
|
||||
- (void)showStatusBar;
|
||||
|
||||
/*
|
||||
Font
|
||||
*/
|
||||
|
||||
// 设置字号
|
||||
- (void)setReaderFontSize:(CGFloat)fontSize;
|
||||
|
||||
// 获取字号
|
||||
- (CGFloat)getReaderFontSize;
|
||||
|
||||
- (CGFloat)getReaderMinFontSize;
|
||||
|
||||
- (CGFloat)getReaderMaxFontSize;
|
||||
|
||||
// 设置行间距
|
||||
- (void)setReaderLinesSpacing:(CGFloat)linesSpacing;
|
||||
|
||||
// 获取行间距
|
||||
- (CGFloat)getReaderLinesSpacing;
|
||||
|
||||
// 获取行间距类型
|
||||
- (TFReaderLineSpacingState)getReaderLineSpacingState;
|
||||
|
||||
/*
|
||||
Frame
|
||||
*/
|
||||
|
||||
// 获取页面size
|
||||
- (CGSize)getReaderViewSize;
|
||||
|
||||
// 获取页面frame
|
||||
- (CGRect)getReaderViewFrame;
|
||||
|
||||
// 获取页面bottom
|
||||
- (CGFloat)getReaderViewBottom;
|
||||
|
||||
/*
|
||||
Color
|
||||
*/
|
||||
|
||||
// 设置背景色
|
||||
- (void)setReaderBackgroundColor:(TFReaderBackColorMode)colorMode;
|
||||
|
||||
// 获取背景色枚举值
|
||||
- (TFReaderBackColorMode)getReaderBackgroundColorMode;
|
||||
|
||||
// 获取背景色
|
||||
- (UIColor *)getReaderBackgroundColor;
|
||||
|
||||
// 背景颜色合集
|
||||
- (NSArray *)getReaderBackgroundColorModeArray;
|
||||
|
||||
// 获取字体颜色
|
||||
- (UIColor *)getReaderTextColor;
|
||||
|
||||
// 获取标题字体颜色
|
||||
- (UIColor *)getReaderTitleTextColor;
|
||||
|
||||
// 获取夜间模式状态
|
||||
- (TFReaderPatternMode)getNightModeState;
|
||||
|
||||
// 设置夜间模式状态
|
||||
- (void)setNightModeState:(TFReaderPatternMode)state;
|
||||
|
||||
|
||||
/*
|
||||
Brightness
|
||||
*/
|
||||
|
||||
// 获取屏幕亮度
|
||||
- (CGFloat)getBrightness;
|
||||
|
||||
// 设定屏幕亮度
|
||||
- (void)setBrightness:(CGFloat)brightness;
|
||||
|
||||
/*
|
||||
TransitionStyle
|
||||
*/
|
||||
// 设置翻页类型
|
||||
- (void)setTransitionStyle:(TFReaderTransitionStyle)transitionStyle;
|
||||
|
||||
// 获取翻页类型
|
||||
- (TFReaderTransitionStyle)getTransitionStyle;
|
||||
|
||||
/*
|
||||
RecordLocation
|
||||
*/
|
||||
// 获取记录章节
|
||||
- (NSInteger)getMemoryChapterIndexWithBook_id:(NSUInteger)book_id;
|
||||
|
||||
// 获取记录页数
|
||||
- (NSInteger)getMemoryPagerIndexWithBook_id:(NSUInteger)book_id;
|
||||
|
||||
// 记录章节 页数
|
||||
- (void)setLocationMemoryOfChapterIndex:(NSInteger)chapterIndex pagerIndex:(NSInteger)pagerIndex book_id:(NSUInteger)book_id;
|
||||
|
||||
/*
|
||||
设置阅读速度
|
||||
*/
|
||||
// 设置阅读速度
|
||||
- (void)setReadSpeed:(NSUInteger)animationDuration;
|
||||
|
||||
// 获取阅读速度
|
||||
- (NSUInteger)getReadSpeed;
|
||||
|
||||
// 开启或关闭自动阅读
|
||||
- (void)setAutoReaderState:(TFReaderAutoReadState)state;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,409 @@
|
||||
//
|
||||
// TFReaderSettingHelper.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFReaderSettingHelper.h"
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#define PUB_DEFAULT_READ_SPEED 10
|
||||
|
||||
#define PUB_MIN_READ_SPEED 5
|
||||
|
||||
#define PUB_MAX_READ_SPEED 60
|
||||
|
||||
@implementation TFReaderSettingHelper
|
||||
|
||||
implementation_singleton(TFReaderSettingHelper)
|
||||
|
||||
#pragma mark - Screen
|
||||
// 开启屏幕常亮
|
||||
- (void)openScreenKeep
|
||||
{
|
||||
[UIApplication sharedApplication].idleTimerDisabled = YES;
|
||||
}
|
||||
|
||||
// 关闭屏幕常亮
|
||||
- (void)closeScreenKeep
|
||||
{
|
||||
[UIApplication sharedApplication].idleTimerDisabled = NO;
|
||||
}
|
||||
|
||||
#pragma mark - Status
|
||||
- (void)hiddenStatusBar
|
||||
{
|
||||
[UIApplication sharedApplication].statusBarHidden = YES;
|
||||
}
|
||||
|
||||
- (void)showStatusBar
|
||||
{
|
||||
[UIApplication sharedApplication].statusBarHidden = NO;
|
||||
}
|
||||
|
||||
#pragma mark - Font
|
||||
|
||||
- (void)setReaderFontSize:(CGFloat)fontSize
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithFloat:fontSize] forKey:TF_READER_FONT];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
if (self.readerFontChanged) {
|
||||
self.readerFontChanged();
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)getReaderFontSize
|
||||
{
|
||||
CGFloat textFontSize = [[[NSUserDefaults standardUserDefaults] objectForKey:TF_READER_FONT] floatValue];
|
||||
|
||||
if (!textFontSize || textFontSize <= [self getReaderMinFontSize]) {
|
||||
return [self getReaderMinFontSize];
|
||||
}
|
||||
|
||||
if (textFontSize >= [self getReaderMaxFontSize]) {
|
||||
return [self getReaderMaxFontSize];
|
||||
}
|
||||
|
||||
return textFontSize;
|
||||
}
|
||||
|
||||
- (CGFloat)getReaderMinFontSize
|
||||
{
|
||||
return kFontSize15;
|
||||
}
|
||||
|
||||
- (CGFloat)getReaderMaxFontSize
|
||||
{
|
||||
return kFontSize30;
|
||||
}
|
||||
|
||||
// 设置行间距
|
||||
- (void)setReaderLinesSpacing:(CGFloat)linesSpacing
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithFloat:linesSpacing] forKey:TF_READER_LINESPACING];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
if (self.readerLinesSpacingChanged) {
|
||||
self.readerLinesSpacingChanged();
|
||||
}
|
||||
}
|
||||
|
||||
// 获取行间距
|
||||
- (CGFloat)getReaderLinesSpacing
|
||||
{
|
||||
CGFloat t_linesSpacing = [[[NSUserDefaults standardUserDefaults] objectForKey:TF_READER_LINESPACING] floatValue];
|
||||
if (t_linesSpacing == 0) {
|
||||
[self setReaderLinesSpacing:line_spacing_medium];
|
||||
return line_spacing_medium;
|
||||
}
|
||||
return t_linesSpacing;
|
||||
}
|
||||
|
||||
- (TFReaderLineSpacingState)getReaderLineSpacingState
|
||||
{
|
||||
CGFloat t_lineSpacing = [self getReaderLinesSpacing];
|
||||
if (t_lineSpacing == line_spacing_small) {
|
||||
return TFReaderLineSpacingStateSmall;
|
||||
} else if (t_lineSpacing == line_spacing_medium) {
|
||||
return TFReaderLineSpacingStateMedium;
|
||||
} else {
|
||||
return TFReaderLineSpacingStateBig;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Frame
|
||||
|
||||
- (CGSize)getReaderViewSize
|
||||
{
|
||||
return [self getReaderViewFrame].size;
|
||||
}
|
||||
|
||||
- (CGRect)getReaderViewFrame
|
||||
{
|
||||
|
||||
AppDelegate *appDelegate = (AppDelegate *)kRCodeSync([[UIApplication sharedApplication] delegate]);
|
||||
if (!appDelegate.checkSettingModel.ad_status_setting.chapter_read_bottom) {
|
||||
return CGRectMake(kMargin,
|
||||
2 * kMargin + PUB_NAVBAR_OFFSET + 10,
|
||||
SCREEN_WIDTH - 2 * kMargin,
|
||||
SCREEN_HEIGHT - 2 * kMargin - PUB_NAVBAR_OFFSET - PUB_TABBAR_OFFSET - 2 * kHalfMargin - kMargin);
|
||||
}
|
||||
return CGRectMake(kMargin,
|
||||
2 * kMargin + PUB_NAVBAR_OFFSET + 10,
|
||||
SCREEN_WIDTH - 2 * kMargin,
|
||||
SCREEN_HEIGHT - 2 * kMargin - PUB_NAVBAR_OFFSET - 2 * kHalfMargin - kMargin - PUB_TABBAR_HEIGHT - (is_iPhoneX?-kMargin:0));
|
||||
}
|
||||
|
||||
- (CGFloat)getReaderViewBottom
|
||||
{
|
||||
return [self getReaderViewFrame].origin.y + [self getReaderViewFrame].size.height;
|
||||
}
|
||||
|
||||
#pragma mark - Color
|
||||
|
||||
// 设置背景色
|
||||
- (void)setReaderBackgroundColor:(TFReaderBackColorMode)colorMode
|
||||
{
|
||||
if ([self getNightModeState] == TFReaderPatternModeNight) {
|
||||
return;
|
||||
}
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedInteger:colorMode] forKey:@"xtfei_back_color"];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
if ([self getNightModeState] == TFReaderPatternModeDaytime) {
|
||||
if (self.readerBackgroundViewChanged) {
|
||||
self.readerBackgroundViewChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取背景色枚举值
|
||||
- (TFReaderBackColorMode)getReaderBackgroundColorMode
|
||||
{
|
||||
if ([self getNightModeState] == TFReaderPatternModeNight) {
|
||||
return TFReaderBackColorBlack;
|
||||
}
|
||||
return [[[NSUserDefaults standardUserDefaults] objectForKey:@"xtfei_back_color"] integerValue];
|
||||
}
|
||||
|
||||
// 获取背景色
|
||||
- (UIColor *)getReaderBackgroundColor
|
||||
{
|
||||
return [UIColor colorWithPatternImage:[UIImage imageNamed:[[self getReaderBackgroundColorModeArray] objectAtIndex:[self getReaderBackgroundColorMode]]]];
|
||||
}
|
||||
|
||||
|
||||
- (NSArray *)getReaderBackgroundColorModeArray
|
||||
{
|
||||
return @[@"read_page_bg_yellow.png", @"read_page_bg_green.png", @"read_page_bg_blue.png", @"read_page_bg_pink.png", @"read_page_bg_white.png", @"read_page_bg_gray.png", @"read_page_bg_black.png"];
|
||||
}
|
||||
|
||||
// 获取字体颜色
|
||||
- (UIColor *)getReaderTextColor
|
||||
{
|
||||
switch ([self getReaderBackgroundColorMode]) {
|
||||
case TFReaderBackColorYellow:
|
||||
return kColorRGBA(92, 66, 45, 1);
|
||||
case TFReaderBackColorGreen:
|
||||
return kColorRGBA(69, 81, 72, 1);
|
||||
break;
|
||||
case TFReaderBackColorBlue:
|
||||
return kColorRGBA(50, 63, 74, 1);
|
||||
break;
|
||||
case TFReaderBackColorPink:
|
||||
return kColorRGBA(144, 38, 61, 1);
|
||||
break;
|
||||
case TFReaderBackColorWhite:
|
||||
return kBlackColor;
|
||||
break;
|
||||
case TFReaderBackColorGray:
|
||||
return kColorRGBA(159, 161, 163, 1);
|
||||
break;
|
||||
case TFReaderBackColorBlack:
|
||||
return kColorRGBA(127, 127, 127, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取标题字体颜色
|
||||
- (UIColor *)getReaderTitleTextColor
|
||||
{
|
||||
CGFloat alpha = 0.5;
|
||||
switch ([self getReaderBackgroundColorMode]) {
|
||||
case TFReaderBackColorYellow:
|
||||
return kColorRGBA(92, 66, 45, alpha);
|
||||
case TFReaderBackColorGreen:
|
||||
return kColorRGBA(69, 81, 72, alpha);
|
||||
break;
|
||||
case TFReaderBackColorBlue:
|
||||
return kColorRGBA(50, 63, 74, alpha);
|
||||
break;
|
||||
case TFReaderBackColorPink:
|
||||
return kColorRGBA(144, 38, 61, alpha);
|
||||
break;
|
||||
case TFReaderBackColorWhite:
|
||||
return kColorRGBA(33, 34, 35, alpha);
|
||||
break;
|
||||
case TFReaderBackColorGray:
|
||||
return kColorRGBA(159, 161, 163, alpha);
|
||||
break;
|
||||
case TFReaderBackColorBlack:
|
||||
return kColorRGBA(127, 127, 127, alpha);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取夜间模式状态
|
||||
- (TFReaderPatternMode)getNightModeState
|
||||
{
|
||||
NSInteger nightModeState = [[[NSUserDefaults standardUserDefaults] objectForKey:TF_READER_NIGHT_MODE] integerValue];
|
||||
if (nightModeState == 0) {
|
||||
return TFReaderPatternModeDaytime;
|
||||
}
|
||||
|
||||
return TFReaderPatternModeNight;
|
||||
}
|
||||
|
||||
// 设置夜间模式状态
|
||||
- (void)setNightModeState:(TFReaderPatternMode)state
|
||||
{
|
||||
if (state == TFReaderPatternModeDaytime) {
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedInteger:0] forKey:TF_READER_NIGHT_MODE];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
} else {
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedInteger:1] forKey:TF_READER_NIGHT_MODE];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
if (self.readerBackgroundViewChanged) {
|
||||
self.readerBackgroundViewChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Brightness
|
||||
// 获取屏幕亮度
|
||||
- (CGFloat)getBrightness
|
||||
{
|
||||
CGFloat brightness = [UIScreen mainScreen].brightness;
|
||||
return brightness;
|
||||
}
|
||||
|
||||
// 设定屏幕亮度
|
||||
- (void)setBrightness:(CGFloat)brightness
|
||||
{
|
||||
[[UIScreen mainScreen] setBrightness:brightness];
|
||||
if (self.readerBrightnessChanged) {
|
||||
self.readerBrightnessChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - TransitionStyle
|
||||
// 设置翻页类型
|
||||
- (void)setTransitionStyle:(TFReaderTransitionStyle)transitionStyle
|
||||
{
|
||||
NSUInteger t_tStyle = 0;
|
||||
switch (transitionStyle) {
|
||||
case TFReaderTransitionStylePageCurl:
|
||||
t_tStyle = 0;
|
||||
break;
|
||||
case TFReaderTransitionStyleScroll:
|
||||
t_tStyle = 1;
|
||||
break;
|
||||
case TFReaderTransitionStyleCover:
|
||||
t_tStyle = 2;
|
||||
break;
|
||||
case TFReaderTransitionStyleNone:
|
||||
t_tStyle = 3;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedInteger:t_tStyle] forKey:TF_READER_TRANSITION_STYLE];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
|
||||
if (self.readerTransitionStyleChanged) {
|
||||
self.readerTransitionStyleChanged(transitionStyle);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取翻页类型
|
||||
- (TFReaderTransitionStyle)getTransitionStyle
|
||||
{
|
||||
NSUInteger t_transitionStyle = [[[NSUserDefaults standardUserDefaults] objectForKey:TF_READER_TRANSITION_STYLE] unsignedIntegerValue];
|
||||
|
||||
switch (t_transitionStyle) {
|
||||
case 0:
|
||||
return TFReaderTransitionStylePageCurl;
|
||||
break;
|
||||
case 1:
|
||||
return TFReaderTransitionStyleScroll;
|
||||
break;
|
||||
case 2:
|
||||
return TFReaderTransitionStyleCover;
|
||||
break;
|
||||
case 3:
|
||||
return TFReaderTransitionStyleNone;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return t_transitionStyle;
|
||||
}
|
||||
|
||||
#pragma mark - RecordLocation
|
||||
// 获取记录章节
|
||||
- (NSInteger)getMemoryChapterIndexWithBook_id:(NSUInteger)book_id
|
||||
{
|
||||
NSUInteger t_chapterIndex = [[[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithFormat:@"%@_%@",TF_READER_CHAPTER_INDEX, [TFUtilsHelper formatStringWithInteger:book_id]]] integerValue];
|
||||
return t_chapterIndex;
|
||||
}
|
||||
|
||||
// 获取记录页数
|
||||
- (NSInteger)getMemoryPagerIndexWithBook_id:(NSUInteger)book_id
|
||||
{
|
||||
NSUInteger t_pagerIndex = [[[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithFormat:@"%@_%@",TF_READER_PAGER_INDEX, [TFUtilsHelper formatStringWithInteger:book_id]]] unsignedIntegerValue];
|
||||
return t_pagerIndex;
|
||||
}
|
||||
|
||||
// 记录章节 页数
|
||||
- (void)setLocationMemoryOfChapterIndex:(NSInteger)chapterIndex pagerIndex:(NSInteger)pagerIndex book_id:(NSUInteger)book_id
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedInteger:chapterIndex] forKey:[NSString stringWithFormat:@"%@_%@",TF_READER_CHAPTER_INDEX, [TFUtilsHelper formatStringWithInteger:book_id]]];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedInteger:pagerIndex] forKey:[NSString stringWithFormat:@"%@_%@",TF_READER_PAGER_INDEX, [TFUtilsHelper formatStringWithInteger:book_id]]];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
/*
|
||||
设置阅读速度
|
||||
*/
|
||||
// 设置阅读速度
|
||||
- (void)setReadSpeed:(NSUInteger)animationDuration
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInteger:animationDuration] forKey:TF_READER_READ_SPEED];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
|
||||
if (self.readerAutoReadSpeedChanged) {
|
||||
self.readerAutoReadSpeedChanged(animationDuration);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取阅读速度
|
||||
- (NSUInteger)getReadSpeed
|
||||
{
|
||||
NSInteger t_readSpeed = [[[NSUserDefaults standardUserDefaults] objectForKey:TF_READER_READ_SPEED] unsignedIntegerValue];
|
||||
|
||||
if (t_readSpeed == 0) {
|
||||
return PUB_DEFAULT_READ_SPEED;
|
||||
}
|
||||
|
||||
if (t_readSpeed < PUB_MIN_READ_SPEED) {
|
||||
return PUB_MIN_READ_SPEED;
|
||||
}
|
||||
|
||||
if (t_readSpeed > kFontSize30) {
|
||||
return PUB_MAX_READ_SPEED;
|
||||
}
|
||||
|
||||
return t_readSpeed;
|
||||
}
|
||||
|
||||
- (void)setAutoReaderState:(TFReaderAutoReadState)state
|
||||
{
|
||||
self.state = state;
|
||||
if (self.readerAutoReaderStateChanged) {
|
||||
self.readerAutoReaderStateChanged(state);
|
||||
}
|
||||
}
|
||||
@end
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFAnnouncementController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFAnnouncementController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,copy) NSString *titleText;
|
||||
@property (nonatomic ,copy) NSString *contentText;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// TFAnnouncementController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/14.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAnnouncementController.h"
|
||||
|
||||
@interface TFAnnouncementController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFAnnouncementController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
|
||||
}
|
||||
- (void)initialize
|
||||
{
|
||||
[self setNavigationBarTitle:self.titleText.length > 0 ? self.titleText:TFLocalizedString(@"公告栏")];
|
||||
self.view.backgroundColor = kWhiteColor;
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Hidden_Tabbar object:nil];
|
||||
}
|
||||
|
||||
- (void)viewDidDisappear:(BOOL)animated
|
||||
{
|
||||
[super viewDidDisappear:animated];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Show_Tabbar object:@"animation"];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
YYTextView *textView = [[YYTextView alloc] init];
|
||||
textView.editable = NO;
|
||||
textView.textColor = kBlackColor;
|
||||
textView.font = kMainFont;
|
||||
[self.view addSubview:textView];
|
||||
|
||||
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString: self.contentText.length > 0 ? self.contentText:@""];
|
||||
text.lineSpacing = 5;
|
||||
text.font = kMainFont;
|
||||
textView.attributedText = text;
|
||||
|
||||
[textView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kHalfMargin);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT + kHalfMargin);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH - kMargin);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - kHalfMargin);
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user