房间内PK选择Pk的人

This commit is contained in:
fengshuo
2022-03-29 21:45:17 +08:00
parent 2f00ee7f78
commit 94ce5d4db1
19 changed files with 678 additions and 85 deletions

View File

@@ -300,6 +300,7 @@
E80B0734280D740600A79F63 /* MessageContentGuildView.m in Sources */ = {isa = PBXBuildFile; fileRef = E80B0733280D740600A79F63 /* MessageContentGuildView.m */; }; E80B0734280D740600A79F63 /* MessageContentGuildView.m in Sources */ = {isa = PBXBuildFile; fileRef = E80B0733280D740600A79F63 /* MessageContentGuildView.m */; };
E80B0737280D790400A79F63 /* GuildMessageModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E80B0736280D790400A79F63 /* GuildMessageModel.m */; }; E80B0737280D790400A79F63 /* GuildMessageModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E80B0736280D790400A79F63 /* GuildMessageModel.m */; };
E80A086227F2AC190027B30C /* RoomPKDetailInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E80A086127F2AC190027B30C /* RoomPKDetailInfoModel.m */; }; E80A086227F2AC190027B30C /* RoomPKDetailInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E80A086127F2AC190027B30C /* RoomPKDetailInfoModel.m */; };
E80A086527F318620027B30C /* XPRoomPKPlayingView.m in Sources */ = {isa = PBXBuildFile; fileRef = E80A086427F318620027B30C /* XPRoomPKPlayingView.m */; };
E80CBDE627D0C1CF001E1EC2 /* HomeMenuSourceModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E80CBDE527D0C1CF001E1EC2 /* HomeMenuSourceModel.m */; }; E80CBDE627D0C1CF001E1EC2 /* HomeMenuSourceModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E80CBDE527D0C1CF001E1EC2 /* HomeMenuSourceModel.m */; };
E80CBDEA27D0C53F001E1EC2 /* XPWeakTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = E80CBDE927D0C53F001E1EC2 /* XPWeakTimer.m */; }; E80CBDEA27D0C53F001E1EC2 /* XPWeakTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = E80CBDE927D0C53F001E1EC2 /* XPWeakTimer.m */; };
E80CBDED27D0D899001E1EC2 /* XPHomeLikeEmptyTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E80CBDEC27D0D899001E1EC2 /* XPHomeLikeEmptyTableViewCell.m */; }; E80CBDED27D0D899001E1EC2 /* XPHomeLikeEmptyTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E80CBDEC27D0D899001E1EC2 /* XPHomeLikeEmptyTableViewCell.m */; };
@@ -1416,6 +1417,8 @@
E80B0736280D790400A79F63 /* GuildMessageModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GuildMessageModel.m; sourceTree = "<group>"; }; E80B0736280D790400A79F63 /* GuildMessageModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GuildMessageModel.m; sourceTree = "<group>"; };
E80A086027F2AC190027B30C /* RoomPKDetailInfoModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RoomPKDetailInfoModel.h; sourceTree = "<group>"; }; E80A086027F2AC190027B30C /* RoomPKDetailInfoModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RoomPKDetailInfoModel.h; sourceTree = "<group>"; };
E80A086127F2AC190027B30C /* RoomPKDetailInfoModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RoomPKDetailInfoModel.m; sourceTree = "<group>"; }; E80A086127F2AC190027B30C /* RoomPKDetailInfoModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RoomPKDetailInfoModel.m; sourceTree = "<group>"; };
E80A086327F318620027B30C /* XPRoomPKPlayingView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomPKPlayingView.h; sourceTree = "<group>"; };
E80A086427F318620027B30C /* XPRoomPKPlayingView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomPKPlayingView.m; sourceTree = "<group>"; };
E80CBDE427D0C1CF001E1EC2 /* HomeMenuSourceModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeMenuSourceModel.h; sourceTree = "<group>"; }; E80CBDE427D0C1CF001E1EC2 /* HomeMenuSourceModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeMenuSourceModel.h; sourceTree = "<group>"; };
E80CBDE527D0C1CF001E1EC2 /* HomeMenuSourceModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeMenuSourceModel.m; sourceTree = "<group>"; }; E80CBDE527D0C1CF001E1EC2 /* HomeMenuSourceModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeMenuSourceModel.m; sourceTree = "<group>"; };
E80CBDE827D0C53F001E1EC2 /* XPWeakTimer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPWeakTimer.h; sourceTree = "<group>"; }; E80CBDE827D0C53F001E1EC2 /* XPWeakTimer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPWeakTimer.h; sourceTree = "<group>"; };
@@ -4025,6 +4028,8 @@
E8664ED527E434D5000171BA /* XPRoomPKRecordViewController.m */, E8664ED527E434D5000171BA /* XPRoomPKRecordViewController.m */,
E81AF32327F1D5B8003B9E43 /* XPRoomPKProgressView.h */, E81AF32327F1D5B8003B9E43 /* XPRoomPKProgressView.h */,
E81AF32427F1D5B8003B9E43 /* XPRoomPKProgressView.m */, E81AF32427F1D5B8003B9E43 /* XPRoomPKProgressView.m */,
E80A086327F318620027B30C /* XPRoomPKPlayingView.h */,
E80A086427F318620027B30C /* XPRoomPKPlayingView.m */,
); );
path = View; path = View;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -7053,6 +7058,7 @@
9BA8A48327C726E8000365A3 /* ThemeColor+SkillCard.m in Sources */, 9BA8A48327C726E8000365A3 /* ThemeColor+SkillCard.m in Sources */,
E8AEAED6271412EC0017FCE0 /* XPRoomViewController.m in Sources */, E8AEAED6271412EC0017FCE0 /* XPRoomViewController.m in Sources */,
E8E5E1A327C3730B00F457D8 /* XPHomeSectionView.m in Sources */, E8E5E1A327C3730B00F457D8 /* XPHomeSectionView.m in Sources */,
E80A086527F318620027B30C /* XPRoomPKPlayingView.m in Sources */,
E8E70D9226F2F60C00F03460 /* XPMineItemModel.m in Sources */, E8E70D9226F2F60C00F03460 /* XPMineItemModel.m in Sources */,
189DD74A26E21D8400AB55B1 /* SSKeychain.m in Sources */, 189DD74A26E21D8400AB55B1 /* SSKeychain.m in Sources */,
E8DACCFE27673F870052092C /* GiftValueInfoModel.m in Sources */, E8DACCFE27673F870052092C /* GiftValueInfoModel.m in Sources */,

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_pk_playing_bg@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_pk_playing_bg@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_pk_playing_fold@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_pk_playing_fold@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@@ -41,6 +41,7 @@
#import "XPAnchorFansTaskModel.h" #import "XPAnchorFansTaskModel.h"
#import "AcrossRoomPKPanelModel.h" #import "AcrossRoomPKPanelModel.h"
#import "RoomPKDetailInfoModel.h" #import "RoomPKDetailInfoModel.h"
#import "RoomPKChooseUserModel.h"
///View ///View
#import "XPRoomHalfWebView.h" #import "XPRoomHalfWebView.h"
#import "XPAnchorAudienceUpMicView.h" #import "XPAnchorAudienceUpMicView.h"
@@ -339,14 +340,24 @@
if (micModel.userInfo && micModel.userInfo.uid > 0) { if (micModel.userInfo && micModel.userInfo.uid > 0) {
UserInfoModel * userInfo = micModel.userInfo; UserInfoModel * userInfo = micModel.userInfo;
if (userInfo.groupType == GroupTyp_Red) { if (userInfo.groupType == GroupTyp_Red) {
[redArray addObject:userInfo]; RoomPKChooseUserModel * redInfo = [[RoomPKChooseUserModel alloc] init];
redInfo.userUrl = userInfo.avatar;
redInfo.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
redInfo.groupType = userInfo.groupType;
redInfo.position = micModel.microState.position;
[redArray addObject:redInfo];
} else if(userInfo.groupType == GroupType_Blue) { } else if(userInfo.groupType == GroupType_Blue) {
[blueArray addObject:userInfo]; RoomPKChooseUserModel * blueInfo = [[RoomPKChooseUserModel alloc] init];
blueInfo.userUrl = userInfo.avatar;
blueInfo.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
blueInfo.groupType = userInfo.groupType;
blueInfo.position = micModel.microState.position;
[blueArray addObject:blueInfo];
} }
} }
} }
self.roompkPanelView.redUserArray = redArray; self.roompkPanelView.redChooseArray = redArray.copy;
self.roompkPanelView.blueUserArray = blueArray; self.roompkPanelView.blueChooseArray = blueArray.copy;
} }
} else { } else {
[XCHUDTool showErrorWithMessage:msg]; [XCHUDTool showErrorWithMessage:msg];
@@ -503,6 +514,38 @@
AttachmentModel *attachment = (AttachmentModel *)obj.attachment; AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_AnchorRoom_AudienceUpMic) { if (attachment.first == CustomMessageType_AnchorRoom_AudienceUpMic) {
[self showAskForUpMic:attachment.data]; [self showAskForUpMic:attachment.data];
} else if(attachment.first == CustomMessageType_Room_PK) {
if (attachment.second == Custom_Message_Sub_Room_PK_Start) {
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:attachment.data];
self.pkDetailInfo.roomPK = pkInfo;
[self.roompkPanelView startRoomPKCountDown:pkInfo.duration];
if (pkInfo.pkStatus == RoomPKStatusType_Playing) {
//TODO: Pk
}
}else if (attachment.second == Custom_Message_Sub_Room_PK_Mode_Open){
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:attachment.data];
self.pkDetailInfo.roomPK = pkInfo;
} else if(attachment.second == Custom_Message_Sub_Room_PK_Re_Start) {
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:attachment.data];
self.pkDetailInfo.roomPK = pkInfo;
} else if(attachment.second == Custom_Message_Sub_Room_PK_Result) {
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:attachment.data];
self.roompkPanelView.isReceivePKResult = YES;
[self.roompkPanelView stopRoomPKCountDown];
if (pkInfo.pkStatus == RoomPKStatusType_ReStart) {///
self.pkDetailInfo.roomPK = pkInfo;
} else {
if (pkInfo.pkId == self.pkDetailInfo.roomPK.pkId) {
self.pkDetailInfo.roomPK = pkInfo;
//TODO:
}
}
} else if(attachment.second == Custom_Message_Sub_Room_PK_Mode_Close) {
[self.roompkPanelView stopRoomPKCountDown];
[self.roompkPanelView clearRoomPKTeamData];
[self.roompkPanelView removeFromSuperview];
//TODO:
}
} else if (attachment.first == CustomMessageType_Across_Room_PK) { } else if (attachment.first == CustomMessageType_Across_Room_PK) {
/// ///
BOOL meIsSuperAdmin = NO; BOOL meIsSuperAdmin = NO;
@@ -789,14 +832,24 @@
if (micModel.userInfo && micModel.userInfo.uid > 0) { if (micModel.userInfo && micModel.userInfo.uid > 0) {
UserInfoModel * userInfo = micModel.userInfo; UserInfoModel * userInfo = micModel.userInfo;
if (userInfo.groupType == GroupTyp_Red) { if (userInfo.groupType == GroupTyp_Red) {
[redArray addObject:userInfo]; RoomPKChooseUserModel * redInfo = [[RoomPKChooseUserModel alloc] init];
redInfo.userUrl = userInfo.avatar;
redInfo.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
redInfo.groupType = userInfo.groupType;
redInfo.position = micModel.microState.position;
[redArray addObject:redInfo];
} else if(userInfo.groupType == GroupType_Blue) { } else if(userInfo.groupType == GroupType_Blue) {
[blueArray addObject:userInfo]; RoomPKChooseUserModel * blueInfo = [[RoomPKChooseUserModel alloc] init];
blueInfo.userUrl = userInfo.avatar;
blueInfo.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
blueInfo.groupType = userInfo.groupType;
blueInfo.position = micModel.microState.position;
[blueArray addObject:blueInfo];
} }
} }
} }
self.roompkPanelView.redUserArray = redArray; self.roompkPanelView.redChooseArray = redArray.copy;
self.roompkPanelView.blueUserArray = blueArray; self.roompkPanelView.blueChooseArray = blueArray.copy;
} }
} else { } else {
[self getRoomPKDetailInfo]; [self getRoomPKDetailInfo];

View File

@@ -55,6 +55,16 @@ NS_ASSUME_NONNULL_BEGIN
duration:(NSString *)duration duration:(NSString *)duration
roomUid:(NSString *)roomUid roomUid:(NSString *)roomUid
operUid:(NSString *)operUid; operUid:(NSString *)operUid;
/// 查询房间PK结果
/// @param completion 完成
/// @param roomUid 房主的uid
/// @param operUid 操作者的uid
/// @param pkId Pk的id
+ (void)checkRoomPKResult:(HttpRequestHelperCompletion)completion
roomUid:(NSString *)roomUid
operUid:(NSString *)operUid
pkId:(NSString *)pkId;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -53,6 +53,14 @@
[self makeRequest:@"room/pk/create" method:HttpRequestHelperMethodPOST completion:completion,__FUNCTION__, pkMode, voteMode, duration, roomUid, operUid, nil]; [self makeRequest:@"room/pk/create" method:HttpRequestHelperMethodPOST completion:completion,__FUNCTION__, pkMode, voteMode, duration, roomUid, operUid, nil];
} }
/// PK
/// @param completion
/// @param roomUid uid
/// @param operUid uid
/// @param pkId Pkid
+ (void)checkRoomPKResult:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid operUid:(NSString *)operUid pkId:(NSString *)pkId {
[self makeRequest:@"room/pk/query" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, roomUid, operUid, pkId, nil];
}
@end @end

