小说绘上架版本
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TFBookStoreAudioController.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 TFBookStoreAudioController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,assign) CGFloat channel;
|
||||
@property (nonatomic ,assign) CGFloat scrollViewContentOffsetY;
|
||||
@property (nonatomic ,strong) NSArray *hotwordArray;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+366
@@ -0,0 +1,366 @@
|
||||
//
|
||||
// TFBookStoreAudioController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreAudioController.h"
|
||||
#import "TFLimitFreeViewController.h"
|
||||
#import "TFBookStoreNovelStyleOneCell.h"
|
||||
#import "TFBookStoreNovelStyleTwoCell.h"
|
||||
#import "TFBookStoreNovelStyleThreeCell.h"
|
||||
#import "TFBookStoreNovelStyleFourCell.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 TFBookStoreAudioController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) TFBookStoreMenuView *headerView;
|
||||
@property (nonatomic ,strong) TFBookStoreModel *audioMallModel;
|
||||
@property (nonatomic ,assign) BOOL needRefresh;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookStoreAudioController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
[self netRequest];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netRequest) name:Notification_Restore_Network object:nil];
|
||||
}
|
||||
|
||||
- (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];
|
||||
}
|
||||
|
||||
- (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:TFProductionTypeAudio]) {
|
||||
[weakSelf.navigationController pushViewController:[TFBannerActionManager getBannerActionWithBannerModel:bannerModel productionType:TFProductionTypeAudio] 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.audioMallModel.label.count;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFBookStoreLabelModel *labelModel = [self.audioMallModel.label objectOrNilAtIndex:indexPath.section];
|
||||
for (TFProductionModel *t_model in labelModel.list) {
|
||||
t_model.productionType = self.productionType;
|
||||
}
|
||||
if (labelModel.ad_type == 0) {
|
||||
switch (labelModel.style) {
|
||||
case 1:
|
||||
return [self createCellWithTabelView:tableView cellClass:TFBookStoreNovelStyleOneCell.class indexPath:indexPath labelModel:labelModel];
|
||||
break;
|
||||
case 2:
|
||||
return [self createCellWithTabelView:tableView cellClass:TFBookStoreNovelStyleTwoCell.class indexPath:indexPath labelModel:labelModel];
|
||||
break;
|
||||
case 3:
|
||||
return [self createCellWithTabelView:tableView cellClass:TFBookStoreNovelStyleThreeCell.class indexPath:indexPath labelModel:labelModel];
|
||||
break;
|
||||
case 4:
|
||||
return [self createCellWithTabelView:tableView cellClass:TFBookStoreNovelStyleFourCell.class indexPath:indexPath labelModel:labelModel];
|
||||
break;
|
||||
|
||||
default:
|
||||
return [self createCellWithTabelView:tableView cellClass:TFBookStoreNovelStyleOneCell.class indexPath:indexPath labelModel:labelModel];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
return [self createAdStyleCellWithTableView:tableView indexPath:indexPath adModel:labelModel];
|
||||
}
|
||||
}
|
||||
|
||||
- (UITableViewCell *)createCellWithTabelView:(UITableView *)tableView cellClass:(Class)cellClass indexPath:(NSIndexPath *)indexPath labelModel:(TFBookStoreLabelModel *)labelModel
|
||||
{
|
||||
WS(weakSelf)
|
||||
TFBookStoreNovelBasicViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(cellClass)];
|
||||
if (!cell) {
|
||||
cell = [[cellClass alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(cellClass)];
|
||||
}
|
||||
|
||||
cell.labelModel = labelModel;
|
||||
cell.cellDidSelectItemBlock = ^(NSInteger production_id) {
|
||||
TFAudioDetailViewController *vc = [[TFAudioDetailViewController alloc] init];
|
||||
vc.audio_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.audioMallModel.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.audioMallModel.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;
|
||||
}
|
||||
|
||||
#pragma mark - 点击事件
|
||||
- (void)moreButtonClick:(UIButton *)sender
|
||||
{
|
||||
TFBookStoreLabelModel *t_labelModel = [self.audioMallModel.label objectOrNilAtIndex:sender.tag];
|
||||
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 changeBookRecommendRequestAtIndex:sender.tag complete:^{
|
||||
[button stopSpin];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
WS(weakSelf)
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"channel_id"] = (self.channel != 0) ? [TFUtilsHelper formatStringWithInteger:self.channel] : @(TFSystemInfoManager.sexChannel);
|
||||
|
||||
[TFNetworkTools POSTQuick:Audio_Mall parameters:params model:TFBookStoreModel.class success:^(BOOL isSuccess, TFBookStoreModel * _Nullable t_model, BOOL isCache, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
|
||||
if (isSuccess) {
|
||||
weakSelf.audioMallModel = 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];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)changeBookRecommendRequestAtIndex:(NSInteger)index complete:(void(^)(void))complete;
|
||||
{
|
||||
TFBookStoreLabelModel *t_labelModel = [self.audioMallModel.label objectOrNilAtIndex:index];
|
||||
NSString *recommend_id = [TFUtilsHelper formatStringWithInteger:t_labelModel.recommend_id];
|
||||
|
||||
if (recommend_id.length <= 0) return;
|
||||
|
||||
WS(weakSelf)
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"recommend_id"] = recommend_id;
|
||||
|
||||
[TFNetworkTools POST:Audio_Refresh parameters:params model:TFBookStoreLabelModel.class success:^(BOOL isSuccess, TFBookStoreLabelModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
|
||||
if (isSuccess) {
|
||||
for (TFProductionModel *obj in t_model.list) {
|
||||
obj.productionType = weakSelf.productionType;
|
||||
}
|
||||
[weakSelf.audioMallModel.label objectAtIndex:index].list = t_model.list;
|
||||
|
||||
TFBookStoreNovelBasicViewCell *cell = [weakSelf.mainTableViewGroup cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:index]];
|
||||
t_model.style = cell.labelModel.style;
|
||||
cell.labelModel = t_model;
|
||||
!complete ? : complete();
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
!complete ?: complete();
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+22
@@ -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
|
||||
+353
@@ -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
|
||||
+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
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// TFBookStoreMoreViewController.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFBookStoreMoreViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,copy) NSString *recommend_id;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
//
|
||||
// TFBookStoreMoreViewController.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreMoreViewController.h"
|
||||
#import "TFBookStoreRecommend.h"
|
||||
#import "TFProductionListViewCell.h"
|
||||
|
||||
@interface TFBookStoreMoreViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookStoreMoreViewController
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber = 1;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
[self.mainTableView.mj_header beginRefreshing];
|
||||
|
||||
self.mainTableView.mj_footer = [TFRefreshFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber ++;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
static NSString *cellName = @"TFProductionListViewCell";
|
||||
TFProductionListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFProductionListViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.productionType = self.productionType;
|
||||
cell.productionModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
cell.hiddenEndLine = (indexPath.row == self.dataSourceArray.count - 1);
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *productionModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel: {
|
||||
TFNovelDetailViewController *novelDetail = [[TFNovelDetailViewController alloc] init];
|
||||
novelDetail.book_id = productionModel.production_id;
|
||||
[self.navigationController pushViewController:novelDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicDetailViewController *comicDetail = [[TFComicDetailViewController alloc] init];
|
||||
comicDetail.comic_id = productionModel.production_id;
|
||||
[self.navigationController pushViewController:comicDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
TFAudioDetailViewController *audioDetail = [[TFAudioDetailViewController alloc] init];
|
||||
audioDetail.audio_id = productionModel.production_id;
|
||||
[self.navigationController pushViewController:audioDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Recommend_More;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Recommend_More;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Recommend_More;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"recommend_id"] = self.recommend_id;
|
||||
params[@"page_num"] = [TFUtilsHelper formatStringWithInteger:self.currentPageNumber];
|
||||
|
||||
[TFNetworkTools POST:url parameters:params model:TFBookStoreRecommend.class success:^(BOOL isSuccess, TFBookStoreRecommend *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
|
||||
if (isSuccess) {
|
||||
[weakSelf setNavigationBarTitle:t_model.recommendTitle ? : TFLocalizedString(@"查看更多")];
|
||||
if (weakSelf.currentPageNumber == 1) {
|
||||
[weakSelf.dataSourceArray removeAllObjects];
|
||||
weakSelf.dataSourceArray = [NSMutableArray arrayWithArray:t_model.recommendList.list];
|
||||
} else {
|
||||
[weakSelf.dataSourceArray addObjectsFromArray:t_model.recommendList.list];
|
||||
}
|
||||
if (t_model.recommendList.total_page <= t_model.recommendList.current_page) {
|
||||
[weakSelf.mainTableView hideRefreshFooter];
|
||||
}
|
||||
}
|
||||
[weakSelf.mainTableView reloadData];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFBookStoreViewController.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFSearchView.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFBookStoreViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,strong) UIButton *sexChooseButton;
|
||||
@property (nonatomic ,assign) BOOL isNavDark;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+456
@@ -0,0 +1,456 @@
|
||||
//
|
||||
// TFBookStoreViewController.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreViewController.h"
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#if TF_Enable_Comic
|
||||
#import "TFBookStoreComicController.h"
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Book
|
||||
#import "TFBookStoreNovelController.h"
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
#import "TFBookStoreAudioController.h"
|
||||
#import "TFAudioPlayViewController.h"
|
||||
#endif
|
||||
|
||||
#import "TFSearchViewController.h"
|
||||
#import "TFLimitFreeViewController.h"
|
||||
#import "TFWebViewController.h"
|
||||
#import "TFCollectionManager.h"
|
||||
#import "TFRecommendBookModel.h"
|
||||
#import "NSObject+Observer.h"
|
||||
#import "AppDelegate+TFStartTimes.h"
|
||||
|
||||
@interface TFBookStoreViewController ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
|
||||
|
||||
@property (nonatomic ,strong) NSMutableArray *childControllers;
|
||||
@property (nonatomic ,weak) UIImageView *searchImageView;
|
||||
|
||||
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
|
||||
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentView;
|
||||
@property (nonatomic ,assign) CGFloat contentOffsetY;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookStoreViewController
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self changeNavBarColorWithContentOffsetY:self.contentOffsetY];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubViews];
|
||||
|
||||
// 首次安装增加推荐书籍
|
||||
WS(weakSelf)
|
||||
[TFNetworkManager networkingStatus:^(BOOL status) {
|
||||
if (status) {
|
||||
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
||||
if ([delegate startTimes] == 1) {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
[weakSelf netRequest];
|
||||
});
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear:animated];
|
||||
|
||||
[self changeNavBarColorWithContentOffsetY:self.contentOffsetY];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Show_Tabbar object:nil];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushFromMallCenter:) name:NSNotification_Rack_JumpToMallCenter object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadSearchBar) name:Notification_Reload_Mall_Hot_Word object:nil];
|
||||
|
||||
[self hiddenNavigationBarLeftButton];
|
||||
|
||||
[self hiddenSeparator];
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
self.navigationBar.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0];
|
||||
|
||||
WS(weakSelf)
|
||||
#if TF_Enable_Book
|
||||
TFBookStoreNovelController *bookStoreNovel = [[TFBookStoreNovelController alloc] init];
|
||||
bookStoreNovel.productionType = TFProductionTypeNovel;
|
||||
bookStoreNovel.channel = 0;
|
||||
[bookStoreNovel addObserver:KEY_PATH(bookStoreNovel, scrollViewContentOffsetY) complete:^(TFBookStoreNovelController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
[self addChildViewController:bookStoreNovel];
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
TFBookStoreComicController *bookStoreComic = [[TFBookStoreComicController alloc] init];
|
||||
bookStoreComic.productionType = TFProductionTypeComic;
|
||||
bookStoreComic.channel = 0;
|
||||
[bookStoreComic addObserver:KEY_PATH(bookStoreComic, scrollViewContentOffsetY) complete:^(TFBookStoreComicController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
[self addChildViewController:bookStoreComic];
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
TFBookStoreAudioController *bookStoreAudio = [[TFBookStoreAudioController alloc] init];
|
||||
bookStoreAudio.productionType = TFProductionTypeAudio;
|
||||
bookStoreAudio.channel = 0;
|
||||
[bookStoreAudio addObserver:KEY_PATH(bookStoreAudio, scrollViewContentOffsetY) complete:^(TFBookStoreAudioController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
[self addChildViewController:bookStoreAudio];
|
||||
#endif
|
||||
|
||||
NSMutableArray *titleArr = [NSMutableArray array];
|
||||
self.childControllers = [NSMutableArray array];
|
||||
|
||||
// 临时记录单站点状态
|
||||
NSMutableArray *t_titleArr = [NSMutableArray array];
|
||||
NSMutableArray *t_chailArr = [NSMutableArray array];
|
||||
|
||||
for (NSNumber *siteNumber in [TFUtilsHelper getSiteState]) {
|
||||
#if TF_Enable_Book
|
||||
if ([siteNumber integerValue] == 1) {
|
||||
[titleArr addObject:TFLocalizedString(@"小说")];
|
||||
[self.childControllers addObject:bookStoreNovel];
|
||||
|
||||
TFBookStoreNovelController *boyVC = [[TFBookStoreNovelController alloc] init];
|
||||
boyVC.channel = 1;
|
||||
boyVC.productionType = TFProductionTypeNovel;
|
||||
[boyVC addObserver:KEY_PATH(boyVC, scrollViewContentOffsetY) complete:^(TFBookStoreNovelController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
|
||||
TFBookStoreNovelController *girlVC = [[TFBookStoreNovelController alloc] init];
|
||||
girlVC.channel = 2;
|
||||
girlVC.productionType = TFProductionTypeNovel;
|
||||
[girlVC addObserver:KEY_PATH(girlVC, scrollViewContentOffsetY) complete:^(TFBookStoreNovelController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
|
||||
[t_titleArr addObjectsFromArray:@[TFLocalizedString(@"男生"), TFLocalizedString(@"女生")]];
|
||||
[t_chailArr addObjectsFromArray:@[boyVC, girlVC]];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
if ([siteNumber integerValue] == 2) {
|
||||
[titleArr addObject:TFLocalizedString(@"漫画")];
|
||||
[self.childControllers addObject:bookStoreComic];
|
||||
|
||||
TFBookStoreComicController *boyVC = [[TFBookStoreComicController alloc] init];
|
||||
boyVC.channel = 1;
|
||||
boyVC.productionType = TFProductionTypeComic;
|
||||
[boyVC addObserver:KEY_PATH(boyVC, scrollViewContentOffsetY) complete:^(TFBookStoreComicController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
|
||||
TFBookStoreComicController *girlVC = [[TFBookStoreComicController alloc] init];
|
||||
girlVC.channel = 2;
|
||||
girlVC.productionType = TFProductionTypeComic;
|
||||
[girlVC addObserver:KEY_PATH(girlVC, scrollViewContentOffsetY) complete:^(TFBookStoreComicController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
|
||||
[t_titleArr addObjectsFromArray:@[TFLocalizedString(@"男生"), TFLocalizedString(@"女生")]];
|
||||
[t_chailArr addObjectsFromArray:@[boyVC, girlVC]];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
if ([siteNumber integerValue] == 3) {
|
||||
[titleArr addObject:TFLocalizedString(@"听书")];
|
||||
[self.childControllers addObject:bookStoreAudio];
|
||||
|
||||
TFBookStoreAudioController *boyVC = [[TFBookStoreAudioController alloc] init];
|
||||
boyVC.channel = 1;
|
||||
boyVC.productionType = TFProductionTypeAudio;
|
||||
[boyVC addObserver:KEY_PATH(boyVC, scrollViewContentOffsetY) complete:^(TFBookStoreAudioController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
|
||||
TFBookStoreAudioController *girlVC = [[TFBookStoreAudioController alloc] init];
|
||||
girlVC.channel = 2;
|
||||
girlVC.productionType = TFProductionTypeAudio;
|
||||
[girlVC addObserver:KEY_PATH(girlVC, scrollViewContentOffsetY) complete:^(TFBookStoreAudioController * _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
|
||||
[weakSelf changeNavBarColorWithContentOffsetY:[newVal floatValue]];
|
||||
}];
|
||||
|
||||
[t_titleArr addObjectsFromArray:@[TFLocalizedString(@"男生"), TFLocalizedString(@"女生")]];
|
||||
[t_chailArr addObjectsFromArray:@[boyVC, girlVC]];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if ([TFUtilsHelper getSiteState].count == 1) {
|
||||
titleArr = t_titleArr;
|
||||
self.childControllers = t_chailArr;
|
||||
}
|
||||
|
||||
self.pageContentView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) parentVC:self childVCs:self.childControllers];
|
||||
self.pageContentView.delegatePageContentCollectionView = self;
|
||||
[self.view addSubview:self.pageContentView];
|
||||
|
||||
self.pageConfigure.indicatorColor = [UIColor whiteColor];
|
||||
self.pageConfigure.indicatorStyle = SGIndicatorStyleDynamic;
|
||||
self.pageConfigure.indicatorHeight = 3;
|
||||
self.pageConfigure.indicatorFixedWidth = 10;
|
||||
self.pageConfigure.indicatorDynamicWidth = 14;
|
||||
self.pageConfigure.indicatorToBottomDistance = 3;
|
||||
self.pageConfigure.titleSelectedColor = [UIColor whiteColor];
|
||||
self.pageConfigure.titleFont = kBoldFont16;
|
||||
self.pageConfigure.titleTextZoom = YES;
|
||||
self.pageConfigure.titleTextZoomRatio = 0.2;
|
||||
self.pageConfigure.titleColor = kColorRGBA(255, 255, 255, 0.9);
|
||||
|
||||
CGFloat width = 0;
|
||||
for (NSString *obj in titleArr) {
|
||||
CGFloat t_width = [TFViewHelper getDynamicWidthWithLabelFont:kBoldFont16 labelHeight:43.0 labelText:obj maxWidth:140.0];
|
||||
width += t_width;
|
||||
width += kLabelHeight;
|
||||
}
|
||||
|
||||
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(kHalfMargin, (is_iPhoneX ? kQuarterMargin : kHalfMargin) + kHalfMargin + PUB_NAVBAR_OFFSET, width, TFPageView_H) delegate:self titleNames:titleArr configure:self.pageConfigure];
|
||||
self.pageTitleView.backgroundColor = [UIColor clearColor];
|
||||
[self.navigationBar addSubview:self.pageTitleView];
|
||||
|
||||
if ([TFUtilsHelper getSiteState].count > 1) {
|
||||
self.sexChooseButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
self.sexChooseButton.adjustsImageWhenHighlighted = NO;
|
||||
[self.sexChooseButton setImageEdgeInsets:UIEdgeInsetsMake(10, 20, 10, 0)];
|
||||
[self.sexChooseButton addTarget:self action:@selector(secChooseButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.navigationBar addSubview:self.sexChooseButton];
|
||||
|
||||
if (TFSystemInfoManager.sexChannel == 1) { // 男
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_boy_dark"] forState:UIControlStateNormal];
|
||||
} else { // 女
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_girl_dark"] forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
[self.sexChooseButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.navigationBar.mas_right).with.offset(- kHalfMargin - kQuarterMargin);
|
||||
make.centerY.mas_equalTo(self.pageTitleView.mas_centerY).with.offset(2);
|
||||
make.width.height.mas_equalTo(44);
|
||||
}];
|
||||
}
|
||||
|
||||
UIImageView *searchImageView = [[UIImageView alloc] init];
|
||||
searchImageView.image = [[UIImage imageNamed:@"public_search"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
||||
[searchImageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(searchClick)]];
|
||||
searchImageView.backgroundColor = [UIColor clearColor];
|
||||
searchImageView.userInteractionEnabled = YES;
|
||||
searchImageView.tintColor = kWhiteColor;
|
||||
[self.navigationBar addSubview:searchImageView];
|
||||
self.searchImageView = searchImageView;
|
||||
|
||||
[searchImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.equalTo(self.pageTitleView).offset(2);
|
||||
if ([TFUtilsHelper getSiteState].count > 1) {
|
||||
make.right.equalTo(self.sexChooseButton.mas_left);
|
||||
} else {
|
||||
make.right.equalTo(self.navigationBar).offset(- kHalfMargin - kQuarterMargin);
|
||||
}
|
||||
make.width.height.mas_equalTo(24);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)searchClick
|
||||
{
|
||||
TFSearchViewController *vc = [[TFSearchViewController alloc] init];
|
||||
vc.productionType = self.productionType;
|
||||
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
- (void)secChooseButtonClick
|
||||
{
|
||||
if (TFSystemInfoManager.sexChannel == 1) { // 男
|
||||
if (self.isNavDark) {
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_girl"] forState:UIControlStateNormal];
|
||||
} else {
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_girl_dark"] forState:UIControlStateNormal];
|
||||
}
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"已切换至女频")];
|
||||
TFSystemInfoManager.sexChannel = 2;
|
||||
} else { // 女
|
||||
if (self.isNavDark) {
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_boy"] forState:UIControlStateNormal];
|
||||
} else {
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_boy_dark"] forState:UIControlStateNormal];
|
||||
}
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"已切换至男频")];
|
||||
TFSystemInfoManager.sexChannel = 1;
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Channel_Change object:nil];
|
||||
}
|
||||
|
||||
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex
|
||||
{
|
||||
[self.pageContentView setPageContentCollectionViewCurrentIndex:selectedIndex];
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex
|
||||
{
|
||||
[self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView index:(NSInteger)index
|
||||
{
|
||||
[self reloadSearchBar];
|
||||
}
|
||||
|
||||
- (void)reloadSearchBar
|
||||
{
|
||||
TFBasicViewController *vc = [self.childControllers objectOrNilAtIndex:self.pageTitleView.signBtnIndex];
|
||||
self.productionType = vc.productionType;
|
||||
CGFloat contentOffsetY = [[vc valueForKey:@"scrollViewContentOffsetY"] integerValue];
|
||||
[self changeNavBarColorWithContentOffsetY:contentOffsetY];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
// 书架增加推荐书籍
|
||||
[TFNetworkTools POST:Shelf_Recommend parameters:nil model:TFRecommendBookModel.class success:^(BOOL isSuccess, TFRecommendBookModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (isSuccess) {
|
||||
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeNovel] getAllCollection].count == 0) {
|
||||
for (TFProductionModel *model in t_model.book) {
|
||||
model.productionType = TFProductionTypeNovel;
|
||||
model.is_recommend = YES;
|
||||
[[TFCollectionManager shareManagerWithProductionType:TFProductionTypeNovel] addCollectionWithProductionModel:model atIndex:0];
|
||||
}
|
||||
}
|
||||
|
||||
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeComic] getAllCollection].count == 0) {
|
||||
for (TFProductionModel *model in t_model.comic) {
|
||||
model.productionType = TFProductionTypeComic;
|
||||
model.is_recommend = YES;
|
||||
[[TFCollectionManager shareManagerWithProductionType:TFProductionTypeComic] addCollectionWithProductionModel:model atIndex:0];
|
||||
}
|
||||
}
|
||||
|
||||
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] getAllCollection].count == 0) {
|
||||
for (TFProductionModel *model in t_model.audio) {
|
||||
model.productionType = TFProductionTypeAudio;
|
||||
model.is_recommend = YES;
|
||||
[[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] addCollectionWithProductionModel:model atIndex:0];
|
||||
}
|
||||
}
|
||||
}
|
||||
} failure:nil];
|
||||
}
|
||||
|
||||
- (void)changeNavBarColorWithContentOffsetY:(CGFloat)contentOffsetY
|
||||
{
|
||||
_contentOffsetY = contentOffsetY;
|
||||
|
||||
CGFloat alpha = [TFColorHelper getAlphaWithContentOffsetY:fabs(contentOffsetY)];
|
||||
CGFloat rbgColor = [TFColorHelper getColorWithContentOffsetY:fabs(contentOffsetY)];
|
||||
|
||||
self.navigationBar.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:alpha];
|
||||
|
||||
[self.pageTitleView resetTitleColor:kColorRGBA(rbgColor, rbgColor, rbgColor, 1) titleSelectedColor:kColorRGBA(rbgColor, rbgColor, rbgColor, 1) indicatorColor:kColorRGBA(rbgColor, rbgColor, rbgColor, 1)];
|
||||
self.searchImageView.tintColor = kColorRGBA(rbgColor, rbgColor, rbgColor, 1);
|
||||
|
||||
if (fabs(contentOffsetY) > 60) {
|
||||
self.isNavDark = YES;
|
||||
} else {
|
||||
self.isNavDark = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setIsNavDark:(BOOL)isNavDark
|
||||
{
|
||||
if (isNavDark) {
|
||||
if ([[TFViewHelper getCurrentViewController] isEqual:self]) {
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
if ([TFUtilsHelper getSiteState].count > 1) {
|
||||
if (TFSystemInfoManager.sexChannel == 1) { // 男
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_boy"] forState:UIControlStateNormal];
|
||||
} else { // 女
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_girl"] forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ([[TFViewHelper getCurrentViewController] isEqual:self]) {
|
||||
[self setStatusBarLightContentStyle];
|
||||
}
|
||||
|
||||
if ([TFUtilsHelper getSiteState].count > 1) {
|
||||
if (TFSystemInfoManager.sexChannel == 1) { // 男
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_boy_dark"] forState:UIControlStateNormal];
|
||||
} else { // 女
|
||||
[self.sexChooseButton setImage:[UIImage imageNamed:@"comic_mall_girl_dark"] forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
}
|
||||
_isNavDark = isNavDark;
|
||||
}
|
||||
|
||||
- (void)pushFromMallCenter:(NSNotification *)notification
|
||||
{
|
||||
#if TF_Enable_Comic
|
||||
// 跳转到漫画相关内容
|
||||
if ([notification.object isEqualToString:@"comic"]) {
|
||||
for (NSInteger i = 0; i < self.pageContentView.childViewControllers.count ; i ++) {
|
||||
if ([[self.pageContentView.childViewControllers objectOrNilAtIndex:i] isKindOfClass:[TFBookStoreComicController class]]) {
|
||||
self.pageTitleView.resetSelectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Book
|
||||
// 跳转到小说相关内容
|
||||
if ([notification.object isEqualToString:@"novel"]) {
|
||||
for (NSInteger i = 0; i < self.pageContentView.childViewControllers.count ; i ++) {
|
||||
if ([[self.pageContentView.childViewControllers objectOrNilAtIndex:i] isKindOfClass:[TFBookStoreNovelController class]]) {
|
||||
self.pageTitleView.resetSelectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
// 跳转到听书相关内容
|
||||
if ([notification.object isEqualToString:@"audio"]) {
|
||||
for (NSInteger i = 0; i < self.pageContentView.childViewControllers.count ; i ++) {
|
||||
if ([[self.pageContentView.childViewControllers objectOrNilAtIndex:i] isKindOfClass:[TFBookStoreAudioController class]]) {
|
||||
self.pageTitleView.resetSelectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// TFBookStoreLabelModel.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFAdvertModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TFProductionModel;
|
||||
@interface TFBookStoreLabelModel : TFAdvertModel
|
||||
|
||||
@property (nonatomic ,assign) NSInteger recommend_id; // 推荐位id
|
||||
@property (nonatomic ,assign) NSInteger style; // 展示风格
|
||||
@property (nonatomic ,copy) NSString *label; // 名称
|
||||
@property (nonatomic ,copy) NSString *total; // 漫画数
|
||||
@property (nonatomic ,assign) BOOL can_more; // 是否有更多 true有,false没有
|
||||
@property (nonatomic ,assign) BOOL can_refresh; // 是否有更多 true有,false没有
|
||||
@property (nonatomic ,assign) NSInteger expire_time;
|
||||
@property (nonatomic ,strong) NSArray <TFProductionModel *>*list; // 作品列表
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFBookStoreLabelModel.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreLabelModel.h"
|
||||
|
||||
@implementation TFBookStoreLabelModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{@"list" : [TFProductionModel class]};
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// TFBookStoreModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/22.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TFBannerModel, TFBookStoreLabelModel, TFBookStoreMenusModel;
|
||||
|
||||
@interface TFBookStoreModel : NSObject
|
||||
|
||||
@property (nonatomic ,strong) NSArray <TFBannerModel *>*banner;
|
||||
@property (nonatomic ,strong) NSArray <TFBookStoreLabelModel *>*label;
|
||||
@property (nonatomic ,strong) NSArray <TFBookStoreMenusModel *> *menus_tabs;
|
||||
@property (nonatomic ,strong) NSArray <NSString *>*hot_word;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface TFBookStoreMenusModel : NSObject
|
||||
|
||||
@property (nonatomic ,copy) NSString *title;
|
||||
@property (nonatomic ,copy) NSString *icon;
|
||||
@property (nonatomic ,copy) NSString *action;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// TFBookStoreModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/22.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreModel.h"
|
||||
#import "TFBookStoreLabelModel.h"
|
||||
#import "TFUserCenterModel.h"
|
||||
|
||||
@implementation TFBookStoreModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{@"banner" : [TFBannerModel class],
|
||||
@"label" : [TFBookStoreLabelModel class],
|
||||
@"menus_tabs": [TFBookStoreMenusModel class]
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation TFBookStoreMenusModel
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFBookStoreRecommend.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/12.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TFProductionListModel;
|
||||
@interface TFBookStoreRecommend : NSObject
|
||||
|
||||
@property (nonatomic ,copy) NSString *recommendTitle;
|
||||
|
||||
@property (nonatomic ,strong) TFProductionListModel *recommendList;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFBookStoreRecommend.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/12.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreRecommend.h"
|
||||
|
||||
@implementation TFBookStoreRecommend
|
||||
|
||||
+ (NSDictionary *)modelCustomPropertyMapper
|
||||
{
|
||||
return @{
|
||||
@"recommendTitle":@"recommend.title",
|
||||
@"recommendList": @[@"list", @"book"]
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// TFBookStoreMenuView.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_ENUM(NSUInteger, TFMenuButtonType) {
|
||||
TFMenuButtonTypeFree, // 免费
|
||||
TFMenuButtonTypeComplete, // 完结
|
||||
TFMenuButtonTypeSort, // 分类
|
||||
TFMenuButtonTypePopularity, // 排行
|
||||
TFMenuButtonTypeMember // 会员
|
||||
};
|
||||
|
||||
typedef void(^BannerrImageClickBlock)(TFBannerModel *bannerModel);
|
||||
|
||||
@interface TFBookStoreMenuView : UIView
|
||||
|
||||
@property (nonatomic ,assign) TFProductionType productionType;
|
||||
@property (nonatomic ,strong) TFBookStoreModel *mallCenterModel;
|
||||
|
||||
@property (nonatomic ,copy) void (^menuButtonClickBlock)(TFMenuButtonType menuButtonType, NSString *menuButtonTitle);
|
||||
|
||||
@property (nonatomic ,copy) void(^bannerrImageClickBlock)(TFBannerModel *bannerModel); // banner点击
|
||||
|
||||
- (void)createSubViews;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,186 @@
|
||||
//
|
||||
// TFBookStoreMenuView.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreMenuView.h"
|
||||
#import "YJMallCollectionViewCell.h"
|
||||
#import "YJBannerView.h"
|
||||
#import "TFUserCenterModel.h"
|
||||
|
||||
@interface TFBookStoreMenuView () <YJBannerViewDelegate, YJBannerViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) YJBannerView *bannerView;
|
||||
@property (nonatomic ,strong) UIView *menuBarView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookStoreMenuView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
|
||||
CGFloat headerHeight = SCREEN_WIDTH - kHalfMargin;
|
||||
|
||||
if (is_iPhone6P) {
|
||||
headerHeight = SCREEN_WIDTH - kMargin - kQuarterMargin;
|
||||
} else if (is_iPhoneX) {
|
||||
headerHeight = SCREEN_WIDTH;
|
||||
} else if (is_iPhone6) {
|
||||
headerHeight = SCREEN_WIDTH - kMargin;
|
||||
}
|
||||
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, headerHeight);
|
||||
self.clipsToBounds = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setProductionType:(TFProductionType)productionType
|
||||
{
|
||||
_productionType = productionType;
|
||||
|
||||
[self createSubViews];
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
self.backgroundColor = kWhiteColor;
|
||||
|
||||
[self addSubview:self.bannerView];
|
||||
|
||||
UIImageView *bannerBottonView = [[UIImageView alloc] init];
|
||||
bannerBottonView.image = [UIImage imageNamed:@"banner_bottom_line.png"];
|
||||
[self addSubview:bannerBottonView];
|
||||
|
||||
[bannerBottonView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.bottom.mas_equalTo(self.bannerView.mas_bottom).with.offset(1);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(kGeometricHeight(SCREEN_WIDTH, 800, 57));
|
||||
}];
|
||||
|
||||
self.menuBarView = [[UIView alloc] init];
|
||||
self.menuBarView.backgroundColor = kWhiteColor;
|
||||
[self addSubview:self.menuBarView];
|
||||
|
||||
[self.menuBarView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.bottom.mas_equalTo(self.mas_bottom);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(SCREEN_WIDTH / 5 - kQuarterMargin);
|
||||
}];
|
||||
}
|
||||
|
||||
- (YJBannerView *)bannerView
|
||||
{
|
||||
if (!_bannerView) {
|
||||
_bannerView = [YJBannerView bannerViewWithFrame:CGRectMake(0, 0, self.width, self.height - (SCREEN_WIDTH / 5)) dataSource:self delegate:self emptyImage:HoldImage placeholderImage:HoldImage selectorString:NSStringFromSelector(@selector(setImageWithURL:placeholder:))];
|
||||
_bannerView.repeatCount = 9999;
|
||||
_bannerView.pageControlAliment = PageControlAlimentCenter;
|
||||
_bannerView.autoDuration = 5.0f;
|
||||
_bannerView.pageControlStyle = PageControlCustom;
|
||||
_bannerView.pageControlDotSize = CGSizeMake(10, 5);
|
||||
_bannerView.pageControlBottomMargin = 15;
|
||||
_bannerView.customPageControlHighlightImage = [UIImage imageNamed:@"pageControlS"];
|
||||
_bannerView.customPageControlNormalImage = [UIImage imageNamed:@"pageControlN"];
|
||||
}
|
||||
return _bannerView;
|
||||
}
|
||||
|
||||
- (NSArray *)bannerViewImages:(YJBannerView *)bannerView
|
||||
{
|
||||
NSMutableArray *t_arr = [NSMutableArray array];
|
||||
for (TFBannerModel *t_model in self.mallCenterModel.banner) {
|
||||
[t_arr addObject:t_model.image];
|
||||
}
|
||||
return t_arr;
|
||||
}
|
||||
|
||||
// 代理方法 点击了哪个bannerView 的 第几个元素
|
||||
- (void)bannerView:(YJBannerView *)bannerView didSelectItemAtIndex:(NSInteger)index
|
||||
{
|
||||
if (self.bannerrImageClickBlock) {
|
||||
self.bannerrImageClickBlock([self.mallCenterModel.banner objectOrNilAtIndex:index]);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *)bannerViewRegistCustomCellClass:(YJBannerView *)bannerView
|
||||
{
|
||||
return @[[YJMallCollectionViewCell class]];
|
||||
}
|
||||
|
||||
/** 根据 Index 选择使用哪个 reuseIdentifier */
|
||||
- (Class)bannerView:(YJBannerView *)bannerView reuseIdentifierForIndex:(NSInteger)index
|
||||
{
|
||||
return [YJMallCollectionViewCell class];
|
||||
}
|
||||
|
||||
/** 自定义 View 刷新数据或者其他配置 */
|
||||
- (UICollectionViewCell *)bannerView:(YJBannerView *)bannerView customCell:(UICollectionViewCell *)customCell index:(NSInteger)index
|
||||
{
|
||||
YJMallCollectionViewCell *cell = (YJMallCollectionViewCell *)customCell;
|
||||
cell.bannerModel = [self.mallCenterModel.banner objectOrNilAtIndex:index];
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)setMallCenterModel:(TFBookStoreModel *)mallCenterModel
|
||||
{
|
||||
_mallCenterModel = mallCenterModel;
|
||||
|
||||
[self.menuBarView removeAllSubviews];
|
||||
[self.bannerView reloadData];
|
||||
|
||||
for (int i = 0; i < mallCenterModel.menus_tabs.count; i ++) {
|
||||
|
||||
TFBookStoreMenusModel *t_model = [mallCenterModel.menus_tabs objectAtIndex:i];
|
||||
|
||||
TFButton *button = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:t_model.title ? : @"" buttonImageName:t_model.icon ? : @"" buttonIndicator:TFButtonIndicatorTitleBottom showMaskView:YES];
|
||||
button.graphicDistance = 0;
|
||||
button.buttonImageScale = 0.6;
|
||||
button.buttonTitleFont = kFont13;
|
||||
button.buttonTag = t_model.action;
|
||||
[button addTarget:self action:@selector(menuButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.menuBarView addSubview:button];
|
||||
|
||||
CGFloat buttonWidth = SCREEN_WIDTH / mallCenterModel.menus_tabs.count;
|
||||
CGFloat buttonHeight = SCREEN_WIDTH / 5 - kQuarterMargin;
|
||||
|
||||
[button mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(i * buttonWidth);
|
||||
make.top.mas_equalTo(0);
|
||||
make.width.mas_equalTo(buttonWidth);
|
||||
make.height.mas_equalTo(buttonHeight);
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)menuButtonClick:(TFButton *)sender
|
||||
{
|
||||
if (self.menuButtonClickBlock) {
|
||||
if ([sender.buttonTag isEqualToString:@"free"]) {
|
||||
self.menuButtonClickBlock(TFMenuButtonTypeFree, sender.buttonTitle ? : @"");
|
||||
}
|
||||
|
||||
if ([sender.buttonTag isEqualToString:@"finished"]) {
|
||||
self.menuButtonClickBlock(TFMenuButtonTypeComplete, sender.buttonTitle ? : @"");
|
||||
}
|
||||
|
||||
if ([sender.buttonTag isEqualToString:@"category"]) {
|
||||
self.menuButtonClickBlock(TFMenuButtonTypeSort, sender.buttonTitle ? : @"");
|
||||
}
|
||||
|
||||
if ([sender.buttonTag isEqualToString:@"rank"]) {
|
||||
self.menuButtonClickBlock(TFMenuButtonTypePopularity, sender.buttonTitle ? : @"");
|
||||
}
|
||||
|
||||
if ([sender.buttonTag isEqualToString:@"vip"]) {
|
||||
self.menuButtonClickBlock(TFMenuButtonTypeMember, sender.buttonTitle ? : @"");
|
||||
}
|
||||
}
|
||||
}
|
||||
@end
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// TFBookStoreNovelController.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 TFBookStoreNovelController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,assign) CGFloat channel;
|
||||
|
||||
@property (nonatomic ,assign) CGFloat scrollViewContentOffsetY;
|
||||
|
||||
@property (nonatomic ,strong) NSArray *hotwordArray;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+400
@@ -0,0 +1,400 @@
|
||||
//
|
||||
// TFBookStoreNovelController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFBookStoreNovelController.h"
|
||||
#import "TFLimitFreeViewController.h"
|
||||
#import "TFBookStoreNovelStyleOneCell.h"
|
||||
#import "TFBookStoreNovelStyleTwoCell.h"
|
||||
#import "TFBookStoreNovelStyleThreeCell.h"
|
||||
#import "TFBookStoreNovelStyleFourCell.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"
|
||||
#import "TFWebViewController.h"
|
||||
|
||||
@interface TFBookStoreNovelController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) TFBookStoreModel *bookStoreNovelModel;
|
||||
@property (nonatomic ,strong) TFBookStoreMenuView *headerView;
|
||||
@property (nonatomic ,assign) BOOL needRefresh;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFBookStoreNovelController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
[self netRequest];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netRequest) name:Notification_Restore_Network object:nil];
|
||||
}
|
||||
|
||||
- (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];
|
||||
}
|
||||
|
||||
- (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:TFProductionTypeNovel]) {
|
||||
[weakSelf.navigationController pushViewController:[TFBannerActionManager getBannerActionWithBannerModel:bannerModel productionType:TFProductionTypeNovel] 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.bookStoreNovelModel.label.count;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFBookStoreLabelModel *labelModel = [self.bookStoreNovelModel.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 = TFBookStoreNovelStyleOneCell.class;
|
||||
switch (labelModel.style) {
|
||||
case 1:
|
||||
cellClass = TFBookStoreNovelStyleOneCell.class;
|
||||
break;
|
||||
case 2:
|
||||
cellClass = TFBookStoreNovelStyleTwoCell.class;
|
||||
break;
|
||||
case 3:
|
||||
cellClass = TFBookStoreNovelStyleThreeCell.class;
|
||||
break;
|
||||
case 4:
|
||||
cellClass = TFBookStoreNovelStyleFourCell.class;
|
||||
break;
|
||||
|
||||
default:
|
||||
cellClass = TFBookStoreNovelStyleOneCell.class;
|
||||
break;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
TFBookStoreNovelBasicViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(cellClass)];
|
||||
if (!cell) {
|
||||
cell = [[cellClass alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(cellClass)];
|
||||
}
|
||||
cell.labelModel = labelModel;
|
||||
|
||||
cell.cellDidSelectItemBlock = ^(NSInteger production_id) {
|
||||
TFNovelDetailViewController *novelDetail = [[TFNovelDetailViewController alloc] init];
|
||||
novelDetail.book_id = production_id;
|
||||
[weakSelf.navigationController pushViewController:novelDetail animated:YES];
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
TFBookStoreLabelModel *labelModel = [self.bookStoreNovelModel.label objectOrNilAtIndex:section];
|
||||
if (labelModel.ad_type != 0) {
|
||||
return kHalfMargin;
|
||||
}
|
||||
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.bookStoreNovelModel.label objectOrNilAtIndex:section];
|
||||
if (labelModel.can_more || labelModel.can_refresh) {
|
||||
|
||||
if (section == self.bookStoreNovelModel.label.count - 1) {
|
||||
return 40;
|
||||
}
|
||||
return 30;
|
||||
}
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 30)];
|
||||
view.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
CGFloat buttonX = SCREEN_WIDTH / 4;
|
||||
CGFloat buttonW = SCREEN_WIDTH / 2;
|
||||
CGFloat buttonH = 30;
|
||||
|
||||
TFBookStoreLabelModel *labelModel = [self.bookStoreNovelModel.label objectOrNilAtIndex:section];
|
||||
|
||||
if (!labelModel.can_more && !labelModel.can_refresh) {
|
||||
return view;
|
||||
}
|
||||
|
||||
if (labelModel.style == 5) { // 排行榜
|
||||
TFButton *moreButton = [TFButton initWithFrame:CGRectMake(kMargin, 0, SCREEN_WIDTH - 2 * kMargin, buttonH) btnTitle:TFLocalizedString(@"查看更多排行榜") btnImageName:@"comic_mall_more" backgroundColor:kGrayViewColor btnTintColor:kGrayTextLightColor btnStyle:TFButtonIndicatorTitleLeft cornerRadius:15 target:self action:@selector(rankButtonClick:)];
|
||||
|
||||
moreButton.graphicDistance = 5;
|
||||
moreButton.tag = section;
|
||||
[view addSubview:moreButton];
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
TFButton *moreButton = [TFButton initWithFrame:CGRectMake(buttonX, 0, 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;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
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, 0, (SCREEN_WIDTH - 3 * kMargin) / 2, buttonH);
|
||||
changeButton.frame = CGRectMake(2 * kMargin + (SCREEN_WIDTH - 3 * kMargin) / 2, 0, (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;
|
||||
}
|
||||
|
||||
#pragma mark - 点击事件
|
||||
- (void)moreButtonClick:(UIButton *)sender
|
||||
{
|
||||
TFBookStoreLabelModel *t_labelModel = [self.bookStoreNovelModel.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:(TFButton *)sender
|
||||
{
|
||||
[sender startSpin];
|
||||
[self changeBookRecommendRequestAtIndex:sender.tag complete:^{
|
||||
[sender stopSpin];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)rankButtonClick:(UIButton *)sender
|
||||
{
|
||||
TFPopularityViewController *vc = [[TFPopularityViewController alloc] init];
|
||||
vc.productionType = self.productionType;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
WS(weakSelf)
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"channel_id"] = self.channel != 0 ? [TFUtilsHelper formatStringWithInteger:self.channel] : @(TFSystemInfoManager.sexChannel);
|
||||
|
||||
[TFNetworkTools POSTQuick:Book_Mall_Center parameters:params model:TFBookStoreModel.class success:^(BOOL isSuccess, TFBookStoreModel * _Nullable t_model, BOOL isCache, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
if (weakSelf.bookStoreNovelModel && isCache) return;
|
||||
if (isSuccess) {
|
||||
weakSelf.bookStoreNovelModel = 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)changeBookRecommendRequestAtIndex:(NSInteger)index complete:(void(^)(void))complete
|
||||
{
|
||||
TFBookStoreLabelModel *t_labelModel = [self.bookStoreNovelModel.label objectOrNilAtIndex:index];
|
||||
|
||||
if (t_labelModel.recommend_id <= 0) {
|
||||
return;
|
||||
}
|
||||
WS(weakSelf)
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"recommend_id"] = [TFUtilsHelper formatStringWithInteger:t_labelModel.recommend_id];
|
||||
|
||||
[TFNetworkTools POST:Book_Refresh parameters:params model:TFBookStoreLabelModel.class success:^(BOOL isSuccess, TFBookStoreLabelModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
|
||||
if (isSuccess) {
|
||||
[weakSelf.bookStoreNovelModel.label objectAtIndex:index].list = t_model.list;
|
||||
|
||||
TFBookStoreNovelBasicViewCell *cell = [weakSelf.mainTableViewGroup cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:index]];
|
||||
t_model.style = cell.labelModel.style;
|
||||
cell.labelModel = t_model;
|
||||
!complete ?: complete();
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
!complete ?: complete();
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
@end
|
||||
+33
@@ -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
|
||||
+109
@@ -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
|
||||
+34
@@ -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
|
||||
+242
@@ -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
|
||||
+32
@@ -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
|
||||
+118
@@ -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
|
||||
+43
@@ -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
|
||||
+82
@@ -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
|
||||
+35
@@ -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
|
||||
+50
@@ -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
|
||||
+61
@@ -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
|
||||
+96
@@ -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
|
||||
+46
@@ -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
|
||||
+53
@@ -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
|
||||
+36
@@ -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
|
||||
+51
@@ -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
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFCompleteCommController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFCompleteCommController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,copy) NSString *channel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+221
@@ -0,0 +1,221 @@
|
||||
//
|
||||
// TFCompleteCommController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFCompleteCommController.h"
|
||||
#import "TFProductionListViewCell.h"
|
||||
#import "TFPublicAdvertisementViewCell.h"
|
||||
|
||||
@interface TFCompleteCommController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,assign) BOOL needRefresh;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFCompleteCommController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
self.needRefresh = YES;
|
||||
[self hiddenNavigationBar:YES];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(self.view.mas_top);
|
||||
make.bottom.mas_equalTo(self.view.mas_bottom).with.offset(- PUB_NAVBAR_HEIGHT - self.pageViewHeight);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
}];
|
||||
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"暂无数据") buttonTitle:@"" tapBlock:^{
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber = 1;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
[self.mainTableView.mj_header beginRefreshing];
|
||||
|
||||
self.mainTableView.mj_footer = [TFRefreshFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber ++;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
if (t_model.ad_type == 0) {
|
||||
TFProductionListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFProductionListViewCell"];
|
||||
|
||||
if (!cell) {
|
||||
cell = [[TFProductionListViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFProductionListViewCell"];
|
||||
}
|
||||
cell.productionType = self.productionType;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
cell.productionModel = t_model;
|
||||
cell.hiddenEndLine = (indexPath.row == self.dataSourceArray.count - 1);
|
||||
return cell;
|
||||
} else {
|
||||
TFPublicAdvertisementViewCell *cell = [self.advertDict objectForKey:[TFUtilsHelper formatStringWithInteger:indexPath.row]];
|
||||
if (!cell) {
|
||||
static NSString *cellName = @"TFPublicAdvertisementViewCell";
|
||||
cell = [[TFPublicAdvertisementViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
cell.mainTableView = tableView;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
[self.advertDict setObject:cell forKey:[TFUtilsHelper formatStringWithInteger:indexPath.row]];
|
||||
}
|
||||
[cell setAdModel:t_model refresh:self.needRefresh];
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return kHalfMargin;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kHalfMargin)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
switch (self.productionType) {
|
||||
#if TF_Enable_Book
|
||||
|
||||
case TFProductionTypeNovel: {
|
||||
TFNovelDetailViewController *vc = [[TFNovelDetailViewController alloc] init];
|
||||
vc.book_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicDetailViewController *comicDetail = [[TFComicDetailViewController alloc] init];
|
||||
comicDetail.comic_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:comicDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
TFAudioDetailViewController *vc = [[TFAudioDetailViewController alloc] init];
|
||||
vc.audio_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
WS(weakSelf)
|
||||
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Finish;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Finish;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Finish;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"channel_id"] = self.channel;
|
||||
params[@"page_num"] = [TFUtilsHelper formatStringWithInteger:self.currentPageNumber];
|
||||
|
||||
[TFNetworkTools POST:url parameters:params model:TFProductionListModel.class success:^(BOOL isSuccess, TFProductionListModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
|
||||
if (isSuccess) {
|
||||
if (weakSelf.currentPageNumber == 1) {
|
||||
[weakSelf.mainTableView showRefreshFooter];
|
||||
[weakSelf.dataSourceArray removeAllObjects];
|
||||
weakSelf.dataSourceArray = [NSMutableArray arrayWithArray:t_model.list];
|
||||
} else {
|
||||
[weakSelf.dataSourceArray addObjectsFromArray:t_model.list];
|
||||
}
|
||||
if (t_model.total_page <= t_model.current_page) {
|
||||
[weakSelf.mainTableView hideRefreshFooter];
|
||||
}
|
||||
}
|
||||
|
||||
weakSelf.needRefresh = YES;
|
||||
[weakSelf.mainTableView reloadData];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
weakSelf.needRefresh = NO;
|
||||
});
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
[TFPromptManager showPromptWithError:error defaultText:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFCompleteViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFCompleteViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
//
|
||||
// TFCompleteViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFCompleteViewController.h"
|
||||
#import "TFCompleteCommController.h"
|
||||
|
||||
@interface TFCompleteViewController ()<
|
||||
#if TF_Enable_PageControl
|
||||
SGPageTitleViewDelegate,
|
||||
#endif
|
||||
SGPageContentCollectionViewDelegate>
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
|
||||
#endif
|
||||
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentCollectionView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFCompleteViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setNavigationBarTitle:self.navTitle ? : TFLocalizedString(@"完结")];
|
||||
[self hiddenSeparator];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
TFCompleteCommController *boyVC = [[TFCompleteCommController alloc] init];
|
||||
boyVC.productionType = self.productionType;
|
||||
boyVC.channel = @"1";
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
TFCompleteCommController *girlVC = [[TFCompleteCommController alloc] init];
|
||||
girlVC.productionType = self.productionType;
|
||||
girlVC.channel = @"2";
|
||||
#endif
|
||||
|
||||
NSArray *childArr = @[boyVC
|
||||
#if TF_Enable_PageControl
|
||||
, girlVC
|
||||
#endif
|
||||
];
|
||||
|
||||
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:
|
||||
#if TF_Enable_PageControl
|
||||
CGRectMake(0, PUB_NAVBAR_HEIGHT + 44, SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
#else
|
||||
CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
#endif
|
||||
parentVC:self childVCs:childArr];
|
||||
_pageContentCollectionView.delegatePageContentCollectionView = self;
|
||||
[self.view addSubview:self.pageContentCollectionView];
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
NSArray *titleArr = @[TFLocalizedString(@"男生"), TFLocalizedString(@"女生")];
|
||||
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, 44) delegate:self titleNames:titleArr configure:self.pageConfigure];
|
||||
self.pageTitleView.backgroundColor = kWhiteColor;
|
||||
[self.view addSubview:_pageTitleView];
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex
|
||||
{
|
||||
[self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex
|
||||
{
|
||||
[self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFFreeCommViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFFreeCommViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,copy) NSString *channel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+220
@@ -0,0 +1,220 @@
|
||||
//
|
||||
// TFFreeCommViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFFreeCommViewController.h"
|
||||
#import "TFProductionListViewCell.h"
|
||||
#import "TFPublicAdvertisementViewCell.h"
|
||||
|
||||
@interface TFFreeCommViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,assign) BOOL needRefresh;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFFreeCommViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
self.needRefresh = YES;
|
||||
[self hiddenNavigationBar:YES];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(self.view.mas_top);
|
||||
make.bottom.mas_equalTo(self.view.mas_bottom).with.offset(- PUB_NAVBAR_HEIGHT - self.pageViewHeight);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
}];
|
||||
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"暂无数据") buttonTitle:@"" tapBlock:^{
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber = 1;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
[self.mainTableView.mj_header beginRefreshing];
|
||||
|
||||
self.mainTableView.mj_footer = [TFRefreshFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber ++;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
if (t_model.ad_type == 0) {
|
||||
TFProductionListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFProductionListViewCell"];
|
||||
|
||||
if (!cell) {
|
||||
cell = [[TFProductionListViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFProductionListViewCell"];
|
||||
}
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
cell.productionType = self.productionType;
|
||||
cell.productionModel = t_model;
|
||||
cell.hiddenEndLine = (indexPath.row == self.dataSourceArray.count - 1);
|
||||
return cell;
|
||||
} else {
|
||||
TFPublicAdvertisementViewCell *cell = [self.advertDict objectForKey:[TFUtilsHelper formatStringWithInteger:indexPath.row]];
|
||||
if (!cell) {
|
||||
static NSString *cellName = @"TFPublicAdvertisementViewCell";
|
||||
cell = [[TFPublicAdvertisementViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
[cell setAdModel:t_model refresh:self.needRefresh];
|
||||
cell.mainTableView = tableView;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
[self.advertDict setObject:cell forKey:[TFUtilsHelper formatStringWithInteger:indexPath.row]];
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return kHalfMargin;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kHalfMargin)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
switch (self.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel: {
|
||||
TFNovelDetailViewController *vc = [[TFNovelDetailViewController alloc] init];
|
||||
vc.book_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicDetailViewController *comicDetail = [[TFComicDetailViewController alloc] init];
|
||||
comicDetail.comic_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:comicDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
TFAudioDetailViewController *vc = [[TFAudioDetailViewController alloc] init];
|
||||
vc.audio_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
WS(weakSelf)
|
||||
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Free;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Free;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Free;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"channel_id"] = self.channel;
|
||||
params[@"page_num"] = [TFUtilsHelper formatStringWithInteger:self.currentPageNumber];
|
||||
|
||||
[TFNetworkTools POST:url parameters:params model:TFProductionListModel.class success:^(BOOL isSuccess, TFProductionListModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
|
||||
if (isSuccess) {
|
||||
if (weakSelf.currentPageNumber == 1) {
|
||||
[weakSelf.mainTableView showRefreshFooter];
|
||||
[weakSelf.dataSourceArray removeAllObjects];
|
||||
weakSelf.dataSourceArray = [NSMutableArray arrayWithArray:t_model.list];
|
||||
} else {
|
||||
[weakSelf.dataSourceArray addObjectsFromArray:t_model.list];
|
||||
}
|
||||
if (t_model.total_page <= t_model.current_page) {
|
||||
[weakSelf.mainTableView hideRefreshFooter];
|
||||
}
|
||||
}
|
||||
|
||||
weakSelf.needRefresh = YES;
|
||||
[weakSelf.mainTableView reloadData];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
weakSelf.needRefresh = NO;
|
||||
});
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFFreeViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFFreeViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// TFFreeViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFFreeViewController.h"
|
||||
#import "TFFreeCommViewController.h"
|
||||
|
||||
@interface TFFreeViewController ()<
|
||||
#if TF_Enable_PageControl
|
||||
SGPageTitleViewDelegate,
|
||||
#endif
|
||||
SGPageContentCollectionViewDelegate>
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
|
||||
#endif
|
||||
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentCollectionView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFFreeViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setNavigationBarTitle:self.navTitle ? : TFLocalizedString(@"免费")];
|
||||
[self hiddenSeparator];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
TFFreeCommViewController *boyVC = [[TFFreeCommViewController alloc] init];
|
||||
boyVC.productionType = self.productionType;
|
||||
boyVC.channel = @"1";
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
TFFreeCommViewController *girlVC = [[TFFreeCommViewController alloc] init];
|
||||
girlVC.productionType = self.productionType;
|
||||
girlVC.channel = @"2";
|
||||
#endif
|
||||
|
||||
NSArray *childArr = @[boyVC
|
||||
#if TF_Enable_PageControl
|
||||
, girlVC
|
||||
#endif
|
||||
];
|
||||
|
||||
|
||||
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:
|
||||
#if TF_Enable_PageControl
|
||||
CGRectMake(0, PUB_NAVBAR_HEIGHT + 44, SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
#else
|
||||
CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
#endif
|
||||
parentVC:self childVCs:childArr];
|
||||
_pageContentCollectionView.delegatePageContentCollectionView = self;
|
||||
[self.view addSubview:self.pageContentCollectionView];
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
NSArray *titleArr = @[TFLocalizedString(@"男生"), TFLocalizedString(@"女生")];
|
||||
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, 44) delegate:self titleNames:titleArr configure:self.pageConfigure];
|
||||
self.pageTitleView.backgroundColor = kWhiteColor;
|
||||
[self.view addSubview:_pageTitleView];
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex
|
||||
{
|
||||
[self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex
|
||||
{
|
||||
[self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFLimitFreeCommController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFLimitFreeCommController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,copy) NSString *channel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+215
@@ -0,0 +1,215 @@
|
||||
//
|
||||
// TFLimitFreeCommController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFLimitFreeCommController.h"
|
||||
#import "TFProductionListViewCell.h"
|
||||
#import "TFPublicAdvertisementViewCell.h"
|
||||
|
||||
@interface TFLimitFreeCommController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,assign) BOOL needRefresh;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFLimitFreeCommController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
self.needRefresh = YES;
|
||||
[self hiddenNavigationBar:YES];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(self.view.mas_top);
|
||||
make.bottom.mas_equalTo(self.view.mas_bottom).with.offset(- PUB_NAVBAR_HEIGHT - self.pageViewHeight);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
}];
|
||||
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"暂无数据") buttonTitle:@"" tapBlock:^{
|
||||
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber = 1;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
|
||||
self.mainTableView.mj_footer = [TFRefreshFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber ++;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
if (t_model.ad_type == 0) {
|
||||
TFProductionListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFProductionListViewCell"];
|
||||
|
||||
if (!cell) {
|
||||
cell = [[TFProductionListViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFProductionListViewCell"];
|
||||
}
|
||||
cell.productionType = self.productionType;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
cell.productionModel = t_model;
|
||||
cell.hiddenEndLine = (indexPath.row == self.dataSourceArray.count - 1);
|
||||
return cell;
|
||||
} else {
|
||||
TFPublicAdvertisementViewCell *cell = [self.advertDict objectForKey:[TFUtilsHelper formatStringWithInteger:indexPath.row]];
|
||||
if (!cell) {
|
||||
static NSString *cellName = @"TFPublicAdvertisementViewCell";
|
||||
cell = [[TFPublicAdvertisementViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
[cell setAdModel:t_model refresh:self.needRefresh];
|
||||
cell.mainTableView = tableView;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
[self.advertDict setObject:cell forKey:[TFUtilsHelper formatStringWithInteger:indexPath.row]];
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
switch (self.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel:
|
||||
{
|
||||
TFNovelDetailViewController *vc = [[TFNovelDetailViewController alloc] init];
|
||||
vc.book_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic:
|
||||
{
|
||||
TFComicDetailViewController *vc = [[TFComicDetailViewController alloc] init];
|
||||
vc.comic_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio:
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//section头部间距
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
//section头部视图
|
||||
- (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;
|
||||
}
|
||||
|
||||
//section底部间距
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
// return PUB_TABBAR_OFFSET == 0 ? kHalfMargin : PUB_TABBAR_OFFSET;
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
//section底部视图
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Free_Time;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Free_Time;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = @"";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:url parameters:@{@"channel_id":self.channel, @"page_num":[TFUtilsHelper formatStringWithInteger:self.currentPageNumber]} model:TFProductionListModel.class success:^(BOOL isSuccess, TFProductionListModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (isSuccess) {
|
||||
if (weakSelf.currentPageNumber == 1) {
|
||||
[weakSelf.mainTableView showRefreshFooter];
|
||||
[weakSelf.dataSourceArray removeAllObjects];
|
||||
weakSelf.dataSourceArray = [NSMutableArray arrayWithArray:t_model.list];
|
||||
} else {
|
||||
[weakSelf.dataSourceArray addObjectsFromArray:t_model.list];
|
||||
}
|
||||
if (t_model.total_page <= t_model.current_page) {
|
||||
[weakSelf.mainTableView hideRefreshFooter];
|
||||
}
|
||||
}
|
||||
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
weakSelf.needRefresh = YES;
|
||||
[weakSelf.mainTableView reloadData];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
weakSelf.needRefresh = NO;
|
||||
});
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFLimitFreeViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFLimitFreeViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
//
|
||||
// TFLimitFreeViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFLimitFreeViewController.h"
|
||||
#import "TFLimitFreeCommController.h"
|
||||
#import "SGPagingView.h"
|
||||
|
||||
@interface TFLimitFreeViewController ()<
|
||||
#if TF_Enable_PageControl
|
||||
SGPageTitleViewDelegate,
|
||||
#endif
|
||||
SGPageContentCollectionViewDelegate>
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
|
||||
#endif
|
||||
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentCollectionView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFLimitFreeViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"限时免费")];
|
||||
[self hiddenSeparator];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
TFLimitFreeCommController *boyVC = [[TFLimitFreeCommController alloc] init];
|
||||
boyVC.channel = @"1";
|
||||
boyVC.productionType = self.productionType;
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
TFLimitFreeCommController *girlVC = [[TFLimitFreeCommController alloc] init];
|
||||
girlVC.channel = @"2";
|
||||
girlVC.productionType = self.productionType;
|
||||
#endif
|
||||
|
||||
NSArray *childArr = @[boyVC
|
||||
#if TF_Enable_PageControl
|
||||
, girlVC
|
||||
#endif
|
||||
];
|
||||
|
||||
|
||||
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:
|
||||
#if TF_Enable_PageControl
|
||||
CGRectMake(0, PUB_NAVBAR_HEIGHT + 44, SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
#else
|
||||
CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
#endif
|
||||
parentVC:self childVCs:childArr];
|
||||
_pageContentCollectionView.delegatePageContentCollectionView = self;
|
||||
[self.view addSubview:self.pageContentCollectionView];
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
NSArray *titleArr = @[TFLocalizedString(@"男生"), TFLocalizedString(@"女生")];
|
||||
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, 44) delegate:self titleNames:titleArr configure:self.pageConfigure];
|
||||
self.pageTitleView.backgroundColor = kWhiteColor;
|
||||
[self.view addSubview:_pageTitleView];
|
||||
|
||||
if (TFSystemInfoManager.sexChannel == 2) {
|
||||
[self.pageTitleView setSelectedIndex:1];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
|
||||
[self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex {
|
||||
[self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// TFMemberViewController.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFMemberViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+383
@@ -0,0 +1,383 @@
|
||||
//
|
||||
// TFMemberViewController.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFMemberViewController.h"
|
||||
#import "TFSortViewController.h"
|
||||
#import "TFUpgradeMemberController.h"
|
||||
#import "TFMemberHeaderView.h"
|
||||
#import "TFBookStoreNovelStyleOneCell.h"
|
||||
#import "TFBookStoreNovelStyleTwoCell.h"
|
||||
#import "TFBookStoreNovelStyleThreeCell.h"
|
||||
#import "TFBookStoreNovelStyleFourCell.h"
|
||||
#import "TFBookStoreComicMaxStyleCell.h"
|
||||
#import "TFBookStoreComicMiddleStyleCell.h"
|
||||
#import "TFBookStoreComicNormalStyleCell.h"
|
||||
#import "TFPublicAdvertisementViewCell.h"
|
||||
#import "TFMemberModel.h"
|
||||
#import "TFBannerActionManager.h"
|
||||
|
||||
@interface TFMemberViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) TFMemberHeaderView *headerView;
|
||||
@property (nonatomic ,strong) TFMemberModel *monthlyModel;
|
||||
@property (nonatomic ,assign) BOOL needRefresh;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFMemberViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
self.needRefresh = YES;
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"会员中心")];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netRequest) name:Notification_Recharge_Success 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(PUB_NAVBAR_HEIGHT);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.headerView = [[TFMemberHeaderView alloc] init];
|
||||
self.headerView.functionButtonClickBlock = ^(TFPrivilegeModel *privilegeModel) {
|
||||
if ([privilegeModel.action isEqualToString:@"library"]) {
|
||||
TFSortViewController *vc = [[TFSortViewController alloc] init];
|
||||
vc.productionType = weakSelf.productionType;
|
||||
vc.isMemberStore = YES;
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
} else {
|
||||
if (!TFUserInfoManager.isLogin) {
|
||||
[TFLoginOptionsViewController presentLoginView:nil];
|
||||
return;
|
||||
}
|
||||
[weakSelf.navigationController pushViewController:[[TFUpgradeMemberController alloc] init] animated:YES];
|
||||
}
|
||||
};
|
||||
self.headerView.bannerrImageClickBlock = ^(TFBannerModel *bannerModel) {
|
||||
if ([TFBannerActionManager getBannerActionWithBannerModel:bannerModel productionType:weakSelf.productionType]) {
|
||||
[weakSelf.navigationController pushViewController:[TFBannerActionManager getBannerActionWithBannerModel:bannerModel productionType:weakSelf.productionType] animated:YES];
|
||||
}
|
||||
};
|
||||
[self.mainTableViewGroup setTableHeaderView:self.headerView];
|
||||
|
||||
[self setEmptyOnView:self.mainTableViewGroup title:TFLocalizedString(@"暂无数据") tapBlock:^{
|
||||
|
||||
}];
|
||||
|
||||
self.mainTableViewGroup.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return self.monthlyModel.label.count;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFBookStoreLabelModel *labelModel = [self.monthlyModel.label objectOrNilAtIndex:indexPath.section];
|
||||
|
||||
if (labelModel.ad_type == 0) {
|
||||
if (self.productionType == TFProductionTypeComic) {
|
||||
switch (labelModel.style) {
|
||||
case 1:
|
||||
return [self createMiddleStyleComicCellWithTableView:tableView indexPath:indexPath labelModel:labelModel];
|
||||
break;
|
||||
case 2:
|
||||
return [self createNormalStyleComicCellWithTableView:tableView indexPath:indexPath labelModel:labelModel];
|
||||
break;
|
||||
case 3:
|
||||
return [self createMaxStyleComicCellWithTableView:tableView indexPath:indexPath labelModel:labelModel];
|
||||
break;
|
||||
|
||||
default:
|
||||
return [self createNormalStyleComicCellWithTableView:tableView indexPath:indexPath labelModel:labelModel];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
for (TFProductionModel *t_model in labelModel.list) {
|
||||
t_model.productionType = self.productionType;
|
||||
}
|
||||
switch (labelModel.style) {
|
||||
case 1:
|
||||
return [self createCellWithTabelView:tableView cellClass:TFBookStoreNovelStyleOneCell.class indexPath:indexPath labelModel:labelModel];
|
||||
break;
|
||||
case 2:
|
||||
return [self createCellWithTabelView:tableView cellClass:TFBookStoreNovelStyleTwoCell.class indexPath:indexPath labelModel:labelModel];
|
||||
break;
|
||||
case 3:
|
||||
return [self createCellWithTabelView:tableView cellClass:TFBookStoreNovelStyleThreeCell.class indexPath:indexPath labelModel:labelModel];
|
||||
break;
|
||||
case 4:
|
||||
return [self createCellWithTabelView:tableView cellClass:TFBookStoreNovelStyleFourCell.class indexPath:indexPath labelModel:labelModel];
|
||||
break;
|
||||
|
||||
default:
|
||||
return [self createCellWithTabelView:tableView cellClass:TFBookStoreNovelStyleOneCell.class indexPath:indexPath labelModel:labelModel];
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return [self createAdStyleCellWithTableView:tableView indexPath:indexPath adModel:labelModel];
|
||||
}
|
||||
}
|
||||
|
||||
- (UITableViewCell *)createCellWithTabelView:(UITableView *)tableView cellClass:(Class)cellClass indexPath:(NSIndexPath *)indexPath labelModel:(TFBookStoreLabelModel *)labelModel
|
||||
{
|
||||
WS(weakSelf)
|
||||
TFBookStoreNovelBasicViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(cellClass)];
|
||||
if (!cell) {
|
||||
cell = [[cellClass alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(cellClass)];
|
||||
}
|
||||
|
||||
cell.labelModel = labelModel;
|
||||
cell.cellSelectMoreBlock = ^(TFBookStoreLabelModel * _Nonnull labelModel) {
|
||||
TFBookStoreMoreViewController *vc = [[TFBookStoreMoreViewController alloc] init];
|
||||
vc.productionType = weakSelf.productionType;
|
||||
vc.recommend_id = [TFUtilsHelper formatStringWithInteger:labelModel.recommend_id];
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
};
|
||||
cell.cellDidSelectItemBlock = ^(NSInteger production_id) {
|
||||
[weakSelf pushToMallDetail:production_id];
|
||||
};
|
||||
cell.showTopMoreBtn = labelModel.can_more;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)createMaxStyleComicCellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath labelModel:(TFBookStoreLabelModel *)labelModel
|
||||
{
|
||||
WS(weakSelf)
|
||||
static NSString *cellName = @"TFBookStoreComicMaxStyleCell";
|
||||
TFBookStoreComicMaxStyleCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFBookStoreComicMaxStyleCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.labelModel = labelModel;
|
||||
cell.showTopMoreButton = labelModel.can_more;
|
||||
cell.cellSelectMoreBlock = ^(TFBookStoreLabelModel * _Nonnull labelModel) {
|
||||
TFBookStoreMoreViewController *vc = [[TFBookStoreMoreViewController alloc] init];
|
||||
vc.productionType = weakSelf.productionType;
|
||||
vc.recommend_id = [TFUtilsHelper formatStringWithInteger:labelModel.recommend_id];
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
};
|
||||
cell.cellDidSelectItemBlock = ^(NSInteger production_id) {
|
||||
[weakSelf pushToMallDetail:production_id];
|
||||
};
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)createMiddleStyleComicCellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath labelModel:(TFBookStoreLabelModel *)labelModel
|
||||
{
|
||||
WS(weakSelf)
|
||||
static NSString *cellName = @"TFBookStoreComicMiddleStyleCell";
|
||||
TFBookStoreComicMiddleStyleCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFBookStoreComicMiddleStyleCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.labelModel = labelModel;
|
||||
cell.showTopMoreButton = labelModel.can_more;
|
||||
cell.cellSelectMoreBlock = ^(TFBookStoreLabelModel * _Nonnull labelModel) {
|
||||
TFBookStoreMoreViewController *vc = [[TFBookStoreMoreViewController alloc] init];
|
||||
vc.productionType = weakSelf.productionType;
|
||||
vc.recommend_id = [TFUtilsHelper formatStringWithInteger:labelModel.recommend_id];
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
};
|
||||
cell.cellDidSelectItemBlock = ^(NSInteger production_id) {
|
||||
[weakSelf pushToMallDetail:production_id];
|
||||
};
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)createNormalStyleComicCellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath labelModel:(TFBookStoreLabelModel *)labelModel
|
||||
{
|
||||
WS(weakSelf)
|
||||
static NSString *cellName = @"TFBookStoreComicNormalStyleCell";
|
||||
TFBookStoreComicNormalStyleCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFBookStoreComicNormalStyleCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.labelModel = labelModel;
|
||||
cell.showTopMoreButton = labelModel.can_more;
|
||||
cell.cellSelectMoreBlock = ^(TFBookStoreLabelModel * _Nonnull labelModel) {
|
||||
TFBookStoreMoreViewController *vc = [[TFBookStoreMoreViewController alloc] init];
|
||||
vc.productionType = weakSelf.productionType;
|
||||
vc.recommend_id = [TFUtilsHelper formatStringWithInteger:labelModel.recommend_id];
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
};
|
||||
cell.cellDidSelectItemBlock = ^(NSInteger production_id) {
|
||||
[weakSelf pushToMallDetail:production_id];
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
//section头部间距
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
if (section == 0) {
|
||||
return kHalfMargin;
|
||||
}
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
//section头部视图
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kHalfMargin)];
|
||||
view.backgroundColor = kGrayViewColor;
|
||||
return view;
|
||||
}
|
||||
|
||||
//section底部间距
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
if (section == self.monthlyModel.label.count - 1) {
|
||||
return PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET;
|
||||
}
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
//section底部视图
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)pushToMallDetail:(NSInteger)production_id
|
||||
{
|
||||
switch (self.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel: {
|
||||
TFNovelDetailViewController *vc = [[TFNovelDetailViewController alloc] init];
|
||||
vc.book_id = production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicDetailViewController *comicDetail = [[TFComicDetailViewController alloc] init];
|
||||
comicDetail.comic_id = production_id;
|
||||
[self.navigationController pushViewController:comicDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
TFAudioDetailViewController *vc = [[TFAudioDetailViewController alloc] init];
|
||||
vc.audio_id = production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
NSString *site_type = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
site_type = @"1";
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
site_type = @"2";
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
site_type = @"3";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Member_Monthly parameters:@{@"site_id":site_type} model:TFMemberModel.class success:^(BOOL isSuccess, TFMemberModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (isSuccess) {
|
||||
weakSelf.monthlyModel = t_model;
|
||||
}
|
||||
weakSelf.headerView.userInfoModel = weakSelf.monthlyModel.user;
|
||||
weakSelf.headerView.banner = weakSelf.monthlyModel.banner;
|
||||
weakSelf.headerView.privilege = weakSelf.monthlyModel.privilege;
|
||||
|
||||
if (weakSelf.monthlyModel.banner.count > 0) {
|
||||
weakSelf.emptyView.contentViewY = 350;
|
||||
} else {
|
||||
weakSelf.emptyView.contentViewY = 200;
|
||||
}
|
||||
|
||||
[weakSelf.mainTableViewGroup setTableHeaderView:weakSelf.headerView];
|
||||
|
||||
[weakSelf.mainTableViewGroup endRefreshing];
|
||||
weakSelf.needRefresh = YES;
|
||||
[weakSelf.mainTableViewGroup reloadData];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
weakSelf.needRefresh = NO;
|
||||
});
|
||||
[weakSelf.mainTableViewGroup xtfei_endLoading];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableViewGroup endRefreshing];
|
||||
[weakSelf.mainTableViewGroup xtfei_endLoading];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// TFMemberModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "TFUpgradeMemberModel.h"
|
||||
#import "TFBookStoreLabelModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TFMemberInfoModel;
|
||||
@interface TFMemberModel : NSObject
|
||||
|
||||
@property (nonatomic ,strong) TFMemberInfoModel *user;
|
||||
@property (nonatomic ,strong) NSArray<TFPrivilegeModel *> *privilege;
|
||||
@property (nonatomic ,strong) NSArray <TFBannerModel *>*banner;
|
||||
@property (nonatomic ,strong) NSArray<TFBookStoreLabelModel *> *label;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface TFMemberInfoModel : NSObject
|
||||
// 昵称
|
||||
@property (nonatomic ,copy) NSString *nickname;
|
||||
// 头像
|
||||
@property (nonatomic ,copy) NSString *avatar;
|
||||
// 包月状态 0未开通包月 1已开通包月
|
||||
@property (nonatomic ,assign) NSInteger baoyue_status;
|
||||
// 包月有效期
|
||||
@property (nonatomic ,copy) NSString *expiry_date;
|
||||
@property (nonatomic ,copy) NSString *vip_desc;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// TFMemberModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFMemberModel.h"
|
||||
|
||||
@implementation TFMemberModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{@"privilege" : [TFPrivilegeModel class],
|
||||
@"banner" : [TFBannerModel class],
|
||||
@"label" : [TFBookStoreLabelModel class]
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation TFMemberInfoModel
|
||||
|
||||
@end
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// TFMemberHeaderView.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFMemberModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFMemberHeaderView : UIView
|
||||
|
||||
@property (nonatomic ,copy) void (^bannerrImageClickBlock)(TFBannerModel *bannerModel); //banner点击
|
||||
@property (nonatomic ,copy) void (^functionButtonClickBlock)(TFPrivilegeModel *privilegeModel);
|
||||
|
||||
@property (nonatomic ,strong) TFMemberInfoModel *userInfoModel;
|
||||
@property (nonatomic ,strong) NSArray <TFBannerModel *>*banner;
|
||||
@property (nonatomic ,strong) NSArray<TFPrivilegeModel *> *privilege;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+279
@@ -0,0 +1,279 @@
|
||||
//
|
||||
// TFMemberHeaderView.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/2.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFMemberHeaderView.h"
|
||||
#import "TFDiscoverHeaderViewCell.h"
|
||||
#import "YJBannerView.h"
|
||||
|
||||
#define UserView_Height 80
|
||||
|
||||
#define Button_Width 70
|
||||
|
||||
@interface TFMemberHeaderView ()<YJBannerViewDelegate, YJBannerViewDataSource>
|
||||
{
|
||||
UIImageView *userAvatar;
|
||||
UILabel *userNickname;
|
||||
UIImageView *vipImageView;
|
||||
UILabel *noticeLabel;
|
||||
UIButton *memberButton;
|
||||
}
|
||||
@property (nonatomic, strong) YJBannerView *bannerView;
|
||||
|
||||
@property (nonatomic, strong) NSMutableArray *bannerImageArr;
|
||||
@end
|
||||
|
||||
@implementation TFMemberHeaderView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
self.backgroundColor = kWhiteColor;
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, UserView_Height + kMoreHalfMargin + kMoreHalfMargin + SCREEN_WIDTH / 5);
|
||||
self.bannerImageArr = [NSMutableArray array];
|
||||
[self createSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
//banner
|
||||
[self addSubview:self.bannerView];
|
||||
|
||||
userAvatar = [[UIImageView alloc] initWithCornerRadiusAdvance:(UserView_Height - 2 * kHalfMargin) / 2 rectCornerType:UIRectCornerAllCorners];
|
||||
userAvatar.image = HoldUserAvatar;
|
||||
[self addSubview:userAvatar];
|
||||
|
||||
[userAvatar mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kHalfMargin);
|
||||
make.top.mas_equalTo(self.bannerView.mas_bottom).with.offset(kMoreHalfMargin);
|
||||
make.width.height.mas_equalTo(UserView_Height - 2 * kHalfMargin);
|
||||
}];
|
||||
|
||||
userNickname = [[UILabel alloc] init];
|
||||
userNickname.backgroundColor = kGrayViewColor;
|
||||
userNickname.textColor = kBlackColor;
|
||||
userNickname.font = kMainFont;
|
||||
userNickname.textAlignment = NSTextAlignmentLeft;
|
||||
[self addSubview:userNickname];
|
||||
|
||||
[userNickname mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(userAvatar.mas_right).with.offset(kHalfMargin);
|
||||
make.bottom.mas_equalTo(userAvatar.mas_centerY).with.offset(- 3);
|
||||
make.width.mas_equalTo(10);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
vipImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"public_vip_normal"]];
|
||||
vipImageView.hidden = YES;
|
||||
[self addSubview:vipImageView];
|
||||
|
||||
[vipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(userNickname.mas_right).with.offset(kQuarterMargin);
|
||||
make.centerY.mas_equalTo(userNickname.mas_centerY);
|
||||
make.height.mas_equalTo(12);
|
||||
make.width.mas_equalTo(kGeometricWidth(12, 138, 48));
|
||||
}];
|
||||
|
||||
memberButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
memberButton.hidden = YES;
|
||||
memberButton.layer.cornerRadius = 4;
|
||||
[memberButton.titleLabel setFont:kFont12];
|
||||
[memberButton setTitle:TFLocalizedString(@"开通") forState:UIControlStateNormal];
|
||||
[memberButton setTitleColor:kColorRGB(120, 79, 18) forState:UIControlStateNormal];
|
||||
[memberButton setBackgroundImage:[UIImage imageNamed:@"monthly_member"] forState:UIControlStateNormal];
|
||||
[memberButton addTarget:self action:@selector(jumpToMember) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:memberButton];
|
||||
|
||||
[memberButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.mas_right).with.offset(- kHalfMargin);
|
||||
make.centerY.mas_equalTo(userAvatar.mas_centerY);
|
||||
make.width.mas_equalTo(kGeometricWidth(30, 210, 80));
|
||||
make.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
noticeLabel = [[UILabel alloc] init];
|
||||
noticeLabel.backgroundColor = kGrayViewColor;
|
||||
noticeLabel.textColor = kGrayTextColor;
|
||||
noticeLabel.font = kFont12;
|
||||
noticeLabel.textAlignment = NSTextAlignmentLeft;
|
||||
[self addSubview:noticeLabel];
|
||||
|
||||
[noticeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(userNickname.mas_left);
|
||||
make.top.mas_equalTo(userAvatar.mas_centerY).with.offset(3);
|
||||
make.right.mas_equalTo(memberButton.mas_left).with.offset(- kHalfMargin);
|
||||
make.height.mas_equalTo(userNickname.mas_height);
|
||||
}];
|
||||
|
||||
// 横线
|
||||
UIView *line = [[UIView alloc] init];
|
||||
line.hidden = NO;
|
||||
line.backgroundColor = kGrayLineColor;
|
||||
|
||||
[self addSubview:line];
|
||||
|
||||
[line mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kHalfMargin);
|
||||
make.top.mas_equalTo(userAvatar.mas_bottom).with.offset(kMoreHalfMargin);
|
||||
make.right.mas_equalTo(self.mas_right).with.offset(- kHalfMargin);
|
||||
make.height.mas_equalTo(kCellLineHeight);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setUserInfoModel:(TFMemberInfoModel *)userInfoModel
|
||||
{
|
||||
_userInfoModel = userInfoModel;
|
||||
|
||||
[userAvatar setImageWithURL:[NSURL URLWithString:userInfoModel.avatar?:@""] placeholder:HoldUserAvatar options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
|
||||
noticeLabel.text = userInfoModel.vip_desc;
|
||||
if (userInfoModel.nickname.length == 0 || !userInfoModel.nickname) {
|
||||
userNickname.text = TFLocalizedString(@"未登录");
|
||||
vipImageView.hidden = YES;
|
||||
} else {
|
||||
userNickname.text = userInfoModel.nickname?:@"";
|
||||
vipImageView.hidden = NO;
|
||||
if (userInfoModel.baoyue_status == 1) {
|
||||
noticeLabel.text = userInfoModel.expiry_date.length > 0 ? userInfoModel.expiry_date :userInfoModel.vip_desc;
|
||||
vipImageView.image = [UIImage imageNamed:@"public_vip_select"];
|
||||
[memberButton setTitle:TFLocalizedString(@"续费") forState:UIControlStateNormal];
|
||||
} else {
|
||||
vipImageView.image = [UIImage imageNamed:@"public_vip_normal"];
|
||||
[memberButton setTitle:TFLocalizedString(@"开通") forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
userNickname.backgroundColor = [UIColor whiteColor];
|
||||
[userNickname mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:userNickname]);
|
||||
}];
|
||||
|
||||
noticeLabel.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
memberButton.hidden = NO;
|
||||
}
|
||||
|
||||
- (void)setPrivilege:(NSArray<TFPrivilegeModel *> *)privilege
|
||||
{
|
||||
if (!_privilege && privilege) {
|
||||
for (int i = 0; i < privilege.count; i ++) {
|
||||
|
||||
TFPrivilegeModel *t_model = [privilege objectAtIndex:i];
|
||||
|
||||
TFButton *button = [[TFButton alloc] initWithFrame:CGRectZero buttonTitle:t_model.label?:@"" buttonImageName:t_model.icon?:@"" buttonIndicator:TFButtonIndicatorTitleBottom showMaskView:YES];
|
||||
button.graphicDistance = 0;
|
||||
button.buttonImageScale = 0.6;
|
||||
button.buttonTitleFont = kFont13;
|
||||
[button addTarget:self action:@selector(functionButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
button.tag = i;
|
||||
[self addSubview:button];
|
||||
|
||||
CGFloat buttonWidth = SCREEN_WIDTH / privilege.count;
|
||||
CGFloat buttonHeight = SCREEN_WIDTH / 5;
|
||||
|
||||
[button mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(i * buttonWidth);
|
||||
make.top.mas_equalTo(userAvatar.mas_bottom).with.offset(kMoreHalfMargin * 2);
|
||||
make.width.mas_equalTo(buttonWidth);
|
||||
make.height.mas_equalTo(buttonHeight);
|
||||
}];
|
||||
}
|
||||
}
|
||||
_privilege = privilege;
|
||||
}
|
||||
|
||||
- (void)setBanner:(NSArray<TFBannerModel *> *)banner
|
||||
{
|
||||
if (banner) {
|
||||
_banner = banner;
|
||||
|
||||
[_bannerImageArr removeAllObjects];
|
||||
|
||||
if (banner.count == 0) {
|
||||
self.bannerView.frame = CGRectMake(0, kHalfMargin, SCREEN_WIDTH, 0);
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, UserView_Height + kMoreHalfMargin + kMoreHalfMargin + SCREEN_WIDTH / 5);
|
||||
[userAvatar mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.bannerView.mas_bottom).with.offset(CGFLOAT_MIN);
|
||||
}];
|
||||
} else {
|
||||
self.bannerView.frame = CGRectMake(0, kHalfMargin, SCREEN_WIDTH, SCREEN_WIDTH / 4);
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH / 4 + kMoreHalfMargin + UserView_Height + kMoreHalfMargin + kMoreHalfMargin + SCREEN_WIDTH / 5);
|
||||
[userAvatar mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.bannerView.mas_bottom).with.offset(kMoreHalfMargin);
|
||||
}];
|
||||
for (TFBannerModel *t_model in banner) {
|
||||
[_bannerImageArr addObject:t_model.image];
|
||||
}
|
||||
|
||||
[self.bannerView reloadData];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (YJBannerView *)bannerView
|
||||
{
|
||||
if (!_bannerView) {
|
||||
_bannerView = [YJBannerView bannerViewWithFrame:CGRectMake(0, kHalfMargin, SCREEN_WIDTH, SCREEN_WIDTH / 4) dataSource:self delegate:self emptyImage:HoldImage placeholderImage:HoldImage selectorString:NSStringFromSelector(@selector(setImageWithURL:placeholder:))];
|
||||
_bannerView.pageControlAliment = PageControlAlimentCenter;
|
||||
_bannerView.repeatCount = 9999;
|
||||
_bannerView.autoDuration = 5.0f;
|
||||
_bannerView.pageControlStyle = PageControlCustom;
|
||||
_bannerView.pageControlDotSize = CGSizeMake(10, 5);
|
||||
_bannerView.customPageControlHighlightImage = [UIImage imageNamed:@"pageControlS"];
|
||||
_bannerView.customPageControlNormalImage = [UIImage imageNamed:@"pageControlN"];
|
||||
}
|
||||
return _bannerView;
|
||||
}
|
||||
|
||||
- (NSArray *)bannerViewRegistCustomCellClass:(YJBannerView *)bannerView
|
||||
{
|
||||
return @[[TFDiscoverHeaderViewCell class]];
|
||||
}
|
||||
|
||||
/** 根据 Index 选择使用哪个 reuseIdentifier */
|
||||
- (Class)bannerView:(YJBannerView *)bannerView reuseIdentifierForIndex:(NSInteger)index
|
||||
{
|
||||
return [TFDiscoverHeaderViewCell class];
|
||||
}
|
||||
|
||||
/** 自定义 View 刷新数据或者其他配置 */
|
||||
- (UICollectionViewCell *)bannerView:(YJBannerView *)bannerView customCell:(UICollectionViewCell *)customCell index:(NSInteger)index
|
||||
{
|
||||
TFDiscoverHeaderViewCell *cell = (TFDiscoverHeaderViewCell *)customCell;
|
||||
cell.imageURL = [self.bannerImageArr objectOrNilAtIndex:index];
|
||||
return cell;
|
||||
}
|
||||
|
||||
// 将网络图片或者本地图片 或者混合数组
|
||||
- (NSArray *)bannerViewImages:(YJBannerView *)bannerView
|
||||
{
|
||||
return _bannerImageArr;
|
||||
}
|
||||
|
||||
// 代理方法 点击了哪个bannerView 的 第几个元素
|
||||
- (void)bannerView:(YJBannerView *)bannerView didSelectItemAtIndex:(NSInteger)index
|
||||
{
|
||||
if (self.bannerrImageClickBlock) {
|
||||
self.bannerrImageClickBlock([self.banner objectOrNilAtIndex:index]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)jumpToMember
|
||||
{
|
||||
if (self.functionButtonClickBlock) {
|
||||
self.functionButtonClickBlock([[TFPrivilegeModel alloc] init]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)functionButtonClick:(UIButton *)sender
|
||||
{
|
||||
if (self.functionButtonClickBlock) {
|
||||
self.functionButtonClickBlock([self.privilege objectAtIndex:sender.tag]);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFPopularityCommViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFPopularityCommViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,copy) NSString *channel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
//
|
||||
// TFPopularityCommViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFPopularityCommViewController.h"
|
||||
#import "TFPopularityDetailViewController.h"
|
||||
#import "TFPopularityViewCell.h"
|
||||
#import "TFPopularityModel.h"
|
||||
|
||||
@interface TFPopularityCommViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFPopularityCommViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self hiddenNavigationBar:YES];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(self.view.mas_top);
|
||||
make.bottom.mas_equalTo(self.view.mas_bottom).with.offset(- PUB_NAVBAR_HEIGHT - self.pageViewHeight);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
}];
|
||||
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"暂无数据") buttonTitle:@"" tapBlock:^{
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
[self.mainTableView.mj_header beginRefreshing];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFPopularityViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WXBookRankListTableViewCell"];
|
||||
|
||||
if (!cell) {
|
||||
cell = [[TFPopularityViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"WXBookRankListTableViewCell"];
|
||||
}
|
||||
if (self.dataSourceArray.count) {
|
||||
cell.rankListModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
}
|
||||
cell.productionType = self.productionType;
|
||||
cell.hiddenEndLine = (indexPath.row == self.dataSourceArray.count - 1);
|
||||
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
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (self.dataSourceArray && self.dataSourceArray.count > 0) {
|
||||
TFPopularityModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
TFPopularityDetailViewController *vc = [[TFPopularityDetailViewController alloc] init];
|
||||
vc.channel = self.channel;
|
||||
vc.productionType = self.productionType;
|
||||
vc.rank_type = t_model.rank_type;
|
||||
vc.navTitle = t_model.list_name?:@"";
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Rank_List;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Rank_List;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Rank_List;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
WS(weakSelf)
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"channel_id"] = self.channel;
|
||||
|
||||
[TFNetworkTools POST:url parameters:params model:nil success:^(BOOL isSuccess, NSDictionary *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
|
||||
if (isSuccess) {
|
||||
NSArray *t_arr = t_model[@"data"];
|
||||
[weakSelf.dataSourceArray removeAllObjects];
|
||||
for (NSDictionary *t_dic in t_arr) {
|
||||
TFPopularityModel *t_model = [TFPopularityModel modelWithDictionary:t_dic];
|
||||
[weakSelf.dataSourceArray addObject:t_model];
|
||||
}
|
||||
}
|
||||
|
||||
[weakSelf.mainTableView reloadData];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
[weakSelf.mainTableView reloadData];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFPopularityDetailViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFPopularityDetailViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,copy) NSString *channel;
|
||||
@property (nonatomic ,copy) NSString *rank_type;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+225
@@ -0,0 +1,225 @@
|
||||
//
|
||||
// TFPopularityDetailViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFPopularityDetailViewController.h"
|
||||
#import "TFProductionListViewCell.h"
|
||||
#import "TFPublicAdvertisementViewCell.h"
|
||||
|
||||
@interface TFPopularityDetailViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,assign) BOOL needRefresh;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFPopularityDetailViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
self.needRefresh = YES;
|
||||
[self setNavigationBarTitle:self.navTitle];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"暂无数据") tapBlock:^{
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber = 1;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
[self.mainTableView.mj_header beginRefreshing];
|
||||
|
||||
self.mainTableView.mj_footer = [TFRefreshFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber ++;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
if (t_model.ad_type == 0) {
|
||||
TFProductionListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFProductionListViewCell"];
|
||||
if (!cell) {
|
||||
cell = [[TFProductionListViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFProductionListViewCell"];
|
||||
}
|
||||
cell.isRankList = YES;
|
||||
cell.productionType = self.productionType;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
cell.productionModel = t_model;
|
||||
cell.hiddenEndLine = (indexPath.row == self.dataSourceArray.count - 1);
|
||||
|
||||
return cell;
|
||||
} else {
|
||||
|
||||
TFPublicAdvertisementViewCell *cell = [self.advertDict objectForKey:[TFUtilsHelper formatStringWithInteger:indexPath.row]];
|
||||
if (!cell) {
|
||||
static NSString *cellName = @"TFPublicAdvertisementViewCell";
|
||||
cell = [[TFPublicAdvertisementViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
[cell setAdModel:t_model refresh:self.needRefresh];
|
||||
cell.mainTableView = tableView;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
[self.advertDict setObject:cell forKey:[TFUtilsHelper formatStringWithInteger:indexPath.row]];
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
switch (self.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel: {
|
||||
TFNovelDetailViewController *vc = [[TFNovelDetailViewController alloc] init];
|
||||
vc.book_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicDetailViewController *comicDetail = [[TFComicDetailViewController alloc] init];
|
||||
comicDetail.comic_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:comicDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
TFAudioDetailViewController *vc = [[TFAudioDetailViewController alloc] init];
|
||||
vc.audio_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Rank_Detail_List;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Rank_Detail_List;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Rank_Detail_List;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"channel_id"] = self.channel;
|
||||
params[@"rank_type"] = self.rank_type;
|
||||
params[@"page_num"] = [TFUtilsHelper formatStringWithInteger:weakSelf.currentPageNumber];
|
||||
|
||||
[TFNetworkTools POST:url parameters:params model:TFProductionListModel.class success:^(BOOL isSuccess, TFProductionListModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
|
||||
if (isSuccess) {
|
||||
if (weakSelf.currentPageNumber == 1) {
|
||||
weakSelf.dataSourceArray = [NSMutableArray arrayWithArray:t_model.list];
|
||||
} else {
|
||||
[weakSelf.dataSourceArray addObjectsFromArray:t_model.list];
|
||||
}
|
||||
|
||||
weakSelf.needRefresh = YES;
|
||||
[weakSelf.mainTableView reloadData];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
weakSelf.needRefresh = NO;
|
||||
});
|
||||
if (t_model.total_page <= t_model.current_page) {
|
||||
[weakSelf.mainTableView hideRefreshFooter];
|
||||
}
|
||||
}
|
||||
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
if (weakSelf.dataSourceArray.count == 0) {
|
||||
[weakSelf.mainTableView xtfei_showEmptyView];
|
||||
} else {
|
||||
[weakSelf.mainTableView xtfei_hideEmptyView];
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFPopularityViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFPopularityViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// TFPopularityViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFPopularityViewController.h"
|
||||
#import "TFPopularityCommViewController.h"
|
||||
|
||||
@interface TFPopularityViewController ()<
|
||||
#if TF_Enable_PageControl
|
||||
SGPageTitleViewDelegate,
|
||||
#endif
|
||||
SGPageContentCollectionViewDelegate>
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
|
||||
#endif
|
||||
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentCollectionView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFPopularityViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setNavigationBarTitle:self.navTitle?:TFLocalizedString(@"榜单")];
|
||||
[self hiddenSeparator];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
TFPopularityCommViewController *boyVC = [[TFPopularityCommViewController alloc] init];
|
||||
boyVC.productionType = self.productionType;
|
||||
boyVC.channel = @"1";
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
TFPopularityCommViewController *girlVC = [[TFPopularityCommViewController alloc] init];
|
||||
girlVC.productionType = self.productionType;
|
||||
girlVC.channel = @"2";
|
||||
#endif
|
||||
|
||||
NSArray *childArr = @[boyVC
|
||||
#if TF_Enable_PageControl
|
||||
, girlVC
|
||||
#endif
|
||||
];
|
||||
|
||||
|
||||
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:
|
||||
#if TF_Enable_PageControl
|
||||
CGRectMake(0, PUB_NAVBAR_HEIGHT + 44, SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
#else
|
||||
CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
#endif
|
||||
parentVC:self childVCs:childArr];
|
||||
_pageContentCollectionView.delegatePageContentCollectionView = self;
|
||||
[self.view addSubview:self.pageContentCollectionView];
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
NSArray *titleArr = @[TFLocalizedString(@"男生"), TFLocalizedString(@"女生")];
|
||||
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, 44) delegate:self titleNames:titleArr configure:self.pageConfigure];
|
||||
self.pageTitleView.backgroundColor = kWhiteColor;
|
||||
[self.view addSubview:_pageTitleView];
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex
|
||||
{
|
||||
[self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex
|
||||
{
|
||||
[self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// TFPopularityModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFPopularityModel : NSObject
|
||||
// 排行榜类型
|
||||
@property (nonatomic ,copy) NSString *rank_type;
|
||||
// 榜单名
|
||||
@property (nonatomic ,copy) NSString *list_name;
|
||||
// 榜单简介
|
||||
@property (nonatomic ,copy) NSString *rankDescription;
|
||||
// 榜单图标
|
||||
@property (nonatomic ,strong) NSArray <NSString *>*icon;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFPopularityModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFPopularityModel.h"
|
||||
|
||||
@implementation TFPopularityModel
|
||||
|
||||
+ (NSDictionary *)modelCustomPropertyMapper
|
||||
{
|
||||
return @{
|
||||
@"rankDescription" :@[@"description", @"desc"],
|
||||
@"list_name" :@[@"list_name", @"title"]
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFPopularityViewCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFPopularityModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFPopularityViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFPopularityModel *rankListModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
//
|
||||
// TFPopularityViewCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFPopularityViewCell.h"
|
||||
|
||||
@interface TFPopularityViewCell ()
|
||||
|
||||
@property (nonatomic ,strong) TFProductionCoverView *iconTop;
|
||||
@property (nonatomic ,strong) TFProductionCoverView *iconCenter;
|
||||
@property (nonatomic ,strong) TFProductionCoverView *iconBottom;
|
||||
@property (nonatomic ,strong) UILabel *rankLabel;
|
||||
@property (nonatomic ,strong) UILabel *descriptionLabel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFPopularityViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
self.iconBottom = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
|
||||
[self.contentView addSubview:self.iconBottom];
|
||||
|
||||
self.iconCenter = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
|
||||
[self.contentView addSubview:self.iconCenter];
|
||||
|
||||
self.iconTop = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
|
||||
[self.contentView addSubview:self.iconTop];
|
||||
|
||||
[self.iconTop mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kHalfMargin);
|
||||
make.width.mas_equalTo(60);
|
||||
make.height.mas_equalTo(kGeometricHeight(60, 3, 4));
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin).priorityLow();
|
||||
}];
|
||||
|
||||
[self.iconCenter mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.iconTop.mas_bottom);
|
||||
make.right.mas_equalTo(self.iconTop.mas_right).with.offset(kMargin);
|
||||
make.width.mas_equalTo(50);
|
||||
make.height.mas_equalTo(kGeometricHeight(50, 3, 4));
|
||||
}];
|
||||
|
||||
[self.iconBottom mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.iconCenter.mas_bottom);
|
||||
make.right.mas_equalTo(self.iconCenter.mas_right).with.offset(kMargin);
|
||||
make.width.mas_equalTo(40);
|
||||
make.height.mas_equalTo(kGeometricHeight(40, 3, 4));
|
||||
}];
|
||||
|
||||
self.rankLabel = [[UILabel alloc] init];
|
||||
self.rankLabel.textColor = kBlackColor;
|
||||
self.rankLabel.backgroundColor = kGrayViewColor;
|
||||
self.rankLabel.font = kMainFont;
|
||||
[self.contentView addSubview:self.rankLabel];
|
||||
|
||||
[self.rankLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.iconTop.mas_centerY).with.offset(- 2);
|
||||
make.left.mas_equalTo(self.iconBottom.mas_right).with.offset(kMargin);
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
|
||||
make.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
self.descriptionLabel = [[UILabel alloc] init];
|
||||
self.descriptionLabel.textColor = kGrayTextColor;
|
||||
self.descriptionLabel.backgroundColor = kGrayViewColor;
|
||||
self.descriptionLabel.font = kFont12;
|
||||
[self.contentView addSubview:self.descriptionLabel];
|
||||
|
||||
[self.descriptionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.iconTop.mas_centerY).with.offset(2);
|
||||
make.left.mas_equalTo(self.rankLabel.mas_left);
|
||||
make.width.mas_equalTo(self.rankLabel.mas_width);
|
||||
make.height.mas_equalTo(self.rankLabel.mas_height);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setRankListModel:(TFPopularityModel *)rankListModel
|
||||
{
|
||||
_rankListModel = rankListModel;
|
||||
|
||||
for (int i = 0; i < rankListModel.icon.count; i++) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
self.iconTop.coverImageUrl = [rankListModel.icon objectOrNilAtIndex:0];
|
||||
break;
|
||||
case 1:
|
||||
self.iconCenter.coverImageUrl = [rankListModel.icon objectOrNilAtIndex:1];
|
||||
if ([rankListModel.icon objectAtIndex:1].length <= 0) {
|
||||
self.iconCenter.hidden = YES;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
self.iconBottom.coverImageUrl = [rankListModel.icon objectOrNilAtIndex:2];
|
||||
if ([rankListModel.icon objectAtIndex:2].length <= 0) {
|
||||
self.iconBottom.hidden = YES;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
self.rankLabel.backgroundColor = [UIColor whiteColor];
|
||||
self.rankLabel.text = rankListModel.list_name?:@"";
|
||||
|
||||
self.descriptionLabel.backgroundColor = [UIColor whiteColor];
|
||||
self.descriptionLabel.text = rankListModel.rankDescription?:@"";
|
||||
}
|
||||
|
||||
- (void)setProductionType:(TFProductionType)productionType
|
||||
{
|
||||
[super setProductionType:productionType];
|
||||
|
||||
self.iconTop.productionType = productionType;
|
||||
}
|
||||
|
||||
@end
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFSearchViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/24.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFSearchViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,strong) NSString *placeholder;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+367
@@ -0,0 +1,367 @@
|
||||
//
|
||||
// TFSearchViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/24.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFSearchViewController.h"
|
||||
#import "TFBookStoreNovelStyleTwoCell.h"
|
||||
#import "TFProductionListViewCell.h"
|
||||
#import "TFHotspotSearchView.h"
|
||||
#import "TFSearchBar.h"
|
||||
#import "TFBookStoreLabelModel.h"
|
||||
#import "TFSearchModel.h"
|
||||
|
||||
@interface TFSearchViewController ()<UITableViewDelegate, UITableViewDataSource, TFSearchBarDelegate>
|
||||
|
||||
@property (nonatomic ,strong) TFHotspotSearchView *hotspotSearchView;
|
||||
@property (nonatomic ,strong) TFBookStoreLabelModel *labelModel;
|
||||
@property (nonatomic ,strong) TFSearchBar *searchBar;
|
||||
@property (nonatomic ,assign) BOOL inSearchState;
|
||||
@property (nonatomic ,strong) NSString *searchStr;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFSearchViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
[self netRequest];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
{
|
||||
[super viewWillDisappear:animated];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Show_Tabbar object:nil];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self hiddenNavigationBar:YES];
|
||||
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.searchBar = [[TFSearchBar alloc] initWithFrame:CGRectMake(5, PUB_NAVBAR_OFFSET + 25, SCREEN_WIDTH - 2 * 5, 40)];
|
||||
self.searchBar.placeholderText = self.placeholder ?: TFLocalizedString(@"搜索您感兴趣的书籍");
|
||||
self.searchBar.backgroundColor = [UIColor clearColor];
|
||||
self.searchBar.delegate = self;
|
||||
[self.view addSubview:self.searchBar];
|
||||
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT + kHalfMargin);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - kHalfMargin);
|
||||
}];
|
||||
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"未搜索到相关内容") buttonTitle:nil tapBlock:^{
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.hotspotSearchView = [[TFHotspotSearchView alloc] init];
|
||||
self.hotspotSearchView.bookClickBlock = ^(NSString *hotspotBook) {
|
||||
weakSelf.searchBar.searchText = hotspotBook;
|
||||
[weakSelf searchButtonClickedWithSearchText:hotspotBook];
|
||||
};
|
||||
[self.mainTableView setTableHeaderView:self.hotspotSearchView];
|
||||
|
||||
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber = 1;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
|
||||
self.mainTableView.mj_footer = [TFRefreshFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber ++;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
|
||||
[self.mainTableView hideRefreshHeader];
|
||||
[self.mainTableView hideRefreshFooter];
|
||||
[self.mainTableView titleLabel].hidden = YES;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.inSearchState ? self.dataSourceArray.count : self.labelModel ? 1 : 0;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
WS(weakSelf)
|
||||
if (self.inSearchState) {
|
||||
static NSString *cellName = @"TFProductionListViewCell";
|
||||
TFProductionListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFProductionListViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.productionType = self.productionType;
|
||||
cell.productionModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
return cell;
|
||||
|
||||
} else {
|
||||
static NSString *cellName = @"TFBookStoreNovelStyleTwoCell";
|
||||
TFBookStoreNovelStyleTwoCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFBookStoreNovelStyleTwoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.cellDidSelectItemBlock = ^(NSInteger production_id) {
|
||||
|
||||
switch (weakSelf.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel: {
|
||||
TFNovelDetailViewController *novelDetail = [[TFNovelDetailViewController alloc] init];
|
||||
novelDetail.book_id = production_id;
|
||||
[weakSelf.navigationController pushViewController:novelDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicDetailViewController *comicDetail = [[TFComicDetailViewController alloc] init];
|
||||
comicDetail.comic_id = production_id;
|
||||
[weakSelf.navigationController pushViewController:comicDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
TFAudioDetailViewController *audioDetail = [[TFAudioDetailViewController alloc] init];
|
||||
audioDetail.audio_id = production_id;
|
||||
[weakSelf.navigationController pushViewController:audioDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
cell.labelModel = self.labelModel;
|
||||
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (self.inSearchState) {
|
||||
TFProductionModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
switch (self.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel: {
|
||||
TFNovelDetailViewController *vc = [[TFNovelDetailViewController alloc] init];
|
||||
vc.book_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicDetailViewController *vc = [[TFComicDetailViewController alloc] init];
|
||||
vc.comic_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
TFAudioDetailViewController *vc = [[TFAudioDetailViewController alloc] init];
|
||||
vc.audio_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
||||
{
|
||||
[self.searchBar searchBarResignFirstResponder];
|
||||
}
|
||||
|
||||
- (void)cancelButtonClicked
|
||||
{
|
||||
if (self.searchStr.length > 0) {
|
||||
self.searchBar.searchText = @"";
|
||||
[self.searchBar resignFirstResponder];
|
||||
[self searchBarCleanText];
|
||||
} else {
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)searchButtonClickedWithSearchText:(NSString *)searchText
|
||||
{
|
||||
self.currentPageNumber = 1;
|
||||
self.inSearchState = YES;
|
||||
self.searchStr = searchText;
|
||||
[self searchNetRequest];
|
||||
}
|
||||
|
||||
- (void)searchBarCleanText
|
||||
{
|
||||
self.currentPageNumber = 1;
|
||||
self.inSearchState = NO;
|
||||
self.searchStr = @"";
|
||||
self.hotspotSearchView.hidden = NO;
|
||||
[self.hotspotSearchView setNormalFrame];
|
||||
[self.mainTableView reloadData];
|
||||
[self.mainTableView xtfei_startLoading];
|
||||
[self.mainTableView hideRefreshFooter];
|
||||
[self.mainTableView hideRefreshHeader];
|
||||
[self.mainTableView titleLabel].hidden = YES;
|
||||
}
|
||||
|
||||
- (void)searchNetRequest
|
||||
{
|
||||
// if ([self.searchStr isEqualToString:TFLocalizedString(@" 切换至测试版 ")]) {
|
||||
// [[NSNotificationCenter defaultCenter] postNotificationName:Notification_Review_State object:@"1"];
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if ([self.searchStr isEqualToString:TFLocalizedString(@" 强行切换至测试版 ")]) {
|
||||
//#ifdef Notification_Force_Review_State
|
||||
// [[NSNotificationCenter defaultCenter] postNotificationName:Notification_Force_Review_State object:@"1"];
|
||||
//#else
|
||||
// [[NSNotificationCenter defaultCenter] postNotificationName:@"mDidForceChangeMagicState" object:@"1"];
|
||||
//#endif
|
||||
// return;
|
||||
// }
|
||||
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Search_List;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Search_List;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Search_List;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"keyword"] = self.searchStr;
|
||||
params[@"page_num"] = [TFUtilsHelper formatStringWithInteger:self.currentPageNumber];
|
||||
|
||||
[TFNetworkTools POST:url parameters:params model:TFProductionListModel.class success:^(BOOL isSuccess, TFProductionListModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
|
||||
if (isSuccess) {
|
||||
if (weakSelf.currentPageNumber == 1) {
|
||||
weakSelf.hotspotSearchView.hidden = YES;
|
||||
weakSelf.hotspotSearchView.frame = CGRectMake(0, 0, 0.1, 0.1);
|
||||
// [weakSelf.mainTableView showRefreshHeader];
|
||||
// [weakSelf.mainTableView showRefreshFooter];
|
||||
[weakSelf.dataSourceArray removeAllObjects];
|
||||
weakSelf.dataSourceArray = [NSMutableArray arrayWithArray:t_model.list];
|
||||
} else {
|
||||
[weakSelf.dataSourceArray addObjectsFromArray:t_model.list];
|
||||
}
|
||||
if (t_model.total_page <= t_model.current_page) {
|
||||
[weakSelf.mainTableView hideRefreshFooter];
|
||||
}
|
||||
}
|
||||
|
||||
[weakSelf.mainTableView reloadData];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Search;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Search;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Search;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:url parameters:nil model:TFSearchModel.class success:^(BOOL isSuccess, TFSearchModel *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (isSuccess) {
|
||||
for (TFProductionModel *tt_model in t_model.list) {
|
||||
tt_model.productionType = weakSelf.productionType;
|
||||
}
|
||||
weakSelf.hotspotSearchView.hotspotBookArray = t_model.hot_word;
|
||||
|
||||
// if (t_model.hot_word.count > 0) {
|
||||
// weakSelf.searchBar.placeholderText = [t_model.hot_word objectOrNilAtIndex:(arc4random() % (t_model.hot_word.count - 1))];
|
||||
// } else {
|
||||
// weakSelf.searchBar.placeholderText = TFLocalizedString(@"搜索您感兴趣的书籍");
|
||||
// }
|
||||
|
||||
weakSelf.labelModel = [[TFBookStoreLabelModel alloc] init];
|
||||
weakSelf.labelModel.list = t_model.list;
|
||||
weakSelf.labelModel.label = TFLocalizedString(@"热搜榜");
|
||||
weakSelf.labelModel.style = 2;
|
||||
}
|
||||
[weakSelf.mainTableView reloadData];
|
||||
} failure:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFSearchModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/24.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class TFProductionModel;
|
||||
@interface TFSearchModel : NSObject
|
||||
|
||||
@property (nonatomic ,strong) NSArray<TFProductionModel *> *list;
|
||||
@property (nonatomic ,strong) NSArray<NSString *> *hot_word;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFSearchModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/24.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFSearchModel.h"
|
||||
|
||||
@implementation TFSearchModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{@"list" : [TFProductionModel class]};
|
||||
}
|
||||
|
||||
@end
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// TFHotspotSearchView.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/24.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef void(^HotspotBookClickBlock)(NSString *hotspotBook);
|
||||
@interface TFHotspotSearchView : UIView
|
||||
|
||||
@property (nonatomic ,strong) NSArray *hotspotBookArray;
|
||||
|
||||
@property (nonatomic ,copy) HotspotBookClickBlock bookClickBlock;
|
||||
|
||||
- (void)setSmallFrame;
|
||||
|
||||
- (void)setNormalFrame;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
//
|
||||
// TFHotspotSearchView.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/24.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFHotspotSearchView.h"
|
||||
|
||||
@interface TFHotspotSearchView ()
|
||||
@property (nonatomic ,assign) CGRect hotspotSearchViewFrame;
|
||||
@end
|
||||
|
||||
@implementation TFHotspotSearchView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setHotspotBookArray:(NSArray *)hotspotBookArray
|
||||
{
|
||||
_hotspotBookArray = hotspotBookArray;
|
||||
|
||||
UILabel *headTitle = [[UILabel alloc] init];
|
||||
headTitle.textColor = kGrayTextColor;
|
||||
headTitle.backgroundColor = [UIColor clearColor];
|
||||
headTitle.text = TFLocalizedString(@"热门搜索");
|
||||
headTitle.font = kFont12;
|
||||
[self addSubview:headTitle];
|
||||
|
||||
[headTitle mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.top.mas_equalTo(kHalfMargin + 5);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH / 2);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
int buttonNum = 2; // 每行多少按钮
|
||||
CGFloat button_W = SCREEN_WIDTH / 2; // 按钮宽
|
||||
CGFloat margin_Y = 2 * kMargin; // 第一个按钮的Y坐标
|
||||
CGFloat button_H = 35; // 按钮高
|
||||
CGFloat button_Y = 0;
|
||||
|
||||
for (int i = 0; i < hotspotBookArray.count; i++) {
|
||||
int row = i / buttonNum; // 行号
|
||||
int loc = i % buttonNum; // 列号
|
||||
CGFloat button_X = button_W * loc;
|
||||
button_Y = margin_Y + button_H * row;
|
||||
|
||||
UIButton *bottomButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
bottomButton.frame = CGRectMake(button_X, button_Y, button_W, button_H);
|
||||
bottomButton.backgroundColor = [UIColor clearColor];
|
||||
bottomButton.tag = i;
|
||||
[bottomButton addTarget:self action:@selector(hotspotBookClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:bottomButton];
|
||||
|
||||
UILabel *indexLabel = [[UILabel alloc] init];
|
||||
indexLabel.backgroundColor = kColorRGBA(203, 204, 204, 1);
|
||||
indexLabel.text = [NSString stringWithFormat:@"%d", i + 1];
|
||||
indexLabel.font = kFont8;
|
||||
indexLabel.layer.cornerRadius = 2;
|
||||
indexLabel.clipsToBounds = YES;
|
||||
indexLabel.textColor = [UIColor whiteColor];
|
||||
indexLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[bottomButton addSubview:indexLabel];
|
||||
|
||||
switch (i) {
|
||||
case 0:
|
||||
indexLabel.backgroundColor = kColorRGBA(227, 58, 52, 1);
|
||||
break;
|
||||
case 1:
|
||||
indexLabel.backgroundColor = kColorRGBA(238, 132, 55, 1);
|
||||
break;
|
||||
case 2:
|
||||
indexLabel.backgroundColor = kColorRGBA(237, 173, 72, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
[indexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kMargin);
|
||||
make.centerY.mas_equalTo(bottomButton.mas_centerY);
|
||||
make.height.width.mas_equalTo(13);
|
||||
}];
|
||||
|
||||
UILabel *hotWordLabel = [[UILabel alloc] init];
|
||||
hotWordLabel.textAlignment = NSTextAlignmentLeft;
|
||||
hotWordLabel.textColor = kBlackColor;
|
||||
hotWordLabel.font = kMainFont;
|
||||
hotWordLabel.text = [hotspotBookArray objectOrNilAtIndex:i];
|
||||
[bottomButton addSubview:hotWordLabel];
|
||||
|
||||
[hotWordLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(indexLabel.mas_right).with.offset(8);
|
||||
make.centerY.mas_equalTo(indexLabel.mas_centerY);
|
||||
make.right.mas_equalTo(bottomButton.mas_right);
|
||||
make.height.mas_equalTo(bottomButton.mas_height);
|
||||
}];
|
||||
}
|
||||
|
||||
self.hotspotSearchViewFrame = CGRectMake(0, 0, SCREEN_WIDTH, button_Y + button_H + kMargin);
|
||||
self.frame = self.hotspotSearchViewFrame;
|
||||
}
|
||||
|
||||
- (void)hotspotBookClick:(UIButton *)sender
|
||||
{
|
||||
NSString *bookName = [self.hotspotBookArray objectOrNilAtIndex:sender.tag];
|
||||
|
||||
if (self.bookClickBlock) {
|
||||
self.bookClickBlock(bookName);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setSmallFrame
|
||||
{
|
||||
self.frame = CGRectMake(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
- (void)setNormalFrame
|
||||
{
|
||||
self.frame = self.hotspotSearchViewFrame;
|
||||
}
|
||||
@end
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFSortViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFSortViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,assign) BOOL isMemberStore; // 是否是会员书库类型
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+272
@@ -0,0 +1,272 @@
|
||||
//
|
||||
// TFSortViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFSortViewController.h"
|
||||
#import "TFProductionListViewCell.h"
|
||||
#import "TFPublicAdvertisementViewCell.h"
|
||||
#import "TFSortHeaderView.h"
|
||||
#import "TFSortModel.h"
|
||||
|
||||
@interface TFSortViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) TFSortHeaderView *headerView;
|
||||
@property (nonatomic ,strong) NSMutableDictionary *parameterDic;
|
||||
@property (nonatomic ,strong) NSString *oldField;
|
||||
@property (nonatomic ,strong) NSString *oldValue;
|
||||
@property (nonatomic ,assign) BOOL needRefresh;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFSortViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
|
||||
[self netRequestWithDictionary:@{@"page_num" : [TFUtilsHelper formatStringWithInteger:self.currentPageNumber], @"page_size" : @"10"}];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
self.needRefresh = YES;
|
||||
|
||||
NSString *navTitle = TFLocalizedString(@"会员书库");
|
||||
if (!self.isMemberStore) {
|
||||
navTitle = self.navTitle ? : TFLocalizedString(@"分类");
|
||||
}
|
||||
|
||||
[self setNavigationBarTitle:navTitle];
|
||||
self.parameterDic = [NSMutableDictionary dictionary];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
[self.mainTableView setTableHeaderView:self.headerView];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber = 1;
|
||||
[weakSelf netRequestWithDictionary:@{@"page_num":[TFUtilsHelper formatStringWithInteger:weakSelf.currentPageNumber]}];
|
||||
}];
|
||||
[self.mainTableView.mj_header beginRefreshing];
|
||||
|
||||
self.mainTableView.mj_footer = [TFRefreshFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber ++;
|
||||
[weakSelf netRequestWithDictionary:@{@"page_num":[TFUtilsHelper formatStringWithInteger:weakSelf.currentPageNumber]}];
|
||||
}];
|
||||
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"暂无数据") centerY:200 tapBlock:^{}];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
if (t_model.ad_type == 0) {
|
||||
TFProductionListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFProductionListViewCell"];
|
||||
|
||||
if (!cell) {
|
||||
cell = [[TFProductionListViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFProductionListViewCell"];
|
||||
}
|
||||
cell.productionType = self.productionType;
|
||||
cell.productionModel = t_model;
|
||||
cell.hiddenEndLine = (indexPath.row == self.dataSourceArray.count - 1);
|
||||
|
||||
return cell;
|
||||
} else {
|
||||
|
||||
TFPublicAdvertisementViewCell *cell = [self.advertDict objectForKey:[TFUtilsHelper formatStringWithInteger:indexPath.row]];
|
||||
if (!cell) {
|
||||
static NSString *cellName = @"TFPublicAdvertisementViewCell";
|
||||
cell = [[TFPublicAdvertisementViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
[cell setAdModel:t_model refresh:self.needRefresh];
|
||||
cell.mainTableView = tableView;
|
||||
[self.advertDict setObject:cell forKey:[TFUtilsHelper formatStringWithInteger:indexPath.row]];
|
||||
}
|
||||
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
switch (self.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel: {
|
||||
TFNovelDetailViewController *vc = [[TFNovelDetailViewController alloc] init];
|
||||
vc.book_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicDetailViewController *vc = [[TFComicDetailViewController alloc] init];
|
||||
vc.comic_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
TFAudioDetailViewController *vc = [[TFAudioDetailViewController alloc] init];
|
||||
vc.audio_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return kHalfMargin;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kHalfMargin)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
- (TFSortHeaderView *)headerView
|
||||
{
|
||||
if (!_headerView) {
|
||||
WS(weakSelf)
|
||||
_headerView = [[TFSortHeaderView alloc] init];
|
||||
_headerView.searchBoxSelectBlock = ^(NSString * _Nonnull field, NSString * _Nonnull value) {
|
||||
if ([weakSelf.oldField isEqualToString:field] && [weakSelf.oldValue isEqualToString:value]) return ;
|
||||
weakSelf.oldField = field;
|
||||
weakSelf.oldValue = value;
|
||||
weakSelf.currentPageNumber = 1;
|
||||
[weakSelf netRequestWithDictionary:@{field:value}];
|
||||
};
|
||||
}
|
||||
return _headerView;
|
||||
}
|
||||
|
||||
- (void)netRequestWithDictionary:(NSDictionary *)parameter
|
||||
{
|
||||
NSString *url = Book_Category_List;
|
||||
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
{
|
||||
if (self.isMemberStore) {
|
||||
url = Book_Member_Store;
|
||||
} else {
|
||||
url = Book_Category_List;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
{
|
||||
if (self.isMemberStore) {
|
||||
url = Comic_Member_Store;
|
||||
} else {
|
||||
url = Comic_Category_List;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
{
|
||||
if (self.isMemberStore) {
|
||||
url = Audio_Member_Store;
|
||||
} else {
|
||||
url = Audio_Category_Index;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
[self.parameterDic addEntriesFromDictionary:parameter];
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:url parameters:self.parameterDic model:TFSortModel.class success:^(BOOL isSuccess, TFSortModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
|
||||
if (isSuccess) {
|
||||
if (weakSelf.currentPageNumber == 1) {
|
||||
[weakSelf.mainTableView showRefreshFooter];
|
||||
weakSelf.dataSourceArray = [NSMutableArray arrayWithArray:t_model.classList.list];
|
||||
weakSelf.headerView.search_box = t_model.search_box;
|
||||
} else {
|
||||
[weakSelf.dataSourceArray addObjectsFromArray:t_model.classList.list];
|
||||
}
|
||||
if (t_model.classList.total_page <= t_model.classList.current_page) {
|
||||
[weakSelf.mainTableView hideRefreshFooter];
|
||||
}
|
||||
} else {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:requestModel.msg ?: TFLocalizedString(@"请求错误")];
|
||||
}
|
||||
|
||||
weakSelf.needRefresh = YES;
|
||||
[weakSelf.mainTableView reloadData];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
weakSelf.needRefresh = NO;
|
||||
});
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[TFPromptManager showPromptWithError:error defaultText:TFLocalizedString(@"请求错误")];
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// TFSortModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TFOptionListModel, TFSearchBoxModel, TFProductionListModel;
|
||||
|
||||
@interface TFSortModel : NSObject
|
||||
|
||||
@property (nonatomic ,strong) NSArray <TFSearchBoxModel *>*search_box;
|
||||
@property (nonatomic ,strong) TFProductionListModel *classList;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface TFSearchBoxModel : NSObject
|
||||
// tab 名
|
||||
@property (nonatomic ,copy) NSString *label;
|
||||
// 字段名 请求分类作品接口时作为参数使用
|
||||
@property (nonatomic ,copy) NSString *field;
|
||||
@property (nonatomic ,strong) NSArray<TFOptionListModel *> *searchList;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface TFOptionListModel : NSObject
|
||||
// 筛选条件名
|
||||
@property (nonatomic ,copy) NSString *display;
|
||||
// 参数值
|
||||
@property (nonatomic ,copy) NSString *value;
|
||||
// 是否选中
|
||||
@property (nonatomic ,assign) BOOL checked;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// TFSortModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFSortModel.h"
|
||||
|
||||
@implementation TFSortModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{@"search_box" : [TFSearchBoxModel class]
|
||||
};
|
||||
}
|
||||
|
||||
+ (NSDictionary *)modelCustomPropertyMapper
|
||||
{
|
||||
return @{@"classList":@"list"};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation TFSearchBoxModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{@"searchList" : [TFOptionListModel class]};
|
||||
}
|
||||
|
||||
+ (NSDictionary *)modelCustomPropertyMapper
|
||||
{
|
||||
return @{
|
||||
@"searchList" :@"list"
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation TFOptionListModel
|
||||
|
||||
@end
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TFSortHeaderView.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFSortModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
typedef void(^SearchBoxSelectBlock)(NSString *field, NSString *value);
|
||||
@interface TFSortHeaderView : UIView
|
||||
|
||||
@property (nonatomic ,strong) NSArray <TFSearchBoxModel *>*search_box;
|
||||
|
||||
@property (nonatomic ,copy) SearchBoxSelectBlock searchBoxSelectBlock;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// TFSortHeaderView.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFSortHeaderView.h"
|
||||
#import "TFFiltrateView.h"
|
||||
|
||||
@interface TFSortHeaderView ()
|
||||
|
||||
@property (nonatomic ,strong) TFFiltrateView *filtrateView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFSortHeaderView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self createSubViews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubViews
|
||||
{
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, 0);
|
||||
|
||||
WS(weakSelf)
|
||||
self.filtrateView = [[TFFiltrateView alloc] init];
|
||||
|
||||
self.filtrateView.selectBlock = ^(NSString * _Nonnull keyword, NSString * _Nonnull value) {
|
||||
if (weakSelf.searchBoxSelectBlock) {
|
||||
weakSelf.searchBoxSelectBlock(keyword, value);
|
||||
}
|
||||
};
|
||||
|
||||
[self addSubview:self.filtrateView];
|
||||
[self.filtrateView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setSearch_box:(NSArray<TFSearchBoxModel *> *)search_box
|
||||
{
|
||||
_search_box = search_box;
|
||||
|
||||
self.filtrateView.search_box = search_box;
|
||||
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, 40 * search_box.count);
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user