257 lines
9.0 KiB
Objective-C
257 lines
9.0 KiB
Objective-C
//
|
||
// YMMineVisitorTableViewCell.m
|
||
// YUMI
|
||
//
|
||
// Created by YUMI on 2022/1/26.
|
||
//
|
||
|
||
#import "XPMineVisitorTableViewCell.h"
|
||
///Third
|
||
#import <Masonry/Masonry.h>
|
||
///Tool
|
||
#import "DJDKMIMOMColor.h"
|
||
#import "NetImageView.h"
|
||
#import "XPMineVisitorItemModel.h"
|
||
#import "UserInfoModel.h"
|
||
|
||
@interface XPMineVisitorTableViewCell()
|
||
|
||
@property (nonatomic ,strong) NetImageView *avaterImgView;
|
||
@property(nonatomic, strong) UIStackView *nameStackView;
|
||
@property (nonatomic, strong) UIImageView *genderImageView;
|
||
@property (nonatomic, strong) UILabel *nickLabel;
|
||
@property(nonatomic, strong) NetImageView *regionImageView;
|
||
@property(nonatomic, strong) NetImageView *charmImageView;
|
||
@property(nonatomic, strong) NetImageView *experImageView;
|
||
@property(nonatomic, strong) NetImageView *nameplateImageView;
|
||
|
||
@property (nonatomic ,strong) UILabel *memberIdLabel;
|
||
@property (nonatomic ,strong) UILabel *timeLabel;
|
||
|
||
@end
|
||
|
||
@implementation XPMineVisitorTableViewCell
|
||
|
||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
||
[self setUpUI];
|
||
[self setUpConstraints];
|
||
}
|
||
return self;
|
||
}
|
||
|
||
#pragma mark - lifeCycle
|
||
- (void)setUpUI {
|
||
self.backgroundColor = [UIColor clearColor];
|
||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||
|
||
[self.contentView addSubview:self.avaterImgView];
|
||
|
||
UIView *spaceView = [[UIView alloc] init];
|
||
_nameStackView = [[UIStackView alloc] initWithArrangedSubviews:@[
|
||
self.nickLabel,
|
||
self.genderImageView,
|
||
self.regionImageView,
|
||
self.charmImageView,
|
||
self.experImageView,
|
||
self.nameplateImageView,
|
||
spaceView
|
||
]];
|
||
_nameStackView.spacing = 4;
|
||
_nameStackView.alignment = UIStackViewAlignmentCenter;
|
||
_nameStackView.distribution = UIStackViewDistributionFill;
|
||
[self.contentView addSubview:self.nameStackView];
|
||
|
||
|
||
[self.contentView addSubview:self.memberIdLabel];
|
||
[self.contentView addSubview:self.timeLabel];
|
||
}
|
||
|
||
#pragma mark - Constraints
|
||
- (void)setUpConstraints {
|
||
[self.avaterImgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.mas_equalTo(25);
|
||
make.leading.mas_equalTo(15);
|
||
make.width.height.mas_equalTo(56);
|
||
}];
|
||
|
||
[self.nameStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.mas_equalTo(self.avaterImgView).offset(-4);
|
||
make.leading.mas_equalTo(self.avaterImgView.mas_trailing).offset(6);
|
||
make.trailing.mas_equalTo(-8);
|
||
make.height.mas_equalTo(22);
|
||
}];
|
||
|
||
[self.genderImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.height.mas_equalTo(14);
|
||
make.width.mas_equalTo(14);
|
||
}];
|
||
[self.regionImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.height.mas_equalTo(14);
|
||
make.width.mas_equalTo(18);
|
||
}];
|
||
[self.charmImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.height.mas_equalTo(18);
|
||
make.width.mas_equalTo(40);
|
||
}];
|
||
[self.experImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.height.mas_equalTo(18);
|
||
make.width.mas_equalTo(40);
|
||
}];
|
||
[self.nameplateImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.height.mas_equalTo(18);
|
||
make.width.mas_equalTo(40);
|
||
}];
|
||
|
||
[self.memberIdLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.centerY.mas_equalTo(self.avaterImgView);
|
||
make.leading.mas_equalTo(self.nameStackView);
|
||
}];
|
||
|
||
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.leading.mas_equalTo(self.nameStackView);
|
||
make.bottom.mas_equalTo(self.avaterImgView);
|
||
}];
|
||
}
|
||
|
||
#pragma mark - event
|
||
- (void)onChatButtonClick:(UIButton *)sender {
|
||
if (self.delegate && [self.delegate respondsToSelector:@selector(onChatClick:)]) {
|
||
[self.delegate onChatClick:self];
|
||
}
|
||
}
|
||
|
||
- (void)onCliekAvatar:(UITapGestureRecognizer *)ges {
|
||
if (self.delegate && [self.delegate respondsToSelector:@selector(onAvatarClick:)]) {
|
||
[self.delegate onAvatarClick:self];
|
||
}
|
||
}
|
||
|
||
/** 最后一个数据 配置圆角 */
|
||
- (void)setIsFirstItem:(BOOL)isFirstItem{
|
||
_isFirstItem = isFirstItem;
|
||
}
|
||
|
||
- (void)setIsLastItem:(BOOL)isLastItem {
|
||
_isLastItem = isLastItem;
|
||
}
|
||
|
||
- (void)setItem:(UserInfoModel *)item {
|
||
_item = item;
|
||
self.nickLabel.text = item.nick;
|
||
self.avaterImgView.imageUrl = item.avatar;
|
||
self.memberIdLabel.text = [NSString stringWithFormat:@"ID:%zd", item.erbanNo];
|
||
self.timeLabel.text = [NSString stringWithFormat:YMLocalizedString(@"20.20.51_text_28"), item.visitTimeDesc];
|
||
[self.genderImageView setImage:item.gender == GenderType_Male ? kImage(@"common_male") : kImage(@"common_female")];
|
||
#if DEBUG
|
||
item.regionIcon = @"";
|
||
#endif
|
||
self.regionImageView.imageUrl = item.regionIcon;
|
||
self.regionImageView.hidden = [NSString isEmpty:item.regionIcon];
|
||
|
||
if (item.userLevelVo) {
|
||
self.experImageView.hidden = NO;
|
||
self.charmImageView.hidden = NO;
|
||
self.experImageView.imageUrl = item.userLevelVo.experUrl;
|
||
self.charmImageView.imageUrl = item.userLevelVo.charmUrl;
|
||
}else {
|
||
self.experImageView.hidden = YES;
|
||
self.charmImageView.hidden = YES;
|
||
}
|
||
|
||
if (item.userVipInfoVO) {
|
||
self.nameplateImageView.hidden = NO;
|
||
self.nameplateImageView.imageUrl = item.userVipInfoVO.nameplateUrl;
|
||
}else {
|
||
self.nameplateImageView.hidden = YES;
|
||
}
|
||
}
|
||
|
||
- (NetImageView *)avaterImgView {
|
||
if (!_avaterImgView) {
|
||
_avaterImgView = [[NetImageView alloc] init];
|
||
_avaterImgView.contentMode = UIViewContentModeScaleAspectFill;
|
||
[_avaterImgView setCornerRadius:56/2];
|
||
}
|
||
return _avaterImgView;
|
||
}
|
||
- (NetImageView *)regionImageView {
|
||
if (!_regionImageView) {
|
||
_regionImageView = [[NetImageView alloc] init];
|
||
_regionImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||
[_regionImageView setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||
[_regionImageView setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||
}
|
||
return _regionImageView;
|
||
}
|
||
- (NetImageView *)charmImageView {
|
||
if (!_charmImageView) {
|
||
_charmImageView = [[NetImageView alloc] init];
|
||
_charmImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||
[_charmImageView setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||
[_charmImageView setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||
}
|
||
return _charmImageView;
|
||
}
|
||
- (NetImageView *)experImageView {
|
||
if (!_experImageView) {
|
||
_experImageView = [[NetImageView alloc] init];
|
||
_experImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||
[_experImageView setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||
[_experImageView setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||
}
|
||
return _experImageView;
|
||
}
|
||
- (NetImageView *)nameplateImageView {
|
||
if (!_nameplateImageView) {
|
||
_nameplateImageView = [[NetImageView alloc] init];
|
||
_nameplateImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||
[_nameplateImageView setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||
[_nameplateImageView setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
||
}
|
||
return _nameplateImageView;
|
||
}
|
||
|
||
- (UILabel *)nickLabel {
|
||
if (!_nickLabel) {
|
||
_nickLabel = [[UILabel alloc] init];
|
||
_nickLabel.textColor = UIColorFromRGB(0x333333);
|
||
_nickLabel.font = [UIFont systemFontOfSize:13];
|
||
_nickLabel.text = YMLocalizedString(@"XPMineVisitorTableViewCell0");
|
||
_nickLabel.translatesAutoresizingMaskIntoConstraints = NO;
|
||
[_nickLabel setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
|
||
[_nickLabel setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
|
||
}
|
||
return _nickLabel;
|
||
}
|
||
|
||
- (UIImageView *)genderImageView {
|
||
if (!_genderImageView) {
|
||
_genderImageView = [[UIImageView alloc] init];
|
||
_genderImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||
}
|
||
return _genderImageView;
|
||
}
|
||
|
||
- (UILabel *)memberIdLabel {
|
||
if (!_memberIdLabel) {
|
||
_memberIdLabel = [[UILabel alloc] init];
|
||
_memberIdLabel.textColor = UIColorFromRGB(0x7b7b7d);
|
||
_memberIdLabel.font = kFontRegular(13);
|
||
_memberIdLabel.text = @"";
|
||
}
|
||
return _memberIdLabel;
|
||
}
|
||
|
||
- (UILabel *)timeLabel {
|
||
if (!_timeLabel) {
|
||
_timeLabel = [[UILabel alloc] init];
|
||
_timeLabel.text = @"";
|
||
_timeLabel.textColor = UIColorFromRGB(0x7b7b7d);
|
||
_timeLabel.font = kFontRegular(13);
|
||
}
|
||
return _timeLabel;
|
||
}
|
||
|
||
@end
|