View File

@@ -44,6 +44,20 @@ typedef NS_ENUM(NSInteger,RoomPKStatusType){
@property (nonatomic, copy) NSDictionary<NSString *, NSDictionary<NSString *, NSArray<NSString *> *> *> *sendGiftUids; @property (nonatomic, copy) NSDictionary<NSString *, NSDictionary<NSString *, NSArray<NSString *> *> *> *sendGiftUids;
///参与PK的队伍 ///参与PK的队伍
@property (nonatomic, strong) NSArray<RoomPKTeamModel *> * teams; @property (nonatomic, strong) NSArray<RoomPKTeamModel *> * teams;
///本地字段
///红队的人员
@property (nonatomic,strong) NSArray *redUserArray;
///蓝队的人员
@property (nonatomic,strong) NSArray *blueUserArray;
///红队按礼物价值计算的话分数
@property (nonatomic,assign) CGFloat redTeamValueScore;
///蓝队总的分数按礼物价值计算的话分数
@property (nonatomic,assign) CGFloat blueTeamValueScore;
///红队收到礼物个数(按照收礼个数)
@property (nonatomic, strong) NSMutableSet * redTeamGiftPersonDic;
///蓝队收到礼物个数(按照收礼个数)
@property (nonatomic, strong) NSMutableSet * blueTeamGiftPersonDic;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -8,15 +8,17 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "XPEnum.h" #import "XPEnum.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class XPRoomPKPanelUserView, UserInfoModel; @class XPRoomPKPanelUserView, RoomPKChooseUserModel;
@protocol XPRoomPKPanelUserViewDelegate <NSObject> @protocol XPRoomPKPanelUserViewDelegate <NSObject>
///选择红队还是蓝队的添加人 ///选择红队还是蓝队的添加人
- (void)xPRoomPKPanelUserView:(XPRoomPKPanelUserView *)view didClickAddButton:(GroupType)type; - (void)xPRoomPKPanelUserView:(XPRoomPKPanelUserView *)view didClickAddButton:(GroupType)type;
@end @end
@interface XPRoomPKPanelUserView : UIView @interface XPRoomPKPanelUserView : UIView
///高度
@property (nonatomic,assign) CGFloat itemHeight;
@property (nonatomic,assign) GroupType type; @property (nonatomic,assign) GroupType type;
@property (nonatomic,strong) NSArray<UserInfoModel *> *userArray; @property (nonatomic,strong, nullable) NSArray<RoomPKChooseUserModel *> *userArray;
///代理 ///代理
@property (nonatomic,weak) id<XPRoomPKPanelUserViewDelegate> delegate; @property (nonatomic,weak) id<XPRoomPKPanelUserViewDelegate> delegate;
@end @end

View File

@@ -12,7 +12,7 @@
#import "NetImageView.h" #import "NetImageView.h"
#import "ThemeColor.h" #import "ThemeColor.h"
///Model ///Model
#import "UserInfoModel.h" #import "RoomPKChooseUserModel.h"
@interface XPRoomPKPanelUserView () @interface XPRoomPKPanelUserView ()
/// ///
@@ -49,6 +49,7 @@
#pragma mark - Private Method #pragma mark - Private Method
- (void)initSubViews { - (void)initSubViews {
self.itemHeight = 25;
[self addSubview:self.stackView]; [self addSubview:self.stackView];
[self.stackView addArrangedSubview:self.addButton]; [self.stackView addArrangedSubview:self.addButton];
[self.stackView addArrangedSubview:self.userView]; [self.stackView addArrangedSubview:self.userView];
@@ -100,14 +101,14 @@
for (int i = 0 ; i< self.viewArray.count; i++) { for (int i = 0 ; i< self.viewArray.count; i++) {
NetImageView * view = [self.viewArray objectAtIndex:i]; NetImageView * view = [self.viewArray objectAtIndex:i];
if (i < self.userArray.count) { if (i < self.userArray.count) {
UserInfoModel * userInfo = [self.userArray objectAtIndex:i]; RoomPKChooseUserModel * userInfo = [self.userArray objectAtIndex:i];
view.hidden = NO; view.hidden = NO;
view.imageUrl = userInfo.avatar; view.imageUrl = userInfo.userUrl;
} else { } else {
view.hidden = YES; view.hidden = YES;
} }
} }
CGFloat userViewWidth = (_userArray.count - 1) * 15 + 25; CGFloat userViewWidth = (_userArray.count - 1) * 15 + self.itemHeight;
[self.userView mas_updateConstraints:^(MASConstraintMaker *make) { [self.userView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(userViewWidth); make.width.mas_equalTo(userViewWidth);
}]; }];
@@ -128,7 +129,7 @@
self.fifthUserView.layer.borderColor = color; self.fifthUserView.layer.borderColor = color;
[self.addButton setImage:[UIImage imageNamed:@"room_pk_progrss_red_add"] forState:UIControlStateNormal]; [self.addButton setImage:[UIImage imageNamed:@"room_pk_progrss_red_add"] forState:UIControlStateNormal];
[self.firstUserView mas_makeConstraints:^(MASConstraintMaker *make) { [self.firstUserView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(25, 25)); make.size.mas_equalTo(CGSizeMake(self.itemHeight, self.itemHeight));
make.right.centerY.mas_equalTo(self.userView); make.right.centerY.mas_equalTo(self.userView);
}]; }];
@@ -161,7 +162,7 @@
self.fifthUserView.layer.borderColor = color; self.fifthUserView.layer.borderColor = color;
[self.addButton setImage:[UIImage imageNamed:@"room_pk_progrss_blue_add"] forState:UIControlStateNormal]; [self.addButton setImage:[UIImage imageNamed:@"room_pk_progrss_blue_add"] forState:UIControlStateNormal];
[self.fifthUserView mas_makeConstraints:^(MASConstraintMaker *make) { [self.fifthUserView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(25, 25)); make.size.mas_equalTo(CGSizeMake(self.itemHeight, self.itemHeight));
make.left.centerY.mas_equalTo(self.userView); make.left.centerY.mas_equalTo(self.userView);
}]; }];
@@ -189,6 +190,13 @@
} }
} }
- (void)setItemHeight:(CGFloat)itemHeight {
_itemHeight = itemHeight;
[self mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(self.itemHeight);
}];
}
- (UIStackView *)stackView { - (UIStackView *)stackView {
if (!_stackView) { if (!_stackView) {
_stackView = [[UIStackView alloc] init]; _stackView = [[UIStackView alloc] init];

View File

@@ -139,10 +139,11 @@
*stop = YES; *stop = YES;
} }
}]; }];
if (selectModel) { if (selectModel && !model.isSelect) {
[self.chooseArray removeObject:selectModel]; selectModel.groupType = GroupType_default;
} }
if (model.isSelect) {
if (model.isSelect && selectModel == nil) {
[self.chooseArray addObject:model]; [self.chooseArray addObject:model];
} }
} }

