小说绘上架版本

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,45 @@
//
// TFComicDownloadManagerCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef void(^CellSelectBlock)(TFProductionModel *comicModel, NSString *comic_name);
typedef void(^ImageViewSelectBlock)(NSInteger comic_id);
typedef void(^ButtonSelectBlock)(TFProductionModel *comicModel);
@interface TFComicDownloadManagerCell : TFBasicTableViewCell
@property (nonatomic, strong) TFProductionModel *comicModel;
@property (nonatomic, copy) CellSelectBlock cellSelectBlock;
@property (nonatomic, copy) ImageViewSelectBlock imageViewSelectBlock;
@property (nonatomic, copy) ButtonSelectBlock buttonSelectBlock;
@property (nonatomic, assign, readonly) BOOL isEditting;
@property (nonatomic, assign, readonly) BOOL isSelected;
/// 选择编辑单元
@property (nonatomic, copy) void(^selecteEdittingCellBlock)(TFProductionModel *productionModel, BOOL isSelected);
- (void)setEditing:(BOOL)editing;
// 强行设置编辑状态
- (void)set_Editting:(BOOL)editting;
// 切换选中状态
- (void)switchSelectedState:(BOOL)state;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,236 @@
//
// TFComicDownloadManagerCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFComicDownloadManagerCell.h"
#import "WXYZ_ComicDownloadManager.h"
#import "TFReadRecordManager.h"
@interface TFComicDownloadManagerCell ()
@property (nonatomic ,weak) UIView *mainView;
@property (nonatomic ,weak) TFProductionCoverView *coverImageView;
@property (nonatomic ,weak) UILabel *titleNameLabel;
@property (nonatomic ,weak) UILabel *subTitleLabel;
@property (nonatomic ,weak) UIButton *readButton;
@property (nonatomic ,weak) UIImageView *selectedView;
@end
@implementation TFComicDownloadManagerCell
- (void)createSubviews
{
[super createSubviews];
[self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cellTapClick:)]];
UIView *mainView = [[UIView alloc] init];
self.mainView = mainView;
mainView.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:mainView];
[mainView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView);
make.left.equalTo(self.contentView).offset(-16.0f);
make.width.equalTo(self.contentView).offset(16.0f);
make.height.equalTo(self.contentView);
}];
UIImageView *selectedView = [[UIImageView alloc] init];
self.selectedView = selectedView;
selectedView.image = [UIImage imageNamed:@"audio_download_unselect"];
[mainView addSubview:selectedView];
[selectedView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(16.0f);
make.left.equalTo(mainView);
make.centerY.equalTo(mainView);
}];
TFProductionCoverView *coverImageView = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeComic coverDirection:TFProductionCoverDirectionVertical];
self.coverImageView = coverImageView;
coverImageView.tag = 200;
[coverImageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cellTapClick:)]];
[mainView addSubview:coverImageView];
[coverImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(selectedView.mas_right).with.offset(kHalfMargin);
make.top.mas_equalTo(mainView.mas_top).with.offset(kQuarterMargin);
make.width.mas_equalTo(BOOK_WIDTH_SMALL - kMargin);
make.height.mas_equalTo(kGeometricHeight(BOOK_WIDTH_SMALL - kMargin, 3, 4));
make.bottom.mas_equalTo(mainView.mas_bottom).with.offset(- kQuarterMargin).priorityLow();
}];
UILabel *titleNameLabel = [[UILabel alloc] init];
self.titleNameLabel = titleNameLabel;
titleNameLabel.textColor = kBlackColor;
titleNameLabel.textAlignment = NSTextAlignmentLeft;
titleNameLabel.font = kBoldFont14;
titleNameLabel.numberOfLines = 0;
[mainView addSubview:titleNameLabel];
[titleNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(coverImageView.mas_right).with.offset(kHalfMargin);
make.top.mas_equalTo(coverImageView.mas_top);
make.right.mas_equalTo(mainView.mas_right).offset(-kQuarterMargin);
}];
UILabel *subTitleLabel = [[UILabel alloc] init];
self.subTitleLabel = subTitleLabel;
subTitleLabel.textColor = kGrayTextColor;
subTitleLabel.textAlignment = NSTextAlignmentLeft;
subTitleLabel.font = kFont12;
subTitleLabel.numberOfLines = 1;
[mainView addSubview:subTitleLabel];
[subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(titleNameLabel);
make.bottom.mas_equalTo(coverImageView.mas_bottom);
}];
UIButton *readButton = [UIButton buttonWithType:UIButtonTypeCustom];
self.readButton = readButton;
readButton.backgroundColor = kMainColor;
readButton.layer.cornerRadius = 12;
[readButton setTitle:TFLocalizedString(@"开始阅读") forState:UIControlStateNormal];
[readButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
[readButton.titleLabel setFont:kFont12];
[readButton addTarget:self action:@selector(readButtonClick) forControlEvents:UIControlEventTouchUpInside];
[mainView addSubview:readButton];
[readButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(mainView.mas_right).with.offset(- kHalfMargin);
make.centerY.mas_equalTo(mainView.mas_centerY);
make.width.mas_equalTo(70);
make.height.mas_equalTo(24);
}];
[titleNameLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.readButton.mas_top).offset(-kQuarterMargin);
}];
[subTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.readButton.mas_bottom).offset(kQuarterMargin);
}];
}
- (void)setComicModel:(TFProductionModel *)comicModel
{
_comicModel = comicModel;
if (comicModel.vertical_cover.length > 0) {
self.coverImageView.coverImageUrl = comicModel.vertical_cover;
} else if (comicModel.horizontal_cover.length > 0) {
self.coverImageView.coverImageUrl = comicModel.horizontal_cover;
} else {
self.coverImageView.coverImageUrl = comicModel.cover;
}
self.titleNameLabel.text = comicModel.name?:@"";
self.subTitleLabel.text = [NSString stringWithFormat:TFLocalizedString(@"%@话/%@话"), [TFUtilsHelper formatStringWithInteger:[[WXYZ_ComicDownloadManager sharedManager] getDownloadChapterCountWithProduction_id:comicModel.production_id]], [TFUtilsHelper formatStringWithInteger:comicModel.total_chapters]];
if ([[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeComic] getReadingRecordChapterTitleWithProduction_id:comicModel.production_id].length > 0) {
[self.readButton setTitle:TFLocalizedString(@"继续阅读") forState:UIControlStateNormal];
} else {
[self.readButton setTitle:TFLocalizedString(@"开始阅读") forState:UIControlStateNormal];
}
}
- (void)cellTapClick:(UITapGestureRecognizer *)tap
{
if (_isEditting) {
[self switchSelectedState:!_isSelected];
return;
}
if (tap.view.tag == 200) {
if (self.imageViewSelectBlock) {
self.imageViewSelectBlock(_comicModel.production_id);
}
} else {
if (self.cellSelectBlock) {
self.cellSelectBlock(_comicModel, _comicModel.name);
}
}
}
- (void)readButtonClick
{
if (self.buttonSelectBlock) {
self.buttonSelectBlock(_comicModel);
}
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
- (void)switchSelectedState:(BOOL)state {
UIImage *image = nil;
if (state) {
image = [UIImage imageNamed:@"audio_download_select"];
} else {
image = [UIImage imageNamed:@"audio_download_unselect"];
}
_isSelected = state;
self.selectedView.image = image;
!self.selecteEdittingCellBlock ?: self.selecteEdittingCellBlock(self.comicModel, state);
}
- (void)setEditing:(BOOL)editing {
if (editing && _isEditting == NO) {
self.readButton.hidden = editing;
[UIView animateWithDuration:0.2 animations:^{
[self.mainView mas_updateConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(17.0f);
}];
[self.mainView.superview layoutIfNeeded];
} completion:^(BOOL finished) {
if (finished) {
self->_isEditting = YES;
}
}];
return;
}
if (!editing && _isEditting == YES) {
self.readButton.hidden = editing;
[UIView animateWithDuration:0.2 animations:^{
[self.mainView mas_updateConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(-16.0f);
}];
[self.mainView.superview layoutIfNeeded];
} completion:^(BOOL finished) {
if (finished) {
self->_isEditting = NO;
}
}];
return;
}
}
- (void)set_Editting:(BOOL)editting {
if (editting) {
[self.mainView mas_updateConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(17.0f);
}];
} else {
[self.mainView mas_updateConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(-16.0f);
}];
}
[self.mainView.superview layoutIfNeeded];
_isEditting = editting;
}
@end
@@ -0,0 +1,22 @@
//
// TFComicDownloadViewCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/15.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "WXYZ_DownloadManagerEnumProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFComicDownloadViewCell : UICollectionViewCell
@property (nonatomic ,strong) TFProductionChapterModel *chapterModel;
@property (nonatomic ,assign) WXYZ_ProductionDownloadState cellDownloadState;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,170 @@
//
// TFComicDownloadViewCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/15.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFComicDownloadViewCell.h"
#import "WXYZ_ComicDownloadManager.h"
@interface TFComicDownloadViewCell ()
{
UILabel *chapterNumLabel;
UIImageView *lockImageView;
UILabel *cellStateLabel;
}
@end
@implementation TFComicDownloadViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
self.backgroundColor = [UIColor clearColor];
[self createSubViews];
}
return self;
}
- (void)createSubViews
{
chapterNumLabel = [[UILabel alloc] init];
chapterNumLabel.backgroundColor = kWhiteColor;
chapterNumLabel.textColor = kBlackColor;
chapterNumLabel.textAlignment = NSTextAlignmentCenter;
chapterNumLabel.font = kMainFont;
chapterNumLabel.layer.cornerRadius = 8;
chapterNumLabel.clipsToBounds = YES;
[self addSubview:chapterNumLabel];
[chapterNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
lockImageView = [[UIImageView alloc] init];
lockImageView.image = [[UIImage imageNamed:@"comic_lock"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
lockImageView.tintColor = kMainColor;
lockImageView.hidden = YES;
[chapterNumLabel addSubview:lockImageView];
[lockImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kQuarterMargin);
make.top.mas_equalTo(kQuarterMargin);
make.width.height.mas_equalTo(self.mas_height).with.multipliedBy(0.3);
}];
cellStateLabel = [[UILabel alloc] init];
cellStateLabel.backgroundColor = [UIColor clearColor];
cellStateLabel.textColor = kWhiteColor;
cellStateLabel.textAlignment = NSTextAlignmentCenter;
cellStateLabel.font = kFont6;
cellStateLabel.layer.cornerRadius = (self.height * 0.2) / 2;
cellStateLabel.clipsToBounds = YES;
[chapterNumLabel addSubview:cellStateLabel];
[cellStateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(chapterNumLabel.mas_right).with.offset(- 2);
make.bottom.mas_equalTo(chapterNumLabel.mas_bottom).with.offset(- 2);
make.width.mas_equalTo(20);
make.height.mas_equalTo(self.mas_height).with.multipliedBy(0.2);
}];
}
- (void)setChapterModel:(TFProductionChapterModel *)chapterModel
{
_chapterModel = chapterModel;
chapterNumLabel.text = chapterModel.display_label?:@"";
if (chapterModel.can_read) {
lockImageView.hidden = YES;
} else {
lockImageView.hidden = NO;
}
chapterNumLabel.text = chapterModel.display_label?:@"";
}
- (void)setCellDownloadState:(WXYZ_ProductionDownloadState)cellDownloadState
{
_cellDownloadState = cellDownloadState;
lockImageView.hidden = self.chapterModel.can_read;
switch (cellDownloadState) {
case WXYZ_ProductionDownloadStateNormal:
{
cellStateLabel.backgroundColor = [UIColor clearColor];
cellStateLabel.hidden = YES;
cellStateLabel.text = @"";
lockImageView.tintColor = kMainColor;
chapterNumLabel.backgroundColor = kWhiteColor;
chapterNumLabel.textColor = kBlackColor;
}
break;
case WXYZ_ProductionDownloadStateDownloading:
{
cellStateLabel.backgroundColor = kColorRGBA(28, 220, 142, 1);
cellStateLabel.hidden = NO;
cellStateLabel.text = TFLocalizedString(@"下载中");
lockImageView.tintColor = kMainColor;
lockImageView.hidden = YES;
chapterNumLabel.backgroundColor = kGrayDeepViewColor;
chapterNumLabel.textColor = kGrayTextColor;
}
break;
case WXYZ_ProductionDownloadStateDownloaded:
{
cellStateLabel.backgroundColor = kColorRGBA(28, 220, 142, 0.5);
cellStateLabel.hidden = NO;
cellStateLabel.text = TFLocalizedString(@"本地");
lockImageView.tintColor = kMainColor;
lockImageView.hidden = YES;
chapterNumLabel.backgroundColor = kGrayDeepViewColor;
chapterNumLabel.textColor = kGrayTextColor;
}
break;
case WXYZ_ProductionDownloadStateFail:
{
cellStateLabel.backgroundColor = kRedColor;
cellStateLabel.hidden = NO;
cellStateLabel.text = TFLocalizedString(@"失败");
lockImageView.tintColor = kMainColor;
chapterNumLabel.backgroundColor = kWhiteColor;
chapterNumLabel.textColor = kBlackColor;
}
break;
case WXYZ_ProductionDownloadStateSelected:
{
cellStateLabel.backgroundColor = [UIColor clearColor];
cellStateLabel.hidden = YES;
cellStateLabel.text = @"";
lockImageView.tintColor = kWhiteColor;
chapterNumLabel.backgroundColor = kMainColor;
chapterNumLabel.textColor = kWhiteColor;
}
break;
default:
break;
}
[cellStateLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabelFont:kFont6 labelHeight:(self.height * 0.2) labelText:cellStateLabel.text]);
}];
}
@end