117 lines
3.6 KiB
Objective-C
117 lines
3.6 KiB
Objective-C
//
|
|
// YMRoomInsideRecommendCell.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2022/4/28.
|
|
//
|
|
|
|
#import "XPRoomInsideRecommendCell.h"
|
|
#import "NetImageView.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "YUMIMacroUitls.h"
|
|
#import "DJDKMIMOMColor.h"
|
|
|
|
@interface XPRoomInsideRecommendCell ()
|
|
|
|
///头像
|
|
@property (nonatomic, strong) NetImageView *avatarImageView;
|
|
///显示名字
|
|
@property (nonatomic,strong) UILabel *nickLabel;
|
|
///标签
|
|
@property (nonatomic,strong) NetImageView *tagImageView;
|
|
|
|
@end
|
|
|
|
@implementation XPRoomInsideRecommendCell
|
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
|
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
self.backgroundColor = [UIColor clearColor];
|
|
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
[self addSubview:self.avatarImageView];
|
|
[self addSubview:self.nickLabel];
|
|
[self addSubview:self.tagImageView];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(12);
|
|
make.leading.mas_equalTo(15);
|
|
make.width.height.mas_equalTo(72);
|
|
}];
|
|
[self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self.avatarImageView).mas_offset(12);
|
|
make.leading.mas_equalTo(self.avatarImageView.mas_trailing).mas_offset(7);
|
|
make.height.mas_equalTo(14);
|
|
make.trailing.mas_equalTo(0);
|
|
}];
|
|
[self.tagImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(self.nickLabel);
|
|
make.top.mas_equalTo(self.nickLabel.mas_bottom).mas_offset(12);
|
|
make.width.mas_equalTo(43);
|
|
make.height.mas_equalTo(18);
|
|
}];
|
|
}
|
|
#pragma mark - Getters And Setters
|
|
- (void)setModel:(XPRoomRecommendModel *)model {
|
|
_model = model;
|
|
self.avatarImageView.imageUrl = model.avatar;
|
|
self.nickLabel.text = model.title;
|
|
self.tagImageView.hidden = [NSString isEmpty:model.tagPict];
|
|
if (! [NSString isEmpty:model.tagPict]) {
|
|
@kWeakify(self);
|
|
[self.tagImageView loadImageWithUrl:model.tagPict completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
|
|
@kStrongify(self);
|
|
if (image) {
|
|
self.tagImageView.image = image;
|
|
[self.tagImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(image.size.width/image.size.height * 18);
|
|
}];
|
|
[self layoutIfNeeded];
|
|
}
|
|
}];
|
|
}
|
|
}
|
|
|
|
- (NetImageView *)avatarImageView {
|
|
if (!_avatarImageView) {
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
|
|
_avatarImageView.layer.masksToBounds = YES;
|
|
_avatarImageView.layer.cornerRadius = 8;
|
|
}
|
|
return _avatarImageView;
|
|
}
|
|
|
|
- (NetImageView *)tagImageView {
|
|
if (!_tagImageView) {
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
_tagImageView = [[NetImageView alloc] initWithConfig:config];
|
|
}
|
|
return _tagImageView;
|
|
}
|
|
|
|
- (UILabel *)nickLabel {
|
|
if (!_nickLabel) {
|
|
_nickLabel = [[UILabel alloc] init];
|
|
_nickLabel.font = [UIFont boldSystemFontOfSize:14];
|
|
_nickLabel.textColor = [UIColor whiteColor];
|
|
}
|
|
return _nickLabel;
|
|
}
|
|
|
|
|
|
@end
|