View File

@@ -0,0 +1,19 @@
//
// XPRoomPKPlayingView.h
// xplan-ios
//
// Created by 冯硕 on 2022/3/29.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class RoomPKDetailInfoModel;
@interface XPRoomPKPlayingView : UIView
///是否是管理员
@property (nonatomic,assign) BOOL isManager;
///PK详情
@property (nonatomic,strong) RoomPKDetailInfoModel *pkDetailInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,338 @@
//
// XPRoomPKPlayingView.m
// xplan-ios
//
// Created by on 2022/3/29.
//
#import "XPRoomPKPlayingView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "ThemeColor.h"
#import "XPMacro.h"
#import "TTPopup.h"
#import "UIImage+Utils.h"
///Model
#import "RoomPKDetailInfoModel.h"
///View
#import "XPRoomPKPanelUserView.h"
@interface XPRoomPKPlayingView ()
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) UIButton *beginButton;
///
@property (nonatomic,strong) UILabel *timeLabel;
///
@property (nonatomic,strong) XPRoomPKPanelUserView * redTeamView;
///
@property (nonatomic,strong) UILabel *redScoreLabel;
///
@property (nonatomic,strong) XPRoomPKPanelUserView * blueTeamView;
///
@property (nonatomic,strong) UILabel *blueScoreLabel;
///
@property (nonatomic,strong) UIView * progressView;
///
@property (nonatomic,strong) UIImageView * redProgressView;
///
@property (nonatomic,strong) UIImageView * blueProgressView;
///线
@property (nonatomic,strong) UIImageView *progressLineView;
///
@property (nonatomic,strong) UIButton *foldButton;
///Pk
@property (nonatomic,strong) UILabel *voteModeLabel;
///pk
@property (nonatomic,strong) UILabel *pkLabel;
@end
@implementation XPRoomPKPlayingView
- (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.backImageView];
[self.backImageView addSubview:self.timeLabel];
[self.backImageView addSubview:self.redTeamView];
[self.backImageView addSubview:self.redScoreLabel];
[self.backImageView addSubview:self.blueTeamView];
[self.backImageView addSubview:self.blueScoreLabel];
[self.backImageView addSubview:self.progressView];
[self.backImageView addSubview:self.beginButton];
[self.backImageView addSubview:self.voteModeLabel];
[self.backImageView addSubview:self.pkLabel];
[self.progressView addSubview:self.redProgressView];
[self.progressView addSubview:self.blueProgressView];
[self.progressView addSubview:self.progressLineView];
}
- (void)initSubViewConstraints {
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(260);
make.height.mas_equalTo(153);
}];
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.backImageView);
}];
[self.redTeamView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.backImageView.mas_centerX).offset(-56);
make.centerY.mas_equalTo(self.backImageView).offset(25);
}];
[self.voteModeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.backImageView).offset(36);
}];
[self.pkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.voteModeLabel.mas_bottom).offset(6);
}];
[self.blueTeamView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.backImageView.mas_centerX).offset(56);
make.centerY.mas_equalTo(self.redTeamView);
}];
[self.progressView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(56 * 2 + 45 * 2);
make.height.mas_equalTo(7);
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.redTeamView.mas_bottom).offset(13);
}];
[self.redProgressView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.bottom.mas_equalTo(self.progressView);
make.width.mas_equalTo(85);
}];
[self.blueProgressView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.top.bottom.mas_equalTo(self.progressView);
make.left.mas_equalTo(self.redProgressView.mas_right);
}];
[self.progressLineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(2.5, 12.5));
make.centerX.mas_equalTo(self.blueProgressView.mas_left).offset(-1.2);
make.centerY.mas_equalTo(self.progressView);
}];
[self.redScoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.progressView);
make.top.mas_equalTo(self.progressView.mas_bottom).offset(3);
}];
[self.blueScoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.redScoreLabel);
make.right.mas_equalTo(self.progressView);
}];
[self.beginButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(90, 24));
make.centerX.mas_equalTo(self.backImageView);
make.bottom.mas_equalTo(self.backImageView.mas_bottom).offset(-15);
}];
}
#pragma mark - Event Response
- (void)beginButtonAction:(UIButton *)sender {
//TODO:
}
- (void)foldButtonAction:(UIButton *)sender {
[TTPopup dismiss];
}
#pragma mark - Getters And Setters
- (void)setIsManager:(BOOL)isManager {
_isManager = isManager;
if (_isManager) {
self.beginButton.hidden = !_isManager;
}
}
- (void)setPkDetailInfo:(RoomPKDetailInfoModel *)pkDetailInfo {
_pkDetailInfo = pkDetailInfo;
if (_pkDetailInfo) {
RoomPKInfoModel * infoModel = pkDetailInfo.roomPK;
if (infoModel.teams.count > 0) {
NSMutableArray * redArray = [NSMutableArray array];
NSMutableArray * blueArray = [NSMutableArray array];
for (int i = 0; i < infoModel.teams.count; i++) {
RoomPKTeamModel * teamInfo = [infoModel.teams objectAtIndex:i];
if (infoModel.pkStatus == RoomPKStatusType_End || infoModel.pkStatus == RoomPKStatusType_NonStart) {
}
}
}
}
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_pk_playing_bg"];
}
return _backImageView;
}
- (UILabel *)timeLabel {
if (!_timeLabel) {
_timeLabel = [[UILabel alloc] init];
_timeLabel.font = [UIFont systemFontOfSize:10];
_timeLabel.textColor = UIColorFromRGB(0x602A06);
_timeLabel.textAlignment = NSTextAlignmentCenter;
_timeLabel.text= @"00:00";
}
return _timeLabel;
}
- (UILabel *)voteModeLabel {
if (!_voteModeLabel) {
_voteModeLabel = [[UILabel alloc] init];
_voteModeLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightMedium];
_voteModeLabel.textColor = UIColorFromRGB(0x79674E);
_voteModeLabel.textAlignment = NSTextAlignmentCenter;
}
return _voteModeLabel;
}
- (UILabel *)pkLabel {
if (!_pkLabel) {
_pkLabel = [[UILabel alloc] init];
_pkLabel.text= @"PK";
_pkLabel.textAlignment = NSTextAlignmentCenter;
_pkLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightMedium];;
_pkLabel.textColor = UIColorFromRGB(0x79674E);
}
return _pkLabel;
}
- (XPRoomPKPanelUserView *)redTeamView {
if (!_redTeamView) {
_redTeamView = [[XPRoomPKPanelUserView alloc] init];
_redTeamView.type = GroupTyp_Red;
_redTeamView.itemHeight = 45;
}
return _redTeamView;
}
- (XPRoomPKPanelUserView *)blueTeamView {
if (!_blueTeamView) {
_blueTeamView = [[XPRoomPKPanelUserView alloc] init];
_blueTeamView.type = GroupType_Blue;
_blueTeamView.itemHeight = 45;
}
return _blueTeamView;
}
- (UIView *)progressView {
if (!_progressView) {
_progressView = [[UIView alloc] init];
_progressView.backgroundColor = [UIColor clearColor];
}
return _progressView;
}
- (UIImageView *)redProgressView {
if (!_redProgressView) {
_redProgressView = [[UIImageView alloc] init];
_redProgressView.userInteractionEnabled = YES;
_redProgressView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFA96AE), UIColorFromRGB(0xE943F8)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
_redProgressView.contentMode = UIViewContentModeScaleAspectFill;
_redProgressView.layer.masksToBounds = YES;
}
return _redProgressView;
}
- (UIImageView *)blueProgressView {
if (!_blueProgressView) {
_blueProgressView = [[UIImageView alloc] init];
_blueProgressView.userInteractionEnabled = YES;
_blueProgressView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x4F7AFF), UIColorFromRGB(0x44C0FE)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
_blueProgressView.contentMode = UIViewContentModeScaleAspectFill;
_blueProgressView.layer.masksToBounds = YES;
}
return _blueProgressView;
}
- (UIImageView *)progressLineView {
if (!_progressLineView) {
_progressLineView = [[UIImageView alloc] init];
_progressLineView.userInteractionEnabled = YES;
_progressLineView.image = [UIImage imageNamed:@"room_pk_progrss_line_bg"];
}
return _progressLineView;
}
- (UILabel *)redScoreLabel {
if (!_redScoreLabel) {
_redScoreLabel = [[UILabel alloc] init];
_redScoreLabel.text = @"0";
_redScoreLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
_redScoreLabel.textColor = UIColor.whiteColor;
_redScoreLabel.textAlignment = NSTextAlignmentCenter;
}
return _redScoreLabel;
}
- (UILabel *)blueScoreLabel {
if (!_blueScoreLabel) {
_blueScoreLabel = [[UILabel alloc] init];
_blueScoreLabel.text = @"0";
_blueScoreLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
_blueScoreLabel.textColor = UIColor.whiteColor;
_blueScoreLabel.textAlignment = NSTextAlignmentCenter;
}
return _blueScoreLabel;
}
- (UIButton *)beginButton {
if (!_beginButton) {
_beginButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_beginButton setTitle:@"重新开始" forState:UIControlStateNormal];
[_beginButton setTitleColor:UIColorFromRGB(0x602A06) forState:UIControlStateNormal];
_beginButton.titleLabel.font = [UIFont systemFontOfSize:15];
[_beginButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFFDAA8), UIColorFromRGB(0xFFBD64)] gradientType:GradientTypeUpleftToLowright imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
_beginButton.layer.masksToBounds = YES;
_beginButton.layer.cornerRadius = 12;
[_beginButton addTarget:self action:@selector(beginButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _beginButton;
}
- (UIButton *)foldButton {
if (!_foldButton) {
_foldButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_foldButton setImage:[UIImage imageNamed:@"room_pk_playing_fold"] forState:UIControlStateNormal];
[_foldButton setImage:[UIImage imageNamed:@"room_pk_playing_fold"] forState:UIControlStateSelected];
[_foldButton addTarget:self action:@selector(foldButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _foldButton;
}
@end

View File

@@ -8,18 +8,28 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class RoomPKDetailInfoModel, MicroQueueModel, UserInfoModel; @class RoomPKDetailInfoModel, MicroQueueModel, RoomPKChooseUserModel;
@interface XPRoomPKProgressView : UIView @interface XPRoomPKProgressView : UIView
///房主的uid
@property (nonatomic,copy) NSString *roomUid;
///群聊的id ///群聊的id
@property (nonatomic,copy) NSString *roomId; @property (nonatomic,copy) NSString *roomId;
@property (nonatomic, strong) NSMutableDictionary<NSString *, MicroQueueModel *> *micQueue; @property (nonatomic, strong) NSMutableDictionary<NSString *, MicroQueueModel *> *micQueue;
@property (nonatomic,strong) RoomPKDetailInfoModel *pkDetailInfo; @property (nonatomic,strong) RoomPKDetailInfoModel *pkDetailInfo;
///是否是管理员 ///是否是管理员
@property (nonatomic,assign) BOOL isManager; @property (nonatomic,assign) BOOL isManager;
///红 ///红色的
@property (nonatomic,strong) NSArray<UserInfoModel *> *redUserArray; @property (nonatomic,strong) NSArray<RoomPKChooseUserModel *> *redChooseArray;
///蓝 ///蓝色的
@property (nonatomic,strong) NSArray<UserInfoModel *> *blueUserArray; @property (nonatomic,strong) NSArray<RoomPKChooseUserModel *> *blueChooseArray;
///是否收到了Pk的结果
@property (nonatomic,assign) BOOL isReceivePKResult;
///清理数据
- (void)clearRoomPKTeamData;
///开始倒计时
- (void)startRoomPKCountDown:(CGFloat)time;
///结束倒计时
- (void)stopRoomPKCountDown;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -13,6 +13,9 @@
#import "XPMacro.h" #import "XPMacro.h"
#import "TTPopup.h" #import "TTPopup.h"
#import "UIImage+Utils.h" #import "UIImage+Utils.h"
#import "Api+RoomPK.h"
#import "AccountInfoStorage.h"
#import "XCHUDTool.h"
///Model ///Model
#import "RoomPKDetailInfoModel.h" #import "RoomPKDetailInfoModel.h"
#import "MicroQueueModel.h" #import "MicroQueueModel.h"
@@ -46,16 +49,22 @@
@property (nonatomic,strong) UIImageView * blueProgressView; @property (nonatomic,strong) UIImageView * blueProgressView;
///线 ///线
@property (nonatomic,strong) UIImageView *progressLineView; @property (nonatomic,strong) UIImageView *progressLineView;
/// ///
@property (nonatomic,strong) NSArray *redChooseArray; @property (strong, nonatomic) dispatch_source_t timer;
/// ///
@property (nonatomic,strong) NSArray *blueChooseArray; @property (nonatomic,assign) CGFloat currentTime;
///
@property (nonatomic,assign) int checkResultNum;
@end @end
@implementation XPRoomPKProgressView @implementation XPRoomPKProgressView
- (instancetype)initWithFrame:(CGRect)frame
{ - (void)dealloc {
[self stopRoomPKCountDown];
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
[self initSubViews]; [self initSubViews];
@@ -64,6 +73,88 @@
return self; return self;
} }
#pragma mark - Public Method
- (void)startRoomPKCountDown:(CGFloat)time {
__block long tempTime = time - 1; //
__weak typeof(self) weakSelf = self;
self.currentTime = tempTime;
if (self.timer != nil) {
dispatch_source_cancel(self.timer);
}
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
dispatch_source_set_timer(self.timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //
dispatch_source_set_event_handler(self.timer, ^{
typeof(weakSelf) self = weakSelf;
if(tempTime <= 0){ //
self.currentTime = 0;
dispatch_source_cancel(self.timer);
dispatch_async(dispatch_get_main_queue(), ^{
//TODO: pk
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
//
NSInteger minute = tempTime / 60;
NSInteger second = (tempTime % 60);
NSString *timeStr = [NSString stringWithFormat:@"%02zd:%02zd", minute, second];
self.timeLabel.text= timeStr;
});
tempTime--;
self.currentTime = tempTime;
}
});
dispatch_resume(self.timer);
}
- (void)stopRoomPKCountDown {
if (self.timer) {
dispatch_source_cancel(_timer);
_timer = nil;
}
}
- (void)clearRoomPKTeamData {
self.redScoreLabel.text = @"0";
self.blueScoreLabel.text = @"0";
self.redTeamView.userArray = nil;
self.blueTeamView.userArray = nil;
}
#pragma mark - pk
- (void)checkRoomPKResult{
if (self.checkResultNum > 2) {
//pk
[self clearRoomPKTeamData];
//TODO:
return;
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (!self.isReceivePKResult) {
NSString * uid = [AccountInfoStorage instance].getUid;
if (self.pkDetailInfo.roomPK.pkId > 0) {
NSString * pkId = [NSString stringWithFormat:@"%ld", self.pkDetailInfo.roomPK.pkId];
[Api checkRoomPKResult:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
self.checkResultNum = 1;
self.isReceivePKResult = YES;
} else {
self.checkResultNum++;
[self checkRoomPKResult];
}
} roomUid:self.roomUid operUid:uid pkId:pkId];
}
}
});
}
- (void)resetRoomPKQueueDefaultGroupType {
}
#pragma mark - Private Method #pragma mark - Private Method
- (void)initSubViews { - (void)initSubViews {
[self addSubview:self.backImageView]; [self addSubview:self.backImageView];
@@ -163,31 +254,10 @@
#pragma mark - XPRoomPKPanelUserViewDelegate #pragma mark - XPRoomPKPanelUserViewDelegate
- (void)xPRoomPKPanelUserView:(XPRoomPKPanelUserView *)view didClickAddButton:(GroupType)type { - (void)xPRoomPKPanelUserView:(XPRoomPKPanelUserView *)view didClickAddButton:(GroupType)type {
if (self.isManager) { if (self.isManager) {
NSMutableArray<RoomPKChooseUserModel *> * redArrar= [NSMutableArray array];
for (int i = 0; i < self.redUserArray.count; i++) {
UserInfoModel * userInfo = [self.redUserArray objectAtIndex:i];
RoomPKChooseUserModel * model = [[RoomPKChooseUserModel alloc] init];
model.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
model.groupType = GroupTyp_Red;
model.nick = userInfo.nick;
[redArrar addObject:model];
}
self.redChooseArray = redArrar.copy;
NSMutableArray<RoomPKChooseUserModel *> * blueArrar= [NSMutableArray array];
for (int i = 0; i < self.blueUserArray.count; i++) {
UserInfoModel * userInfo = [self.blueUserArray objectAtIndex:i];
RoomPKChooseUserModel * model = [[RoomPKChooseUserModel alloc] init];
model.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
model.groupType = GroupType_Blue;
model.nick = userInfo.nick;
[blueArrar addObject:model];
}
self.blueChooseArray = blueArrar.copy;
XPRoomPKSelectUserView * chooseUserView = [[XPRoomPKSelectUserView alloc] init]; XPRoomPKSelectUserView * chooseUserView = [[XPRoomPKSelectUserView alloc] init];
chooseUserView.delegate = self; chooseUserView.delegate = self;
chooseUserView.redUserArray = redArrar; chooseUserView.redUserArray = self.redChooseArray;
chooseUserView.blueUserArray = blueArrar; chooseUserView.blueUserArray = self.blueChooseArray;
chooseUserView.groupType = type; chooseUserView.groupType = type;
chooseUserView.microQueueArray = self.micQueue.allValues; chooseUserView.microQueueArray = self.micQueue.allValues;
[TTPopup popupView:chooseUserView style:TTPopupStyleAlert]; [TTPopup popupView:chooseUserView style:TTPopupStyleAlert];
@@ -252,7 +322,25 @@
#pragma mark - Event Response #pragma mark - Event Response
- (void)beginButtonAction:(UIButton *)sender { - (void)beginButtonAction:(UIButton *)sender {
if (self.redChooseArray.count > 0 && self.blueChooseArray.count > 0) {
if (self.pkDetailInfo.roomPK.pkStatus == RoomPKStatusType_End || self.pkDetailInfo.roomPK.pkStatus == RoomPKStatusType_ReStart) {
[TTPopup alertWithMessage:@"当前正在准备阶段是否确认准备开始PK?" confirmHandler:^{
//TODO: Pk
} cancelHandler:^{
}];
} else if(self.pkDetailInfo.roomPK.pkStatus == RoomPKStatusType_Playing) {
//TODO: PK
} else if(self.pkDetailInfo.roomPK.pkStatus == RoomPKStatusType_NonStart) {
[TTPopup alertWithMessage:@"当前正在准备阶段是否确认准备开始PK?" confirmHandler:^{
///PK
} cancelHandler:^{
}];
}
} else {
[XCHUDTool showErrorWithMessage:@"每队至少有一个人"];
}
} }
#pragma mark - Getters And Setters #pragma mark - Getters And Setters
@@ -263,31 +351,14 @@
} }
} }
- (void)setPkDetailInfo:(RoomPKDetailInfoModel *)pkDetailInfo { - (void)setRedChooseArray:(NSArray<RoomPKChooseUserModel *> *)redChooseArray {
_pkDetailInfo = pkDetailInfo; _redChooseArray = redChooseArray;
if (_pkDetailInfo) { self.redTeamView.userArray = _redChooseArray;
RoomPKInfoModel * infoModel = pkDetailInfo.roomPK;
if (infoModel.teams.count > 0) {
NSMutableArray * redArray = [NSMutableArray array];
NSMutableArray * blueArray = [NSMutableArray array];
for (int i = 0; i < infoModel.teams.count; i++) {
RoomPKTeamModel * teamInfo = [infoModel.teams objectAtIndex:i];
if (infoModel.pkStatus == RoomPKStatusType_End || infoModel.pkStatus == RoomPKStatusType_NonStart) {
}
}
}
}
} }
- (void)setRedUserArray:(NSArray *)redUserArray { - (void)setBlueChooseArray:(NSArray<RoomPKChooseUserModel *> *)blueChooseArray {
_redUserArray = redUserArray; _blueChooseArray = blueChooseArray;
self.redTeamView.userArray = _redUserArray; self.blueTeamView.userArray = _blueChooseArray;
}
- (void)setBlueUserArray:(NSArray *)blueUserArray {
_blueUserArray = blueUserArray;
self.blueTeamView.userArray = _blueUserArray;
} }
- (UIImageView *)backImageView { - (UIImageView *)backImageView {

View File

@@ -56,9 +56,9 @@
/// ///
@property (nonatomic,assign) int duraTime; @property (nonatomic,assign) int duraTime;
/// ///
@property (nonatomic,copy) NSArray *redUserArray; @property (nonatomic,strong) NSMutableArray *redUserArray;
/// ///
@property (nonatomic,copy) NSArray *blueUserArray; @property (nonatomic,strong) NSMutableArray *blueUserArray;
@end @end
@implementation XPRoomPKViewController @implementation XPRoomPKViewController
@@ -238,9 +238,9 @@
- (void)xPRoomPKSelectUserView:(XPRoomPKSelectUserView *)view groupType:(GroupType)groupType didChooseUserInfos:(NSArray<RoomPKChooseUserModel *> *)userInfos { - (void)xPRoomPKSelectUserView:(XPRoomPKSelectUserView *)view groupType:(GroupType)groupType didChooseUserInfos:(NSArray<RoomPKChooseUserModel *> *)userInfos {
[TTPopup dismiss]; [TTPopup dismiss];
if (groupType == GroupTyp_Red) { if (groupType == GroupTyp_Red) {
self.redUserArray = userInfos; self.redUserArray = [NSMutableArray arrayWithArray:userInfos];;
} else { } else {
self.blueUserArray = userInfos; self.blueUserArray = [NSMutableArray arrayWithArray:userInfos];
} }
if (self.redUserArray.count > 0) { if (self.redUserArray.count > 0) {
@@ -262,14 +262,24 @@
RoomPKChooseUserModel * userInfo = [self.redUserArray objectAtIndex:i]; RoomPKChooseUserModel * userInfo = [self.redUserArray objectAtIndex:i];
if (i < self.redTeamViews.count) { if (i < self.redTeamViews.count) {
XPRoomPKUserView * userView = [self.redTeamViews objectAtIndex:i]; XPRoomPKUserView * userView = [self.redTeamViews objectAtIndex:i];
userView.userInfo = userInfo; if (userInfo.groupType == GroupTyp_Red) {
userView.userInfo = userInfo;
} else {
userView.userInfo = nil;
[self.redUserArray removeObject:userInfo];
}
} }
} }
for (int i = 0; i < self.blueUserArray.count; i++) { for (int i = 0; i < self.blueUserArray.count; i++) {
RoomPKChooseUserModel * userInfo = [self.blueUserArray objectAtIndex:i]; RoomPKChooseUserModel * userInfo = [self.blueUserArray objectAtIndex:i];
if (i < self.blueTeamViews.count) { if (i < self.blueTeamViews.count) {
XPRoomPKUserView * userView = [self.blueTeamViews objectAtIndex:i]; XPRoomPKUserView * userView = [self.blueTeamViews objectAtIndex:i];
userView.userInfo = userInfo; if (userInfo.groupType == GroupType_Blue) {
userView.userInfo = userInfo;
} else {
userView.userInfo = nil;
[self.blueUserArray removeObject:userInfo];
}
} }
} }
} }
@@ -470,5 +480,4 @@
@end @end