156 lines
4.9 KiB
Objective-C
156 lines
4.9 KiB
Objective-C
//
|
|
// YMSessionListHeadFriendCell.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2022/11/17.
|
|
//
|
|
|
|
#import "XPSessionListHeadFriendCell.h"
|
|
#import <Masonry/Masonry.h>
|
|
#import "DJDKMIMOMColor.h"
|
|
#import "NetImageView.h"
|
|
#import "UIImage+Utils.h"
|
|
#import "XPSessionListFansPartyModel.h"
|
|
#import "XPNoteView.h"
|
|
|
|
@interface XPSessionListHeadFriendCell()
|
|
|
|
@property (nonatomic, strong) UILabel *nameLabel;
|
|
@property (nonatomic, strong) NetImageView *imageView;
|
|
@property (nonatomic, strong) UIImageView *dotView;
|
|
///音符背景
|
|
@property (nonatomic, strong) UIImageView *noteBgImageView;
|
|
///直播中
|
|
@property (nonatomic, strong) UILabel *liveLabel;
|
|
///音符动效
|
|
@property (nonatomic,strong) XPNoteView *noteImageView;
|
|
///动画的数组
|
|
@property (nonatomic,strong) NSArray *animationArray;
|
|
@end
|
|
|
|
@implementation XPSessionListHeadFriendCell
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
if (self = [super initWithFrame:frame]) {
|
|
[self initView];
|
|
[self initContraints];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)initView {
|
|
[self.contentView addSubview:self.dotView];
|
|
[self.contentView addSubview:self.imageView];
|
|
[self.contentView addSubview:self.nameLabel];
|
|
|
|
|
|
[self.imageView addSubview:self.noteBgImageView];
|
|
[self.imageView addSubview:self.noteImageView];
|
|
[self.imageView addSubview:self.liveLabel];
|
|
}
|
|
|
|
- (void)initContraints {
|
|
[self.dotView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(0);
|
|
make.centerX.mas_equalTo(self);
|
|
make.width.height.mas_equalTo(60);
|
|
}];
|
|
[self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.centerY.mas_equalTo(self.dotView);
|
|
make.width.height.mas_equalTo(56);
|
|
}];
|
|
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.mas_equalTo(self);
|
|
make.top.mas_equalTo(self.dotView.mas_bottom).mas_offset(2);
|
|
make.height.mas_equalTo(17);
|
|
make.leading.mas_equalTo(0);
|
|
}];
|
|
|
|
[self.noteBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.trailing.bottom.mas_equalTo(self.imageView);
|
|
make.height.mas_equalTo(14);
|
|
}];
|
|
|
|
[self.noteImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(self.noteBgImageView).mas_offset(15);
|
|
make.centerY.mas_equalTo(self.noteBgImageView).mas_offset(-1);
|
|
make.height.mas_equalTo(10);
|
|
make.width.mas_equalTo(10);
|
|
}];
|
|
[self.liveLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(self.noteImageView.mas_trailing).mas_offset(2);
|
|
make.centerY.mas_equalTo(self.noteImageView);
|
|
}];
|
|
}
|
|
|
|
- (void)configData:(XPSessionListFansPartyModel *)data {
|
|
self.imageView.imageUrl = data.avatar;
|
|
NSString *name = data.nick.length > 4 ? [data.nick substringToIndex:4] : data.nick;
|
|
self.nameLabel.text = name;
|
|
}
|
|
|
|
- (UILabel *)nameLabel {
|
|
if (!_nameLabel) {
|
|
_nameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
|
_nameLabel.backgroundColor = [UIColor clearColor];
|
|
_nameLabel.font = [UIFont systemFontOfSize:12];
|
|
_nameLabel.textColor = DJDKMIMOMColor.secondTextColor;
|
|
_nameLabel.textAlignment = NSTextAlignmentCenter;
|
|
}
|
|
return _nameLabel;
|
|
}
|
|
|
|
- (NetImageView *)imageView {
|
|
if (!_imageView) {
|
|
NetImageConfig *config = [[NetImageConfig alloc] init];
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
_imageView = [[NetImageView alloc] initWithConfig:config];
|
|
_imageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
_imageView.layer.cornerRadius = 54/2;
|
|
_imageView.layer.masksToBounds = YES;
|
|
_imageView.layer.borderWidth = 1;
|
|
_imageView.layer.borderColor = [UIColor whiteColor].CGColor;
|
|
}
|
|
return _imageView;
|
|
}
|
|
|
|
- (UIImageView *)dotView {
|
|
if (!_dotView) {
|
|
_dotView = [[UIImageView alloc] init];
|
|
_dotView.layer.cornerRadius = 60 / 2;
|
|
_dotView.layer.masksToBounds = YES;
|
|
_dotView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x5BC8F8), UIColorFromRGB(0x66D9D9)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(60, 60)];
|
|
}
|
|
return _dotView;
|
|
}
|
|
|
|
- (UIImageView *)noteBgImageView {
|
|
if (!_noteBgImageView) {
|
|
_noteBgImageView = [[UIImageView alloc] init];
|
|
_noteBgImageView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFFA936), UIColorFromRGB(0xFFCB47)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(52, 14)];
|
|
}
|
|
return _noteBgImageView;
|
|
}
|
|
|
|
- (UILabel *)liveLabel {
|
|
if (!_liveLabel) {
|
|
_liveLabel = [[UILabel alloc] init];
|
|
_liveLabel.font = [UIFont systemFontOfSize:8];
|
|
_liveLabel.textColor = [UIColor whiteColor];
|
|
_liveLabel.text = YMLocalizedString(@"XPSessionListHeadFriendCell0");
|
|
}
|
|
return _liveLabel;
|
|
}
|
|
|
|
- (XPNoteView *)noteImageView {
|
|
if (!_noteImageView) {
|
|
_noteImageView = [[XPNoteView alloc] init];
|
|
_noteImageView.pillarColor = [UIColor whiteColor];
|
|
_noteImageView.pillarWidth = 1.5;
|
|
[_noteImageView startAnimation];
|
|
}
|
|
return _noteImageView;
|
|
}
|
|
|
|
@end
|