126 lines
3.5 KiB
Objective-C
126 lines
3.5 KiB
Objective-C
//
|
|
// XPGiftUserCollectionViewCell.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2021/11/9.
|
|
//
|
|
|
|
#import "XPGiftUserCollectionViewCell.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
///Tool
|
|
#import "ThemeColor+SendGift.h"
|
|
///Model
|
|
#import "MicroQueueModel.h"
|
|
#import "UserInfoModel.h"
|
|
#import "MicroStateModel.h"
|
|
#import "XPGiftMicroUserModel.h"
|
|
///View
|
|
#import "NetImageView.h"
|
|
|
|
@interface XPGiftUserCollectionViewCell ()
|
|
///头像
|
|
@property (nonatomic,strong) NetImageView *avatarImageView;
|
|
///当前位置的
|
|
@property (nonatomic,strong) UILabel *positionLabel;
|
|
///没有选中的时候覆盖的
|
|
@property (nonatomic,strong) UIView * coverView;
|
|
@end
|
|
|
|
@implementation XPGiftUserCollectionViewCell
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
if (self = [super initWithFrame:frame]) {
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)layoutSubviews {
|
|
[super layoutSubviews];
|
|
self.coverView.layer.cornerRadius = self.coverView.frame.size.width / 2;
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
[self.contentView addSubview:self.avatarImageView];
|
|
[self.contentView addSubview:self.positionLabel];
|
|
[self.contentView addSubview:self.coverView];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.top.mas_equalTo(self.contentView);
|
|
make.height.mas_equalTo(28);
|
|
make.width.mas_equalTo(28);
|
|
}];
|
|
|
|
[self.positionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(10);
|
|
make.centerY.mas_equalTo(self.avatarImageView.mas_bottom);
|
|
make.width.mas_equalTo(10);
|
|
make.centerX.mas_equalTo(self.avatarImageView);
|
|
}];
|
|
|
|
[self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_equalTo(self.contentView);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (void)setMicroModel:(XPGiftMicroUserModel *)microModel {
|
|
_microModel = microModel;
|
|
if (_microModel.microQueue.microState.position == -1) {
|
|
self.positionLabel.text = @"房主位";
|
|
[self.positionLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(23);
|
|
}];
|
|
} else {
|
|
self.positionLabel.text = [NSString stringWithFormat:@"%d", microModel.microQueue.microState.position + 1];
|
|
[self.positionLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(10);
|
|
}];
|
|
}
|
|
UserInfoModel * userInfo = microModel.microQueue.userInfo;
|
|
self.avatarImageView.imageUrl = userInfo.avatar;
|
|
|
|
self.coverView.hidden = microModel.isSelect;
|
|
}
|
|
|
|
- (NetImageView *)avatarImageView {
|
|
if (!_avatarImageView) {
|
|
_avatarImageView = [[NetImageView alloc] init];
|
|
_avatarImageView.layer.masksToBounds = YES;
|
|
_avatarImageView.layer.cornerRadius = 28/2;
|
|
_avatarImageView.imageType = ImageTypeUserIcon;
|
|
_avatarImageView.image = [UIImageConstant defaultAvatarPlaceholder];
|
|
}
|
|
return _avatarImageView;
|
|
}
|
|
|
|
- (UILabel *)positionLabel{
|
|
if (!_positionLabel) {
|
|
_positionLabel = [[UILabel alloc] init];
|
|
_positionLabel.font = [UIFont systemFontOfSize:8];
|
|
_positionLabel.textColor = [ThemeColor mainTextColor];
|
|
_positionLabel.textAlignment = NSTextAlignmentCenter;
|
|
_positionLabel.backgroundColor = [ThemeColor appMainColor];
|
|
_positionLabel.layer.masksToBounds = YES;
|
|
_positionLabel.layer.cornerRadius = 5;
|
|
}
|
|
return _positionLabel;
|
|
}
|
|
|
|
- (UIView *)coverView {
|
|
if (!_coverView) {
|
|
_coverView = [[UIView alloc] init];
|
|
_coverView.backgroundColor = [ThemeColor avatarCoverColor];
|
|
_coverView.layer.masksToBounds = YES;
|
|
_coverView.layer.cornerRadius = 35/2;
|
|
}
|
|
return _coverView;
|
|
}
|
|
|
|
@end
|