Files
peko-ios/YuMi/Modules/YMMine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.m
eggmanQQQ dc7a2688cf temp save
2024-06-24 19:11:54 +08:00

1081 lines
41 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// XPMineHeaderView.m
// xplan-ios
//
// Created by 冯硕 on 2021/9/22.
//
#import "XPMineUserInfoHeaderView.h"
///Third
#import <Masonry/Masonry.h>
#import <SDCycleScrollView/SDCycleScrollView.h>
#import "SDPhotoBrowser.h"
#import <ReactiveObjC/ReactiveObjC.h>
#import <SVGA.h>
///Tool
#import "UIImage+ImageEffects.h"
#import "UIImage+Utils.h"
#import "NetImageView.h"
#import "XPSkillCardPlayerManager.h"
#import "XPRoomMiniManager.h"
///view
#import "XPMineUserInfoHeaderTagView.h"
///Model
#import "UserInfoModel.h"
#define StackSpring(axis) \
^{\
UIView *view = UIView.new; \
[view mas_makeConstraints:^(MASConstraintMaker *make) {\
if (axis == UILayoutConstraintAxisHorizontal) {\
make.width.mas_equalTo(1000).priorityLow();\
} else {\
make.height.mas_equalTo(1000).priorityLow();\
}\
}];\
return view;\
}()
@interface XPMineUserInfoHeaderView ()<SDCycleScrollViewDelegate, SDPhotoBrowserDelegate,XPMineUserInfoHeaderTagViewDelegate>
///轮播图
@property (nonatomic,strong) SDCycleScrollView *pi_cycleScrollView;
///显示当前的页数
@property (nonatomic,strong) UIButton *pageButton;
///审核中图标
@property (nonatomic,strong) UIImageView *reviewIcon;
///图片数组
@property (nonatomic,strong) NSArray *imageUrls;
///用户的头像和相册
@property (nonatomic,strong) NSMutableArray<UserPhoto *> *userPhtotArray;
///用户信息
@property (nonatomic,strong) UIView * userInfoView;
///用户信息的背景
@property (nonatomic,strong) UIStackView *nickStackView;
///名字
@property (nonatomic,strong) UILabel *nameLabel;
///sex
@property (nonatomic,strong) UIButton *sexImageView;
///正在直播父图
@property (nonatomic,strong) UIImageView *onlineView;
///正在直播icon图
@property (nonatomic,strong) SVGAImageView *onlineIconView;
///正在直播中tilte
@property (nonatomic,strong) UILabel *onlineTitleView;
///正在直播中
@property (nonatomic,strong) UIButton *onlineButton;
///
@property (nonatomic,strong) UIStackView *idStackView;
///靓号
@property (nonatomic,strong) UIImageView *beautifulImageView;
///id
@property (nonatomic,strong) UILabel *idLabel;
///魅力等级 等级 铭牌
@property (nonatomic,strong) UIStackView *tagStackView;
///魅力等级
@property (nonatomic,strong) NetImageView *charmImageView;
///等级
@property (nonatomic,strong) NetImageView *experImageView;
///代充
@property (nonatomic,strong) NetImageView *rechargeImageView;
///铭牌的容器
@property (nonatomic,strong) UIView * namePlateView;
///铭牌图片
@property (nonatomic,strong) NetImageView *nameplateImageView;
///铭牌文字
@property (nonatomic,strong) UILabel *nameplateLabel;
///新用户
@property (nonatomic,strong) UIImageView *newUserImageView;
///官方的
@property (nonatomic,strong) UIImageView *officalImageView;
///标签跟签名容器
@property (nonatomic,strong) UIStackView *singStackView;
///标签
@property (nonatomic,strong) XPMineUserInfoHeaderTagView *tagView;
///签名的背景
@property (nonatomic,strong) UIView * signBackView;
///签名
@property (nonatomic,strong) UILabel *signLabel;
///分割线
//@property (nonatomic,strong) UIView * lineView;
///头像的
@property (nonatomic,strong) UserPhoto *avatarPhoto;
///头像
@property (nonatomic,strong) NetImageView * avatarView;
///VIP等级icon
@property (nonatomic,strong) NetImageView *nobleImageView;
@property (nonatomic, strong) UIStackView *locateDateStackView;
@property (nonatomic, strong) UILabel *locateLabel;
@property (nonatomic, strong) UILabel *birthDateLabel;
@property (nonatomic, strong) UIImageView *relationshipView;
@property (nonatomic, strong) UILabel *fansNum;
@property (nonatomic, strong) UILabel *followersNum;
@end
@implementation XPMineUserInfoHeaderView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
// [self initSubViews];
// [self initSubViewConstraints];
[self setupUI];
}
return self;
}
#pragma mark - Private Method
- (void)setupUI {
[self addSubview:self.pi_cycleScrollView];
[self.pi_cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.top.mas_equalTo(self);
make.height.mas_equalTo(kGetScaleWidth(256));
}];
[self addSubview:self.onlineButton];
[self.onlineButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self);
make.top.mas_equalTo(self).offset(104);
make.size.mas_equalTo(CGSizeMake(63, 23));
}];
[self addSubview:self.pageButton];
[self.pageButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self);
make.top.mas_equalTo(self).offset(124);
make.size.mas_equalTo(CGSizeMake(63, 23));
}];
[self addSubview:self.userInfoView];
[self.userInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.mas_equalTo(self);
make.top.mas_equalTo(self).offset(kGetScaleWidth(224));
make.bottom.mas_equalTo(self);
}];
[self.userInfoView addSubview:self.avatarView];
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(kGetScaleWidth(72));
make.centerX.mas_equalTo(0);
make.centerY.equalTo(self.userInfoView.mas_top);
}];
[self setupNameArea];
[self setupIDArea];
[self setupLocateArea];
[self setupTagsArea];
[self setupCustomDesc];
[self setupRelationshipArea];
}
- (void)setupNameArea {
[self.userInfoView addSubview:self.nickStackView];
[self.nickStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.mas_equalTo(self.userInfoView);
make.top.mas_equalTo(self.avatarView.mas_bottom).offset(18);
}];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(25);
}];
[self.nobleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(20);
}];
[self.sexImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(28, 14));
}];
// [self.nickStackView addArrangedSubview:StackSpring(UILayoutConstraintAxisHorizontal)];
[self.nickStackView addArrangedSubview:self.nobleImageView];
[self.nickStackView addArrangedSubview:self.nameLabel];
[self.nickStackView addArrangedSubview:self.sexImageView];
// [self.nickStackView addArrangedSubview:StackSpring(UILayoutConstraintAxisHorizontal)];
}
- (void)setupIDArea {
[self.userInfoView addSubview:self.idStackView];
[self.idStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.mas_equalTo(self.userInfoView);
make.top.mas_equalTo(self.nickStackView.mas_bottom).offset(4);
}];
[self.beautifulImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(12, 15));
}];
[self.idLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(14);
}];
[self.idStackView addArrangedSubview:[UIView new]];
[self.idStackView addArrangedSubview:self.beautifulImageView];
[self.idStackView addArrangedSubview:self.idLabel];
[self.idStackView addArrangedSubview:[UIView new]];
}
- (void)setupLocateArea {
[self.userInfoView addSubview:self.locateDateStackView];
[self.locateDateStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.mas_equalTo(self.userInfoView);
make.top.mas_equalTo(self.idStackView.mas_bottom).offset(4);
}];
[self.locateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(16);
}];
[self.birthDateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(16);
}];
UILabel *line = [UILabel labelInitWithText:@"|"
font:self.locateLabel.font
textColor:self.locateLabel.textColor];
[self.locateDateStackView addArrangedSubview:StackSpring(UILayoutConstraintAxisHorizontal)];
[self.locateDateStackView addArrangedSubview:self.locateLabel];
[self.locateDateStackView addArrangedSubview:line];
[self.locateDateStackView addArrangedSubview:self.birthDateLabel];
[self.locateDateStackView addArrangedSubview:StackSpring(UILayoutConstraintAxisHorizontal)];
}
- (void)setupTagsArea {
[self.userInfoView addSubview:self.tagStackView];
[self.tagStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.locateDateStackView.mas_bottom).offset(4);
make.leading.trailing.mas_equalTo(self.userInfoView);
}];
[self.newUserImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(20);
}];
[self.officalImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(20);
}];
[self.experImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(20);
make.width.mas_equalTo(34);
}];
[self.charmImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(20);
make.width.mas_equalTo(34);
}];
[self.rechargeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(18);
make.width.mas_equalTo(54);
}];
[self.namePlateView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(30);
make.width.mas_equalTo(80);
}];
///用户信息中的标签
[self.tagStackView addArrangedSubview:[self stackSpaceView]];
[self.tagStackView addArrangedSubview:self.newUserImageView];
[self.tagStackView addArrangedSubview:self.officalImageView];
[self.tagStackView addArrangedSubview:self.experImageView];
[self.tagStackView addArrangedSubview:self.charmImageView];
[self.tagStackView addArrangedSubview:self.namePlateView];
[self.tagStackView addArrangedSubview:self.rechargeImageView];
[self.tagStackView addArrangedSubview:[self stackSpaceView]];
///铭牌
[self.namePlateView addSubview:self.nameplateImageView];
[self.namePlateView addSubview:self.nameplateLabel];
[self.nameplateImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(30);
make.top.mas_equalTo(0);
make.width.mas_equalTo(80);
}];
[self.nameplateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.mas_equalTo(self.nameplateImageView);
make.trailing.mas_equalTo(self.namePlateView).offset(-2);
}];
}
- (void)setupCustomDesc {
[self.userInfoView addSubview:self.signLabel];
[self.signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.userInfoView);
make.top.mas_equalTo(self.tagStackView.mas_bottom).offset(4);
make.width.mas_equalTo(KScreenWidth - 70);
}];
}
- (void)setupRelationshipArea {
[self.userInfoView addSubview:self.relationshipView];
[self.relationshipView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.signLabel.mas_bottom);
make.left.mas_equalTo(self.userInfoView).offset(14);
make.right.mas_equalTo(self.userInfoView).offset(-14);
make.height.mas_equalTo(55);
}];
UIView *line = [[UIView alloc] init];
line.backgroundColor = [UIColor colorWithWhite:1 alpha:0.6];
[self.relationshipView addSubview:line];
[line mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.relationshipView);
make.size.mas_equalTo(CGSizeMake(1.5, 20));
}];
UILabel *followerTitle = [UILabel labelInitWithText:@"关注"
font:[UIFont systemFontOfSize:13 weight:UIFontWeightBold]
textColor:[UIColor colorWithWhite:1 alpha:0.8]];
UILabel *fansTitle = [UILabel labelInitWithText:@"粉丝"
font:[UIFont systemFontOfSize:13 weight:UIFontWeightBold]
textColor:[UIColor colorWithWhite:1 alpha:0.8]];
[self.relationshipView addSubview:followerTitle];
[followerTitle mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.relationshipView).offset(10);
make.right.mas_equalTo(line.mas_left).offset(-60);
}];
[self.relationshipView addSubview:fansTitle];
[fansTitle mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.relationshipView).offset(10);
make.left.mas_equalTo(line.mas_right).offset(60);
}];
[self.relationshipView addSubview:self.followersNum];
[self.followersNum mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(followerTitle);
make.top.mas_equalTo(followerTitle.mas_bottom).offset(4);
}];
[self.relationshipView addSubview:self.fansNum];
[self.fansNum mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(fansTitle);
make.top.mas_equalTo(fansTitle.mas_bottom).offset(4);
}];
}
- (void)initSubViews {
[self addSubview:self.reviewIcon];
[self.onlineView addSubview:self.onlineIconView];
[self.onlineView addSubview:self.onlineTitleView];
[self.onlineView addSubview:self.onlineButton];
[self.singStackView addArrangedSubview:self.tagView];
[self.singStackView addArrangedSubview:self.signBackView];
[self.signBackView addSubview:self.signLabel];
@kWeakify(self);
SVGAParser * parser = [[SVGAParser alloc]init];
[parser parseWithNamed:@"pi_new_mine_info_online" inBundle:[NSBundle mainBundle] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
@kStrongify(self);
self.onlineIconView.loops = 0;
self.onlineIconView.clearsAfterStop = NO;
self.onlineIconView.videoItem = videoItem;
[self.onlineIconView startAnimation];
} failureBlock:^(NSError * _Nonnull error) {
}];
}
- (void)initSubViewConstraints {
[self.reviewIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.trailing.mas_equalTo(self);
make.width.mas_equalTo(85);
make.height.mas_equalTo(50);
}];
[self.onlineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.avatarView);
make.width.mas_equalTo(84);
make.leading.mas_equalTo(4);
make.height.mas_equalTo(22);
}];
[self.onlineIconView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(18);
make.top.mas_equalTo(3);
make.width.mas_equalTo(12);
make.height.mas_equalTo(12);
}];
[self.onlineTitleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.onlineIconView);
make.leading.mas_equalTo(32);
make.height.mas_equalTo(14);
}];
[self.onlineButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.onlineView);
}];
[self.pageButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(-15);
make.width.mas_equalTo(42);
make.height.mas_equalTo(22);
make.bottom.mas_equalTo(self.userInfoView.mas_top).offset(-8);
}];
[self.experImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(20);
make.width.mas_equalTo(34);
}];
[self.singStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(15);
make.top.mas_equalTo(103);
make.trailing.mas_equalTo(-15);
}];
[self.tagView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.equalTo(self.singStackView);
make.height.mas_equalTo(20);
}];
[self.signBackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_greaterThanOrEqualTo(10);
make.leading.trailing.equalTo(self.singStackView);
make.bottom.equalTo(self.userInfoView.mas_bottom).mas_offset(-17);
}];
[self.signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.signBackView);
}];
// [self.userShadowImageView.superview layoutIfNeeded];
}
#pragma mark - SDPhotoBrowserDelegate
- (NSURL *)photoBrowser:(SDPhotoBrowser *)browser highQualityImageURLForIndex:(NSInteger)index {
if(browser.isAvatar == YES){
return [NSURL URLWithString:self.avatarView.imageUrl];
}
NSString * photoUrl = [self.imageUrls objectAtIndex:index];
return [NSURL URLWithString:photoUrl];
}
- (UIImage *)photoBrowser:(SDPhotoBrowser *)browser placeholderImageForIndex:(NSInteger)index {
return [UIImageConstant defaultBannerPlaceholder];
}
#pragma mark - SDCycleScrollViewDelegate
-(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index {
[self.pageButton setTitle:[NSString stringWithFormat:@"%ld/%lu",(index + 1), (unsigned long)self.imageUrls.count] forState:UIControlStateNormal];
UserPhoto * photo = [self.userPhtotArray objectAtIndex:index];
self.reviewIcon.hidden = !photo.isReview;
}
// 轮播图点击
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
NSInteger count = self.imageUrls.count;
SDPhotoBrowser *browser = [[SDPhotoBrowser alloc]init];
browser.sourceImagesContainerView = self.pi_cycleScrollView;
browser.delegate = self;
browser.imageCount = count;
browser.currentImageIndex = index;
browser.isMe = NO;
[browser show];
}
///复制id
-(void)copyNameAction{
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"XPMineUserInfoHeaderView0")];
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard. string = [NSString stringWithFormat:@"%ld", (long)_userInfo.erbanNo];
}
-(void)toSoundAction{
}
-(void)setPlaySoundStatus:(BOOL)isPlay{
}
-(void)setPlaySoundTime:(NSInteger)time{
}
#pragma mark - XPMineUserInfoHeaderTagView
- (void)didClickGotoIvidualView{
if(self.delegate && [self.delegate respondsToSelector:@selector(xPMineUserInfoHeaderView:didClickGotoEditView:)]){
[self.delegate xPMineUserInfoHeaderView:self didClickGotoEditView:self.tagView.itemList];
}
}
- (void)didClickGotoEditVC{
if(self.delegate && [self.delegate respondsToSelector:@selector(xPMineUserInfoHeaderView:didClickGotoEditVC:)]){
[self.delegate xPMineUserInfoHeaderView:self didClickGotoEditVC:self.tagView.itemList];
}
}
#pragma mark - Event Response
-(void)clickAvatarAction{
SDPhotoBrowser *browser = [[SDPhotoBrowser alloc]init];
browser.sourceImagesContainerView = self.avatarView;
browser.delegate = self;
browser.imageCount = 1;
browser.currentImageIndex = 0;
browser.isMe = NO;
browser.isAvatar = YES;
[browser show];
}
- (void)onlineButtonAction:(UIButton *)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineUserInfoHeaderView:didClickGoToRoom:)]) {
[self.delegate xPMineUserInfoHeaderView:self didClickGoToRoom:self.roomUid];
}
}
-(void)playSoundAction{
}
#pragma mark - Getters And Setters
- (void)setUserInfo:(UserInfoModel *)userInfo {
_userInfo = userInfo;
if (_userInfo) {
self.nameLabel.text = _userInfo.nick;
self.birthDateLabel.text = @"1987-99-00";//[NSString calculateConstellationWithMonth:userInfo.birth];
self.locateLabel.text = userInfo.region; //@"苏格拉场";
NSString *text = [NSString stringWithFormat:@"ID:%ld", (long)_userInfo.erbanNo];
NSMutableAttributedString *textAtt = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@ ",text] attributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x6D6B89)}];
NSTextAttachment * attachment = [[NSTextAttachment alloc] init];
UIImage *iconImage = [UIImage imageNamed:@"user_card_copy_id1"];;
attachment.bounds = CGRectMake(0, roundf(self.idLabel.font.capHeight - iconImage.size.height)/2.f, iconImage.size.width, iconImage.size.height);
attachment.image = iconImage;
[textAtt insertAttributedString:[NSMutableAttributedString attributedStringWithAttachment:attachment] atIndex:textAtt.length];
self.idLabel.attributedText = textAtt;
self.signLabel.text = _userInfo.userDesc.length > 0 ? _userInfo.userDesc : YMLocalizedString(@"XPTreasureFairyFriendCell0");
self.fansNum.text = [@(_userInfo.fansNum) stringValue];
self.followersNum.text = [@(_userInfo.followNum) stringValue];;
[self.sexImageView setTitle:[NSString getAgeWithBirth:_userInfo.birth] forState:UIControlStateNormal];
self.sexImageView.backgroundColor = _userInfo.gender == GenderType_Male ? UIColorFromRGB(0x6BB3FF) :UIColorFromRGB(0xFF80CC);
self.sexImageView.titleEdgeInsets = _userInfo.gender != GenderType_Male ? UIEdgeInsetsMake(0, 2, 0, 0):UIEdgeInsetsMake(0, -1, 0, 0);
self.sexImageView.selected = _userInfo.gender != GenderType_Male;
self.officalImageView.hidden = userInfo.defUser != UserLevelType_Offical;
self.beautifulImageView.hidden = !userInfo.hasPrettyErbanNo;
self.newUserImageView.hidden = !userInfo.newUser;
if (userInfo.userLevelVo.experUrl) {
[self.experImageView loadImageWithUrl:userInfo.userLevelVo.experUrl completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
self.experImageView.image = image;
CGFloat width = image.size.width*20/ (image.size.height > 0 ? image.size.height : 1);
[self.experImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(20);
make.width.mas_equalTo(width);
}];
}];
}
self.experImageView.hidden = userInfo.userLevelVo.experUrl.length <= 0;
if (userInfo.userLevelVo.charmUrl) {
[self.charmImageView loadImageWithUrl:userInfo.userLevelVo.charmUrl completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
self.charmImageView.image = image;
CGFloat width = image.size.width*20/ (image.size.height > 0 ? image.size.height : 1);
[self.charmImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(20);
make.width.mas_equalTo(width);
}];
}] ;
}
self.charmImageView.hidden = userInfo.userLevelVo.charmUrl.length <= 0;
if(userInfo.isCustomWord == YES){
if (userInfo.nameplatePic.length > 0) {
self.nameplateImageView.imageUrl = userInfo.nameplatePic;
self.namePlateView.hidden = NO;
} else {
self.namePlateView.hidden = YES;
}
}else{
if (userInfo.nameplateWord.length > 0 && userInfo.nameplatePic.length > 0) {
self.nameplateImageView.imageUrl = userInfo.nameplatePic;
self.nameplateLabel.text = userInfo.nameplateWord;
self.namePlateView.hidden = NO;
} else {
self.namePlateView.hidden = YES;
}
}
self.rechargeImageView.hidden = !_userInfo.isRechargeUser;
[self.userPhtotArray removeAllObjects];
// 轮播图
NSMutableArray * imageUrls = [NSMutableArray array];
if (userInfo.avatar) {
[imageUrls addObject:userInfo.avatar];
if (![self.userPhtotArray containsObject:self.avatarPhoto]) {
[self.userPhtotArray addObject:self.avatarPhoto];
}
self.avatarPhoto.isReview = userInfo.isReview;
self.avatarPhoto.photoUrl = userInfo.avatar;
self.avatarView.imageUrl = userInfo.avatar;
}
if (self.userInfo.privatePhoto.count > 0) {
for (int i = 0; i < self.userInfo.privatePhoto.count; i++) {
UserPhoto * photo = [self.userInfo.privatePhoto objectAtIndex:i];
if (photo.photoUrl.length > 0) {
[self.userPhtotArray addObject:photo];
[imageUrls addObject:photo.photoUrl];
}
}
}
if (imageUrls.count > 0) {
self.imageUrls = imageUrls;
self.pi_cycleScrollView.imageURLStringsGroup = imageUrls;
[self.pageButton setTitle:[NSString stringWithFormat:@"1/%lu",(unsigned long)imageUrls.count] forState:UIControlStateNormal];;
// 要初始化一下当前的审核状态
if(self.userPhtotArray.count > 0){
self.reviewIcon.hidden = ![self.userPhtotArray objectAtIndex:0].isReview;
}
}
}
// self.nobleImageView.hidden = userInfo.userVipInfoVO.vipIcon.length == 0;
[self.nobleImageView loadImageWithUrl:userInfo.userVipInfoVO.vipIcon completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
self.nobleImageView.image = image;
CGFloat height = image.size.height > 0 ? image.size.height : 1;
CGFloat scale = image.size.width / height ;
[self.nobleImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(30* scale, 30));
}];
}];
}
- (void)setRoomUid:(NSString *)roomUid {
_roomUid = roomUid;
if([XPSkillCardPlayerManager shareInstance].isInRoom == YES || [[XPRoomMiniManager shareManager] getRoomInfo] != nil){
self.onlineView.hidden = _roomUid.length <= 0;
}else{
self.onlineView.hidden = YES;
}
}
-(void)setTagModel:(XPMineUserInfoTagModel *)tagModel{
_tagModel = tagModel;
NSMutableArray *itemList = [NSMutableArray array];
for (NSString *text in _tagModel.meLabels) {
if(text.length > 0){
XPMineUserInfoTagItemModel *model = [XPMineUserInfoTagItemModel new];
model.label = text;
CGRect stringRect = [text boundingRectWithSize:CGSizeMake(MAXFLOAT, 18) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10 weight:UIFontWeightRegular]} context:nil];
model.width = stringRect.size.width + 14;
[itemList addObject:model];
}
}
NSString *uid = [[AccountInfoStorage instance]getUid];
BOOL isMe = self.userInfo.uid == uid.integerValue;
if(isMe == YES){
_tagView.hidden = YES;
}else{
// _tagView.hidden = !(itemList.count > 0);
_tagView.hidden = YES;
}
_tagView.uid = @(self.userInfo.uid).stringValue;
_tagView.itemList = itemList;
}
- (UIView *)userInfoView {
if (!_userInfoView) {
_userInfoView = [[UIView alloc] init];
_userInfoView.backgroundColor = [UIColor clearColor];
_userInfoView.backgroundColor = [UIColor yellowColor];
_userInfoView.layer.masksToBounds = NO;
_userInfoView.layer.cornerRadius = 8;
}
return _userInfoView;
}
- (UIStackView *)nickStackView {
if (!_nickStackView) {
_nickStackView = [[UIStackView alloc] init];
_nickStackView.backgroundColor = [UIColor systemBlueColor];
_nickStackView.axis = UILayoutConstraintAxisHorizontal;
_nickStackView.distribution = UIStackViewDistributionEqualCentering;
_nickStackView.alignment = UIStackViewAlignmentCenter;
_nickStackView.spacing = 5;
}
return _nickStackView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightBold];
_nameLabel.textColor = UIColorFromRGB(0x1A1A1A);
}
return _nameLabel;
}
- (UIButton *)sexImageView {
if (!_sexImageView) {
_sexImageView = [[UIButton alloc] init];
[_sexImageView setImage:kImage(@"home_age_boy_icon") forState:UIControlStateNormal];
[_sexImageView setImage:kImage(@"home_age_girl_icon") forState:UIControlStateSelected];
_sexImageView.titleLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightMedium];
[_sexImageView setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_sexImageView.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
_sexImageView.layer.cornerRadius = 14/2;
_sexImageView.layer.masksToBounds = YES;
}
return _sexImageView;
}
- (UIStackView *)idStackView {
if (!_idStackView) {
_idStackView = [[UIStackView alloc] init];
_idStackView.backgroundColor = [UIColor greenColor];
_idStackView.axis = UILayoutConstraintAxisHorizontal;
_idStackView.distribution = UIStackViewDistributionEqualCentering;
_idStackView.alignment = UIStackViewAlignmentCenter;
_idStackView.spacing = 5;
}
return _idStackView;
}
- (UIImageView *)beautifulImageView {
if (!_beautifulImageView) {
_beautifulImageView = [[UIImageView alloc] init];
_beautifulImageView.userInteractionEnabled = YES;
_beautifulImageView.image = [UIImage getLanguageImage:@"common_icon_beautiful"];
}
return _beautifulImageView;
}
- (UILabel *)idLabel {
if (!_idLabel) {
_idLabel = [[UILabel alloc] init];
_idLabel.font = [UIFont systemFontOfSize:11 weight:UIFontWeightMedium];
_idLabel.textColor = UIColorFromRGB(0x191919);
_idLabel.userInteractionEnabled = YES;
UITapGestureRecognizer *longPress = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(copyNameAction)];
[_idLabel addGestureRecognizer:longPress];
}
return _idLabel;
}
-(UIImageView *)onlineView{
if (!_onlineView){
_onlineView = [UIImageView new];
UIImage *image = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor],[DJDKMIMOMColor confirmButtonGradientMiddleColor],[DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:1 imgSize:CGSizeMake(84, 22)];
_onlineView.image = image;
_onlineView.userInteractionEnabled = YES;
_onlineView.hidden = YES;
}
return _onlineView;
}
- (SVGAImageView *)onlineIconView {
if (_onlineIconView == nil) {
_onlineIconView = [[SVGAImageView alloc]init];
_onlineIconView.contentMode = UIViewContentModeScaleToFill;
_onlineIconView.userInteractionEnabled = NO;
_onlineIconView.backgroundColor = [UIColor clearColor];
}
return _onlineIconView;
}
-(UILabel *)onlineTitleView{
if (!_onlineTitleView){
_onlineTitleView = [UILabel labelInitWithText:YMLocalizedString(@"XPMineUserInfoHeaderView3") font:[UIFont systemFontOfSize:11 weight:UIFontWeightRegular] textColor:[UIColor whiteColor]];
}
return _onlineTitleView;
}
- (UIButton *)onlineButton {
if (!_onlineButton) {
_onlineButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_onlineButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x41EABA), UIColorFromRGB(0x26cc9c)]
gradientType:GradientTypeTopToBottom
imgSize:CGSizeMake(63, 23)]
forState:UIControlStateNormal];
[_onlineButton addTarget:self
action:@selector(onlineButtonAction:)
forControlEvents:UIControlEventTouchUpInside];
[_onlineButton setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
}
return _onlineButton;
}
- (SDCycleScrollView *)pi_cycleScrollView {
if (!_pi_cycleScrollView) {
_pi_cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero
delegate:self
placeholderImage:[UIImageConstant defaultBannerPlaceholder]];
_pi_cycleScrollView.backgroundColor = [UIColor clearColor];
_pi_cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
_pi_cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleNone;
_pi_cycleScrollView.autoScroll = NO;
// SDCycleScrollView没有适配阿语在RTL下会乱滚都用LTR算了
_pi_cycleScrollView.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
for (UIView *subView in _pi_cycleScrollView.subviews) {
subView.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
}
}
return _pi_cycleScrollView;
}
- (UIButton *)pageButton {
if (!_pageButton) {
_pageButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_pageButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_pageButton.titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
_pageButton.backgroundColor = UIColorRGBAlpha(0x000000, 0.4);
_pageButton.layer.cornerRadius = 11;
_pageButton.layer.masksToBounds = YES;
}
return _pageButton;
}
- (UIImageView *)reviewIcon {
if (!_reviewIcon) {
_reviewIcon = [[UIImageView alloc] init];
_reviewIcon.image = [UIImage getLanguageImage:@"mine_album_reviewing"];
_reviewIcon.hidden = YES;
}
return _reviewIcon;
}
- (UIStackView *)tagStackView {
if (!_tagStackView) {
_tagStackView = [[UIStackView alloc] init];
_tagStackView.axis = UILayoutConstraintAxisHorizontal;
_tagStackView.distribution = UIStackViewDistributionEqualCentering;
_tagStackView.alignment = UIStackViewAlignmentCenter;
_tagStackView.spacing = 2;
}
return _tagStackView;
}
- (NetImageView *)experImageView {
if (!_experImageView) {
NetImageConfig * config = [[NetImageConfig alloc] init];
config.imageType = ImageTypeUserCardLevel;
_experImageView = [[NetImageView alloc] initWithConfig:config];
_experImageView.userInteractionEnabled = YES;
_experImageView.hidden = YES;
_experImageView.contentMode = UIViewContentModeScaleToFill;
}
return _experImageView;
}
- (NetImageView *)charmImageView {
if (!_charmImageView) {
NetImageConfig * config = [[NetImageConfig alloc] init];
config.imageType = ImageTypeUserCardLevel;
_charmImageView = [[NetImageView alloc] initWithConfig:config];
_charmImageView.userInteractionEnabled = YES;
_charmImageView.hidden = YES;
_charmImageView.contentMode = UIViewContentModeScaleToFill;
}
return _charmImageView;
}
- (UIView *)namePlateView {
if (!_namePlateView) {
_namePlateView = [[UIView alloc] init];
_namePlateView.backgroundColor = [UIColor clearColor];
_namePlateView.hidden = YES;
}
return _namePlateView;
}
- (NetImageView *)nameplateImageView {
if (!_nameplateImageView) {
NetImageConfig * config = [[NetImageConfig alloc] init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
config.imageType = ImageTypeUserCardLevel;
_nameplateImageView = [[NetImageView alloc] initWithConfig:config];
_nameplateImageView.userInteractionEnabled = YES;
_nameplateImageView.contentMode = UIViewContentModeScaleAspectFit;
}
return _nameplateImageView;
}
- (UILabel *)nameplateLabel {
if (!_nameplateLabel) {
_nameplateLabel = [[UILabel alloc] init];
_nameplateLabel.font = [UIFont systemFontOfSize:10];
_nameplateLabel.textAlignment = NSTextAlignmentCenter;
_nameplateLabel.textColor = [UIColor whiteColor];
}
return _nameplateLabel;
}
- (UIImageView *)newUserImageView {
if (!_newUserImageView) {
_newUserImageView = [[UIImageView alloc] init];
_newUserImageView.userInteractionEnabled = YES;
_newUserImageView.image = [UIImage getLanguageImage:@"common_new_user"];
_newUserImageView.hidden = YES;
}
return _newUserImageView;
}
- (UIImageView *)officalImageView {
if (!_officalImageView) {
_officalImageView = [[UIImageView alloc] init];
_officalImageView.userInteractionEnabled = YES;
_officalImageView.image = [UIImage imageNamed:@"common_offical"];
_officalImageView.hidden = YES;
}
return _officalImageView;
}
- (UIView *)signBackView {
if (!_signBackView) {
_signBackView = [[UIView alloc] init];
_signBackView.backgroundColor = [UIColor whiteColor];
}
return _signBackView;
}
//- (UIView *)lineView {
// if (!_lineView) {
// _lineView = [[UIView alloc] init];
// _lineView.backgroundColor = [DJDKMIMOMColor dividerColor];
// }
// return _lineView;
//}
- (UILabel *)signLabel {
if (!_signLabel) {
_signLabel = [[UILabel alloc] init];
_signLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
_signLabel.textColor = UIColorFromRGB(0x1a1a1a);
_signLabel.numberOfLines = 2;
_signLabel.textAlignment = NSTextAlignmentCenter;
}
return _signLabel;
}
- (NSMutableArray *)userPhtotArray {
if (!_userPhtotArray) {
_userPhtotArray = [NSMutableArray array];
}
return _userPhtotArray;
}
- (UserPhoto *)avatarPhoto {
if (!_avatarPhoto) {
_avatarPhoto = [[UserPhoto alloc] init];
}
return _avatarPhoto;
}
-(NetImageView *)avatarView{
if (!_avatarView){
NetImageConfig * config = [[NetImageConfig alloc] init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
config.imageType = ImageTypeUserIcon;
_avatarView = [[NetImageView alloc]initWithConfig:config];
_avatarView.layer.cornerRadius = kGetScaleWidth(36);
_avatarView.layer.masksToBounds = YES;
_avatarView.layer.borderWidth = 1;
_avatarView.userInteractionEnabled = YES;
_avatarView.layer.borderColor = [UIColor whiteColor].CGColor;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickAvatarAction)];
[_avatarView addGestureRecognizer:tap];
}
return _avatarView;
}
-(XPMineUserInfoHeaderTagView *)tagView{
if (!_tagView){
_tagView = [[XPMineUserInfoHeaderTagView alloc]initWithFrame:CGRectZero];
_tagView.delegate = self;
}
return _tagView;
}
- (UIStackView *)singStackView {
if (!_singStackView) {
_singStackView = [[UIStackView alloc] init];
_singStackView.backgroundColor = [UIColor systemRedColor];
_singStackView.axis = UILayoutConstraintAxisVertical;
_singStackView.distribution = UIStackViewDistributionFill;
_singStackView.alignment = UIStackViewAlignmentCenter;
_singStackView.spacing = 11;
}
return _singStackView;
}
- (NetImageView *)rechargeImageView{
if(!_rechargeImageView){
_rechargeImageView = [NetImageView new];
_rechargeImageView.image = [UIImage getLanguageImage:@"mine_info_recharge"];
_rechargeImageView.hidden = YES;
}
return _rechargeImageView;
}
- (NetImageView *)nobleImageView {
if (!_nobleImageView) {
_nobleImageView = [[NetImageView alloc] init];
_nobleImageView.backgroundColor = [UIColor purpleColor];
// _nobleImageView.hidden = YES;
}
return _nobleImageView;
}
- (UIStackView *)locateDateStackView {
if (!_locateDateStackView) {
_locateDateStackView = [[UIStackView alloc] init];
_locateDateStackView.backgroundColor = [UIColor systemRedColor];
_locateDateStackView.axis = UILayoutConstraintAxisHorizontal;
_locateDateStackView.distribution = UIStackViewDistributionFill;
_locateDateStackView.alignment = UIStackViewAlignmentCenter;
_locateDateStackView.spacing = 6;
}
return _locateDateStackView;
}
- (UILabel *)locateLabel {
if (!_locateLabel) {
_locateLabel = [[UILabel alloc] init];
_locateLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
_locateLabel.textColor = UIColorFromRGB(0x1a1a1a);
}
return _locateLabel;
}
- (UILabel *)birthDateLabel {
if (!_birthDateLabel) {
_birthDateLabel = [[UILabel alloc] init];
_birthDateLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
_birthDateLabel.textColor = UIColorFromRGB(0x1a1a1a);
}
return _birthDateLabel;
}
- (UIImageView *)relationshipView {
if (!_relationshipView) {
_relationshipView = [[UIImageView alloc] init];
_relationshipView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x41EABA), UIColorFromRGB(0x26cc9c)]
gradientType:GradientTypeTopToBottom
imgSize:CGSizeMake(360, 55)];
_relationshipView.userInteractionEnabled = YES;
}
return _relationshipView;
}
- (UIView *)stackSpaceView {
return [UIView new];
}
- (UILabel *)fansNum {
if (!_fansNum) {
_fansNum = [[UILabel alloc] init];
_fansNum.font = [UIFont systemFontOfSize:18 weight:UIFontWeightBold];
_fansNum.textColor = [UIColor whiteColor];
}
return _fansNum;
}
- (UILabel *)followersNum {
if (!_followersNum) {
_followersNum = [[UILabel alloc] init];
_followersNum.font = [UIFont systemFontOfSize:18 weight:UIFontWeightBold];
_followersNum.textColor = [UIColor whiteColor];
}
return _followersNum;
}
@end