小说绘上架版本

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,28 @@
//
// TFComicDetailFooterView.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/19.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFComicDetailModel.h"
NS_ASSUME_NONNULL_BEGIN
typedef void(^PushToComicDetailBlock)(NSInteger production_id);
@interface TFComicDetailFooterView : TFBasicViewController
@property (nonatomic, strong) TFComicDetailModel *detailModel;
@property (nonatomic, assign) BOOL canScroll;
@property (nonatomic, assign) CGFloat contentOffSetY;
@property (nonatomic, copy) PushToComicDetailBlock pushToComicDetailBlock;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,89 @@
//
// TFComicDetailFooterView.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/19.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFComicDetailFooterView.h"
#import "TFComicDetailLeftViewController.h"
#import "TFComicDetailRightViewController.h"
@interface TFComicDetailFooterView () <SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
{
TFComicDetailLeftViewController *leftVC;
TFComicDetailRightViewController *rightVC;
}
@property (nonatomic, strong) SGPageTitleView *pageTitleView;
@property (nonatomic, strong) SGPageContentCollectionView *pageContentCollectionView;
@end
@implementation TFComicDetailFooterView
- (void)viewDidLoad
{
[super viewDidLoad];
[self hiddenNavigationBar:YES];
[self createSubViews];
}
- (void)createSubViews
{
WS(weakSelf)
leftVC = [[TFComicDetailLeftViewController alloc] init];
leftVC.pushToComicDetailBlock = ^(NSInteger production_id) {
if (weakSelf.pushToComicDetailBlock) {
weakSelf.pushToComicDetailBlock(production_id);
}
};
rightVC = [[TFComicDetailRightViewController alloc] init];
NSArray *childArr = @[leftVC, rightVC];
NSArray *titleArr = @[TFLocalizedString(@"详情"), TFLocalizedString(@"目录")];
self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, 44.6, self.view.width, SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - PUB_TABBAR_OFFSET - 44 - 44.6 - kQuarterMargin) parentVC:self childVCs:childArr];
self.pageContentCollectionView.delegatePageContentCollectionView = self;
[self.view addSubview:self.pageContentCollectionView];
self.pageConfigure.bottomSeparatorColor = kGrayLineColor;
self.pageConfigure.titleFont = kMainFont;
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 44) delegate:self titleNames:titleArr configure:self.pageConfigure];
self.pageTitleView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.pageTitleView];
}
- (void)setDetailModel:(TFComicDetailModel *)detailModel
{
_detailModel = detailModel;
leftVC.detailModel = self.detailModel;
rightVC.comicModel = self.detailModel.productionModel;
}
- (void)setCanScroll:(BOOL)canScroll
{
leftVC.canScroll = canScroll;
rightVC.canScroll = canScroll;
}
- (void)setContentOffSetY:(CGFloat)contentOffSetY
{
rightVC.contentOffSetY = contentOffSetY;
}
- (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,24 @@
//
// TFComicDetailHeaderView.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/19.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFComicDetailModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFComicDetailHeaderView : UIView
@property (nonatomic ,strong) TFProductionModel *comicProductionModel;
@property (nonatomic ,assign) CGFloat headerViewAlpha;
- (void)reloadHeaderView;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,290 @@
//
// TFComicDetailHeaderView.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/19.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFComicDetailHeaderView.h"
#import "TFTagboardView.h"
#import "TFCollectionManager.h"
#import "UIView+AZGradient.h"
#import "UIImage+Blur.h"
@interface TFComicDetailHeaderView ()
{
UIView *backFrostedGlassView;
UIView *tagBottomView;
UIImageView *comicCoverImageView;
UILabel *comicTitleLabel;
UIButton *collectButton;
UILabel *hotLabel;
UILabel *authorLabel;
UILabel *collectNumLabel;
TFTagboardView *tagView;
UIVisualEffectView *effectView;
}
@property (nonatomic ,weak) UIImageView *backHoldImageView;
@end
@implementation TFComicDetailHeaderView
- (instancetype)init
{
if (self = [super init]) {
[self createSubViews];
}
return self;
}
- (void)createSubViews
{
UIImageView *backHoldImageView = [[UIImageView alloc] init];
self.backHoldImageView = backHoldImageView;
backHoldImageView.image = HoldImage;
backHoldImageView.contentMode = UIViewContentModeScaleAspectFill;
backHoldImageView.clipsToBounds = YES;
[self addSubview:backHoldImageView];
[backHoldImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(0);
make.top.mas_equalTo(0);
make.width.mas_equalTo(SCREEN_WIDTH);
make.height.mas_equalTo(Comic_Detail_HeaderView_Height);
}];
backFrostedGlassView = [[UIView alloc] init];
[self addSubview:backFrostedGlassView];
[backFrostedGlassView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(backHoldImageView);
}];
effectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
effectView.alpha = 0;
[self addSubview:effectView];
[effectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(backHoldImageView);
}];
tagBottomView = [[UIView alloc] init];
tagBottomView.backgroundColor = kWhiteColor;
tagBottomView.layer.cornerRadius = 20;
[self addSubview:tagBottomView];
[tagBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(0);
make.bottom.mas_equalTo(self.mas_bottom).with.offset(kMargin);
make.width.mas_equalTo(self.mas_width);
make.height.mas_equalTo(80 + kMargin);
}];
comicCoverImageView = [[UIImageView alloc] initWithCornerRadiusAdvance:8 rectCornerType:UIRectCornerAllCorners];
comicCoverImageView.image = HoldImage;
comicCoverImageView.contentMode = UIViewContentModeScaleAspectFill;
[comicCoverImageView zy_attachBorderWidth:2 color:kWhiteColor];
[self addSubview:comicCoverImageView];
[comicCoverImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.mas_left).with.offset(kMargin);
make.bottom.mas_equalTo(self.mas_bottom).with.offset(- kQuarterMargin);
make.width.mas_equalTo((255) / 2);
make.height.mas_equalTo(kGeometricHeight((255) / 2, 3, 4));
}];
comicTitleLabel = [[UILabel alloc] init];
comicTitleLabel.textColor = kWhiteColor;
comicTitleLabel.textAlignment = NSTextAlignmentLeft;
comicTitleLabel.font = kBoldFont22;
[self addSubview:comicTitleLabel];
[comicTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(comicCoverImageView.mas_right).with.offset(kHalfMargin);
make.top.mas_equalTo(comicCoverImageView.mas_top);
make.right.mas_equalTo(self.mas_right).with.offset(- kHalfMargin);
make.height.mas_equalTo(30);
}];
collectButton = [UIButton buttonWithType:UIButtonTypeCustom];
collectButton.backgroundColor = kMainColor;
collectButton.layer.cornerRadius = 12;
collectButton.hidden = YES;
[collectButton setTitle:TFLocalizedString(@"+收藏") forState:UIControlStateNormal];
[collectButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
[collectButton.titleLabel setFont:kFont12];
[collectButton addTarget:self action:@selector(collectionClick:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:collectButton];
[collectButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.mas_right).with.offset(- kMargin);
make.bottom.mas_equalTo(tagBottomView.mas_top).with.offset(- kHalfMargin);
make.height.mas_equalTo(24);
make.width.mas_equalTo(70.0);
}];
collectNumLabel = [[UILabel alloc] init];
collectNumLabel.backgroundColor = [UIColor clearColor];
collectNumLabel.textColor = kWhiteColor;
collectNumLabel.textAlignment = NSTextAlignmentLeft;
collectNumLabel.font = kMainFont;
[self addSubview:collectNumLabel];
[collectNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(comicCoverImageView.mas_right).with.offset(kHalfMargin);
make.bottom.mas_equalTo(collectButton.mas_bottom);
make.right.mas_equalTo(collectButton.mas_left).with.offset(-kQuarterMargin);
make.height.mas_equalTo(20);
}];
hotLabel = [[UILabel alloc] init];
hotLabel.backgroundColor = [UIColor clearColor];
hotLabel.textColor = kWhiteColor;
hotLabel.textAlignment = NSTextAlignmentLeft;
hotLabel.font = kMainFont;
[self addSubview:hotLabel];
[hotLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(comicCoverImageView.mas_right).with.offset(kHalfMargin);
make.bottom.mas_equalTo(collectNumLabel.mas_top).with.offset(- kQuarterMargin);
make.right.mas_equalTo(self.mas_right).with.offset(- kHalfMargin);
make.height.mas_equalTo(collectNumLabel.mas_height);
}];
authorLabel = [[UILabel alloc] init];
authorLabel.backgroundColor = [UIColor clearColor];
authorLabel.textColor = kWhiteColor;
authorLabel.textAlignment = NSTextAlignmentLeft;
authorLabel.font = kMainFont;
[self addSubview:authorLabel];
[authorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(comicCoverImageView.mas_right).with.offset(kHalfMargin);
make.bottom.mas_equalTo(hotLabel.mas_top).with.offset(- kQuarterMargin);
make.right.mas_equalTo(self.mas_right).with.offset(- kHalfMargin);
make.height.mas_equalTo(collectNumLabel.mas_height);
}];
tagView = [[TFTagboardView alloc] init];
tagView.textAlignment = TFTagboardTextAlignmentLeft;
tagView.borderStyle = TFTagboardBorderStyleFill;
tagView.layoutStyle = TFTagboardLayoutStyleScroll;
tagView.spacing = 15;
tagView.cornerRadius = 8.5;
[self addSubview:tagView];
[tagView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(comicCoverImageView.mas_right).with.offset(kHalfMargin);
make.top.mas_equalTo(tagBottomView.mas_top).with.offset(kHalfMargin);
make.right.mas_equalTo(self.mas_right).with.offset(- kMargin);
make.height.mas_equalTo(20);
}];
}
- (void)setComicProductionModel:(TFProductionModel *)comicProductionModel
{
if (_comicProductionModel != comicProductionModel) {
_comicProductionModel = comicProductionModel;
collectButton.hidden = NO;
WS(weakSelf)
[[YYWebImageManager sharedManager] requestImageWithURL:[NSURL URLWithString:comicProductionModel.horizontal_cover.length > 0 ?comicProductionModel.horizontal_cover:comicProductionModel.vertical_cover] options:YYWebImageOptionSetImageWithFadeAnimation progress:nil transform:nil completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) {
dispatch_async(dispatch_get_main_queue(), ^{
SS(strongSelf)
weakSelf.backHoldImageView.image = [image imgWithLightAlpha:0.4 radius:3 colorSaturationFactor:1.8];
strongSelf->backFrostedGlassView.backgroundColor = kColorRGBA(0, 0, 0, 0.4);
});
}];
[comicCoverImageView setImageWithURL:[NSURL URLWithString:comicProductionModel.vertical_cover] placeholder:HoldImage options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
comicTitleLabel.attributedText = [self formatAttributedText:comicProductionModel.name];
hotLabel.attributedText = [self formatAttributedText:comicProductionModel.hot_num];
collectNumLabel.attributedText = [self formatAttributedText:comicProductionModel.total_favors];
authorLabel.attributedText = [self formatAttributedText:comicProductionModel.author];
tagView.tagboardArray = comicProductionModel.tag;
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeComic] isCollectedWithProductionModel:comicProductionModel]) {
collectButton.tag = 1;
collectButton.backgroundColor = [kMainColor colorWithAlphaComponent:0.75];
[collectButton setTitle:TFLocalizedString(@"已收藏") forState:UIControlStateNormal];
} else {
collectButton.tag = 0;
collectButton.backgroundColor = kMainColor;
[collectButton setTitle:TFLocalizedString(@"+收藏") forState:UIControlStateNormal];
}
}
}
- (NSAttributedString *)formatAttributedText:(NSString *)normalText
{
// NSShadow *shadow = [[NSShadow alloc] init];
// shadow.shadowBlurRadius = 6.0;
// shadow.shadowOffset = CGSizeMake(0, 0);
// shadow.shadowColor = [UIColor blackColor];
NSMutableAttributedString *authorAttString = [[NSMutableAttributedString alloc] initWithString:normalText?:@""];
// [authorAttString addAttribute:NSShadowAttributeName value:shadow range:NSMakeRange(0, authorAttString.length)];
return authorAttString;
}
- (void)setHeaderViewAlpha:(CGFloat)headerViewAlpha
{
_headerViewAlpha = headerViewAlpha;
[tagBottomView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(80 * headerViewAlpha);
}];
comicCoverImageView.alpha = headerViewAlpha;
comicTitleLabel.alpha = headerViewAlpha;
collectButton.alpha = headerViewAlpha;
hotLabel.alpha = headerViewAlpha;
collectNumLabel.alpha = headerViewAlpha;
authorLabel.alpha = headerViewAlpha;
tagView.alpha = headerViewAlpha;
backFrostedGlassView.alpha = headerViewAlpha;
effectView.alpha = 1 - headerViewAlpha;
}
- (void)reloadHeaderView
{
if (![[TFCollectionManager shareManagerWithProductionType:TFProductionTypeComic] isCollectedWithProductionModel:self.comicProductionModel]) {
collectButton.backgroundColor = kMainColor;
[collectButton setTitle:TFLocalizedString(@"+收藏") forState:UIControlStateNormal];
} else {
collectButton.backgroundColor = [kMainColor colorWithAlphaComponent:0.75];
[collectButton setTitle:TFLocalizedString(@"已收藏") forState:UIControlStateNormal];
}
}
- (void)collectionClick:(UIButton *)sender
{
if (![[TFCollectionManager shareManagerWithProductionType:TFProductionTypeComic] isCollectedWithProductionModel:self.comicProductionModel]) {
[TFUtilsHelper synchronizationRackProductionWithProduction_id:self.comicProductionModel.production_id productionType:TFProductionTypeComic complete:nil];
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeComic] addCollectionWithProductionModel:self.comicProductionModel]) {
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"已加入书架")];
}
[self reloadHeaderView];
}
}
@end
@@ -0,0 +1,20 @@
//
// TFComicDetailIntroductionCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/19.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFComicDetailModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFComicDetailIntroductionCell : TFBasicTableViewCell
@property (nonatomic ,strong) TFProductionModel *comicModel;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,95 @@
//
// TFComicDetailIntroductionCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/19.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFComicDetailIntroductionCell.h"
@interface TFComicDetailIntroductionCell ()
{
UILabel *introductionLabel;
UILabel *introductionContent;
}
@end
@implementation TFComicDetailIntroductionCell
- (void)createSubviews
{
[super createSubviews];
introductionLabel = [[UILabel alloc] init];
introductionLabel.text = TFLocalizedString(@"作品简介");
introductionLabel.textColor = kGrayTextDeepColor;
introductionLabel.textAlignment = NSTextAlignmentLeft;
introductionLabel.font = kMainFont;
[self.contentView addSubview:introductionLabel];
[introductionLabel 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.right.mas_equalTo(self.contentView.mas_right).with.offset(- kMargin);
make.height.mas_equalTo(0.0);
}];
introductionContent = [[UILabel alloc] init];
introductionContent.textColor = kGrayTextColor;
introductionContent.textAlignment = NSTextAlignmentLeft;
introductionContent.font = kFont12;
introductionContent.numberOfLines = 0;
[self.contentView addSubview:introductionContent];
[introductionContent mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(introductionLabel.mas_left);
make.top.mas_equalTo(self.contentView.mas_top).offset(kHalfMargin);
make.right.mas_equalTo(introductionLabel.mas_right);
}];
UIView *splitLine = [[UIView alloc] init];
splitLine.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:splitLine];
[splitLine mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(0.1);
make.right.bottom.left.equalTo(self.contentView);
make.top.equalTo(introductionContent.mas_bottom).offset(kHalfMargin).priorityLow();
}];
}
- (void)setComicModel:(TFProductionModel *)comicModel
{
if (_comicModel != comicModel) {
_comicModel = comicModel;
if (comicModel.production_descirption.length > 0) {
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:comicModel.production_descirption?:@""];
attributedString.lineSpacing = 6;
attributedString.font = kFont12;
attributedString.color = kGrayTextColor;
YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:CGSizeMake(SCREEN_WIDTH - 2 * kMargin, MAXFLOAT) text:attributedString];
if (layout.rowCount < 5) {
introductionContent.attributedText = attributedString;
} else {
// 截取前5行的内容
YYTextLine *lastLine = layout.lines[4];
NSMutableAttributedString *t_atr = [[attributedString attributedSubstringFromRange:NSMakeRange(0, lastLine.range.location + lastLine.range.length)] mutableCopy];
// 截取第5行一半的内容
CGFloat maxWidth = (SCREEN_WIDTH - 2 * kMargin) / 2.0;
if (lastLine.lineWidth > maxWidth) {
// 获取多出来的距离
CGFloat spacing = lastLine.lineWidth - maxWidth;
// 获取多余的文字个数(多余的间距 / 单个字的宽度)
NSInteger number = spacing / (lastLine.lineWidth / lastLine.range.length);
t_atr = [[t_atr attributedSubstringFromRange:NSMakeRange(0, t_atr.length - number - 1)] mutableCopy];
[t_atr appendString:@" ..."];
}
introductionContent.attributedText = t_atr;
}
}
}
}
@end
@@ -0,0 +1,20 @@
//
// TFComicDetailRightViewCell.h
// TFReader
//
// Created by 谢腾飞 on 2020/12/19.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TFReadRecordManager.h"
NS_ASSUME_NONNULL_BEGIN
@interface TFComicDetailRightViewCell : TFBasicTableViewCell
@property (nonatomic ,strong) TFProductionChapterModel *chapterModel;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,116 @@
//
// TFComicDetailRightViewCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/19.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFComicDetailRightViewCell.h"
#import "TFProductionCoverView.h"
@interface TFComicDetailRightViewCell ()
{
TFProductionCoverView *comicCoverImageView;
UILabel *comicTitleLabel;
UILabel *comicSubTitleLabel;
UIView *grayMask;
UIImageView *currentReadImageView;
}
@end
@implementation TFComicDetailRightViewCell
- (void)createSubviews
{
[super createSubviews];
self.selectionStyle = UITableViewCellSelectionStyleNone;
comicCoverImageView = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeComic coverDirection:TFProductionCoverDirectionHorizontal];
[self.contentView addSubview:comicCoverImageView];
[comicCoverImageView 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 * 0.8);
make.width.mas_equalTo(self.contentView.mas_width).multipliedBy(0.4).with.offset(- kMargin - kHalfMargin);
make.height.mas_equalTo(kGeometricHeight(((SCREEN_WIDTH * 0.4) - kMargin - kHalfMargin), 5, 3));
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin * 0.8).priorityLow();
}];
comicTitleLabel = [[UILabel alloc] init];
comicTitleLabel.textColor = kBlackColor;
comicTitleLabel.textAlignment = NSTextAlignmentLeft;
comicTitleLabel.font = kMainFont;
[self.contentView addSubview:comicTitleLabel];
[comicTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(comicCoverImageView.mas_right).with.offset(kHalfMargin);
make.top.mas_equalTo(comicCoverImageView.mas_top);
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
make.height.mas_equalTo(30);
}];
comicSubTitleLabel = [[UILabel alloc] init];
comicSubTitleLabel.textColor = kGrayTextColor;
comicSubTitleLabel.textAlignment = NSTextAlignmentLeft;
comicSubTitleLabel.font = kFont12;
[self.contentView addSubview:comicSubTitleLabel];
[comicSubTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(comicTitleLabel.mas_left);
make.bottom.mas_equalTo(comicCoverImageView.mas_bottom);
make.right.mas_equalTo(comicTitleLabel.mas_right);
make.height.mas_equalTo(20);
}];
grayMask = [[UIView alloc] init];
grayMask.backgroundColor = kWhiteColor;
grayMask.alpha = 0;
grayMask.userInteractionEnabled = YES;
[self.contentView addSubview:grayMask];
[grayMask mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.contentView);
}];
currentReadImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"comic_current_read"]];
currentReadImageView.hidden = YES;
[self.contentView addSubview:currentReadImageView];
[currentReadImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kHalfMargin);
make.right.mas_equalTo(self.contentView.mas_right);
make.width.height.mas_equalTo(20);
}];
}
- (void)setChapterModel:(TFProductionChapterModel *)chapterModel
{
_chapterModel = chapterModel;
comicCoverImageView.coverImageUrl = chapterModel.cover;
comicCoverImageView.is_locked = chapterModel.is_preview;
comicTitleLabel.text = chapterModel.chapter_title?:@"";
comicSubTitleLabel.text = chapterModel.subtitle?:@"";
if ([[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeComic] getReadingRecordChapter_idWithProduction_id:chapterModel.production_id] == chapterModel.chapter_id) {
self.contentView.backgroundColor = kGrayLineColor;
grayMask.alpha = 0.7;
currentReadImageView.hidden = NO;
} else if ([[TFReadRecordManager shareManagerWithProductionType:TFProductionTypeComic] chapterHasReadedWithProduction_id:chapterModel.production_id chapter_id:chapterModel.chapter_id]) {
self.contentView.backgroundColor = kGrayLineColor;
grayMask.alpha = 0.7;
currentReadImageView.hidden = YES;
} else {
self.contentView.backgroundColor = kWhiteColor;
grayMask.alpha = 0;
currentReadImageView.hidden = YES;
}
}
@end