优化公共房间管理器的进入逻辑,新增延迟进入公共房间的功能以改善用户体验。同时,移除 RoomAnimationView 中的调试视图相关代码,提升代码整洁性和可维护性。

This commit is contained in:
edwinQQQ
2025-08-14 18:36:23 +08:00
parent edf844c1e8
commit cd4710ecf6
4 changed files with 19 additions and 117 deletions

View File

@@ -102,10 +102,8 @@
} }
// //
self.isInitialized = NO;
self.isInPublicRoom = NO; self.isInPublicRoom = NO;
self.currentPublicRoomId = nil; self.currentPublicRoomId = nil;
} }
#pragma mark - #pragma mark -
@@ -263,7 +261,9 @@
return; return;
} }
[self tryEnterPublicRoom]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self tryEnterPublicRoom];
});
} }
- (void)exitPublicRoomWithCompletion:(void(^)(NSError * _Nullable error))completion { - (void)exitPublicRoomWithCompletion:(void(^)(NSError * _Nullable error))completion {

View File

@@ -322,9 +322,6 @@ XPRoomGraffitiGiftAnimationViewDelegate
NSLog(@" - 手势: %@ (delegate: %@)", NSStringFromClass([gesture class]), gesture.delegate ? @"已设置" : @"未设置"); NSLog(@" - 手势: %@ (delegate: %@)", NSStringFromClass([gesture class]), gesture.delegate ? @"已设置" : @"未设置");
} }
//
[self addZoneDebugViews];
// bannerContainer // bannerContainer
self.bannerContainer.userInteractionEnabled = YES; self.bannerContainer.userInteractionEnabled = YES;
NSLog(@"🔧 bannerContainer用户交互已启用: %@", self.bannerContainer.userInteractionEnabled ? @"是" : @"否"); NSLog(@"🔧 bannerContainer用户交互已启用: %@", self.bannerContainer.userInteractionEnabled ? @"是" : @"否");
@@ -403,75 +400,6 @@ XPRoomGraffitiGiftAnimationViewDelegate
return BannerZoneNone; return BannerZoneNone;
} }
#pragma mark - Visual Debug (Test Environment)
- (void)addZoneDebugViews {
//
#ifdef DEBUG
NSLog(@"🎨 开始添加区域调试视图");
NSLog(@" - bannerContainer: %@ (frame: %.1f,%.1f,%.1f,%.1f)",
self.bannerContainer ? @"存在" : @"nil",
self.bannerContainer.frame.origin.x, self.bannerContainer.frame.origin.y,
self.bannerContainer.frame.size.width, self.bannerContainer.frame.size.height);
//
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// -
UIView *centerDebugView = [[UIView alloc] init];
centerDebugView.backgroundColor = [[UIColor blueColor] colorWithAlphaComponent:0.3];
centerDebugView.frame = [self getCenterZone];
centerDebugView.userInteractionEnabled = NO;
centerDebugView.tag = 999; // debugtag
[self.bannerContainer addSubview:centerDebugView];
// -
UIView *leftDebugView = [[UIView alloc] init];
leftDebugView.backgroundColor = [[UIColor redColor] colorWithAlphaComponent:0.3];
leftDebugView.frame = [self getLeftZone];
leftDebugView.userInteractionEnabled = NO;
leftDebugView.tag = 999; // debugtag
[self.bannerContainer addSubview:leftDebugView];
// - 绿
UIView *rightDebugView = [[UIView alloc] init];
rightDebugView.backgroundColor = [[UIColor greenColor] colorWithAlphaComponent:0.3];
rightDebugView.frame = [self getRightZone];
rightDebugView.userInteractionEnabled = NO;
rightDebugView.tag = 999; // debugtag
[self.bannerContainer addSubview:rightDebugView];
NSLog(@"🎨 区域调试视图已添加");
NSLog(@" - 中央区域: 蓝色 (%.1f, %.1f, %.1f, %.1f)",
centerDebugView.frame.origin.x, centerDebugView.frame.origin.y,
centerDebugView.frame.size.width, centerDebugView.frame.size.height);
NSLog(@" - 左侧区域: 红色 (%.1f, %.1f, %.1f, %.1f)",
leftDebugView.frame.origin.x, leftDebugView.frame.origin.y,
leftDebugView.frame.size.width, leftDebugView.frame.size.height);
NSLog(@" - 右侧区域: 绿色 (%.1f, %.1f, %.1f, %.1f)",
rightDebugView.frame.origin.x, rightDebugView.frame.origin.y,
rightDebugView.frame.size.width, rightDebugView.frame.size.height);
});
#endif
}
- (void)ensureDebugViewsExist {
#ifdef DEBUG
// debug
BOOL hasDebugViews = NO;
for (UIView *subview in self.bannerContainer.subviews) {
if (subview.tag == 999) {
hasDebugViews = YES;
break;
}
}
if (!hasDebugViews) {
NSLog(@"🎨 重新添加debug视图");
[self addZoneDebugViews];
}
#endif
}
#pragma mark - UIGestureRecognizerDelegate #pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
@@ -1227,7 +1155,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
return; return;
} }
#ifdef DEBUG #if 0
// DEBUGbanner // DEBUGbanner
BOOL enableBannerCopy = YES; // NO BOOL enableBannerCopy = YES; // NO
NSInteger copyCount = 10; // NSInteger copyCount = 10; //
@@ -1371,7 +1299,7 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
NSLog(@"🔄 清理了 %ld 个banner视图保留debug视图", (long)viewsToRemove.count); NSLog(@"🔄 清理了 %ld 个banner视图保留debug视图", (long)viewsToRemove.count);
// debug // debug
[self ensureDebugViewsExist]; // [self ensureDebugViewsExist];
switch (nextAttachment.second) { switch (nextAttachment.second) {
case Custom_Message_Sub_General_Floating_Screen_One_Room: case Custom_Message_Sub_General_Floating_Screen_One_Room:
@@ -1435,9 +1363,6 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break; break;
} }
} }
// debug
[self ensureDebugViewsExist];
}); });
} }
@@ -1471,9 +1396,6 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break; break;
} }
} }
// debug
[self ensureDebugViewsExist];
}); });
} }
@@ -1506,9 +1428,6 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break; break;
} }
} }
// debug
[self ensureDebugViewsExist];
}); });
} }
@@ -1546,9 +1465,6 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break; break;
} }
} }
// debug
[self ensureDebugViewsExist];
}); });
} }
@@ -1730,9 +1646,6 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break; break;
} }
} }
// debug
[self ensureDebugViewsExist];
}); });
} }
@@ -1811,9 +1724,6 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
break; break;
} }
} }
// debug
[self ensureDebugViewsExist];
}); });
} }
@@ -3165,9 +3075,6 @@ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherG
- (XPRoomAnimationHitView *)bannerContainer { - (XPRoomAnimationHitView *)bannerContainer {
if (!_bannerContainer) { if (!_bannerContainer) {
_bannerContainer = [[XPRoomAnimationHitView alloc] init]; _bannerContainer = [[XPRoomAnimationHitView alloc] init];
#if DEBUG
_bannerContainer.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
#endif
} }
return _bannerContainer; return _bannerContainer;
} }

