小说绘上架版本
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFDiscoverComicViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFDiscoverComicViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
//
|
||||
// TFDiscoverComicViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFDiscoverComicViewController.h"
|
||||
#import "TFDiscoverComicViewCell.h"
|
||||
#import "TFDiscoverComicAdvertisementCell.h"
|
||||
#import "TFDiscoverHeaderView.h"
|
||||
#import "TFDiscoverComicModel.h"
|
||||
#import "TFBannerActionManager.h"
|
||||
|
||||
@interface TFDiscoverComicViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,strong) TFDiscoverComicModel *comicDiscoverModel;
|
||||
@property (nonatomic ,strong) TFDiscoverHeaderView *headerView;
|
||||
@property (nonatomic ,assign) BOOL needRefresh;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFDiscoverComicViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
self.needRefresh = YES;
|
||||
[self hiddenNavigationBar:YES];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
[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(self.view.mas_height).with.offset(-PUB_TABBAR_HEIGHT - PUB_NAVBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.headerView = [[TFDiscoverHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, CGFLOAT_MIN)];
|
||||
self.headerView.bannerrImageClickBlock = ^(TFBannerModel * _Nonnull bannerModel) {
|
||||
if ([TFBannerActionManager getBannerActionWithBannerModel:bannerModel productionType:TFProductionTypeComic]) {
|
||||
[weakSelf.navigationController pushViewController:[TFBannerActionManager getBannerActionWithBannerModel:bannerModel productionType:TFProductionTypeComic] animated:YES];
|
||||
}
|
||||
};
|
||||
[self.mainTableView setTableHeaderView:self.headerView];
|
||||
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
[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.comicDiscoverModel.item_list.list.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *productionModel = [self.comicDiscoverModel.item_list.list objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
if (productionModel.ad_type == 0) {
|
||||
TFDiscoverComicViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFDiscoverComicViewCell"];
|
||||
if (!cell) {
|
||||
cell = [[TFDiscoverComicViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFDiscoverComicViewCell"];
|
||||
}
|
||||
cell.discoverComic = [self.comicDiscoverModel.item_list.list objectOrNilAtIndex:indexPath.row];
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
|
||||
return cell;
|
||||
} else {
|
||||
|
||||
static NSString *cellName = @"TFDiscoverComicAdvertisementCell";
|
||||
TFDiscoverComicAdvertisementCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[TFDiscoverComicAdvertisementCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
[cell setAdModel:productionModel refresh:self.needRefresh];
|
||||
cell.mainTableView = tableView;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
|
||||
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, 10)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *productionModel = [self.comicDiscoverModel.item_list.list objectOrNilAtIndex:indexPath.row];
|
||||
|
||||
TFComicDetailViewController *comicDetail = [[TFComicDetailViewController alloc] init];
|
||||
comicDetail.comic_id = productionModel.production_id;
|
||||
[self.navigationController pushViewController:comicDetail animated:YES];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
WS(weakSelf)
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"channel_id"] = @(TFSystemInfoManager.sexChannel);
|
||||
params[@"page_num"] = @(self.currentPageNumber);
|
||||
|
||||
[TFNetworkTools POSTQuick:Comic_Discover parameters:params model:TFDiscoverComicModel.class success:^(BOOL isSuccess, TFDiscoverComicModel * _Nullable discoverComicModel, BOOL isCache, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
|
||||
if (isSuccess) {
|
||||
weakSelf.headerView.banner = discoverComicModel.banner;
|
||||
weakSelf.comicDiscoverModel = discoverComicModel;
|
||||
|
||||
if (weakSelf.comicDiscoverModel.banner.count > 0) {
|
||||
weakSelf.headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH / 4);
|
||||
} else {
|
||||
weakSelf.headerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, CGFLOAT_MIN);
|
||||
}
|
||||
if (discoverComicModel.item_list.current_page >= discoverComicModel.item_list.total_page) {
|
||||
[weakSelf.mainTableView hideRefreshFooter];
|
||||
}
|
||||
[weakSelf.mainTableView setTableHeaderView:weakSelf.headerView];
|
||||
}
|
||||
|
||||
weakSelf.needRefresh = YES;
|
||||
[weakSelf.mainTableView reloadData];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
weakSelf.needRefresh = NO;
|
||||
});
|
||||
} failure:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFDiscoverComicModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class TFProductionModel, TFTagModel, TFBannerModel;
|
||||
|
||||
@interface TFDiscoverComicModel : NSObject
|
||||
|
||||
@property (nonatomic ,strong) NSArray <TFBannerModel *>*banner;
|
||||
@property (nonatomic ,strong) TFProductionListModel *item_list;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFDiscoverComicModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFDiscoverComicModel.h"
|
||||
|
||||
@implementation TFDiscoverComicModel
|
||||
|
||||
+ (NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass
|
||||
{
|
||||
return @{@"banner" : [TFBannerModel class]};
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// TFDiscoverComicViewCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFDiscoverComicViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFProductionModel *discoverComic;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,111 @@
|
||||
//
|
||||
// TFDiscoverComicViewCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/16.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFDiscoverComicViewCell.h"
|
||||
#import "TFTagboardView.h"
|
||||
|
||||
@interface TFDiscoverComicViewCell ()
|
||||
|
||||
@property (nonatomic ,strong) UIImageView *coverView;
|
||||
@property (nonatomic ,strong) UILabel *titleLabel;
|
||||
@property (nonatomic ,strong) UILabel *flagLabel;
|
||||
@property (nonatomic ,strong) TFTagboardView *tagboardView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFDiscoverComicViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
self.coverView = [[UIImageView alloc] initWithCornerRadiusAdvance:8 rectCornerType:UIRectCornerAllCorners];
|
||||
self.coverView.frame = CGRectMake(kHalfMargin, kHalfMargin, SCREEN_WIDTH - kMargin, kGeometricHeight(SCREEN_WIDTH - kMargin, 7, 4));
|
||||
self.coverView.image = HoldImage;
|
||||
self.coverView.layer.shadowColor = [UIColor blackColor].CGColor;
|
||||
self.coverView.layer.shadowOffset = CGSizeMake(0, 0);
|
||||
self.coverView.layer.shadowOpacity = 0.1f;
|
||||
self.coverView.layer.shadowRadius = 2.0f;
|
||||
self.coverView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
[self.coverView.layer setShadowPath:[[UIBezierPath bezierPathWithRect:self.coverView.bounds] CGPath]];
|
||||
[self.contentView addSubview:self.coverView];
|
||||
|
||||
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.textColor = kBlackColor;
|
||||
self.titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.titleLabel.font = kMainFont;
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(kHalfMargin);
|
||||
make.top.mas_equalTo(self.coverView.height + kHalfMargin + kHalfMargin);
|
||||
make.height.mas_equalTo(20);
|
||||
make.width.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
|
||||
// 标签
|
||||
self.tagboardView = [[TFTagboardView alloc] init];
|
||||
self.tagboardView.font = kFont10;
|
||||
self.tagboardView.cornerRadius = 4;
|
||||
[self.contentView addSubview:self.tagboardView];
|
||||
|
||||
[self.tagboardView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.titleLabel.mas_right).with.offset(kHalfMargin);
|
||||
make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(-kHalfMargin);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
|
||||
self.flagLabel = [[UILabel alloc] init];
|
||||
self.flagLabel.textColor = kGrayTextColor;
|
||||
self.flagLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.flagLabel.font = kFont11;
|
||||
[self.contentView addSubview:self.flagLabel];
|
||||
|
||||
[self.flagLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.titleLabel.mas_left);
|
||||
make.top.mas_equalTo(self.titleLabel.mas_bottom).with.offset(kQuarterMargin);
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(-kHalfMargin);
|
||||
make.height.mas_equalTo(15);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(-kQuarterMargin).priorityLow();
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setDiscoverComic:(TFProductionModel *)discoverComic
|
||||
{
|
||||
_discoverComic = discoverComic;
|
||||
|
||||
[self.coverView setImageWithURL:[NSURL URLWithString:discoverComic.cover ? : @""] placeholder:HoldImage options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
|
||||
|
||||
self.titleLabel.text = discoverComic.name ? : @"";
|
||||
[self.titleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.titleLabel]);
|
||||
}];
|
||||
|
||||
if (discoverComic.flag.length > 0) {
|
||||
self.flagLabel.text = discoverComic.flag ? : @"";
|
||||
[self.flagLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(15);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(-kQuarterMargin).priorityLow();
|
||||
}];
|
||||
} else {
|
||||
[self.flagLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(CGFLOAT_MIN);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).priorityLow();
|
||||
}];
|
||||
}
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
self.tagboardView.tagboardArray = discoverComic.tag;
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user