Files
peko-ios/YuMi/Modules/YMRoom/View/UserCard/View/XPUserCardViewController.m
2023-10-18 15:11:56 +08:00

1426 lines
56 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.

//
// YMUserCardViewController.m
// YUMI
//
// Created by YUMI on 2021/11/24.
//
#import "XPUserCardViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <YYImage/YYAnimatedImageView.h>
///Tool
#import "YUMIMacroUitls.h"
#import "ThemeColor+UserCard.h"
#import "TTPopup.h"
#import "YUMIHtmlUrl.h"
#import "XNDJTDDLoadingTool.h"
#import "AccountInfoStorage.h"
#import "SpriteSheetImageManager.h"
#import "UIImage+Utils.h"
#import "XCCurrentVCStackManager.h"
#import "StatisticsServiceHelper.h"
#import "NSArray+Safe.h"
#import "NSMutableDictionary+Saft.h"
#import "ClientConfig.h"
///Model
#import "UserInfoModel.h"
#import "XPUserCardItemModel.h"
#import "RoomInfoModel.h"
#import "AttachmentModel.h"
#import "XPKickUserModel.h"
#import "XPUserCardMicroItemModel.h"
#import "MicroQueueModel.h"
#import "MicroStateModel.h"
///View
#import "XPSendGiftView.h"
#import "NetImageView.h"
#import "XPUserCardItemCollectionViewCell.h"
#import "XPUserCardSkillCardView.h"
#import "XPRoomSendTextView.h"
#import "XPRoomHalfMessageView.h"
///P
#import "XPUserCardPresenter.h"
#import "XPUserCardProtocol.h"
///VC
#import "XPWebViewController.h"
#import "XPMineUserInfoViewController.h"
#import "XPMineSimpleUserInfoViewController.h"
#import "SessionViewController.h"
@interface XPUserCardViewController ()<UICollectionViewDelegate, UICollectionViewDataSource,XPUserCardProtocol>
///上面点击的view
@property (nonatomic,strong) UIView *topTapView;
///下面点击的view
@property (nonatomic,strong) UIView *bottomTapView;
///背景
@property (nonatomic,strong) UIView *backView;
///最外层的容器
@property (nonatomic,strong) UIStackView *stackView;
///展示用户的信息
@property (nonatomic,strong) UIView * userInfoView;
///贵族资料卡头饰
@property (nonatomic, strong) NetImageView *nobleImageView;
///模糊效果
@property (strong, nonatomic) UIVisualEffectView *effectView;
///头像背景
@property (nonatomic,strong) NetImageView *backImageView;
///头饰
@property (nonatomic,strong) YYAnimatedImageView *headWearImageView;
///头饰播放
@property (nonatomic, strong) SpriteSheetImageManager *manager;
///头像
@property (nonatomic,strong) NetImageView *avatarImageView;
///名字
@property (nonatomic,strong) UILabel *nickLabel;
///性别
@property (nonatomic,strong) UIButton *sexImageView;
///新用户
@property (nonatomic,strong) UIImageView *newUserImageView;
///官方的
@property (nonatomic,strong) UIImageView *officalImageView;
///魅力等级 等级 铭牌
@property (nonatomic,strong) UIStackView *tagStackView;
///魅力等级
@property (nonatomic,strong) NetImageView *charmImageView;
///贵族icon
@property (nonatomic, strong) NetImageView *nobleIconImageView;
///等级
@property (nonatomic,strong) NetImageView *experImageView;
///铭牌的容器
@property (nonatomic,strong) UIView * namePlateView;
///铭牌图片
@property (nonatomic,strong) NetImageView *nameplateImageView;
///铭牌文字
@property (nonatomic,strong) UILabel *nameplateLabel;
///ID
@property (nonatomic,strong) UILabel *idLabel;
///复制ID
@property (nonatomic,strong) UIImageView *copysIdImageView;
///举报
@property (nonatomic,strong) UIButton *reportButton;
///关闭
@property (nonatomic,strong) UIButton *closeButton;
///列表
@property (nonatomic,strong) UICollectionView *collectionView;
///技能卡列表
@property (nonatomic, strong) XPUserCardSkillCardView *skillCardView;
///分割线
@property (nonatomic,strong) UIView * sepLineView;
///操作的容器
@property (nonatomic,strong) UIStackView *operaStackView;
///选择心动
@property (nonatomic,strong) UIButton *pickHeartButton;
///选择心动的容器
@property (nonatomic,strong) UIView * pickHeartView;
///展示用户的uid
@property (nonatomic,strong) XPUserCardInfoModel *cardInfo;
///数据源
@property (nonatomic,copy) NSArray<XPUserCardItemModel *> *datasource;
///操作麦序的数据
@property (nonatomic,copy) NSArray<XPUserCardMicroItemModel *> * microItems;
///目标用户的信息
@property (nonatomic,strong) UserInfoModel *targetUserInfo;
@end
@implementation XPUserCardViewController
- (instancetype)initWithUser:(XPUserCardInfoModel *)cardInfo {
if (self = [super init]) {
self.modalPresentationStyle = UIModalPresentationOverFullScreen;
self.cardInfo = cardInfo;
}
return self;
}
#pragma mark - Life Style
- (XPUserCardPresenter *)createPresenter {
return [[XPUserCardPresenter alloc] init];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self initHttp];
[self initSubViews];
[self initSubViewConstraints];
[self initEvent];
}
#pragma mark - Private Method
- (void)initSubViews {
self.view.backgroundColor = [UIColor clearColor];
///设置颜色 stackView 设置背景色 会失败
[self.view addSubview:self.topTapView];
[self.view addSubview:self.backView];
[self.view addSubview:self.bottomTapView];
[self.backView addSubview:self.stackView];
[self.view addSubview:self.nobleImageView];
[self.stackView addArrangedSubview:self.userInfoView];
[self.stackView addArrangedSubview:self.skillCardView];
[self.stackView addArrangedSubview:self.collectionView];
[self.stackView addArrangedSubview:self.sepLineView];
[self.stackView addArrangedSubview:self.operaStackView];
[self.stackView addArrangedSubview:self.pickHeartView];
///用户信息
[self.userInfoView addSubview:self.backImageView];
[self.userInfoView addSubview:self.effectView];
[self.userInfoView addSubview:self.avatarImageView];
[self.userInfoView addSubview:self.headWearImageView];
[self.userInfoView addSubview:self.nobleIconImageView];
[self.userInfoView addSubview:self.nickLabel];
[self.userInfoView addSubview:self.sexImageView];
[self.userInfoView addSubview:self.tagStackView];
[self.userInfoView addSubview:self.idLabel];
[self.userInfoView addSubview:self.copysIdImageView];
[self.userInfoView addSubview:self.reportButton];
[self.userInfoView addSubview:self.closeButton];
///用户信息中的标签
[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.namePlateView addSubview:self.nameplateImageView];
[self.namePlateView addSubview:self.nameplateLabel];
[self.pickHeartView addSubview:self.pickHeartButton];
[self configRoomDatingPickHeart];
}
- (void)initSubViewConstraints {
[self.topTapView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.mas_equalTo(self.view);
make.bottom.mas_equalTo(self.backView.mas_top);
}];
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.view).inset(45);
make.centerY.mas_equalTo(self.view);
make.bottom.mas_equalTo(self.stackView.mas_bottom);
}];
[self.bottomTapView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.left.right.mas_equalTo(self.view);
make.top.mas_equalTo(self.backView.mas_bottom);
}];
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(KScreenWidth - 90);
make.top.centerX.mas_equalTo(self.backView);
}];
[self.userInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(self.stackView);
make.height.mas_equalTo(110);
}];
CGFloat nobleMargin = (KScreenWidth - 45) * 45.0 / (KScreenWidth - 90);
[self.nobleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(180);
make.top.mas_equalTo(self.backView).mas_offset(-70);
make.right.mas_equalTo(self.backView).offset(nobleMargin*0.5);
make.left.mas_equalTo(self.backView).mas_offset(-nobleMargin*0.5);
}];
[self.skillCardView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(self.userInfoView);
make.height.mas_equalTo(0);
}];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(self.userInfoView);
make.height.mas_equalTo(0);
}];
[self.sepLineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(KScreenWidth - 45 * 2 - 10 * 2, 1));
}];
[self.operaStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(self.userInfoView);
make.height.mas_equalTo(40);
}];
///用户信息的子view
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.userInfoView);
}];
[self.effectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.userInfoView);
}];
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(50, 50));
make.left.mas_equalTo(self.userInfoView).offset(15);
make.top.mas_equalTo(self.userInfoView).offset(30);
}];
[self.headWearImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.avatarImageView);
make.width.mas_equalTo(self.avatarImageView.mas_width).multipliedBy(1.31);
make.height.mas_equalTo(self.headWearImageView.mas_width);
}];
[self.nobleIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.headWearImageView.mas_right).offset(5);
make.top.mas_equalTo(self.avatarImageView);
make.height.mas_equalTo(20);
make.width.mas_equalTo(0);
}];
[self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nobleIconImageView.mas_right);
make.top.mas_equalTo(self.avatarImageView);
}];
[self.sexImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(28, 14));
make.left.mas_equalTo(self.nickLabel.mas_right).offset(4);
make.centerY.mas_equalTo(self.nickLabel);
}];
[self.tagStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nobleIconImageView);
make.top.mas_equalTo(self.nobleIconImageView.mas_bottom).offset(3);
make.height.mas_equalTo(20);
}];
[self.idLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nobleIconImageView);
make.top.mas_equalTo(self.tagStackView.mas_bottom).offset(3);
}];
[self.copysIdImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(15, 15));
make.left.mas_equalTo(self.idLabel.mas_right).offset(2);
make.centerY.mas_equalTo(self.idLabel);
}];
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(22, 22));
make.top.mas_equalTo(self.userInfoView).offset(5);
make.right.mas_equalTo(self.userInfoView).offset(-6);
}];
[self.reportButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.closeButton);
make.right.mas_equalTo(self.closeButton.mas_left).offset(-5);
}];
[self.newUserImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(15);
}];
[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(20);
make.width.mas_equalTo(60);
make.left.top.mas_equalTo(self.namePlateView);
}];
[self.nameplateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.mas_equalTo(self.nameplateImageView);
make.right.mas_equalTo(self.namePlateView).offset(-2);
}];
[self.pickHeartView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(200);
make.height.mas_equalTo(40);
}];
[self.pickHeartButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.centerY.mas_equalTo(self.pickHeartView);
make.height.mas_equalTo(30);
}];
}
- (void)initEvent {
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(disMisssVc:)];
[self.topTapView addGestureRecognizer:tap];
UITapGestureRecognizer * bottomTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(disMisssVc:)];
[self.bottomTapView addGestureRecognizer:bottomTap];
UITapGestureRecognizer * userInfoTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoUserInfoVC:)];
[self.avatarImageView addGestureRecognizer:userInfoTap];
}
- (void)initHttp {
[self.presenter getUserInfo:self.cardInfo.uid];
[self.presenter getFunctionItemsByUserInfo:self.cardInfo];
[self.presenter getMicroFunctionItemsByUserInfo:self.cardInfo];
}
- (void)configRoomDatingPickHeart {
self.pickHeartView.hidden = YES;
if (self.cardInfo.roomInfo.roomModeType == RoomModeType_Open_Blind && self.cardInfo.roomInfo.blindDateState == RoomPlayDateingType_Pick && [AccountInfoStorage instance].getUid.integerValue != self.cardInfo.uid.integerValue) {
__block MicroQueueModel * selfMicqueue;
__block MicroQueueModel * targetMicqueue;
[self.cardInfo.micQueue.allValues enumerateObjectsUsingBlock:^(MicroQueueModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (obj.userInfo && obj.userInfo.uid == [AccountInfoStorage instance].getUid.integerValue) {
selfMicqueue = obj;
} else if(obj.userInfo && obj.userInfo.uid == self.cardInfo.uid.integerValue) {
targetMicqueue = obj;
}
}];
if (selfMicqueue.userInfo && selfMicqueue.userInfo.uid > 0 && !selfMicqueue.userInfo.hasSelectUser && selfMicqueue.microState.position != -1 && targetMicqueue.microState.position != -1) {
self.pickHeartView.hidden = NO;
}
}
}
- (void)updateCollectionHeight:(NSArray *)array {
if (array.count > 0) {
CGFloat collectionHeight = 16 + 10;
NSInteger page = array.count / 4;
if (page > 0) {
if (array.count % 4 ==0) {
collectionHeight += (page * 55 + (page-1) * 16);
} else {
collectionHeight += ((page + 1) * 55 + page * 16);
}
} else {
collectionHeight += 55;
}
[self.collectionView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(collectionHeight);
}];
}
}
///拉黑/踢出房间 发送自定义消息
- (void)sendCustomMessageKickOrBlackUser:(int)first second:(int)second {
RoomInfoModel * roomInfo = self.cardInfo.roomInfo;
XPKickUserModel *notifyModel = [[XPKickUserModel alloc] init];
notifyModel.handleNick = self.cardInfo.nick;
notifyModel.handleUid = [AccountInfoStorage instance].getUid.integerValue;
notifyModel.targetUid = self.cardInfo.uid.integerValue;
notifyModel.targetNick = self.targetUserInfo.nick;
notifyModel.uid = self.cardInfo.uid.integerValue;
AttachmentModel *attachment = [[AttachmentModel alloc] init];
attachment.first = first;
attachment.second = second;
attachment.data = [notifyModel model2dictionary];
NSString * sessionId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
NIMMessage *message = [[NIMMessage alloc]init];
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachment;
message.messageObject = object;
//构造会话
NIMSession *session = [NIMSession session:sessionId type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
}
- (NSArray<XPGiftUserInfoModel *> *)configGiftUsers:(NSMutableDictionary<NSString *,MicroQueueModel *> *)queue {
NSMutableArray * array = [NSMutableArray array];
BOOL receiveIsOnMic = NO;
for (MicroQueueModel * microModel in queue.allValues) {
if (microModel.userInfo && microModel.userInfo.uid >0) {
UserInfoModel * userInfo = microModel.userInfo;
if (userInfo.uid == self.cardInfo.uid.integerValue) {
receiveIsOnMic = YES;
}
}
}
if (receiveIsOnMic) {
for (MicroQueueModel * microModel in queue.allValues) {
if (microModel.userInfo && microModel.userInfo.uid >0) {
UserInfoModel * userInfo = microModel.userInfo;
XPGiftUserInfoModel * userModel = [[XPGiftUserInfoModel alloc] init];
userModel.avatar = userInfo.avatar;
userModel.vipMic = userInfo.vipMic;
userModel.position = [NSString stringWithFormat:@"%d", microModel.microState.position];
userModel.uid = userInfo.uid;
if (userInfo.uid == self.cardInfo.uid.integerValue) {
userModel.isSelect = YES;
}
if (self.cardInfo.roomInfo.type == RoomType_Anchor && microModel.microState.position == -1) {///个播房一直为离开模式,不需要添加房主位
continue;
}
[array addObject:userModel];
}
}
RoomInfoModel * roomInfo = self.cardInfo.roomInfo;
if (roomInfo.leaveMode) {
XPGiftUserInfoModel * userModel = [[XPGiftUserInfoModel alloc] init];
userModel.avatar = roomInfo.avatar;
userModel.position = @"-1";
userModel.uid = self.cardInfo.uid.integerValue;
if (roomInfo.uid == self.cardInfo.uid.integerValue) {
userModel.isSelect = YES;
}
[array addObject:userModel];
} else if (roomInfo.type == RoomType_Anchor) {
BOOL hadContainerOwner = NO;
for (UserInfoModel *userModel in array) {
if (userModel.uid == roomInfo.uid) {
hadContainerOwner = YES;
break;
}
}
if (!hadContainerOwner) {
XPGiftUserInfoModel * userModel = [[XPGiftUserInfoModel alloc] init];
userModel.avatar = roomInfo.avatar;
userModel.position = @"-1";
userModel.uid = self.cardInfo.uid.integerValue;
if (roomInfo.uid == self.cardInfo.uid.integerValue) {
userModel.isSelect = YES;
}
[array addObject:userModel];
}
}
} else {
XPGiftUserInfoModel * userModel = [[XPGiftUserInfoModel alloc] init];
userModel.avatar = self.targetUserInfo.avatar;
userModel.nick = self.targetUserInfo.nick;
userModel.uid = self.cardInfo.uid.integerValue;
userModel.isSelect = YES;
[array addObject:userModel];
}
return array;
}
//自己是否在游戏中
- (BOOL)isInSudGame:(NSString *)uid {
BOOL isGamePlaying = NO;
if (self.cardInfo.roomInfo.type == RoomType_MiniGame) {
for (int i = -1; i<5; i++) {
NSMutableDictionary * micQueue = self.cardInfo.micQueue;
MicroQueueModel *micSequence = [micQueue objectForKey:[NSString stringWithFormat:@"%d", i]];
if (micSequence == nil || micSequence.userInfo == nil) {
continue;
}
if (micSequence.userInfo.uid == uid.integerValue && micSequence.userInfo.gameStatus == LittleGamePlayStatus_Plying) {
isGamePlaying = YES;
break;
}
}
}
return isGamePlaying;
}
#pragma mark - XPUserCardProtocol
- (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo {
self.targetUserInfo = userInfo;
self.avatarImageView.imageUrl = userInfo.avatar;
self.backImageView.imageUrl = userInfo.avatar;
self.nobleImageView.imageUrl = userInfo.userInfoCardPic;
self.nobleIconImageView.imageUrl = userInfo.userVipInfoVO.vipIcon;
if (userInfo.userVipInfoVO && userInfo.userVipInfoVO.vipIcon) {//贵族icon
[self.nobleIconImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(20);
}];
[self.nickLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nobleIconImageView.mas_right).mas_offset(2);
}];
}
NSString * nick = userInfo.nick;
if (nick.length > 8) {
nick = [NSString stringWithFormat:@"%@…", [nick substringToIndex:8]];
}
self.nickLabel.text = nick.length > 0 ? nick : @"";
[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.newUserImageView.hidden = !userInfo.newUser;
if (userInfo.newUser) {
if (userInfo.fromSayHelloChannel) {
self.newUserImageView.image = [UIImage imageNamed:@"room_new_user_greet_new"];
} else {
self.newUserImageView.image = [UIImage imageNamed:@"common_new_user"];
}
}
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_makeConstraints:^(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_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(20);
make.width.mas_equalTo(width);
}];
}];;
}
self.charmImageView.hidden = userInfo.userLevelVo.charmUrl.length <= 0;
self.copysIdImageView.hidden = NO;
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.idLabel.text = [NSString stringWithFormat:@"ID%ld", userInfo.erbanNo];
NSString * headwearUrl= userInfo.headwearEffect.length > 0 ? userInfo.headwearEffect : userInfo.headwearPic;
self.headWearImageView.hidden = headwearUrl.length <= 0;
if (headwearUrl.length > 0) {
NSURL *url = [NSURL URLWithString:headwearUrl];
@kWeakify(self);
[self.manager loadSpriteSheetImageWithURL:url completionBlock:^(YYSpriteSheetImage * _Nullable sprit) {
@kStrongify(self);
self.headWearImageView.image = sprit;
} failureBlock:^(NSError * _Nullable error) {
}];
}
if (userInfo.uid == [AccountInfoStorage instance].getUid.integerValue) {
self.reportButton.hidden = YES;
} else {
self.reportButton.hidden = NO;
}
if (userInfo.absCardPics.count) {
[self.skillCardView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(30);
}];
}
self.skillCardView.dataArray = userInfo.absCardPics;
}
- (void)onGetFunctionArraySccess:(NSArray<XPUserCardItemModel *> *)array {
if (array.count <= 0) {return;}
self.datasource = array;
self.collectionView.hidden = NO;
[self.collectionView reloadData];
[self updateCollectionHeight:self.datasource];
}
- (void)onGetMicroFunctionArraySuccess:(NSArray<XPUserCardMicroItemModel *> *)array {
if (array.count <= 0) {return;}
self.microItems = array;
self.operaStackView.hidden = NO;
self.sepLineView.hidden = NO;
for (XPUserCardMicroItemModel * model in array) {
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:model.title forState:UIControlStateNormal];
button.titleLabel.font = [UIFont systemFontOfSize:13];
button.tag = model.type;
button.selected = model.status;
[button setTitleColor:[DJDKMIMOMColor userMicroTitleColor] forState:UIControlStateNormal];
[button addTarget:self action:@selector(microButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[self.operaStackView addArrangedSubview:button];
}
}
- (void)attentionUserSuccess:(XPUserCardItemModel *)item {
///其实这个遍历 有没有都行 只是为了预防 在vc中修改了数据源中的item 还是判断一下吧
[self.datasource enumerateObjectsUsingBlock:^(XPUserCardItemModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (item.type == obj.type) {
obj.isSelect = item.isSelect;
*stop = YES;
}
}];
[self.collectionView reloadData];
}
- (void)makeKickUserFinish:(NSError *)error {
if (error == nil && self.targetUserInfo) {
[self dismissViewControllerAnimated:YES completion:nil];
[self sendCustomMessageKickOrBlackUser:CustomMessageType_Kick_User second:Custom_Message_Sub_Kick_BeKicked];
} else if (error.code == 404) {
[self showErrorToast:YMLocalizedString(@"XPUserCardViewController0")];
}
}
- (void)superAdminKickUserFinish:(NSError *)error {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)markUserManagerFinish:(XPUserCardItemModel *)item error:(NSError *)error {
if (error == nil) {
[self.datasource enumerateObjectsUsingBlock:^(XPUserCardItemModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (item.type == obj.type) {
obj.isSelect = item.isSelect;
*stop = YES;
}
}];
[self.collectionView reloadData];
}
}
- (void)makeUserBlackFinish:(NSError *)error {
if (error == nil && self.targetUserInfo) {
[self dismissViewControllerAnimated:YES completion:nil];
if (self.cardInfo.position.length > 0) {
NIMChatroomQueueRemoveRequest *request = [[NIMChatroomQueueRemoveRequest alloc]init];
request.key = self.cardInfo.position;
request.roomId = [NSString stringWithFormat:@"%ld", self.cardInfo.roomInfo.roomId];
[[NIMSDK sharedSDK].chatroomManager removeChatroomQueueObject:request completion:^(NSError * _Nullable error, NSDictionary<NSString *,NSString *> * _Nullable element) {
if (error == nil ) {
}
}];
}
[self sendCustomMessageKickOrBlackUser:CustomMessageType_Kick_User second:Custom_Message_Sub_Kick_BlackList];
} else if (error.code == 417) {
[self showErrorToast:YMLocalizedString(@"XPUserCardViewController1")];
}
}
- (void)lockMicroSusccess {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)muteMicroSusccess {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)kickDownMicroSuccess {
if (self.cardInfo.uid.integerValue != [AccountInfoStorage instance].getUid.integerValue) {
[self sendCustomMessageKickOrBlackUser:CustomMessageType_Queue second:Custom_Message_Sub_Queue_Kick];
}
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)upMicroSuccess {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)cleanUserGiftValueSuccess:(NSDictionary *)dic {
[self showSuccessToast:YMLocalizedString(@"XPUserCardViewController2")];
NIMMessage * message = [[NIMMessage alloc] init];
AttachmentModel * attachMent = [[AttachmentModel alloc] init];
attachMent.first = CustomMessageType_Room_GiftValue;
attachMent.second = Custom_Message_Sub_Room_GiftValue_Sync;
attachMent.data = dic;
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachMent;
message.messageObject = object;
//构造会话
NSString * sessionId = [NSString stringWithFormat:@"%ld", self.cardInfo.roomInfo.roomId];
NIMSession *session = [NIMSession session:sessionId type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)roomDatingPickHeartUserSuccess {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)superAdminHandleUserSuccess:(NSString *)opt {
[self showSuccessToast:YMLocalizedString(@"XPUserCardViewController3")];
[self dismissViewControllerAnimated:YES completion:nil];
if ([opt isEqualToString:@"-1"]) {///拉黑
if (self.cardInfo.position.length > 0) {
NIMChatroomQueueRemoveRequest *request = [[NIMChatroomQueueRemoveRequest alloc]init];
request.key = self.cardInfo.position;
request.roomId = [NSString stringWithFormat:@"%ld", self.cardInfo.roomInfo.roomId];
[[NIMSDK sharedSDK].chatroomManager removeChatroomQueueObject:request completion:^(NSError * _Nullable error, NSDictionary<NSString *,NSString *> * _Nullable element) {
if (error == nil ) {
}
}];
}
[self sendCustomMessageKickOrBlackUser:CustomMessageType_Kick_User second:Custom_Message_Sub_Kick_BlackList];
}
}
- (BOOL)shouldHideSendGiftItem {
return self.shouldHideSendGiftItem;
}
#pragma mark - UICollectionViewDelegate
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.datasource.count;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[collectionView deselectItemAtIndexPath:indexPath animated:YES];
///自己是公会超管
BOOL meIsSuperAdmin = NO;
for (GuildSuperAdminInfoModel *managerInfo in self.cardInfo.superMangerList) {
if ([managerInfo.uid isEqualToString:[AccountInfoStorage instance].getUid]) {
meIsSuperAdmin = YES;
}
}
if (self.datasource.count > 0) {
XPUserCardItemModel * model = [self.datasource safeObjectAtIndex1:indexPath.item];
NSString * roomId = [NSString stringWithFormat:@"%ld", self.cardInfo.roomInfo.roomId];;
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.cardInfo.roomInfo.uid];;
switch (model.type) {
case UserCardItemType_Chat:
{
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_mike_click eventAttributes:@{@"actionType" : @"chat"}];
[self dismissViewControllerAnimated:YES completion:^{
UIViewController * controller = (UIViewController *)self.cardInfo.delegate;
XPRoomHalfMessageView *halfMessageView = [[XPRoomHalfMessageView alloc] initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight) controller:controller];
halfMessageView.chatUserId = self.cardInfo.uid;
[controller.view addSubview:halfMessageView];
[UIView animateWithDuration:.35 animations:^{
CGRect rect = halfMessageView.frame;
rect.origin.y = 0;
halfMessageView.frame = rect;
}];
}];
}
break;
case UserCardItemType_Gift:
{
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_mike_click eventAttributes:@{@"actionType" : @"sendGift"}];
[self dismissViewControllerAnimated:NO completion:nil];
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.cardInfo.roomInfo.uid];
XPSendGiftView * giftView = [[XPSendGiftView alloc] initWithType:SendGiftType_Room uid:roomUid];
giftView.delegate = self.cardInfo.delegate;
NSArray *users = [self configGiftUsers:self.cardInfo.delegate.getMicroQueue];
[giftView configGiftUsers:users];
[self.presentingViewController presentViewController:giftView animated:YES completion:nil];
}
break;
case UserCardItemType_Attention:
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_mike_click eventAttributes:@{@"actionType" : @"attention"}];
[self.presenter attentionUser:self.cardInfo.uid status:!model.isSelect];
break;
case UserCardItemType_KickOut:
{
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_mike_click eventAttributes:@{@"actionType" : @"kickout"}];
// 1、判断是否为防被踢用户
if (self.targetUserInfo.userVipInfoVO.preventKick) {
//2、判断是否为管理员操作
if (self.cardInfo.roomInfo.uid != [AccountInfoStorage instance].getUid.integerValue) {
[self showErrorToast:[NSString stringWithFormat:YMLocalizedString(@"XPUserCardViewController4"), self.targetUserInfo.userVipInfoVO.vipName]];
} else {//房主操作
NSString *message = [NSString stringWithFormat:YMLocalizedString(@"XPUserCardViewController5"), self.targetUserInfo.userVipInfoVO.vipName];
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.title = @"";
config.message = message;
[TTPopup alertWithConfig:config confirmHandler:^{
if ([self isInSudGame:self.cardInfo.uid]) {
NSString *message = YMLocalizedString(@"XPUserCardViewController6");
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.title = @"";
config.message = message;
[TTPopup alertWithConfig:config confirmHandler:^{
[self.presenter makeKickUser:self.cardInfo.uid roomId:roomId];
} cancelHandler:^{
}];
} else {
[self.presenter makeKickUser:self.cardInfo.uid roomId:roomId];
}
} cancelHandler:^{
}];
}
return;
}
if ([self isInSudGame:self.cardInfo.uid]) {
NSString *message = YMLocalizedString(@"XPUserCardViewController6");
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.title = @"";
config.message = message;
[TTPopup alertWithConfig:config confirmHandler:^{
if (meIsSuperAdmin) {
[self.presenter superAdminKickUser:self.targetUserInfo.nick cardInfo:self.cardInfo];
} else {
[self.presenter makeKickUser:self.cardInfo.uid roomId:roomId];
}
} cancelHandler:^{
}];
} else {
NSString *message = [NSString stringWithFormat:YMLocalizedString(@"XPUserCardViewController8"),self.targetUserInfo.nick];
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.title = YMLocalizedString(@"XPUserCardViewController9");
config.message = message;
[TTPopup alertWithConfig:config confirmHandler:^{
if (meIsSuperAdmin) {
[self.presenter superAdminKickUser:self.targetUserInfo.nick cardInfo:self.cardInfo];
} else {
[self.presenter makeKickUser:self.cardInfo.uid roomId:roomId];
}
} cancelHandler:^{
}];
}
}
break;
case UserCardItemType_Black:
{
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_mike_click eventAttributes:@{@"actionType" : @"blacklist"}];
// 1、判断是否为防被踢用户
if (self.targetUserInfo.userVipInfoVO.preventKick) {
//2、判断是否为管理员操作
if (self.cardInfo.roomInfo.uid != [AccountInfoStorage instance].getUid.integerValue) {
[self showErrorToast:[NSString stringWithFormat:YMLocalizedString(@"XPUserCardViewController4"), self.targetUserInfo.userVipInfoVO.vipName]];
} else {//房主操作
NSString *message = [NSString stringWithFormat:YMLocalizedString(@"XPUserCardViewController11"), self.targetUserInfo.userVipInfoVO.vipName];
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.title = @"";
config.message = message;
[TTPopup alertWithConfig:config confirmHandler:^{
if ([self isInSudGame:self.cardInfo.uid]) {
NSString *message = YMLocalizedString(@"XPUserCardViewController6");
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.title = @"";
config.message = message;
[TTPopup alertWithConfig:config confirmHandler:^{
[self.presenter makeKickUser:self.cardInfo.uid roomId:roomId];
} cancelHandler:^{
}];
} else {
[self.presenter makeKickUser:self.cardInfo.uid roomId:roomId];
}
} cancelHandler:^{
}];
}
return;
}
if ([self isInSudGame:self.cardInfo.uid]) {
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.title = @"";
config.message = [NSString stringWithFormat: YMLocalizedString(@"XPUserCardViewController13"), self.targetUserInfo.nick];
[TTPopup alertWithConfig:config confirmHandler:^{
if (meIsSuperAdmin) {
[self.presenter superAdminHandleUser:self.cardInfo.uid opt:@"-1" roomUid:roomUid isSet:YES];
} else {
[self.presenter makeUserBlack:self.cardInfo.uid roomId:roomId];
}
} cancelHandler:^{
}];
} else {
NSString *title = [NSString stringWithFormat:YMLocalizedString(@"XPUserCardViewController14"),self.targetUserInfo.nick];
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.title = title;
config.message = YMLocalizedString(@"XPUserCardViewController15");
[TTPopup alertWithConfig:config confirmHandler:^{
if (meIsSuperAdmin) {
[self.presenter superAdminHandleUser:self.cardInfo.uid opt:@"-1" roomUid:roomUid isSet:YES];
}else {
[self.presenter makeUserBlack:self.cardInfo.uid roomId:roomId];
}
} cancelHandler:^{
}];
}
}
break;
case UserCardItemType_Manager:
{
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_mike_click eventAttributes:@{@"actionType" : @"manager"}];
if (meIsSuperAdmin) {
[self.presenter superAdminHandleUser:self.cardInfo.uid opt:@"1" roomUid:roomUid isSet:!model.isSelect];
} else {
[self.presenter makeUserManager:self.cardInfo.uid roomId:roomId enable:!model.isSelect];
}
}
break;
case UserCardItemType_Invite_Micro:
{
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_mike_click eventAttributes:@{@"actionType" : @"invite_micro"}];
if ([AccountInfoStorage instance].getUid.integerValue == self.targetUserInfo.uid) {
[self.presenter upMicro:roomId position:model.position userInfo:self.targetUserInfo];
} else {
if (self.cardInfo.roomInfo.leaveMode && [model.position isEqualToString:@"-1"]) {
return;
}
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
[dic safeSetObject:@(model.position.integerValue) forKey:@"micPosition"];
[dic safeSetObject:@(self.targetUserInfo.uid) forKey:@"uid"];
AttachmentModel *attachement = [[AttachmentModel alloc]init];
attachement.first = CustomMessageType_Queue;
attachement.second = Custom_Message_Sub_Queue_Invite;
attachement.data = dic;
NIMMessage *message = [[NIMMessage alloc]init];
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachement;
message.messageObject = object;
//构造会话
NIMSession *session = [NIMSession session:roomId type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
[self dismissViewControllerAnimated:YES completion:nil];
}
}
break;
case UserCardItemType_AtUser:
{
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_mike_click eventAttributes:@{@"actionType" : @"atUser"}];
if (self.cardInfo.roomInfo.isCloseScreen) {
[self showErrorToast:YMLocalizedString(@"XPUserCardViewController16")];
return;
}
[self dismissViewControllerAnimated:NO completion:^{
UIViewController *vc = self.cardInfo.delegate.getCurrentNav.viewControllers[0];
[XPRoomSendTextView showTextView:vc.view delegate:self.cardInfo.delegate atUid:self.cardInfo.uid atNick:self.targetUserInfo.nick];
}];
}
default:
break;
}
}
}
#pragma mark - UICollectionViewDataSource
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
XPUserCardItemCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPUserCardItemCollectionViewCell class]) forIndexPath:indexPath];
cell.itemModel = [self.datasource safeObjectAtIndex1:indexPath.item];
return cell;
}
#pragma mark - Event Response
- (void)microButtonAction:(UIButton *)sender {
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.cardInfo.roomInfo.uid];;
NSString * roomId = [NSString stringWithFormat:@"%ld", self.cardInfo.roomInfo.roomId];;
switch (sender.tag) {
case UserCardMicroType_UpDown:
{
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_mike_click eventAttributes:@{@"actionType" : @"downMic"}];
if (sender.selected) {
if ([self isInSudGame:self.cardInfo.uid]) {
if (self.cardInfo.uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) {
[self showErrorToast:YMLocalizedString(@"XPUserCardViewController17")];
[self dismissViewControllerAnimated:YES completion:nil];
} else {
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.message = YMLocalizedString(@"XPUserCardViewController18");
[TTPopup alertWithConfig:config confirmHandler:^{
[self.presenter kickDownMicro:self.cardInfo.position roomId:roomId];
} cancelHandler:^{
}];
}
return;
}else {
[self.presenter kickDownMicro:self.cardInfo.position roomId:roomId];
}
} else {
self.operaStackView.hidden = YES;
int micCount = self.cardInfo.roomInfo.type == RoomType_Anchor ? 4 : self.cardInfo.roomInfo.type == RoomType_MiniGame ? 6 : 9;
[self.presenter getRoomMicroItems:micCount cardInfo:self.cardInfo];
}
}
break;
case UserCardMicroType_Lock:
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_mike_click eventAttributes:@{@"actionType" : @"lockMic"}];
[self.presenter microLock:roomUid state:sender.selected position:self.cardInfo.position];
break;
case UserCardMicroType_Mute:
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_mike_click eventAttributes:@{@"actionType" : @"muteMic"}];
[self.presenter microMute:roomUid state:sender.selected position:self.cardInfo.position];
break;
case UserCardMicroType_Clean_Gift_Value:
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_mike_click eventAttributes:@{@"actionType" : @"cleanGiftValue"}];
[self.presenter cleanUserGiftValue:roomUid micUid:self.cardInfo.uid];
break;
default:
break;
}
}
- (void)reportButtonAction:(UIButton *)sender {
[self dismissViewControllerAnimated:YES completion:nil];
XPWebViewController *vc = [[XPWebViewController alloc]init];
NSString *urlstr = [NSString stringWithFormat:@"%@?reportUid=%@&source=USERCARD",URLWithType(kReportRoomURL),self.cardInfo.uid];
vc.url = urlstr;
[(UINavigationController *)self.presentingViewController pushViewController:vc animated:YES];
}
- (void)closeButtonAction:(UIButton *)sender {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_mike_click eventAttributes:@{@"actionType" : @"close"}];
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)disMisssVc:(UITapGestureRecognizer *)tap {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)gotoUserInfoVC:(UITapGestureRecognizer *)tap {
[self dismissViewControllerAnimated:YES completion:nil];
if ([ClientConfig shareConfig].canOpen) {
XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init];
userInfoVC.uid = self.cardInfo.uid.integerValue;
[((UINavigationController *)self.presentingViewController) pushViewController:userInfoVC animated:YES];
}else{
XPMineSimpleUserInfoViewController * userInfoVC = [[XPMineSimpleUserInfoViewController alloc] init];
userInfoVC.uid = self.cardInfo.uid.integerValue;
[((UINavigationController *)self.presentingViewController) pushViewController:userInfoVC animated:YES];
}
}
- (void)pickHeartButtonAction:(UIButton *)sender {
if (self.cardInfo.position.length > 0) {
TTAlertConfig * config = [[TTAlertConfig alloc] init];
config.title = [NSString stringWithFormat:YMLocalizedString(@"XPUserCardViewController19"), (self.cardInfo.position.intValue + 1)];
config.message = YMLocalizedString(@"XPUserCardViewController20");
config.messageColor = UIColorFromRGB(0xFE5D7F);
config.messageFont = [UIFont systemFontOfSize:14];
[TTPopup alertWithConfig:config confirmHandler:^{
[self.presenter pickHeartUser:[NSString stringWithFormat:@"%ld", self.cardInfo.roomInfo.uid] chosenUserId:self.cardInfo.uid];
} cancelHandler:^{
}];
}
}
- (void)copysIdRecognizer {
[UIPasteboard generalPasteboard].string = [NSString stringWithFormat:@"%ld", self.targetUserInfo.erbanNo];
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"XPUserCardViewController21")];
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventID_datacard_copyid_click];
}
#pragma mark - Getters And Setters
- (UIView *)topTapView {
if (!_topTapView) {
_topTapView = [[UIView alloc] init];
_topTapView.backgroundColor = [UIColor clearColor];
}
return _topTapView;
}
- (UIView *)bottomTapView {
if (!_bottomTapView) {
_bottomTapView = [[UIView alloc] init];
_bottomTapView.backgroundColor = [UIColor clearColor];
}
return _bottomTapView;
}
- (UIView *)backView {
if (!_backView) {
_backView = [[UIView alloc] init];
_backView.backgroundColor = [UIColor whiteColor];
_backView.layer.masksToBounds = YES;
_backView.layer.cornerRadius = 12;
}
return _backView;
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisVertical;
_stackView.distribution = UIStackViewDistributionFill;
_stackView.alignment = UIStackViewAlignmentCenter;
_stackView.spacing = 0;
}
return _stackView;
}
- (UIView *)userInfoView {
if (!_userInfoView) {
_userInfoView = [[UIView alloc] init];
_userInfoView.backgroundColor = [UIColor clearColor];
}
return _userInfoView;
}
- (UIVisualEffectView *)effectView {
if (!_effectView) {
UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
_effectView = [[UIVisualEffectView alloc]initWithEffect:effect];
}
return _effectView;
}
- (NetImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[NetImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.layer.masksToBounds = YES;
_backImageView.layer.cornerRadius = 25;
_backImageView.contentMode = UIViewContentModeScaleAspectFill;
_backImageView.image = [UIImageConstant defaultAvatarPlaceholder];
}
return _backImageView;
}
- (NetImageView *)nobleImageView {
if (!_nobleImageView) {
_nobleImageView = [[NetImageView alloc] init];
_nobleImageView.contentMode = UIViewContentModeScaleToFill;
_nobleImageView.layer.masksToBounds = YES;
}
return _nobleImageView;
}
- (UIButton *)reportButton {
if (!_reportButton) {
_reportButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_reportButton setTitle:YMLocalizedString(@"XPUserCardViewController22") forState:UIControlStateNormal];
[_reportButton setTitleColor:[DJDKMIMOMColor userNickColor] forState:UIControlStateNormal];
_reportButton.titleLabel.font = [UIFont systemFontOfSize:12];
[_reportButton addTarget:self action:@selector(reportButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _reportButton;
}
- (UIButton *)closeButton {
if (!_closeButton) {
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_closeButton setImage:[UIImage imageNamed:@"usercard_close"] forState:UIControlStateNormal];
[_closeButton setImage:[UIImage imageNamed:@"usercard_close"] forState:UIControlStateSelected];
[_closeButton addTarget:self action:@selector(closeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _closeButton;
}
- (NetImageView *)avatarImageView {
if (!_avatarImageView) {
NetImageConfig * config = [[NetImageConfig alloc] init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
config.imageType = ImageTypeUserIcon;
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
_avatarImageView.userInteractionEnabled = YES;
_avatarImageView.layer.masksToBounds = YES;
_avatarImageView.layer.cornerRadius = 25;
_avatarImageView.contentMode = UIViewContentModeScaleAspectFill;
}
return _avatarImageView;
}
- (UILabel *)nickLabel {
if (!_nickLabel) {
_nickLabel = [[UILabel alloc] init];
_nickLabel.font = [UIFont systemFontOfSize:15];
_nickLabel.textColor = [DJDKMIMOMColor userNickColor];
}
return _nickLabel;
}
- (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 *)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.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
config.imageType = ImageTypeUserCardLevel;
_experImageView = [[NetImageView alloc] initWithConfig:config];
_experImageView.userInteractionEnabled = YES;
_experImageView.hidden = YES;
_experImageView.contentMode = UIViewContentModeScaleAspectFit;
}
return _experImageView;
}
- (NetImageView *)charmImageView {
if (!_charmImageView) {
NetImageConfig * config = [[NetImageConfig alloc] init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
config.imageType = ImageTypeUserCardLevel;
_charmImageView = [[NetImageView alloc] initWithConfig:config];
_charmImageView.userInteractionEnabled = YES;
_charmImageView.hidden = YES;
_charmImageView.contentMode = UIViewContentModeScaleAspectFit;
}
return _charmImageView;
}
- (NetImageView *)nobleIconImageView {
if (!_nobleIconImageView) {
NetImageConfig * config = [[NetImageConfig alloc] init];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
config.imageType = ImageTypeUserCardLevel;
_nobleIconImageView = [[NetImageView alloc] initWithConfig:config];
_nobleIconImageView.contentMode = UIViewContentModeScaleAspectFit;
}
return _nobleIconImageView;
}
- (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 = [DJDKMIMOMColor userNickColor];
}
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;
}
- (UILabel *)idLabel {
if (!_idLabel) {
_idLabel = [[UILabel alloc] init];
_idLabel.font = [UIFont systemFontOfSize:10];
_idLabel.textColor = [DJDKMIMOMColor textThirdColor];
_idLabel.userInteractionEnabled = YES;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(copysIdRecognizer)];
[_idLabel addGestureRecognizer:tap];
}
return _idLabel;
}
- (XPUserCardSkillCardView *)skillCardView {
if (!_skillCardView) {
_skillCardView = [[XPUserCardSkillCardView alloc] init];
}
return _skillCardView;
}
- (UICollectionView *)collectionView{
if (!_collectionView) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.itemSize = CGSizeMake((KScreenWidth - 45 * 2)/ 4, 55);
layout.minimumLineSpacing = 16;
layout.minimumInteritemSpacing = 0;
layout.sectionInset = UIEdgeInsetsMake(16, 0, 10, 0);
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.dataSource = self;
_collectionView.delegate = self;
_collectionView.hidden = YES;
_collectionView.backgroundColor = [UIColor clearColor];
[_collectionView registerClass:[XPUserCardItemCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPUserCardItemCollectionViewCell class])];
}
return _collectionView;
}
- (UIView *)sepLineView {
if (!_sepLineView) {
_sepLineView = [[UIView alloc] init];
_sepLineView.backgroundColor = [DJDKMIMOMColor userDividerColor];
_sepLineView.hidden = YES;
}
return _sepLineView;
}
- (UIStackView *)operaStackView {
if (!_operaStackView) {
_operaStackView = [[UIStackView alloc] init];
_operaStackView.axis = UILayoutConstraintAxisHorizontal;
_operaStackView.distribution = UIStackViewDistributionFillEqually;
_operaStackView.alignment = UIStackViewAlignmentFill;
_operaStackView.spacing = 0;
_operaStackView.hidden = YES;
}
return _operaStackView;
}
- (SpriteSheetImageManager *)manager {
if (!_manager) {
_manager = [[SpriteSheetImageManager alloc] init];
}
return _manager;
}
- (YYAnimatedImageView *)headWearImageView {
if (!_headWearImageView) {
_headWearImageView = [[YYAnimatedImageView alloc] init];
_headWearImageView.backgroundColor = [UIColor clearColor];
_headWearImageView.contentMode = UIViewContentModeScaleAspectFit;
}
return _headWearImageView;
}
- (UIView *)pickHeartView {
if (!_pickHeartView) {
_pickHeartView = [[UIView alloc] init];
_pickHeartView.backgroundColor = [UIColor clearColor];
_pickHeartView.hidden = YES;
}
return _pickHeartView;
}
- (UIButton *)pickHeartButton {
if (!_pickHeartButton) {
_pickHeartButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_pickHeartButton setTitle:YMLocalizedString(@"XPUserCardViewController23") forState:UIControlStateNormal];
[_pickHeartButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_pickHeartButton.titleLabel.font = [UIFont systemFontOfSize:13];
[_pickHeartButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFA7186), UIColorFromRGB(0xFA4972)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
_pickHeartButton.layer.masksToBounds = YES;
_pickHeartButton.layer.cornerRadius = 15;
[_pickHeartButton addTarget:self action:@selector(pickHeartButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _pickHeartButton;
}
- (UIImageView *)copysIdImageView {
if (!_copysIdImageView) {
_copysIdImageView = [[UIImageView alloc] init];
_copysIdImageView.userInteractionEnabled = YES;
_copysIdImageView.image = [UIImage imageNamed:@"mine_user_id_copy_white"];
_copysIdImageView.hidden = YES;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(copysIdRecognizer)];
[_copysIdImageView addGestureRecognizer:tap];
}
return _copysIdImageView;
}
@end