小说绘上架版本
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFPopularityCommViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFPopularityCommViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,copy) NSString *channel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
//
|
||||
// TFPopularityCommViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFPopularityCommViewController.h"
|
||||
#import "TFPopularityDetailViewController.h"
|
||||
#import "TFPopularityViewCell.h"
|
||||
#import "TFPopularityModel.h"
|
||||
|
||||
@interface TFPopularityCommViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFPopularityCommViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self hiddenNavigationBar:YES];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(self.view.mas_top);
|
||||
make.bottom.mas_equalTo(self.view.mas_bottom).with.offset(- PUB_NAVBAR_HEIGHT - self.pageViewHeight);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
}];
|
||||
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"暂无数据") buttonTitle:@"" tapBlock:^{
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
[self.mainTableView.mj_header beginRefreshing];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFPopularityViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WXBookRankListTableViewCell"];
|
||||
|
||||
if (!cell) {
|
||||
cell = [[TFPopularityViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"WXBookRankListTableViewCell"];
|
||||
}
|
||||
if (self.dataSourceArray.count) {
|
||||
cell.rankListModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
}
|
||||
cell.productionType = self.productionType;
|
||||
cell.hiddenEndLine = (indexPath.row == self.dataSourceArray.count - 1);
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, CGFLOAT_MIN)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (self.dataSourceArray && self.dataSourceArray.count > 0) {
|
||||
TFPopularityModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
TFPopularityDetailViewController *vc = [[TFPopularityDetailViewController alloc] init];
|
||||
vc.channel = self.channel;
|
||||
vc.productionType = self.productionType;
|
||||
vc.rank_type = t_model.rank_type;
|
||||
vc.navTitle = t_model.list_name?:@"";
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Rank_List;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Rank_List;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Rank_List;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
WS(weakSelf)
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"channel_id"] = self.channel;
|
||||
|
||||
[TFNetworkTools POST:url parameters:params model:nil success:^(BOOL isSuccess, NSDictionary *_Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
|
||||
if (isSuccess) {
|
||||
NSArray *t_arr = t_model[@"data"];
|
||||
[weakSelf.dataSourceArray removeAllObjects];
|
||||
for (NSDictionary *t_dic in t_arr) {
|
||||
TFPopularityModel *t_model = [TFPopularityModel modelWithDictionary:t_dic];
|
||||
[weakSelf.dataSourceArray addObject:t_model];
|
||||
}
|
||||
}
|
||||
|
||||
[weakSelf.mainTableView reloadData];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
[weakSelf.mainTableView reloadData];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFPopularityDetailViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFPopularityDetailViewController : TFBasicViewController
|
||||
|
||||
@property (nonatomic ,copy) NSString *channel;
|
||||
@property (nonatomic ,copy) NSString *rank_type;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+225
@@ -0,0 +1,225 @@
|
||||
//
|
||||
// TFPopularityDetailViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFPopularityDetailViewController.h"
|
||||
#import "TFProductionListViewCell.h"
|
||||
#import "TFPublicAdvertisementViewCell.h"
|
||||
|
||||
@interface TFPopularityDetailViewController ()<UITableViewDelegate, UITableViewDataSource>
|
||||
|
||||
@property (nonatomic ,assign) BOOL needRefresh;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFPopularityDetailViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
self.needRefresh = YES;
|
||||
[self setNavigationBarTitle:self.navTitle];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.mainTableView.delegate = self;
|
||||
self.mainTableView.dataSource = self;
|
||||
self.mainTableView.contentInset = UIEdgeInsetsMake(0, 0, PUB_TABBAR_OFFSET, 0);
|
||||
[self.view addSubview:self.mainTableView];
|
||||
|
||||
[self.mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
|
||||
make.width.mas_equalTo(self.view.mas_width);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"暂无数据") tapBlock:^{
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
self.mainTableView.mj_header = [TFRefreshHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber = 1;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
[self.mainTableView.mj_header beginRefreshing];
|
||||
|
||||
self.mainTableView.mj_footer = [TFRefreshFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.currentPageNumber ++;
|
||||
[weakSelf netRequest];
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.dataSourceArray.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
if (t_model.ad_type == 0) {
|
||||
TFProductionListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TFProductionListViewCell"];
|
||||
if (!cell) {
|
||||
cell = [[TFProductionListViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TFProductionListViewCell"];
|
||||
}
|
||||
cell.isRankList = YES;
|
||||
cell.productionType = self.productionType;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
cell.productionModel = t_model;
|
||||
cell.hiddenEndLine = (indexPath.row == self.dataSourceArray.count - 1);
|
||||
|
||||
return cell;
|
||||
} else {
|
||||
|
||||
TFPublicAdvertisementViewCell *cell = [self.advertDict objectForKey:[TFUtilsHelper formatStringWithInteger:indexPath.row]];
|
||||
if (!cell) {
|
||||
static NSString *cellName = @"TFPublicAdvertisementViewCell";
|
||||
cell = [[TFPublicAdvertisementViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
[cell setAdModel:t_model refresh:self.needRefresh];
|
||||
cell.mainTableView = tableView;
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
[self.advertDict setObject:cell forKey:[TFUtilsHelper formatStringWithInteger:indexPath.row]];
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
TFProductionModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
|
||||
switch (self.productionType) {
|
||||
#if TF_Enable_Book
|
||||
case TFProductionTypeNovel: {
|
||||
TFNovelDetailViewController *vc = [[TFNovelDetailViewController alloc] init];
|
||||
vc.book_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Comic
|
||||
case TFProductionTypeComic: {
|
||||
TFComicDetailViewController *comicDetail = [[TFComicDetailViewController alloc] init];
|
||||
comicDetail.comic_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:comicDetail animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TF_Enable_Audio
|
||||
case TFProductionTypeAudio: {
|
||||
TFAudioDetailViewController *vc = [[TFAudioDetailViewController alloc] init];
|
||||
vc.audio_id = t_model.production_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
NSString *url = @"";
|
||||
switch (self.productionType) {
|
||||
case TFProductionTypeNovel:
|
||||
url = Book_Rank_Detail_List;
|
||||
break;
|
||||
case TFProductionTypeComic:
|
||||
url = Comic_Rank_Detail_List;
|
||||
break;
|
||||
case TFProductionTypeAudio:
|
||||
url = Audio_Rank_Detail_List;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
WS(weakSelf)
|
||||
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
params[@"channel_id"] = self.channel;
|
||||
params[@"rank_type"] = self.rank_type;
|
||||
params[@"page_num"] = [TFUtilsHelper formatStringWithInteger:weakSelf.currentPageNumber];
|
||||
|
||||
[TFNetworkTools POST:url parameters:params model:TFProductionListModel.class success:^(BOOL isSuccess, TFProductionListModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
|
||||
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
|
||||
if (isSuccess) {
|
||||
if (weakSelf.currentPageNumber == 1) {
|
||||
weakSelf.dataSourceArray = [NSMutableArray arrayWithArray:t_model.list];
|
||||
} else {
|
||||
[weakSelf.dataSourceArray addObjectsFromArray:t_model.list];
|
||||
}
|
||||
|
||||
weakSelf.needRefresh = YES;
|
||||
[weakSelf.mainTableView reloadData];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
weakSelf.needRefresh = NO;
|
||||
});
|
||||
if (t_model.total_page <= t_model.current_page) {
|
||||
[weakSelf.mainTableView hideRefreshFooter];
|
||||
}
|
||||
}
|
||||
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
if (weakSelf.dataSourceArray.count == 0) {
|
||||
[weakSelf.mainTableView xtfei_showEmptyView];
|
||||
} else {
|
||||
[weakSelf.mainTableView xtfei_hideEmptyView];
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[weakSelf.mainTableView endRefreshing];
|
||||
[weakSelf.mainTableView xtfei_endLoading];
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// TFPopularityViewController.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFBasicViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFPopularityViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// TFPopularityViewController.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFPopularityViewController.h"
|
||||
#import "TFPopularityCommViewController.h"
|
||||
|
||||
@interface TFPopularityViewController ()<
|
||||
#if TF_Enable_PageControl
|
||||
SGPageTitleViewDelegate,
|
||||
#endif
|
||||
SGPageContentCollectionViewDelegate>
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
|
||||
#endif
|
||||
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentCollectionView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFPopularityViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setNavigationBarTitle:self.navTitle?:TFLocalizedString(@"榜单")];
|
||||
[self hiddenSeparator];
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
TFPopularityCommViewController *boyVC = [[TFPopularityCommViewController alloc] init];
|
||||
boyVC.productionType = self.productionType;
|
||||
boyVC.channel = @"1";
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
TFPopularityCommViewController *girlVC = [[TFPopularityCommViewController alloc] init];
|
||||
girlVC.productionType = self.productionType;
|
||||
girlVC.channel = @"2";
|
||||
#endif
|
||||
|
||||
NSArray *childArr = @[boyVC
|
||||
#if TF_Enable_PageControl
|
||||
, girlVC
|
||||
#endif
|
||||
];
|
||||
|
||||
|
||||
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:
|
||||
#if TF_Enable_PageControl
|
||||
CGRectMake(0, PUB_NAVBAR_HEIGHT + 44, SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
#else
|
||||
CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT)
|
||||
#endif
|
||||
parentVC:self childVCs:childArr];
|
||||
_pageContentCollectionView.delegatePageContentCollectionView = self;
|
||||
[self.view addSubview:self.pageContentCollectionView];
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
NSArray *titleArr = @[TFLocalizedString(@"男生"), TFLocalizedString(@"女生")];
|
||||
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, 44) delegate:self titleNames:titleArr configure:self.pageConfigure];
|
||||
self.pageTitleView.backgroundColor = kWhiteColor;
|
||||
[self.view addSubview:_pageTitleView];
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TF_Enable_PageControl
|
||||
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex
|
||||
{
|
||||
[self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
|
||||
}
|
||||
|
||||
- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex
|
||||
{
|
||||
[self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// TFPopularityModel.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFPopularityModel : NSObject
|
||||
// 排行榜类型
|
||||
@property (nonatomic ,copy) NSString *rank_type;
|
||||
// 榜单名
|
||||
@property (nonatomic ,copy) NSString *list_name;
|
||||
// 榜单简介
|
||||
@property (nonatomic ,copy) NSString *rankDescription;
|
||||
// 榜单图标
|
||||
@property (nonatomic ,strong) NSArray <NSString *>*icon;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// TFPopularityModel.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFPopularityModel.h"
|
||||
|
||||
@implementation TFPopularityModel
|
||||
|
||||
+ (NSDictionary *)modelCustomPropertyMapper
|
||||
{
|
||||
return @{
|
||||
@"rankDescription" :@[@"description", @"desc"],
|
||||
@"list_name" :@[@"list_name", @"title"]
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// TFPopularityViewCell.h
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "TFPopularityModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TFPopularityViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFPopularityModel *rankListModel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
//
|
||||
// TFPopularityViewCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/17.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFPopularityViewCell.h"
|
||||
|
||||
@interface TFPopularityViewCell ()
|
||||
|
||||
@property (nonatomic ,strong) TFProductionCoverView *iconTop;
|
||||
@property (nonatomic ,strong) TFProductionCoverView *iconCenter;
|
||||
@property (nonatomic ,strong) TFProductionCoverView *iconBottom;
|
||||
@property (nonatomic ,strong) UILabel *rankLabel;
|
||||
@property (nonatomic ,strong) UILabel *descriptionLabel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFPopularityViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
self.iconBottom = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
|
||||
[self.contentView addSubview:self.iconBottom];
|
||||
|
||||
self.iconCenter = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
|
||||
[self.contentView addSubview:self.iconCenter];
|
||||
|
||||
self.iconTop = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
|
||||
[self.contentView addSubview:self.iconTop];
|
||||
|
||||
[self.iconTop mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kHalfMargin);
|
||||
make.width.mas_equalTo(60);
|
||||
make.height.mas_equalTo(kGeometricHeight(60, 3, 4));
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin).priorityLow();
|
||||
}];
|
||||
|
||||
[self.iconCenter mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.iconTop.mas_bottom);
|
||||
make.right.mas_equalTo(self.iconTop.mas_right).with.offset(kMargin);
|
||||
make.width.mas_equalTo(50);
|
||||
make.height.mas_equalTo(kGeometricHeight(50, 3, 4));
|
||||
}];
|
||||
|
||||
[self.iconBottom mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.iconCenter.mas_bottom);
|
||||
make.right.mas_equalTo(self.iconCenter.mas_right).with.offset(kMargin);
|
||||
make.width.mas_equalTo(40);
|
||||
make.height.mas_equalTo(kGeometricHeight(40, 3, 4));
|
||||
}];
|
||||
|
||||
self.rankLabel = [[UILabel alloc] init];
|
||||
self.rankLabel.textColor = kBlackColor;
|
||||
self.rankLabel.backgroundColor = kGrayViewColor;
|
||||
self.rankLabel.font = kMainFont;
|
||||
[self.contentView addSubview:self.rankLabel];
|
||||
|
||||
[self.rankLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.iconTop.mas_centerY).with.offset(- 2);
|
||||
make.left.mas_equalTo(self.iconBottom.mas_right).with.offset(kMargin);
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
|
||||
make.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
self.descriptionLabel = [[UILabel alloc] init];
|
||||
self.descriptionLabel.textColor = kGrayTextColor;
|
||||
self.descriptionLabel.backgroundColor = kGrayViewColor;
|
||||
self.descriptionLabel.font = kFont12;
|
||||
[self.contentView addSubview:self.descriptionLabel];
|
||||
|
||||
[self.descriptionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.iconTop.mas_centerY).with.offset(2);
|
||||
make.left.mas_equalTo(self.rankLabel.mas_left);
|
||||
make.width.mas_equalTo(self.rankLabel.mas_width);
|
||||
make.height.mas_equalTo(self.rankLabel.mas_height);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setRankListModel:(TFPopularityModel *)rankListModel
|
||||
{
|
||||
_rankListModel = rankListModel;
|
||||
|
||||
for (int i = 0; i < rankListModel.icon.count; i++) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
self.iconTop.coverImageUrl = [rankListModel.icon objectOrNilAtIndex:0];
|
||||
break;
|
||||
case 1:
|
||||
self.iconCenter.coverImageUrl = [rankListModel.icon objectOrNilAtIndex:1];
|
||||
if ([rankListModel.icon objectAtIndex:1].length <= 0) {
|
||||
self.iconCenter.hidden = YES;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
self.iconBottom.coverImageUrl = [rankListModel.icon objectOrNilAtIndex:2];
|
||||
if ([rankListModel.icon objectAtIndex:2].length <= 0) {
|
||||
self.iconBottom.hidden = YES;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
self.rankLabel.backgroundColor = [UIColor whiteColor];
|
||||
self.rankLabel.text = rankListModel.list_name?:@"";
|
||||
|
||||
self.descriptionLabel.backgroundColor = [UIColor whiteColor];
|
||||
self.descriptionLabel.text = rankListModel.rankDescription?:@"";
|
||||
}
|
||||
|
||||
- (void)setProductionType:(TFProductionType)productionType
|
||||
{
|
||||
[super setProductionType:productionType];
|
||||
|
||||
self.iconTop.productionType = productionType;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user