Files
midi_ios/QXLive/HomePage(声播)/View/首页/排行榜/QXMyRankView.m
2025-08-14 10:07:49 +08:00

144 lines
6.3 KiB
Objective-C

//
// QXMyRankView.m
// IsLandVoice
//
// Created by 启星 on 2025/3/4.
//
#import "QXMyRankView.h"
@interface QXMyRankView()
{
CGRect tmpRect;
}
@end
@implementation QXMyRankView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self = [[[NSBundle mainBundle]loadNibNamed:@"QXMyRankView" owner:nil options:nil] lastObject];
tmpRect = frame;
self.frame = frame;
}
return self;
}
-(void)setIsCP:(BOOL)isCP{
_isCP = isCP;
self.headerImageView1.hidden = !isCP;
self.headerImageView2.hidden = !isCP;
self.allNickNameLabel.hidden = !isCP;
self.headerImageViewBG.hidden = !isCP;
self.headerImageView.hidden = isCP;
self.nickNameLabel.hidden = isCP;
self.valueLabel.hidden = isCP;
self.valueBGImageView.hidden = isCP;
}
-(void)setModel:(QXMyRankModel *)model{
_model = model;
self.nickNameLabel.text = model.nickname;
if (model.rank.intValue <= 0) {
self.rankResultLabel.text = @"暂未上榜";
}else{
NSString *s = [NSString stringWithFormat:@"第%@名",model.rank];
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:s];
[attr yy_setColor:[UIColor colorWithHexString:@"#FF8ACC"] range:NSMakeRange(1, model.rank.length)];
self.rankResultLabel.attributedText = attr;
}
[self.headerImageView sd_setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage:[UIImage imageNamed:@"user_header_placehoulder"]];
self.valueLabel.text = model.total;
NSString *diff = model.diff;
NSString *s1 = [NSString stringWithFormat:@"距离上一名差%@",diff];
NSMutableAttributedString *attr1 = [[NSMutableAttributedString alloc] initWithString:s1];
[attr1 yy_setColor:[UIColor colorWithHexString:@"#FF8ACC"] range:NSMakeRange(6, diff.length)];
self.needLabel.attributedText = attr1;
}
-(void)setRoomModel:(QXMyRankModel *)roomModel{
_roomModel = roomModel;
self.nickNameLabel.text = roomModel.room_name;
if (roomModel.rank.intValue <= 0) {
self.rankResultLabel.text = @"暂未上榜";
}else{
NSString *s = [NSString stringWithFormat:@"第%@名",roomModel.rank];
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:s];
[attr yy_setColor:[UIColor colorWithHexString:@"#FF8ACC"] range:NSMakeRange(1, roomModel.rank.length)];
self.rankResultLabel.attributedText = attr;
}
[self.headerImageView sd_setImageWithURL:[NSURL URLWithString:roomModel.room_cover] placeholderImage:[UIImage imageNamed:@"user_header_placehoulder"]];
self.valueLabel.text = roomModel.total;
NSString *diff = roomModel.diff;
NSString *s1 = [NSString stringWithFormat:@"距离上一名差%@",roomModel.diff];
NSMutableAttributedString *attr1 = [[NSMutableAttributedString alloc] initWithString:s1];
[attr1 yy_setColor:[UIColor colorWithHexString:@"#FF8ACC"] range:NSMakeRange(6, diff.length)];
self.needLabel.attributedText = attr1;
}
-(void)setGuildModel:(QXMyRankModel *)guildModel{
_guildModel = guildModel;
if (guildModel.guild_name.length>0) {
self.nickNameLabel.text = guildModel.guild_name;
}else{
self.nickNameLabel.text = @"暂无公会";
}
if (guildModel.rank.intValue <= 0) {
self.rankResultLabel.text = @"暂未上榜";
}else{
NSString *s = [NSString stringWithFormat:@"第%@名",guildModel.rank];
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:s];
[attr yy_setColor:[UIColor colorWithHexString:@"#FF8ACC"] range:NSMakeRange(1, guildModel.rank.length)];
self.rankResultLabel.attributedText = attr;
}
[self.headerImageView sd_setImageWithURL:[NSURL URLWithString:guildModel.cover] placeholderImage:[UIImage imageNamed:@"user_header_placehoulder"]];
self.valueLabel.text = guildModel.total;
NSString *diff = guildModel.diff;
NSString *s1 = [NSString stringWithFormat:@"距离上一名差%@",guildModel.diff];
NSMutableAttributedString *attr1 = [[NSMutableAttributedString alloc] initWithString:s1];
[attr1 yy_setColor:[UIColor colorWithHexString:@"#FF8ACC"] range:NSMakeRange(6, diff.length)];
self.needLabel.attributedText = attr1;
}
//
-(void)setCpModel:(QXMyRankModel *)cpModel{
_cpModel = cpModel;
if (cpModel.nickname1.length == 0 || cpModel== nil) {
// self.allNickNameLabel.text = [NSString stringWithFormat:@"%@",cpModel.nickname];
self.allNickNameLabel.text = [NSString stringWithFormat:@"%@",QXGlobal.shareGlobal.loginModel.nickname];
[self.headerImageView1 sd_setImageWithURL:[NSURL URLWithString:QXGlobal.shareGlobal.loginModel.avatar] placeholderImage:[UIImage imageNamed:@"user_header_placehoulder"]];
self.needLabel.text = @"-";
}else{
self.allNickNameLabel.text = [NSString stringWithFormat:@"%@\n%@",cpModel.nickname,cpModel.nickname1];
[self.headerImageView1 sd_setImageWithURL:[NSURL URLWithString:cpModel.user_avatar] placeholderImage:[UIImage imageNamed:@"user_header_placehoulder"]];
[self.headerImageView2 sd_setImageWithURL:[NSURL URLWithString:cpModel.user_avatar1] placeholderImage:[UIImage imageNamed:@"user_header_placehoulder"]];
NSString *diff = cpModel.diff;
NSString *s1 = [NSString stringWithFormat:@"距离上一名差%@",cpModel.diff];
NSMutableAttributedString *attr1 = [[NSMutableAttributedString alloc] initWithString:s1];
[attr1 yy_setColor:[UIColor colorWithHexString:@"#FF8ACC"] range:NSMakeRange(6, diff.length)];
self.needLabel.attributedText = attr1;
}
if (cpModel.rank.intValue <= 0) {
self.rankResultLabel.text = @"暂未上榜";
}else{
NSString *s = [NSString stringWithFormat:@"第%@名",cpModel.rank];
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:s];
[attr yy_setColor:[UIColor colorWithHexString:@"#FF8ACC"] range:NSMakeRange(1, cpModel.rank.length)];
self.rankResultLabel.attributedText = attr;
}
}
-(void)layoutSubviews{
[super layoutSubviews];
self.frame = tmpRect;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end