小说绘上架版本

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 @@
//
// 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