146 lines
4.1 KiB
Objective-C
146 lines
4.1 KiB
Objective-C
//
|
|
// XPMineDataSkillDataCollectionViewCell.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2022/4/14.
|
|
//
|
|
|
|
#import "XPMineDataSkillDataCollectionViewCell.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "NetImageView.h"
|
|
///Model
|
|
#import "MineSkillCardListInfoModel.h"
|
|
|
|
@interface XPMineDataSkillDataCollectionViewCell ()
|
|
|
|
///背景
|
|
@property (nonatomic,strong) UIView * backView;
|
|
///显示图片
|
|
@property (nonatomic,strong) NetImageView *logoImageView;
|
|
///标题
|
|
@property (nonatomic,strong) UILabel *titleLabel;
|
|
///技能卡
|
|
@property (nonatomic,strong) UILabel *skillLabel;
|
|
|
|
@end
|
|
|
|
@implementation XPMineDataSkillDataCollectionViewCell
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
self.backgroundColor = [UIColor clearColor];
|
|
[self.contentView addSubview:self.backView];
|
|
[self.backView addSubview:self.logoImageView];
|
|
[self.backView addSubview:self.titleLabel];
|
|
[self.backView addSubview:self.skillLabel];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_equalTo(self.contentView);
|
|
}];
|
|
|
|
[self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.bottom.mas_equalTo(self.backView).inset(8);
|
|
make.leading.mas_equalTo(self.backView).offset(4);
|
|
make.height.mas_equalTo(self.logoImageView.mas_width);
|
|
}];
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.mas_equalTo(self.logoImageView.mas_centerY).offset(-2);
|
|
make.leading.mas_equalTo(self.logoImageView.mas_trailing).offset(4);
|
|
make.trailing.mas_lessThanOrEqualTo(self.backView);
|
|
}];
|
|
|
|
[self.skillLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.trailing.mas_equalTo(self.titleLabel);
|
|
make.top.mas_equalTo(self.logoImageView.mas_centerY).offset(2);
|
|
}];
|
|
}
|
|
- (UIColor *)getSkillCardBackColor:(NSString *)cardId {
|
|
UIColor * color = UIColorFromRGB(0xFEF5E8);
|
|
if ([cardId isEqualToString:@"1"]) {
|
|
color = UIColorFromRGB(0xEEF2FF);
|
|
} else if([cardId isEqualToString:@"2"]) {
|
|
color = UIColorFromRGB(0xFEF5E8);
|
|
}else if([cardId isEqualToString:@"3"]) {
|
|
color = UIColorFromRGB(0xF2FFE0);
|
|
}else if([cardId isEqualToString:@"4"]) {
|
|
color = UIColorFromRGB(0xE9FFF4);
|
|
}else if([cardId isEqualToString:@"5"]) {
|
|
color = UIColorFromRGB(0xFFE7EF);
|
|
}else if([cardId isEqualToString:@"6"]) {
|
|
color = UIColorFromRGB(0xF9ECFF);
|
|
}else if([cardId isEqualToString:@"7"]) {
|
|
color = UIColorFromRGB(0xFFE4FB);
|
|
}else if([cardId isEqualToString:@"9"]) {
|
|
color = UIColorFromRGB(0xF7EFDB);
|
|
}
|
|
return color;
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (void)setSkillInfo:(MineSkillCardListInfoModel *)skillInfo {
|
|
_skillInfo = skillInfo;
|
|
if (_skillInfo) {
|
|
self.logoImageView.imageUrl = _skillInfo.icon;
|
|
NSString * title = [_skillInfo.propVals componentsJoinedByString:@"/"];
|
|
self.skillLabel.text = title;
|
|
self.titleLabel.text = _skillInfo.name;
|
|
self.backView.backgroundColor = [self getSkillCardBackColor:skillInfo.cardId];
|
|
}
|
|
}
|
|
|
|
- (NetImageView *)logoImageView {
|
|
if (!_logoImageView) {
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
config.imageType = ImageTypeUserIcon;
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
_logoImageView = [[NetImageView alloc] initWithConfig:config];
|
|
}
|
|
return _logoImageView;
|
|
}
|
|
|
|
- (UIView *)backView {
|
|
if (!_backView) {
|
|
_backView = [[UIView alloc] init];
|
|
_backView.backgroundColor = UIColorFromRGB(0xFEF5E8);
|
|
_backView.layer.masksToBounds = YES;
|
|
_backView.layer.cornerRadius = 8;
|
|
}
|
|
return _backView;
|
|
}
|
|
|
|
- (UILabel *)titleLabel {
|
|
if (!_titleLabel) {
|
|
_titleLabel = [[UILabel alloc] init];
|
|
_titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
|
|
_titleLabel.textColor = [DJDKMIMOMColor mainTextColor];
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
|
|
- (UILabel *)skillLabel {
|
|
if (!_skillLabel) {
|
|
_skillLabel = [[UILabel alloc] init];
|
|
_skillLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
|
|
_skillLabel.textColor = [DJDKMIMOMColor mainTextColor];
|
|
}
|
|
return _skillLabel;
|
|
}
|
|
|
|
|
|
|
|
@end
|