Files
peko-ios/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnchorRankBannerView.m

181 lines
5.4 KiB
Mathematica
Raw Normal View History

2023-07-14 18:50:55 +08:00
//
// YMRoomAnchorRankBannerView.m
// YUMI
//
// Created by YUMI on 2022/4/15.
//
#import "XPRoomAnchorRankBannerView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "ThemeColor+Room.h"
#import "DJDKMIMOMColor.h"
///Model
#import "RoomHalfHourRankModel.h"
///View
#import "NetImageView.h"
@interface XPRoomAnchorRankBannerView()
///
@property (nonatomic,strong) UIImageView *bgImageView;
///icon
@property (nonatomic,strong) UIImageView *iconImageView;
///
@property (nonatomic,strong) NetImageView *avatImageView;
///
@property (nonatomic,strong) UILabel *titleLabel;
///
@property (nonatomic,strong) UILabel *nickLabel;
///
@property (nonatomic, strong) UILabel *descLabel;
///
@property (nonatomic, strong) UILabel *rankLabel;
@end
@implementation XPRoomAnchorRankBannerView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.bgImageView];
[self addSubview:self.iconImageView];
[self addSubview:self.titleLabel];
[self addSubview:self.avatImageView];
[self addSubview:self.nickLabel];
[self addSubview:self.descLabel];
[self addSubview:self.rankLabel];
}
- (void)initSubViewConstraints {
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.centerY.mas_equalTo(self);
make.width.mas_equalTo(360);
make.height.mas_equalTo(50);
}];
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.bgImageView).mas_offset(-14);
make.centerY.mas_equalTo(self);
make.width.mas_equalTo(61);
make.height.mas_equalTo(60);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.iconImageView.mas_right).mas_offset(3);
make.centerY.mas_equalTo(self.bgImageView).mas_offset(2);
}];
[self.avatImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.titleLabel.mas_right).mas_offset(3);
make.centerY.mas_equalTo(self.titleLabel);
make.width.height.mas_equalTo(22);
}];
[self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.avatImageView.mas_right).mas_offset(3);
make.centerY.mas_equalTo(self.titleLabel);
}];
[self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nickLabel.mas_right).mas_offset(3);
make.centerY.mas_equalTo(self.titleLabel);
}];
[self.rankLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.descLabel.mas_right);
make.centerY.mas_equalTo(self.titleLabel);
}];
}
- (void)setAnchorRankInfo:(RoomHalfHourRankModel *)anchorRankInfo {
_anchorRankInfo = anchorRankInfo;
if (anchorRankInfo) {
self.avatImageView.imageUrl = _anchorRankInfo.avatar;
NSString *nick = _anchorRankInfo.nick;
if(nick.length > 4) {
nick = [NSString stringWithFormat:@"%@…", [nick substringToIndex:4]];
}
self.nickLabel.text = nick;
self.descLabel.text = _anchorRankInfo.desc;
}
}
#pragma mark - Getters And Setters
- (UIImageView *)bgImageView {
if (!_bgImageView) {
_bgImageView = [[UIImageView alloc] init];
_bgImageView.image = [UIImage imageNamed:@"anchor_hour_rank_bg"];
}
return _bgImageView;
}
- (UIImageView *)iconImageView {
if (!_iconImageView) {
_iconImageView = [[UIImageView alloc] init];
_iconImageView.image = [UIImage imageNamed:@"anchor_hour_rank_icon"];
}
return _iconImageView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:13 weight:UIFontWeightBold];
label.textColor = [UIColor whiteColor];
label.text = YMLocalizedString(@"XPRoomAnchorRankBannerView0");
_titleLabel = label;
}
return _titleLabel;
}
- (NetImageView *)avatImageView {
if (!_avatImageView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.imageType = ImageTypeUserIcon;
_avatImageView = [[NetImageView alloc] initWithConfig:config];
_avatImageView.layer.masksToBounds = YES;
_avatImageView.layer.cornerRadius = 11;
}
return _avatImageView;
}
- (UILabel *)nickLabel {
if (!_nickLabel) {
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:13 weight:UIFontWeightBold];
label.textColor = UIColorFromRGB(0xFFFC2C);
_nickLabel = label;
}
return _nickLabel;
}
- (UILabel *)descLabel {
if (!_descLabel) {
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:13 weight:UIFontWeightHeavy];
label.textColor = [UIColor whiteColor];
_descLabel = label;
}
return _descLabel;
}
- (UILabel *)rankLabel {
if (!_rankLabel) {
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:13 weight:UIFontWeightHeavy];
label.textColor = UIColorFromRGB(0xFFFC2C);
label.text = @"TOP1";
_rankLabel = label;
}
return _rankLabel;
}
@end