删除 XPRoomMoreMenuActionTest 相关的测试文件,简化代码结构,提升项目的可维护性和清晰度。

This commit is contained in:
edwinQQQ
2025-09-01 19:16:48 +08:00
parent b657f3856b
commit cff4ddeeba
17 changed files with 113 additions and 850 deletions

View File

@@ -6,31 +6,25 @@
//
#import "XPGiftEffectAction.h"
#import "XPRoomMoreMenuActionContext.h"
#import "RoomInfoModel.h"
#import "BaseViewController.h"
UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
@implementation XPGiftEffectAction
+ (instancetype)openAction {
XPGiftEffectAction *action = [[XPGiftEffectAction alloc] init];
action.title = YMLocalizedString(@"XPMoreMenuPresenter5"); // 使
action.imageName = @"room_more_menu_gift_effect"; // 使
action.title = YMLocalizedString(@"XPMoreMenuPresenter5");
action.imageName = @"room_more_menu_gift_effect";
action.type = RoomMoreMenuType_Gift_Effect_Open;
action.isEnabled = YES;
action.titleColor = [DJDKMIMOMColor appCellBackgroundColor]; // 使
action.titleColor = [DJDKMIMOMColor appCellBackgroundColor];
return action;
}
+ (instancetype)closeAction {
XPGiftEffectAction *action = [[XPGiftEffectAction alloc] init];
action.title = YMLocalizedString(@"XPMoreMenuPresenter28"); // 使
action.imageName = @"room_more_menu_gift_effect"; // 使
action.title = YMLocalizedString(@"XPMoreMenuPresenter28");
action.imageName = @"room_more_menu_gift_effect";
action.type = RoomMoreMenuType_Gift_Effect_Close;
action.isEnabled = YES;
action.titleColor = [DJDKMIMOMColor appCellBackgroundColor]; // 使
action.titleColor = [DJDKMIMOMColor appCellBackgroundColor];
return action;
}
@@ -43,89 +37,5 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
}
}
- (BOOL)canExecuteWithContext:(XPRoomMoreMenuActionContext *)context {
NSLog(@"=== XPGiftEffectAction canExecuteWithContext ===");
NSLog(@"Action 标题: %@", self.title);
NSLog(@"Action isEnabled: %@", self.isEnabled ? @"YES" : @"NO");
//
BOOL canExecute = self.isEnabled;
NSLog(@"canExecuteWithContext 返回: %@", canExecute ? @"YES" : @"NO");
return canExecute;
}
- (void)executeWithContext:(XPRoomMoreMenuActionContext *)context {
NSLog(@"=== XPGiftEffectAction executeWithContext ===");
NSLog(@"Action 类型: %ld", (long)self.type);
NSLog(@"Action 标题: %@", self.title);
//
if (self.type == RoomMoreMenuType_Gift_Effect_Open) {
NSLog(@"执行开启礼物特效操作");
[self executeOpenAction];
} else if (self.type == RoomMoreMenuType_Gift_Effect_Close) {
NSLog(@"执行关闭礼物特效操作");
[self executeCloseAction];
} else {
NSLog(@"❌ 未知的 Action 类型: %ld", (long)self.type);
}
//
[self showSuccessToastWithContext:context];
//
if (context.presentingViewController && [context.presentingViewController respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) {
NSLog(@"关闭当前页面");
BaseViewController *viewController = (BaseViewController *)context.presentingViewController;
[viewController dismissViewControllerAnimated:YES completion:nil];
} else {
NSLog(@"❌ 无法关闭页面presentingViewController 无效");
}
}
#pragma mark - Private Methods
- (void)executeOpenAction {
NSLog(@"=== executeOpenAction ===");
//
NSDictionary *dic = @{@"hasAnimationEffect": @(1)};
NSLog(@"发送开启礼物特效通知: %@", dic);
[[NSNotificationCenter defaultCenter] postNotificationName:kRoomGiftEffectUpdateNotificationKey object:dic];
NSLog(@"executeOpenAction 执行完成");
}
- (void)executeCloseAction {
NSLog(@"=== executeCloseAction ===");
//
NSDictionary *dic = @{@"hasAnimationEffect": @(0)};
NSLog(@"发送关闭礼物特效通知: %@", dic);
[[NSNotificationCenter defaultCenter] postNotificationName:kRoomGiftEffectUpdateNotificationKey object:dic];
NSLog(@"executeCloseAction 执行完成");
}
- (void)showSuccessToastWithContext:(XPRoomMoreMenuActionContext *)context {
NSString *message;
if (self.type == RoomMoreMenuType_Gift_Effect_Open) {
message = YMLocalizedString(@"XPRoomMoreMenuViewController4");
} else if (self.type == RoomMoreMenuType_Gift_Effect_Close) {
message = YMLocalizedString(@"XPRoomMoreMenuViewController5");
} else {
return;
}
NSLog(@"显示成功提示: %@", message);
// context toast
if (context.presentingViewController && [context.presentingViewController respondsToSelector:@selector(showSuccessToast:)]) {
BaseViewController *viewController = (BaseViewController *)context.presentingViewController;
[viewController showSuccessToast:message];
} else {
NSLog(@"❌ 无法显示 toastpresentingViewController 无效或没有 showSuccessToast 方法");
}
}
@end

View File

@@ -6,12 +6,7 @@
//
#import "XPPKAction.h"
#import "XPRoomMoreMenuActionContext.h"
#import "RoomInfoModel.h"
#import "BaseViewController.h"
#import "XPRoomPKViewController.h"
#import "XPAcrossRoomPKViewController.h"
#import "XPAnchorPKViewController.h"
@implementation XPPKAction
@@ -129,215 +124,4 @@
return roomInfo.roomModeType == RoomModeType_Open_Blind ? [self datingCloseAction] : [self datingOpenAction];
}
#pragma mark - XPRoomMoreMenuAction
- (BOOL)canExecuteWithContext:(XPRoomMoreMenuActionContext *)context {
NSLog(@"=== XPPKAction canExecuteWithContext ===");
NSLog(@"Action 类型: %ld, 标题: %@", (long)self.type, self.title);
// PKAction
return YES;
}
- (void)executeWithContext:(XPRoomMoreMenuActionContext *)context {
NSLog(@"=== XPPKAction executeWithContext ===");
NSLog(@"Action 类型: %ld, 标题: %@", (long)self.type, self.title);
switch (self.type) {
case RoomMoreMenuType_Room_PK_Open:
[self executeRoomPKOpen:context];
break;
case RoomMoreMenuType_Room_PK_Close:
[self executeRoomPKClose:context];
break;
case RoomMoreMenuType_Room_Across_PK_Open:
[self executeAcrossRoomPKOpen:context];
break;
case RoomMoreMenuType_Room_Across_PK_Close:
[self executeAcrossRoomPKClose:context];
break;
case RoomMoreMenuType_Room_Anchor_PK_Open:
[self executeAnchorPKOpen:context];
break;
case RoomMoreMenuType_Room_Anchor_PK_Close:
[self executeAnchorPKClose:context];
break;
case RoomMoreMenuType_Room_Dating_Open:
[self executeDatingOpen:context];
break;
case RoomMoreMenuType_Room_Dating_Close:
[self executeDatingClose:context];
break;
default:
NSLog(@"❌ 未知的PK Action类型: %ld", (long)self.type);
break;
}
}
#pragma mark -
- (void)executeRoomPKOpen:(XPRoomMoreMenuActionContext *)context {
NSLog(@"执行开启同房PK模式");
//
if (context.roomInfo.roomModeType == RoomModeType_Open_Blind) {
[self showErrorToast:YMLocalizedString(@"XPRoomMoreMenuViewController20") context:context];
[self dismissViewController:context];
return;
}
if (context.roomInfo.roomModeType == RoomModeType_Open_AcrossRoomPK_mode) {
[self showErrorToast:YMLocalizedString(@"XPRoomMoreMenuViewController21") context:context];
[self dismissViewController:context];
return;
}
// PK
[self dismissViewController:context];
XPRoomPKViewController *roomPKVC = [[XPRoomPKViewController alloc] initWithDelegate:context.hostDelegate];
[context.hostDelegate.getCurrentNav pushViewController:roomPKVC animated:YES];
}
- (void)executeRoomPKClose:(XPRoomMoreMenuActionContext *)context {
NSLog(@"执行关闭同房PK模式");
// PK
[self dismissViewController:context];
XPRoomPKViewController *roomPKVC = [[XPRoomPKViewController alloc] initWithDelegate:context.hostDelegate];
[context.hostDelegate.getCurrentNav pushViewController:roomPKVC animated:YES];
}
- (void)executeAcrossRoomPKOpen:(XPRoomMoreMenuActionContext *)context {
NSLog(@"执行开启跨房PK");
//
if (context.roomInfo.roomModeType == RoomModeType_Open_Blind) {
[self showErrorToast:YMLocalizedString(@"XPRoomMoreMenuViewController13") context:context];
[self dismissViewController:context];
return;
}
if (context.roomInfo.roomModeType == RoomModeType_Open_PK_Mode) {
[self showErrorToast:YMLocalizedString(@"XPRoomMoreMenuViewController14") context:context];
[self dismissViewController:context];
return;
}
// PK
[self dismissViewController:context];
NSString *roomUid = [NSString stringWithFormat:@"%ld", context.roomInfo.uid];
XPAcrossRoomPKViewController *acrossRoomPKVC = [[XPAcrossRoomPKViewController alloc] initWithRoomUid:roomUid];
[context.hostDelegate.getCurrentNav presentViewController:acrossRoomPKVC animated:YES completion:nil];
}
- (void)executeAcrossRoomPKClose:(XPRoomMoreMenuActionContext *)context {
NSLog(@"执行关闭跨房PK");
[self showErrorToast:YMLocalizedString(@"XPRoomMoreMenuViewController15") context:context];
[self dismissViewController:context];
}
- (void)executeAnchorPKOpen:(XPRoomMoreMenuActionContext *)context {
NSLog(@"执行开启主播PK");
if (context.hostDelegate.getRoomInfo.pkMatchStartTime) {
// PK
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.message = YMLocalizedString(@"XPRoomMoreMenuViewController16");
[TTPopup alertWithConfig:config confirmHandler:^{
NSString *roomUid = [NSString stringWithFormat:@"%ld", context.roomInfo.uid];
// [context.hostDelegate requestCancelMatchRandomPK:roomUid];
} cancelHandler:^{
}];
} else {
// PK
[self dismissViewController:context];
NSString *roomUid = [NSString stringWithFormat:@"%ld", context.roomInfo.uid];
XPAnchorPKViewController *anchorPKVC = [[XPAnchorPKViewController alloc] initWithRoomUid:roomUid];
[context.hostDelegate.getCurrentNav presentViewController:anchorPKVC animated:YES completion:nil];
}
}
- (void)executeAnchorPKClose:(XPRoomMoreMenuActionContext *)context {
NSLog(@"执行关闭主播PK");
if (context.roomInfo.pkState == AcrossRoomPkStateTypePenalty) {
if ([context.roomInfo.winUid isEqualToString:[AccountInfoStorage instance].getUid]) {
//
if (context.roomInfo.roundId) {
// [context.hostDelegate requestFinishAnchorPK:[NSString stringWithFormat:@"%ld", context.roomInfo.roundId]];
}
} else if ([context.roomInfo.winUid isEqualToString:context.roomInfo.pkUid]) {
//
} else {
//
if (context.roomInfo.roundId) {
// [context.hostDelegate requestFinishAnchorPK:[NSString stringWithFormat:@"%ld", context.roomInfo.roundId]];
}
}
} else {
if (context.roomInfo.roundId) {
// [context.hostDelegdate requestFinishAnchorPK:[NSString stringWithFormat:@"%ld", context.roomInfo.roundId]];
}
}
}
- (void)executeDatingOpen:(XPRoomMoreMenuActionContext *)context {
NSLog(@"执行开启相亲模式");
//
if (context.roomInfo.roomModeType == RoomModeType_Open_AcrossRoomPK_mode) {
[self showErrorToast:YMLocalizedString(@"XPRoomMoreMenuViewController6") context:context];
[self dismissViewController:context];
return;
}
if (context.roomInfo.roomModeType == RoomModeType_Open_PK_Mode) {
[self showErrorToast:YMLocalizedString(@"XPRoomMoreMenuViewController7") context:context];
[self dismissViewController:context];
return;
}
//
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.message = YMLocalizedString(@"XPRoomMoreMenuViewController8");
config.confirmButtonConfig.title = YMLocalizedString(@"XPRoomMoreMenuViewController9");
[TTPopup alertWithConfig:config confirmHandler:^{
NSString *roomUid = [NSString stringWithFormat:@"%ld", context.roomInfo.uid];
// [context.hostDelegate openRoomDating:roomUid];
} cancelHandler:^{
}];
}
- (void)executeDatingClose:(XPRoomMoreMenuActionContext *)context {
NSLog(@"执行关闭相亲模式");
//
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.title = YMLocalizedString(@"XPRoomMoreMenuViewController10");
config.message = YMLocalizedString(@"XPRoomMoreMenuViewController11");
config.confirmButtonConfig.title = YMLocalizedString(@"XPRoomMoreMenuViewController12");
[TTPopup alertWithConfig:config confirmHandler:^{
NSString *roomUid = [NSString stringWithFormat:@"%ld", context.roomInfo.uid];
// [context.hostDelegate closeRoomDating:roomUid];
} cancelHandler:^{
}];
}
#pragma mark -
- (void)showErrorToast:(NSString *)message context:(XPRoomMoreMenuActionContext *)context {
if (context.presentingViewController && [context.presentingViewController respondsToSelector:@selector(showErrorToast:)]) {
BaseViewController *viewController = (BaseViewController *)context.presentingViewController;
[viewController showErrorToast:message];
}
}
- (void)dismissViewController:(XPRoomMoreMenuActionContext *)context {
if (context.presentingViewController && [context.presentingViewController respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) {
BaseViewController *viewController = (BaseViewController *)context.presentingViewController;
[viewController dismissViewControllerAnimated:NO completion:nil];
}
}
@end

View File

@@ -6,8 +6,6 @@
//
#import "XPRoomBackGroundSettingAction.h"
#import "CustomRoomBGContentViewController.h"
#import "RoomInfoModel.h"
@implementation XPRoomBackGroundSettingAction
@@ -16,26 +14,8 @@
action.title = YMLocalizedString(@"1.0.18_0");
action.imageName = @"room_menu_background";
action.type = RoomMoreMenuType_Room_Type_Background;
action.isEnabled = YES;
action.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor];
return action;
}
- (void)executeWithContext:(XPRoomMoreMenuActionContext *)context {
[context.presentingViewController dismissViewControllerAnimated:YES completion:nil];
// XPRoomSettingViewController *roomSettingVC = [[XPRoomSettingViewController alloc] initWithDelegate:context.hostDelegate];
// [context.hostDelegate.getCurrentNav pushViewController:roomSettingVC animated:YES];
//
CustomRoomBGContentViewController *vc = [[CustomRoomBGContentViewController alloc] init];
vc.roomInfo = context.roomInfo;
vc.roomUID = [NSString stringWithFormat:@"%ld", vc.roomInfo.uid];
vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
[context.hostDelegate.getCurrentNav presentViewController:vc
animated:YES
completion:nil];
}
@end

