209 lines
7.3 KiB
Objective-C
209 lines
7.3 KiB
Objective-C
//
|
|
// XPNewPartyListCollectionViewCell.m
|
|
// xplan-ios
|
|
//
|
|
// Created by duoban on 2023/7/26.
|
|
//
|
|
|
|
#import "XPNewPartyListCollectionViewCell.h"
|
|
@interface XPNewPartyListCollectionViewCell()
|
|
///标签背景
|
|
@property(nonatomic,strong) NetImageView *tagBgView;
|
|
///标签
|
|
@property(nonatomic,strong) UILabel *tagView;
|
|
///背景图片
|
|
@property(nonatomic,strong) NetImageView *bgImageView;
|
|
///热力背景
|
|
@property(nonatomic,strong) UIImageView *hotBgView;
|
|
///热力
|
|
@property(nonatomic,strong) UILabel *hotNumView;
|
|
///热力logo
|
|
@property(nonatomic,strong) UIImageView *hotIconView;
|
|
///标题
|
|
@property(nonatomic,strong) UILabel *titleView;
|
|
///蒙层
|
|
@property(nonatomic,strong) UIImageView *curMaskView;
|
|
@end
|
|
|
|
@implementation XPNewPartyListCollectionViewCell
|
|
-(instancetype)initWithFrame:(CGRect)frame{
|
|
self = [super initWithFrame:frame];
|
|
if(self){
|
|
[self installUI];
|
|
[self installConstraints];
|
|
for (int i = 0; i < 5; i++) {
|
|
NetImageView *imageView = [[NetImageView alloc]init];
|
|
imageView.tag = 100+i;
|
|
imageView.layer.cornerRadius = kGetScaleWidth(18)/2;
|
|
imageView.layer.masksToBounds = YES;
|
|
imageView.hidden = YES;
|
|
imageView.layer.borderWidth = 1;
|
|
imageView.layer.borderColor = [UIColor whiteColor].CGColor;
|
|
[self.bgImageView addSubview:imageView];
|
|
CGFloat left = i * kGetScaleWidth(12) + kGetScaleWidth(8);
|
|
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.height.mas_equalTo(kGetScaleWidth(18));
|
|
make.bottom.mas_equalTo(-kGetScaleWidth(28));
|
|
make.leading.mas_equalTo(left);
|
|
|
|
}];
|
|
}
|
|
}
|
|
return self;
|
|
}
|
|
-(void)installUI{
|
|
[self.contentView addSubview:self.bgImageView];
|
|
[self.bgImageView addSubview:self.tagBgView];
|
|
[self.tagBgView addSubview:self.tagView];
|
|
[self.bgImageView addSubview:self.hotBgView];
|
|
[self.hotBgView addSubview:self.hotIconView];
|
|
[self.hotBgView addSubview:self.hotNumView];
|
|
[self.bgImageView addSubview:self.curMaskView];
|
|
[self.bgImageView addSubview:self.titleView];
|
|
|
|
}
|
|
-(void)installConstraints{
|
|
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self.contentView);
|
|
}];
|
|
|
|
[self.tagBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(kGetScaleWidth(6));
|
|
make.leading.mas_equalTo(kGetScaleWidth(8));
|
|
make.width.mas_greaterThanOrEqualTo(kGetScaleWidth(58));
|
|
make.height.mas_equalTo(kGetScaleWidth(18));
|
|
}];
|
|
|
|
[self.tagView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.trailing.equalTo(self.tagBgView).inset(kGetScaleWidth(7));
|
|
make.centerY.equalTo(self.tagBgView);
|
|
}];
|
|
[self.hotBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(kGetScaleWidth(6));
|
|
make.trailing.mas_equalTo(-kGetScaleWidth(8));
|
|
make.height.mas_equalTo(kGetScaleWidth(16));
|
|
make.width.mas_greaterThanOrEqualTo(kGetScaleWidth(35));
|
|
}];
|
|
[self.hotIconView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.height.mas_equalTo(kGetScaleWidth(12));
|
|
make.leading.mas_equalTo(kGetScaleWidth(6));
|
|
make.centerY.equalTo(self.hotBgView);
|
|
}];
|
|
[self.hotNumView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(kGetScaleWidth(20));
|
|
make.trailing.mas_equalTo(-kGetScaleWidth(8));
|
|
make.centerY.equalTo(self.hotBgView);
|
|
|
|
}];
|
|
[self.curMaskView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.trailing.bottom.equalTo(self.bgImageView);
|
|
make.height.mas_equalTo(kGetScaleWidth(54));
|
|
}];
|
|
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(kGetScaleWidth(20));
|
|
make.bottom.mas_equalTo(-kGetScaleWidth(6));
|
|
make.leading.trailing.equalTo(self.bgImageView).inset(kGetScaleWidth(8));
|
|
}];
|
|
}
|
|
- (void)setRoomModel:(HomeRecommendRoomModel *)roomModel {
|
|
_roomModel = roomModel;
|
|
if (_roomModel) {
|
|
|
|
_bgImageView.imageUrl = _roomModel.avatar;
|
|
self.titleView.text = _roomModel.title.length > 0 ? _roomModel.title : @"";
|
|
self.hotNumView.text = _roomModel.onlineNum > 0 ? [NSString stringWithFormat:@"%ld", _roomModel.onlineNum] : @"0";
|
|
// ///推荐页的标签
|
|
_tagBgView.hidden = YES;
|
|
if (_roomModel.iconContent.length > 0) {
|
|
_tagBgView.image = kImage(@"home_party_tag_bg");
|
|
_tagBgView.hidden = NO;
|
|
if (_roomModel.crossPking) {
|
|
_tagView.text = @"PK中";
|
|
} else {
|
|
_tagView.text = _roomModel.iconContent;
|
|
}
|
|
}else{
|
|
if( _roomModel.tagPict > 0){
|
|
_tagBgView.hidden = NO;
|
|
_tagView.text = @"";
|
|
_tagBgView.imageUrl = _roomModel.tagPict;
|
|
}
|
|
|
|
}
|
|
if (_roomModel.micUsers.count > 5) {
|
|
_roomModel.micUsers = [_roomModel.micUsers subarrayWithRange:NSMakeRange(0, 5)];
|
|
}
|
|
|
|
for (int i = 0; i < _roomModel.micUsers.count; i++) {
|
|
NetImageView * imageView = [self.bgImageView viewWithTag:100+i];
|
|
if (i < _roomModel.micUsers.count) {
|
|
HomePartyMicUserModel * userInfo = _roomModel.micUsers[i];
|
|
imageView.imageUrl = userInfo.avatar;
|
|
imageView.hidden = NO;
|
|
} else {
|
|
imageView.hidden = YES;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#pragma mark - 懒加载
|
|
- (NetImageView *)bgImageView{
|
|
if(!_bgImageView){
|
|
_bgImageView = [[NetImageView alloc]init];
|
|
_bgImageView.backgroundColor = UIColorFromRGB(0xF8F8FA);
|
|
_bgImageView.layer.cornerRadius = kGetScaleWidth(15);
|
|
_bgImageView.layer.masksToBounds = YES;
|
|
}
|
|
return _bgImageView;
|
|
}
|
|
- (NetImageView *)tagBgView{
|
|
if(!_tagBgView){
|
|
_tagBgView = [NetImageView new];
|
|
_tagBgView.image = kImage(@"home_party_tag_bg");
|
|
}
|
|
return _tagBgView;
|
|
}
|
|
- (UILabel *)tagView{
|
|
if(!_tagView){
|
|
_tagView = [UILabel labelInitWithText:@"" font:kFontMedium(11) textColor:[UIColor whiteColor]];
|
|
_tagView.textAlignment = NSTextAlignmentCenter;
|
|
}
|
|
return _tagView;
|
|
}
|
|
- (UIImageView *)hotBgView{
|
|
if(!_hotBgView){
|
|
_hotBgView = [UIImageView new];
|
|
_hotBgView.layer.cornerRadius = kGetScaleWidth(16)/2;
|
|
_hotBgView.layer.masksToBounds = YES;
|
|
_hotBgView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
|
|
}
|
|
return _hotBgView;
|
|
}
|
|
- (UILabel *)hotNumView{
|
|
if(!_hotNumView){
|
|
_hotNumView = [UILabel labelInitWithText:@"0" font:kFontSemibold(11) textColor:[UIColor whiteColor]];
|
|
}
|
|
return _hotNumView;
|
|
}
|
|
- (UIImageView *)hotIconView{
|
|
if(!_hotIconView){
|
|
_hotIconView = [UIImageView new];
|
|
_hotIconView.image = kImage(@"home_party_hot_icon");
|
|
}
|
|
return _hotIconView;
|
|
}
|
|
-(UILabel *)titleView{
|
|
if(!_titleView){
|
|
_titleView = [UILabel labelInitWithText:@"" font:kFontMedium(14) textColor:[UIColor whiteColor]];
|
|
}
|
|
return _titleView;
|
|
}
|
|
- (UIImageView *)curMaskView{
|
|
if(!_curMaskView){
|
|
_curMaskView = [UIImageView new];
|
|
_curMaskView.image = kImage(@"home_party_mask");
|
|
}
|
|
return _curMaskView;
|
|
}
|
|
@end
|