Files
yinmeng-ios/xplan-ios/Main/Mine/View/SubViews/XPMineHeadView.m
2023-01-04 14:14:33 +08:00

761 lines
29 KiB
Objective-C

//
// XPMineHeadView.m
// xplan-ios
//
// Created by 冯硕 on 2021/9/16.
//
#import "XPMineHeadView.h"
///Third
#import <Masonry/Masonry.h>
#import <YYText/YYText.h>
///Tool
#import "ThemeColor.h"
#import "XPMacro.h"
#import "UIImage+Utils.h"
#import <YYImage/YYAnimatedImageView.h>
#import "SpriteSheetImageManager.h"
#import "StatisticsServiceHelper.h"
///View
#import "NetImageView.h"
#import "UIImage+Utils.h"
#import "XPMineFriendNumberView.h"
#import "XPNobleCenterEntranceView.h"
#import "XPMineAccountView.h"
#import "XPMineHeadTeenagerView.h"
///Model
#import "UserInfoModel.h"
#import "WalletInfoModel.h"
#import "NobleCenterModel.h"
#import "AnchorLevelModel.h"
@interface XPMineHeadView ()
///头像
@property (nonatomic,strong) NetImageView * avatarImageView;
///普通的
@property (nonatomic,strong) YYAnimatedImageView *headWearImageView;
///头饰播放
@property (nonatomic, strong) SpriteSheetImageManager *manager;
///name的容器
@property (nonatomic,strong) UIStackView *nameStackView;
///贵族等级icon
@property (nonatomic,strong) NetImageView *nobleImageView;
///名字
@property (nonatomic,strong) UILabel *nameLabel;
///id 的容器
@property (nonatomic,strong) UIStackView *idStackView;
///id
@property (nonatomic,strong) UILabel *idLabel;
///性别
@property (nonatomic,strong) UIImageView *sexImageView;
///显示等级
@property (nonatomic,strong) YYLabel *levelLabel;
///关注、粉丝的容器
@property (nonatomic,strong) UIStackView *attentionStackView;
///关注
@property (nonatomic,strong) XPMineFriendNumberView *attentionView;
///粉丝
@property (nonatomic,strong) XPMineFriendNumberView *fansView;
///访客记录
@property (nonatomic,strong) XPMineFriendNumberView *visitorView;
///足迹
@property (nonatomic,strong) XPMineFriendNumberView *footprintView;
///技能卡
@property (nonatomic, strong) UIButton *skillCardButton;
///账户中心
@property (nonatomic, strong) XPMineAccountView *accountView;
///贵族中心
@property (nonatomic, strong) XPNobleCenterEntranceView *nobleEntranceView;
@property (nonatomic, strong) XPMineHeadTeenagerView *teenagerView;
///主播评级
@property (nonatomic,strong) UIButton *anchorLevel;
@end
@implementation XPMineHeadView
- (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 addSubview:self.avatarImageView];
[self addSubview:self.headWearImageView];
[self addSubview:self.nobleImageView];
[self addSubview:self.nameStackView];
[self addSubview:self.idStackView];
[self addSubview:self.anchorLevel];
[self.nameStackView addArrangedSubview:self.nameLabel];
[self.idStackView addArrangedSubview:self.idLabel];
[self.idStackView addArrangedSubview:self.sexImageView];
[self addSubview:self.levelLabel];
[self addSubview:self.skillCardButton];
[self addSubview:self.attentionStackView];
[self.attentionStackView addArrangedSubview:self.attentionView];
[self.attentionStackView addArrangedSubview:self.fansView];
[self.attentionStackView addArrangedSubview:self.visitorView];
[self.attentionStackView addArrangedSubview:self.footprintView];
[self addSubview:self.accountView];
[self addSubview:self.nobleEntranceView];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAvatarImageView)];
[self.avatarImageView addGestureRecognizer:tap];
}
- (void)initSubViewConstraints {
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(68, 68));
make.left.mas_equalTo(self).offset(20);
make.top.mas_equalTo(self).offset(30 + kStatusBarHeight);
}];
[self.headWearImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.centerY.mas_equalTo(self.avatarImageView);
make.width.mas_equalTo(self.avatarImageView.mas_width).multipliedBy(1.31);
make.height.mas_equalTo(self.headWearImageView.mas_width);
}];
[self.nobleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.headWearImageView.mas_right).offset(9);
make.top.mas_equalTo(self.avatarImageView).mas_offset(14);
make.width.height.mas_equalTo(20);
}];
[self.nameStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.nobleImageView);
make.left.mas_equalTo(self.nobleImageView.mas_right).mas_offset(10);
make.height.mas_equalTo(16);
make.right.mas_equalTo(self.skillCardButton.mas_left).mas_offset(-2);
}];
[self.idStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nobleImageView);
make.top.mas_equalTo(self.nameStackView.mas_bottom).offset(10);
make.height.mas_equalTo(16);
}];
[self.levelLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nobleImageView);
make.top.mas_equalTo(self.idStackView.mas_bottom).offset(8);
}];
[self.skillCardButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.avatarImageView).mas_offset(-1);
make.right.mas_equalTo(14);
make.width.mas_equalTo(87);
make.height.mas_equalTo(28);
}];
[self.attentionStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.levelLabel.mas_bottom).mas_offset(16);
make.height.mas_equalTo(45);
make.left.mas_equalTo(15);
make.right.mas_equalTo(-15);
}];
CGFloat width = (KScreenWidth - 30) / 4;
CGFloat height = 45;
[self.attentionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(width, height));
}];
[self.fansView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(width, height));
}];
[self.visitorView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(width, height));
}];
[self.footprintView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(width, height));
}];
width = (KScreenWidth - 30 - 16) * 0.5;
height = width * 64 / 164;
[self.accountView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self);
make.size.mas_equalTo(CGSizeMake(width, height));
make.left.mas_equalTo(15);
}];
[self.nobleEntranceView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.accountView);
make.size.mas_equalTo(CGSizeMake(width, height));
make.right.mas_equalTo(-15);
}];
[self.anchorLevel mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(91);
make.height.mas_equalTo(28);
make.right.mas_equalTo(self);
make.bottom.mas_equalTo(self.skillCardButton.mas_top).offset(-14);
}];
}
#pragma mark - Action
- (void)tapAvatarImageView {
if (self.userInfo.parentMode) {
return;
}
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineHeadView:didClickAvatar:)]) {
[self.delegate xPMineHeadView:self didClickAvatar:self.userInfo];
}
}
///技能卡
- (void)tapSkillCardRecognizer {
if (self.delegate && [self.delegate respondsToSelector:@selector(xpMineHeadViewClickSkillCard)]) {
[self.delegate xpMineHeadViewClickSkillCard];
}
}
///粉丝
- (void)tapFansRecognizer {
if (self.delegate && [self.delegate respondsToSelector:@selector(xpMineHeadViewClickFans)]) {
[self.delegate xpMineHeadViewClickFans];
}
}
///关注
- (void)tapAttentionRecognizer {
if (self.delegate && [self.delegate respondsToSelector:@selector(xpMineHeadViewClickAttention)]) {
[self.delegate xpMineHeadViewClickAttention];
}
}
///访客
- (void)tapVisitorRecognizer {
if (self.delegate && [self.delegate respondsToSelector:@selector(xpMineHeadViewClickVisitor)]) {
[self.delegate xpMineHeadViewClickVisitor];
}
}
///足迹
- (void)tapFootprintRecognizer {
if (self.delegate && [self.delegate respondsToSelector:@selector(xpMineHeadViewClickFootprint)]) {
[self.delegate xpMineHeadViewClickFootprint];
}
}
///账号中心
- (void)tapAccountrecognizer {
if (self.delegate && [self.delegate respondsToSelector:@selector(xpMineHeadViewClickAcount)]) {
[self.delegate xpMineHeadViewClickAcount];
}
}
///贵族中心
- (void)tapNobleCenterrecognizer {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineHeadViewCliekNobleCenter)]) {
[self.delegate xPMineHeadViewCliekNobleCenter];
}
}
///青少年模式
- (void)tapTeenagerView {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPmineHeadViewClickTeenager)]) {
[self.delegate xPmineHeadViewClickTeenager];
}
}
- (void)anchorLevelAction:(UIButton *)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineHeadView:didClickAnchorLevel:)]) {
[self.delegate xPMineHeadView:self didClickAnchorLevel:self.anchorLevelInfo];
}
}
#pragma mark - NSMutableAttributedString
-(NSInteger) getMonth:(long )time
{
NSDate *date = [NSDate dateWithTimeIntervalSince1970:time/1000];
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDateComponents* components = [calendar components:NSCalendarUnitMonth fromDate:date];
NSInteger month = components.month;
return month;
}
- (NSInteger) getDay:(long) time
{
NSDate *date = [NSDate dateWithTimeIntervalSince1970:time/1000];
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDateComponents* components = [calendar components:NSCalendarUnitDay fromDate:date];
NSInteger day = components.day;
return day;
}
- (NSString *)calculateConstellationWithMonth:(long)time
{
NSString *astroString = @"魔羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯";
NSString *astroFormat = @"102123444543";
NSString *result;
NSInteger month = [self getMonth:time];
NSInteger day = [self getDay:time];
if (month<1 || month>12 || day<1 || day>31){
return @"错误日期格式!";
}
if(month==2 && day>29)
{
return @"错误日期格式!!";
}else if(month==4 || month==6 || month==9 || month==11) {
if (day>30) {
return @"错误日期格式!!!";
}
}
result=[NSString stringWithFormat:@"%@",[astroString substringWithRange:NSMakeRange(month*2-(day < [[astroFormat substringWithRange:NSMakeRange((month-1), 1)] intValue] - (-19))*2,2)]];
return [NSString stringWithFormat:@"%@座",result];
}
/// 生成一个图片的富文本
/// @param imageUrl 网络图片的地址
- (NSMutableAttributedString *)createUrlImageAttribute:(NSString *)imageUrl {
NetImageConfig *config = [[NetImageConfig alloc]init];
///先这样吧
config.autoLoad = YES;
NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageUrl config:config];
UIImage* image = imageView.image;
if (image) {
CGFloat scale = image.size.width / image.size.height;
imageView.bounds = CGRectMake(0, 0, 20 * scale, 20);
} else {
dispatch_async(dispatch_get_global_queue(0, 0), ^{
NSURL *imgUrl = [NSURL URLWithString:imageUrl];
UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
dispatch_async(dispatch_get_main_queue(), ^{
if (myImage) {
CGFloat scale = myImage.size.width / myImage.size.height;
imageView.bounds = CGRectMake(0, 0, 20 * scale, 20);
} else {
imageView.bounds = CGRectMake(0, 0, 20, 20);
}
});
});
}
imageView.layer.masksToBounds = YES;
imageView.contentMode = UIViewContentModeScaleAspectFit;
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.bounds.size.width, imageView.bounds.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
return attrString;
}
/// 占位的富文本
/// @param width 需要的间隙
- (NSMutableAttributedString *)createSapceAttribute:(CGFloat)width {
UIView *spaceView = [[UIView alloc]init];
spaceView.backgroundColor = [UIColor clearColor];
spaceView.bounds = CGRectMake(0, 0, width, 10);
NSMutableAttributedString * attribute = [NSMutableAttributedString yy_attachmentStringWithContent:spaceView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(spaceView.frame.size.width, spaceView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
return attribute;
}
//dateLabel
- (NSMutableAttributedString *)makeDateLabel:(long)birth{
NSString *dateStr = [NSString stringWithFormat:@" %@ ",[self calculateConstellationWithMonth:birth]];
UIButton *dataButton = [UIButton buttonWithType:UIButtonTypeCustom];
[dataButton setTitle:dateStr forState:UIControlStateNormal];
dataButton.titleLabel.font = [UIFont boldSystemFontOfSize:10];
[dataButton setTitleColor:UIColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
dataButton.frame = CGRectMake(0, 0, 45, 17);
dataButton.layer.masksToBounds = YES;
dataButton.layer.cornerRadius = 17/2;
[dataButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
NSMutableAttributedString * dateLabelString = [NSMutableAttributedString yy_attachmentStringWithContent:dataButton contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(dataButton.frame.size.width, dataButton.frame.size.height) alignToFont:[UIFont systemFontOfSize:11] alignment:YYTextVerticalAlignmentCenter];
return dateLabelString;
}
///铭牌
- (NSMutableAttributedString *)createNameplateAttibute:(NSString *)tagName image:(NSString *)imageName textFont:(UIFont *)textFont {
NetImageConfig *config = [[NetImageConfig alloc]init];
///先这样吧
config.autoLoad = YES;
NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageName config:config];
UIImage* image = imageView.image;
if (image) {
CGFloat scale = image.size.width / image.size.height;
imageView.bounds = CGRectMake(0, 0, 20 * scale, 20);
} else {
NSURL *imgUrl = [NSURL URLWithString:imageName];
UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
CGFloat scale = myImage.size.width / myImage.size.height;
if (scale == 0) {
imageView.bounds = CGRectMake(0, 0, 60, 20);
}else {
imageView.bounds = CGRectMake(0, 0, 20* scale, 20);
}
}
imageView.contentMode = UIViewContentModeScaleAspectFit;
// 铭牌文字
UILabel *label = [[UILabel alloc] init];
label.textAlignment = NSTextAlignmentCenter;
label.font = [UIFont boldSystemFontOfSize:12];
label.adjustsFontSizeToFitWidth = YES;
label.textColor = UIColor.whiteColor;
label.text = tagName;
[imageView addSubview:label];
[label mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(27);
make.right.mas_equalTo(-8);
make.centerY.mas_equalTo(0);
}];
NSMutableAttributedString *string = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:imageView.bounds.size alignToFont:[UIFont boldSystemFontOfSize:12] alignment:YYTextVerticalAlignmentCenter];
return string;
}
///当装扮铭牌时,我的页面中不需要显示铭牌标识
- (NSMutableAttributedString *)creatNameplateLevleAttribute:(UserInfoModel *)userInfo {
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init];
if (!userInfo) {
return attributedString;
}
//主播认证
if (userInfo.nameplateWord.length > 0 && userInfo.nameplatePic.length>0) {
[self createNameplateAttibute:userInfo.nameplateWord image:userInfo.nameplatePic textFont:[UIFont systemFontOfSize:9]];
[attributedString appendAttributedString:[self createSapceAttribute:2]];
}
// userRank 用户级别
if (userInfo.userLevelVo.experUrl) {
[attributedString appendAttributedString:[self createUrlImageAttribute:userInfo.userLevelVo.experUrl]];
[attributedString appendAttributedString:[self createSapceAttribute:2]];
}
//charmRank 魅力等级
if (userInfo.userLevelVo.charmUrl) {
[attributedString appendAttributedString:[self createUrlImageAttribute:userInfo.userLevelVo.charmUrl]];
[attributedString appendAttributedString:[self createSapceAttribute:2]];
}
// constellation 星座
if (userInfo.birth) {
[attributedString appendAttributedString:[self makeDateLabel:userInfo.birth]];
}
return attributedString;
}
#pragma mark - Getters And Setters
- (void)setUserInfo:(UserInfoModel *)userInfo {
_userInfo = userInfo;
if (_userInfo) {
NSString * headurl = userInfo.headwearEffect.length > 0 ? userInfo.headwearEffect : userInfo.headwearPic;
if (headurl.length >0) {
self.headWearImageView.hidden = NO;
NSURL *url = [NSURL URLWithString:headurl];
@kWeakify(self);
[self.manager loadSpriteSheetImageWithURL:url completionBlock:^(YYSpriteSheetImage * _Nullable sprit) {
@kStrongify(self);
self.headWearImageView.image = sprit;
} failureBlock:^(NSError * _Nullable error) {
}];
} else {
self.headWearImageView.hidden = YES;
}
self.idLabel.text = [NSString stringWithFormat:@"魔力号:%ld", (long)_userInfo.erbanNo];
self.nameLabel.text = _userInfo.nick.length > 0 ? _userInfo.nick : @"";
self.avatarImageView.imageUrl = userInfo.avatar;
if (userInfo.isReview) {
[self.avatarImageView loadImageWithUrl:userInfo.reviewingAvatar completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
UIImage * waterImage = [UIImage imageNamed:@"mine_avatar_reviewing"];
float ratio = waterImage.size.height / waterImage.size.width;
float rectY = image.size.height * (1 - ratio);
self.avatarImageView.image = [UIImage waterImageWithImage:image waterImage:waterImage waterImageRect:CGRectMake(0, rectY, image.size.width, image.size.height * ratio)];
}];
} else {
self.avatarImageView.imageUrl = userInfo.avatar;
}
self.nobleImageView.imageUrl = userInfo.userVipInfoVO.vipIcon;
UIImage *nobleImage = self.nobleImageView.image;
if (nobleImage) {
CGFloat scale = nobleImage.size.width / nobleImage.size.height;
[self.nobleImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(20* scale, 20));
}];
[self.nameStackView mas_updateConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nobleImageView.mas_right).mas_offset(5);
}];
} else {
[self.nobleImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(0, 20));
}];
[self.nameStackView mas_updateConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nobleImageView.mas_right);
}];
}
NSString * sexName;
if (userInfo.gender == GenderType_Male) {
sexName = @"common_male";
} else {
sexName = @"common_female";
}
self.sexImageView.image = [UIImage imageNamed:sexName];
self.levelLabel.attributedText = [self creatNameplateLevleAttribute:_userInfo];
self.fansView.number = [NSString stringWithFormat:@"%ld",_userInfo.fansNum];
self.attentionView.number = [NSString stringWithFormat:@"%ld",_userInfo.followNum];
self.visitorView.number = [NSString stringWithFormat:@"%ld", _userInfo.visitNum];
self.footprintView.number = [NSString stringWithFormat:@"%ld", _userInfo.inRoomNum];
self.nobleEntranceView.vipInfo = userInfo.userVipInfoVO;
if (userInfo.parentMode) {//青少年模式
if (!self.teenagerView.superview) {
[self addSubview:self.teenagerView];
[self.teenagerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.levelLabel.mas_bottom).mas_offset(16);
make.height.mas_equalTo(44);
make.left.right.mas_equalTo(self).inset(16);
}];
}
self.attentionStackView.hidden = YES;
self.accountView.hidden = YES;
self.nobleEntranceView.hidden = YES;
self.skillCardButton.hidden = YES;
} else {
[self.teenagerView removeFromSuperview];
self.teenagerView = nil;
self.attentionStackView.hidden = NO;
self.accountView.hidden = NO;
self.nobleEntranceView.hidden = NO;
self.skillCardButton.hidden = NO;
}
}
}
- (void)setWalletInfo:(WalletInfoModel *)walletInfo {
self.accountView.diamonds = walletInfo.diamonds;
}
- (void)setVisitorUnReadCount:(NSInteger)visitorUnReadCount {
self.visitorView.visitorNum = visitorUnReadCount;
}
- (void)setNobleInfo:(NobleCenterModel *)nobleInfo {
self.nobleEntranceView.nobleInfo = nobleInfo;
}
- (void)setAnchorLevelInfo:(AnchorLevelModel *)anchorLevelInfo {
_anchorLevelInfo = anchorLevelInfo;
if (_anchorLevelInfo) {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventRoom_grade_profit_pop_show];
self.anchorLevel.hidden = NO;
if ([_anchorLevelInfo.grade isEqualToString:@"S"]) {
[self.anchorLevel setBackgroundImage:[UIImage imageNamed:@"mine_anchor_level_enter_s"] forState:UIControlStateNormal];
} else if([_anchorLevelInfo.grade isEqualToString:@"B"]) {
[self.anchorLevel setBackgroundImage:[UIImage imageNamed:@"mine_anchor_level_enter_b"] forState:UIControlStateNormal];
} else if([_anchorLevelInfo.grade isEqualToString:@"C"]) {
[self.anchorLevel setBackgroundImage:[UIImage imageNamed:@"mine_anchor_level_enter_c"] forState:UIControlStateNormal];
}else if([_anchorLevelInfo.grade isEqualToString:@"D"]) {
[self.anchorLevel setBackgroundImage:[UIImage imageNamed:@"mine_anchor_level_enter_d"] forState:UIControlStateNormal];
} else {
[self.anchorLevel setBackgroundImage:[UIImage imageNamed:@"mine_anchor_level_enter_a"] forState:UIControlStateNormal];
}
} else {
self.anchorLevel.hidden = YES;
}
}
- (NetImageView *)avatarImageView {
if (!_avatarImageView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.imageType = ImageTypeUserIcon;
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
_avatarImageView.userInteractionEnabled = YES;
_avatarImageView.layer.masksToBounds = YES;
_avatarImageView.layer.cornerRadius = 34;
}
return _avatarImageView;
}
- (UIStackView *)nameStackView {
if (!_nameStackView) {
_nameStackView = [[UIStackView alloc] init];
_nameStackView.axis = UILayoutConstraintAxisHorizontal;
_nameStackView.distribution = UIStackViewDistributionFill;
_nameStackView.alignment = UIStackViewAlignmentCenter;
_nameStackView.spacing = 5;
}
return _nameStackView;
}
- (NetImageView *)nobleImageView {
if (!_nobleImageView) {
_nobleImageView = [[NetImageView alloc] init];
}
return _nobleImageView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:16];
_nameLabel.textColor = UIColorFromRGB(0x000000);
}
return _nameLabel;
}
- (UIStackView *)idStackView {
if (!_idStackView) {
_idStackView = [[UIStackView alloc] init];
_idStackView.axis = UILayoutConstraintAxisHorizontal;
_idStackView.distribution = UIStackViewDistributionFill;
_idStackView.alignment = UIStackViewAlignmentCenter;
_idStackView.spacing = 5;
}
return _idStackView;
}
- (UILabel *)idLabel {
if (!_idLabel) {
_idLabel = [[UILabel alloc] init];
_idLabel.font = [UIFont systemFontOfSize:13];
_idLabel.textColor = [ThemeColor secondTextColor];
}
return _idLabel;
}
- (UIImageView *)sexImageView {
if (!_sexImageView) {
_sexImageView = [[UIImageView alloc] init];
_sexImageView.userInteractionEnabled = YES;
}
return _sexImageView;
}
- (YYLabel *)levelLabel {
if (!_levelLabel) {
_levelLabel = [[YYLabel alloc] init];
_levelLabel.preferredMaxLayoutWidth = KScreenWidth - 88;
}
return _levelLabel;
}
- (UIButton *)skillCardButton {
if (!_skillCardButton) {
_skillCardButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_skillCardButton setImage:[UIImage imageNamed:@"mine_normal_skill_card"] forState:UIControlStateNormal];
[_skillCardButton setTitle:@"技能卡" forState:UIControlStateNormal];
_skillCardButton.titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
[_skillCardButton setTitleColor:UIColorFromRGB(0x000000) forState:UIControlStateNormal];
[_skillCardButton setImageEdgeInsets:UIEdgeInsetsMake(0, -10, 0, 0)];
_skillCardButton.backgroundColor = UIColorRGBAlpha(0xFFFFFF, 0.7);
_skillCardButton.layer.cornerRadius = 14;
_skillCardButton.layer.masksToBounds = YES;
[_skillCardButton addTarget:self action:@selector(tapSkillCardRecognizer) forControlEvents:UIControlEventTouchUpInside];
}
return _skillCardButton;
}
- (UIStackView *)attentionStackView {
if (!_attentionStackView) {
_attentionStackView = [[UIStackView alloc] init];
_attentionStackView.axis = UILayoutConstraintAxisHorizontal;
_attentionStackView.distribution = UIStackViewDistributionFill;
_attentionStackView.alignment = UIStackViewAlignmentFill;
}
return _attentionStackView;
}
- (XPMineFriendNumberView *)attentionView {
if (!_attentionView) {
_attentionView = [[XPMineFriendNumberView alloc] init];
_attentionView.title = @"关注";
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAttentionRecognizer)];
[_attentionView addGestureRecognizer:tap];
}
return _attentionView;
}
- (XPMineFriendNumberView *)fansView {
if (!_fansView) {
_fansView = [[XPMineFriendNumberView alloc] init];
_fansView.title = @"粉丝";
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapFansRecognizer)];
[_fansView addGestureRecognizer:tap];
}
return _fansView;
}
- (XPMineFriendNumberView *)visitorView {
if (!_visitorView) {
_visitorView = [[XPMineFriendNumberView alloc] init];
_visitorView.title = @"访客";
_visitorView.isVisitor = YES;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapVisitorRecognizer)];
[_visitorView addGestureRecognizer:tap];
}
return _visitorView;
}
- (XPMineFriendNumberView *)footprintView {
if (!_footprintView) {
_footprintView = [[XPMineFriendNumberView alloc] init];
_footprintView.title = @"足迹";
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapFootprintRecognizer)];
[_footprintView addGestureRecognizer:tap];
}
return _footprintView;
}
- (XPMineAccountView *)accountView {
if (!_accountView) {
_accountView = [[XPMineAccountView alloc] init];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAccountrecognizer)];
[_accountView addGestureRecognizer:tap];
}
return _accountView;
}
- (XPNobleCenterEntranceView *)nobleEntranceView {
if (!_nobleEntranceView) {
_nobleEntranceView = [[XPNobleCenterEntranceView alloc] init];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapNobleCenterrecognizer)];
[_nobleEntranceView addGestureRecognizer:tap];
}
return _nobleEntranceView;
}
- (XPMineHeadTeenagerView *)teenagerView {
if (!_teenagerView) {
_teenagerView = [[XPMineHeadTeenagerView alloc] init];
_teenagerView.layer.cornerRadius = 8;
_teenagerView.layer.masksToBounds = YES;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTeenagerView)];
[_teenagerView addGestureRecognizer:tap];
}
return _teenagerView;
}
- (YYAnimatedImageView *)headWearImageView {
if (!_headWearImageView) {
_headWearImageView = [[YYAnimatedImageView alloc] init];
_headWearImageView.backgroundColor = [UIColor clearColor];
_headWearImageView.contentMode = UIViewContentModeScaleAspectFit;
_headWearImageView.layer.masksToBounds = YES;
_headWearImageView.layer.cornerRadius = 10;
}
return _headWearImageView;
}
- (SpriteSheetImageManager *)manager {
if (!_manager) {
_manager = [[SpriteSheetImageManager alloc] init];
}
return _manager;
}
- (UIButton *)anchorLevel {
if (!_anchorLevel) {
_anchorLevel = [UIButton buttonWithType:UIButtonTypeCustom];
[_anchorLevel setImage:[UIImage imageNamed:@"mine_anchor_level_enter"] forState:UIControlStateNormal];
[_anchorLevel setImage:[UIImage imageNamed:@"mine_anchor_level_enter"] forState:UIControlStateSelected];
[_anchorLevel setTitle:@"主播评级" forState:UIControlStateNormal];
_anchorLevel.titleLabel.font = [UIFont systemFontOfSize:12];
[_anchorLevel setTitleColor:[ThemeColor mainTextColor] forState:UIControlStateNormal];
[_anchorLevel setTitleEdgeInsets:UIEdgeInsetsMake(0, 25, 0, 0)];
[_anchorLevel addTarget:self action:@selector(anchorLevelAction:) forControlEvents:UIControlEventTouchUpInside];
_anchorLevel.hidden = YES;
}
return _anchorLevel;
}
@end