View File

@@ -130,12 +130,12 @@ exitCurrentRoom:(void(^)(void))exit {
if (self) { if (self) {
[self setupUI]; [self setupUI];
self.userInteractionEnabled = NO; self.userInteractionEnabled = NO;
// UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom]; UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
// [self addSubview:b]; [self addSubview:b];
// [b mas_remakeConstraints:^(MASConstraintMaker *make) { [b mas_remakeConstraints:^(MASConstraintMaker *make) {
// make.edges.mas_equalTo(self); make.edges.mas_equalTo(self);
// }]; }];
// [b addTarget:self action:@selector(handelTap) forControlEvents:UIControlEventTouchUpInside]; [b addTarget:self action:@selector(handelTap) forControlEvents:UIControlEventTouchUpInside];
} }
return self; return self;
} }

View File

@@ -340,19 +340,14 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
[[IAPManager sharedManager] handleLogin]; [[IAPManager sharedManager] handleLogin];
[[IAPManager sharedManager] retryCheckAllReceipt]; [[IAPManager sharedManager] retryCheckAllReceipt];
// 1 NSLog(@"TabbarViewController: 统一入口 - 开始进入公共房间");
// @kWeakify(self); [[PublicRoomManager sharedManager] enterPublicRoomWithCompletion:^(NSError * _Nullable error) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ if (error) {
// @kStrongify(self); NSLog(@"TabbarViewController: 进入公共房间失败: %@", error);
NSLog(@"TabbarViewController: 统一入口 - 开始进入公共房间"); } else {
[[PublicRoomManager sharedManager] enterPublicRoomWithCompletion:^(NSError * _Nullable error) { NSLog(@"TabbarViewController: 进入公共房间成功");
if (error) { }
NSLog(@"TabbarViewController: 进入公共房间失败: %@", error); }];
} else {
NSLog(@"TabbarViewController: 进入公共房间成功");
}
}];
});
} }
-(void)getRoomGameInfo{ -(void)getRoomGameInfo{