小说绘上架版本

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,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