Files
yinmeng-ios/xplan-ios/Main/Room/View/Sailing/View/Cell/XPSailingRankTableViewCell.m
2022-08-12 18:58:10 +08:00

154 lines
4.5 KiB
Objective-C

//
// XPSailingRankTableViewCell.m
// xplan-ios
//
// Created by 冯硕 on 2022/8/12.
//
#import "XPSailingRankTableViewCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "ThemeColor.h"
#import "NetImageView.h"
@interface XPSailingRankTableViewCell ()
///背景
@property (nonatomic,strong) UIView * backView;
///排名
@property (nonatomic,strong) UIButton *rankButton;
///头像
@property (nonatomic,strong) NetImageView *avatarImageView;
///昵称
@property (nonatomic,strong) UILabel *nickLabel;
///钻石
@property (nonatomic,strong) UILabel *coinLabel;
///钻石
@property (nonatomic,strong) UIImageView *diamondImageView;
@end
@implementation XPSailingRankTableViewCell
- (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.backView];
[self.backView addSubview:self.rankButton];
[self.backView addSubview:self.avatarImageView];
[self.backView addSubview:self.nickLabel];
[self.backView addSubview:self.diamondImageView];
[self.backView addSubview:self.coinLabel];
}
- (void)initSubViewConstraints {
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.contentView).inset(15);
make.top.mas_equalTo(self.contentView);
make.height.mas_equalTo(60);
}];
[self.rankButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(29, 20));
make.left.mas_equalTo(self.backView).offset(15);
make.centerY.mas_equalTo(self.backView);
}];
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(50, 50));
make.centerY.mas_equalTo(self.backView);
make.left.mas_equalTo(self.rankButton.mas_right).offset(24);
}];
[self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.avatarImageView.mas_right);
make.centerY.mas_equalTo(self.nickLabel);
make.right.mas_lessThanOrEqualTo(self.diamondImageView.mas_left).offset(-5);
}];
[self.diamondImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(14, 12));
make.centerY.mas_equalTo(self.backView);
make.right.mas_equalTo(self.coinLabel.mas_left).offset(-2);
}];
[self.coinLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.backView).offset(-10);
make.centerY.mas_equalTo(self.backView);
}];
}
#pragma mark - Getters And Setters
- (UIView *)backView {
if (!_backView) {
_backView = [[UIView alloc] init];
_backView.backgroundColor = [ThemeColor colorWithHexString:@"#F9F0D9"];
_backView.layer.masksToBounds = YES;
_backView.layer.cornerRadius = 6;
}
return _backView;
}
- (UIButton *)rankButton {
if (!_rankButton) {
_rankButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_rankButton setTitle:@"1" forState:UIControlStateNormal];
[_rankButton setTitleColor:[ThemeColor colorWithHexString:@"#CFAD79"] forState:UIControlStateNormal];
_rankButton.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
}
return _rankButton;
}
- (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 = 50/2;
}
return _avatarImageView;
}
- (UILabel *)nickLabel {
if (!_nickLabel) {
_nickLabel = [[UILabel alloc] init];
_nickLabel.font = [UIFont systemFontOfSize:12];
_nickLabel.textColor = [ThemeColor colorWithHexString:@"#A08161"];
}
return _nickLabel;
}
- (UIImageView *)diamondImageView {
if (!_diamondImageView) {
_diamondImageView = [[UIImageView alloc] init];
_diamondImageView.userInteractionEnabled = YES;
_diamondImageView.image = [UIImage imageNamed:@"common_diamond"];
}
return _diamondImageView;
}
- (UILabel *)coinLabel {
if (!_coinLabel) {
_coinLabel = [[UILabel alloc] init];
_coinLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
_coinLabel.textColor = [ThemeColor colorWithHexString:@"#64472E"];
}
return _coinLabel;
}
@end