Files
peko-ios/YuMi/Modules/YMMine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.m
2024-04-03 17:18:44 +08:00

1130 lines
42 KiB
Objective-C

//
// 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"
@interface XPMineUserInfoHeaderView ()<SDCycleScrollViewDelegate, SDPhotoBrowserDelegate,XPMineUserInfoHeaderTagViewDelegate>
///轮播图
@property (nonatomic,strong) SDCycleScrollView *pi_cycleScrollView;
///背景图
@property (nonatomic,strong) UIImageView *bgView;
///覆盖的view
@property (nonatomic,strong) UIImageView * coverImageView;
///显示当前的页数
@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) UIImageView *usershadowImageView;
@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 *beautifulImageViw;
///id
@property (nonatomic,strong) UILabel *idLabel;
///空白的占位图
@property (nonatomic,strong) UIView * spaceView;
///粉丝数
@property (nonatomic,strong) UILabel *fansNumLabel;
///魅力等级 等级 铭牌
@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;
///声音背景
@property (nonatomic,strong) UIImageView *soundView;
///声音播放
@property (nonatomic,strong) UIButton *palySoundBtn;
///声音动效
@property (nonatomic,strong) SVGAImageView *soundSVGAView;
///声音时间
@property (nonatomic,strong) UILabel *soundTimeView;
///录制声音提示
@property (nonatomic,strong) UILabel *soundPromptView;
///录制声音按钮
@property (nonatomic,strong) UIButton *toSoundBtn;
///贵族等级icon
@property (nonatomic,strong) NetImageView *nobleImageView;
@end
@implementation XPMineUserInfoHeaderView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.pi_cycleScrollView];
[self addSubview:self.coverImageView];
[self addSubview:self.bgView];
[self addSubview:self.reviewIcon];
[self addSubview:self.userInfoView];
[self addSubview:self.pageButton];
[self addSubview:self.avatarView];
[self addSubview:self.soundView];
[self.avatarView addSubview:self.onlineView];
[self.onlineView addSubview:self.onlineIconView];
[self.onlineView addSubview:self.onlineTitleView];
[self.onlineView addSubview:self.onlineButton];
[self.userInfoView addSubview:self.usershadowImageView];
[self.usershadowImageView addSubview:self.singStackView];
// [self.userInfoView addSubview:self.lineView];
[self.usershadowImageView addSubview:self.nickStackView];
[self.usershadowImageView addSubview:self.idStackView];
[self.usershadowImageView addSubview:self.tagStackView];
[self.soundView addSubview:self.palySoundBtn];
[self.soundView addSubview:self.soundSVGAView];
[self.soundView addSubview:self.soundTimeView];
[self.soundView addSubview:self.soundPromptView];
[self.soundView addSubview:self.toSoundBtn];
[self.nickStackView addArrangedSubview:self.nobleImageView];
[self.nickStackView addArrangedSubview:self.nameLabel];
[self.nickStackView addArrangedSubview:self.sexImageView];
[self.idStackView addArrangedSubview:self.beautifulImageViw];
[self.idStackView addArrangedSubview:self.idLabel];
[self.idStackView addArrangedSubview:self.spaceView];
[self.idStackView addArrangedSubview:self.fansNumLabel];
///用户信息中的标签
[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.namePlateView addSubview:self.nameplateImageView];
[self.namePlateView addSubview:self.nameplateLabel];
[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) {
}];
SVGAParser *soundParser = [SVGAParser new];
[soundParser parseWithNamed:@"pi_new_mine_info_sound_play" inBundle:[NSBundle mainBundle] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
@kStrongify(self);
self.soundSVGAView.loops = 0;
self.soundSVGAView.clearsAfterStop = NO;
self.soundSVGAView.videoItem = videoItem;
} failureBlock:^(NSError * _Nonnull error) {
}];
}
- (void)initSubViewConstraints {
[self.pi_cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(self);
make.height.mas_equalTo(245);
}];
[self.coverImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.pi_cycleScrollView);
}];
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.left.right.equalTo(self.pi_cycleScrollView);
make.height.mas_equalTo(25);
}];
[self.reviewIcon mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.right.mas_equalTo(self);
make.width.mas_equalTo(85);
make.height.mas_equalTo(50);
}];
[self.userInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self);
make.bottom.mas_equalTo(self);
make.height.mas_greaterThanOrEqualTo(133);
}];
[self.usershadowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(15);
make.right.mas_equalTo(-15);
make.top.height.mas_equalTo(self.userInfoView);
}];
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(88);
make.left.mas_equalTo(30);
make.top.equalTo(self.userInfoView.mas_top).mas_offset(-28);
}];
[self.onlineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.avatarView);
make.width.mas_equalTo(84);
make.left.mas_equalTo(4);
make.height.mas_equalTo(22);
}];
[self.onlineIconView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.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.left.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.right.mas_equalTo(-15);
make.width.mas_equalTo(42);
make.height.mas_equalTo(22);
make.bottom.mas_equalTo(self.userInfoView.mas_top).offset(-8);
}];
// [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.right.mas_equalTo(self.userInfoView).inset(15);
// make.bottom.mas_equalTo(self.userInfoView);
// make.height.mas_equalTo(1);
// }];
[self.nickStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.usershadowImageView).offset(115);
make.top.mas_equalTo(self.usershadowImageView).offset(11);
make.right.lessThanOrEqualTo(@(-15));
}];
[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.idStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nickStackView);
make.top.mas_equalTo(self.nickStackView.mas_bottom).offset(4);
make.right.mas_equalTo(-15);
}];
[self.beautifulImageViw mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(15, 15));
}];
[self.spaceView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.greaterThanOrEqualTo(@10);
make.height.mas_equalTo(15);
}];
[self.tagStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.usershadowImageView).offset(15);
make.top.mas_equalTo(self.userInfoView).offset(68);
make.right.lessThanOrEqualTo(@70);
}];
[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.newUserImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(20);
}];
[self.officalImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(20);
}];
[self.namePlateView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(20);
make.width.mas_equalTo(self.nameplateImageView.mas_width);
}];
[self.nameplateImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(30);
make.top.mas_equalTo(-5);
make.width.mas_equalTo(80);
}];
[self.nameplateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.mas_equalTo(self.nameplateImageView);
make.right.mas_equalTo(self.namePlateView).offset(-2);
}];
[self.singStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(15);
make.top.mas_equalTo(103);
make.right.mas_equalTo(-15);
}];
[self.tagView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.singStackView);
make.height.mas_equalTo(20);
}];
[self.signBackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_greaterThanOrEqualTo(10);
make.left.right.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.soundView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-15);
make.width.mas_equalTo(98);
make.height.mas_equalTo(28);
make.bottom.equalTo(self.userInfoView.mas_top).mas_offset(-5);
}];
[self.palySoundBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(18);
make.top.mas_equalTo(5);
make.left.mas_equalTo(4);
}];
[self.soundSVGAView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(27);
make.width.mas_equalTo(35);
make.height.mas_equalTo(19);
make.centerY.equalTo(self.soundView);
}];
[self.soundTimeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(67);
make.centerY.equalTo(self.soundView);
}];
[self.soundPromptView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-8);
make.centerY.equalTo(self.soundView);
}];
[self.toSoundBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.soundView);
}];
[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 defalutBannerPlaceholder];
}
#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{
if(self.soundTimeView.hidden == NO){
[self playSoundAction];
return;
}
if(self.delegate && [self.delegate respondsToSelector:@selector(didClickGoToPlaySound)]){
[self.delegate didClickGoToPlaySound];
}
}
-(void)setPlaySoundStatus:(BOOL)isPlay{
self.palySoundBtn.selected = isPlay;
if(self.palySoundBtn.selected == YES){
[self.soundSVGAView startAnimation];
}else{
[self.soundSVGAView stopAnimation];
self.soundTimeView.text = [NSString stringWithFormat:@"%ld\"",_soundModel.second];
}
}
-(void)setPlaySoundTime:(NSInteger)time{
self.soundTimeView.text = [NSString stringWithFormat:@"%ld\"",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{
self.palySoundBtn.selected = !self.palySoundBtn.selected;
if(self.palySoundBtn.selected == YES){
[self.soundSVGAView startAnimation];
}else{
[self.soundSVGAView stopAnimation];
}
if(self.delegate && [self.delegate respondsToSelector:@selector(xPMineUserInfoHeaderView:didClickPlaySound:)]){
[self.delegate xPMineUserInfoHeaderView:self didClickPlaySound:self.palySoundBtn.selected];
}
}
#pragma mark - Getters And Setters
-(void)setSoundModel:(XPSoundCardModel *)soundModel{
_soundModel = soundModel;
if(_soundModel != nil){
if(_soundModel.status == 2){
_soundView.hidden = NO;
_soundTimeView.hidden = NO;
_soundSVGAView.hidden = NO;
_soundPromptView.hidden = YES;
_soundTimeView.text = [NSString stringWithFormat:@"%ld\"",_soundModel.second];
return;
}
if(_soundModel.uid.integerValue == [[AccountInfoStorage instance] getUid].integerValue){
_soundView.hidden = NO;
_soundPromptView.hidden = NO;
_soundTimeView.hidden = YES;
_soundSVGAView.hidden = YES;
}
return;
}
if(_soundModel.uid.integerValue == [[AccountInfoStorage instance] getUid].integerValue){
_soundView.hidden = NO;
_soundPromptView.hidden = NO;
_soundTimeView.hidden = YES;
_soundSVGAView.hidden = YES;
return;
}
_soundView.hidden = YES;
_soundTimeView.text = [NSString stringWithFormat:@"%d\"",0];
}
- (void)setUserInfo:(UserInfoModel *)userInfo {
_userInfo = userInfo;
if (_userInfo) {
self.nameLabel.text = _userInfo.nick;
NSString *text = [NSString stringWithFormat:@"ID:%ld", (long)_userInfo.erbanNo];
NSMutableAttributedString *textAtt = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@ ",text] attributes:@{NSForegroundColorAttributeName:self.idLabel.textColor}];
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.fansNumLabel.text =[NSString stringWithFormat:YMLocalizedString(@"XPMineUserInfoHeaderView2"), _userInfo.fansNum];
[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.beautifulImageViw.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.nameplateWord.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(20* scale, 20));
}];
}];
}
- (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 = NO;
}else{
_tagView.hidden = !(itemList.count > 0);
}
_tagView.uid = @(self.userInfo.uid).stringValue;
_tagView.itemList = itemList;
}
- (UIImageView *)coverImageView {
if (!_coverImageView) {
_coverImageView = [[UIImageView alloc] init];
_coverImageView.userInteractionEnabled = NO;
_coverImageView.image = [UIImage imageNamed:@"mine_userinfo_header_shadow_bg"];
}
return _coverImageView;
}
- (UIView *)userInfoView {
if (!_userInfoView) {
_userInfoView = [[UIView alloc] init];
_userInfoView.backgroundColor = [UIColor clearColor];
_userInfoView.layer.masksToBounds = YES;
_userInfoView.layer.cornerRadius = 12;
}
return _userInfoView;
}
- (UIImageView *)usershadowImageView {
if (!_usershadowImageView) {
_usershadowImageView = [[UIImageView alloc] init];
_usershadowImageView.userInteractionEnabled = YES;
_usershadowImageView.backgroundColor = [UIColor whiteColor];
_usershadowImageView.layer.cornerRadius = 13;
_usershadowImageView.layer.masksToBounds = YES;
}
return _usershadowImageView;
}
- (UIStackView *)nickStackView {
if (!_nickStackView) {
_nickStackView = [[UIStackView alloc] init];
_nickStackView.axis = UILayoutConstraintAxisHorizontal;
_nickStackView.distribution = UIStackViewDistributionFill;
_nickStackView.alignment = UIStackViewAlignmentCenter;
_nickStackView.spacing = 5;
}
return _nickStackView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
_nameLabel.textColor = UIColorFromRGB(0x1F1A4E);
}
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.axis = UILayoutConstraintAxisHorizontal;
_idStackView.distribution = UIStackViewDistributionFill;
_idStackView.alignment = UIStackViewAlignmentCenter;
_idStackView.spacing = 5;
}
return _idStackView;
}
- (UIImageView *)beautifulImageViw {
if (!_beautifulImageViw) {
_beautifulImageViw = [[UIImageView alloc] init];
_beautifulImageViw.userInteractionEnabled = YES;
_beautifulImageViw.image = [UIImage imageNamed:@"common_icon_beautiful"];
}
return _beautifulImageViw;
}
- (UILabel *)fansNumLabel {
if (!_fansNumLabel) {
_fansNumLabel = [[UILabel alloc] init];
_fansNumLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
_fansNumLabel.textColor = UIColorFromRGB(0x6D6B89);
}
return _fansNumLabel;
}
- (UIView *)spaceView {
if (!_spaceView) {
_spaceView = [[UIView alloc] init];
_spaceView.backgroundColor = [UIColor clearColor];
}
return _spaceView;
}
- (UILabel *)idLabel {
if (!_idLabel) {
_idLabel = [[UILabel alloc] init];
_idLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
_idLabel.textColor = UIColorFromRGB(0x6D6B89);
_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 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 defalutBannerPlaceholder]];
_pi_cycleScrollView.backgroundColor = [UIColor clearColor];
_pi_cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
_pi_cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleNone;
_pi_cycleScrollView.autoScroll = NO;
}
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 imageNamed:@"mine_album_reviewing"];
_reviewIcon.hidden = YES;
}
return _reviewIcon;
}
- (UIStackView *)tagStackView {
if (!_tagStackView) {
_tagStackView = [[UIStackView alloc] init];
_tagStackView.axis = UILayoutConstraintAxisHorizontal;
_tagStackView.distribution = UIStackViewDistributionFill;
_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 imageNamed:@"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:13 weight:UIFontWeightRegular];;
_signLabel.textColor = UIColorFromRGB(0xB3B3C3);
_signLabel.numberOfLines = 2;
}
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 = 44;
_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;
}
-(UIImageView *)bgView{
if (!_bgView){
_bgView = [UIImageView new];
_bgView.image = [UIImage imageNamed:@"mine_userinfo_header_bg"];
}
return _bgView;
}
- (UIImageView *)soundView{
if (!_soundView){
_soundView = [UIImageView new];
UIImage *image = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor],[DJDKMIMOMColor confirmButtonGradientMiddleColor],[DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(98, 28)];
_soundView.image = image;
_soundView.layer.cornerRadius = 14;
_soundView.userInteractionEnabled = YES;
_soundView.layer.masksToBounds = YES;
_soundView.hidden = YES;
}
return _soundView;
}
- (UIButton *)palySoundBtn{
if (!_palySoundBtn){
_palySoundBtn = [UIButton new];
[_palySoundBtn setBackgroundImage:kImage(@"mine_info_close") forState:UIControlStateNormal];
[_palySoundBtn setBackgroundImage:kImage(@"mine_info_paly") forState:UIControlStateSelected];
[_palySoundBtn setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
[_palySoundBtn addTarget:self action:@selector(playSoundAction) forControlEvents:UIControlEventTouchUpInside];
}
return _palySoundBtn;
}
- (SVGAImageView *)soundSVGAView {
if (_soundSVGAView == nil) {
_soundSVGAView = [[SVGAImageView alloc]init];
_soundSVGAView.contentMode = UIViewContentModeScaleToFill;
_soundSVGAView.userInteractionEnabled = NO;
_soundSVGAView.backgroundColor = [UIColor clearColor];
}
return _soundSVGAView;
}
- (UILabel *)soundTimeView{
if (!_soundTimeView){
_soundTimeView = [UILabel labelInitWithText:@"0\"" font:[UIFont systemFontOfSize:14 weight:UIFontWeightMedium] textColor:[UIColor whiteColor]];
}
return _soundTimeView;
}
- (UILabel *)soundPromptView{
if (!_soundPromptView){
_soundPromptView = [UILabel labelInitWithText:YMLocalizedString(@"XPMineUserInfoHeaderView4") font:[UIFont systemFontOfSize:12 weight:UIFontWeightMedium] textColor:[UIColor whiteColor]];
_soundPromptView.hidden = YES;
_soundPromptView.userInteractionEnabled = YES;
}
return _soundPromptView;
}
-(UIButton *)toSoundBtn{
if (!_toSoundBtn){
_toSoundBtn = [UIButton new];
[_toSoundBtn addTarget:self action:@selector(toSoundAction) forControlEvents:UIControlEventTouchUpInside];
}
return _toSoundBtn;
}
-(XPMineUserInfoHeaderTagView *)tagView{
if (!_tagView){
_tagView = [[XPMineUserInfoHeaderTagView alloc]initWithFrame:CGRectZero];
_tagView.delegate = self;
}
return _tagView;
}
- (UIStackView *)singStackView {
if (!_singStackView) {
_singStackView = [[UIStackView alloc] init];
_singStackView.axis = UILayoutConstraintAxisVertical;
_singStackView.distribution = UIStackViewDistributionFill;
_singStackView.alignment = UIStackViewAlignmentCenter;
_singStackView.spacing = 11;
}
return _singStackView;
}
- (NetImageView *)rechargeImageView{
if(!_rechargeImageView){
_rechargeImageView = [NetImageView new];
_rechargeImageView.image = kImage(@"mine_info_recharge");
_rechargeImageView.hidden = YES;
}
return _rechargeImageView;
}
- (NetImageView *)nobleImageView {
if (!_nobleImageView) {
_nobleImageView = [[NetImageView alloc] init];
_nobleImageView.hidden = YES;
}
return _nobleImageView;
}
@end