322 lines
11 KiB
Objective-C
322 lines
11 KiB
Objective-C
//
|
|
// XPFindNewFriendTableViewCell.m
|
|
// xplan-ios
|
|
//
|
|
// Created by XY on 2023/3/3.
|
|
//
|
|
|
|
#import "XPFindNewFriendTableViewCell.h"
|
|
/// Third
|
|
#import <Masonry.h>
|
|
#import <SVGAParser.h>
|
|
#import <SVGAPlayer.h>
|
|
/// Tool
|
|
#import "NetImageView.h"
|
|
#import "ThemeColor.h"
|
|
#import "XPButton.h"
|
|
|
|
@interface XPFindNewFriendTableViewCell()
|
|
/// 背景
|
|
@property (nonatomic, strong) UIView *bgView;
|
|
/// 头像
|
|
@property (nonatomic, strong) NetImageView *avatarImageView;
|
|
/// 在线状态
|
|
@property (nonatomic, strong) UIImageView *onlineImageView;
|
|
@property (nonatomic, strong) UIStackView *nameStackView;
|
|
/// 贵族图标
|
|
@property (nonatomic, strong) UIImageView *nobleImageView;
|
|
/// 昵称
|
|
@property (nonatomic, strong) UILabel *nickLabel;
|
|
@property (nonatomic, strong) UIStackView *constellationStackView;
|
|
/// 性别年龄
|
|
@property (nonatomic, strong) UIButton *sexBtn;
|
|
/// 星座
|
|
@property (nonatomic, strong) UILabel *constellationLabel;
|
|
/// 签名
|
|
@property (nonatomic, strong) UILabel *signLabel;
|
|
/// 直播中/和Ta聊
|
|
@property (nonatomic, strong) SVGAPlayer *livingView;
|
|
@property (nonatomic, strong) UIImageView *chatImageView;
|
|
|
|
@property (nonatomic, strong) UILabel *statusLabel;
|
|
|
|
@property (nonatomic, strong) UIStackView *statusStackView;
|
|
|
|
@end
|
|
|
|
@implementation XPFindNewFriendTableViewCell
|
|
|
|
- (void)awakeFromNib {
|
|
[super awakeFromNib];
|
|
// Initialization code
|
|
}
|
|
|
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
|
[super setSelected:selected animated:animated];
|
|
|
|
// Configure the view for the selected state
|
|
}
|
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
|
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
|
if (self) {
|
|
self.backgroundColor = UIColor.clearColor;
|
|
self.contentView.backgroundColor = UIColor.clearColor;
|
|
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
|
|
SVGAParser *parser = [[SVGAParser alloc] init];
|
|
[parser parseWithNamed:@"home_living" inBundle:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
|
|
if (videoItem != nil) {
|
|
self.livingView.videoItem = videoItem;
|
|
[self.livingView startAnimation];
|
|
}
|
|
} failureBlock:nil];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
[self.contentView addSubview:self.bgView];
|
|
[self.bgView addSubview:self.avatarImageView];
|
|
[self.bgView addSubview:self.onlineImageView];
|
|
[self.bgView addSubview:self.nameStackView];
|
|
[self.bgView addSubview:self.constellationStackView];
|
|
[self.bgView addSubview:self.signLabel];
|
|
[self.bgView addSubview:self.livingView];
|
|
[self.bgView addSubview:self.chatImageView];
|
|
[self.bgView addSubview:self.statusLabel];
|
|
|
|
[self.nameStackView addArrangedSubview:self.nobleImageView];
|
|
[self.nameStackView addArrangedSubview:self.nickLabel];
|
|
|
|
[self.constellationStackView addArrangedSubview:self.sexBtn];
|
|
[self.constellationStackView addArrangedSubview:self.constellationLabel];
|
|
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(25);
|
|
make.right.mas_equalTo(-15);
|
|
make.top.mas_equalTo(6);
|
|
make.bottom.mas_equalTo(-6);
|
|
}];
|
|
|
|
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(-10);
|
|
make.centerY.mas_equalTo(self.bgView);
|
|
make.size.mas_equalTo(CGSizeMake(72, 72));
|
|
}];
|
|
|
|
[self.onlineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_equalTo(self.avatarImageView.mas_right).offset(-4);
|
|
make.bottom.mas_equalTo(self.avatarImageView.mas_bottom).offset(-7);
|
|
make.size.mas_equalTo(CGSizeMake(12, 12));
|
|
}];
|
|
|
|
[self.nameStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self.avatarImageView.mas_right).offset(12);
|
|
make.top.mas_equalTo(self.avatarImageView.mas_top).offset(4);
|
|
make.height.mas_equalTo(21);
|
|
}];
|
|
|
|
[self.nobleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(self.nobleImageView.mas_height);
|
|
}];
|
|
|
|
[self.constellationStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerY.mas_equalTo(self.avatarImageView);
|
|
make.left.mas_equalTo(self.nameStackView);
|
|
}];
|
|
|
|
[self.sexBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(15);
|
|
}];
|
|
|
|
[self.signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(self.nameStackView);
|
|
make.bottom.mas_equalTo(self.avatarImageView.mas_bottom).offset(-4);
|
|
}];
|
|
|
|
[self.livingView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_equalTo(-15);
|
|
make.centerY.mas_equalTo(self.bgView).mas_offset(-8);
|
|
make.size.mas_equalTo(CGSizeMake(20, 20));
|
|
}];
|
|
|
|
[self.chatImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_equalTo(self.livingView);
|
|
}];
|
|
|
|
[self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(self.livingView.mas_bottom).offset(2);
|
|
make.centerX.mas_equalTo(self.livingView);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
|
|
- (void)setRoomInfo:(HomeRecommendRoomModel *)roomInfo {
|
|
self.nobleImageView.hidden = YES;
|
|
self.nickLabel.text = @"用户昵称";
|
|
[self.sexBtn setImage:[UIImage imageNamed:@"home_sex_female"] forState:UIControlStateNormal];
|
|
self.sexBtn.backgroundColor = [ThemeColor colorWithHexString:@"#FF9CCE"];
|
|
[self.sexBtn setTitle:@"22" forState:UIControlStateNormal];
|
|
self.constellationLabel.text = @"巨蟹座";
|
|
self.signLabel.text = @"我是个默认的个性签名";
|
|
self.livingView.hidden = NO;
|
|
self.statusLabel.text = @"直播中";
|
|
// self.statusLabel.text = @"和TA聊";
|
|
}
|
|
|
|
- (UIView *)bgView {
|
|
if (!_bgView) {
|
|
_bgView = [[UIView alloc] init];
|
|
_bgView.backgroundColor = [ThemeColor appCellBackgroundColor];
|
|
_bgView.layer.cornerRadius = 10;
|
|
}
|
|
return _bgView;
|
|
}
|
|
|
|
- (NetImageView *)avatarImageView {
|
|
if (!_avatarImageView) {
|
|
NetImageConfig * config = [[NetImageConfig alloc] init];
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
config.imageType = ImageTypeUserIcon;
|
|
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
|
|
_avatarImageView.userInteractionEnabled = YES;
|
|
_avatarImageView.layer.masksToBounds = YES;
|
|
_avatarImageView.layer.cornerRadius = 36;
|
|
_avatarImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
// UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapAvatarGuest)];
|
|
// [_avatarImageView addGestureRecognizer:tap];
|
|
}
|
|
return _avatarImageView;
|
|
}
|
|
|
|
- (UIImageView *)onlineImageView {
|
|
if (!_onlineImageView) {
|
|
_onlineImageView = [[UIImageView alloc] init];
|
|
_onlineImageView.backgroundColor = [ThemeColor colorWithHexString:@"#6CE19A"];
|
|
_onlineImageView.layer.cornerRadius = 6;
|
|
_onlineImageView.layer.borderWidth = 2;
|
|
_onlineImageView.layer.borderColor = UIColor.whiteColor.CGColor;
|
|
_onlineImageView.clipsToBounds = YES;
|
|
}
|
|
return _onlineImageView;
|
|
}
|
|
|
|
- (UIStackView *)nameStackView {
|
|
if (!_nameStackView) {
|
|
_nameStackView = [[UIStackView alloc] init];
|
|
_nameStackView.axis = UILayoutConstraintAxisHorizontal;
|
|
_nameStackView.distribution = UIStackViewDistributionFill;
|
|
_nameStackView.alignment = UIStackViewAlignmentFill;
|
|
_nameStackView.spacing = 3;
|
|
}
|
|
return _nameStackView;
|
|
}
|
|
|
|
- (UIImageView *)nobleImageView {
|
|
if (!_nobleImageView) {
|
|
_nobleImageView = [[UIImageView alloc] init];
|
|
_nobleImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
}
|
|
return _nobleImageView;
|
|
}
|
|
|
|
- (UILabel *)nickLabel {
|
|
if (!_nickLabel) {
|
|
_nickLabel = [[UILabel alloc] init];
|
|
_nickLabel.textColor = [ThemeColor mainTextColor];
|
|
_nickLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
|
|
}
|
|
return _nickLabel;
|
|
}
|
|
|
|
- (UIStackView *)constellationStackView {
|
|
if (!_constellationStackView) {
|
|
_constellationStackView = [[UIStackView alloc] init];
|
|
_constellationStackView.axis = UILayoutConstraintAxisHorizontal;
|
|
_constellationStackView.distribution = UIStackViewDistributionFill;
|
|
_constellationStackView.alignment = UIStackViewAlignmentFill;
|
|
_constellationStackView.spacing = 9;
|
|
}
|
|
return _constellationStackView;
|
|
}
|
|
|
|
- (UIButton *)sexBtn {
|
|
if (!_sexBtn) {
|
|
_sexBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
_sexBtn.titleLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightRegular];
|
|
_sexBtn.layer.cornerRadius = 7.5;
|
|
_sexBtn.clipsToBounds = YES;
|
|
_sexBtn.userInteractionEnabled = NO;
|
|
_sexBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 4, 0, 4);
|
|
// _sexBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 4, 0, 0);
|
|
}
|
|
return _sexBtn;
|
|
}
|
|
|
|
- (UILabel *)constellationLabel {
|
|
if (!_constellationLabel) {
|
|
_constellationLabel = [[UILabel alloc] init];
|
|
_constellationLabel.textColor = [ThemeColor textThirdColor];
|
|
_constellationLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightRegular];
|
|
}
|
|
return _constellationLabel;
|
|
}
|
|
|
|
- (UILabel *)signLabel {
|
|
if (!_signLabel) {
|
|
_signLabel = [[UILabel alloc] init];
|
|
_signLabel.textColor = [ThemeColor textThirdColor];
|
|
_signLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
|
|
}
|
|
return _signLabel;
|
|
}
|
|
|
|
- (SVGAPlayer *)livingView {
|
|
if (!_livingView) {
|
|
_livingView = [[SVGAPlayer alloc] init];
|
|
_livingView.hidden = YES;
|
|
}
|
|
return _livingView;
|
|
}
|
|
|
|
- (UIImageView *)chatImageView {
|
|
if (!_chatImageView) {
|
|
_chatImageView = [[UIImageView alloc] init];
|
|
_chatImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
_chatImageView.image = [UIImage imageNamed:@"home_chat"];
|
|
_chatImageView.hidden = YES;
|
|
}
|
|
return _chatImageView;
|
|
}
|
|
|
|
- (UILabel *)statusLabel {
|
|
if (!_statusLabel) {
|
|
_statusLabel = [[UILabel alloc] init];
|
|
_statusLabel.textColor = [ThemeColor textThirdColor];
|
|
_statusLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightRegular];
|
|
}
|
|
return _statusLabel;
|
|
}
|
|
|
|
- (UIStackView *)statusStackView {
|
|
if (!_statusStackView) {
|
|
_statusStackView = [[UIStackView alloc] init];
|
|
_statusStackView.axis = UILayoutConstraintAxisVertical;
|
|
_statusStackView.distribution = UIStackViewDistributionFill;
|
|
_statusStackView.alignment = UIStackViewAlignmentFill;
|
|
_statusStackView.spacing = 5;
|
|
}
|
|
return _statusStackView;
|
|
}
|
|
|
|
@end
|