小说绘上架版本

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,33 @@
//
// TFBookStoreNovelBasicItemCell.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
@interface TFBookStoreNovelBasicItemCell : UICollectionViewCell
@property (nonatomic ,strong) TFProductionCoverView *coverView;
@property (nonatomic ,strong) UILabel *titleLabel;
@property (nonatomic ,strong) UILabel *subtitleLabel;
@property (nonatomic ,strong) UIView *lineView;
@property (nonatomic ,strong) TFProductionModel *labelListModel;
@property (nonatomic ,strong) NSIndexPath *cellIndexPath;
@property (nonatomic ,assign) BOOL hiddenEndLine;
- (void)createSubviews;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,109 @@
//
// TFBookStoreNovelBasicItemCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFBookStoreNovelBasicItemCell.h"
@implementation TFBookStoreNovelBasicItemCell
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
self.backgroundColor = kWhiteColor;
[self createSubviews];
}
return self;
}
- (void)createSubviews
{
// 封面
self.coverView = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
self.coverView.userInteractionEnabled = YES;
[self addSubview:self.coverView];
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(0);
make.top.mas_equalTo(kHalfMargin);
make.width.mas_equalTo(BOOK_WIDTH - 10);
make.height.mas_equalTo(kGeometricHeight(BOOK_WIDTH - 10, 3, 4));
make.bottom.mas_equalTo(self.mas_bottom).priorityLow();
}];
// 书名
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.mas_right);
make.height.mas_equalTo(BOOK_CELL_TITLE_HEIGHT / 2);
}];
// 子标题
self.subtitleLabel = [[UILabel alloc] init];
self.subtitleLabel.textColor = kGrayTextColor;
self.subtitleLabel.textAlignment = NSTextAlignmentLeft;
self.subtitleLabel.font = kFont11;
self.subtitleLabel.numberOfLines = 1;
self.subtitleLabel.hidden = YES;
[self addSubview:self.subtitleLabel];
[self.subtitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.titleLabel.mas_left);
make.top.mas_equalTo(self.titleLabel.mas_bottom);
make.right.mas_equalTo(self.titleLabel.mas_right);
make.height.mas_equalTo(self.titleLabel.mas_height);
make.bottom.mas_equalTo(self.mas_bottom).priorityLow();
}];
// 横线
self.lineView = [[UIView alloc] init];
self.lineView.hidden = YES;
self.lineView.backgroundColor = kGrayLineColor;
[self addSubview:self.lineView];
[self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kMargin);
make.top.mas_equalTo(self.mas_bottom).with.offset(-kCellLineHeight);
make.right.mas_equalTo(self.mas_right).with.offset(kHalfMargin);
make.height.mas_equalTo(kCellLineHeight);
}];
}
- (void)setLabelListModel:(TFProductionModel *)labelListModel
{
_labelListModel = labelListModel;
if (!labelListModel) {
return;
}
self.coverView.coverImageUrl = labelListModel.cover;
self.coverView.productionType = labelListModel.productionType;
self.titleLabel.text = labelListModel.name ? : @"";
}
- (void)setHiddenEndLine:(BOOL)hiddenEndLine
{
_hiddenEndLine = hiddenEndLine;
self.lineView.hidden = hiddenEndLine;
}
- (void)setCellIndexPath:(NSIndexPath *)cellIndexPath
{
_cellIndexPath = cellIndexPath;
}
@end
@@ -0,0 +1,34 @@
//
// TFBookStoreNovelBasicViewCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBookStoreLabelModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFBookStoreNovelBasicViewCell : TFBasicTableViewCell
@property (nonatomic ,strong) UILabel *titleLabel;
@property (nonatomic ,strong) UICollectionView *collectionView;
// 默认 NO 与showTopRefreshButton 互斥
@property (nonatomic ,assign) BOOL showTopMoreBtn;
// 默认 NO 与showTopMoreButton 互斥
@property (nonatomic ,assign) BOOL showTopRefreshBtn;
@property (nonatomic ,strong) TFBookStoreLabelModel *labelModel;
@property (nonatomic ,copy) void (^cellDidSelectItemBlock)(NSInteger production_id);
@property (nonatomic ,copy) void (^cellSelectMoreBlock)(TFBookStoreLabelModel *labelModel);
@property (nonatomic ,copy) void (^cellSelectRefreshBlock)(TFBookStoreLabelModel *labelModel, NSIndexPath *indexPath);
// 停止刷新状态
- (void)stopRefreshing;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,242 @@
//
// TFBookStoreNovelBasicViewCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFBookStoreNovelBasicViewCell.h"
#import "TFBookStoreNovelHorizontalCell.h"
#import "TFBookStoreNovelVerticalCell.h"
#import "WXYZ_CountDownView.h"
@interface TFBookStoreNovelBasicViewCell ()
@property (nonatomic ,strong) UIImageView *iconView;
@property (nonatomic ,strong) WXYZ_CountDownView *countdownView;
@property (nonatomic ,strong) TFButton *moreBtn;
@property (nonatomic ,strong) TFButton *refreshBtn;
@end
@implementation TFBookStoreNovelBasicViewCell
- (void)createSubviews
{
[super createSubviews];
[self setupSubview];
[self setupSubviewFrame];
}
- (void)setupSubview
{
self.titleLabel = [[UILabel alloc] init];
self.titleLabel.textAlignment = NSTextAlignmentLeft;
self.titleLabel.textColor = kBlackColor;
self.titleLabel.backgroundColor = kGrayViewColor;
self.titleLabel.font = kBoldFont16;
[self.contentView addSubview:self.titleLabel];
self.moreBtn = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:TFLocalizedString(@"查看更多") buttonImageName:@"public_more" buttonIndicator:TFButtonIndicatorTitleLeft];
self.moreBtn.buttonTintColor = kGrayTextLightColor;
self.moreBtn.graphicDistance = 5;
self.moreBtn.buttonImageScale = 0.35;
self.moreBtn.hidden = YES;
[self.moreBtn addTarget:self action:@selector(moreButtonClick) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:self.moreBtn];
self.refreshBtn = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:TFLocalizedString(@"换一换") buttonImageName:@"comic_mall_refresh" buttonIndicator:TFButtonIndicatorTitleLeft];
self.refreshBtn.buttonTintColor = kGrayTextLightColor;
self.refreshBtn.graphicDistance = 5;
self.refreshBtn.buttonImageScale = 0.5;
self.refreshBtn.hidden = YES;
[self.refreshBtn addTarget:self action:@selector(refreshButtonClick) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:self.refreshBtn];
self.iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"book_label_hold"]];
self.iconView.hidden = YES;
[self.contentView addSubview:self.iconView];
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
flowLayout.minimumLineSpacing = 0;
flowLayout.minimumInteritemSpacing = 0;
flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
flowLayout.itemSize = CGSizeMake(BOOK_WIDTH , VerticalCellHeight);
flowLayout.sectionInset = UIEdgeInsetsMake(0, kHalfMargin, 0, kHalfMargin);
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
self.collectionView.scrollEnabled = NO;
self.collectionView.backgroundColor = [UIColor clearColor];
self.collectionView.alwaysBounceVertical = NO;
self.collectionView.showsVerticalScrollIndicator = NO;
self.collectionView.showsHorizontalScrollIndicator = NO;
if (@available(iOS 11.0, *)) {
self.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
[self.contentView addSubview:self.collectionView];
// 倒计时
self.countdownView = [[WXYZ_CountDownView alloc] init];
self.countdownView.hidden = YES;
[self.contentView addSubview:self.countdownView];
}
- (void)setupSubviewFrame
{
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kMargin + kHalfMargin);
make.top.mas_equalTo(self.contentView.mas_top);
make.width.mas_equalTo(100);
make.height.mas_equalTo(kLabelHeight + kHalfMargin);
}];
[self.moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
make.width.mas_equalTo(80);
make.height.mas_equalTo(30);
}];
[self.refreshBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
make.width.mas_equalTo(80);
make.height.mas_equalTo(30);
}];
[self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kHalfMargin);
make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
make.width.mas_equalTo(kHalfMargin + kQuarterMargin);
make.height.mas_equalTo(kHalfMargin + kQuarterMargin);
}];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(0);
make.top.mas_equalTo(self.titleLabel.mas_bottom);
make.width.mas_equalTo(self.contentView.mas_width);
make.height.mas_equalTo(SCREEN_WIDTH);
make.bottom.mas_equalTo(self.contentView.mas_bottom).priorityLow();
}];
[self.countdownView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.titleLabel.mas_right).with.offset(kHalfMargin);
make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
make.height.mas_equalTo(20);
}];
}
- (void)setLabelModel:(TFBookStoreLabelModel *)labelModel
{
if (labelModel && _labelModel != labelModel) {
_labelModel = labelModel;
if (labelModel.label.length > 0) {
self.titleLabel.text = labelModel.label;
}
self.titleLabel.backgroundColor = kWhiteColor;
[self.titleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.titleLabel]);
}];
if (labelModel.expire_time > 0) {
self.countdownView.hidden = NO;
self.countdownView.timeStamp = labelModel.expire_time;
} else if (labelModel.expire_time == -1) {
self.countdownView.hidden = YES;
self.countdownView.timeStamp = 0;
} else {
self.countdownView.hidden = YES;
}
self.iconView.hidden = NO;
[self.collectionView reloadData];
switch (labelModel.style) {
case 1: { // TFBookStoreNovelStyleOneCell
[self.collectionView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(VerticalCellHeight + kHalfMargin);
}];
}
break;
case 2: { // TFBookStoreNovelStyleTwoCell
[self.collectionView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(self.labelModel.list.count <= 3 ? (VerticalCellHeight + kHalfMargin) : ((VerticalCellHeight + kHalfMargin) *2));
}];
}
break;
case 3: { // TFBookStoreNovelStyleThreeCell
[self.collectionView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(self.labelModel.list.count <= 3 ? (VerticalCellHeight + kHalfMargin) : VerticalCellHeight + (HorizontalCellHeight + kHalfMargin) * ((self.labelModel.list.count - 3) <= 3 ? (self.labelModel.list.count - 3) : 3));
}];
}
break;
case 4: { // TFBookStoreNovelStyleFourCell
[self.collectionView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(self.labelModel.list.count <= 1 ? HorizontalCellHeight : VerticalCellHeight + HorizontalCellHeight + kHalfMargin);
}];
}
break;
default: {
[self.collectionView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(VerticalCellHeight + kHalfMargin);
}];
}
break;
}
}
// self.refreshBtn.hidden = (labelModel.list.count == 0);
self.iconView.hidden = (labelModel.list.count == 0);
self.titleLabel.hidden = (labelModel.list.count == 0);
}
- (void)setShowTopMoreBtn:(BOOL)showTopMoreBtn
{
_showTopMoreBtn = showTopMoreBtn;
self.moreBtn.hidden = !showTopMoreBtn;
self.refreshBtn.hidden = showTopMoreBtn;
}
- (void)setShowTopRefreshBtn:(BOOL)showTopRefreshBtn
{
_showTopRefreshBtn = showTopRefreshBtn;
self.refreshBtn.hidden = !showTopRefreshBtn;
self.moreBtn.hidden = showTopRefreshBtn;
}
- (void)stopRefreshing
{
[self.refreshBtn stopSpin];
}
- (void)moreButtonClick
{
if (self.cellSelectMoreBlock) {
self.cellSelectMoreBlock(self.labelModel);
}
}
- (void)refreshButtonClick
{
[self.refreshBtn startSpin];
if (self.cellSelectRefreshBlock) {
self.cellSelectRefreshBlock(self.labelModel, self.index);
} else {
[self.refreshBtn stopSpin];
}
}
@end
@@ -0,0 +1,32 @@
//
// TFBookStoreNovelHorizontalCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBookStoreNovelBasicItemCell.h"
NS_ASSUME_NONNULL_BEGIN
/*
横排布书籍cell
┌──────────────┐ ┌────────────────────────┐
│ │ │ book Name │
│ │ └────────────────────────┘
│ │ ┌────────────────────────┐
│ photo │ │ │
│ │ │ describe │
│ │ │ │
│ │ │ │
└──────────────┘ └────────────────────────┘
*/
#define HorizontalCellHeight (kGeometricHeight(BOOK_WIDTH - 10, 3, 4) + kHalfMargin)
@interface TFBookStoreNovelHorizontalCell : TFBookStoreNovelBasicItemCell
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,118 @@
//
// TFBookStoreNovelHorizontalCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFBookStoreNovelHorizontalCell.h"
#import "TFTagboardView.h"
@interface TFBookStoreNovelHorizontalCell ()
@property (nonatomic ,strong) UILabel *authorLabel;
@property (nonatomic ,strong) TFTagboardView *tagboardView;
@property (nonatomic ,strong) YYLabel *introductionLabel;
@end
@implementation TFBookStoreNovelHorizontalCell
- (void)createSubviews
{
[super createSubviews];
[self setupSubview];
[self setupSubviewFrame];
}
- (void)setupSubview
{
// 作者
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.tagboardView = [[TFTagboardView alloc] init];
self.tagboardView.font = kFont11;
self.tagboardView.textAlignment = TFTagboardTextAlignmentRight;
self.tagboardView.borderStyle = TFTagboardBorderStyleBorder;
self.tagboardView.cornerRadius = 3;
self.tagboardView.spacing = 10;
[self addSubview:self.tagboardView];
// 简介
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 addSubview:self.introductionLabel];
}
- (void)setupSubviewFrame
{
[self.coverView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(0);
make.top.mas_equalTo(0);
make.width.mas_equalTo(BOOK_WIDTH - 10);
make.height.mas_equalTo(kGeometricHeight(BOOK_WIDTH - 10, 3, 4));
}];
[self.titleLabel mas_remakeConstraints:^(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.mas_right);
make.height.mas_equalTo(BOOK_CELL_TITLE_HEIGHT / 2);
}];
[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(10);
make.height.mas_equalTo(self.titleLabel.mas_height);
}];
[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 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);
}];
}
- (void)setLabelListModel:(TFProductionModel *)labelListModel
{
[super setLabelListModel:labelListModel];
self.authorLabel.text = labelListModel.author ? : @"";
[self.authorLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.authorLabel]);
}];
self.tagboardView.tagboardArray = labelListModel.tag;
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString: labelListModel.production_descirption ? : @""];
text.lineSpacing = 5;
text.font = kFont13;
text.color = kColorRGBA(118, 118, 118, 1);
self.introductionLabel.attributedText = text;
}
@end
@@ -0,0 +1,43 @@
//
// TFBookStoreNovelStyleFourCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBookStoreNovelBasicViewCell.h"
NS_ASSUME_NONNULL_BEGIN
/*
横一竖三排布方式
┌──────────────┐ ┌──────────────────────────────────┐
│ │ │ book Name │
│ │ └──────────────────────────────────┘
│ │ ┌──────────────────────────────────┐
│ photo │ │ │
│ │ │ describe │
│ │ │ │
│ │ │ │
└──────────────┘ └──────────────────────────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ photo │ │ photo │ │ photo │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
└──────────────┘ └──────────────┘ └──────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ book Name │ │ book Name │ │ book Name │
└──────────────┘ └──────────────┘ └──────────────┘
*/
@interface TFBookStoreNovelStyleFourCell : TFBookStoreNovelBasicViewCell <UICollectionViewDelegate, UICollectionViewDataSource>
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,82 @@
//
// TFBookStoreNovelStyleFourCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFBookStoreNovelStyleFourCell.h"
#import "TFBookStoreNovelVerticalCell.h"
#import "TFBookStoreNovelHorizontalCell.h"
@implementation TFBookStoreNovelStyleFourCell
static NSString *verticalCell = @"TFBookStoreNovelVerticalCell";
static NSString *horizontalCell = @"TFBookStoreNovelHorizontalCell";
- (void)createSubviews
{
[super createSubviews];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
[self.collectionView registerClass:[TFBookStoreNovelVerticalCell class] forCellWithReuseIdentifier:verticalCell];
[self.collectionView registerClass:[TFBookStoreNovelHorizontalCell class] forCellWithReuseIdentifier:horizontalCell];
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
if (self.labelModel.list.count <= 1) {
return 1;
}
return 2;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
if (self.labelModel.list.count <= 1) {
return 1;
}
if (section == 0) {
return 1;
} else {
return self.labelModel.list.count > 3?3:self.labelModel.list.count - 1;
}
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
TFBookStoreNovelHorizontalCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:horizontalCell forIndexPath:indexPath];
cell.labelListModel = [self.labelModel.list objectOrNilAtIndex:indexPath.row];
cell.hiddenEndLine = YES;
return cell;
} else {
TFBookStoreNovelVerticalCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:verticalCell forIndexPath:indexPath];
cell.labelListModel = [self.labelModel.list objectOrNilAtIndex:indexPath.row + 1];
return cell;
}
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
return CGSizeMake(SCREEN_WIDTH - kMargin, HorizontalCellHeight);
}
return CGSizeMake(BOOK_WIDTH, VerticalCellHeight);
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
TFProductionModel *labelListModel = [self.labelModel.list objectOrNilAtIndex:indexPath.section + indexPath.row];
if (self.cellDidSelectItemBlock) {
self.cellDidSelectItemBlock(labelListModel.production_id);
}
}
@end
@@ -0,0 +1,35 @@
//
// TFBookStoreNovelStyleOneCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBookStoreNovelBasicViewCell.h"
NS_ASSUME_NONNULL_BEGIN
/*
一排三列 排布方式
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ photo │ │ photo │ │ photo │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
└──────────────┘ └──────────────┘ └──────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ book Name │ │ book Name │ │ book Name │
└──────────────┘ └──────────────┘ └──────────────┘
*/
@interface TFBookStoreNovelStyleOneCell : TFBookStoreNovelBasicViewCell <UICollectionViewDelegate, UICollectionViewDataSource>
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,50 @@
//
// TFBookStoreNovelStyleOneCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFBookStoreNovelStyleOneCell.h"
#import "TFBookStoreNovelVerticalCell.h"
@implementation TFBookStoreNovelStyleOneCell
static NSString *cellID = @"TFBookStoreNovelVerticalCell";
- (void)createSubviews
{
[super createSubviews];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
[self.collectionView registerClass:[TFBookStoreNovelVerticalCell class] forCellWithReuseIdentifier:cellID];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
if (!self.labelModel.list) {
return 3;
}
return self.labelModel.list.count <= 3 ? self.labelModel.list.count : 3;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
TFBookStoreNovelVerticalCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
cell.labelListModel = [self.labelModel.list objectOrNilAtIndex:indexPath.row];
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
TFProductionModel *labelListModel = [self.labelModel.list objectOrNilAtIndex:indexPath.row];
if (self.cellDidSelectItemBlock) {
self.cellDidSelectItemBlock(labelListModel.production_id);
}
}
@end
@@ -0,0 +1,61 @@
//
// TFBookStoreNovelStyleThreeCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBookStoreNovelBasicViewCell.h"
NS_ASSUME_NONNULL_BEGIN
/*
横三竖三排布方式
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ photo │ │ photo │ │ photo │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
└──────────────┘ └──────────────┘ └──────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ book Name │ │ book Name │ │ book Name │
└──────────────┘ └──────────────┘ └──────────────┘
┌──────────────┐ ┌──────────────────────────────────┐
│ │ │ book Name │
│ │ └──────────────────────────────────┘
│ │ ┌──────────────────────────────────┐
│ photo │ │ │
│ │ │ describe │
│ │ │ │
│ │ │ │
└──────────────┘ └──────────────────────────────────┘
┌──────────────┐ ┌──────────────────────────────────┐
│ │ │ book Name │
│ │ └──────────────────────────────────┘
│ │ ┌──────────────────────────────────┐
│ photo │ │ │
│ │ │ describe │
│ │ │ │
│ │ │ │
└──────────────┘ └──────────────────────────────────┘
┌──────────────┐ ┌──────────────────────────────────┐
│ │ │ book Name │
│ │ └──────────────────────────────────┘
│ │ ┌──────────────────────────────────┐
│ photo │ │ │
│ │ │ describe │
│ │ │ │
│ │ │ │
└──────────────┘ └──────────────────────────────────┘
*/
@interface TFBookStoreNovelStyleThreeCell : TFBookStoreNovelBasicViewCell <UICollectionViewDelegate, UICollectionViewDataSource>
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,96 @@
//
// TFBookStoreNovelStyleThreeCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFBookStoreNovelStyleThreeCell.h"
#import "TFBookStoreNovelVerticalCell.h"
#import "TFBookStoreNovelHorizontalCell.h"
@implementation TFBookStoreNovelStyleThreeCell
static NSString *verticalCell = @"TFBookStoreNovelVerticalCell";
static NSString *horizontalCell = @"TFBookStoreNovelHorizontalCell";
- (void)createSubviews
{
[super createSubviews];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
[self.collectionView registerClass:[TFBookStoreNovelVerticalCell class] forCellWithReuseIdentifier:verticalCell];
[self.collectionView registerClass:[TFBookStoreNovelHorizontalCell class] forCellWithReuseIdentifier:horizontalCell];
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
if (self.labelModel.list.count <= 3) {
return 1;
}
return 2;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
if (self.labelModel.list.count <= 3) {
return self.labelModel.list.count;
}
if (section == 0) {
return 3;
}
return self.labelModel.list.count - 3;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
TFBookStoreNovelVerticalCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:verticalCell forIndexPath:indexPath];
cell.labelListModel = [self.labelModel.list objectOrNilAtIndex:indexPath.row];
return cell;
} else {
TFBookStoreNovelHorizontalCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:horizontalCell forIndexPath:indexPath];
cell.labelListModel = [self.labelModel.list objectOrNilAtIndex:indexPath.row + 3];
cell.hiddenEndLine = indexPath.row == self.labelModel.list.count - 3 - 1;
return cell;
}
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
return CGSizeMake(BOOK_WIDTH, VerticalCellHeight);
}
return CGSizeMake(SCREEN_WIDTH - kMargin, HorizontalCellHeight);
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
if (section == 0) {
return UIEdgeInsetsMake(0, kHalfMargin, 0, kHalfMargin);
}
return UIEdgeInsetsMake(kHalfMargin, kHalfMargin, 0, kHalfMargin);
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
return kHalfMargin;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
TFProductionModel *labelListModel = [self.labelModel.list objectOrNilAtIndex:indexPath.section * 3 + indexPath.row];
if (self.cellDidSelectItemBlock) {
self.cellDidSelectItemBlock(labelListModel.production_id);
}
}
@end
@@ -0,0 +1,46 @@
//
// TFBookStoreNovelStyleTwoCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBookStoreNovelBasicViewCell.h"
NS_ASSUME_NONNULL_BEGIN
/*
两排三列排布方式
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ photo │ │ photo │ │ photo │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
└──────────────┘ └──────────────┘ └──────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ book Name │ │ book Name │ │ book Name │
└──────────────┘ └──────────────┘ └──────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ photo │ │ photo │ │ photo │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
└──────────────┘ └──────────────┘ └──────────────┘
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ book Name │ │ book Name │ │ book Name │
└──────────────┘ └──────────────┘ └──────────────┘
*/
@interface TFBookStoreNovelStyleTwoCell : TFBookStoreNovelBasicViewCell <UICollectionViewDelegate, UICollectionViewDataSource>
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,53 @@
//
// TFBookStoreNovelStyleTwoCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFBookStoreNovelStyleTwoCell.h"
#import "TFBookStoreNovelVerticalCell.h"
@implementation TFBookStoreNovelStyleTwoCell
static NSString *cellID = @"TFBookStoreNovelVerticalCell";
- (void)createSubviews
{
[super createSubviews];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
[self.collectionView registerClass:[TFBookStoreNovelVerticalCell class] forCellWithReuseIdentifier:cellID];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.labelModel.list.count <= 6 ? self.labelModel.list.count : 6;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
TFBookStoreNovelVerticalCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
cell.labelListModel = [self.labelModel.list objectOrNilAtIndex:indexPath.row];
return cell;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
return kHalfMargin;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
TFProductionModel *production = [self.labelModel.list objectOrNilAtIndex:indexPath.row];
if (self.cellDidSelectItemBlock) {
self.cellDidSelectItemBlock(production.production_id);
}
}
@end
@@ -0,0 +1,36 @@
//
// TFBookStoreNovelVerticalCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBookStoreNovelBasicItemCell.h"
NS_ASSUME_NONNULL_BEGIN
/*
竖直排布书籍cell
┌──────────────┐
│ │
│ │
│ │
│ photo │
│ │
│ │
│ │
└──────────────┘
┌──────────────┐
│ book Name │
└──────────────┘
*/
#define VerticalCellHeight (BOOK_HEIGHT + BOOK_CELL_TITLE_HEIGHT + kQuarterMargin)
@interface TFBookStoreNovelVerticalCell : TFBookStoreNovelBasicItemCell
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,51 @@
//
// TFBookStoreNovelVerticalCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFBookStoreNovelVerticalCell.h"
@implementation TFBookStoreNovelVerticalCell
- (void)createSubviews
{
[super createSubviews];
[self.coverView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.mas_centerX);
make.top.mas_equalTo(self.mas_top);
make.width.mas_equalTo(BOOK_WIDTH);
make.height.mas_equalTo(BOOK_HEIGHT);
}];
[self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.coverView.mas_left);
make.top.mas_equalTo(self.coverView.mas_bottom).with.offset(kQuarterMargin);
make.width.mas_equalTo(self.coverView.mas_width);
make.height.mas_equalTo(BOOK_CELL_TITLE_HEIGHT / 2);
}];
self.subtitleLabel.hidden = NO;
}
- (void)setLabelListModel:(TFProductionModel *)labelListModel
{
[super setLabelListModel:labelListModel];
NSString *str = @"";
for (TFTagModel *tagModel in labelListModel.tag) {
if (tagModel.tab.length > 0) {
str = [[str stringByAppendingString:tagModel.tab ? : @""] stringByAppendingString:@" "];
}
}
if (str.length == 0) {
str = labelListModel.production_descirption;
}
self.subtitleLabel.text = str;
}
@end