房间PK一开始 点击加入和排麦的时候toast

This commit is contained in:
fengshuo
2022-05-29 14:31:00 +08:00
parent 33b9873afd
commit b3c2711ae6
8 changed files with 104 additions and 73 deletions

View File

@@ -15,6 +15,7 @@
#import "ClientConfig.h"
#import "NetImageView.h"
#import "TTPopup.h"
#import "XCHUDTool.h"
///Model
#import "UserInfoModel.h"
#import "RoomInfoModel.h"
@@ -355,6 +356,10 @@
}
- (void)didTapJoinDatingRecognizer {
if (self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_PK_Mode && self.hostDelegate.isRoomPKPlaying) {
[XCHUDTool showErrorWithMessage:@"PK已开始暂时无法排麦"];
return;
}
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
request.userIds = @[[AccountInfoStorage instance].getUid];

View File

@@ -21,6 +21,8 @@ NS_ASSUME_NONNULL_BEGIN
///获取房间PK队伍的
- (NSArray *)getRoomPKGroupTeamList;
///房间内PK是否正在进行
- (BOOL)isRoomPKPlaying;
@end

View File

@@ -205,6 +205,11 @@
return @[redArray, blueArray];
}
///PK
- (BOOL)isRoomPKPlaying {
return [self.roompkPanelView isRoomPKPlaying];
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.contributeEnterView];

View File

@@ -122,6 +122,11 @@
}
break;
case XPRoomMenuItemType_ArrangeMic:{
if (self.delegate.getRoomInfo.roomModeType == RoomModeType_Open_PK_Mode && self.delegate.isRoomPKPlaying) {
[XCHUDTool showErrorWithMessage:@"PK已开始暂时无法排麦"];
return;
}
self.arrangeMicButton.selected = NO;
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.roomId];

View File

@@ -34,6 +34,8 @@ NS_ASSUME_NONNULL_BEGIN
- (NSArray *)getRoomSuperAdminList;
///获取房间PK队伍的
- (NSArray *)getRoomPKGroupTeamList;
///房间内PK是否正在进行
- (BOOL)isRoomPKPlaying;
@end
NS_ASSUME_NONNULL_END

View File

@@ -25,6 +25,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)enterRoomGetRoomPKDetailInfo;
///处理pK的状态
- (void)handleRoomPKCustomMessage:(AttachmentModel *)attachment;
///房间PK是否在进行中
- (BOOL)isRoomPKPlaying;
@end
NS_ASSUME_NONNULL_END

View File

@@ -84,6 +84,8 @@
@property (nonatomic,assign) BOOL isReceivePKResult;
///pk
@property (nonatomic,strong) RoomPKInfoModel *roomPKInfo;
///
@property (nonatomic,assign) BOOL isPlaying;
@end
@@ -284,79 +286,8 @@
} roomUid:roomUid];
}
- (void)startRoomPKCountDown:(CGFloat)time {
__block long tempTime = time; //
__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(), ^{
[self checkRoomPKResult];
});
} 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;
self.roomPKPlayingView.currentTime = timeStr;
});
tempTime--;
self.currentTime = tempTime;
}
});
dispatch_resume(self.timer);
}
- (void)stopRoomPKCountDown {
if (self.timer) {
dispatch_source_cancel(_timer);
_timer = nil;
}
}
- (void)clearRoomPKTeamData {
[self.roomPKPlayingView clearRoomPKData];
self.redScoreLabel.text = @"0";
self.blueScoreLabel.text = @"0";
self.redTeamScore = 0;
self.blueTeamScore = 0;
[self.redTeamGiftPersonDic removeAllObjects];
[self.redTeamGiftPersonDic removeAllObjects];
self.timeLabel.text = @"未开始";
[self.redProgressView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(85);
}];
}
- (void)configRedTeamScore:(long)redTeamScore blueTeamScore:(long)blueTeamScore {
self.redTeamScore = redTeamScore;
self.blueTeamScore = blueTeamScore;
self.redScoreLabel.text = [NSString stringWithFormat:@"%ld", redTeamScore];
self.blueScoreLabel.text = [NSString stringWithFormat:@"%ld", blueTeamScore];
if (redTeamScore > 0 || blueTeamScore > 0) {
CGFloat redScale = (CGFloat)redTeamScore / (CGFloat)(redTeamScore + blueTeamScore);
if (redScale == 1) {
redScale = 0.99;
}
[self.redProgressView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(85 * 2 * redScale);
}];
}
[self.roomPKPlayingView configRedTeamScore:redTeamScore blueTeamScore:blueTeamScore];
- (BOOL)isRoomPKPlaying {
return self.isPlaying;
}
#pragma mark - pk
@@ -576,6 +507,7 @@
}
- (void)handleRoomPKInfoChangeState {
self.isPlaying = NO;
if (self.roomPKInfo) {
switch (_roomPKInfo.pkStatus) {
case RoomPKStatusType_End:
@@ -585,6 +517,7 @@
{
[TTPopup dismiss];
self.beginButton.hidden = YES;
self.isPlaying = YES;
self.roomPKPlayingView.pkDetailInfo = self.roomPKInfo;
self.roomPKPlayingView.redChooseArray = self.redChooseArray;
self.roomPKPlayingView.blueChooseArray = self.blueChooseArray;
@@ -661,6 +594,79 @@
return @"";
}
- (void)startRoomPKCountDown:(CGFloat)time {
__block long tempTime = time; //
__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(), ^{
[self checkRoomPKResult];
});
} 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;
self.roomPKPlayingView.currentTime = timeStr;
});
tempTime--;
self.currentTime = tempTime;
}
});
dispatch_resume(self.timer);
}
- (void)stopRoomPKCountDown {
if (self.timer) {
dispatch_source_cancel(_timer);
_timer = nil;
}
}
- (void)clearRoomPKTeamData {
[self.roomPKPlayingView clearRoomPKData];
self.redScoreLabel.text = @"0";
self.blueScoreLabel.text = @"0";
self.redTeamScore = 0;
self.blueTeamScore = 0;
[self.redTeamGiftPersonDic removeAllObjects];
[self.redTeamGiftPersonDic removeAllObjects];
self.timeLabel.text = @"未开始";
[self.redProgressView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(85);
}];
}
- (void)configRedTeamScore:(long)redTeamScore blueTeamScore:(long)blueTeamScore {
self.redTeamScore = redTeamScore;
self.blueTeamScore = blueTeamScore;
self.redScoreLabel.text = [NSString stringWithFormat:@"%ld", redTeamScore];
self.blueScoreLabel.text = [NSString stringWithFormat:@"%ld", blueTeamScore];
if (redTeamScore > 0 || blueTeamScore > 0) {
CGFloat redScale = (CGFloat)redTeamScore / (CGFloat)(redTeamScore + blueTeamScore);
if (redScale == 1) {
redScale = 0.99;
}
[self.redProgressView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(85 * 2 * redScale);
}];
}
[self.roomPKPlayingView configRedTeamScore:redTeamScore blueTeamScore:blueTeamScore];
}
#pragma mark - XPRoomPKPanelUserViewDelegate
- (void)xPRoomPKPanelUserView:(XPRoomPKPanelUserView *)view didClickAddButton:(GroupType)type {

View File

@@ -919,6 +919,10 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
return [self.functionView getRoomPKGroupTeamList];
}
- (BOOL)isRoomPKPlaying {
return [self.functionView isRoomPKPlaying];
}
- (void)onMicroQueueUpdate:(NSMutableDictionary<NSString *,MicroQueueModel *> *)queue {
[self.menuContainerView onMicroQueueUpdate:queue];
[self.functionView onRoomUpdate];