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.
108 lines
4.4 KiB
108 lines
4.4 KiB
4 years ago
|
//
|
||
|
// TFAudioRecommendedViewCell.m
|
||
|
// TFReader
|
||
|
//
|
||
|
// Created by 谢腾飞 on 2020/12/25.
|
||
|
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "TFAudioRecommendedViewCell.h"
|
||
|
#import "TFCollectionManager.h"
|
||
|
#import "TFAudioRecommendedModel.h"
|
||
|
|
||
|
@interface TFAudioRecommendedViewCell ()
|
||
|
|
||
|
@property (nonatomic ,strong) UILabel *playAmountLabel;
|
||
|
@property (nonatomic ,strong) UIButton *collectionBtn;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation TFAudioRecommendedViewCell
|
||
|
|
||
|
- (void)createSubviews
|
||
|
{
|
||
|
[super createSubviews];
|
||
|
|
||
|
self.tagboardView.hidden = YES;
|
||
|
self.authorLabel.textColor = kMainColor;
|
||
|
|
||
|
UIImageView *playAmountIconView = [[UIImageView alloc] init];
|
||
|
playAmountIconView.image = [UIImage imageNamed:@"audio_directory_readtime"];
|
||
|
[self.contentView addSubview:playAmountIconView];
|
||
|
|
||
|
[playAmountIconView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.mas_equalTo(self.authorLabel.mas_right).with.offset(kHalfMargin);
|
||
|
make.centerY.mas_equalTo(self.authorLabel.mas_centerY);
|
||
|
make.height.mas_equalTo(10);
|
||
|
make.width.mas_equalTo(10);
|
||
|
}];
|
||
|
|
||
|
self.playAmountLabel = [[UILabel alloc] init];
|
||
|
self.playAmountLabel.font = kFont12;
|
||
|
self.playAmountLabel.textColor = kGrayTextColor;
|
||
|
[self.contentView addSubview:self.playAmountLabel];
|
||
|
|
||
|
[self.playAmountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.mas_equalTo(playAmountIconView.mas_right).with.offset(kQuarterMargin);
|
||
|
make.centerY.mas_equalTo(playAmountIconView.mas_centerY);
|
||
|
make.height.mas_equalTo(30);
|
||
|
make.width.mas_equalTo(CGFLOAT_MIN);
|
||
|
}];
|
||
|
|
||
|
self.collectionBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
|
self.collectionBtn.layer.cornerRadius = 10;
|
||
|
self.collectionBtn.layer.borderColor = kMainColor.CGColor;
|
||
|
self.collectionBtn.layer.borderWidth = 0.4;
|
||
|
[self.collectionBtn addTarget:self action:@selector(collectionBtnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||
|
[self.collectionBtn setTitle:TFLocalizedString(@"收藏") forState:UIControlStateNormal];
|
||
|
[self.collectionBtn setTitleColor:kMainColor forState:UIControlStateNormal];
|
||
|
[self.collectionBtn.titleLabel setFont:kFont11];
|
||
|
[self.contentView addSubview:self.collectionBtn];
|
||
|
|
||
|
[self.collectionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin);
|
||
|
make.centerY.mas_equalTo(playAmountIconView.mas_centerY);
|
||
|
make.width.mas_equalTo(60);
|
||
|
make.height.mas_equalTo(20);
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
- (void)setListModel:(TFAudioContentModel *)listModel
|
||
|
{
|
||
|
[super setProductionModel:listModel];
|
||
|
|
||
|
self.authorLabel.text = listModel.finished ? : @"";
|
||
|
[self.authorLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||
|
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.authorLabel]);
|
||
|
}];
|
||
|
|
||
|
self.playAmountLabel.text = [NSString stringWithFormat:@"%zd", listModel.total_views];
|
||
|
[self.playAmountLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
||
|
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.playAmountLabel]);
|
||
|
}];
|
||
|
|
||
|
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] isCollectedWithProduction_id:self.productionModel.production_id]) {
|
||
|
[self.collectionBtn setTitle:TFLocalizedString(@"已收藏") forState:UIControlStateNormal];
|
||
|
} else {
|
||
|
[self.collectionBtn setTitle:TFLocalizedString(@"收藏") forState:UIControlStateNormal];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- (void)collectionBtnClick:(UIButton *)sender
|
||
|
{
|
||
|
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] isCollectedWithProduction_id:self.productionModel.production_id]) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if ([[TFCollectionManager shareManagerWithProductionType:TFProductionTypeAudio] addCollectionWithProductionModel:self.productionModel]) {
|
||
|
[self.collectionBtn setTitle:TFLocalizedString(@"已收藏") forState:UIControlStateNormal];
|
||
|
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"已加入书架")];
|
||
|
} else {
|
||
|
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"加入书架失败")];
|
||
|
}
|
||
|
|
||
|
[TFUtilsHelper synchronizationRackProductionWithProduction_id:self.productionModel.production_id productionType:TFProductionTypeAudio complete:nil];
|
||
|
}
|
||
|
|
||
|
@end
|