小说绘上架版本
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// TFBookStoreComicBasicItemCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFProductionCoverView.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
#define Comic_MaxCross_Geometric_Height(x) (((5 * x) / 9))
|
||||
#define Comic_MiddleCross_Geometric_Height(x) (((2 * x) / 3))
|
||||
#define Comic_Normal_Geometric_Height(x) (((4 * x) / 3))
|
||||
#define Comic_Cell_Title_Height 40
|
||||
#define Comic_Cell_Line_Space 3.0f
|
||||
|
||||
@interface TFBookStoreComicBasicItemCell : UICollectionViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFProductionModel *productionModel;
|
||||
@property (nonatomic ,strong) TFProductionCoverView *comicCoverView;
|
||||
@property (nonatomic ,strong) UILabel *titileLabel;
|
||||
@property (nonatomic ,strong) UILabel *describeLabel;
|
||||
|
||||
- (void)createSubViews;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// TFBookStoreComicBasicItemCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreComicBasicItemCell.h"
|
||||
#import "TFBookStoreComicNormalItemCell.h"
|
||||
|
||||
@interface TFBookStoreComicBasicItemCell ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookStoreComicBasicItemCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
|
||||
self.backgroundColor = kWhiteColor;
|
||||
[self createSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
[self setupSubview];
|
||||
[self setupSubviewFrame];
|
||||
}
|
||||
|
||||
- (void)setupSubview
|
||||
{
|
||||
self.comicCoverView = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeComic coverDirection:TFProductionCoverDirectionVertical];
|
||||
[self addSubview:self.comicCoverView];
|
||||
|
||||
self.titileLabel = [[UILabel alloc] init];
|
||||
self.titileLabel.textColor = kBlackColor;
|
||||
self.titileLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.titileLabel.font = kMainFont;
|
||||
self.titileLabel.numberOfLines = 1;
|
||||
[self addSubview:self.titileLabel];
|
||||
|
||||
self.describeLabel = [[UILabel alloc] init];
|
||||
self.describeLabel.textColor = kGrayTextColor;
|
||||
self.describeLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.describeLabel.font = kFont12;
|
||||
self.describeLabel.numberOfLines = 1;
|
||||
[self addSubview:self.describeLabel];
|
||||
}
|
||||
|
||||
- (void)setupSubviewFrame
|
||||
{
|
||||
[self.comicCoverView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.mas_left);
|
||||
make.top.mas_equalTo(self.mas_top);
|
||||
make.width.mas_equalTo(Comic_NormalVertical_Width);
|
||||
make.height.mas_equalTo(Comic_NormalVertical_Height);
|
||||
}];
|
||||
|
||||
|
||||
[self.titileLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.mas_left).with.offset(kQuarterMargin);
|
||||
make.top.mas_equalTo(self.comicCoverView.mas_bottom).with.offset(kQuarterMargin);
|
||||
make.right.mas_equalTo(self.mas_right).with.offset(-kQuarterMargin);
|
||||
make.height.mas_equalTo(Comic_Cell_Title_Height / 2);
|
||||
}];
|
||||
|
||||
|
||||
[self.describeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.titileLabel.mas_left);
|
||||
make.top.mas_equalTo(self.titileLabel.mas_bottom);
|
||||
make.right.mas_equalTo(self.titileLabel.mas_right);
|
||||
make.height.mas_equalTo(self.titileLabel.mas_height);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setProductionModel:(TFProductionModel *)productionModel
|
||||
{
|
||||
if (!productionModel) return;
|
||||
|
||||
_productionModel = productionModel;
|
||||
|
||||
self.comicCoverView.coverTitleString = productionModel.flag ? : @"";
|
||||
self.titileLabel.text = productionModel.name ? : @"";
|
||||
}
|
||||
|
||||
@end
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// TFBookStoreComicBasicViewCell.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
|
||||
|
||||
typedef void (^CellDidSelectItemBlock)(NSInteger production_id);
|
||||
typedef void (^CellSelectMoreBlock)(TFBookStoreLabelModel *labelModel);
|
||||
|
||||
@interface TFBookStoreComicBasicViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,strong) UICollectionView *collectionView;
|
||||
@property (nonatomic ,assign) BOOL showTopMoreButton;
|
||||
@property (nonatomic ,strong) TFBookStoreLabelModel *labelModel;
|
||||
@property (nonatomic ,copy) CellDidSelectItemBlock cellDidSelectItemBlock;
|
||||
@property (nonatomic ,copy) CellSelectMoreBlock cellSelectMoreBlock;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
//
|
||||
// TFBookStoreComicBasicViewCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreComicBasicViewCell.h"
|
||||
#import "TFBookStoreComicBasicItemCell.h"
|
||||
#import "TFBookStoreComicNormalItemCell.h"
|
||||
#import "TFBookStoreComicMiddleItemCell.h"
|
||||
#import "TFBookStoreComicMaxItemCell.h"
|
||||
|
||||
@interface TFBookStoreComicBasicViewCell ()
|
||||
|
||||
@property (nonatomic ,strong) UIImageView *iconView;
|
||||
@property (nonatomic ,strong) UILabel *titleLabel;
|
||||
@property (nonatomic ,strong) TFButton *moreButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookStoreComicBasicViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
[self setupSubview];
|
||||
[self setupSubviewFrame];
|
||||
}
|
||||
|
||||
- (void)setupSubview
|
||||
{
|
||||
self.iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"comic_label_hold"]];
|
||||
self.iconView.hidden = YES;
|
||||
[self.contentView addSubview:self.iconView];
|
||||
|
||||
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.moreButton = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:TFLocalizedString(@"查看更多") buttonImageName:@"public_more" buttonIndicator:TFButtonIndicatorTitleLeft];
|
||||
self.moreButton.buttonTintColor = kGrayTextLightColor;
|
||||
self.moreButton.graphicDistance = 5;
|
||||
self.moreButton.buttonImageScale = 0.35;
|
||||
self.moreButton.hidden = YES;
|
||||
[self.moreButton addTarget:self action:@selector(moreButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.contentView addSubview:self.moreButton];
|
||||
|
||||
|
||||
|
||||
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
|
||||
flowLayout.minimumInteritemSpacing = Comic_Cell_Line_Space;
|
||||
flowLayout.minimumLineSpacing = 0.01;
|
||||
flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
|
||||
flowLayout.itemSize = CGSizeMake(Comic_NormalVertical_Width, Comic_NormalVertical_Height);
|
||||
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;
|
||||
[self.contentView addSubview:self.collectionView];
|
||||
}
|
||||
|
||||
- (void)setupSubviewFrame
|
||||
{
|
||||
[self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kHalfMargin);
|
||||
make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
|
||||
make.width.mas_equalTo(kHalfMargin + kHalfMargin);
|
||||
make.height.mas_equalTo(kHalfMargin + kHalfMargin);
|
||||
}];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin + kHalfMargin + kQuarterMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH / 2);
|
||||
make.height.mas_equalTo(kLabelHeight + kHalfMargin);
|
||||
}];
|
||||
|
||||
[self.moreButton 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.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();
|
||||
}];
|
||||
}
|
||||
|
||||
- (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]);
|
||||
}];
|
||||
|
||||
self.iconView.hidden = NO;
|
||||
[self.collectionView reloadData];
|
||||
|
||||
switch (labelModel.style) {
|
||||
case 1: {
|
||||
[self.collectionView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(labelModel.list.count < 3 ? Comic_MiddleCell_Height : Comic_MiddleCell_Height *2);
|
||||
}];
|
||||
}
|
||||
break;
|
||||
case 2: {
|
||||
[self.collectionView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(labelModel.list.count <= 3 ? Comic_NormalCell_Height : Comic_NormalCell_Height *2);
|
||||
}];
|
||||
}
|
||||
break;
|
||||
case 3: {
|
||||
[self.collectionView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(Comic_MaxCell_Height + (labelModel.list.count == 1 ? 0 : Comic_NormalCell_Height));
|
||||
}];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setShowTopMoreButton:(BOOL)showTopMoreButton
|
||||
{
|
||||
_showTopMoreButton = showTopMoreButton;
|
||||
|
||||
self.moreButton.hidden = !showTopMoreButton;
|
||||
}
|
||||
|
||||
- (void)moreButtonClick
|
||||
{
|
||||
if (self.cellSelectMoreBlock) {
|
||||
self.cellSelectMoreBlock(self.labelModel);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// TFBookStoreComicMaxItemCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBookStoreComicBasicItemCell.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// 大图设置
|
||||
#define Comic_MaxCross_Width (SCREEN_WIDTH - 2 * kHalfMargin)
|
||||
#define Comic_MaxCross_Height Comic_MaxCross_Geometric_Height(Comic_MaxCross_Width)
|
||||
#define Comic_MaxCell_Width Comic_MaxCross_Width
|
||||
#define Comic_MaxCell_Height (Comic_MaxCross_Height + Comic_Cell_Title_Height + kHalfMargin)
|
||||
|
||||
@interface TFBookStoreComicMaxItemCell : TFBookStoreComicBasicItemCell
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// TFBookStoreComicMaxItemCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreComicMaxItemCell.h"
|
||||
|
||||
@implementation TFBookStoreComicMaxItemCell
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
[super createSubViews];
|
||||
|
||||
self.comicCoverView.coverDirection = TFProductionCoverDirectionHorizontal;
|
||||
|
||||
[self.comicCoverView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(Comic_MaxCross_Width);
|
||||
make.height.mas_equalTo(Comic_MaxCross_Height);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setProductionModel:(TFProductionModel *)productionModel
|
||||
{
|
||||
[super setProductionModel:productionModel];
|
||||
|
||||
if (productionModel.horizontal_cover.length > 0) {
|
||||
self.comicCoverView.coverImageUrl = productionModel.horizontal_cover;
|
||||
} else if (productionModel.vertical_cover.length > 0) {
|
||||
self.comicCoverView.coverImageUrl = productionModel.vertical_cover;
|
||||
}
|
||||
|
||||
self.describeLabel.text = productionModel.production_descirption ? : @"";
|
||||
}
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFBookStoreComicMaxStyleCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBookStoreComicBasicViewCell.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFBookStoreComicMaxStyleCell : TFBookStoreComicBasicViewCell
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// TFBookStoreComicMaxStyleCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreComicMaxStyleCell.h"
|
||||
#import "TFBookStoreComicMaxItemCell.h"
|
||||
#import "TFBookStoreComicNormalItemCell.h"
|
||||
|
||||
@interface TFBookStoreComicMaxStyleCell ()<UICollectionViewDelegate, UICollectionViewDataSource>
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookStoreComicMaxStyleCell
|
||||
static NSString *maxItem = @"TFBookStoreComicMaxItemCell";
|
||||
static NSString *normalItem = @"TFBookStoreComicNormalItemCell";
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
self.collectionView.delegate = self;
|
||||
self.collectionView.dataSource = self;
|
||||
|
||||
[self.collectionView registerClass:[TFBookStoreComicMaxItemCell class] forCellWithReuseIdentifier:maxItem];
|
||||
[self.collectionView registerClass:[TFBookStoreComicNormalItemCell class] forCellWithReuseIdentifier:normalItem];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
|
||||
{
|
||||
if (self.labelModel.list.count == 0) {
|
||||
return 0;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
|
||||
{
|
||||
if (section == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return self.labelModel.list.count <= 3 ? self.labelModel.list.count : 3;
|
||||
}
|
||||
}
|
||||
|
||||
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (indexPath.section == 0) {
|
||||
TFBookStoreComicMaxItemCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:maxItem forIndexPath:indexPath];
|
||||
cell.productionModel = [self.labelModel.list objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
return cell;
|
||||
|
||||
} else {
|
||||
TFBookStoreComicNormalItemCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:normalItem forIndexPath:indexPath];
|
||||
cell.productionModel = [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(Comic_MaxCell_Width ,Comic_MaxCell_Height);
|
||||
}
|
||||
return CGSizeMake(Comic_NormalCell_Width ,Comic_NormalCell_Height);
|
||||
}
|
||||
|
||||
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *production = [self.labelModel.list objectOrNilAtIndex:indexPath.row];
|
||||
if (indexPath.section != 0) {
|
||||
production = [self.labelModel.list objectOrNilAtIndex:indexPath.row + 1];
|
||||
}
|
||||
|
||||
if (self.cellDidSelectItemBlock) {
|
||||
self.cellDidSelectItemBlock(production.production_id);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// TFBookStoreComicMiddleItemCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBookStoreComicBasicItemCell.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// 中图设置
|
||||
#define Comic_MiddleCross_Width (SCREEN_WIDTH - Comic_Cell_Line_Space - 2 * kHalfMargin) / 2
|
||||
#define Comic_MiddleCross_Height Comic_MiddleCross_Geometric_Height(Comic_MiddleCross_Width)
|
||||
#define Comic_MiddleCell_Width Comic_MiddleCross_Width
|
||||
#define Comic_MiddleCell_Height (Comic_MiddleCross_Height + Comic_Cell_Title_Height + kHalfMargin)
|
||||
|
||||
@interface TFBookStoreComicMiddleItemCell : TFBookStoreComicBasicItemCell
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// TFBookStoreComicMiddleItemCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreComicMiddleItemCell.h"
|
||||
|
||||
@implementation TFBookStoreComicMiddleItemCell
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
[super createSubViews];
|
||||
|
||||
self.comicCoverView.coverDirection = TFProductionCoverDirectionHorizontal;
|
||||
|
||||
[self.comicCoverView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(Comic_MiddleCross_Width);
|
||||
make.height.mas_equalTo(Comic_MiddleCross_Height);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setProductionModel:(TFProductionModel *)productionModel
|
||||
{
|
||||
[super setProductionModel:productionModel];
|
||||
|
||||
if (productionModel.horizontal_cover.length > 0) {
|
||||
|
||||
self.comicCoverView.coverImageUrl = productionModel.horizontal_cover;
|
||||
} else if (productionModel.vertical_cover.length > 0) {
|
||||
|
||||
self.comicCoverView.coverImageUrl = productionModel.vertical_cover;
|
||||
}
|
||||
|
||||
self.describeLabel.text = productionModel.production_descirption ? : @"";
|
||||
}
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFBookStoreComicMiddleStyleCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBookStoreComicBasicViewCell.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFBookStoreComicMiddleStyleCell : TFBookStoreComicBasicViewCell
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// TFBookStoreComicMiddleStyleCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreComicMiddleStyleCell.h"
|
||||
#import "TFBookStoreComicMiddleItemCell.h"
|
||||
|
||||
@interface TFBookStoreComicMiddleStyleCell ()<UICollectionViewDelegate, UICollectionViewDataSource>
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookStoreComicMiddleStyleCell
|
||||
static NSString *cellID = @"TFBookStoreComicMiddleItemCell";
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
self.collectionView.delegate = self;
|
||||
self.collectionView.dataSource = self;
|
||||
|
||||
[self.collectionView registerClass:[TFBookStoreComicMiddleItemCell class] forCellWithReuseIdentifier:cellID];
|
||||
}
|
||||
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
|
||||
{
|
||||
return self.labelModel.list.count <= 4 ? self.labelModel.list.count : 4;
|
||||
}
|
||||
|
||||
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFBookStoreComicMiddleItemCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
|
||||
cell.productionModel = [self.labelModel.list objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return CGSizeMake(Comic_MiddleCell_Width, Comic_MiddleCell_Height);
|
||||
}
|
||||
|
||||
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *production = [self.labelModel.list objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
if (self.cellDidSelectItemBlock) {
|
||||
self.cellDidSelectItemBlock(production.production_id);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// TFBookStoreComicNormalItemCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBookStoreComicBasicItemCell.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// 小图设置
|
||||
#define Comic_NormalVertical_Width (SCREEN_WIDTH - 2 * Comic_Cell_Line_Space - 2 * kHalfMargin) / 3
|
||||
#define Comic_NormalVertical_Height Comic_Normal_Geometric_Height(Comic_NormalVertical_Width)
|
||||
#define Comic_NormalCell_Width Comic_NormalVertical_Width
|
||||
#define Comic_NormalCell_Height (Comic_NormalVertical_Height + Comic_Cell_Title_Height + kHalfMargin)
|
||||
|
||||
@interface TFBookStoreComicNormalItemCell : TFBookStoreComicBasicItemCell
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// TFBookStoreComicNormalItemCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreComicNormalItemCell.h"
|
||||
|
||||
@implementation TFBookStoreComicNormalItemCell
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
[super createSubViews];
|
||||
|
||||
[self.comicCoverView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(Comic_NormalVertical_Width);
|
||||
make.height.mas_equalTo(Comic_NormalVertical_Height);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setProductionModel:(TFProductionModel *)productionModel
|
||||
{
|
||||
[super setProductionModel:productionModel];
|
||||
|
||||
if (productionModel.vertical_cover.length > 0) {
|
||||
self.comicCoverView.coverImageUrl = productionModel.vertical_cover;
|
||||
} else if (productionModel.horizontal_cover.length > 0) {
|
||||
self.comicCoverView.coverImageUrl = productionModel.horizontal_cover;
|
||||
}
|
||||
|
||||
NSString *describeStr = @"";
|
||||
for (TFTagModel *tagModel in productionModel.tag) {
|
||||
describeStr = [[describeStr stringByAppendingString:tagModel.tab ? : @""] stringByAppendingString:@" "];
|
||||
}
|
||||
self.describeLabel.text = describeStr ? : @"";
|
||||
}
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFBookStoreComicNormalStyleCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBookStoreComicBasicViewCell.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFBookStoreComicNormalStyleCell : TFBookStoreComicBasicViewCell
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// TFBookStoreComicNormalStyleCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreComicNormalStyleCell.h"
|
||||
#import "TFBookStoreComicNormalItemCell.h"
|
||||
|
||||
@interface TFBookStoreComicNormalStyleCell ()<UICollectionViewDelegate, UICollectionViewDataSource>
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookStoreComicNormalStyleCell
|
||||
static NSString *cellID = @"TFBookStoreComicNormalItemCell";
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
self.collectionView.delegate = self;
|
||||
self.collectionView.dataSource = self;
|
||||
|
||||
[self.collectionView registerClass:[TFBookStoreComicNormalItemCell 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
|
||||
{
|
||||
TFBookStoreComicNormalItemCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
|
||||
cell.productionModel = [self.labelModel.list objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
return CGSizeMake(Comic_NormalCell_Width, Comic_NormalCell_Height);
|
||||
}
|
||||
|
||||
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *listModel = [self.labelModel.list objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
if (self.cellDidSelectItemBlock) {
|
||||
self.cellDidSelectItemBlock(listModel.production_id);
|
||||
}
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user