2023-07-14 18:50:55 +08:00
|
|
|
//
|
|
|
|
// YMMineFriendTableViewCell.m
|
|
|
|
// YUMI
|
|
|
|
//
|
|
|
|
// Created by YUMI on 2021/12/21.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "XPMineFriendTableViewCell.h"
|
|
|
|
///Third
|
|
|
|
#import <Masonry/Masonry.h>
|
|
|
|
///Tool
|
|
|
|
#import "NetImageConfig.h"
|
|
|
|
#import "NetImageView.h"
|
|
|
|
#import "DJDKMIMOMColor.h"
|
|
|
|
#import "UIImage+Utils.h"
|
|
|
|
///Model
|
|
|
|
#import "UserInfoModel.h"
|
|
|
|
|
|
|
|
@interface XPMineFriendTableViewCell ()
|
|
|
|
///头像
|
|
|
|
@property (nonatomic,strong) NetImageView *avatarImageView;
|
|
|
|
///容器
|
|
|
|
@property (nonatomic,strong) UIStackView *stackView;
|
|
|
|
///昵称
|
|
|
|
@property (nonatomic,strong) UILabel *nickLabel;
|
|
|
|
///性别
|
2023-09-20 17:34:12 +08:00
|
|
|
@property (nonatomic,strong) UIButton *sexImageView;
|
2023-07-14 18:50:55 +08:00
|
|
|
///等级
|
|
|
|
@property (nonatomic,strong) NetImageView *experImageView;
|
|
|
|
///魅力等级
|
|
|
|
@property (nonatomic,strong) NetImageView *charmImageView;
|
|
|
|
///签名
|
|
|
|
@property (nonatomic,strong) UILabel *signLabel;
|
|
|
|
///分割线
|
|
|
|
@property (nonatomic,strong) UIView *lineView;
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation XPMineFriendTableViewCell
|
|
|
|
- (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.contentView addSubview:self.avatarImageView];
|
|
|
|
[self.contentView addSubview:self.stackView];
|
|
|
|
[self.contentView addSubview:self.signLabel];
|
|
|
|
[self.contentView addSubview:self.lineView];
|
|
|
|
|
|
|
|
[self.stackView addArrangedSubview:self.nickLabel];
|
|
|
|
[self.stackView addArrangedSubview:self.sexImageView];
|
|
|
|
[self.stackView addArrangedSubview:self.experImageView];
|
|
|
|
[self.stackView addArrangedSubview:self.charmImageView];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)initSubViewConstraints {
|
|
|
|
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.size.mas_equalTo(CGSizeMake(55, 55));
|
|
|
|
make.centerY.mas_equalTo(self.contentView);
|
|
|
|
make.left.mas_equalTo(self.contentView).offset(15);
|
|
|
|
}];
|
|
|
|
|
|
|
|
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.mas_equalTo(self.avatarImageView.mas_right).offset(10);
|
|
|
|
make.bottom.mas_equalTo(self.avatarImageView.mas_centerY).offset(-2);
|
|
|
|
}];
|
|
|
|
|
|
|
|
[self.signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.mas_equalTo(self.stackView);
|
|
|
|
make.top.mas_equalTo(self.avatarImageView.mas_centerY).offset(2);
|
|
|
|
}];
|
2023-09-20 17:34:12 +08:00
|
|
|
[self.sexImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.width.mas_equalTo(28);
|
|
|
|
make.height.mas_equalTo(14);
|
|
|
|
}];
|
2023-07-14 18:50:55 +08:00
|
|
|
[self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.mas_equalTo(self.stackView);
|
|
|
|
make.bottom.mas_equalTo(self.contentView);
|
|
|
|
make.height.mas_equalTo(1);
|
|
|
|
make.right.mas_equalTo(self.contentView).offset(-15);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Getters And Setters
|
|
|
|
- (void)setUserInfo:(UserInfoModel *)userInfo {
|
|
|
|
_userInfo = userInfo;
|
|
|
|
if (_userInfo) {
|
|
|
|
self.avatarImageView.imageUrl = _userInfo.avatar;
|
2023-08-16 14:21:58 +08:00
|
|
|
NSString *text = _userInfo.nick.length > 5 ? [NSString stringWithFormat:@"%@...",[_userInfo.nick substringToIndex:5]]:_userInfo.nick;
|
|
|
|
self.nickLabel.text = text;
|
2023-07-14 18:50:55 +08:00
|
|
|
self.signLabel.text = _userInfo.userDesc && _userInfo.userDesc.length > 0? _userInfo.userDesc : YMLocalizedString(@"XPMineFriendTableViewCell0");
|
|
|
|
if (self.isInRoom) {
|
|
|
|
self.experImageView.hidden = NO;
|
|
|
|
self.charmImageView.hidden = NO;
|
|
|
|
self.experImageView.imageUrl = _userInfo.userLevelVo.experUrl;
|
|
|
|
self.charmImageView.imageUrl = _userInfo.userLevelVo.charmUrl;
|
2023-09-20 17:34:12 +08:00
|
|
|
|
|
|
|
[self.sexImageView setTitle:[NSString getAgeWithBirth:_userInfo.birth] forState:UIControlStateNormal];
|
|
|
|
self.sexImageView.backgroundColor = _userInfo.gender == GenderType_Male ? UIColorFromRGB(0x6BB3FF) :UIColorFromRGB(0xFF80CC);
|
2023-07-14 18:50:55 +08:00
|
|
|
UIImage* image = self.experImageView.image;
|
|
|
|
if (image) {
|
|
|
|
CGFloat scale = image.size.width / image.size.height;
|
|
|
|
[self.experImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.size.mas_equalTo(CGSizeMake(20* scale, 20));
|
|
|
|
}];
|
|
|
|
} else {
|
|
|
|
NSURL *imgUrl = [NSURL URLWithString:_userInfo.userLevelVo.experUrl];
|
|
|
|
UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
|
|
|
|
CGFloat scale = myImage.size.width / myImage.size.height;
|
|
|
|
[self.experImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.size.mas_equalTo(CGSizeMake(20* scale, 20));
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
UIImage* charmImage = self.charmImageView.image;
|
|
|
|
if (charmImage) {
|
|
|
|
CGFloat scale = charmImage.size.width / charmImage.size.height;
|
|
|
|
[self.charmImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.size.mas_equalTo(CGSizeMake(20* scale, 20));
|
|
|
|
}];
|
|
|
|
} else {
|
|
|
|
NSURL *imgUrl = [NSURL URLWithString:_userInfo.userLevelVo.charmUrl];
|
|
|
|
UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
|
|
|
|
CGFloat scale = myImage.size.width / myImage.size.height;
|
|
|
|
[self.charmImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.size.mas_equalTo(CGSizeMake(20* scale, 20));
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
self.experImageView.hidden = YES;
|
|
|
|
self.charmImageView.hidden = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NetImageView *)avatarImageView {
|
|
|
|
if (!_avatarImageView) {
|
|
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
|
|
config.imageType = ImageTypeUserIcon;
|
|
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
|
|
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
|
|
|
|
_avatarImageView.layer.masksToBounds = YES;
|
|
|
|
_avatarImageView.layer.cornerRadius = 55/2;
|
|
|
|
}
|
|
|
|
return _avatarImageView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UIStackView *)stackView {
|
|
|
|
if (!_stackView) {
|
|
|
|
_stackView = [[UIStackView alloc] init];
|
|
|
|
_stackView.axis = UILayoutConstraintAxisHorizontal;
|
|
|
|
_stackView.distribution = UIStackViewDistributionFill;
|
|
|
|
_stackView.alignment = UIStackViewAlignmentCenter;
|
|
|
|
_stackView.spacing = 10;
|
|
|
|
}
|
|
|
|
return _stackView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UILabel *)nickLabel {
|
|
|
|
if (!_nickLabel) {
|
|
|
|
_nickLabel = [[UILabel alloc] init];
|
|
|
|
_nickLabel.font = [UIFont systemFontOfSize:15];
|
|
|
|
_nickLabel.textColor = [DJDKMIMOMColor mainTextColor];
|
|
|
|
}
|
|
|
|
return _nickLabel;
|
|
|
|
}
|
|
|
|
|
2023-09-20 17:34:12 +08:00
|
|
|
- (UIButton *)sexImageView {
|
2023-07-14 18:50:55 +08:00
|
|
|
if (!_sexImageView) {
|
2023-09-20 17:34:12 +08:00
|
|
|
_sexImageView = [[UIButton alloc] init];
|
|
|
|
[_sexImageView setImage:kImage(@"home_age_boy_icon") forState:UIControlStateNormal];
|
|
|
|
[_sexImageView setImage:kImage(@"home_age_girl_icon") forState:UIControlStateSelected];
|
|
|
|
_sexImageView.titleLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightMedium];
|
|
|
|
[_sexImageView setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
|
|
_sexImageView.imageEdgeInsets = UIEdgeInsetsMake(0, 2, 0, 0);
|
|
|
|
_sexImageView.layer.cornerRadius = 14/2;
|
|
|
|
_sexImageView.layer.masksToBounds = YES;
|
2023-07-14 18:50:55 +08:00
|
|
|
}
|
|
|
|
return _sexImageView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NetImageView *)experImageView {
|
|
|
|
if (!_experImageView) {
|
|
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
|
|
_experImageView = [[NetImageView alloc] initWithConfig:config];
|
|
|
|
}
|
|
|
|
return _experImageView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NetImageView *)charmImageView {
|
|
|
|
if (!_charmImageView) {
|
|
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
|
|
_charmImageView = [[NetImageView alloc] initWithConfig:config];
|
|
|
|
}
|
|
|
|
return _charmImageView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UILabel *)signLabel{
|
|
|
|
if (!_signLabel) {
|
|
|
|
_signLabel = [[UILabel alloc] init];
|
|
|
|
_signLabel.textColor = [DJDKMIMOMColor secondTextColor];
|
|
|
|
_signLabel.font = [UIFont systemFontOfSize:12];
|
|
|
|
}
|
|
|
|
return _signLabel;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UIView *)lineView {
|
|
|
|
if (!_lineView) {
|
|
|
|
_lineView = [[UIView alloc] init];
|
|
|
|
_lineView.backgroundColor = [DJDKMIMOMColor dividerColor];
|
|
|
|
}
|
|
|
|
return _lineView;
|
|
|
|
}
|
|
|
|
@end
|