小说绘上架版本

This commit is contained in:
xtfei2011
2021-02-07 11:24:08 +08:00
commit ee5c1c8b12
1762 changed files with 115892 additions and 0 deletions
@@ -0,0 +1,121 @@
//
// TFBasicViewController.h
// WXReader
//
// Created by 谢腾飞 on 2020/11/21.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBasicNavBarView.h"
#import "TFEmptyView.h"
#import "SGPagingView.h"
NS_ASSUME_NONNULL_BEGIN
#define TFPageView_H 44
typedef NS_ENUM(NSUInteger, TFProductionType) {
TFProductionTypeNovel = 0,
TFProductionTypeComic = 1,
TFProductionTypeAudio = 2,
TFProductionTypeAi = 3
};
@interface TFBasicViewController : UIViewController
#pragma mark - 属性
@property (nonatomic ,strong) NSMutableArray *dataSourceArray;
@property (nonatomic ,strong) NSMutableDictionary *advertDict;
@property (nonatomic ,assign) int currentPageNumber;
@property (nonatomic ,assign) TFProductionType productionType;
@property (nonatomic ,assign) CGFloat pageViewHeight;
#pragma mark - 控件
@property (nonatomic ,strong) TFBasicNavBarView *navigationBar;
@property (nonatomic ,strong) UITableView *mainTableView;
@property (nonatomic ,strong) UITableView *mainTableViewGroup;
@property (nonatomic ,strong) UICollectionViewFlowLayout *mainCollectionViewFlowLayout;
@property (nonatomic ,strong) UICollectionView *mainCollectionView;
@property (nonatomic ,strong) SGPageTitleViewConfigure *pageConfigure;
@property (nonatomic ,strong) TFEmptyView *emptyView;
@property (nonatomic ,copy) NSString *navTitle;
@property (nonatomic ,assign) BOOL isPresentState;
#pragma mark - 公共方法
// 返回上一页
- (void)popViewController;
// 是否可右滑返回
- (void)navigationCanSlidingBack:(BOOL)canSlidingBack;
// 空白占位图
- (void)setEmptyOnView:(UIScrollView *)scrollView title:(NSString *_Nullable)title tapBlock:(void(^)(void))tapBlock;
// 空白占位图,自定义Y值
- (void)setEmptyOnView:(UIScrollView *)scrollView title:(NSString *_Nullable)title centerY:(CGFloat)centerY tapBlock:(void(^)(void))tapBlock;
// 空白占位图
- (void)setEmptyOnView:(UIScrollView *)scrollView title:(NSString * _Nullable)title buttonTitle:(NSString * _Nullable)buttonTitle tapBlock:(void(^)(void))tapBlock;
// 空白占位图
- (void)setEmptyOnView:(UIScrollView *)scrollView title:(NSString * _Nullable)title detailTitle:(NSString * _Nullable)detailTitle buttonTitle:(NSString * _Nullable)buttonTitle tapBlock:(void(^)(void))tapBlock;
// 空白占位图
- (void)setEmptyOnView:(UIScrollView *)scrollView imageName:(NSString * _Nullable)imageName title:(NSString *)title detailTitle:(NSString * _Nullable)detailTitle buttonTitle:(NSString * _Nullable)buttonTitle centerY:(CGFloat)centerY tapBlock:(void(^)(void))tapBlock;
// 取消cell左滑删除状态
- (void)cancleTableViewCellEditingState;
#pragma mark - 导航栏设置
// 隐藏导航条
- (void)hiddenNavigationBar:(BOOL)hidden;
// 设置导航条背景色
- (void)setNavigationBarBackgroundColor:(UIColor *)color;
// 设置导航条标题
- (void)setNavigationBarTitle:(NSString *)title;
// 设置导航条标题颜色
- (void)setNavigationBarTintColor:(UIColor *)tintColor;
// 隐藏返回按钮
- (void)hiddenNavigationBarLeftButton;
// 设置导航栏右侧按钮
- (void)setNavigationBarRightButton:(UIButton *)rightButton;
// 设置导航栏左侧按钮
- (void)setNavigationBarLeftButton:(UIButton *)leftButton;
// 设置导航栏线条 - 无
- (void)hiddenSeparator;
// 设置导航栏线条 - 细
- (void)setNavSmallSeparator;
// 设置导航栏线条 - 粗
- (void)setNavLargeSeparator;
// 隐藏home条
- (void)hiddenHomeIndicator;
// 显示home条
- (void)showHomeIndicator;
#pragma mark - 状态栏设置
// 状态条白色
- (void)setStatusBarLightContentStyle;
// 设置状态条黑色
- (void)setStatusBarDefaultStyle;
#pragma mark - 接口数据缓存
- (void)asyncCacheNetworkWithURLString:(NSString *)URLString response:(NSDictionary *)response;
- (NSDictionary *)getCacheWithURLString:(NSString *)URLString;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,374 @@
//
// TFBasicViewController.m
// WXReader
//
// Created by 谢腾飞 on 2020/11/21.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFBasicViewController.h"
#import "XHNetworkCache.h"
@interface TFBasicViewController ()
{
BOOL hiddenHomeIndicator;
}
@end
@implementation TFBasicViewController
#pragma mark - 属性
- (NSMutableArray *)dataSourceArray
{
if (!_dataSourceArray) {
_dataSourceArray = [NSMutableArray array];
}
return _dataSourceArray;
}
- (NSMutableDictionary *)advertDict
{
if (!_advertDict) {
_advertDict = [NSMutableDictionary dictionary];
}
return _advertDict;
}
- (int)currentPageNumber
{
if (!_currentPageNumber) {
_currentPageNumber = 1;
}
return _currentPageNumber;
}
- (CGFloat)pageViewHeight
{
#if TF_Enable_PageControl
_pageViewHeight = 44;
#else
_pageViewHeight = 0;
#endif
if ([TFUtilsHelper getSiteState].count <= 1) {
_pageViewHeight = 0;
}
return _pageViewHeight;
}
#pragma mark - 控件
- (TFBasicNavBarView *)navigationBar
{
if (!_navigationBar) {
_navigationBar = [[TFBasicNavBarView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, SCREEN_WIDTH, PUB_NAVBAR_HEIGHT)];
_navigationBar.navCurrentController = self;
_navigationBar.backgroundColor = [UIColor whiteColor];
_navigationBar.userInteractionEnabled = YES;
[_navigationBar setSmallSeparator];
}
return _navigationBar;
}
- (UITableView *)mainTableView
{
if (!_mainTableView) {
_mainTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_mainTableView.backgroundColor = [UIColor clearColor];
_mainTableView.showsVerticalScrollIndicator = NO;
_mainTableView.showsHorizontalScrollIndicator = NO;
_mainTableView.estimatedRowHeight = 100;
_mainTableView.sectionFooterHeight = 10;
_mainTableView.rowHeight = UITableViewAutomaticDimension;
_mainTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
if (@available(iOS 11.0, *)) {
_mainTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
}
return _mainTableView;
}
- (UITableView *)mainTableViewGroup
{
if (!_mainTableViewGroup) {
_mainTableViewGroup = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
_mainTableViewGroup.backgroundColor = [UIColor clearColor];
_mainTableViewGroup.showsVerticalScrollIndicator = NO;
_mainTableViewGroup.showsHorizontalScrollIndicator = NO;
_mainTableViewGroup.estimatedRowHeight = 100;
_mainTableViewGroup.sectionFooterHeight = 10;
_mainTableViewGroup.rowHeight = UITableViewAutomaticDimension;
_mainTableViewGroup.separatorStyle = UITableViewCellSeparatorStyleNone;
if (@available(iOS 11.0, *)) {
_mainTableViewGroup.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
}
return _mainTableViewGroup;
}
- (UICollectionView *)mainCollectionView
{
if (!_mainCollectionView) {
_mainCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:self.mainCollectionViewFlowLayout];
_mainCollectionView.userInteractionEnabled = YES;
_mainCollectionView.backgroundColor = [UIColor clearColor];
_mainCollectionView.showsVerticalScrollIndicator = NO;
_mainCollectionView.showsHorizontalScrollIndicator = NO;
_mainCollectionView.alwaysBounceVertical = YES;
if (@available(iOS 11.0, *)) {
_mainCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
}
return _mainCollectionView;
}
- (UICollectionViewFlowLayout *)mainCollectionViewFlowLayout
{
if (!_mainCollectionViewFlowLayout) {
_mainCollectionViewFlowLayout = [[UICollectionViewFlowLayout alloc] init];
_mainCollectionViewFlowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
}
return _mainCollectionViewFlowLayout;
}
- (SGPageTitleViewConfigure *)pageConfigure
{
if (!_pageConfigure) {
_pageConfigure = [SGPageTitleViewConfigure pageTitleViewConfigure];
_pageConfigure.bounces = NO;
_pageConfigure.showBottomSeparator = YES;
_pageConfigure.bottomSeparatorColor = kGrayLineColor;
_pageConfigure.bottomSeparatorColor = [UIColor clearColor];
_pageConfigure.titleFont = kFont15;
_pageConfigure.titleColor = kBlackColor;
_pageConfigure.titleSelectedColor = kMainColor;
_pageConfigure.indicatorDynamicWidth = 10;
_pageConfigure.indicatorStyle = SGIndicatorStyleDynamic;
_pageConfigure.indicatorHeight = 4;
_pageConfigure.indicatorCornerRadius = 2;
_pageConfigure.indicatorToBottomDistance = 5;
_pageConfigure.indicatorColor = kMainColor;
}
return _pageConfigure;
}
#pragma mark - 公共方法
// 返回上一页
- (void)popViewController
{
[self.navigationBar popViewController];
}
// 是否可右滑返回
- (void)navigationCanSlidingBack:(BOOL)canSlidingBack;
{
if (self.navigationController) {
((TFNavigationController *)(self.navigationController)).enableSlidingBack = canSlidingBack;
}
}
// 空白占位图
- (void)setEmptyOnView:(UIScrollView *)scrollView title:(NSString *)title tapBlock:(void(^)(void))tapBlock
{
[self setEmptyOnView:scrollView imageName:@"" title:title detailTitle:@"" buttonTitle:@"" centerY:-1 tapBlock:tapBlock];
}
- (void)setEmptyOnView:(UIScrollView *)scrollView title:(NSString *)title centerY:(CGFloat)centerY tapBlock:(void(^)(void))tapBlock {
[self setEmptyOnView:scrollView imageName:@"" title:title detailTitle:@"" buttonTitle:@"" centerY:200 tapBlock:tapBlock];
}
// 空白占位图
- (void)setEmptyOnView:(UIScrollView *)scrollView title:(NSString *)title buttonTitle:(NSString *)buttonTitle tapBlock:(void(^)(void))tapBlock
{
[self setEmptyOnView:scrollView imageName:@"" title:title detailTitle:@"" buttonTitle:buttonTitle centerY:-1 tapBlock:tapBlock];
}
// 空白占位图
- (void)setEmptyOnView:(UIScrollView *)scrollView title:(NSString *)title detailTitle:(NSString *)detailTitle buttonTitle:(NSString *)buttonTitle tapBlock:(void(^)(void))tapBlock
{
[self setEmptyOnView:scrollView imageName:@"" title:title detailTitle:detailTitle buttonTitle:buttonTitle centerY:-1 tapBlock:tapBlock];
}
// 空白占位图
- (void)setEmptyOnView:(UIScrollView *)scrollView imageName:(NSString *)imageName title:(NSString *)title detailTitle:(NSString *)detailTitle buttonTitle:(NSString *)buttonTitle centerY:(CGFloat)centerY tapBlock:(void(^)(void))tapBlock
{
if ([imageName isEqualToString:@""]) {
imageName = @"public_no_data.png";
}
TFEmptyView *emptyView = [TFEmptyView emptyActionViewWithImage:imageName title:title detail:detailTitle btnTitle:buttonTitle btnClickBlock:^{
if (tapBlock) {
tapBlock();
}
}];
centerY = centerY == -1 ? 100 : centerY;
emptyView.contentViewY = centerY;
emptyView.imageSize = CGSizeMake(200, 200);
emptyView.autoShowEmptyView = NO;
emptyView.titleLabFont = kMainFont;
emptyView.titleLabTextColor = kGrayTextColor;
emptyView.promptImageView.tintColor = kMainColor;
emptyView.actionBtnBorderWidth = 1;
emptyView.actionBtnBorderColor = kMainColor;
emptyView.actionBtnTitleColor = kMainColor;
emptyView.actionBtnHeight = 35;
emptyView.actionBtnHorizontalMargin = 20;
scrollView.xtfei_emptyView = emptyView;
[scrollView xtfei_startLoading];
_emptyView = emptyView;
}
// 取消cell左滑删除状态
- (void)cancleTableViewCellEditingState
{
if (self.mainTableView.isEditing) {
[self.mainTableView setEditing:NO animated:YES];
}
if (self.mainTableViewGroup.isEditing) {
[self.mainTableViewGroup setEditing:NO animated:YES];
}
}
#pragma mark - 导航栏设置
- (void)hiddenNavigationBar:(BOOL)hidden
{
_navigationBar.hidden = hidden;
if (hidden) {
[self hiddenSeparator];
}
}
- (void)setNavigationBarBackgroundColor:(UIColor *)color
{
[_navigationBar setBackgroundColor:color];
}
- (void)setNavigationBarTitle:(NSString *)title
{
[_navigationBar setNavigationBarTitle:title];
}
- (void)setNavigationBarTintColor:(UIColor *)tintColor
{
[_navigationBar setNavigationBarTintColor:tintColor];
}
- (void)hiddenNavigationBarLeftButton
{
[_navigationBar hiddenLeftBarButton];
}
- (void)setNavigationBarRightButton:(UIButton *)rightButton
{
[_navigationBar setRightBarButton:rightButton];
}
// 设置导航栏左侧按钮
- (void)setNavigationBarLeftButton:(UIButton *)leftButton
{
[_navigationBar setLeftBarButton:leftButton];
}
- (void)hiddenSeparator
{
[_navigationBar hiddenSeparator];
}
- (void)setNavSmallSeparator
{
[_navigationBar setSmallSeparator];
}
- (void)setNavLargeSeparator
{
[_navigationBar setLargeSeparator];
}
#pragma mark - 状态栏设置
- (void)setStatusBarLightContentStyle
{
[TFViewHelper setStateBarLightStyle];
}
- (void)setStatusBarDefaultStyle
{
[TFViewHelper setStateBarDefaultStyle];
}
// 隐藏home条
- (void)hiddenHomeIndicator
{
if (is_iPhoneX) {
if (@available(iOS 11.0, *)) {
hiddenHomeIndicator = YES;
[self prefersHomeIndicatorAutoHidden];
}
}
}
// 显示home条
- (void)showHomeIndicator
{
if (is_iPhoneX) {
if (@available(iOS 11.0, *)) {
hiddenHomeIndicator = NO;
[self prefersHomeIndicatorAutoHidden];
}
}
}
#pragma mark - 接口数据缓存
- (void)asyncCacheNetworkWithURLString:(NSString *)URLString response:(NSDictionary *)response
{
[XHNetworkCache save_asyncJsonResponseToCacheFile:response andURL:URLString completed:^(BOOL result) {
if (result) {
}
}];
}
- (NSDictionary *)getCacheWithURLString:(NSString *)URLString
{
return [XHNetworkCache cacheJsonWithURL:URLString];
}
#pragma mark - 生命周期
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = kWhiteColor;
[self.view addSubview:self.navigationBar];
[self hiddenSeparator];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (self.navigationBar && !self.navigationBar.hidden) {
[self.view bringSubviewToFront:self.navigationBar];
}
((TFNavigationController *)(self.navigationController)).enableSlidingBack = YES;
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[TFPromptManager hiddenAlert];
}
- (BOOL)prefersHomeIndicatorAutoHidden
{
return hiddenHomeIndicator;
}
@end
@@ -0,0 +1,19 @@
//
// TFNavigationController.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 TFNavigationController : UINavigationController
@property (nonatomic ,assign) BOOL enableSlidingBack;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,74 @@
//
// TFNavigationController.m
// WXReader
//
// Created by 谢腾飞 on 2020/12/1.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFNavigationController.h"
#import "UINavigationController+TFExtension.h"
@interface TFNavigationController ()<UINavigationControllerDelegate>
@property (nonatomic ,assign) BOOL isSwitching;
@end
@implementation TFNavigationController
- (void)viewDidLoad
{
[super viewDidLoad];
self.delegate = self;
// 使导航条有效
[self setNavigationBarHidden:NO];
[self.navigationBar setHidden:YES];
}
- (void)setEnableSlidingBack:(BOOL)enableSlidingBack
{
_enableSlidingBack = enableSlidingBack;
self.interactivePopGestureRecognizer.enabled = enableSlidingBack;
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if (self.viewControllers.count > 0 && !self.isTransition) {
viewController.hidesBottomBarWhenPushed = YES;
}
if (animated) {
if (self.isSwitching) {
return; // 1. 如果是动画,并且正在切换,直接忽略
}
self.isSwitching = YES; // 2. 否则修改状态
}
[super pushViewController:viewController animated:animated];
self.isSwitching = NO;
self.isTransition = NO;
}
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
BOOL isRootVC = viewController == navigationController.viewControllers.firstObject;
if (self.enableSlidingBack) {
self.enableSlidingBack = !isRootVC;
}
self.isSwitching = NO; // 3. 还原状态
}
- (UIViewController *)popViewControllerAnimated:(BOOL)animated
{
self.isSwitching = NO;
return [super popViewControllerAnimated:animated];
}
@end