352 lines
13 KiB
Objective-C
352 lines
13 KiB
Objective-C
//
|
|
// XPPartyListCollectionViewCell.m
|
|
// xplan-ios
|
|
//
|
|
// Created by XY on 2023/3/7.
|
|
//
|
|
|
|
#import "XPPartyListCollectionViewCell.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "ThemeColor.h"
|
|
#import "NetImageView.h"
|
|
#import "XPHomeGradientLabel.h"
|
|
#import "NSArray+Safe.h"
|
|
///Model
|
|
#import "HomeRecommendRoomModel.h"
|
|
|
|
@interface XPPartyListCollectionViewCell()
|
|
|
|
///头像
|
|
@property (nonatomic,strong) NetImageView *avatarImageView;
|
|
///背景
|
|
@property (nonatomic,strong) UIImageView *backView;
|
|
///房间标题
|
|
@property (nonatomic,strong) UILabel *roomTitleLabel;
|
|
///房间的标签
|
|
@property (nonatomic,strong) NetImageView *roomTagImageView;
|
|
///房间榜单的用户
|
|
@property (nonatomic,strong) UIStackView *stackView;
|
|
///第一个人的头像
|
|
@property (nonatomic,strong) NetImageView *firstImageView;
|
|
///第二个人的头像
|
|
@property (nonatomic,strong) NetImageView *secondImageView;
|
|
///第三个人的头像
|
|
@property (nonatomic,strong) NetImageView *thirdImageView;
|
|
///第四个人的头像
|
|
@property (nonatomic,strong) NetImageView *fourthImageView;
|
|
///第五个人的头像
|
|
@property (nonatomic,strong) NetImageView *fifImageView;
|
|
///个数的logo
|
|
@property (nonatomic,strong) UIImageView *logoImageView;
|
|
///房间的人的个数
|
|
@property (nonatomic,strong) UILabel *numberLabel;
|
|
|
|
@end
|
|
|
|
@implementation XPPartyListCollectionViewCell
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
self.backgroundColor = [UIColor clearColor];
|
|
self.contentView.backgroundColor = [UIColor clearColor];
|
|
[self.contentView addSubview:self.backView];
|
|
[self.backView addSubview:self.avatarImageView];
|
|
[self.backView addSubview:self.roomTitleLabel];
|
|
[self.backView addSubview:self.roomTagImageView];
|
|
[self.backView addSubview:self.stackView];
|
|
[self.backView addSubview:self.logoImageView];
|
|
[self.backView addSubview:self.numberLabel];
|
|
|
|
[self.stackView addArrangedSubview:self.firstImageView];
|
|
[self.stackView addArrangedSubview:self.secondImageView];
|
|
[self.stackView addArrangedSubview:self.thirdImageView];
|
|
[self.stackView addArrangedSubview:self.fourthImageView];
|
|
[self.stackView addArrangedSubview:self.fifImageView];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.mas_equalTo(self.contentView).inset(15);
|
|
make.top.mas_equalTo(0);
|
|
make.height.mas_equalTo(102);
|
|
}];
|
|
|
|
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(70, 70));
|
|
make.left.mas_equalTo(12);
|
|
make.centerY.mas_equalTo(self.backView);
|
|
}];
|
|
|
|
[self.roomTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self.avatarImageView.mas_right).offset(10);
|
|
make.top.mas_equalTo(self.avatarImageView);
|
|
make.right.mas_lessThanOrEqualTo(-70);
|
|
}];
|
|
|
|
[self.roomTagImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(38, 16));
|
|
make.left.mas_equalTo(self.roomTitleLabel);
|
|
make.top.mas_equalTo(self.roomTitleLabel.mas_bottom).offset(6);
|
|
}];
|
|
|
|
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self.roomTitleLabel);
|
|
make.height.mas_equalTo(20);
|
|
make.bottom.mas_equalTo(self.avatarImageView);
|
|
}];
|
|
|
|
[self.firstImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(20);
|
|
}];
|
|
|
|
[self.secondImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(20);
|
|
}];
|
|
|
|
[self.thirdImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(20);
|
|
}];
|
|
|
|
[self.fourthImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(20);
|
|
}];
|
|
|
|
[self.fifImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(20);
|
|
}];
|
|
|
|
[self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(12, 12));
|
|
make.centerY.mas_equalTo(self.stackView);
|
|
make.right.mas_equalTo(self.numberLabel.mas_left).offset(-2);
|
|
}];
|
|
|
|
[self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerY.mas_equalTo(self.stackView);
|
|
make.right.mas_equalTo(-12);
|
|
}];
|
|
}
|
|
#pragma mark - Getters And Setters
|
|
//- (void)setRoomInfo:(HomePlayRoomModel *)roomInfo {
|
|
// _roomInfo = roomInfo;
|
|
// if (_roomInfo) {
|
|
// self.roomTitleLabel.text = _roomInfo.title;
|
|
// if (roomInfo.mgName.length) {
|
|
// self.gamenameLabel.text = roomInfo.mgName;
|
|
// _gamenameLabel.gradientColor = @[(id)UIColorFromRGB(0x61C4FE).CGColor, (id)UIColorFromRGB(0xA979FF).CGColor];
|
|
// } else {
|
|
// self.gamenameLabel.text = @"扩列交友";
|
|
// _gamenameLabel.gradientColor = @[(id)UIColorFromRGB(0xFF969B).CGColor, (id)UIColorFromRGB(0x8C5FFF).CGColor];
|
|
// }
|
|
// self.roomTagImageView.imageUrl = _roomInfo.tagPict;
|
|
// self.numberLabel.text = [NSString stringWithFormat:@"%ld", _roomInfo.onlineNum];
|
|
// self.avatarImageView.imageUrl = _roomInfo.avatar;
|
|
// if (_roomInfo.micUsers.count > 5) {
|
|
// _roomInfo.micUsers = [_roomInfo.micUsers subarrayWithRange:NSMakeRange(0, 5)];
|
|
// }
|
|
//
|
|
// for (int i = 0; i < self.stackView.subviews.count; i++) {
|
|
// NetImageView * imageView = [self.stackView.subviews safeObjectAtIndex1:i];
|
|
// if (i < _roomInfo.micUsers.count) {
|
|
// HomePlayMicUserModel * userInfo = [_roomInfo.micUsers safeObjectAtIndex1:i];
|
|
// imageView.imageUrl = userInfo.avatar;
|
|
// imageView.hidden = NO;
|
|
// } else {
|
|
// imageView.hidden = YES;
|
|
// }
|
|
// }
|
|
// self.broadCastLabel.text = roomInfo.broadMsg ? roomInfo.broadMsg : @"";
|
|
// if (roomInfo.broadMsg.length) {
|
|
// [self.roomTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
// make.top.mas_equalTo(self.backView).mas_offset(8);
|
|
// }];
|
|
// [self.roomTagImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
// make.top.mas_equalTo(self.broadCastLabel.mas_bottom).mas_offset(6);
|
|
// }];
|
|
// } else {
|
|
// [self.roomTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
// make.top.mas_equalTo(self.backView).mas_offset(10);
|
|
// }];
|
|
// [self.roomTagImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
// make.top.mas_equalTo(self.roomTitleLabel.mas_bottom).mas_offset(8);
|
|
// }];
|
|
// }
|
|
// self.acrossPkButton.hidden = !_roomInfo.crossPking;
|
|
// }
|
|
//}
|
|
|
|
- (void)setRoomModel:(HomeRecommendRoomModel *)roomModel {
|
|
_roomModel = roomModel;
|
|
if (_roomModel) {
|
|
self.avatarImageView.imageUrl = _roomModel.avatar;
|
|
self.roomTitleLabel.text = _roomModel.title.length > 0 ? _roomModel.title : @"";
|
|
self.numberLabel.text = [NSString stringWithFormat:@"%ld", _roomModel.onlineNum];
|
|
self.roomTagImageView.imageUrl = _roomModel.tagPict;
|
|
|
|
if (_roomModel.micUsers.count > 5) {
|
|
_roomModel.micUsers = [_roomModel.micUsers subarrayWithRange:NSMakeRange(0, 5)];
|
|
}
|
|
|
|
for (int i = 0; i < self.stackView.subviews.count; i++) {
|
|
NetImageView * imageView = [self.stackView.subviews safeObjectAtIndex1:i];
|
|
if (i < _roomModel.micUsers.count) {
|
|
HomePartyMicUserModel * userInfo = [_roomModel.micUsers safeObjectAtIndex1:i];
|
|
imageView.imageUrl = userInfo.avatar;
|
|
imageView.hidden = NO;
|
|
} else {
|
|
imageView.hidden = YES;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
- (UIImageView *)backView {
|
|
if (!_backView) {
|
|
_backView = [[UIImageView alloc] init];
|
|
_backView.contentMode = UIViewContentModeScaleAspectFill;
|
|
_backView.image = [UIImage imageNamed:@"home_party_cell_bg"];
|
|
}
|
|
return _backView;
|
|
}
|
|
|
|
- (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 = 10;
|
|
}
|
|
return _avatarImageView;
|
|
}
|
|
|
|
- (UILabel *)roomTitleLabel {
|
|
if (!_roomTitleLabel) {
|
|
_roomTitleLabel = [[UILabel alloc] init];
|
|
_roomTitleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
|
|
_roomTitleLabel.textColor = [ThemeColor mainTextColor];
|
|
}
|
|
return _roomTitleLabel;
|
|
}
|
|
|
|
- (NetImageView *)roomTagImageView {
|
|
if (!_roomTagImageView) {
|
|
_roomTagImageView = [[NetImageView alloc] init];
|
|
_roomTagImageView.userInteractionEnabled = YES;
|
|
}
|
|
return _roomTagImageView;
|
|
}
|
|
|
|
- (UIStackView *)stackView {
|
|
if (!_stackView) {
|
|
_stackView = [[UIStackView alloc] init];
|
|
_stackView.axis = UILayoutConstraintAxisHorizontal;
|
|
_stackView.distribution = UIStackViewDistributionFill;
|
|
_stackView.alignment = UIStackViewAlignmentFill;
|
|
_stackView.spacing = 2;
|
|
}
|
|
return _stackView;
|
|
}
|
|
|
|
- (NetImageView *)firstImageView {
|
|
if (!_firstImageView) {
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
config.imageType = ImageTypeUserIcon;
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
_firstImageView = [[NetImageView alloc] initWithConfig:config];
|
|
_firstImageView.layer.masksToBounds = YES;
|
|
_firstImageView.layer.cornerRadius = 10;
|
|
_firstImageView.layer.borderWidth = 1;
|
|
_firstImageView.layer.borderColor = [UIColor whiteColor].CGColor;
|
|
}
|
|
return _firstImageView;
|
|
}
|
|
|
|
- (NetImageView *)secondImageView {
|
|
if (!_secondImageView) {
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
config.imageType = ImageTypeUserIcon;
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
_secondImageView = [[NetImageView alloc] initWithConfig:config];
|
|
_secondImageView.layer.masksToBounds = YES;
|
|
_secondImageView.layer.cornerRadius = 10;
|
|
_secondImageView.layer.borderWidth = 1;
|
|
_secondImageView.layer.borderColor = [UIColor whiteColor].CGColor;
|
|
}
|
|
return _secondImageView;
|
|
}
|
|
|
|
- (NetImageView *)thirdImageView {
|
|
if (!_thirdImageView) {
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
config.imageType = ImageTypeUserIcon;
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
_thirdImageView = [[NetImageView alloc] initWithConfig:config];
|
|
_thirdImageView.layer.masksToBounds = YES;
|
|
_thirdImageView.layer.cornerRadius = 10;
|
|
_thirdImageView.layer.borderWidth = 1;
|
|
_thirdImageView.layer.borderColor = [UIColor whiteColor].CGColor;
|
|
}
|
|
return _thirdImageView;
|
|
}
|
|
|
|
- (NetImageView *)fourthImageView {
|
|
if (!_fourthImageView) {
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
config.imageType = ImageTypeUserIcon;
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
_fourthImageView = [[NetImageView alloc] initWithConfig:config];
|
|
_fourthImageView.layer.masksToBounds = YES;
|
|
_fourthImageView.layer.cornerRadius = 10;
|
|
_fourthImageView.layer.borderWidth = 1;
|
|
_fourthImageView.layer.borderColor = [UIColor whiteColor].CGColor;
|
|
}
|
|
return _fourthImageView;
|
|
}
|
|
|
|
- (NetImageView *)fifImageView {
|
|
if (!_fifImageView) {
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
config.imageType = ImageTypeUserIcon;
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
_fifImageView = [[NetImageView alloc] initWithConfig:config];
|
|
_fifImageView.layer.masksToBounds = YES;
|
|
_fifImageView.layer.cornerRadius = 10;
|
|
_fifImageView.layer.borderWidth = 1;
|
|
_fifImageView.layer.borderColor = [UIColor whiteColor].CGColor;
|
|
}
|
|
return _fifImageView;
|
|
}
|
|
|
|
- (UIImageView *)logoImageView {
|
|
if (!_logoImageView) {
|
|
_logoImageView = [[UIImageView alloc] init];
|
|
_logoImageView.userInteractionEnabled = YES;
|
|
_logoImageView.image = [UIImage imageNamed:@"home_party_fire"];
|
|
}
|
|
return _logoImageView;
|
|
}
|
|
|
|
- (UILabel *)numberLabel {
|
|
if (!_numberLabel) {
|
|
_numberLabel = [[UILabel alloc] init];
|
|
_numberLabel.font = [UIFont systemFontOfSize:12];
|
|
_numberLabel.textColor = [ThemeColor secondTextColor];
|
|
}
|
|
return _numberLabel;
|
|
}
|
|
|
|
@end
|