feat: 重构房间右下菜单栏
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// RoomSideMenu.h
|
||||
// YuMi
|
||||
//
|
||||
// Created by P on 2024/12/20.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "RoomInfoModel.h"
|
||||
#import "BoomInfoModel.h"
|
||||
#import "RoomHostDelegate.h"
|
||||
#import "XPRedPacketModel.h"
|
||||
#import "RoomGuestDelegate.h"
|
||||
#import "ActivityInfoModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface RoomSideMenu : UIView<RoomGuestDelegate>
|
||||
|
||||
@property (nonatomic, copy) void(^openRedPacketHandle)(XPRedPacketModel * _Nullable redModel, RoomType type, BOOL checkList);
|
||||
@property (nonatomic, copy) void(^showSendGiftView)(void);
|
||||
@property (nonatomic, strong) NSMutableArray *redPacketList;
|
||||
@property (nonatomic, strong) NSMutableArray *playList;
|
||||
@property (nonatomic, strong) NSMutableArray *littleGameList;
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate;
|
||||
- (void)updateView;
|
||||
- (void)updateForBoomDetailArray:(NSArray <BoomDetailModel*> *)models;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
704
YuMi/Modules/YMRoom/View/ActivityContainerView/RoomSideMenu.m
Normal file
704
YuMi/Modules/YMRoom/View/ActivityContainerView/RoomSideMenu.m
Normal file
@@ -0,0 +1,704 @@
|
||||
//
|
||||
// RoomSideMenu.m
|
||||
// YuMi
|
||||
//
|
||||
// Created by P on 2024/12/20.
|
||||
//
|
||||
|
||||
#import "RoomSideMenu.h"
|
||||
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
#import <ReactiveObjC/ReactiveObjC.h>
|
||||
#import <SDCycleScrollView/SDCycleScrollView.h>
|
||||
|
||||
#import "Api+Room.h"
|
||||
#import "Api+LittleGame.h"
|
||||
#import "Api+TreasureFairy.h"
|
||||
|
||||
#import "RoomBoomManager.h"
|
||||
#import "RoomBoomEntryView.h"
|
||||
#import "LittleGameInfoModel.h"
|
||||
|
||||
#import "MSRoomGameWebVC.h"
|
||||
#import "MSRoomMenuGameVC.h"
|
||||
#import "XPRoomAnimationView.h"
|
||||
#import "XPWebViewController.h"
|
||||
#import "XPRoomViewController.h"
|
||||
#import "BoomInfoViewController.h"
|
||||
#import "XPSailingViewController.h"
|
||||
#import "XCCurrentVCStackManager.h"
|
||||
#import "XPCandyTreeViewController.h"
|
||||
#import "XPArrangeMicViewController.h"
|
||||
|
||||
UIKIT_EXTERN NSString *kShowFirstRechargeView;
|
||||
|
||||
@interface RoomSideMenu ()<UITableViewDelegate, UITableViewDataSource, SDCycleScrollViewDelegate>
|
||||
|
||||
@property(nonatomic, strong) NSMutableArray *menuItemViews;
|
||||
@property (nonatomic, strong) RACSubject *menuItemViewsSubject; // 数据源信号
|
||||
|
||||
///游戏菜单按钮
|
||||
@property(nonatomic, strong) UIButton *gambleMenuButton;
|
||||
/// 配置的入口,逻辑由 API 返回数据决定
|
||||
@property(nonatomic, strong) UIButton *configEntranceMenuButton;
|
||||
@property(nonatomic, strong) UIButton *pkMenuButton;
|
||||
@property (nonatomic,strong) UIImageView *joinView;
|
||||
|
||||
@property (nonatomic, strong) UITableView *tableView;
|
||||
@property(nonatomic, strong) UIScrollView *scrollView;
|
||||
@property (nonatomic,strong) SDCycleScrollView *cycleScrollView;
|
||||
@property (nonatomic, weak) id<RoomHostDelegate> hostDelegate;
|
||||
@property (nonatomic, strong) NSMutableArray<ActivityInfoModel *> *activityList;
|
||||
@property (nonatomic, assign) BOOL isLoadActivity;
|
||||
|
||||
@property (nonatomic, strong) RoomBoomEntryView *boomView;
|
||||
@property (nonatomic, copy) NSArray <BoomDetailModel *> *boomModels;
|
||||
|
||||
@property (nonatomic, strong) NetImageView *loader_url_1;
|
||||
@property (nonatomic, strong) NetImageView *loader_url_2;
|
||||
|
||||
@end
|
||||
|
||||
// TODO: 补充红包视图 | 调整顺序 | 调整大小 | 支持收起展开
|
||||
|
||||
@implementation RoomSideMenu
|
||||
|
||||
- (void)dealloc {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[[RoomBoomManager sharedManager] removeEventListenerForTarget:self];
|
||||
}
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
#if DEBUG
|
||||
self.backgroundColor = [UIColor orangeColor];
|
||||
#endif
|
||||
self.menuItemViews = @[].mutableCopy;
|
||||
self.menuItemViewsSubject = [RACSubject subject];
|
||||
self.hostDelegate = delegate;
|
||||
[self setupViews];
|
||||
[self setupBoomManager];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Setup
|
||||
- (void)setupViews {
|
||||
[self addSubview:self.cycleScrollView];
|
||||
[self addSubview:self.scrollView];
|
||||
|
||||
[self.cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.leading.trailing.equalTo(self);
|
||||
make.height.mas_equalTo(self.cycleScrollView.mas_width);
|
||||
}];
|
||||
|
||||
[self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.cycleScrollView.mas_bottom);
|
||||
make.leading.trailing.bottom.equalTo(self);
|
||||
}];
|
||||
|
||||
@kWeakify(self);
|
||||
[self.menuItemViewsSubject subscribeNext:^(NSArray * _Nullable x) {
|
||||
@kStrongify(self);
|
||||
[self updateScrollView: x];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setupBoomManager {
|
||||
@kWeakify(self);
|
||||
[[RoomBoomManager sharedManager] registerBoomProgressUpdate:^(id _Nonnull sth) {
|
||||
@kStrongify(self);
|
||||
if ([sth isKindOfClass:[BoomDetailModel class]]) {
|
||||
self.boomView.boomModel = (BoomDetailModel *)sth;
|
||||
}
|
||||
} target:self];
|
||||
}
|
||||
|
||||
- (void)updateMenuItem:(UIView *)itemView isRemove:(BOOL)isRemove {
|
||||
if (isRemove) {
|
||||
if ([self.menuItemViews containsObject:itemView]) {
|
||||
[self.menuItemViews removeObject:itemView];
|
||||
}
|
||||
} else {
|
||||
if ([self.menuItemViews containsObject:itemView]) {
|
||||
return;
|
||||
}
|
||||
[self.menuItemViews addObject:itemView];
|
||||
}
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self.menuItemViewsSubject sendNext:self.menuItemViews];
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - Methods
|
||||
- (void)updateView {
|
||||
if (self.isLoadActivity) {
|
||||
[self configLittleGameActivity];
|
||||
} else {
|
||||
[self requestActivityList];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateForBoomDetailArray:(NSArray <BoomDetailModel*> *)models {
|
||||
_boomModels = models;
|
||||
if (!models || models.count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL hasBoom = NO;
|
||||
for (BoomDetailModel *boom in models) {
|
||||
if (boom.currLevel == 1) {
|
||||
hasBoom = YES;
|
||||
self.boomView.boomModel = boom;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasBoom) {
|
||||
// 处理到顶级后可能找不到数据的异常
|
||||
self.boomView.boomModel = [models lastObject];
|
||||
}
|
||||
|
||||
[self updateMenuItem:self.boomView isRemove:NO];
|
||||
}
|
||||
|
||||
- (void)updateScrollView:(NSArray *)data {
|
||||
// 清空当前 scrollView 的 subviews
|
||||
[self.scrollView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
||||
|
||||
// 设置 contentSize
|
||||
CGFloat width = self.scrollView.bounds.size.width;
|
||||
self.scrollView.contentSize = CGSizeMake(self.scrollView.bounds.size.width,
|
||||
MAX(self.scrollView.bounds.size.height, width * data.count));
|
||||
|
||||
// 动态添加 subviews
|
||||
CGFloat yOffset = self.scrollView.contentSize.height; // 从底部开始布局
|
||||
for (UIView *view in data) {
|
||||
[self.scrollView addSubview:view];
|
||||
yOffset -= width;
|
||||
view.frame = CGRectMake(0, yOffset, width, width);
|
||||
}
|
||||
|
||||
// 滚动到底部
|
||||
if (self.scrollView.contentSize.height > self.scrollView.bounds.size.height) {
|
||||
[self.scrollView setContentOffset:CGPointMake(0, self.scrollView.contentSize.height - self.scrollView.bounds.size.height)
|
||||
animated:NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)configLittleGameActivity {
|
||||
[self updateCycleView];
|
||||
}
|
||||
|
||||
- (void)requestActivityList {
|
||||
RACSubject* playRAC = [RACSubject subject];
|
||||
RACSubject* activityRAC = [RACSubject subject];
|
||||
RACSubject* littleGameRAC = [RACSubject subject];
|
||||
|
||||
@kWeakify(self);
|
||||
[[RACSignal combineLatest:@[playRAC,
|
||||
activityRAC,
|
||||
littleGameRAC]
|
||||
reduce:^id(NSArray<ActivityInfoModel*> *playModels,
|
||||
NSArray <ActivityInfoModel *>*activityModels,
|
||||
NSArray<LittleGameInfoModel*> *littleGameModels){
|
||||
@kStrongify(self);
|
||||
self.playList = [NSMutableArray arrayWithArray:playModels];
|
||||
self.activityList = [NSMutableArray arrayWithArray:activityModels];
|
||||
self.littleGameList = [NSMutableArray arrayWithArray:littleGameModels];
|
||||
|
||||
[self dealWithData];
|
||||
|
||||
[self onRoomUpdate];
|
||||
return nil;
|
||||
}] subscribeError:^(NSError * _Nullable error) {
|
||||
[XNDJTDDLoadingTool showErrorWithMessage:error.domain];
|
||||
}];
|
||||
|
||||
[self loadGames:playRAC];
|
||||
[self loadActivities:activityRAC];
|
||||
[self loadLittleGames:littleGameRAC];
|
||||
}
|
||||
|
||||
- (void)loadGames:(RACSubject *)racSubject {
|
||||
RoomInfoModel *roomInfo = self.hostDelegate.getRoomInfo;
|
||||
NSString * roomId = [NSString stringWithFormat:@"%ld", roomInfo.uid];
|
||||
[Api getPlayList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (code == 200) {
|
||||
NSArray <ActivityInfoModel *>* array = [ActivityInfoModel modelsWithArray:data.data];
|
||||
[racSubject sendNext:array];
|
||||
[racSubject sendCompleted];
|
||||
} else {
|
||||
[racSubject sendError:[NSError errorWithDomain:msg code:code userInfo:nil]];
|
||||
}
|
||||
} roomId:roomId];
|
||||
}
|
||||
|
||||
- (void)loadActivities:(RACSubject *)racSubject {
|
||||
RoomInfoModel *roomInfo = self.hostDelegate.getRoomInfo;
|
||||
NSString * roomId = [NSString stringWithFormat:@"%ld", roomInfo.uid];
|
||||
[Api roomActivityList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (code == 200) {
|
||||
NSArray <ActivityInfoModel *>* array = [ActivityInfoModel modelsWithArray:data.data];
|
||||
[racSubject sendNext:array];
|
||||
[racSubject sendCompleted];
|
||||
} else {
|
||||
[racSubject sendError:[NSError errorWithDomain:msg code:code userInfo:nil]];
|
||||
}
|
||||
} roomId:roomId];
|
||||
}
|
||||
|
||||
- (void)loadLittleGames:(RACSubject *)racSubject {
|
||||
RoomInfoModel *roomInfo = self.hostDelegate.getRoomInfo;
|
||||
NSString * roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
|
||||
[Api getLittleGameList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (code == 200) {
|
||||
NSArray * array = [LittleGameInfoModel modelsWithArray:data.data];
|
||||
[racSubject sendNext:array];
|
||||
[racSubject sendCompleted];
|
||||
} else {
|
||||
[racSubject sendError:[NSError errorWithDomain:msg code:code userInfo:nil]];
|
||||
}
|
||||
}
|
||||
roomUid:roomUid];
|
||||
}
|
||||
|
||||
-(void)dealWithData{
|
||||
self.isLoadActivity = YES;
|
||||
self.cycleScrollView.hidden = NO;
|
||||
|
||||
if (self.playList.count > 0 || self.littleGameList.count >0) {
|
||||
[self updateMenuItem:self.gambleMenuButton isRemove:NO];
|
||||
}
|
||||
|
||||
if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) {
|
||||
[self configLittleGameActivity];
|
||||
} else {
|
||||
[self updateCycleView];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateConfigEntranceButtons:(RoomInfoModel *)roomInfo {
|
||||
RoomBottomEntranceModel *model = roomInfo.rightBottomIconConfig;
|
||||
if (!model) {
|
||||
return;
|
||||
}
|
||||
|
||||
@kWeakify(self);
|
||||
if (![NSString isEmpty:model.icon2Url]) {
|
||||
[self.loader_url_2 loadImageWithUrl:model.icon2Url
|
||||
completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
|
||||
@kStrongify(self);
|
||||
[self.gambleMenuButton setImage:image
|
||||
forState:UIControlStateNormal];
|
||||
}];
|
||||
}
|
||||
|
||||
if (![NSString isEmpty:model.icon1Url]) {
|
||||
[self.loader_url_1 loadImageWithUrl:model.icon1Url
|
||||
completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
|
||||
@kStrongify(self);
|
||||
[self.configEntranceMenuButton setImage:image
|
||||
forState:UIControlStateNormal];
|
||||
[self updateMenuItem:self.configEntranceMenuButton isRemove:NO];
|
||||
}];
|
||||
} else {
|
||||
if (_configEntranceMenuButton) {
|
||||
[self updateMenuItem:self.configEntranceMenuButton isRemove:YES];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateCycleView {
|
||||
NSMutableArray *picArray = [NSMutableArray array];
|
||||
for (ActivityInfoModel *model in self.activityList) {
|
||||
[picArray addObject:model.icon ?: @""];
|
||||
}
|
||||
|
||||
self.cycleScrollView.imageURLStringsGroup = picArray;
|
||||
if (picArray.count > 1) {
|
||||
[self.cycleScrollView setAutoScroll:YES];
|
||||
self.cycleScrollView.autoScrollTimeInterval = 3;
|
||||
} else {
|
||||
[self.cycleScrollView setAutoScroll:NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)openURL:(NSString *)urlString {
|
||||
RoomInfoModel *roomInfo = self.hostDelegate.getRoomInfo;
|
||||
XPWebViewController *vc = [[XPWebViewController alloc] initWithRoomUID:@(roomInfo.uid).stringValue];
|
||||
vc.url = urlString;
|
||||
[self.hostDelegate.getCurrentNav pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
- (void)openBaiShunGame:(RoomBottomEntranceModel *)model {
|
||||
if ([self.hostDelegate isKindOfClass:[XPRoomViewController class]]){
|
||||
ActivityInfoModel *activityModel = [[ActivityInfoModel alloc] init];
|
||||
activityModel.skipContent = model.skipUrl;
|
||||
activityModel.skipType = ActivitySkipType_Web;
|
||||
activityModel.showType = 1;
|
||||
activityModel.code = @"BAISHUN";
|
||||
activityModel.ruleValue = model.reserve;
|
||||
if (activityModel.gameModel) {
|
||||
MSRoomGameWebVC *vc = [[MSRoomGameWebVC alloc] initWithDelegate:self.hostDelegate
|
||||
gameModel:activityModel];
|
||||
vc.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
|
||||
XPRoomViewController *roomVC = (XPRoomViewController *)self.hostDelegate;
|
||||
[roomVC addChildViewController:vc];
|
||||
XPRoomAnimationView *animationView;
|
||||
for (id obj in self.hostDelegate.getSuperView.subviews) {
|
||||
if ([obj isKindOfClass:[XPRoomAnimationView class]]){
|
||||
animationView = obj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
[self.hostDelegate.getSuperView addSubview:vc.view];
|
||||
vc.view.tag = 913;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - User Response
|
||||
- (void)displayBoomInfoProgress {
|
||||
BoomInfoViewController *vc = [[BoomInfoViewController alloc] init];
|
||||
vc.roomUid = self.hostDelegate.getRoomInfo.uid;
|
||||
vc.partitionId = self.hostDelegate.getUserInfo.partitionId;
|
||||
vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
||||
[self.hostDelegate.getCurrentNav presentViewController:vc animated:YES completion:nil];
|
||||
|
||||
@kWeakify(self);
|
||||
[vc setShowGiftPanel:^{
|
||||
@kStrongify(self);
|
||||
if (self.showSendGiftView) {
|
||||
self.showSendGiftView();
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)didTapGameMenuButton {
|
||||
MSRoomMenuGameVC *vc = [[MSRoomMenuGameVC alloc] initWithDelegate:self.hostDelegate roomMenuType:MSRoomMenuTypeGame];
|
||||
vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
||||
[self.hostDelegate.getCurrentNav presentViewController:vc animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)didTapConfigEntranceButton {
|
||||
RoomInfoModel *roomInfo = self.hostDelegate.getRoomInfo;
|
||||
RoomBottomEntranceModel *model = roomInfo.rightBottomIconConfig;
|
||||
|
||||
if (!model || model.skipUrl.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (model.skipType) {
|
||||
case 1:
|
||||
[self openURL:model.skipUrl];
|
||||
break;
|
||||
case 2:
|
||||
[self openBaiShunGame:model];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didTapPKMenuButton {
|
||||
[self.hostDelegate showPKPanel];
|
||||
}
|
||||
|
||||
- (void)didTapJoinDatingRecognizer {
|
||||
if (self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_PK_Mode && self.hostDelegate.isRoomPKPlaying) {
|
||||
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPRoomActivityContainerView2")];
|
||||
return;
|
||||
}
|
||||
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
|
||||
request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
|
||||
request.userIds = @[[AccountInfoStorage instance].getUid];
|
||||
@kWeakify(self);
|
||||
[[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
|
||||
@kStrongify(self);
|
||||
NIMChatroomMember * member;
|
||||
if (error == nil) {
|
||||
member = members.firstObject;
|
||||
}
|
||||
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
|
||||
XPArrangeMicInfoModel * info = [[XPArrangeMicInfoModel alloc] init];
|
||||
info.roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
|
||||
info.roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
|
||||
info.nick = roomInfo.nick;
|
||||
info.roomAvatar = roomInfo.avatar;
|
||||
info.roomTitle = roomInfo.title;
|
||||
info.micQueue = [self.hostDelegate getMicroQueue];
|
||||
info.isManager = (member.type == NIMChatroomMemberTypeCreator || member.type == NIMChatroomMemberTypeManager);
|
||||
info.type = roomInfo.roomModeType == RoomModeType_Open_Blind ? ArrangeMicType_Dating : roomInfo.roomModeType == RoomModeType_Open_PK_Mode ? ArrangeMicType_Room_PK : ArrangeMicType_Normal;
|
||||
XPArrangeMicViewController * arrangeMicVC = [[XPArrangeMicViewController alloc] initWithInfo:info];
|
||||
[self.hostDelegate.getCurrentNav presentViewController:arrangeMicVC animated:YES completion:nil];
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - Room Delegate
|
||||
- (void)onRoomEntered {
|
||||
|
||||
}
|
||||
|
||||
- (void)onRoomUpdate {
|
||||
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
|
||||
|
||||
[self updateConfigEntranceButtons:roomInfo];
|
||||
|
||||
if (roomInfo.roomModeType != RoomModeType_Open_PK_Mode) {
|
||||
[self updateMenuItem:self.pkMenuButton isRemove:YES];
|
||||
} else {
|
||||
[self updateMenuItem:self.pkMenuButton isRemove:NO];
|
||||
}
|
||||
|
||||
switch (roomInfo.type) {
|
||||
case RoomType_MiniGame:
|
||||
break;
|
||||
default: {
|
||||
[self updateCycleView];
|
||||
|
||||
if (roomInfo.roomModeType == RoomModeType_Open_Blind || roomInfo.roomModeType == RoomModeType_Open_PK_Mode || roomInfo.roomModeType == RoomModeType_Open_Micro_Mode) {
|
||||
if (roomInfo.roomModeType == RoomModeType_Open_PK_Mode ) {
|
||||
self.joinView.image = [UIImage getLanguageImage:@"room_pk_normal_member_enter"];
|
||||
} else {
|
||||
self.joinView.image = [UIImage getLanguageImage:@"room_mode_dating_enter"];
|
||||
}
|
||||
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
|
||||
request.roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
|
||||
request.userIds = @[[AccountInfoStorage instance].getUid];
|
||||
@kWeakify(self);
|
||||
[[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
|
||||
@kStrongify(self);
|
||||
if (error == nil) {
|
||||
NIMChatroomMember * member = members.firstObject;
|
||||
if (member.type == NIMTeamMemberTypeOwner || member.type == NIMTeamMemberTypeManager) {
|
||||
[self updateMenuItem:self.joinView isRemove:YES];
|
||||
return;
|
||||
}
|
||||
}
|
||||
[self updateMenuItem:self.joinView isRemove:NO];
|
||||
}];
|
||||
} else {
|
||||
[self updateMenuItem:self.joinView isRemove:YES];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
[self updateMenuItem:self.pkMenuButton isRemove:NO];
|
||||
[self updateMenuItem:self.joinView isRemove:NO];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)handleNIMTextMessage:(NIMMessage *)message {
|
||||
|
||||
}
|
||||
|
||||
- (void)handleNIMNotificationMessage:(NIMMessage *)message {
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDataSource
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
// Return number of menu items
|
||||
return 5; // Adjust based on your needs
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MenuCell"];
|
||||
|
||||
// Configure cell based on index
|
||||
// Add your menu items here
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
#pragma mark - SDCycleScrollViewDelegate
|
||||
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
|
||||
NSArray *imageUrlList = cycleScrollView.imageURLStringsGroup;
|
||||
|
||||
if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) {
|
||||
[self jumpPlayActionWithIndex:index imageUrlList:imageUrlList];
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *picUrl = [imageUrlList xpSafeObjectAtIndex:index];
|
||||
if ([NSString isEmpty:picUrl]) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableArray *infoList = @[].mutableCopy;
|
||||
ActivityInfoModel * info;
|
||||
for (ActivityInfoModel * getInfo in self.activityList) {
|
||||
if([getInfo.icon isEqualToString:picUrl]){
|
||||
info = getInfo;
|
||||
}
|
||||
if(getInfo.skipType == ActivitySkipType_Web){
|
||||
[infoList addObject:getInfo];
|
||||
}
|
||||
}
|
||||
if (info == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ([info.code isEqualToString:@"FIRST_CHARGE"]) {
|
||||
[self firstRechargeTapRecognizer];
|
||||
} else if ([info.code isEqualToString:@"FIND_LOVE"]) {
|
||||
[self lookLoveTapRecognizer];
|
||||
} else if ([info.code isEqualToString:@"NAUTICAL_ADVENTURE"]) {
|
||||
|
||||
} else if ([info.code isEqualToString:@"SEIZE_TREASURE"]) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
-(void)jumpPlayActionWithIndex:(NSInteger)index imageUrlList:(NSArray *)imageUrlList {
|
||||
|
||||
}
|
||||
|
||||
- (void)firstRechargeTapRecognizer {
|
||||
[[NSNotificationCenter defaultCenter]postNotificationName:kShowFirstRechargeView object:nil];
|
||||
}
|
||||
|
||||
- (void)lookLoveTapRecognizer {
|
||||
XPCandyTreeViewController * candyTreeVC = [[XPCandyTreeViewController alloc] initWithDelegate:self.hostDelegate];
|
||||
candyTreeVC.view.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
|
||||
[[XCCurrentVCStackManager shareManager].getCurrentVC.view addSubview:candyTreeVC.view];
|
||||
[[XCCurrentVCStackManager shareManager].getCurrentVC addChildViewController:candyTreeVC];
|
||||
[candyTreeVC.navigationController setNavigationBarHidden:YES animated:NO];
|
||||
[UIView animateWithDuration:0.1 animations:^{
|
||||
candyTreeVC.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
|
||||
}completion:^(BOOL finished) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)sailTapRecognizer {
|
||||
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
|
||||
XPSailingViewController * sailingVC = [[XPSailingViewController alloc] initWithRoomUid:roomUid];
|
||||
[self.hostDelegate.getCurrentNav presentViewController:sailingVC animated:YES completion:nil];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Getters
|
||||
- (UITableView *)tableView {
|
||||
if (!_tableView) {
|
||||
_tableView = [[UITableView alloc] init];
|
||||
_tableView.delegate = self;
|
||||
_tableView.dataSource = self;
|
||||
_tableView.transform = CGAffineTransformMakeScale(1, -1);
|
||||
_tableView.backgroundColor = [UIColor clearColor];
|
||||
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
[_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"MenuCell"];
|
||||
}
|
||||
return _tableView;
|
||||
}
|
||||
|
||||
- (UIScrollView *)scrollView {
|
||||
if (!_scrollView) {
|
||||
_scrollView = [[UIScrollView alloc] init];
|
||||
_scrollView.backgroundColor = [UIColor greenColor];
|
||||
}
|
||||
return _scrollView;
|
||||
}
|
||||
|
||||
- (UIButton *)gambleMenuButton {
|
||||
if (!_gambleMenuButton) {
|
||||
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[b setImage:[UIImage imageNamed:@"ms_room_game_button"] forState:UIControlStateNormal];
|
||||
[b addTarget:self action:@selector(didTapGameMenuButton) forControlEvents:UIControlEventTouchUpInside];
|
||||
b.imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
b.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
|
||||
b.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
|
||||
_gambleMenuButton = b;
|
||||
}
|
||||
return _gambleMenuButton;
|
||||
}
|
||||
|
||||
- (UIButton *)configEntranceMenuButton {
|
||||
if (!_configEntranceMenuButton) {
|
||||
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[b setImage:[UIImage imageNamed:@"ms_room_game_add_coin"] forState:UIControlStateNormal];
|
||||
[b addTarget:self action:@selector(didTapConfigEntranceButton) forControlEvents:UIControlEventTouchUpInside];
|
||||
b.imageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
b.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
|
||||
b.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
|
||||
_configEntranceMenuButton = b;
|
||||
}
|
||||
return _configEntranceMenuButton;
|
||||
}
|
||||
|
||||
- (UIButton *)pkMenuButton {
|
||||
if (!_pkMenuButton) {
|
||||
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[b setImage:[UIImage imageNamed:@"room_pk_panel_mini_icon"] forState:UIControlStateNormal];
|
||||
[b addTarget:self action:@selector(didTapPKMenuButton) forControlEvents:UIControlEventTouchUpInside];
|
||||
b.imageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
_pkMenuButton = b;
|
||||
}
|
||||
return _pkMenuButton;
|
||||
}
|
||||
|
||||
- (SDCycleScrollView *)cycleScrollView {
|
||||
if (!_cycleScrollView) {
|
||||
_cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:nil];
|
||||
_cycleScrollView.backgroundColor = [UIColor purpleColor];
|
||||
_cycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
|
||||
_cycleScrollView.currentPageDotColor = [UIColor whiteColor];
|
||||
_cycleScrollView.pageDotColor = [UIColor colorWithWhite:1 alpha:0.2];
|
||||
_cycleScrollView.pageControlDotSize = CGSizeMake(5, 2);
|
||||
_cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleClassic;
|
||||
_cycleScrollView.currentPageDotImage = [UIImage imageNamed:@"room_activity_banner_select"];
|
||||
_cycleScrollView.pageDotImage = [UIImage imageNamed:@"room_activity_banner_normal"];
|
||||
_cycleScrollView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.00];
|
||||
_cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFit;
|
||||
_cycleScrollView.pageControlBottomOffset = -10;
|
||||
_cycleScrollView.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
|
||||
}
|
||||
return _cycleScrollView;
|
||||
}
|
||||
|
||||
- (RoomBoomEntryView *)boomView {
|
||||
if (!_boomView) {
|
||||
_boomView = [[RoomBoomEntryView alloc] init];
|
||||
_boomView.userInteractionEnabled = YES;
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(displayBoomInfoProgress)];
|
||||
[_boomView addGestureRecognizer:tap];
|
||||
}
|
||||
return _boomView;
|
||||
}
|
||||
|
||||
- (UIImageView *)joinView {
|
||||
if (!_joinView) {
|
||||
_joinView = [[UIImageView alloc] init];
|
||||
_joinView.image = [UIImage getLanguageImage:@"room_mode_dating_enter"];
|
||||
_joinView.userInteractionEnabled = YES;
|
||||
_joinView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapJoinDatingRecognizer)];
|
||||
[_joinView addGestureRecognizer:tap];
|
||||
}
|
||||
return _joinView;
|
||||
}
|
||||
|
||||
- (NetImageView *)loader_url_1 {
|
||||
if (!_loader_url_1) {
|
||||
_loader_url_1 = [[NetImageView alloc] init];
|
||||
}
|
||||
return _loader_url_1;
|
||||
}
|
||||
|
||||
- (NetImageView *)loader_url_2 {
|
||||
if (!_loader_url_2) {
|
||||
_loader_url_2 = [[NetImageView alloc] init];
|
||||
}
|
||||
return _loader_url_2;
|
||||
}
|
||||
|
||||
@end
|
@@ -254,6 +254,8 @@ UIKIT_EXTERN NSString *kShowFirstRechargeView;
|
||||
-(void)dealWithData{
|
||||
self.isLoadActivity = YES;
|
||||
self.pi_cycleScrollView.hidden = NO;
|
||||
|
||||
self.gambleMenuButton.hidden = (self.playList.count == 0 && self.littleGameList.count == 0) ? YES : NO;
|
||||
|
||||
if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) {
|
||||
[self configLittleGameActivity];
|
||||
|
Reference in New Issue
Block a user