删除 XPRoomMoreMenuActionTest 相关的测试文件,简化代码结构,提升项目的可维护性和清晰度。
This commit is contained in:
@@ -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(@"❌ 无法显示 toast:presentingViewController 无效或没有 showSuccessToast 方法");
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -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);
|
||||
|
||||
// 所有PK相关的Action都可以执行
|
||||
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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -12,10 +12,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@interface XPSocialAction : XPRoomMoreMenuAction
|
||||
|
||||
// 邀请粉丝
|
||||
+ (instancetype)inviteFansAction;
|
||||
//+ (instancetype)inviteFansAction;
|
||||
|
||||
// 发布广播
|
||||
+ (instancetype)releaseRadioAction;
|
||||
//+ (instancetype)releaseRadioAction;
|
||||
|
||||
// VIP小喇叭
|
||||
+ (instancetype)trumpetAction;
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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 实例
|
||||
|
@@ -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;
|
||||
|
@@ -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{
|
||||
|
@@ -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 {
|
||||
|
@@ -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
|
@@ -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
|
Reference in New Issue
Block a user