小说绘上架版本
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// TFHistoricalRecordCommCell.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
|
||||
|
||||
typedef void(^ContinueReadBlock)(NSInteger book_id);
|
||||
@interface TFHistoricalRecordCommCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic ,strong) TFProductionModel *productionModel;
|
||||
@property (nonatomic ,copy) ContinueReadBlock continueReadBlock;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
//
|
||||
// TFHistoricalRecordCommCell.m
|
||||
// TFReader
|
||||
//
|
||||
// Created by 谢腾飞 on 2020/12/21.
|
||||
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TFHistoricalRecordCommCell.h"
|
||||
|
||||
@interface TFHistoricalRecordCommCell ()
|
||||
|
||||
@property (nonatomic ,strong) UIView *advertView;
|
||||
@property (nonatomic ,strong) TFProductionCoverView *coverView;
|
||||
@property (nonatomic ,strong) UIButton *continueBtn;
|
||||
@property (nonatomic ,strong) UILabel *titleLabel;
|
||||
@property (nonatomic ,strong) UILabel *recordLabel;
|
||||
@property (nonatomic ,strong) UILabel *timeLabel;
|
||||
@property (nonatomic ,strong) UIView *posterView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation TFHistoricalRecordCommCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
// 图片
|
||||
self.coverView = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical];
|
||||
self.coverView.userInteractionEnabled = YES;
|
||||
self.coverView.hidden = YES;
|
||||
[self.contentView addSubview:self.coverView];
|
||||
|
||||
[self.coverView 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(BOOK_WIDTH_SMALL - kMargin);
|
||||
make.height.mas_equalTo(kGeometricHeight(BOOK_WIDTH_SMALL - kMargin, 3, 4));
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin).priorityLow();
|
||||
}];
|
||||
|
||||
self.continueBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[self.continueBtn setHidden:YES];
|
||||
[self.continueBtn.layer setCornerRadius:12];
|
||||
[self.continueBtn setBackgroundColor:kMainColor];
|
||||
[self.continueBtn setTitle:TFLocalizedString(@"历史记录继续阅读") forState:UIControlStateNormal];
|
||||
[self.continueBtn setTitleColor:kWhiteColor forState:UIControlStateNormal];
|
||||
[self.continueBtn.titleLabel setFont:kFont11];
|
||||
[self.continueBtn addTarget:self action:@selector(continueReadClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.contentView addSubview:self.continueBtn];
|
||||
|
||||
[self.continueBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
|
||||
make.centerY.mas_equalTo(self.coverView.mas_centerY);
|
||||
make.width.mas_equalTo(70);
|
||||
make.height.mas_equalTo(24);
|
||||
}];
|
||||
|
||||
// 书名
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.numberOfLines = 1;
|
||||
self.titleLabel.hidden = YES;
|
||||
self.titleLabel.backgroundColor = kWhiteColor;
|
||||
self.titleLabel.font = kMainFont;
|
||||
self.titleLabel.textAlignment = NSTextAlignmentLeft;
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.coverView.mas_right).with.offset(kHalfMargin);
|
||||
make.right.mas_equalTo(self.continueBtn.mas_left).with.offset(- kHalfMargin);
|
||||
make.top.mas_equalTo(self.coverView.mas_top).mas_offset(10);
|
||||
}];
|
||||
|
||||
// 阅读记录
|
||||
self.recordLabel = [[UILabel alloc] init];
|
||||
self.recordLabel.hidden = YES;
|
||||
self.recordLabel.textColor = kGrayTextColor;
|
||||
self.recordLabel.font = kFont11;
|
||||
self.recordLabel.textAlignment = NSTextAlignmentLeft;
|
||||
[self.contentView addSubview:self.recordLabel];
|
||||
|
||||
[self.recordLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.titleLabel.mas_left);
|
||||
make.centerY.mas_equalTo(self.coverView.centerY).mas_offset(10);
|
||||
make.width.mas_equalTo(self.titleLabel.mas_width);
|
||||
make.height.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
// 更新记录
|
||||
self.timeLabel = [[UILabel alloc] init];
|
||||
self.timeLabel.hidden = YES;
|
||||
self.timeLabel.textColor = kGrayTextColor;
|
||||
self.timeLabel.font = kFont10;
|
||||
self.timeLabel.textAlignment = NSTextAlignmentLeft;
|
||||
[self.contentView addSubview:self.timeLabel];
|
||||
|
||||
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.titleLabel.mas_left);
|
||||
make.top.mas_equalTo(self.recordLabel.mas_bottom);
|
||||
make.width.mas_equalTo(self.titleLabel.mas_width);
|
||||
make.height.mas_equalTo(self.recordLabel.mas_height);
|
||||
}];
|
||||
|
||||
|
||||
self.posterView = [[UIView alloc] init];
|
||||
self.posterView.backgroundColor = [UIColor whiteColor];
|
||||
self.posterView.hidden = YES;
|
||||
[self.contentView addSubview:self.posterView];
|
||||
|
||||
[self.posterView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.contentView);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setAdvertView:(UIView *)advertView
|
||||
{
|
||||
_advertView = advertView;
|
||||
|
||||
[self.posterView addSubview:advertView];
|
||||
}
|
||||
|
||||
- (void)setProductionModel:(TFProductionModel *)productionModel
|
||||
{
|
||||
_productionModel = productionModel;
|
||||
|
||||
if (productionModel.ad_type != 0) {
|
||||
self.coverView.hidden = YES;
|
||||
self.continueBtn.hidden = YES;
|
||||
self.titleLabel.hidden = YES;
|
||||
self.recordLabel.hidden = YES;
|
||||
self.timeLabel.hidden = YES;
|
||||
self.posterView.hidden = NO;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
self.coverView.hidden = NO;
|
||||
self.continueBtn.hidden = NO;
|
||||
self.titleLabel.hidden = NO;
|
||||
self.recordLabel.hidden = NO;
|
||||
self.timeLabel.hidden = NO;
|
||||
self.posterView.hidden = YES;
|
||||
|
||||
self.titleLabel.text = productionModel.name ? : @"";
|
||||
|
||||
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;
|
||||
} else {
|
||||
self.coverView.coverImageUrl = productionModel.cover;
|
||||
}
|
||||
|
||||
if (self.productionType == TFProductionTypeAudio) {
|
||||
self.recordLabel.text = [NSString stringWithFormat:@"%@%@", TFLocalizedString(@"上次收听到:"), productionModel.record_title ?: @""];
|
||||
} else {
|
||||
self.recordLabel.text = [NSString stringWithFormat:@"%@%@", TFLocalizedString(@"上次阅读到:"), productionModel.record_title ?: @""];
|
||||
}
|
||||
|
||||
self.timeLabel.text = [NSString stringWithFormat:TFLocalizedString(@"%@ 更新至第%@章"), productionModel.last_chapter_time ? : @"", [TFUtilsHelper formatStringWithInteger:productionModel.total_chapters] ?: @""];
|
||||
}
|
||||
|
||||
- (void)continueReadClick
|
||||
{
|
||||
if (self.continueReadBlock) {
|
||||
self.continueReadBlock(_productionModel.production_id);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setProductionType:(TFProductionType)productionType
|
||||
{
|
||||
[super setProductionType:productionType];
|
||||
|
||||
self.coverView.productionType = productionType;
|
||||
|
||||
if (productionType == TFProductionTypeAudio) {
|
||||
[self.continueBtn setTitle:TFLocalizedString(@"历史记录继续收听") forState:UIControlStateNormal];
|
||||
} else {
|
||||
[self.continueBtn setTitle:TFLocalizedString(@"历史记录继续阅读") forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user