小说绘上架版本

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
@@ -0,0 +1,19 @@
//
// TFTabbarViewHelper.h
// WXReader
//
// Created by 谢腾飞 on 2020/12/1.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "CYLTabBarController.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFTabbarViewHelper : NSObject
@property (nonatomic ,strong ,readonly) CYLTabBarController *tabBarController;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,215 @@
//
// TFTabbarViewHelper.m
// WXReader
//
// Created by 谢腾飞 on 2020/12/1.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFTabbarViewHelper.h"
#import "TFBookRackViewController.h"
#import "TFBookStoreViewController.h"
#import "TFDiscoverViewController.h"
#import "TFMineViewController.h"
@interface TFTabbarViewHelper () <UITabBarControllerDelegate>
@property (nonatomic ,strong ,readwrite) CYLTabBarController *tabBarController;
@end
@implementation TFTabbarViewHelper
- (instancetype)init
{
if (self = [super init]) {
// 隐藏tabbar
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(hiddenTabbar:) name:Notification_Hidden_Tabbar object:nil];
// 显示tabbar
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showTabbar:) name:Notification_Show_Tabbar object:nil];
// 改变审核状态
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeMagicState:) name:Notification_Review_State object:nil];
// 改变tabbar选项卡
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changTabbarIndex:) name:Notification_Change_Tabbar_Index object:nil];
// 切换语言状态
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(switchLanguage) name:Notification_Switch_Language object:nil];
}
return self;
}
- (CYLTabBarController *)tabBarController
{
if (!_tabBarController) {
CYLTabBarController *tabBarController = nil;
if (@available(iOS 13.0, *)) {
tabBarController = [CYLTabBarController tabBarControllerWithViewControllers:self.viewControllers tabBarItemsAttributes:self.tabBarItemsAttributesForController imageInsets:UIEdgeInsetsMake(1, 0, 1, 0) titlePositionAdjustment:UIOffsetMake(0, -3)];
[[UITabBar appearance] setUnselectedItemTintColor:kColorRGBA(217, 217, 217, 1)];
[[UITabBar appearance] setTintColor:kMainColor];
} else {
tabBarController = [CYLTabBarController tabBarControllerWithViewControllers:self.viewControllers tabBarItemsAttributes:self.tabBarItemsAttributesForController imageInsets:UIEdgeInsetsMake(0, 0, 0, 0) titlePositionAdjustment:UIOffsetMake(0, -3)];
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:kMainColor} forState:UIControlStateSelected];
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:kColorRGBA(217, 217, 217, 1)} forState:UIControlStateNormal];
}
tabBarController.tabBarHeight = PUB_TABBAR_HEIGHT;
tabBarController.tabBar.translucent = YES;
tabBarController.delegate = self;
tabBarController.tabBar.clipsToBounds = YES;
[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];
[[UITabBar appearance] setBackgroundImage:[TFViewHelper scaleImage:[UIImage imageNamed:@"tabbar_background"] toScale:1]];
if (![[NSUserDefaults standardUserDefaults] objectForKey:TF_TABBAR_SELECT_MEMORY]) {
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInteger:1] forKey:TF_TABBAR_SELECT_MEMORY];
[[NSUserDefaults standardUserDefaults] synchronize];
}
NSNumber *selectIndex = [[NSUserDefaults standardUserDefaults] objectForKey:TF_TABBAR_SELECT_MEMORY];
tabBarController.selectedIndex = [selectIndex integerValue];
_tabBarController = tabBarController;
}
return _tabBarController;
}
- (NSArray *)tabBarItemsAttributesForController
{
NSMutableArray *tabbarItems = [NSMutableArray array];
for (int i = 0; i < self.titleArr.count; i ++) {
[tabbarItems addObject:@{
CYLTabBarItemTitle : self.titleArr[i],
CYLTabBarItemImage : self.itemImageArr[i],
CYLTabBarItemSelectedImage : self.itemImageSelectedArr[i],
}];
}
NSArray *tabBarItemsAttributes = [tabbarItems copy];
return tabBarItemsAttributes;
}
- (NSArray *)titleArr
{
return @[TFLocalizedString(@"书架"), TFLocalizedString(@"书城"), TFLocalizedString(@"发现"), TFLocalizedString(@"我的")];
}
- (NSArray *)itemImageArr
{
return @[@"bookRack", @"bookMall", @"discover", @"mine"];
}
- (NSArray *)itemImageSelectedArr
{
return @[@"bookRack_select", @"bookMall_select", @"discover_select", @"mine_select"];
}
- (NSArray *)viewControllers
{
NSArray *t_viewControllers;
TFBookRackViewController *bookRackViewController = [[TFBookRackViewController alloc] init];
TFBookStoreViewController *bookMallViewController = [[TFBookStoreViewController alloc] init];
TFDiscoverViewController *discoverViewController = [[TFDiscoverViewController alloc] init];
TFMineViewController *mineViewController = [[TFMineViewController alloc] init];
t_viewControllers = @[bookRackViewController, bookMallViewController, discoverViewController, mineViewController];
NSMutableArray *t_navigationControllers = [NSMutableArray array];
for (UIViewController *t_viewController in t_viewControllers) {
UINavigationController *t_navigationController = [[TFNavigationController alloc] initWithRootViewController:t_viewController];
[t_navigationControllers addObject:t_navigationController];
}
return [t_navigationControllers copy];
}
- (void)tabBarController:(UITabBarController *)tabBarController didSelectControl:(UIControl *)control
{
[UIApplication sharedApplication].statusBarHidden = NO;
[self saveTabbarSelectedIndex:tabBarController.selectedIndex];
}
- (void)saveTabbarSelectedIndex:(NSUInteger)selectedIndex
{
if (selectedIndex == 0 || selectedIndex == 1) {
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedInteger:selectedIndex] forKey:TF_TABBAR_SELECT_MEMORY];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}
#pragma mark - Notification
// 隐藏tabbar
- (void)hiddenTabbar:(NSNotification *)notification
{
self.tabBarController.tabBar.hidden = YES;
NSString *animationState = [NSString stringWithFormat:@"%@", notification.object];
if ([animationState isEqualToString:@"1"]) {
self.tabBarController.tabBar.frame = CGRectMake(0, SCREEN_HEIGHT, self.tabBarController.tabBar.frame.size.width, self.tabBarController.tabBar.frame.size.height);
} else {
[UIView animateWithDuration:kAnimatedDuration animations:^{
self.tabBarController.tabBar.frame = CGRectMake(0, SCREEN_HEIGHT, self.tabBarController.tabBar.frame.size.width, self.tabBarController.tabBar.frame.size.height);
}];
}
}
// 显示tabbar
- (void)showTabbar:(NSNotification *)notification
{
NSString *animationState = [NSString stringWithFormat:@"%@", notification.object];
self.tabBarController.tabBar.hidden = NO;
if ([animationState isEqualToString:@"animation"]) {
[UIView animateWithDuration:kAnimatedDuration animations:^{
self.tabBarController.tabBar.frame = CGRectMake(0, SCREEN_HEIGHT - self.tabBarController.tabBar.frame.size.height, self.tabBarController.tabBar.frame.size.width, self.tabBarController.tabBar.frame.size.height);
}];
} else {
self.tabBarController.tabBar.frame = CGRectMake(0, SCREEN_HEIGHT - self.tabBarController.tabBar.frame.size.height, self.tabBarController.tabBar.frame.size.width, self.tabBarController.tabBar.frame.size.height);
}
}
// 改变tabbar选项卡位置
- (void)changTabbarIndex:(NSNotification *)notification
{
[self.tabBarController setSelectedIndex:[notification.object integerValue]];
NSUInteger selectIndex = [notification.object integerValue];
[self saveTabbarSelectedIndex:selectIndex];
}
// 改变tabbar结构
- (void)changeMagicState:(NSNotification *)notification
{
// 如果本地状态与通知状态相同,就不更改界面
if ([TFSystemInfoManager.magicStatus isEqualToString:notification.object]) {
return;
}
TFSystemInfoManager.magicStatus = notification.object;
self.tabBarController = nil;
[kMainWindow setRootViewController:self.tabBarController];
}
- (void)switchLanguage
{
if (![NSThread isMainThread]) {
[self performSelectorOnMainThread:@selector(switchLanguage) withObject:nil waitUntilDone:YES];
return;
}
self.tabBarController = nil;
kMainWindow.rootViewController = self.tabBarController;
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Change_Tabbar_Index object:@"1"];
}
@end
@@ -0,0 +1,85 @@
//
// TFBasicNavBarView.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 TFBasicNavBarView : UIView
@property (nonatomic ,weak) UIViewController *navCurrentController;
// 标题
@property (nonatomic ,strong) UILabel *navTitleLabel;
@property (nonatomic ,assign) BOOL isPresentState;
// 透过点击
@property (nonatomic ,assign) BOOL touchEnabled;
/**
隐藏返回按钮
*/
- (void)hiddenLeftBarButton;
/**
白色返回按钮
*/
- (void)setLightLeftButton;
/**
设置返回按钮颜色
*/
- (void)setLeftButtonTintColor:(UIColor *)tintColor;
/**
设置导航栏左侧按钮
*/
- (void)setLeftBarButton:(UIButton *)leftButton;
/**
设置导航栏右侧按钮
*/
- (void)setRightBarButton:(UIButton *)rightButton;
/**
分割线(细)
*/
- (void)setSmallSeparator;
/**
分割线(粗)
*/
- (void)setLargeSeparator;
/**
分割线(无)
*/
- (void)hiddenSeparator;
/**
设置导航栏标题
*/
- (void)setNavigationBarTitle:(NSString *)title;
/**
设置导航栏标题颜色
*/
- (void)setNavigationBarTintColor:(UIColor *)tintColor;
/**
设置导航栏标题字号
*/
- (void)setNavigationBarTintFont:(UIFont *)font;
/*
返回界面
**/
- (void)popViewController;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,224 @@
//
// TFBasicNavBarView.m
// WXReader
//
// Created by 谢腾飞 on 2020/12/1.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFBasicNavBarView.h"
#import "WXYZ_AudioSettingHelper.h"
@interface TFBasicNavBarView ()
// 默认返回按钮
@property (nonatomic ,strong) UIButton *defaultLeftButton;
// 导航栏边线
@property (nonatomic ,strong) UIImageView *navBottomLine;
@end
@implementation TFBasicNavBarView
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
[self createSubViews];
}
return self;
}
- (void)createSubViews
{
[self addSubview:self.navTitleLabel];
[self addSubview:self.defaultLeftButton];
[self addSubview:self.navBottomLine];
}
#pragma mark - public
/**
隐藏返回按钮
*/
- (void)hiddenLeftBarButton
{
self.defaultLeftButton.hidden = YES;
}
/**
白色返回按钮
*/
- (void)setLightLeftButton
{
[self.defaultLeftButton setTintColor:kWhiteColor];
}
/**
设置返回按钮颜色
*/
- (void)setLeftButtonTintColor:(UIColor *)tintColor
{
[self.defaultLeftButton setTintColor:tintColor];
}
/**
设置导航栏左侧按钮
*/
- (void)setLeftBarButton:(UIButton *)leftButton
{
if (self.defaultLeftButton) {
[self.defaultLeftButton removeFromSuperview];
}
[self addSubview:leftButton];
}
/**
设置导航栏右侧按钮
*/
- (void)setRightBarButton:(UIButton *)rightButton
{
[self addSubview:rightButton];
}
/**
分割线(细)
*/
- (void)setSmallSeparator
{
self.navBottomLine.frame = CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, 1);
self.navBottomLine.hidden = NO;
}
/**
分割线(粗)
*/
- (void)setLargeSeparator
{
self.navBottomLine.frame = CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, 5);
self.navBottomLine.hidden = NO;
}
/**
分割线(无)
*/
- (void)hiddenSeparator
{
self.navBottomLine.frame = CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, 0);
self.navBottomLine.hidden = YES;
}
/**
设置导航栏标题
*/
- (void)setNavigationBarTitle:(NSString *)title
{
[self.navTitleLabel setText:title];
self.navTitleLabel.frame = CGRectMake((SCREEN_WIDTH - 240) / 2.0, PUB_NAVBAR_OFFSET + 20, 240, 44);
}
/**
设置导航栏标题颜色
*/
- (void)setNavigationBarTintColor:(UIColor *)tintColor
{
[self.navTitleLabel setTextColor:tintColor];
}
/**
设置导航栏标题字号
*/
- (void)setNavigationBarTintFont:(UIFont *)font
{
[self.navTitleLabel setFont:font];
}
- (void)setBackgroundColor:(UIColor *)backgroundColor
{
[super setBackgroundColor:backgroundColor];
self.navTitleLabel.backgroundColor = backgroundColor;
}
- (UILabel *)navTitleLabel
{
if (!_navTitleLabel) {
_navTitleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_navTitleLabel.backgroundColor = [UIColor clearColor];
_navTitleLabel.textColor = [UIColor blackColor];
_navTitleLabel.numberOfLines = 1;
_navTitleLabel.font = kFont16;
_navTitleLabel.textAlignment = NSTextAlignmentCenter;
}
return _navTitleLabel;
}
- (UIButton *)defaultLeftButton
{
if (!_defaultLeftButton) {
_defaultLeftButton = [UIButton buttonWithType:UIButtonTypeCustom];
_defaultLeftButton.backgroundColor = [UIColor clearColor];
_defaultLeftButton.frame = CGRectMake(kHalfMargin, PUB_NAVBAR_OFFSET + 20, 44, 44);
_defaultLeftButton.adjustsImageWhenHighlighted = NO;
[_defaultLeftButton.titleLabel setFont:kMainFont];
[_defaultLeftButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[_defaultLeftButton setImageEdgeInsets:UIEdgeInsetsMake(12, 6, 12, 18)];
[_defaultLeftButton setImage:[[UIImage imageNamed:@"public_back"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
[_defaultLeftButton setTintColor:kBlackColor];
[_defaultLeftButton addTarget:self action:@selector(popViewController) forControlEvents:UIControlEventTouchUpInside];
}
return _defaultLeftButton;
}
- (UIImageView *)navBottomLine
{
if (!_navBottomLine) {
_navBottomLine = [[UIImageView alloc] initWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, 5)];
_navBottomLine.userInteractionEnabled = YES;
_navBottomLine.image = [UIImage imageNamed:@"navbar_bottom_line"];
}
return _navBottomLine;
}
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
UIView *hitView = [super hitTest:point withEvent:event];
if (self.touchEnabled && hitView == self) {
return nil;
}
return hitView;
}
- (void)popViewController
{
BOOL pop = NO;
NSArray *viewcontrollers = self.navCurrentController.navigationController.viewControllers;
if (viewcontrollers.count > 1) {
if ([viewcontrollers objectAtIndex:viewcontrollers.count - 1] == self) {
pop = YES;
[self.navCurrentController.navigationController popViewControllerAnimated:YES];
}
} else {
if ([self.navCurrentController isKindOfClass:[NSClassFromString(@"WXYZ_BookAiPlayPageViewController") class]]) {
[[WXYZ_AudioSettingHelper sharedManager] playPageViewShow:NO productionType:TFProductionTypeAi];
}
if ([self.navCurrentController isKindOfClass:[NSClassFromString(@"TFAudioPlayViewController") class]]) {
[[WXYZ_AudioSettingHelper sharedManager] playPageViewShow:NO productionType:TFProductionTypeAudio];
}
[self.navCurrentController dismissViewControllerAnimated:YES completion:nil];
}
if (!pop) {
[self.navCurrentController.navigationController popViewControllerAnimated:YES];
}
}
- (void)dealloc
{
if (_navCurrentController) {
[_navCurrentController willMoveToParentViewController:nil];
[_navCurrentController.view removeFromSuperview];
[_navCurrentController removeFromParentViewController];
}
}
@end
@@ -0,0 +1,25 @@
//
// TFBasicTableViewCell.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 TFBasicTableViewCell : UITableViewCell
@property (nonatomic ,strong) NSIndexPath *index;
@property (nonatomic ,assign) BOOL hiddenEndLine;
@property (nonatomic ,strong) UIView *lineView;
@property (nonatomic ,assign) TFProductionType productionType;
- (void)createSubviews;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,57 @@
//
// TFBasicTableViewCell.m
// WXReader
//
// Created by 谢腾飞 on 2020/12/1.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFBasicTableViewCell.h"
@implementation TFBasicTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.backgroundColor = [UIColor whiteColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self createSubviews];
}
return self;
}
- (void)createSubviews
{
self.lineView = [[UIView alloc] init];
self.lineView.backgroundColor = kGrayLineColor;
self.lineView.hidden = YES;
[self.contentView addSubview:self.lineView];
[self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kMargin);
make.width.mas_equalTo(SCREEN_WIDTH - kMargin);
make.height.mas_equalTo(kCellLineHeight);
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(-kCellLineHeight);
}];
}
- (void)setIndex:(NSIndexPath *)index
{
_index = index;
}
- (void)setHiddenEndLine:(BOOL)hiddenEndLine
{
_hiddenEndLine = hiddenEndLine;
self.lineView.hidden = hiddenEndLine;
}
- (void)setProductionType:(TFProductionType)productionType
{
_productionType = productionType;
}
@end
@@ -0,0 +1,28 @@
//
// TFProductionListViewCell.h
// WXReader
//
// Created by 谢腾飞 on 2020/12/1.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFTagboardView.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFProductionListViewCell : TFBasicTableViewCell
@property (nonatomic ,strong) TFProductionModel *productionModel;
// 是否来自榜单
@property (nonatomic ,assign) BOOL isRankList;
// 书籍图片
@property (nonatomic ,strong) TFProductionCoverView *coverView;
@property (nonatomic ,strong) UILabel *titleLabel;
@property (nonatomic ,strong) YYLabel *introductionLabel;
@property (nonatomic ,strong) UILabel *authorLabel;
@property (nonatomic ,strong) TFTagboardView *tagboardView;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,184 @@
//
// TFProductionListViewCell.m
// WXReader
//
// Created by 谢腾飞 on 2020/12/1.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFProductionListViewCell.h"
@interface TFProductionListViewCell ()
@property (nonatomic ,weak) UIImageView *indexImageView;
@property (nonatomic ,weak) UILabel *indexLabel;
@end
@implementation TFProductionListViewCell
- (void)createSubviews
{
[super createSubviews];
self.backgroundColor = kWhiteColor;
// 图片
self.coverView = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
[self.contentView addSubview:self.coverView];
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kHalfMargin);
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kHalfMargin);
make.width.mas_equalTo(BOOK_WIDTH_SMALL);
make.height.mas_equalTo(BOOK_HEIGHT_SMALL);
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin).priorityLow();
}];
UIImageView *indexImageView = [[UIImageView alloc] init];
indexImageView.backgroundColor = [UIColor clearColor];
indexImageView.hidden = YES;
indexImageView.contentMode = UIViewContentModeScaleAspectFit;
[self.coverView addSubview:indexImageView];
self.indexImageView = indexImageView;
[indexImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.coverView).offset(-kQuarterMargin);
make.top.equalTo(self.coverView);
make.size.mas_equalTo(CGSizeMake(24.0, 23.0));
}];
UILabel *indexLabel = [[UILabel alloc] init];
indexLabel.textColor = [UIColor whiteColor];
indexLabel.font = kFont12;
[indexImageView addSubview:indexLabel];
self.indexLabel = indexLabel;
[indexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(indexImageView).offset(-2.0f);
make.centerX.equalTo(indexImageView);
}];
// 书名
self.titleLabel = [[UILabel alloc] init];
self.titleLabel.numberOfLines = 1;
self.titleLabel.backgroundColor = kWhiteColor;
self.titleLabel.font = kMainFont;
self.titleLabel.textAlignment = NSTextAlignmentLeft;
[self addSubview:self.titleLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.coverView.mas_right).with.offset(kHalfMargin);
make.top.mas_equalTo(self.coverView.mas_top);
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
make.height.mas_equalTo(BOOK_CELL_TITLE_HEIGHT / 2);
}];
// 作者
self.authorLabel = [[UILabel alloc] init];
self.authorLabel.numberOfLines = 1;
self.authorLabel.backgroundColor = kWhiteColor;
self.authorLabel.font = kFont11;
self.authorLabel.textColor = kColorRGBA(176, 176, 177, 1);
self.authorLabel.textAlignment = NSTextAlignmentLeft;
[self addSubview:self.authorLabel];
[self.authorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.titleLabel.mas_left);
make.bottom.mas_equalTo(self.coverView.mas_bottom);
make.width.mas_equalTo(CGFLOAT_MIN);
make.height.mas_equalTo(self.titleLabel.mas_height);
}];
// 标签
self.tagboardView = [[TFTagboardView alloc] init];
self.tagboardView.font = kFont10;
self.tagboardView.textAlignment = TFTagboardTextAlignmentRight;
self.tagboardView.borderStyle = TFTagboardBorderStyleBorder;
self.tagboardView.cornerRadius = 3;
self.tagboardView.spacing = 10;
[self addSubview:self.tagboardView];
[self.tagboardView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.authorLabel.mas_right).with.offset(kHalfMargin);
make.right.mas_equalTo(self.titleLabel.mas_right);
make.centerY.mas_equalTo(self.authorLabel.mas_centerY);
make.height.mas_equalTo(self.authorLabel.mas_height);
}];
// 简介
self.introductionLabel = [[YYLabel alloc] init];
self.introductionLabel.numberOfLines = 3;
self.introductionLabel.textVerticalAlignment = YYTextVerticalAlignmentTop;
self.introductionLabel.backgroundColor = kWhiteColor;
self.introductionLabel.font = kFont13;
self.introductionLabel.textColor = kColorRGBA(102, 102, 102, 1);
self.introductionLabel.textAlignment = NSTextAlignmentLeft;
self.introductionLabel.layer.masksToBounds = YES;
[self addSubview:self.introductionLabel];
[self.introductionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.titleLabel.mas_left);
make.right.mas_equalTo(self.titleLabel.mas_right);
make.top.mas_equalTo(self.titleLabel.mas_bottom).with.offset(kHalfMargin);
make.bottom.mas_equalTo(self.authorLabel.mas_top).with.offset(- kHalfMargin);
}];
[self layoutIfNeeded];
}
- (void)setProductionModel:(TFProductionModel *)productionModel
{
_productionModel = productionModel;
NSString *imageName;
switch ([productionModel.display_no integerValue]) {
case 0:
imageName = @"book_list_one";
break;
case 1:
imageName = @"book_list_two";
break;
case 2:
imageName = @"book_list_three";
break;
default:
imageName = @"book_list_other";
break;
}
self.indexImageView.image = [UIImage imageNamed:imageName];
self.indexImageView.hidden = [productionModel.display_no integerValue] > 19;
if (!self.isRankList) {
self.indexImageView.hidden = YES;
}
self.indexLabel.text = productionModel.display_no ? : @"";
self.coverView.coverImageUrl = productionModel.cover;
self.titleLabel.text = productionModel.name ? : @"";
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString: productionModel.production_descirption ? : @""];
text.lineSpacing = 5;
text.font = kFont13;
text.color = kColorRGBA(118, 118, 118, 1);
self.introductionLabel.attributedText = text;
self.authorLabel.text = productionModel.author ? : @"";
[self.authorLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.authorLabel]);
}];
self.tagboardView.tagboardArray = productionModel.tag;
}
- (void)setProductionType:(TFProductionType)productionType
{
[super setProductionType:productionType];
self.coverView.productionType = productionType;
}
@end