View File

@@ -18,19 +18,4 @@
return action;
}
- (void)executeWithContext:(XPRoomMoreMenuActionContext *)context {
[context.presentingViewController dismissViewControllerAnimated:YES completion:nil];
TTAlertConfig * config = [[TTAlertConfig alloc] init];
config.title = YMLocalizedString(@"XPRoomMoreMenuViewController17");
config.message = YMLocalizedString(@"XPRoomMoreMenuViewController18");
config.confirmButtonConfig.title = YMLocalizedString(@"TTAlertConfig0");
[TTPopup alertWithConfig:config confirmHandler:^{
// [self.presenter cleanScreen:roomUid uid:[AccountInfoStorage instance].getUid];
// TODO:
} cancelHandler:^{
}];
}
@end

View File

@@ -6,8 +6,6 @@
//
#import "XPRoomSettingAction.h"
#import "XPRoomMoreMenuActionContext.h"
#import "XPRoomSettingViewController.h"
@implementation XPRoomSettingAction
@@ -16,24 +14,8 @@
action.title = YMLocalizedString(@"XPMoreMenuPresenter21");
action.imageName = @"room_more_menu_setting";
action.type = RoomMoreMenuType_Room_Setting;
action.isEnabled = YES;
action.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor];
return action;
}
- (BOOL)canExecuteWithContext:(XPRoomMoreMenuActionContext *)context {
//
// YES
return self.isEnabled;
}
- (void)executeWithContext:(XPRoomMoreMenuActionContext *)context {
//
[context.presentingViewController dismissViewControllerAnimated:YES completion:nil];
//
XPRoomSettingViewController *roomSettingVC = [[XPRoomSettingViewController alloc] initWithDelegate:context.hostDelegate];
[context.hostDelegate.getCurrentNav pushViewController:roomSettingVC animated:YES];
}
@end

