Files
keyboard/keyBoard/Class/Me/V/KBSkinDetailHeaderCell.m
2025-12-11 15:39:33 +08:00

86 lines
3.0 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// KBSkinDetailHeaderCell.m
// keyBoard
//
// Created by Mac on 2025/11/8.
//
#import "KBSkinDetailHeaderCell.h"
#import "UIImageView+KBWebImage.h"
#import "KBShopThemeDetailModel.h"
@implementation KBSkinDetailHeaderCell
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.contentView.backgroundColor = [UIColor whiteColor];
self.contentView.layer.cornerRadius = 12;
self.contentView.layer.masksToBounds = YES;
[self.contentView addSubview:self.coverView];
[self.contentView addSubview:self.leftLabel];
[self.contentView addSubview:self.rightLabel];
// 上图16:9 比例;下方左右文案
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.right.equalTo(self.contentView);
// 高度按照宽度等比(接近截图比例)
// make.height.equalTo(self.contentView.mas_width).multipliedBy(0.58);
make.height.mas_equalTo(KBFit(264));
}];
[self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView).offset(0);
make.top.equalTo(self.coverView.mas_bottom).offset(10);
}];
[self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView).offset(-12);
make.centerY.equalTo(self.leftLabel);
}];
}
return self;
}
- (void)configWithDetail:(KBShopThemeDetailModel *)detail {
NSString *title = detail.themeName.length ? detail.themeName : @"Dopamine";
NSString *download = detail.themeDownload.length ? detail.themeDownload : @"0";
NSString *downloadText = [NSString stringWithFormat:@"%@: %@", KBLocalized(@"Download"), download];
self.leftLabel.text = title;
self.rightLabel.text = downloadText;
UIImage *placeholder = [UIImage imageNamed:@"shop_headbigBg_icon"];
if (detail.themePreviewImageUrl.length) {
[self.coverView kb_setImageURL:detail.themePreviewImageUrl placeholder:placeholder];
} else {
self.coverView.image = placeholder;
}
}
#pragma mark - Lazy
- (UIImageView *)coverView {
if (!_coverView) {
_coverView = [[UIImageView alloc] init];
_coverView.contentMode = UIViewContentModeScaleAspectFill;
_coverView.clipsToBounds = YES;
_coverView.layer.cornerRadius = 12;
}
return _coverView;
}
- (UILabel *)leftLabel {
if (!_leftLabel) {
_leftLabel = [UILabel new];
_leftLabel.textColor = [UIColor colorWithHex:KBBlackValue];
_leftLabel.font = [KBFont medium:16];
_leftLabel.text = @"Dopamine";
}
return _leftLabel;
}
- (UILabel *)rightLabel {
if (!_rightLabel) {
_rightLabel = [UILabel new];
_rightLabel.textColor = [UIColor colorWithHex:KBColorValue];
_rightLabel.font = [KBFont regular:13];
_rightLabel.textAlignment = NSTextAlignmentRight;
_rightLabel.text = @"Download: 1 Million";
}
return _rightLabel;
}
@end