Files
peko-ios/YuMi/Modules/YMRoom/View/MoreView/Action/XPSocialAction.m

148 lines
6.1 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// XPSocialAction.m
// YUMI
//
// Created by YUMI on 2024/12/19.
//
#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 appCellBackgroundColor]; // 使用正确的标题颜色
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 appCellBackgroundColor]; // 使用正确的标题颜色
return action;
}
+ (instancetype)trumpetAction {
XPSocialAction *action = [[XPSocialAction alloc] init];
action.title = @"VIP小喇叭"; // 暂时使用硬编码,后续改为本地化
action.imageName = @"room_more_menu_trumpet"; // 使用正确的图片名称
action.type = RoomMoreMenuType_Room_trumpet;
action.isEnabled = YES;
action.titleColor = [DJDKMIMOMColor appCellBackgroundColor]; // 使用正确的标题颜色
return action;
}
+ (instancetype)reportAction {
XPSocialAction *action = [[XPSocialAction alloc] init];
action.title = @"举报房间"; // 暂时使用硬编码,后续改为本地化
action.imageName = @"room_more_menu_message"; // 暂时使用消息图标,后续添加举报图标
action.type = RoomMoreMenuType_Room_report;
action.isEnabled = YES;
action.titleColor = [DJDKMIMOMColor appCellBackgroundColor]; // 使用正确的标题颜色
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