You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
4.4 KiB

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