小说绘上架版本

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,22 @@
//
// TFBookStoreComicController.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBasicViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFBookStoreComicController : TFBasicViewController
@property (nonatomic ,assign) CGFloat channel;
@property (nonatomic ,assign) CGFloat scrollViewContentOffsetY;
@property (nonatomic ,strong) NSArray *hotwordArray;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,353 @@
//
// TFBookStoreComicController.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFBookStoreComicController.h"
#import "TFLimitFreeViewController.h"
#import "TFBookStoreComicMaxStyleCell.h"
#import "TFBookStoreComicMiddleStyleCell.h"
#import "TFBookStoreComicNormalStyleCell.h"
#import "TFPublicAdvertisementViewCell.h"
#import "TFBookStoreMenuView.h"
#import "TFBookStoreLabelModel.h"
#import "TFBannerActionManager.h"
// 分类
#import "TFSortViewController.h"
// 排行榜
#import "TFPopularityViewController.h"
// 会员
#import "TFMemberViewController.h"
// 完本
#import "TFCompleteViewController.h"
// 限免
#import "TFFreeViewController.h"
@interface TFBookStoreComicController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic ,strong) TFBookStoreMenuView *headerView;
@property (nonatomic ,strong) TFBookStoreModel *comicModel;
@property (nonatomic ,assign) BOOL needRefresh;
@end
@implementation TFBookStoreComicController
- (void)viewDidLoad
{
[super viewDidLoad];
[self initialize];
[self createSubviews];
[self netRequest];
}
- (void)initialize
{
self.needRefresh = YES;
[self hiddenNavigationBar:YES];
self.hotwordArray = [NSArray array];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netRequest) name:Notification_Channel_Change object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netRequest) name:Notification_Restore_Network object:nil];
}
- (void)createSubviews
{
self.mainTableViewGroup.delegate = self;
self.mainTableViewGroup.dataSource = self;
[self.view addSubview:self.mainTableViewGroup];
[self.mainTableViewGroup mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(0);
make.top.mas_equalTo(0);
make.width.mas_equalTo(self.view.mas_width);
make.height.mas_equalTo(self.view.mas_height).with.offset(- PUB_TABBAR_HEIGHT);
}];
WS(weakSelf)
self.headerView = [[TFBookStoreMenuView alloc] init];
self.headerView.productionType = self.productionType;
self.headerView.bannerrImageClickBlock = ^(TFBannerModel * _Nonnull bannerModel) {
if ([TFBannerActionManager getBannerActionWithBannerModel:bannerModel productionType:TFProductionTypeComic]) {
[weakSelf.navigationController pushViewController:[TFBannerActionManager getBannerActionWithBannerModel:bannerModel productionType:TFProductionTypeComic] animated:YES];
}
};
self.headerView.menuButtonClickBlock = ^(TFMenuButtonType menuButtonType, NSString * _Nonnull menuButtonTitle) {
switch (menuButtonType) {
case TFMenuButtonTypeFree: {
TFFreeViewController *free = [[TFFreeViewController alloc] init];
free.productionType = weakSelf.productionType;
free.navTitle = menuButtonTitle;
[weakSelf.navigationController pushViewController:free animated:YES];
}
break;
case TFMenuButtonTypeComplete: {
TFCompleteViewController *complete = [[TFCompleteViewController alloc] init];
complete.productionType = weakSelf.productionType;
complete.navTitle = menuButtonTitle;
[weakSelf.navigationController pushViewController:complete animated:YES];
}
break;
case TFMenuButtonTypeSort: {
TFSortViewController *sort = [[TFSortViewController alloc] init];
sort.productionType = weakSelf.productionType;
sort.navTitle = menuButtonTitle;
[weakSelf.navigationController pushViewController:sort animated:YES];
}
break;
case TFMenuButtonTypePopularity: {
TFPopularityViewController *popularity = [[TFPopularityViewController alloc] init];
popularity.productionType = weakSelf.productionType;
popularity.navTitle = menuButtonTitle;
[weakSelf.navigationController pushViewController:popularity animated:YES];
}
break;
case TFMenuButtonTypeMember: {
TFMemberViewController *member = [[TFMemberViewController alloc] init];
member.productionType = weakSelf.productionType;
[weakSelf.navigationController pushViewController:member animated:YES];
}
break;
default:
break;
}
};
self.mainTableViewGroup.tableHeaderView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH);
[self.mainTableViewGroup setTableHeaderView:self.headerView];
self.mainTableViewGroup.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
[weakSelf netRequest];
}];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.comicModel.label.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
TFBookStoreLabelModel *labelModel = [self.comicModel.label objectOrNilAtIndex:indexPath.section];
if (labelModel.ad_type == 0) {
return [self createCellWithTabelView:tableView indexPath:indexPath labelModel:labelModel];
} else {
return [self createAdStyleCellWithTableView:tableView indexPath:indexPath adModel:labelModel];
}
}
- (UITableViewCell *)createCellWithTabelView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath labelModel:(TFBookStoreLabelModel *)labelModel
{
Class cellClass = TFBookStoreComicNormalStyleCell.class;
switch (labelModel.style) {
case 1:
cellClass = TFBookStoreComicMiddleStyleCell.class;
break;
case 2:
cellClass = TFBookStoreComicNormalStyleCell.class;
break;
case 3:
cellClass = TFBookStoreComicMaxStyleCell.class;
break;
default:
cellClass = TFBookStoreComicNormalStyleCell.class;
break;
}
WS(weakSelf)
TFBookStoreComicBasicViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(cellClass)];
if (!cell) {
cell = [[cellClass alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(cellClass)];
}
cell.labelModel = labelModel;
cell.cellDidSelectItemBlock = ^(NSInteger production_id) {
TFComicDetailViewController *vc = [[TFComicDetailViewController alloc] init];
vc.comic_id = production_id;
[weakSelf.navigationController pushViewController:vc animated:YES];
};
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (UITableViewCell *)createAdStyleCellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath adModel:(TFBookStoreLabelModel *)labelModel
{
static NSString *cellName = @"TFPublicAdvertisementViewCell";
TFPublicAdvertisementViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
if (!cell) {
cell = [[TFPublicAdvertisementViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
}
[cell setAdModel:labelModel refresh:self.needRefresh];
cell.mainTableView = tableView;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return CGFLOAT_MIN;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, CGFLOAT_MIN)];
view.backgroundColor = [UIColor clearColor];
return view;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
TFBookStoreLabelModel *labelModel = [self.comicModel.label objectOrNilAtIndex:section];
if (labelModel.can_more || labelModel.can_refresh) {
return 50;
}
return CGFLOAT_MIN;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 50)];
view.backgroundColor = [UIColor whiteColor];
CGFloat buttonX = SCREEN_WIDTH / 4;
CGFloat buttonY = 10;
CGFloat buttonW = SCREEN_WIDTH / 2;
CGFloat buttonH = 30;
TFBookStoreLabelModel *labelModel = [self.comicModel.label objectOrNilAtIndex:section];
if (!labelModel.can_more && !labelModel.can_refresh) {
return view;
}
TFButton *moreButton = [TFButton initWithFrame:CGRectMake(buttonX, buttonY, buttonW, buttonH) btnTitle:TFLocalizedString(@"更多") btnImageName:@"comic_mall_more" backgroundColor:kGrayViewColor btnTintColor:kGrayTextLightColor btnStyle:TFButtonIndicatorTitleLeft cornerRadius:15 target:self action:@selector(moreButtonClick:)];
moreButton.graphicDistance = 5;
moreButton.tag = section;
[moreButton addTarget:self action:@selector(moreButtonClick:) forControlEvents:UIControlEventTouchUpInside];
TFButton *changeButton = [TFButton initWithFrame:CGRectMake(buttonX, 0, buttonW, buttonH) btnTitle:TFLocalizedString(@"换一换") btnImageName:@"comic_mall_refresh" backgroundColor:kGrayViewColor btnTintColor:kGrayTextLightColor btnStyle:TFButtonIndicatorTitleLeft cornerRadius:15 target:self action:@selector(changeButtonClick:)];
changeButton.graphicDistance = 5;
changeButton.buttonImageScale = 0.5;
changeButton.tag = section;
[changeButton addTarget:self action:@selector(changeButtonClick:) forControlEvents:UIControlEventTouchUpInside];
if (labelModel.can_more && !labelModel.can_refresh) {
[view addSubview:moreButton];
}
if (!labelModel.can_more && labelModel.can_refresh) {
[view addSubview:changeButton];
}
if (labelModel.can_more && labelModel.can_refresh) {
moreButton.frame = CGRectMake(kMargin, buttonY, (SCREEN_WIDTH - 3 * kMargin) / 2, buttonH);
changeButton.frame = CGRectMake(2 * kMargin + (SCREEN_WIDTH - 3 * kMargin) / 2, buttonY, (SCREEN_WIDTH - 3 * kMargin) / 2, buttonH);
[view addSubview:moreButton];
[view addSubview:changeButton];
}
return view;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat pointY = scrollView.contentOffset.y;
self.scrollViewContentOffsetY = pointY;
[UIApplication sharedApplication].statusBarHidden = NO;
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
CGFloat pointY = scrollView.contentOffset.y;
self.scrollViewContentOffsetY = pointY;
}
- (void)moreButtonClick:(UIButton *)sender
{
TFBookStoreLabelModel *t_labelModel = [self.comicModel.label objectOrNilAtIndex:sender.tag];
if (t_labelModel.expire_time > 0) {
TFLimitFreeViewController *vc = [[TFLimitFreeViewController alloc] init];
vc.productionType = self.productionType;
[self.navigationController pushViewController:vc animated:YES];
} else {
TFBookStoreMoreViewController *vc = [[TFBookStoreMoreViewController alloc] init];
vc.productionType = self.productionType;
vc.recommend_id = [TFUtilsHelper formatStringWithInteger:t_labelModel.recommend_id];
[self.navigationController pushViewController:vc animated:YES];
}
}
- (void)changeButtonClick:(UIButton *)sender
{
TFButton *button = (TFButton *)sender;
[button startSpin];
[self changeRecommendRequestAtIndex:sender.tag complete:^{
[button stopSpin];
}];
}
- (void)netRequest
{
WS(weakSelf)
[TFNetworkTools POSTQuick:Comic_Mall parameters:@{@"channel_id":self.channel != 0?[TFUtilsHelper formatStringWithInteger:self.channel]:@(TFSystemInfoManager.sexChannel)} model:TFBookStoreModel.class success:^(BOOL isSuccess, TFBookStoreModel * _Nullable t_model, BOOL isCache, TFNetworkRequestModel * _Nonnull requestModel) {
if (isSuccess) {
weakSelf.comicModel = t_model;
weakSelf.headerView.mallCenterModel = t_model;
weakSelf.hotwordArray = t_model.hot_word;
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Reload_Mall_Hot_Word object:nil];
}
[weakSelf.mainTableViewGroup endRefreshing];
weakSelf.needRefresh = YES;
[weakSelf.mainTableViewGroup reloadData];
dispatch_async(dispatch_get_main_queue(), ^{
weakSelf.needRefresh = NO;
});
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[weakSelf.mainTableViewGroup endRefreshing];
[weakSelf.mainTableViewGroup reloadData];
}];
}
- (void)changeRecommendRequestAtIndex:(NSInteger)index complete:(void(^)(void))complete
{
TFBookStoreLabelModel *t_labelModel = [self.comicModel.label objectOrNilAtIndex:index];
NSString *recommend_id = [TFUtilsHelper formatStringWithInteger:t_labelModel.recommend_id];
if (recommend_id.length <= 0 || [recommend_id isEqualToString:@"0"]) {
return;
}
WS(weakSelf)
[TFNetworkTools POST:Comic_Refresh parameters:@{@"recommend_id":recommend_id} model:TFBookStoreLabelModel.class success:^(BOOL isSuccess, TFBookStoreLabelModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
if (isSuccess) {
if (t_model.list.count > 0) {
[weakSelf.comicModel.label objectAtIndex:index].list = t_model.list;
TFBookStoreComicBasicViewCell *cell = [weakSelf.mainTableViewGroup cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:index]];
cell.labelModel = t_model;
!complete ?: complete();
}
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
!complete ?: complete();
}];
}
@end
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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