View File

@@ -6,8 +6,6 @@
//
#import "XPRoomTypeSettingAction.h"
#import "XPRoomMoreMenuActionContext.h"
#import "RoomModeViewController.h"
@implementation XPRoomTypeSettingAction
@@ -16,22 +14,8 @@
action.title = YMLocalizedString(@"XPMoreMenuPresenter25");
action.imageName = @"room_type_selection_icon";
action.type = RoomMoreMenuType_Room_Type_Setting;
action.isEnabled = YES;
action.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor];
return action;
}
- (BOOL)canExecuteWithContext:(XPRoomMoreMenuActionContext *)context {
return self.isEnabled;
}
- (void)executeWithContext:(XPRoomMoreMenuActionContext *)context {
//
[context.presentingViewController dismissViewControllerAnimated:YES completion:nil];
RoomModeViewController *vc = [[RoomModeViewController alloc] init];
vc.roomInfo = context.hostDelegate.getRoomInfo;
[context.hostDelegate.getCurrentNav pushViewController:vc animated:YES];
}
@end

View File

@@ -12,10 +12,10 @@ NS_ASSUME_NONNULL_BEGIN
@interface XPSocialAction : XPRoomMoreMenuAction
// 邀请粉丝
+ (instancetype)inviteFansAction;
//+ (instancetype)inviteFansAction;
// 发布广播
+ (instancetype)releaseRadioAction;
//+ (instancetype)releaseRadioAction;
// VIP小喇叭
+ (instancetype)trumpetAction;

