Files
peko-ios/YuMi/Modules/YMMine/View/Cell/MineInfo/XPMineGuildTableViewCell.m
2024-09-23 20:35:29 +08:00

122 lines
4.1 KiB
Objective-C

//
// XPMineGuildTableViewCell.m
// YuMi
//
// Created by P on 2024/9/19.
//
#import "XPMineGuildTableViewCell.h"
#import "GuildInfo.h"
@interface XPMineGuildTableViewCell ()
@property (nonatomic, strong) NetImageView *avatarImageView;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *guildIDLabel;
@property (nonatomic, strong) UILabel *agentIDLabel;
@end
@implementation XPMineGuildTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.backgroundColor = [UIColor clearColor];
self.contentView.backgroundColor = [UIColor clearColor];
[self setupUI];
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
}
- (void)setupUI {
UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:kImage(@"user_guild_bg")];
[self.contentView addSubview:backgroundImageView];
[backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.leading.trailing.mas_equalTo(self.contentView);
make.height.mas_equalTo(kGetScaleWidth(85));
}];
[self.contentView addSubview:self.avatarImageView];
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(backgroundImageView);
make.leading.mas_equalTo(self.contentView).offset(12);
make.width.height.mas_equalTo(kGetScaleWidth(62));
}];
UIStackView *stack = [[UIStackView alloc] init];
stack.axis = UILayoutConstraintAxisVertical;
stack.spacing = 3;
stack.alignment = UIStackViewAlignmentLeading;
[self.contentView addSubview:stack];
[stack mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.avatarImageView.mas_trailing).offset(12);
make.top.bottom.mas_equalTo(self.avatarImageView);
make.trailing.mas_equalTo(self.contentView).offset(-12);
}];
[stack addArrangedSubview:self.nameLabel];
[stack addArrangedSubview:self.guildIDLabel];
[stack addArrangedSubview:self.agentIDLabel];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(20);
}];
[self.guildIDLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(18);
}];
[self.agentIDLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(18);
}];
}
- (void)setInfo:(GuildInfo *)info {
_info = info;
self.avatarImageView.imageUrl = info.avatar;
self.nameLabel.text = [NSString stringWithFormat:@"%@%@", YMLocalizedString(@"UserDetail_1"), info.guildName];
self.guildIDLabel.text = [NSString stringWithFormat:@"%@%ld", YMLocalizedString(@"UserDetail_2"), (long)info.guildId];
self.agentIDLabel.text = [NSString stringWithFormat:@"%@%ld", YMLocalizedString(@"UserDetail_3"), (long)info.erbanNo];
}
#pragma mark -
- (NetImageView *)avatarImageView {
if (!_avatarImageView) {
_avatarImageView = [[NetImageView alloc] init];
_avatarImageView.layer.cornerRadius = 8;
_avatarImageView.layer.borderColor = UIColorFromRGB(0xFFEEAC).CGColor;
_avatarImageView.layer.borderWidth = 1;
_avatarImageView.layer.masksToBounds = YES;
}
return _avatarImageView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [UILabel labelInitWithText:@"" font:kFontMedium(14) textColor:[UIColor whiteColor]];
}
return _nameLabel;
}
- (UILabel *)guildIDLabel {
if (!_guildIDLabel) {
_guildIDLabel = [UILabel labelInitWithText:@"" font:kFontMedium(13) textColor:[UIColor colorWithWhite:1 alpha:0.6]];
}
return _guildIDLabel;
}
- (UILabel *)agentIDLabel {
if (!_agentIDLabel) {
_agentIDLabel = [UILabel labelInitWithText:@"" font:kFontMedium(13) textColor:[UIColor colorWithWhite:1 alpha:0.6]];
}
return _agentIDLabel;
}
@end