小说绘上架版本

This commit is contained in:
xtfei2011
2021-02-07 11:24:08 +08:00
commit ee5c1c8b12
1762 changed files with 115892 additions and 0 deletions
@@ -0,0 +1,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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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