View File

@@ -6,46 +6,36 @@
//
#import "XPSocialAction.h"
#import "XPRoomMoreMenuActionContext.h"
#import "XPRoomMoreItemModel.h"
#import "XPRoomInviteFansView.h"
#import "XPReleaseRadioViewController.h"
#import "XPRoomTrumpetViewController.h"
#import "XPWebViewController.h"
#import "RoomInfoModel.h"
#import "TTPopup.h"
#import "YUMIConstant.h"
@implementation XPSocialAction
#pragma mark - Factory Methods
+ (instancetype)inviteFansAction {
XPSocialAction *action = [[XPSocialAction alloc] init];
action.title = @"邀请粉丝"; // 使
action.imageName = @"room_more_menu_invite_friend"; // 使
action.type = RoomMoreMenuType_Invite_Fans;
action.isEnabled = YES;
action.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor]; // 使
return action;
}
//+ (instancetype)inviteFansAction {
// XPSocialAction *action = [[XPSocialAction alloc] init];
// action.title = @"邀请粉丝"; // 使
// action.imageName = @"room_more_menu_invite_friend"; // 使
// action.type = RoomMoreMenuType_Invite_Fans;
// action.isEnabled = YES;
// action.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor]; // 使
// return action;
//}
+ (instancetype)releaseRadioAction {
XPSocialAction *action = [[XPSocialAction alloc] init];
action.title = @"发布广播"; // 使
action.imageName = @"room_more_menu_release_radio"; // 使
action.type = RoomMoreMenuType_Release_Radio;
action.isEnabled = YES;
action.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor]; // 使
return action;
}
//+ (instancetype)releaseRadioAction {
// XPSocialAction *action = [[XPSocialAction alloc] init];
// action.title = @"发布广播"; // 使
// action.imageName = @"room_more_menu_release_radio"; // 使
// action.type = RoomMoreMenuType_Release_Radio;
// action.isEnabled = YES;
// action.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor]; // 使
// return action;
//}
+ (instancetype)trumpetAction {
XPSocialAction *action = [[XPSocialAction alloc] init];
action.title = @"VIP小喇叭"; // 使
action.title = YMLocalizedString(@"XPMoreMenuPresenter35"); // 使
action.imageName = @"room_more_menu_trumpet"; // 使
action.type = RoomMoreMenuType_Room_trumpet;
action.isEnabled = YES;
action.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor]; // 使
return action;
}
@@ -55,93 +45,9 @@
action.title = YMLocalizedString(@"XPMoreMenuPresenter36");
action.imageName = @"room_info_report";
action.type = RoomMoreMenuType_Room_report;
action.isEnabled = YES;
action.titleColor = [DJDKMIMOMColor roomMoreMenuTextColor]; // 使
return action;
}
#pragma mark - XPRoomMoreMenuAction Override
- (BOOL)canExecuteWithContext:(XPRoomMoreMenuActionContext *)context {
//
// 1.
// 2. 广
// 3. VIP
// 4.
return self.isEnabled;
}
- (void)executeWithContext:(XPRoomMoreMenuActionContext *)context {
NSString *roomUid = [NSString stringWithFormat:@"%ld", context.roomInfo.uid];
switch (self.type) {
case RoomMoreMenuType_Invite_Fans:
[self executeInviteFans:roomUid context:context];
break;
case RoomMoreMenuType_Release_Radio:
[self executeReleaseRadio:context];
break;
case RoomMoreMenuType_Room_trumpet:
[self executeTrumpet:roomUid context:context];
break;
case RoomMoreMenuType_Room_report:
[self executeReport:context];
break;
default:
break;
}
}
#pragma mark - Private Methods
- (void)executeInviteFans:(NSString *)roomUid context:(XPRoomMoreMenuActionContext *)context {
[context.presentingViewController dismissViewControllerAnimated:YES completion:nil];
XPRoomInviteFansView *inviteFansView = [[XPRoomInviteFansView alloc] initWithRoomUid:roomUid];
[TTPopup popupView:inviteFansView style:TTPopupStyleActionSheet];
}
- (void)executeReleaseRadio:(XPRoomMoreMenuActionContext *)context {
// presenter 使
// [context.presenter getRoomRadioMessageListWithType:[NSString stringWithFormat:@"%zd", context.roomInfo.type]];
// 广
[context.presentingViewController dismissViewControllerAnimated:YES completion:nil];
XPReleaseRadioViewController *releaseRadioVC = [[XPReleaseRadioViewController alloc] initWithDelegate:context.hostDelegate];
releaseRadioVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
[context.hostDelegate.getCurrentNav presentViewController:releaseRadioVC animated:YES completion:nil];
}
- (void)executeTrumpet:(NSString *)roomUid context:(XPRoomMoreMenuActionContext *)context {
// presenter 使
// [context.presenter getRoomgetUserVipRoomTrumpet:roomUid];
//
[context.presentingViewController dismissViewControllerAnimated:YES completion:nil];
XPRoomTrumpetViewController *trumpetVC = [[XPRoomTrumpetViewController alloc] initWithDelegate:context.hostDelegate];
trumpetVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
[context.hostDelegate.getCurrentNav presentViewController:trumpetVC animated:YES completion:nil];
}
- (void)executeReport:(XPRoomMoreMenuActionContext *)context {
[context.presentingViewController dismissViewControllerAnimated:YES completion:nil];
TTActionSheetConfig *action = [TTActionSheetConfig normalTitle:YMLocalizedString(@"RoomHeaderView10") clickAction:^{
// 使 TTPopup FFPopup
[TTPopup dismiss];
[context.hostDelegate requesstShieldingAction];
}];
TTActionSheetConfig *action1 = [TTActionSheetConfig normalTitle:YMLocalizedString(@"RoomHeaderView12") clickAction:^{
// 使 TTPopup FFPopup
[TTPopup dismiss];
XPWebViewController *webVC = [[XPWebViewController alloc] initWithRoomUID:@(context.roomInfo.roomId).stringValue];
NSString *urlstr = [NSString stringWithFormat:@"%@?reportUid=%ld&source=ROOM", URLWithType(kReportRoomURL), context.hostDelegate.getRoomInfo.uid];
webVC.url = urlstr;
[[context.hostDelegate getCurrentNav] pushViewController:webVC animated:YES];
}];
[TTPopup actionSheetWithItems:@[action, action1]];
}
@end

