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.
181 lines
6.0 KiB
181 lines
6.0 KiB
4 years ago
|
//
|
||
|
// TFBookRackCommCell.m
|
||
|
// WXReader
|
||
|
//
|
||
|
// Created by 谢腾飞 on 2020/12/1.
|
||
|
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "TFBookRackCommCell.h"
|
||
|
|
||
|
@interface TFBookRackCommCell ()
|
||
|
|
||
|
@property (nonatomic ,strong) UILabel *titleLabel;
|
||
|
@property (nonatomic ,strong) UILabel *finishedLabel;
|
||
|
@property (nonatomic ,strong) UIImageView *selectView;
|
||
|
@property (nonatomic ,strong) UIImageView *recommendView;
|
||
|
@property (nonatomic ,strong) UILabel *badgeLabel;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation TFBookRackCommCell
|
||
|
|
||
|
- (instancetype)initWithFrame:(CGRect)frame
|
||
|
{
|
||
|
if (self = [super initWithFrame:frame]) {
|
||
|
self.backgroundColor = kWhiteColor;
|
||
|
[self createSubviews];
|
||
|
}
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
- (void)createSubviews
|
||
|
{
|
||
|
self.coverView = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
|
||
|
self.coverView.userInteractionEnabled = YES;
|
||
|
[self addSubview:self.coverView];
|
||
|
|
||
|
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.centerX.mas_equalTo(self.mas_centerX);
|
||
|
make.top.mas_equalTo(self.mas_top);
|
||
|
make.width.mas_equalTo(BOOK_WIDTH);
|
||
|
make.height.mas_equalTo(BOOK_HEIGHT);
|
||
|
}];
|
||
|
|
||
|
self.recommendView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:TFLocalizedString(@"book_rack_recommend_conner")]];
|
||
|
self.recommendView.hidden = YES;
|
||
|
[self.coverView addSubview:self.recommendView];
|
||
|
|
||
|
[self.recommendView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.mas_equalTo(0);
|
||
|
make.top.mas_equalTo(0);
|
||
|
make.width.mas_equalTo(BOOK_WIDTH / 3);
|
||
|
make.height.mas_equalTo(kGeometricHeight((BOOK_WIDTH / 3), 102, 54));
|
||
|
}];
|
||
|
|
||
|
self.badgeLabel = [[UILabel alloc] init];
|
||
|
self.badgeLabel.hidden = YES;
|
||
|
self.badgeLabel.textAlignment = NSTextAlignmentCenter;
|
||
|
self.badgeLabel.textColor = kWhiteColor;
|
||
|
self.badgeLabel.backgroundColor = kColorRGBA(229, 91, 94, 1);
|
||
|
self.badgeLabel.font = kFont9;
|
||
|
self.badgeLabel.numberOfLines = 1;
|
||
|
self.badgeLabel.layer.cornerRadius = 8;
|
||
|
self.badgeLabel.layer.borderColor = [UIColor whiteColor].CGColor;
|
||
|
self.badgeLabel.layer.borderWidth = 2;
|
||
|
self.badgeLabel.clipsToBounds = YES;
|
||
|
[self.coverView addSubview:self.badgeLabel];
|
||
|
|
||
|
[self.badgeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.centerX.mas_equalTo(self.coverView.mas_right).with.offset(- 3);
|
||
|
make.centerY.mas_equalTo(self.coverView.mas_top).with.offset(3);
|
||
|
make.width.height.mas_equalTo(16);
|
||
|
}];
|
||
|
|
||
|
self.selectView = [[UIImageView alloc] init];
|
||
|
self.selectView.hidden = YES;
|
||
|
self.selectView.userInteractionEnabled = YES;
|
||
|
self.selectView.image = [UIImage imageNamed:@"audio_download_unselect"];
|
||
|
[self addSubview:self.selectView];
|
||
|
|
||
|
[self.selectView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.right.mas_equalTo(self.coverView.mas_right).with.offset(- 5);
|
||
|
make.bottom.mas_equalTo(self.coverView.mas_bottom).with.offset(- 5);
|
||
|
make.height.width.mas_equalTo(18);
|
||
|
}];
|
||
|
|
||
|
self.titleLabel = [[UILabel alloc] init];
|
||
|
self.titleLabel.numberOfLines = 1;
|
||
|
self.titleLabel.backgroundColor = kGrayViewColor;
|
||
|
self.titleLabel.font = kFont12;
|
||
|
self.titleLabel.textAlignment = NSTextAlignmentLeft;
|
||
|
self.titleLabel.textColor = kBlackColor;
|
||
|
[self addSubview:self.titleLabel];
|
||
|
|
||
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.mas_equalTo(self.coverView.mas_left);
|
||
|
make.top.mas_equalTo(self.coverView.mas_bottom).with.offset(kHalfMargin);
|
||
|
make.width.mas_equalTo(self.coverView.mas_width);
|
||
|
make.height.mas_equalTo(BOOK_CELL_TITLE_HEIGHT / 2);
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
- (void)setProductionModel:(TFProductionModel *)productionModel
|
||
|
{
|
||
|
_productionModel = productionModel;
|
||
|
|
||
|
self.coverView.productionType = productionModel.productionType;
|
||
|
|
||
|
if (productionModel.cover.length > 0) {
|
||
|
self.coverView.coverImageUrl = productionModel.cover;
|
||
|
} else if (productionModel.vertical_cover.length > 0) {
|
||
|
self.coverView.coverImageUrl = productionModel.vertical_cover;
|
||
|
} else if (productionModel.horizontal_cover.length > 0) {
|
||
|
self.coverView.coverImageUrl = productionModel.horizontal_cover;
|
||
|
}
|
||
|
|
||
|
self.recommendView.hidden = !productionModel.is_recommend;
|
||
|
self.titleLabel.backgroundColor = kWhiteColor;
|
||
|
self.titleLabel.text = productionModel.name ? : @"";
|
||
|
self.badgeLabel.hidden = YES;
|
||
|
}
|
||
|
|
||
|
- (void)setBookSeleced:(BOOL)bookSeleced
|
||
|
{
|
||
|
_bookSeleced = bookSeleced;
|
||
|
|
||
|
if (bookSeleced) {
|
||
|
self.selectView.image = [UIImage imageNamed:@"audio_download_select"];
|
||
|
self.coverView.alpha = 1.0f;
|
||
|
} else {
|
||
|
self.selectView.image = [UIImage imageNamed:@"audio_download_unselect"];
|
||
|
self.coverView.alpha = 0.5f;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- (void)setBadgeNum:(NSString *)badgeNum
|
||
|
{
|
||
|
if ([badgeNum isEqualToString:@"0"]) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (_productionModel.total_chapters == 0) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
badgeNum = [NSString stringWithFormat:@"%@", [TFUtilsHelper formatStringWithInteger:abs((int)_productionModel.total_chapters - [badgeNum intValue])]];
|
||
|
|
||
|
if (badgeNum && ![badgeNum isEqualToString:@"0"]) {
|
||
|
|
||
|
self.badgeLabel.hidden = NO;
|
||
|
self.badgeLabel.text = badgeNum;
|
||
|
if (badgeNum.length == 2) {
|
||
|
[self.badgeLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||
|
make.width.mas_equalTo(21);
|
||
|
}];
|
||
|
} else if (badgeNum.length >= 3) {
|
||
|
[self.badgeLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||
|
make.width.mas_equalTo(26);
|
||
|
}];
|
||
|
}
|
||
|
} else {
|
||
|
self.badgeLabel.hidden = YES;
|
||
|
}
|
||
|
|
||
|
_badgeNum = badgeNum;
|
||
|
}
|
||
|
|
||
|
- (void)setStartEditing:(BOOL)startEditing
|
||
|
{
|
||
|
_startEditing = startEditing;
|
||
|
|
||
|
if (startEditing) {
|
||
|
self.coverView.alpha = 0.5f;
|
||
|
self.selectView.hidden = NO;
|
||
|
} else {
|
||
|
self.coverView.alpha = 1.0f;
|
||
|
self.selectView.hidden = YES;
|
||
|
}
|
||
|
}
|
||
|
@end
|