小说绘上架版本

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,18 @@
//
// TFAppraiseCommViewController.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/21.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBasicViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFAppraiseCommViewController : TFBasicViewController
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,188 @@
//
// TFAppraiseCommViewController.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/21.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFAppraiseCommViewController.h"
#import "TFAppraiseDetailViewController.h"
#import "TFAppraiseCommViewCell.h"
@interface TFAppraiseCommViewController ()<UITableViewDelegate, UITableViewDataSource>
@end
@implementation TFAppraiseCommViewController
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self setStatusBarDefaultStyle];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self initialize];
[self createSubviews];
[self netRequest];
}
- (void)initialize
{
[self hiddenNavigationBar:YES];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(netRequest) name:Notification_Login_Success object:nil];
}
- (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.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - self.pageViewHeight);
make.width.mas_equalTo(self.view.mas_width);
}];
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];
}];
[self createEmptyView];
}
- (void)createEmptyView
{
WS(weakSelf)
if (!TFUserInfoManager.isLogin) {
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"登录后可查看评论内容") buttonTitle:TFLocalizedString(@"立即登录") tapBlock:^{
[TFLoginOptionsViewController presentLoginView:^(TFUserInfoManager * _Nonnull userInfo) {
weakSelf.emptyView = nil;
[weakSelf createEmptyView];
}];
}];
} else {
[self setEmptyOnView:self.mainTableView title:TFLocalizedString(@"暂无评论内容") buttonTitle:nil tapBlock:^{
}];
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.dataSourceArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellName = @"TFAppraiseCommViewCell";
TFAppraiseCommViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
if (!cell) {
cell = [[TFAppraiseCommViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
}
cell.commentsDetailModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
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 == 0 ? 10 : PUB_TABBAR_OFFSET)];
view.backgroundColor = [UIColor clearColor];
return view;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
TFCommentsListModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
TFAppraiseDetailViewController *vc = [[TFAppraiseDetailViewController alloc] init];
vc.productionType = self.productionType;
vc.comment_id = t_model.comment_id;
[self.navigationController pushViewController:vc animated:YES];
}
- (void)netRequest
{
if ([TFNetworkManager networkingStatus] == NO) {
[self.mainTableView endRefreshing];
[self.mainTableView xtfei_showEmptyView];
return;
}
NSString *url = @"";
switch (self.productionType) {
case TFProductionTypeNovel:
url = Book_Comments_List;
break;
case TFProductionTypeComic:
url = Comic_Comments_List;
break;
case TFProductionTypeAudio:
url = Audio_Comments_List;
break;
default:
break;
}
WS(weakSelf)
[TFNetworkTools POST:url parameters:@{@"page_num":[TFUtilsHelper formatStringWithInteger:self.currentPageNumber]} model:TFCommentsModel.class success:^(BOOL isSuccess, TFCommentsModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull 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.mainTableView reloadData];
[weakSelf.mainTableView xtfei_endLoading];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[weakSelf.mainTableView endRefreshing];
[weakSelf.mainTableView xtfei_endLoading];
}];
}
@end
@@ -0,0 +1,20 @@
//
// TFAppraiseDetailViewController.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/21.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBasicViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFAppraiseDetailViewController : TFBasicViewController
@property (nonatomic ,assign) NSInteger comment_id;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,251 @@
//
// TFAppraiseDetailViewController.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/21.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFAppraiseDetailViewController.h"
#import "TFAppraiseDetailHeaderView.h"
#import "TFCommentsViewCell.h"
#import "TFAppraiseDetailModel.h"
@interface TFAppraiseDetailViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic ,strong) TFAppraiseDetailModel *appraiseDetailModel;
@property (nonatomic ,strong) UILabel *footerView;
@end
@implementation TFAppraiseDetailViewController
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self setStatusBarDefaultStyle];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self initialize];
[self createSubviews];
[self netRequest];
}
- (void)initialize
{
[self hiddenSeparator];
[self setNavigationBarTitle:TFLocalizedString(@"评论详情")];
}
- (void)createSubviews
{
self.mainTableViewGroup.delegate = self;
self.mainTableViewGroup.dataSource = self;
[self.view addSubview:self.mainTableViewGroup];
[self.mainTableViewGroup setTableFooterView:self.footerView];
[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(self.view.mas_height).with.offset(- PUB_NAVBAR_HEIGHT - PUB_TABBAR_OFFSET);
}];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0) {
return 1;
}
return self.dataSourceArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
WS(weakSelf)
static NSString *cellName = @"TFAppraiseDetailHeaderView";
TFAppraiseDetailHeaderView *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
if (!cell) {
cell = [[TFAppraiseDetailHeaderView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
}
cell.commentProductionClickBlock = ^{
switch (weakSelf.productionType) {
#if TF_Enable_Book
case TFProductionTypeNovel: {
TFNovelDetailViewController *vc = [[TFNovelDetailViewController alloc] init];
vc.book_id = weakSelf.appraiseDetailModel.production_id;
[weakSelf.navigationController pushViewController:vc animated:YES];
}
break;
#endif
#if TF_Enable_Comic
case TFProductionTypeComic: {
TFComicDetailViewController *vc = [[TFComicDetailViewController alloc] init];
vc.comic_id = weakSelf.appraiseDetailModel.production_id;
[weakSelf.navigationController pushViewController:vc animated:YES];
}
break;
#endif
#if TF_Enable_Audio
case TFProductionTypeAudio: {
TFAudioDetailViewController *vc = [[TFAudioDetailViewController alloc] init];
vc.audio_id = weakSelf.appraiseDetailModel.production_id;
[weakSelf.navigationController pushViewController:vc animated:YES];
}
break;
#endif
default:
break;
}
};
cell.appraiseDetailModel = self.appraiseDetailModel;
cell.productionType = self.productionType;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
} else {
static NSString *cellName = @"TFCommentsViewCell";
TFCommentsViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
if (!cell) {
cell = [[TFCommentsViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
}
cell.commentModel = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.hiddenEndLine = indexPath.row == self.dataSourceArray.count - 1;
return cell;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
TFCommentsListModel *t_model = [self.dataSourceArray objectOrNilAtIndex:indexPath.row];
self.comment_id = t_model.comment_id;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 0) {
return CGFLOAT_MIN;
}
return 44;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 44)];
if (section == 1) {
UILabel *headerTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(kMargin, 0, SCREEN_WIDTH - kMargin, 44)];
headerTitleLabel.textColor = kBlackColor;
headerTitleLabel.text = [NSString stringWithFormat:@"%@ (%@)", TFLocalizedString(@"全部回复"), [TFUtilsHelper formatStringWithInteger:self.appraiseDetailModel.total_count]];
headerTitleLabel.font = kBoldMainFont;
headerTitleLabel.backgroundColor = [UIColor clearColor];
[view addSubview:headerTitleLabel];
}
return view;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
if (section == 0) {
return 10;
}
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)];
if (section == 0) {
view.backgroundColor = kGrayViewColor;
} else {
view.backgroundColor = [UIColor clearColor];
}
return view;
}
- (UILabel *)footerView
{
if (!_footerView) {
_footerView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, CGFLOAT_MIN)];
_footerView.textColor = kGrayTextColor;
_footerView.textAlignment = NSTextAlignmentCenter;
_footerView.font = kFont10;
}
return _footerView;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];
}
- (void)netRequest
{
WS(weakSelf)
NSDictionary *parameters = [NSDictionary dictionary];
switch (self.productionType) {
case TFProductionTypeNovel:
parameters = @{@"page_num":[TFUtilsHelper formatStringWithInteger:self.currentPageNumber], @"comment_id":[TFUtilsHelper formatStringWithInteger:self.comment_id], @"type":@"1"};
break;
case TFProductionTypeComic:
parameters = @{@"page_num":[TFUtilsHelper formatStringWithInteger:self.currentPageNumber], @"comment_id":[TFUtilsHelper formatStringWithInteger:self.comment_id], @"type":@"2"};
break;
case TFProductionTypeAudio:
parameters = @{@"page_num":[TFUtilsHelper formatStringWithInteger:self.currentPageNumber], @"comment_id":[TFUtilsHelper formatStringWithInteger:self.comment_id], @"type":@"3"};
break;
default:
break;
}
[TFNetworkTools POST:Comment_Detail parameters:parameters model:TFAppraiseDetailModel.class success:^(BOOL isSuccess, TFAppraiseDetailModel * _Nullable t_model, TFNetworkRequestModel * _Nonnull requestModel) {
if (isSuccess) {
if (weakSelf.currentPageNumber == 1) {
weakSelf.appraiseDetailModel = t_model;
[weakSelf.mainTableViewGroup 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.mainTableViewGroup hideRefreshFooter];
weakSelf.footerView.text = TFLocalizedString(@"已显示全部");
weakSelf.footerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 30);
} else {
weakSelf.footerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, CGFLOAT_MIN);
}
if (t_model.total_count == 0) {
weakSelf.footerView.text = TFLocalizedString(@"暂无评论回复");
weakSelf.footerView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 30);
}
[weakSelf.mainTableViewGroup setTableFooterView:weakSelf.footerView];
}
[weakSelf.mainTableViewGroup endRefreshing];
[weakSelf.mainTableViewGroup reloadData];
[weakSelf.mainTableViewGroup xtfei_endLoading];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[weakSelf.mainTableViewGroup endRefreshing];
[weakSelf.mainTableViewGroup xtfei_endLoading];
}];
}
@end
@@ -0,0 +1,18 @@
//
// TFAppraiseViewController.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/21.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBasicViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFAppraiseViewController : TFBasicViewController
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,115 @@
//
// TFAppraiseViewController.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/21.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFAppraiseViewController.h"
#import "TFAppraiseCommViewController.h"
@interface TFAppraiseViewController ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
@property (nonatomic ,strong) SGPageTitleView *pageTitleView;
@property (nonatomic ,strong) SGPageContentCollectionView *pageContentCollectionView;
@end
@implementation TFAppraiseViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self initialize];
[self createSubViews];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self setStatusBarDefaultStyle];
[[NSNotificationCenter defaultCenter] postNotificationName:Notification_Hidden_Tabbar object:@"1"];
}
- (void)initialize
{
[self setNavigationBarTitle:TFLocalizedString(@"我的评论")];
[self hiddenSeparator];
}
- (void)createSubViews
{
#if TF_Enable_Book
TFAppraiseCommViewController *bookVC = [[TFAppraiseCommViewController alloc] init];
bookVC.productionType = TFProductionTypeNovel;
[self addChildViewController:bookVC];
#endif
#if TF_Enable_Comic
TFAppraiseCommViewController *comicVC = [[TFAppraiseCommViewController alloc] init];
comicVC.productionType = TFProductionTypeComic;
[self addChildViewController:comicVC];
#endif
#if TF_Enable_Audio
TFAppraiseCommViewController *audioVC = [[TFAppraiseCommViewController alloc] init];
audioVC.productionType = TFProductionTypeAudio;
[self addChildViewController:audioVC];
#endif
NSMutableArray *titleArr = [NSMutableArray array];
NSMutableArray *childArr = [NSMutableArray array];
for (NSNumber *siteNumber in [TFUtilsHelper getSiteState]) {
#if TF_Enable_Book
if ([siteNumber integerValue] == 1) {
[titleArr addObject:TFLocalizedString(@"小说")];
[childArr addObject:bookVC];
}
#endif
#if TF_Enable_Comic
if ([siteNumber integerValue] == 2) {
[titleArr addObject:TFLocalizedString(@"漫画")];
[childArr addObject:comicVC];
}
#endif
#if TF_Enable_Audio
if ([siteNumber integerValue] == 3) {
[titleArr addObject:TFLocalizedString(@"听书")];
[childArr addObject:audioVC];
}
#endif
}
if ([TFUtilsHelper getSiteState].count <= 1) {
[titleArr removeAllObjects];
[titleArr addObject:TFLocalizedString(@"评论")];
}
self.pageViewHeight = titleArr.count > 1?self.pageViewHeight:0;
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT + self.pageViewHeight, SCREEN_WIDTH, SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - self.pageViewHeight) parentVC:self childVCs:childArr];
self.pageContentCollectionView.delegatePageContentCollectionView = self;
[self.view addSubview:self.pageContentCollectionView];
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, PUB_NAVBAR_HEIGHT, SCREEN_WIDTH, self.pageViewHeight) delegate:self titleNames:titleArr configure:self.pageConfigure];
self.pageTitleView.backgroundColor = kWhiteColor;
[self.view addSubview:self.pageTitleView];
}
- (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];
}
@end
@@ -0,0 +1,32 @@
//
// TFAppraiseDetailModel.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/21.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface TFAppraiseDetailModel : TFCommentsModel
@property (nonatomic ,assign) NSInteger production_id; // 作品id
@property (nonatomic ,assign) NSInteger chapter_id;
@property (nonatomic ,copy) NSString *name; // 作品名
@property (nonatomic ,assign) NSInteger comment_id;
@property (nonatomic ,assign) NSInteger uid;
@property (nonatomic ,copy) NSString *nickname;
@property (nonatomic ,copy) NSString *avatar;
@property (nonatomic ,copy) NSString *time;
@property (nonatomic ,assign) NSInteger like_num;
@property (nonatomic ,copy) NSString *content;
@property (nonatomic ,assign) BOOL is_vip;
@property (nonatomic ,copy) NSString *cover;
@property (nonatomic ,copy) NSString *author;
@property (nonatomic ,copy) NSString *reply_info;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,21 @@
//
// TFAppraiseDetailModel.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/21.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFAppraiseDetailModel.h"
@implementation TFAppraiseDetailModel
+ (NSDictionary *)modelCustomPropertyMapper
{
return @{
@"production_id" : @[@"book_id", @"comic_id", @"audio_id"],
@"name" : @[@"name", @"title", @"book_name", @"comic_name", @"audio_name"]
};
}
@end
@@ -0,0 +1,20 @@
//
// TFAppraiseCommViewCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/21.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFBasicTableViewCell.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFAppraiseCommViewCell : TFBasicTableViewCell
@property (nonatomic ,strong) TFCommentsListModel *commentsDetailModel;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,200 @@
//
// TFAppraiseCommViewCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/21.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFAppraiseCommViewCell.h"
@interface TFAppraiseCommViewCell ()
@property (nonatomic ,strong) UIImageView *avatarView; //头像
@property (nonatomic ,strong) UILabel *nickNameLabel; //昵称
@property (nonatomic ,strong) UIImageView *vipView; // VIP标识
@property (nonatomic ,strong) UILabel *timeLabel; //发布时间
@property (nonatomic ,strong) UILabel *commentLabel; //评论
@property (nonatomic ,strong) YYLabel *replyCommentLabel; //二级评论
@property (nonatomic ,strong) UILabel *bookNameLabel;
@property (nonatomic ,strong) UILabel *commentCountLabel;
@end
@implementation TFAppraiseCommViewCell
- (void)createSubviews
{
[super createSubviews];
// 头像
self.avatarView = [[UIImageView alloc] initWithCornerRadiusAdvance:35.0f / 2 rectCornerType:UIRectCornerAllCorners];
[self.contentView addSubview:self.avatarView];
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kMargin);
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kHalfMargin);
make.width.height.mas_equalTo(35.0f);
}];
// 昵称
self.nickNameLabel = [[UILabel alloc] init];
self.nickNameLabel.textColor = kGrayTextDeepColor;
self.nickNameLabel.font = kFont13;
self.nickNameLabel.textAlignment = NSTextAlignmentLeft;
[self.contentView addSubview:self.nickNameLabel];
[self.nickNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.avatarView.mas_right).with.offset(kHalfMargin);
make.top.mas_equalTo(self.avatarView.mas_top);
make.width.mas_equalTo(200);
make.height.mas_equalTo(self.avatarView.mas_height).multipliedBy(0.6);
}];
self.vipView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"public_vip_normal"]];
self.vipView.hidden = YES;
[self addSubview:self.vipView];
[self.vipView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nickNameLabel.mas_right);
make.centerY.mas_equalTo(self.nickNameLabel.mas_centerY);
make.height.mas_equalTo(10);
make.width.mas_equalTo(kGeometricWidth(10, 138, 48));
}];
self.timeLabel = [[UILabel alloc] init];
self.timeLabel.textAlignment = NSTextAlignmentLeft;
self.timeLabel.font = kFont10;
self.timeLabel.textColor = kGrayTextColor;
[self.contentView addSubview:self.timeLabel];
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nickNameLabel.mas_left);
make.bottom.mas_equalTo(self.avatarView.mas_bottom);
make.right.mas_equalTo(self.contentView.mas_right);
make.height.mas_equalTo(self.avatarView.mas_height).multipliedBy(0.4);
}];
// 二级评论
self.replyCommentLabel = [[YYLabel alloc] init];
self.replyCommentLabel.textAlignment = NSTextAlignmentLeft;
self.replyCommentLabel.textColor = kGrayTextDeepColor;
self.replyCommentLabel.font = kFont13;
self.replyCommentLabel.backgroundColor = kGrayViewColor;
self.replyCommentLabel.numberOfLines = 0;
self.replyCommentLabel.textContainerInset = UIEdgeInsetsMake(6, 5, 4, 5);
[self.contentView addSubview:self.replyCommentLabel];
[self.replyCommentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nickNameLabel.mas_left);
make.top.mas_equalTo(self.avatarView.mas_bottom);
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
make.height.mas_equalTo(CGFLOAT_MIN);
}];
// 评论
self.commentLabel = [[UILabel alloc] init];
self.commentLabel.textAlignment = NSTextAlignmentLeft;
self.commentLabel.font = kMainFont;
self.commentLabel.numberOfLines = 0;
self.commentLabel.textColor = kBlackColor;
[self.contentView addSubview:self.commentLabel];
[self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nickNameLabel.mas_left);
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
make.top.mas_equalTo(self.replyCommentLabel.mas_bottom).with.offset(kHalfMargin);
make.height.mas_equalTo(200);
}];
self.commentCountLabel = [[UILabel alloc] init];
self.commentCountLabel.font = kFont10;
self.commentCountLabel.textAlignment = NSTextAlignmentRight;
self.commentCountLabel.textColor = kGrayTextColor;
[self.contentView addSubview:self.commentCountLabel];
[self.commentCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
make.top.mas_equalTo(self.commentLabel.mas_bottom).with.offset(kHalfMargin);
make.width.mas_equalTo(100);
make.height.mas_equalTo(15);
}];
self.bookNameLabel = [[UILabel alloc] init];
self.bookNameLabel.font = kFont10;
self.bookNameLabel.textAlignment = NSTextAlignmentLeft;
self.bookNameLabel.textColor = kGrayTextColor;
[self.contentView addSubview:self.bookNameLabel];
[self.bookNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nickNameLabel.mas_left);
make.right.mas_equalTo(self.commentCountLabel.mas_left).with.offset(- kHalfMargin);
make.centerY.mas_equalTo(self.commentCountLabel.mas_centerY);
make.height.mas_equalTo(self.commentCountLabel.mas_height);
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin).priorityLow();
}];
}
- (void)setCommentsDetailModel:(TFCommentsListModel *)commentsDetailModel
{
if (!commentsDetailModel) {
return;
}
_commentsDetailModel = commentsDetailModel;
self.timeLabel.text = [NSString stringWithFormat:@"%@",commentsDetailModel.time ? : @""];
self.commentLabel.text = [NSString stringWithFormat:@"%@",commentsDetailModel.content ? : @""];
[self.commentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo([TFViewHelper getDynamicHeightWithLabelFont:self.commentLabel.font labelWidth:(SCREEN_WIDTH - 35.0f - kMargin) labelText:self.commentLabel.text] - kHalfMargin);
}];
[self.avatarView setImageWithURL:[NSURL URLWithString:commentsDetailModel.avatar ? : @""] placeholder:HoldUserAvatar options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
self.nickNameLabel.text = [NSString stringWithFormat:@"%@",commentsDetailModel.nickname ? : @""];
[self.nickNameLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.nickNameLabel]);
}];
if (commentsDetailModel.is_vip == 1) {
self.vipView.hidden = NO;
} else {
self.vipView.hidden = YES;
}
self.commentCountLabel.text = [NSString stringWithFormat:TFLocalizedString(@"%@条回复"), [TFUtilsHelper formatStringWithInteger:commentsDetailModel.reply_num]];
[self.commentCountLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.commentCountLabel]);
}];
self.bookNameLabel.text = commentsDetailModel.name_title ? : @"";
if (commentsDetailModel.reply_info.length > 0) {
CGFloat replyHeight = [TFViewHelper getDynamicHeightWithLabelFont:kFont11 labelWidth:(SCREEN_WIDTH - 2 * kMargin - 35.0f - kHalfMargin) labelText:commentsDetailModel.reply_info ? : @""];
NSString *replyInfo = [NSString stringWithFormat:@"%@",commentsDetailModel.reply_info ? : @""];
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
style.lineSpacing = 3;
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:replyInfo];
[attrString addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, replyInfo.length)];
[attrString addAttribute:NSFontAttributeName value:kFont11 range:NSMakeRange(0, replyInfo.length)];
self.replyCommentLabel.attributedText = attrString;
[self.replyCommentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.avatarView.mas_bottom).with.offset(kHalfMargin);
make.height.mas_equalTo(replyHeight);
}];
} else {
self.replyCommentLabel.attributedText = [[NSMutableAttributedString alloc] initWithString:@""];
[self.replyCommentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.avatarView.mas_bottom);
make.height.mas_equalTo(CGFLOAT_MIN);
}];
}
[self.commentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo([TFViewHelper getDynamicHeightWithLabelFont:self.commentLabel.font labelWidth:(SCREEN_WIDTH - 35.0f - kMargin) labelText:self.commentLabel.text] - kHalfMargin);
}];
}
@end
@@ -0,0 +1,22 @@
//
// TFAppraiseDetailHeaderView.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/21.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFAppraiseDetailModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFAppraiseDetailHeaderView : TFBasicTableViewCell
@property (nonatomic ,copy) void (^commentProductionClickBlock)(void);
@property (nonatomic ,strong) TFAppraiseDetailModel *appraiseDetailModel;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,234 @@
//
// TFAppraiseDetailHeaderView.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/21.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFAppraiseDetailHeaderView.h"
@interface TFAppraiseDetailHeaderView ()
@property (nonatomic ,strong) UIImageView *avatarView; //头像
@property (nonatomic ,strong) UILabel *nickNameLabel; //昵称
@property (nonatomic ,strong) UIImageView *vipView; // VIP标识
@property (nonatomic ,strong) UILabel *timeLabel; //发布时间
@property (nonatomic ,strong) UILabel *commentLabel; //评论
@property (nonatomic ,strong) YYLabel *replycommentLabel; // 二级评论
@property (nonatomic ,strong) TFProductionCoverView *coverView;
@property (nonatomic ,strong) UIButton *baseBtn;
@property (nonatomic ,strong) UILabel *titleLabel;
@property (nonatomic ,strong) UILabel *authorLabel;
@end
@implementation TFAppraiseDetailHeaderView
- (void)createSubviews
{
[super createSubviews];
// 头像
self.avatarView = [[UIImageView alloc] initWithCornerRadiusAdvance:35.0f / 2 rectCornerType:UIRectCornerAllCorners];
[self.contentView addSubview:self.avatarView];
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kMargin);
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kMargin);
make.width.height.mas_equalTo(35.0f);
}];
// 昵称
self.nickNameLabel = [[UILabel alloc] init];
self.nickNameLabel.textColor = kGrayTextDeepColor;
self.nickNameLabel.font = kFont13;
self.nickNameLabel.textAlignment = NSTextAlignmentLeft;
[self.contentView addSubview:self.nickNameLabel];
[self.nickNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.avatarView.mas_right).with.offset(kHalfMargin);
make.top.mas_equalTo(self.avatarView.mas_top);
make.width.mas_equalTo(200);
make.height.mas_equalTo(self.avatarView.mas_height).multipliedBy(0.6);
}];
self.vipView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"public_vip_normal"]];
self.vipView.hidden = YES;
[self.contentView addSubview:self.vipView];
[self.vipView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nickNameLabel.mas_right);
make.centerY.mas_equalTo(self.nickNameLabel.mas_centerY);
make.height.mas_equalTo(10);
make.width.mas_equalTo(kGeometricWidth(10, 138, 48));
}];
self.timeLabel = [[UILabel alloc] init];
self.timeLabel.textAlignment = NSTextAlignmentLeft;
self.timeLabel.font = kFont10;
self.timeLabel.textColor = kGrayTextColor;
[self.contentView addSubview:self.timeLabel];
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.avatarView.mas_right).with.offset(kHalfMargin);
make.bottom.mas_equalTo(self.avatarView.mas_bottom);
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
make.height.mas_equalTo(self.avatarView.mas_height).multipliedBy(0.4);
}];
// 二级评论
self.replycommentLabel = [[YYLabel alloc] init];
self.replycommentLabel.textAlignment = NSTextAlignmentLeft;
self.replycommentLabel.textColor = kGrayTextDeepColor;
self.replycommentLabel.font = kFont13;
self.replycommentLabel.backgroundColor = kGrayViewColor;
self.replycommentLabel.numberOfLines = 0;
self.replycommentLabel.textContainerInset = UIEdgeInsetsMake(6, 5, 4, 5);
[self.contentView addSubview:self.replycommentLabel];
[self.replycommentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.avatarView.mas_left);
make.top.mas_equalTo(self.avatarView.mas_bottom);
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
make.height.mas_equalTo(CGFLOAT_MIN);
}];
// 评论
self.commentLabel = [[UILabel alloc] init];
self.commentLabel.textAlignment = NSTextAlignmentLeft;
self.commentLabel.font = kFont12;
self.commentLabel.numberOfLines = 0;
self.commentLabel.textColor = KGrayTextMiddleColor;
[self.contentView addSubview:self.commentLabel];
[self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kMargin);
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
make.top.mas_equalTo(self.replycommentLabel.mas_bottom).with.offset(kHalfMargin);
make.height.mas_equalTo(200);
}];
self.baseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.baseBtn.backgroundColor = kGrayViewColor;
[ self.baseBtn addTarget:self action:@selector(commentProductionClick) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview: self.baseBtn];
[ self.baseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kMargin);
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
make.top.mas_equalTo(self.commentLabel.mas_bottom).with.offset(kHalfMargin);
make.height.mas_equalTo(kGeometricHeight(SCREEN_WIDTH, 3, 1) - kMargin);
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin).priorityLow();
}];
self.coverView = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
self.coverView.userInteractionEnabled = NO;
[ self.baseBtn addSubview:self.coverView];
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo( self.baseBtn.mas_left).with.offset(kHalfMargin);
make.centerY.mas_equalTo( self.baseBtn.mas_centerY);
make.height.mas_equalTo( self.baseBtn.mas_height).with.offset(- kMargin);
make.width.mas_equalTo(kGeometricWidth(kGeometricHeight(SCREEN_WIDTH, 3, 1) - 2 * kMargin, 3, 4));
}];
self.titleLabel = [[UILabel alloc] init];
self.titleLabel.textColor = kBlackColor;
self.titleLabel.textAlignment = NSTextAlignmentLeft;
self.titleLabel.numberOfLines = 1;
self.titleLabel.font = kMainFont;
[ self.baseBtn addSubview:self.titleLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.coverView.mas_right).with.offset(kHalfMargin);
make.bottom.mas_equalTo( self.baseBtn.mas_centerY);
make.right.mas_equalTo( self.baseBtn.mas_right).with.offset(- kHalfMargin);
make.height.mas_equalTo(40);
}];
self.authorLabel = [[UILabel alloc] init];
self.authorLabel.textColor = kGrayTextColor;
self.authorLabel.textAlignment = NSTextAlignmentLeft;
self.authorLabel.font = kFont10;
[ self.baseBtn addSubview:self.authorLabel];
[self.authorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.titleLabel.mas_left);
make.right.mas_equalTo(self.titleLabel.mas_right);
make.height.mas_equalTo(30);
make.top.mas_equalTo( self.baseBtn.mas_centerY);
}];
}
- (void)setAppraiseDetailModel:(TFAppraiseDetailModel *)appraiseDetailModel
{
_appraiseDetailModel = appraiseDetailModel;
self.timeLabel.text = [NSString stringWithFormat:@"%@",appraiseDetailModel.time ? : @""];
self.commentLabel.text = [NSString stringWithFormat:@"%@",appraiseDetailModel.content ? : @""];
[self.commentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo([TFViewHelper getDynamicHeightWithLabelFont:self.commentLabel.font labelWidth:(SCREEN_WIDTH - 35.0f - kMargin) labelText:self.commentLabel.text] - kHalfMargin);
}];
[self.avatarView setImageWithURL:[NSURL URLWithString:appraiseDetailModel.avatar ? : @""] placeholder:HoldUserAvatar options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
self.nickNameLabel.text = [NSString stringWithFormat:@"%@",appraiseDetailModel.nickname ? : @""];
[self.nickNameLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.nickNameLabel]);
}];
if (appraiseDetailModel.is_vip == 1) {
self.vipView.hidden = NO;
} else {
self.vipView.hidden = YES;
}
self.coverView.coverImageUrl = appraiseDetailModel.cover;
self.titleLabel.text = appraiseDetailModel.name ? : @"";
self.authorLabel.text = appraiseDetailModel.author ? : @"";
if (appraiseDetailModel.reply_info.length > 0) {
CGFloat replyHeight = [TFViewHelper getDynamicHeightWithLabelFont:kFont11 labelWidth:(SCREEN_WIDTH - 2 * kMargin - 35.0f - kHalfMargin) labelText:appraiseDetailModel.reply_info];
NSString *replyInfo = [NSString stringWithFormat:@"%@",appraiseDetailModel.reply_info];
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
style.lineSpacing = 3;
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:replyInfo];
[attrString addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, replyInfo.length)];
[attrString addAttribute:NSFontAttributeName value:kFont11 range:NSMakeRange(0, replyInfo.length)];
self.replycommentLabel.attributedText = attrString;
[self.replycommentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.avatarView.mas_bottom).with.offset(kHalfMargin);
make.height.mas_equalTo(replyHeight);
}];
} else {
self.replycommentLabel.attributedText = [[NSMutableAttributedString alloc] initWithString:@""];
[self.replycommentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.avatarView.mas_bottom);
make.height.mas_equalTo(CGFLOAT_MIN);
}];
}
}
- (void)setProductionType:(TFProductionType)productionType
{
[super setProductionType:productionType];
self.coverView.productionType = productionType;
}
- (void)commentProductionClick
{
if (self.commentProductionClickBlock) {
self.commentProductionClickBlock();
}
}
@end