View File

@@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param context 操作上下文
* @return 操作列表
*/
+ (NSArray<XPRoomMoreMenuAction *> *)createActionsWithContext:(XPRoomMoreMenuActionContext *)context;
//+ (NSArray<XPRoomMoreMenuAction *> *)createActionsWithContext:(XPRoomMoreMenuActionContext *)context;
/// 超管直接回使用固定组合 models (trumpet, giftEffect, appManager, report)
+ (NSArray<XPRoomMoreMenuAction *> *)createSuperAdminActionsWithContext:(XPRoomMoreMenuActionContext *)context;

View File

@@ -44,63 +44,62 @@
RoomInfoModel *roomInfo = context.roomInfo;
RoomType type = roomInfo.type;
NSInteger indexOfRoomAlbum = 0;
// MARK:
// 1. PK -
if ((isCreator || isManager || isSuperAdmin) &&
type != RoomType_MiniGame &&
type != RoomType_Anchor) {
[actions addObject:[XPPKAction roomPKActionWithRoomInfo:context.roomInfo]];
indexOfRoomAlbum += 1;
type != RoomType_MiniGame && type != RoomType_Anchor) {
[actions addObject:[XPPKAction roomPKActionWithRoomInfo:roomInfo]];
}
if (isCreator && type != RoomType_MiniGame && type != RoomType_Anchor) {
[actions addObject:[XPPKAction corssPKActionWithRoomInfo:context.roomInfo]];
indexOfRoomAlbum += 1;
}
if (isOnMic) {
[actions addObject:[XPRoomMusicPanelAction action]];
indexOfRoomAlbum += 1;
[actions addObject:[XPPKAction corssPKActionWithRoomInfo:roomInfo]];
}
if (isCreator && type == RoomType_Anchor) {
[actions addObject:[XPPKAction anchorPKActionWithRoomInfo:context.roomInfo]];
indexOfRoomAlbum += 1;
[actions addObject:[XPPKAction anchorPKActionWithRoomInfo:roomInfo]];
}
// 2. -
if ((isCreator || isManager || isSuperAdmin) &&
roomInfo.canOpenBlindDate &&
type != RoomType_Anchor && type != RoomType_MiniGame) {
[actions insertObject:[XPPKAction blindActionWithRoomInfo:roomInfo] atIndex:0];
}
// 3. -
if (isOnMic) {
[actions addObject:[XPRoomMusicPanelAction action]];
}
// 4. -
if (isCreator || isManager || isSuperAdmin) {
if (roomInfo.canOpenBlindDate && type != RoomType_Anchor && type != RoomType_MiniGame) {
[actions insertObject:[XPPKAction blindActionWithRoomInfo:context.roomInfo] atIndex:0];
indexOfRoomAlbum += 1;
}
[actions addObject:[XPSocialAction trumpetAction]];
[actions addObject:[XPGiftEffectAction actionWithRoomInfo:context.roomInfo]];
[actions addObject:[XPGiftEffectAction actionWithRoomInfo:roomInfo]];
[actions addObject:[XPRoomSettingAction action]];
[actions addObject:[XPRoomBackGroundSettingAction action]];
[actions addObject:[XPRoomCleanMessagesAction action]];
indexOfRoomAlbum += 1;
} else {
[actions addObject:[XPSocialAction trumpetAction]];
[actions addObject:[XPGiftEffectAction actionWithRoomInfo:context.roomInfo]];
[actions addObject:[XPGiftEffectAction actionWithRoomInfo:roomInfo]];
}
// 5.
[actions addObject:[XPSocialAction reportAction]];
if ((isCreator || isManager || isSuperAdmin) && // &
roomInfo.isPermitRoom != PermitRoomType_License && //
roomInfo.roomModeType != RoomModeType_Open_Blind && //
type != RoomType_MiniGame && // 10/15
type != RoomType_Anchor) {
// 6.
if ((isCreator || isManager || isSuperAdmin) &&
roomInfo.isPermitRoom != PermitRoomType_License &&
roomInfo.roomModeType != RoomModeType_Open_Blind &&
type != RoomType_MiniGame && type != RoomType_Anchor) {
[actions addObject:[XPRoomTypeSettingAction action]];
}
if(roomInfo.hasRoomAlbum == YES){
[actions insertObject:[XPRoomRoomPhotoAction action] atIndex:indexOfRoomAlbum];
// 7. -
if (roomInfo.hasRoomAlbum) {
NSInteger insertIndex = [self calculateRoomAlbumInsertIndex:actions];
[actions insertObject:[XPRoomRoomPhotoAction action] atIndex:insertIndex];
}
// 8. -
if ([ClientConfig shareConfig].configInfo.redEnvelopeConfig.open && roomInfo.redEnvelopeOpen) {
[actions insertObject:[XPRoomRedPacketAction action] atIndex:1];
}
@@ -128,40 +127,19 @@
+ (NSArray<XPRoomMoreMenuAction *> *)createSuperAdminActionsWithContext:(XPRoomMoreMenuActionContext *)context {
NSMutableArray *actions = [NSMutableArray array];
// Action
// 1. -
[actions addObject:[XPGiftEffectAction actionWithRoomInfo:context.roomInfo]];
// 2. -
//
[actions addObject:[XPRoomSettingAction action]];
[actions addObject:[XPRoomTypeSettingAction action]];
[actions addObject:[XPRoomBackGroundSettingAction action]];
// 3. - 使
[actions addObject:[XPSocialAction inviteFansAction]];
[actions addObject:[XPSocialAction releaseRadioAction]];
[actions addObject:[XPSocialAction trumpetAction]];
[actions addObject:[XPGiftEffectAction actionWithRoomInfo:context.roomInfo]];
[actions addObject:[XPRoomAppManagerAction action]];
[actions addObject:[XPSocialAction reportAction]];
[actions addObject:[XPRoomRedPacketAction action]];
[actions addObject:[XPRoomMusicPanelAction action]];
// 4. PK - Action
[actions addObject:[XPPKAction roomPKActionWithRoomInfo:context.roomInfo]];
XPPKAction *crossAction = [XPPKAction corssPKActionWithRoomInfo:context.roomInfo];
if (crossAction) {
[actions addObject:crossAction];
}
XPPKAction *blindAction = [XPPKAction blindActionWithRoomInfo:context.roomInfo];
if (blindAction) {
[actions addObject:blindAction];
}
// TODO:
return actions;
}
//
+ (NSInteger)calculateRoomAlbumInsertIndex:(NSArray<XPRoomMoreMenuAction *> *)actions {
//
//
return MIN(actions.count, 3); // 3
}
@end

View File

@@ -27,12 +27,6 @@ NS_ASSUME_NONNULL_BEGIN
/// 图标名称
@property (nonatomic, copy) NSString *imageName;
/// 是否启用
@property (nonatomic, assign) BOOL isEnabled;
/// 是否选中
@property (nonatomic, assign) BOOL isSelected;
/// 操作类型
@property (nonatomic, assign) RoomMoreMenuType type;
@@ -42,19 +36,6 @@ NS_ASSUME_NONNULL_BEGIN
/// 图标颜色
@property (nonatomic, strong) UIColor *imageTintColor;
/**
* 检查是否可以执行此操作
* @param context 操作上下文
* @return 是否可以执行
*/
- (BOOL)canExecuteWithContext:(XPRoomMoreMenuActionContext *)context;
/**
* 执行操作
* @param context 操作上下文
*/
- (void)executeWithContext:(XPRoomMoreMenuActionContext *)context;
/**
* 转换为数据模型
* @return XPRoomMoreItemModel 实例

View File

@@ -6,25 +6,12 @@
//
#import "XPRoomMoreMenuAction.h"
#import "XPRoomMoreMenuActionContext.h"
@implementation XPRoomMoreMenuAction
- (BOOL)canExecuteWithContext:(XPRoomMoreMenuActionContext *)context {
//
return self.isEnabled;
}
- (void)executeWithContext:(XPRoomMoreMenuActionContext *)context {
//
NSAssert(NO, @"子类必须重写 executeWithContext: 方法");
}
- (XPRoomMoreItemModel *)toItemModel {
XPRoomMoreItemModel *model = [[XPRoomMoreItemModel alloc] init];
model.title = self.title;
model.imageName = self.imageName;
model.isSelected = self.isSelected;
model.titleColor = self.titleColor;
model.imageTintColor = self.imageTintColor;
model.type = self.type;

View File

@@ -56,58 +56,53 @@
isOnMic:(BOOL)isOnMic
isAppSuperAdmin:(BOOL)isAppSuperAdmin {
//
XPRoomMoreMenuActionContext *context = [XPRoomMoreMenuActionContext
contextWithRoomInfo:roomInfo
userInfo:nil // nil delegate
hostDelegate:nil // nil delegate
presentingViewController:nil // nil delegate
isOnMic:isOnMic
isSuperAdmin:isSuperAdmin
isAppSuperAdmin:isAppSuperAdmin];
// 使 Action
//
//#ifdef DEBUG
// // MARK: actions
// for (XPRoomMoreMenuAction *action in actions) {
// [models addObject:[action toItemModel]];
// }
// [[self getView] getMoreMenuDataSuccess:models];
// return;
//#endif
if (isAppSuperAdmin) {
NSArray<XPRoomMoreMenuAction *> *actions = [XPRoomMoreMenuActionFactory createSuperAdminActionsWithContext:context];
NSMutableArray *models = [NSMutableArray array];
for (XPRoomMoreMenuAction *action in actions) {
[models addObject:[action toItemModel]];
XPRoomMoreMenuActionContext *context = [XPRoomMoreMenuActionContext
contextWithRoomInfo:roomInfo
userInfo:nil
hostDelegate:nil
presentingViewController:nil
isOnMic:isOnMic
isSuperAdmin:isSuperAdmin
isAppSuperAdmin:isAppSuperAdmin];
if (isAppSuperAdmin) {
// 使
NSArray<XPRoomMoreMenuAction *> *actions = [XPRoomMoreMenuActionFactory createSuperAdminActionsWithContext:context];
[self convertActionsToModels:actions];
} else {
//
@kWeakify(self);
[self loadNIMMemberData:^(NSArray<NIMChatroomMember *> * _Nullable members) {
@kStrongify(self);
BOOL isCreator = NO;
BOOL isManager = NO;
if (members && members.count > 0) {
NIMChatroomMember *member = members.firstObject;
isCreator = member.type == NIMChatroomMemberTypeCreator;
isManager = member.type == NIMChatroomMemberTypeManager;
}
NSArray<XPRoomMoreMenuAction *> *actions = [XPRoomMoreMenuActionFactory
createPanelActionsWithContext:context
isCreator:isCreator
isManager:isManager
isSuperAdmin:isSuperAdmin
isOnMic:isOnMic];
[self convertActionsToModels:actions];
} withRoomInfo:roomInfo];
}
[[self getView] getMoreMenuDataSuccess:models];
} else {
@kWeakify(self);
[self loadNIMMemberData:^(NSArray<NIMChatroomMember *> * _Nullable members) {
@kStrongify(self);
NSArray<XPRoomMoreMenuAction *> *actions;
NSMutableArray *models = [NSMutableArray array];
if (members && members.count > 0) {
NIMChatroomMember * member = members.firstObject;
actions = [XPRoomMoreMenuActionFactory
createPanelActionsWithContext:context
isCreator:member.type == NIMChatroomMemberTypeCreator
isManager:member.type == NIMChatroomMemberTypeManager
isSuperAdmin:isSuperAdmin
isOnMic:isOnMic];
} else {
actions = [XPRoomMoreMenuActionFactory
createPanelActionsForNoCharRoomMembersWithContext:context];
}
for (XPRoomMoreMenuAction *action in actions) {
[models addObject:[action toItemModel]];
}
[[self getView] getMoreMenuDataSuccess:models];
} withRoomInfo:roomInfo];
}
// Action
- (void)convertActionsToModels:(NSArray<XPRoomMoreMenuAction *> *)actions {
NSMutableArray *models = [NSMutableArray array];
for (XPRoomMoreMenuAction *action in actions) {
[models addObject:[action toItemModel]];
}
[[self getView] getMoreMenuDataSuccess:models];
}
- (void)getMoreMenuDataSource:(RoomInfoModel *)roomInfo isSuperAdmin:(BOOL)isSuperAdmin isOnMic:(BOOL)isOnMic isAppSuperAdmin:(BOOL)isAppSuperAdmin{

View File

@@ -47,7 +47,6 @@
#import "RoomModeViewController.h"
#import "XPRoomMoreMenuActionTest.h"
#import "XPRoomMoreMenuActionFactory.h"
#import "XPRoomMoreMenuAction.h"
#import "XPPKAction.h"
@@ -94,9 +93,6 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
[self initSubViews];
[self initSubViewConstraints];
//
[self testNewArchitecture];
///
BOOL meIsSuperAdmin = NO;
for (GuildSuperAdminInfoModel *managerInfo in self.hostDelegate.getRoomSuperAdminList) {
@@ -116,42 +112,6 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
isAppSuperAdmin:[self.hostDelegate.getUserInfo platformRole]==1];
}
//
- (void)testNewArchitecture {
NSLog(@"=== 测试新架构实现 ===");
//
XPRoomMoreMenuActionContext *context = [XPRoomMoreMenuActionContext
contextWithRoomInfo:self.roomInfo
userInfo:self.hostDelegate.getUserInfo
hostDelegate:self.hostDelegate
presentingViewController:self
isOnMic:self.isOnMic
isSuperAdmin:NO
isAppSuperAdmin:[self.hostDelegate.getUserInfo platformRole]==1];
// Action
NSArray<XPRoomMoreMenuAction *> *actions = [XPRoomMoreMenuActionFactory
createActionsWithContext:context];
NSLog(@"工厂创建了 %lu 个 Action", (unsigned long)actions.count);
// Action
for (XPRoomMoreMenuAction *action in actions) {
NSLog(@"Action: %@, 类型: %ld", action.title, (long)action.type);
//
BOOL canExecute = [action canExecuteWithContext:context];
NSLog(@" 可以执行: %@", canExecute ? @"是" : @"否");
//
XPRoomMoreItemModel *model = [action toItemModel];
NSLog(@" 模型标题: %@", model.title);
}
NSLog(@"✅ 新架构测试完成");
}
#pragma mark - Private Method
- (void)initSubViews {
self.modalPresentationStyle = UIModalPresentationOverFullScreen;
@@ -316,76 +276,6 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
NSLog(@"=== 点击菜单项 ===");
NSLog(@"点击的菜单项: 标题=%@, 类型=%ld", item.title, (long)item.type);
[self handleItemWithLegacyLogic:item];
return;
//
XPRoomMoreMenuActionContext *context = [XPRoomMoreMenuActionContext
contextWithRoomInfo:self.roomInfo
userInfo:self.hostDelegate.getUserInfo
hostDelegate:self.hostDelegate
presentingViewController:self
isOnMic:self.isOnMic
isSuperAdmin:NO //
isAppSuperAdmin:[self.hostDelegate.getUserInfo platformRole]==1];
// Action
XPRoomMoreMenuAction *action = [self findActionForItem:item];
NSLog(@"找到的 Action: %@", action ? @"是" : @"否");
if (action) {
NSLog(@"Action 标题: %@, 类型: %ld", action.title, (long)action.type);
[self handleItemWithLegacyLogic:[action toItemModel]];
// NSLog(@"准备调用 canExecuteWithContext...");
// BOOL canExecute = [action canExecuteWithContext:context];
// NSLog(@"Action 可以执行: %@", canExecute ? @"是" : @"否");
//
// if (canExecute) {
// NSLog(@"开始执行 Action...");
// // TODO: action type VC
// [action executeWithContext:context];
// NSLog(@"Action 执行完成");
// } else {
// NSLog(@"Action 无法执行,使用 fallback 逻辑");
// [self handleItemWithLegacyLogic:item];
// }
} else {
NSLog(@"未找到 Action使用 fallback 逻辑");
// Action使 switch fallback
[self handleItemWithLegacyLogic:item];
}
}
- (XPRoomMoreMenuAction *)findActionForItem:(XPRoomMoreItemModel *)item {
//
XPRoomMoreMenuActionContext *context = [XPRoomMoreMenuActionContext
contextWithRoomInfo:self.roomInfo
userInfo:self.hostDelegate.getUserInfo
hostDelegate:self.hostDelegate
presentingViewController:self
isOnMic:self.isOnMic
isSuperAdmin:NO
isAppSuperAdmin:[self.hostDelegate.getUserInfo platformRole]==1];
// Action
NSArray<XPRoomMoreMenuAction *> *actions = [XPRoomMoreMenuActionFactory createActionsWithContext:context];
NSLog(@"=== findActionForItem 调试 ===");
NSLog(@"查找类型: %ld", (long)item.type);
NSLog(@"工厂创建了 %lu 个 Action", (unsigned long)actions.count);
// Action
for (XPRoomMoreMenuAction *action in actions) {
NSLog(@"检查 Action: 标题=%@, 类型=%ld", action.title, (long)action.type);
if (action.type == item.type) {
NSLog(@"✅ 找到匹配的 Action: %@", action.title);
return action;
}
}
NSLog(@"❌ 未找到匹配的 Action");
return nil;
}
- (void)handleItemWithLegacyLogic:(XPRoomMoreItemModel *)item {

View File

@@ -1,23 +0,0 @@
//
// XPRoomMoreMenuActionTest.h
// YuMi
//
// Created by P on 2025/8/29.
//
#import <Foundation/Foundation.h>
#import "XPRoomMoreMenuActionContext.h"
#import "XPRoomMoreMenuAction.h"
#import "XPRoomMoreMenuActionFactory.h"
#import "XPGiftEffectAction.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPRoomMoreMenuActionTest : NSObject
+ (void)testGiftEffectAction;
+ (void)testActionFactory;
@end
NS_ASSUME_NONNULL_END

View File

@@ -1,70 +0,0 @@
//
// XPRoomMoreMenuActionTest.m
// YuMi
//
// Created by Eggman on 2025/1/13.
//
#import "XPRoomMoreMenuActionTest.h"
@implementation XPRoomMoreMenuActionTest
+ (void)testGiftEffectAction {
NSLog(@"=== 测试礼物特效 Action ===");
// Action
XPGiftEffectAction *openAction = [XPGiftEffectAction openAction];
XPGiftEffectAction *closeAction = [XPGiftEffectAction closeAction];
NSLog(@"开启 Action 标题: %@", openAction.title);
NSLog(@"关闭 Action 标题: %@", closeAction.title);
NSLog(@"开启 Action 类型: %ld", (long)openAction.type);
NSLog(@"关闭 Action 类型: %ld", (long)closeAction.type);
//
XPRoomMoreItemModel *openModel = [openAction toItemModel];
XPRoomMoreItemModel *closeModel = [closeAction toItemModel];
NSLog(@"开启模型标题: %@", openModel.title);
NSLog(@"关闭模型标题: %@", closeModel.title);
NSLog(@"✅ 礼物特效 Action 测试通过");
}
+ (void)testActionFactory {
NSLog(@"=== 测试 Action 工厂 ===");
//
XPRoomMoreMenuActionContext *context = [XPRoomMoreMenuActionContext
contextWithRoomInfo:nil
userInfo:nil
hostDelegate:nil
presentingViewController:nil
isOnMic:NO
isSuperAdmin:NO
isAppSuperAdmin:NO];
// Action
NSArray<XPRoomMoreMenuAction *> *actions = [XPRoomMoreMenuActionFactory
createActionsWithContext:context];
NSLog(@"工厂创建了 %lu 个 Action", (unsigned long)actions.count);
for (XPRoomMoreMenuAction *action in actions) {
NSLog(@"Action: %@, 类型: %ld", action.title, (long)action.type);
}
NSLog(@"✅ Action 工厂测试通过");
}
+ (void)runAllTests {
NSLog(@"开始测试房间更多菜单重构实现...");
[self testGiftEffectAction];
[self testActionFactory];
NSLog(@"<22><> 所有测试完成!");
}
@end