新增布局按钮到 XPHomePagingViewController,优化顶部控制视图的交互功能。同时,更新 RoomAnimationView 中的动画管理逻辑,增加本地开关状态缓存,减少对 TurboModeStateManager 的频繁调用,提升性能和可维护性。修复 TurboModeStateManager 的初始化逻辑,确保应用启动时 Turbo 模式为关闭状态,并新增强制打开/关闭所有开关的功能。更新 XPEffectPanelViewController 以同步 Turbo 模式状态,确保 UI 显示与实际状态一致。

This commit is contained in:
edwinQQQ
2025-09-10 17:21:25 +08:00
parent d414cd1cfc
commit 58ff7805bf
9 changed files with 330 additions and 137 deletions

View File

@@ -24,6 +24,7 @@
@property (nonatomic, strong) UIView *topControlView;
@property (nonatomic, strong) UIButton *mineButton;
@property (nonatomic, strong) UIButton *recommendButton;
@property (nonatomic, strong) UIButton *layoutButton;
@property (nonatomic, strong) UIPageViewController *pageContainer;
@property (nonatomic, strong) NSArray *viewControllers; //
@@ -160,6 +161,19 @@
make.trailing.mas_equalTo(self.topControlView).offset(-16);
make.width.height.mas_equalTo(28);
}];
_layoutButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_layoutButton setImage:kImage(@"room_layout_type_1") forState:UIControlStateNormal];
[_layoutButton setImage:kImage(@"room_layout_type_2") forState:UIControlStateSelected];
[_topControlView addSubview:_layoutButton];
[_layoutButton addTarget:self
action:@selector(didTapLayoutButton)
forControlEvents:UIControlEventTouchUpInside];
[_layoutButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(searchButton);
make.trailing.mas_equalTo(searchButton.mas_leading).offset(-16);
make.width.height.mas_equalTo(28);
}];
}
- (void)displayMineTab {
@@ -201,6 +215,10 @@
completion:nil];
}
- (void)didTapLayoutButton {
self.layoutButton.selected = !self.layoutButton.isSelected;
}
#pragma mark - UIPageViewController Delegate & DataSource
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {
return nil;

View File

@@ -191,6 +191,12 @@ BannerSchedulerDelegate
// 🔧 使 TurboModeStateManager
@property (nonatomic, strong) NSString *currentRoomId; // ID
// 🔧 TurboModeStateManager
@property (nonatomic, assign) BOOL cachedGiftEffectsEnabled;
@property (nonatomic, assign) BOOL cachedGlobalGiftScreenEnabled;
@property (nonatomic, assign) BOOL cachedGlobalGameScreenEnabled;
@property (nonatomic, assign) BOOL cachedCpMicEnabled;
@end
@implementation RoomAnimationView
@@ -221,34 +227,14 @@ BannerSchedulerDelegate
NSLog(@"⚠️ 检测到重要动画正在播放,延迟清理");
//
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self forceCancelAllAnimations];
[self cancelAllAnimations];
});
return;
}
[self forceCancelAllAnimations];
[self cancelAllAnimations];
}
- (void)forceCancelAllAnimations {
NSLog(@"🔄 强制取消所有动画");
// POP
[self pop_removeAllAnimations];
// POP
NSArray *containers = @[self.bannerContainer, self.topContainer, self.middleContainer, self.bottomContainer];
for (UIView *container in containers) {
if (!container) continue;
for (UIView *subview in container.subviews) {
[subview pop_removeAllAnimations];
}
}
// UIView
[UIView setAnimationsEnabled:NO];
NSLog(@"🔄 所有动画取消完成");
}
- (void)cleanupAllSubviews {
NSLog(@"🔄 清理所有子视图");
@@ -260,12 +246,12 @@ BannerSchedulerDelegate
NSLog(@"⚠️ 检测到重要动画正在播放,延迟清理子视图");
//
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self forceCleanupAllSubviews];
[self cleanupAllSubviews];
});
return;
}
[self forceCleanupAllSubviews];
[self cleanupAllSubviews];
}
- (void)forceCleanupAllSubviews {
@@ -503,6 +489,12 @@ BannerSchedulerDelegate
name:kTurboCurrentRoomIdSet
object:nil];
// 🔧 Turbo Mode
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleTurboModeStateChanged:)
name:@"TurboModeStateChanged"
object:nil];
NSLog(@"🎮 Turbo Mode通知监听设置完成");
}
@@ -598,8 +590,8 @@ BannerSchedulerDelegate
effectPath:(NSString *)effectPath
isCPEnter:(BOOL)isCP {
// 🔧 使 TurboModeStateManager
if (![[TurboModeStateManager sharedManager] isGiftEffectsEnabledForRoom:self.currentRoomId]) {
// 🔧 使
if (!self.cachedGiftEffectsEnabled) {
NSLog(@"🎮 Turbo Mode进房特效已关闭跳过进房动画");
return;
}
@@ -728,11 +720,11 @@ BannerSchedulerDelegate
return;
}
// 🔧 使 TurboModeStateManager Banner
// 🔧 inserBannerModelToQueue
if (obj.second == Custom_Message_Sub_General_Floating_Screen_One_Room ||
obj.second == Custom_Message_Sub_General_Floating_Screen_All_Room) {
// banner
if (![[TurboModeStateManager sharedManager] isGlobalGameScreenEnabledForRoom:self.currentRoomId]) {
if (!self.cachedGlobalGameScreenEnabled) {
NSLog(@"🎮 Turbo Mode全局游戏屏幕已关闭跳过游戏banner");
return;
}
@@ -740,10 +732,18 @@ BannerSchedulerDelegate
obj.second == Custom_Message_Sub_Gift_ChannelNotify ||
obj.second == Custom_Message_Sub_LuckyPackage) {
// banner
if (![[TurboModeStateManager sharedManager] isGlobalGiftScreenEnabledForRoom:self.currentRoomId]) {
if (!self.cachedGlobalGiftScreenEnabled) {
NSLog(@"🎮 Turbo Mode全局礼物屏幕已关闭跳过礼物banner");
return;
}
} else if (obj.second == Custom_Message_Sub_CP_Gift ||
obj.second == Custom_Message_Sub_CP_Upgrade ||
obj.second == Custom_Message_Sub_CP_Binding) {
// CPbanner -
if (!self.cachedGiftEffectsEnabled) {
NSLog(@"🎮 Turbo Mode礼物特效已关闭跳过CP banner");
return;
}
}
#if 0
@@ -944,12 +944,7 @@ BannerSchedulerDelegate
}
- (void)receiveRoomGiftBanner:(AttachmentModel *)obj {
// 🔧 使 TurboModeStateManager
if (![[TurboModeStateManager sharedManager] isGlobalGiftScreenEnabledForRoom:self.currentRoomId]) {
NSLog(@"🎮 RoomAnimationView 全局礼物屏幕已关闭,跳过 RoomGiftBanner");
return;
}
// 🔧 inserBannerModelToQueue
[self inserBannerModelToQueue:obj];
}
@@ -976,12 +971,7 @@ BannerSchedulerDelegate
}
- (void)receiveCPEvent:(AttachmentModel *)attachment {
// 🔧 使 TurboModeStateManager
if (![[TurboModeStateManager sharedManager] isGiftEffectsEnabledForRoom:self.currentRoomId]) {
NSLog(@"🎮 RoomAnimationView 礼物特效已关闭跳过CP动画");
return;
}
// 🔧 inserBannerModelToQueue
[self inserBannerModelToQueue:attachment];
}
@@ -1177,12 +1167,7 @@ BannerSchedulerDelegate
}
- (void)receiveLuckGiftBanner:(AttachmentModel *)attachment {
// 🔧 使 TurboModeStateManager
if (![[TurboModeStateManager sharedManager] isGlobalGiftScreenEnabledForRoom:self.currentRoomId]) {
NSLog(@"🎮 RoomAnimationView 全局礼物屏幕已关闭,跳过 LuckyGiftWinningBanner");
return;
}
// 🔧 inserBannerModelToQueue
[self inserBannerModelToQueue:attachment];
}
@@ -1228,12 +1213,7 @@ BannerSchedulerDelegate
}
- (void)receiveGameBanner:(AttachmentModel *)attachment {
// 🔧 使 TurboModeStateManager
if (![[TurboModeStateManager sharedManager] isGlobalGameScreenEnabledForRoom:self.currentRoomId]) {
NSLog(@"🎮 RoomAnimationView 全局游戏屏幕已关闭,跳过 GameBanner");
return;
}
// 🔧 inserBannerModelToQueue
[self inserBannerModelToQueue:attachment];
}
@@ -1367,8 +1347,8 @@ BannerSchedulerDelegate
#pragma mark - Method: Send Gifts
- (void)receiveGiftHandleSendGiftAnimationWith:(GiftReceiveInfoModel *)receiveInfo attachment:(AttachmentModel *)attachment {
// 🔧 使 TurboModeStateManager
if (![[TurboModeStateManager sharedManager] isGiftEffectsEnabledForRoom:self.currentRoomId]) {
// 🔧 使
if (!self.cachedGiftEffectsEnabled) {
NSLog(@"🎮 RoomAnimationView 礼物特效已关闭,跳过动画");
return;
}
@@ -4285,6 +4265,9 @@ BannerSchedulerDelegate
- (void)handleTurboGiftEffectsChanged:(NSNotification *)notification {
BOOL enabled = [notification.userInfo[@"on"] boolValue];
// 🔧
self.cachedGiftEffectsEnabled = enabled;
//
if (!enabled) {
[self cleanupGiftEffects];
@@ -4297,6 +4280,9 @@ BannerSchedulerDelegate
- (void)handleTurboGlobalGiftScreenChanged:(NSNotification *)notification {
BOOL enabled = [notification.userInfo[@"on"] boolValue];
// 🔧
self.cachedGlobalGiftScreenEnabled = enabled;
// banner
if (!enabled) {
[self cleanupGiftBanners];
@@ -4309,6 +4295,9 @@ BannerSchedulerDelegate
- (void)handleTurboGlobalGameScreenChanged:(NSNotification *)notification {
BOOL enabled = [notification.userInfo[@"on"] boolValue];
// 🔧
self.cachedGlobalGameScreenEnabled = enabled;
// banner
if (!enabled) {
[self cleanupGameBanners];
@@ -4321,6 +4310,9 @@ BannerSchedulerDelegate
- (void)handleTurboCpMicChanged:(NSNotification *)notification {
BOOL enabled = [notification.userInfo[@"on"] boolValue];
// 🔧
self.cachedCpMicEnabled = enabled;
// CP MicMidpointRectManager
NSLog(@"🎮 RoomAnimationView CP麦位开关状态变化: %@", enabled ? @"开启" : @"关闭");
}
@@ -4333,13 +4325,79 @@ BannerSchedulerDelegate
self.currentRoomId = roomId;
//
[[TurboModeStateManager sharedManager] updateGiftEffectsForRoom:roomId
[[TurboModeStateManager sharedManager] updateGiftEffectsForRoom:roomId
enabled:self.hostDelegate.getRoomInfo.hasAnimationEffect];
// 🔧
[self updateLocalSwitchCache];
NSLog(@"🎮 RoomAnimationView: 收到房间ID设置通知房间ID: %@", roomId);
}
}
// 🔧
- (void)updateLocalSwitchCache {
if (!self.currentRoomId) return;
TurboModeStateManager *manager = [TurboModeStateManager sharedManager];
self.cachedGiftEffectsEnabled = [manager isGiftEffectsEnabledForRoom:self.currentRoomId];
self.cachedGlobalGiftScreenEnabled = [manager isGlobalGiftScreenEnabledForRoom:self.currentRoomId];
self.cachedGlobalGameScreenEnabled = [manager isGlobalGameScreenEnabledForRoom:self.currentRoomId];
self.cachedCpMicEnabled = [manager isCpMicEnabledForRoom:self.currentRoomId];
NSLog(@"🎮 RoomAnimationView: 本地开关缓存已更新 - 礼物特效:%@, 全局礼物:%@, 全局游戏:%@, CP麦位:%@",
self.cachedGiftEffectsEnabled ? @"开启" : @"关闭",
self.cachedGlobalGiftScreenEnabled ? @"开启" : @"关闭",
self.cachedGlobalGameScreenEnabled ? @"开启" : @"关闭",
self.cachedCpMicEnabled ? @"开启" : @"关闭");
}
// 🔧 Turbo Mode
- (void)handleTurboModeStateChanged:(NSNotification *)notification {
BOOL turboModeEnabled = [notification.userInfo[@"enabled"] boolValue];
if (turboModeEnabled) {
// Turbo Mode banner
[self stopAllBannersAndAnimations];
NSLog(@"🎮 RoomAnimationView: Turbo Mode 已开启,停止所有 banner 和动画");
} else {
// Turbo Mode banner
NSLog(@"🎮 RoomAnimationView: Turbo Mode 已关闭,恢复正常的 banner 和动画控制");
}
}
// 🔧 banner
- (void)stopAllBannersAndAnimations {
// banner
if (self.bannerScheduler) {
[self.bannerScheduler clearQueue];
[self.bannerScheduler pause];
}
// cleanupGiftEffects
//
for (UIView *subview in self.topContainer.subviews) {
if ([subview respondsToSelector:@selector(stopAnimation)]) {
[subview performSelector:@selector(stopAnimation)];
}
}
//
for (UIView *subview in self.middleContainer.subviews) {
if ([subview respondsToSelector:@selector(stopAnimation)]) {
[subview performSelector:@selector(stopAnimation)];
}
}
//
for (UIView *subview in self.bottomContainer.subviews) {
if ([subview respondsToSelector:@selector(stopAnimation)]) {
[subview performSelector:@selector(stopAnimation)];
}
}
}
// 🔧
- (BOOL)hasImportantAnimationPlaying {
// topContainer

View File

@@ -5,7 +5,7 @@
// Created by P on 2025/9/2.
//
#import "../Model/XPRoomMoreMenuAction.h"
#import "XPRoomMoreMenuAction.h"
NS_ASSUME_NONNULL_BEGIN

View File

@@ -5,7 +5,7 @@
// Created by Linus on 2025/1/13.
//
#import "../Model/XPRoomMoreMenuAction.h"
#import "XPRoomMoreMenuAction.h"
@class RoomInfoModel;

View File

@@ -7,14 +7,14 @@
#import "XPTurboModeAction.h"
#import "RoomInfoModel.h"
#import "../Manager/TurboModeStateManager.h"
#import "TurboModeStateManager.h"
@implementation XPTurboModeAction
+ (instancetype)openAction {
XPTurboModeAction *action = [[XPTurboModeAction alloc] init];
action.title = YMLocalizedString(@"20.20.62_text_9.1");
action.imageName = @"icon_turbo_mode";
action.imageName = @"icon_turbo_mode_on";
action.type = Room_Turbo_Mode_Open;
action.titleColor = [DJDKMIMOMColor appCellBackgroundColor];
return action;
@@ -23,7 +23,7 @@
+ (instancetype)closeAction {
XPTurboModeAction *action = [[XPTurboModeAction alloc] init];
action.title = YMLocalizedString(@"20.20.62_text_9.2");
action.imageName = @"icon_turbo_mode";
action.imageName = @"icon_turbo_mode_off";
action.type = Room_Turbo_Mode_Close;
action.titleColor = [DJDKMIMOMColor appCellBackgroundColor];
return action;

View File

@@ -47,6 +47,10 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setCurrentRoomId:(NSString *)roomId;
- (NSString *)loadCurrentRoomId;
// 🔧 新增:强制打开/关闭当前房间的所有开关(含通知与缓存更新)
- (void)forceCloseAllSwitches:(NSString *)roomId;
- (void)forceOpenAllSwitches:(NSString *)roomId;
@end
NS_ASSUME_NONNULL_END

View File

@@ -6,7 +6,7 @@
//
#import "TurboModeStateManager.h"
#import "../XPTurboModeConstants.h"
#import "XPTurboModeConstants.h"
@interface TurboModeStateManager ()
@@ -32,8 +32,9 @@
- (instancetype)init {
if (self = [super init]) {
//
self.globalTurboEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"TurboMode_Global"];
// 🔧 2appturbo mode
// turbo mode
self.globalTurboEnabled = NO;
self.roomSwitchStates = [NSMutableDictionary dictionary];
self.currentUserId = nil;
}
@@ -267,14 +268,26 @@
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
//
// 🔧 roomSwitchStates
[self ensureRoomSwitchStatesExist:roomId];
NSMutableDictionary *roomStates = [self.roomSwitchStates[roomId] mutableCopy];
//
roomStates[@"giftEffects"] = @(NO);
//
roomStates[@"globalGiftScreen"] = @(NO);
[defaults setBool:NO forKey:kTurboGlobalGiftScreenEnabledKey(roomId)];
//
roomStates[@"globalGameScreen"] = @(NO);
[defaults setBool:NO forKey:kTurboGlobalGameScreenEnabledKey(roomId)];
// CP
roomStates[@"cpMic"] = @(NO);
[defaults setBool:NO forKey:kTurboCpMicEnabledKey(roomId)];
self.roomSwitchStates[roomId] = roomStates;
[defaults synchronize];
//
@@ -283,25 +296,33 @@
- (void)forceOpenAllSwitches:(NSString *)roomId {
if (!roomId) return;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
//
//
// 🔧 roomSwitchStates
[self ensureRoomSwitchStatesExist:roomId];
NSMutableDictionary *roomStates = [self.roomSwitchStates[roomId] mutableCopy];
//
roomStates[@"giftEffects"] = @(YES);
//
roomStates[@"globalGiftScreen"] = @(YES);
[defaults setBool:YES forKey:kTurboGlobalGiftScreenEnabledKey(roomId)];
//
roomStates[@"globalGameScreen"] = @(YES);
[defaults setBool:YES forKey:kTurboGlobalGameScreenEnabledKey(roomId)];
// CP
roomStates[@"cpMic"] = @(YES);
[defaults setBool:YES forKey:kTurboCpMicEnabledKey(roomId)];
self.roomSwitchStates[roomId] = roomStates;
[defaults synchronize];
//
[[NSNotificationCenter defaultCenter]
postNotificationName:kTurboGiftEffectsEnabledChanged
object:nil
userInfo:@{ @"on": @(YES), @"roomId": roomId }];
[[NSNotificationCenter defaultCenter]
postNotificationName:kTurboGlobalGiftScreenEnabledChanged
object:nil
userInfo:@{ @"on": @(YES), @"roomId": roomId }];
[[NSNotificationCenter defaultCenter]
postNotificationName:kTurboGlobalGameScreenEnabledChanged
object:nil
userInfo:@{ @"on": @(YES), @"roomId": roomId }];
//
[self sendSwitchStateChangeNotificationsForOpen:roomId];
}
- (void)sendSwitchStateChangeNotifications:(NSString *)roomId {
@@ -322,6 +343,38 @@
postNotificationName:kTurboGlobalGameScreenEnabledChanged
object:nil
userInfo:@{@"on": @(NO), @"roomId": roomId}];
// CP
[[NSNotificationCenter defaultCenter]
postNotificationName:kTurboCpMicEnabledChanged
object:nil
userInfo:@{@"on": @(NO), @"roomId": roomId}];
}
- (void)sendSwitchStateChangeNotificationsForOpen:(NSString *)roomId {
//
[[NSNotificationCenter defaultCenter]
postNotificationName:kTurboGiftEffectsEnabledChanged
object:nil
userInfo:@{@"on": @(YES), @"roomId": roomId}];
//
[[NSNotificationCenter defaultCenter]
postNotificationName:kTurboGlobalGiftScreenEnabledChanged
object:nil
userInfo:@{@"on": @(YES), @"roomId": roomId}];
//
[[NSNotificationCenter defaultCenter]
postNotificationName:kTurboGlobalGameScreenEnabledChanged
object:nil
userInfo:@{@"on": @(YES), @"roomId": roomId}];
// CP
[[NSNotificationCenter defaultCenter]
postNotificationName:kTurboCpMicEnabledChanged
object:nil
userInfo:@{@"on": @(YES), @"roomId": roomId}];
}
- (void)loadTurboModeStatesFromCache {
@@ -395,15 +448,16 @@
_currentRoomId = roomId;
//
// 🔧 1turbo mode
[self ensureRoomSwitchStatesExist:roomId];
[self applyTurboModeToSwitchesForRoom:roomId];
// ID
[[NSNotificationCenter defaultCenter] postNotificationName:kTurboCurrentRoomIdSet
object:nil
userInfo:@{@"roomId": roomId}];
NSLog(@"🎮 TurboModeStateManager: 设置当前房间ID: %@", roomId);
NSLog(@"🎮 TurboModeStateManager: 设置当前房间ID: %@已应用turbo mode影响", roomId);
}
// 🔧 ID

View File

@@ -35,6 +35,7 @@
[super viewDidLoad];
[self setupUI];
[self setupSwitchStates];
[self setupNotifications];
}
- (void)setupUI {
@@ -173,13 +174,11 @@
NSString *roomId = @(self.roomInfo.roomId).stringValue;
self.roomId = roomId;
// 🔧 使 TurboModeStateManager
// 🔧
// RoomAnimationView
TurboModeStateManager *manager = [TurboModeStateManager sharedManager];
//
[manager updateGiftEffectsForRoom:roomId enabled:self.roomInfo.hasAnimationEffect];
//
// updateGiftEffectsForRoom
BOOL giftEffectsEnabled = [manager isGiftEffectsEnabledForRoom:roomId];
BOOL globalGiftScreenEnabled = [manager isGlobalGiftScreenEnabledForRoom:roomId];
BOOL globalGameScreenEnabled = [manager isGlobalGameScreenEnabledForRoom:roomId];
@@ -346,4 +345,113 @@
NSLog(@"🎮 显示 Toast: %@", message);
}
#pragma mark - Notifications
- (void)setupNotifications {
// Turbo Mode
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleTurboModeStateChanged:)
name:@"TurboModeStateChanged"
object:nil];
//
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleGiftEffectsChanged:)
name:kTurboGiftEffectsEnabledChanged
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleGlobalGiftScreenChanged:)
name:kTurboGlobalGiftScreenEnabledChanged
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleGlobalGameScreenChanged:)
name:kTurboGlobalGameScreenEnabledChanged
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleCpMicChanged:)
name:kTurboCpMicEnabledChanged
object:nil];
}
- (void)handleTurboModeStateChanged:(NSNotification *)notification {
BOOL turboModeEnabled = [notification.userInfo[@"enabled"] boolValue];
// 🔧 3TurboModeStateManagerXPEffectPanelViewController
TurboModeStateManager *manager = [TurboModeStateManager sharedManager];
if (turboModeEnabled) {
// Turbo Mode
[manager forceCloseAllSwitches:self.roomId];
[self updateSwitchesUIForTurboMode:YES];
NSLog(@"🎮 Turbo Mode 已开启,所有开关已强制关闭");
} else {
// Turbo Mode
[manager forceOpenAllSwitches:self.roomId];
[self updateSwitchesUIForTurboMode:NO];
NSLog(@"🎮 Turbo Mode 已关闭,所有开关已强制打开");
}
}
- (void)updateSwitchesUIForTurboMode:(BOOL)turboModeEnabled {
if (turboModeEnabled) {
// 🔧 Turbo Mode
// UIforceCloseAllSwitches
self.giftEffectsSwitch.on = NO;
self.globalGiftScreenSwitch.on = NO;
self.globalGameScreenSwitch.on = NO;
self.cpMicSwitch.on = NO;
} else {
// 🔧 Turbo Mode
// forceOpenAllSwitches handleXxxChanged UI
NSLog(@"🎮 Turbo Mode 已关闭等待开关状态变化通知更新UI");
}
}
- (void)handleGiftEffectsChanged:(NSNotification *)notification {
BOOL enabled = [notification.userInfo[@"on"] boolValue];
NSString *roomId = notification.userInfo[@"roomId"];
if ([roomId isEqualToString:self.roomId]) {
self.giftEffectsSwitch.on = enabled;
NSLog(@"🎮 礼物特效开关状态已更新: %@", enabled ? @"开启" : @"关闭");
}
}
- (void)handleGlobalGiftScreenChanged:(NSNotification *)notification {
BOOL enabled = [notification.userInfo[@"on"] boolValue];
NSString *roomId = notification.userInfo[@"roomId"];
if ([roomId isEqualToString:self.roomId]) {
self.globalGiftScreenSwitch.on = enabled;
NSLog(@"🎮 全局礼物屏幕开关状态已更新: %@", enabled ? @"开启" : @"关闭");
}
}
- (void)handleGlobalGameScreenChanged:(NSNotification *)notification {
BOOL enabled = [notification.userInfo[@"on"] boolValue];
NSString *roomId = notification.userInfo[@"roomId"];
if ([roomId isEqualToString:self.roomId]) {
self.globalGameScreenSwitch.on = enabled;
NSLog(@"🎮 全局游戏屏幕开关状态已更新: %@", enabled ? @"开启" : @"关闭");
}
}
- (void)handleCpMicChanged:(NSNotification *)notification {
BOOL enabled = [notification.userInfo[@"on"] boolValue];
NSString *roomId = notification.userInfo[@"roomId"];
if ([roomId isEqualToString:self.roomId]) {
self.cpMicSwitch.on = enabled;
NSLog(@"🎮 CP麦位开关状态已更新: %@", enabled ? @"开启" : @"关闭");
}
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end

View File

@@ -56,7 +56,7 @@
#import "XPEffectPanelViewController.h"
#import "XPTurboModeConstants.h"
#import "XPRoomSettingPresenter.h"
#import "../Manager/TurboModeStateManager.h"
#import "TurboModeStateManager.h"
UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
@@ -88,31 +88,6 @@ extern NSString *const kTurboModeButtonStateChanged;
@implementation XPRoomMoreMenuViewController
// 🔧 Turbo_Mode
- (void)setupTurboModeButton {
self.turboModeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.turboModeButton setTitle:YMLocalizedString(@"20.20.62_text_9") forState:UIControlStateNormal];
[self.turboModeButton setImage:[UIImage imageNamed:@"icon_turbo_mode"] forState:UIControlStateNormal];
[self.turboModeButton addTarget:self action:@selector(turboModeButtonTapped) forControlEvents:UIControlEventTouchUpInside];
//
self.turboModeButton.backgroundColor = [UIColor colorWithWhite:0.1 alpha:0.8];
self.turboModeButton.layer.cornerRadius = 8;
self.turboModeButton.titleLabel.font = [UIFont systemFontOfSize:14];
[self.view addSubview:self.turboModeButton];
// - 使 Masonry
[self.turboModeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.topView.mas_bottom).offset(20);
make.centerX.mas_equalTo(self.view);
make.width.mas_equalTo(120);
make.height.mas_equalTo(40);
}];
//
[self updateTurboModeButtonStateOnRoomEnter];
}
// 🔧 Turbo Mode
- (void)setupTurboModeNotifications {
@@ -152,33 +127,10 @@ extern NSString *const kTurboModeButtonStateChanged;
completion:nil];
}
// 🔧
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self updateTurboModeButtonStateOnRoomEnter];
}
- (void)updateTurboModeButtonStateOnRoomEnter {
NSString *roomId = @(self.roomInfo.roomId).stringValue;
// 🔧 使 TurboModeStateManager
TurboModeStateManager *manager = [TurboModeStateManager sharedManager];
//
[manager updateGiftEffectsForRoom:roomId enabled:self.roomInfo.hasAnimationEffect];
//
BOOL giftEffectsEnabled = [manager isGiftEffectsEnabledForRoom:roomId];
BOOL globalGiftScreenEnabled = [manager isGlobalGiftScreenEnabledForRoom:roomId];
BOOL globalGameScreenEnabled = [manager isGlobalGameScreenEnabledForRoom:roomId];
BOOL cpMicEnabled = [manager isCpMicEnabledForRoom:roomId];
BOOL allOn = giftEffectsEnabled && globalGiftScreenEnabled && globalGameScreenEnabled && cpMicEnabled;
[self updateTurboModeButtonState:allOn];
}
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate isUserOnMic:(BOOL)isOnMic {
if (self = [super init]) {
self.modalPresentationStyle = UIModalPresentationOverFullScreen;
@@ -196,7 +148,6 @@ extern NSString *const kTurboModeButtonStateChanged;
- (void)viewDidLoad {
[super viewDidLoad];
[self initSubViews];
// [self setupTurboModeButton];
[self setupTurboModeNotifications];
[self initSubViewConstraints];