feat: 优化 LUDO 的退房提示

This commit is contained in:
eggmanQQQ
2024-08-07 15:35:30 +08:00
parent c999bdbaf8
commit 259c8ab3f7
5 changed files with 40 additions and 4 deletions

View File

@@ -63,11 +63,20 @@
}
///
-(void)startMatchGameWithroomId:(NSString *)roomId mgId:(NSString *)mgId gameMode:(NSString *)gameMode{
@kWeakify(self);
[Api startMatchGame:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
[[self getView]startMatchGameSuccess];
} fail:^(NSInteger code, NSString * _Nullable msg) {
} showLoading:YES errorToast:YES] roomId:roomId mgId:mgId gameMode:gameMode];
if (code == 34792) { //
[TTPopup alertWithMessage:msg confirmHandler:^{
@kStrongify(self);
[[self getView] forceExitRoom];
} cancelHandler:^{}];
} else {
[[self getView] showErrorToast:msg];
}
} showLoading:YES errorToast:NO] roomId:roomId mgId:mgId gameMode:gameMode];
}
///
-(void)getRoomGameDetailWithRoomType:(NSString *)roomType{

View File

@@ -18,6 +18,8 @@ NS_ASSUME_NONNULL_BEGIN
-(void)getRoomGameConfigSuccessWithUser:(UserInfoModel *)user gameModel:(MSTabbarRoomGameModel *)gameModel;
///开始游戏
-(void)startMatchGameSuccess;
///用户选择退出房间并重新排位
-(void)forceExitRoom;
///得到游戏详情
-(void)getRoomGameDetailsSuccessWithModel:(MSRoomGameModel *)model;
///得到金币数量

View File

@@ -11,6 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface MSTabbarRoomGameVC : MvpViewController
@property (nonatomic, copy) void(^needForceExitRoom)(void);
@end
NS_ASSUME_NONNULL_END

View File

@@ -119,6 +119,17 @@
}
- (void)forceExitRoom {
if (_needForceExitRoom) {
_needForceExitRoom();
@kWeakify(self);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
@kStrongify(self);
[self startMatchGameActionWithModel:self.chooseGameModel];
});
}
}
#pragma mark - MSRoomGameProtocol
///

View File

@@ -754,8 +754,20 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
// viewController = [[XPNewHomeViewController alloc] init];
viewController = [[XPHomePagingViewController alloc] init];
break;
case 1:
viewController = [[MSTabbarRoomGameVC alloc] init];
case 1: {
@kWeakify(self);
MSTabbarRoomGameVC *vc = [[MSTabbarRoomGameVC alloc] init];
vc.needForceExitRoom = ^{
@kStrongify(self);
if ([XPRoomMiniManager shareManager].getRoomInfo) {
[[RtcManager instance] exitRoom];
[[NIMSDK sharedSDK].chatroomManager exitChatroom:[NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId]
completion:nil];
[self.roomMineView hiddenRoomMiniView];
}
};
viewController = vc;
}
break;
case 2:
viewController = [[XPMomentsViewController alloc] init];