小说绘上架版本
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// TFDownloadCacheViewController.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
|
||||
|
||||
@interface TFDownloadCacheViewController : TFBasicViewController
|
||||
|
||||
// 只显示小说模块
|
||||
@property (nonatomic ,assign) BOOL onlyBookMode;
|
||||
|
||||
@property (nonatomic ,assign) BOOL pushFromReader;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
//
|
||||
// TFDownloadCacheViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFDownloadCacheViewController.h"
|
||||
#import "TFComicDownloadManagerController.h"
|
||||
#import "TFNovelDownloadManagerController.h"
|
||||
#import "WXYZ_AudioDownloadCacheViewController.h"
|
||||
|
||||
#import "SGPagingView.h"
|
||||
|
||||
@interface TFDownloadCacheViewController ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
|
||||
|
||||
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
|
||||
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentCollectionView;
|
||||
|
||||
@property (nonatomic ,weak) TFNovelDownloadManagerController *bookVC;
|
||||
|
||||
@property (nonatomic ,weak) TFComicDownloadManagerController *comicVC;
|
||||
|
||||
@property (nonatomic ,weak) WXYZ_AudioDownloadCacheViewController *audioVC;
|
||||
|
||||
@property (nonatomic ,weak) UIButton *rightButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFDownloadCacheViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubViews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
[self setStatusBarDefaultStyle];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Hidden_Tabbar object:@"1"];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"下载缓存")];
|
||||
[self hiddenSeparator];
|
||||
[self setNavigationBarRightButton:({
|
||||
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
self.rightButton = button;
|
||||
[button setTitle:TFLocalizedString(@"编辑") forState:UIControlStateNormal];
|
||||
button.titleLabel.font = kFont14;
|
||||
[button setTitleColor:kGrayTextColor forState:UIControlStateNormal];
|
||||
[button addTarget:self action:@selector(editEvent) forControlEvents:UIControlEventTouchUpInside];
|
||||
button.backgroundColor = [UIColor clearColor];
|
||||
button;
|
||||
})];
|
||||
[self.rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.view).offset(-kMargin);
|
||||
make.centerY.equalTo(self.navigationBar.navTitleLabel);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)editEvent {
|
||||
NSInteger index = self.pageTitleView.signBtnIndex;
|
||||
switch (index) {
|
||||
case 0:
|
||||
{
|
||||
BOOL isEdtting = !self.bookVC.editStateBlock ?: self.bookVC.editStateBlock();
|
||||
[self.rightButton setTitle:isEdtting ? TFLocalizedString(@"取消") : TFLocalizedString(@"编辑") forState:UIControlStateNormal];
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
BOOL isEdtting = !self.comicVC.editStateBlock ?: self.comicVC.editStateBlock();
|
||||
[self.rightButton setTitle:isEdtting ? TFLocalizedString(@"取消") : TFLocalizedString(@"编辑") forState:UIControlStateNormal];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
BOOL isEdtting = !self.audioVC.editStateBlock ?: self.audioVC.editStateBlock();
|
||||
[self.rightButton setTitle:isEdtting ? TFLocalizedString(@"取消") : TFLocalizedString(@"编辑") forState:UIControlStateNormal];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
#if TF_Enable_Book
|
||||
TFNovelDownloadManagerController *bookVC = [[TFNovelDownloadManagerController alloc] init];
|
||||
self.bookVC = bookVC;
|
||||
WS(weakSelf)
|
||||
bookVC.changeEditStateBlock = ^(BOOL status) {
|
||||
[weakSelf.rightButton setTitle:status ? TFLocalizedString(@"编辑") : TFLocalizedString(@"取消") forState:UIControlStateNormal];
|
||||
};
|
||||
bookVC.pushFromReader = self.pushFromReader;
|
||||
[self addChildViewController:bookVC];
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
TFComicDownloadManagerController *comicVC = [[TFComicDownloadManagerController alloc] init];
|
||||
self.comicVC = comicVC;
|
||||
comicVC.changeEditStateBlock = ^(BOOL status) {
|
||||
[weakSelf.rightButton setTitle:status ? TFLocalizedString(@"编辑") : TFLocalizedString(@"取消") forState:UIControlStateNormal];
|
||||
};
|
||||
[self addChildViewController:comicVC];
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
WXYZ_AudioDownloadCacheViewController *audioVC = [[WXYZ_AudioDownloadCacheViewController alloc] init];
|
||||
self.audioVC = audioVC;
|
||||
audioVC.changeEditStateBlock = ^(BOOL status) {
|
||||
[weakSelf.rightButton setTitle:status ? TFLocalizedString(@"编辑") : TFLocalizedString(@"取消") forState:UIControlStateNormal];
|
||||
};
|
||||
audioVC.productionType = TFProductionTypeAudio;
|
||||
[self addChildViewController:audioVC];
|
||||
#endif
|
||||
|
||||
NSMutableArray *titleArr = [NSMutableArray array];
|
||||
NSMutableArray *childArr = [NSMutableArray array];
|
||||
|
||||
if (self.onlyBookMode) {
|
||||
|
||||
#if TF_Enable_Book
|
||||
// [titleArr addObject:TFLocalizedString(@"小说")];
|
||||
[childArr addObject:bookVC];
|
||||
#endif
|
||||
|
||||
} else {
|
||||
for (NSNumber *siteNumber in [TFUtilsHelper getSiteState]) {
|
||||
#if TF_Enable_Book
|
||||
if ([siteNumber integerValue] == 1) {
|
||||
[titleArr addObject:TFLocalizedString(@"小说")];
|
||||
[childArr addObject:bookVC];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
if ([siteNumber integerValue] == 2) {
|
||||
[titleArr addObject:TFLocalizedString(@"漫画")];
|
||||
[childArr addObject:comicVC];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
if ([siteNumber integerValue] == 3) {
|
||||
[titleArr addObject:TFLocalizedString(@"听书")];
|
||||
[childArr addObject:audioVC];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if ([TFUtilsHelper getSiteState].count <= 1) {
|
||||
[titleArr removeAllObjects];
|
||||
[titleArr addObject:TFLocalizedString(@"下载")];
|
||||
}
|
||||
}
|
||||
|
||||
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT + self.pageViewHeight, SCREEN_WIDTH, SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - self.pageViewHeight) parentVC:self childVCs:childArr];
|
||||
_pageContentCollectionView.delegatePageContentCollectionView = self;
|
||||
[self.view addSubview:self.pageContentCollectionView];
|
||||
|
||||
if (titleArr.count > 0) {
|
||||
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, self.pageViewHeight) delegate:self titleNames:titleArr configure:self.pageConfigure];
|
||||
self.pageTitleView.backgroundColor = kWhiteColor;
|
||||
[self.view addSubview:_pageTitleView];
|
||||
} else {
|
||||
self.pageContentCollectionView.frame = CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex
|
||||
{
|
||||
[self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView index:(NSInteger)index
|
||||
{
|
||||
TFBasicViewController *vc = [pageContentCollectionView.childViewControllers objectAtIndex:index];
|
||||
[vc cancleTableViewCellEditingState];
|
||||
switch (index) {
|
||||
case 0:
|
||||
[self.rightButton setTitle:self.bookVC.isEditting ? TFLocalizedString(@"取消") : TFLocalizedString(@"编辑") forState:UIControlStateNormal];
|
||||
break;
|
||||
case 1:
|
||||
[self.rightButton setTitle:self.comicVC.isEditting ? TFLocalizedString(@"取消") : TFLocalizedString(@"编辑") forState:UIControlStateNormal];
|
||||
break;
|
||||
case 2:
|
||||
[self.rightButton setTitle:self.audioVC.isEditting ? TFLocalizedString(@"取消") : TFLocalizedString(@"编辑") forState:UIControlStateNormal];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex
|
||||
{
|
||||
|
||||
[self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
|
||||
}
|
||||
|
||||
@end
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// TFDownloadViewController.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
|
||||
|
||||
@interface TFDownloadViewController : TFBasicViewController
|
||||
|
||||
// 选择存储器
|
||||
@property (nonatomic ,strong) NSMutableDictionary *selectSourceDictionary;
|
||||
// index合集
|
||||
@property (nonatomic ,strong) NSMutableDictionary *cellIndexDictionary;
|
||||
// 重置选择存储器
|
||||
- (void)resetSelectSourceDicWithDataSourceArray:(NSArray <TFProductionChapterModel *>*)dataSourceArray productionType:(TFProductionType)productionType;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// TFDownloadViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/15.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFDownloadViewController.h"
|
||||
#import "WXYZ_ComicDownloadManager.h"
|
||||
#import "WXYZ_AudioDownloadManager.h"
|
||||
|
||||
@interface TFDownloadViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFDownloadViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
}
|
||||
|
||||
// 重置选择存储器
|
||||
- (void)resetSelectSourceDicWithDataSourceArray:(NSArray <TFProductionChapterModel *>*)dataSourceArray productionType:(TFProductionType)productionType
|
||||
{
|
||||
// 刷新数据后,已选择章节的恢复设置为已选择
|
||||
NSMutableDictionary *t_selectDictionary = [self.selectSourceDictionary mutableCopy];
|
||||
|
||||
[self.selectSourceDictionary removeAllObjects];
|
||||
|
||||
// index合集
|
||||
[self.cellIndexDictionary removeAllObjects];
|
||||
|
||||
NSMutableArray *t_arr = [dataSourceArray mutableCopy];
|
||||
|
||||
for (int i = 0; i < t_arr.count; i++) {
|
||||
TFProductionChapterModel *t_chapterModel = [t_arr objectAtIndex:i];
|
||||
if (productionType == TFProductionTypeComic) {
|
||||
|
||||
WXYZ_ProductionDownloadState state = [[WXYZ_ComicDownloadManager sharedManager] getChapterDownloadStateWithProduction_id:t_chapterModel.production_id chapter_id:t_chapterModel.chapter_id];
|
||||
[self.selectSourceDictionary setObject:[TFUtilsHelper formatStringWithInteger:state] forKey:[TFUtilsHelper formatStringWithInteger:t_chapterModel.chapter_id]];
|
||||
|
||||
} else if (productionType == TFProductionTypeAudio) {
|
||||
WXYZ_ProductionDownloadState state = [[WXYZ_AudioDownloadManager sharedManager] getChapterDownloadStateWithProduction_id:t_chapterModel.production_id chapter_id:t_chapterModel.chapter_id];
|
||||
[self.selectSourceDictionary setObject:[TFUtilsHelper formatStringWithInteger:state] forKey:[TFUtilsHelper formatStringWithInteger:t_chapterModel.chapter_id]];
|
||||
}
|
||||
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
|
||||
[self.cellIndexDictionary setObject:indexPath forKey:[TFUtilsHelper formatStringWithInteger:t_chapterModel.chapter_id]];
|
||||
}
|
||||
|
||||
|
||||
for (NSString *t_key in t_selectDictionary.allKeys) {
|
||||
if ([[t_selectDictionary objectForKey:t_key] integerValue] == WXYZ_ProductionDownloadStateSelected) {
|
||||
[self.selectSourceDictionary setObject:[TFUtilsHelper formatStringWithInteger:WXYZ_ProductionDownloadStateSelected] forKey:t_key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)selectSourceDictionary
|
||||
{
|
||||
if (!_selectSourceDictionary) {
|
||||
_selectSourceDictionary = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return _selectSourceDictionary;
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)cellIndexDictionary
|
||||
{
|
||||
if (!_cellIndexDictionary) {
|
||||
_cellIndexDictionary = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return _cellIndexDictionary;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user