2023-07-14 18:50:55 +08:00
|
|
|
|
//
|
2023-09-22 17:43:21 +08:00
|
|
|
|
// XPRoomInfoView.m
|
|
|
|
|
// xplan-ios
|
2023-07-14 18:50:55 +08:00
|
|
|
|
//
|
2023-09-22 17:43:21 +08:00
|
|
|
|
// Created by 冯硕 on 2021/10/11.
|
2023-07-14 18:50:55 +08:00
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "RoomHeaderView.h"
|
|
|
|
|
///Third
|
|
|
|
|
#import <NIMSDK/NIMSDK.h>
|
|
|
|
|
#import <Masonry/Masonry.h>
|
2023-10-28 04:46:10 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#import "TTPopup.h"
|
|
|
|
|
#import <FFPopup/FFPopup.h>
|
2023-09-22 17:43:21 +08:00
|
|
|
|
#import "HttpRequestHelper.h"
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///Tool
|
|
|
|
|
#import "UIImage+Utils.h"
|
|
|
|
|
#import "UIButton+EnlargeTouchArea.h"
|
|
|
|
|
#import "ThemeColor+Room.h"
|
|
|
|
|
#import "TTPopup.h"
|
|
|
|
|
#import "AccountInfoStorage.h"
|
|
|
|
|
#import "HttpRequestHelper.h"
|
|
|
|
|
#import "Api+Room.h"
|
|
|
|
|
#import "XCCurrentVCStackManager.h"
|
|
|
|
|
///Model
|
|
|
|
|
#import "RoomInfoModel.h"
|
|
|
|
|
#import "UserInfoModel.h"
|
|
|
|
|
#import "AttachMentModel.h"
|
|
|
|
|
#import "MicroQueueModel.h"
|
|
|
|
|
#import "XPRoomRecommendModel.h"
|
|
|
|
|
///View
|
2024-06-27 21:31:00 +08:00
|
|
|
|
#import "XPRoomTopicAlertView.h"
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#import "XPRoomRecommendView.h"
|
|
|
|
|
///VC
|
|
|
|
|
#import "XPWebViewcontroller.h"
|
|
|
|
|
#import "XPRoomOnLineViewController.h"
|
|
|
|
|
#import "XPRoomViewController.h"
|
2024-06-27 21:31:00 +08:00
|
|
|
|
#import "XPRoomTypeSelectionViewController.h"
|
|
|
|
|
#import "XPRoomTopicViewController.h"
|
|
|
|
|
|
2025-03-21 16:19:07 +08:00
|
|
|
|
#import "ShareHelder.h"
|
|
|
|
|
#import "XPRoomPresenter.h"
|
2025-09-17 18:44:26 +08:00
|
|
|
|
#import "TurboModeStateManager.h"
|
|
|
|
|
#import "XPTurboModeConstants.h"
|
2025-03-21 16:19:07 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
|
2025-02-10 18:49:34 +08:00
|
|
|
|
@interface RoomHeaderView ()<XPRoomRecommendViewDelegate>
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///容器
|
|
|
|
|
@property (nonatomic,strong) UIStackView *nickStackView;
|
|
|
|
|
///
|
|
|
|
|
@property (nonatomic,strong) UIStackView *titleStackView;
|
2024-05-21 14:17:30 +08:00
|
|
|
|
|
|
|
|
|
@property(nonatomic,strong) NetImageView *avatarView;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///房间名字
|
|
|
|
|
@property (nonatomic,strong) MarqueeLabel *titleLabel;
|
2024-12-28 15:41:56 +08:00
|
|
|
|
@property(nonatomic, strong) NetImageView *levelImageView;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///礼物特效
|
2025-09-17 18:44:26 +08:00
|
|
|
|
@property (nonatomic,strong) UIImageView *noGiftEffectImageView;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///锁房标识
|
|
|
|
|
@property (nonatomic,strong) UIImageView *lockRoomImageView;
|
|
|
|
|
///
|
|
|
|
|
@property (nonatomic,strong) UIStackView *onlineStackView;
|
|
|
|
|
///id和在线人数
|
|
|
|
|
@property (nonatomic,strong) YYLabel *idLabel;
|
2025-03-21 16:19:07 +08:00
|
|
|
|
///分享
|
|
|
|
|
@property (nonatomic,strong) UIButton *shareButton;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///收藏
|
|
|
|
|
@property (nonatomic,strong) UIButton *collectButton;
|
|
|
|
|
///设置
|
|
|
|
|
@property (nonatomic,strong) UIButton *settingButton;
|
2024-06-27 21:31:00 +08:00
|
|
|
|
///话题设置
|
|
|
|
|
@property (nonatomic, strong) UIButton *topicButton;
|
2023-09-22 17:43:21 +08:00
|
|
|
|
///代理
|
2023-07-14 18:50:55 +08:00
|
|
|
|
@property (nonatomic, weak) id<RoomHostDelegate> hostDelegate;
|
|
|
|
|
///右侧推荐房间
|
|
|
|
|
@property (nonatomic, strong) XPRoomRecommendView *recommendRoomView;
|
2023-09-22 17:43:21 +08:00
|
|
|
|
///返回按钮,最小化
|
|
|
|
|
@property (nonatomic,strong) UIButton *backBtn;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
///是否已发送过收藏房间公屏消息
|
|
|
|
|
@property (nonatomic, assign) BOOL hadShowCollectInScreen;
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation RoomHeaderView
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
2023-09-22 17:43:21 +08:00
|
|
|
|
self = [super init];
|
|
|
|
|
if (self) {
|
2023-07-14 18:50:55 +08:00
|
|
|
|
_hostDelegate = delegate;
|
2023-09-22 17:43:21 +08:00
|
|
|
|
[self initSubViews];
|
|
|
|
|
[self initSubViewConstraints];
|
2025-09-17 18:44:26 +08:00
|
|
|
|
[self setupTurboModeNotifications];
|
2023-09-22 17:43:21 +08:00
|
|
|
|
}
|
|
|
|
|
return self;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Event Response
|
|
|
|
|
- (void)backButtonAction:(UIButton *)sender {
|
|
|
|
|
[self.hostDelegate miniRoom];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)settingButtonAction:(UIButton *)sender {
|
|
|
|
|
self.recommendRoomView.frame = CGRectMake(KScreenWidth, 0, 250, KScreenHeight);
|
|
|
|
|
FFPopup *popup = [FFPopup popupWithContentView:self.recommendRoomView];
|
2024-04-12 17:52:35 +08:00
|
|
|
|
popup.showType = isMSRTL() ? FFPopupShowType_SlideInFromLeft:FFPopupShowType_SlideInFromRight;
|
|
|
|
|
popup.dismissType = isMSRTL() ? FFPopupDismissType_SlideOutToLeft : FFPopupDismissType_SlideOutToRight;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
popup.maskType = FFPopupMaskType_Dimmed;
|
|
|
|
|
popup.dimmedMaskAlpha = 0.0;
|
|
|
|
|
popup.shouldDismissOnBackgroundTouch = YES;
|
2024-04-12 17:52:35 +08:00
|
|
|
|
FFPopupHorizontalLayout horizontalLayout = isMSRTL() ? FFPopupHorizontalLayout_Left : FFPopupHorizontalLayout_Right;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
FFPopupVerticalLayout verticalLayout = FFPopupVerticalLayout_Center;
|
|
|
|
|
[popup showWithLayout:FFPopupLayoutMake(horizontalLayout, verticalLayout) duration:0.0];
|
2024-06-27 21:31:00 +08:00
|
|
|
|
@kWeakify(self);
|
2023-07-14 18:50:55 +08:00
|
|
|
|
popup.didFinishDismissingBlock = ^{
|
2024-06-27 21:31:00 +08:00
|
|
|
|
@kStrongify(self);
|
2023-07-14 18:50:55 +08:00
|
|
|
|
[self.recommendRoomView removeFromSuperview];
|
|
|
|
|
};
|
|
|
|
|
popup.didFinishShowingBlock = ^{
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
[Api reqeustRecommendRoom:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
2024-06-27 21:31:00 +08:00
|
|
|
|
@kStrongify(self);
|
2023-07-14 18:50:55 +08:00
|
|
|
|
if (code == 200) {
|
|
|
|
|
NSArray *array = [XPRoomRecommendModel modelsWithArray:data.data];
|
|
|
|
|
self.recommendRoomView.roomList = [NSMutableArray arrayWithArray:array];
|
|
|
|
|
}
|
|
|
|
|
} roomId:[NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]];
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-27 21:31:00 +08:00
|
|
|
|
- (void)topicButtonAction:(UIButton *)sender {
|
|
|
|
|
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
|
|
|
|
|
request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
|
|
|
|
|
request.userIds = @[[AccountInfoStorage instance].getUid];
|
|
|
|
|
[[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request
|
|
|
|
|
completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
|
|
|
|
|
if (error== nil) {
|
|
|
|
|
NIMChatroomMember* member = members.firstObject;
|
|
|
|
|
RoomInfoModel * roomInfo= self.hostDelegate.getRoomInfo;
|
|
|
|
|
if (member.type == NIMChatroomMemberTypeCreator || member.type == NIMChatroomMemberTypeManager) {
|
|
|
|
|
XPRoomTopicViewController * editTopicVC = [[XPRoomTopicViewController alloc] init];
|
|
|
|
|
editTopicVC.roomInfo = roomInfo;
|
|
|
|
|
[self.hostDelegate.getCurrentNav pushViewController:editTopicVC animated:YES];
|
|
|
|
|
} else {
|
|
|
|
|
TTPopupService * config = [[TTPopupService alloc] init];
|
|
|
|
|
XPRoomTopicAlertView * alertView = [[XPRoomTopicAlertView alloc] init];
|
|
|
|
|
alertView.title = roomInfo.roomDesc;
|
|
|
|
|
alertView.message = roomInfo.introduction;
|
|
|
|
|
config.contentView = alertView;
|
|
|
|
|
[TTPopup popupWithConfig:config];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-21 16:19:07 +08:00
|
|
|
|
- (void)shareButtonAction:(UIButton *)sender {
|
|
|
|
|
// @kWeakify(self);
|
|
|
|
|
XPRoomPresenter *presenter = [[XPRoomPresenter alloc] init];
|
|
|
|
|
[presenter getShareLink:@(self.hostDelegate.getRoomInfo.uid).stringValue
|
|
|
|
|
success:^(NSString * _Nonnull link) {
|
|
|
|
|
// @kStrongify(self);
|
|
|
|
|
if (![NSString isEmpty:link]) {
|
|
|
|
|
[ShareHelder shareImage:kImage(@"share_icon") //self.hostDelegate.getRoomInfo.avatar
|
|
|
|
|
url:link
|
|
|
|
|
fromController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
|
|
|
|
}
|
|
|
|
|
} failure:^(NSError * _Nonnull error) {
|
|
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
}
|
2024-05-21 14:17:30 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#pragma mark - Private Method
|
|
|
|
|
- (void)initSubViews {
|
2024-05-21 14:17:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[self addSubview:self.avatarView];
|
2023-09-22 17:43:21 +08:00
|
|
|
|
[self addSubview:self.nickStackView];
|
|
|
|
|
[self addSubview:self.collectButton];
|
2024-04-17 16:02:42 +08:00
|
|
|
|
|
2023-09-22 17:43:21 +08:00
|
|
|
|
[self addSubview:self.settingButton];
|
2024-06-27 21:31:00 +08:00
|
|
|
|
[self addSubview:self.topicButton];
|
2025-03-21 16:19:07 +08:00
|
|
|
|
[self addSubview:self.shareButton];
|
2023-09-22 17:43:21 +08:00
|
|
|
|
[self addSubview:self.backBtn];
|
|
|
|
|
[self.nickStackView addArrangedSubview:self.titleStackView];
|
|
|
|
|
[self.nickStackView addArrangedSubview:self.onlineStackView];
|
|
|
|
|
|
2024-05-21 14:17:30 +08:00
|
|
|
|
|
2023-09-22 17:43:21 +08:00
|
|
|
|
[self.onlineStackView addArrangedSubview:self.idLabel];
|
|
|
|
|
|
|
|
|
|
[self.titleStackView addArrangedSubview:self.titleLabel];
|
2025-09-17 18:44:26 +08:00
|
|
|
|
[self.titleStackView addArrangedSubview:self.noGiftEffectImageView];
|
2023-09-22 17:43:21 +08:00
|
|
|
|
[self.titleStackView addArrangedSubview:self.lockRoomImageView];
|
2024-12-28 15:41:56 +08:00
|
|
|
|
[self.titleStackView addArrangedSubview:self.levelImageView];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)initSubViewConstraints {
|
2023-09-22 17:43:21 +08:00
|
|
|
|
// 设置
|
|
|
|
|
[self.settingButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
2024-04-11 17:05:27 +08:00
|
|
|
|
make.trailing.mas_equalTo(-15);
|
2023-09-22 17:43:21 +08:00
|
|
|
|
make.bottom.mas_equalTo(-11);
|
|
|
|
|
make.width.height.mas_equalTo(22);
|
|
|
|
|
}];
|
2024-06-27 21:31:00 +08:00
|
|
|
|
|
|
|
|
|
[self.topicButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.trailing.mas_equalTo(-45);
|
|
|
|
|
make.bottom.mas_equalTo(-11);
|
|
|
|
|
make.width.height.mas_equalTo(22);
|
|
|
|
|
}];
|
2024-04-18 18:37:21 +08:00
|
|
|
|
|
2023-09-22 17:43:21 +08:00
|
|
|
|
[self.collectButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.centerY.equalTo(self.settingButton);
|
2024-07-22 19:29:12 +08:00
|
|
|
|
make.trailing.mas_equalTo(-75);
|
|
|
|
|
// make.trailing.equalTo(self.topicButton.mas_leading).mas_offset(-5);
|
2024-04-17 16:02:42 +08:00
|
|
|
|
make.size.mas_equalTo(CGSizeMake(20, 20));
|
2023-09-22 17:43:21 +08:00
|
|
|
|
}];
|
2025-03-21 16:19:07 +08:00
|
|
|
|
[self.shareButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.centerY.equalTo(self.collectButton);
|
|
|
|
|
make.trailing.mas_equalTo(self.collectButton.mas_leading).offset(-6);
|
|
|
|
|
make.size.mas_equalTo(CGSizeMake(24, 24));
|
|
|
|
|
}];
|
2024-04-17 16:02:42 +08:00
|
|
|
|
|
2024-05-21 14:17:30 +08:00
|
|
|
|
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.leading.mas_equalTo(self).offset(35);
|
|
|
|
|
make.width.height.mas_equalTo(31);
|
|
|
|
|
make.centerY.mas_equalTo(self.settingButton);
|
|
|
|
|
}];
|
2023-09-22 17:43:21 +08:00
|
|
|
|
[self.nickStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
2023-07-14 18:50:55 +08:00
|
|
|
|
make.centerY.mas_equalTo(self.settingButton);
|
2024-05-21 14:17:30 +08:00
|
|
|
|
make.leading.equalTo(self.avatarView.mas_trailing).mas_offset(6);
|
2025-03-21 16:19:07 +08:00
|
|
|
|
make.trailing.mas_equalTo(self.shareButton.mas_leading);
|
2024-05-21 14:17:30 +08:00
|
|
|
|
}];
|
|
|
|
|
[self.titleStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.width.mas_greaterThanOrEqualTo(50);
|
2023-09-22 17:43:21 +08:00
|
|
|
|
}];
|
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
2024-07-22 19:29:12 +08:00
|
|
|
|
make.width.mas_lessThanOrEqualTo(150);
|
|
|
|
|
// make.height.mas_equalTo(12);
|
2023-09-22 17:43:21 +08:00
|
|
|
|
}];
|
2024-05-21 14:17:30 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
[self.idLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
2024-05-21 14:17:30 +08:00
|
|
|
|
make.height.mas_equalTo(7);
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}];
|
2023-09-22 17:43:21 +08:00
|
|
|
|
|
2025-09-17 18:44:26 +08:00
|
|
|
|
[self.noGiftEffectImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
2024-07-22 19:29:12 +08:00
|
|
|
|
make.size.mas_equalTo(CGSizeMake(20,20));
|
2023-09-22 17:43:21 +08:00
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.lockRoomImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
2024-05-21 14:17:30 +08:00
|
|
|
|
make.size.mas_equalTo(CGSizeMake(20,20));
|
2023-09-22 17:43:21 +08:00
|
|
|
|
}];
|
|
|
|
|
|
2024-12-28 15:41:56 +08:00
|
|
|
|
[self.levelImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.size.mas_equalTo(CGSizeMake(40,16));
|
|
|
|
|
}];
|
|
|
|
|
|
2023-09-22 17:43:21 +08:00
|
|
|
|
[self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
2024-06-27 21:31:00 +08:00
|
|
|
|
make.leading.mas_equalTo(15);
|
|
|
|
|
make.height.width.mas_equalTo(20);
|
|
|
|
|
make.centerY.mas_equalTo(self.settingButton);
|
2023-09-22 17:43:21 +08:00
|
|
|
|
}];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
2024-12-28 15:41:56 +08:00
|
|
|
|
|
|
|
|
|
- (void)updateLevel:(NSString *)levelIcon {
|
|
|
|
|
self.levelImageView.imageUrl = levelIcon;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#pragma mark - RoomGuestDelegate
|
|
|
|
|
- (void)onRoomEntered {
|
2024-07-22 19:29:12 +08:00
|
|
|
|
[self handleRoomInfoChange:NO];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)onRoomUpdate {
|
|
|
|
|
[self handleRoomInfoChange:YES];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)handleRoomInfoChange:(BOOL)isUpdate {
|
2023-09-22 17:43:21 +08:00
|
|
|
|
RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo;
|
|
|
|
|
if (roomInfo) {
|
2024-07-22 19:29:12 +08:00
|
|
|
|
self.idLabel.text = [NSString stringWithFormat:@"ID:%ld",(long)roomInfo.erbanNo];
|
|
|
|
|
self.avatarView.imageUrl = roomInfo.avatar;
|
2023-09-22 17:43:21 +08:00
|
|
|
|
self.titleLabel.text = roomInfo.title;
|
2025-09-18 14:30:21 +08:00
|
|
|
|
|
|
|
|
|
// 初始化时直接使用 isGiftEffectsEnabledForRoom: 的状态
|
2025-09-17 18:44:26 +08:00
|
|
|
|
[self updateGiftEffectImageViewVisibility];
|
2025-09-18 14:30:21 +08:00
|
|
|
|
|
2023-09-22 17:43:21 +08:00
|
|
|
|
if (roomInfo.uid == [AccountInfoStorage instance].getUid.integerValue) {
|
|
|
|
|
self.collectButton.hidden = YES;
|
|
|
|
|
} else {
|
2024-04-17 16:02:42 +08:00
|
|
|
|
self.collectButton.hidden = NO;
|
2024-07-22 19:29:12 +08:00
|
|
|
|
}
|
|
|
|
|
if (!isUpdate) {
|
|
|
|
|
self.collectButton.selected = roomInfo.isRoomFans; // 收藏后,房间数据没有及时更新到 room info,此时不需读 room info 状态
|
2023-09-22 17:43:21 +08:00
|
|
|
|
}
|
|
|
|
|
self.lockRoomImageView.hidden = roomInfo.roomPwd.length <= 0;
|
2024-12-28 15:41:56 +08:00
|
|
|
|
self.levelImageView.hidden = [NSString isEmpty:roomInfo.roomLevelIcon];
|
|
|
|
|
self.levelImageView.imageUrl = roomInfo.roomLevelIcon;
|
2023-09-22 17:43:21 +08:00
|
|
|
|
}
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-22 19:29:12 +08:00
|
|
|
|
|
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
#pragma mark - Event Response
|
|
|
|
|
- (void)collectButtonAction:(UIButton *)sender {
|
2024-04-17 16:02:42 +08:00
|
|
|
|
NSString * type = self.collectButton.selected ? @"2" : @"1";
|
2023-09-22 17:43:21 +08:00
|
|
|
|
NSString * uid = [AccountInfoStorage instance].getUid;
|
|
|
|
|
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
|
2024-06-21 16:14:36 +08:00
|
|
|
|
@kWeakify(self);
|
2023-09-22 17:43:21 +08:00
|
|
|
|
[Api collectRoom:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
2024-06-21 16:14:36 +08:00
|
|
|
|
@kStrongify(self);
|
2023-09-22 17:43:21 +08:00
|
|
|
|
if (code == 200) {
|
2024-04-17 16:02:42 +08:00
|
|
|
|
self.collectButton.selected = !self.collectButton.selected;
|
2023-09-22 17:43:21 +08:00
|
|
|
|
if ([type isEqualToString:@"1"]) {///收藏的话
|
|
|
|
|
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"RoomHeaderView6")];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
if (self.hadShowCollectInScreen) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
self.hadShowCollectInScreen = YES;
|
2023-09-22 17:43:21 +08:00
|
|
|
|
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
|
|
|
|
|
[dic setValue:[AccountInfoStorage instance].getUid forKey:@"uid"];
|
|
|
|
|
[dic setValue:self.hostDelegate.getUserInfo.nick forKey:@"nick"];
|
|
|
|
|
[dic setValue:[NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid] forKey:@"targetUid"];
|
|
|
|
|
[dic setValue:self.hostDelegate.getRoomInfo.nick forKey:@"targetNick"];
|
|
|
|
|
NSDictionary * data = @{@"data":dic};
|
|
|
|
|
AttachmentModel *attachment = [[AttachmentModel alloc]init];
|
|
|
|
|
attachment.first = CustomMessageType_Collection_Room;
|
|
|
|
|
attachment.second = Custom_Message_Sub_Collect_Room_Tips;
|
|
|
|
|
attachment.data = data;
|
|
|
|
|
NIMMessage *message = [[NIMMessage alloc]init];
|
|
|
|
|
NIMCustomObject *object = [[NIMCustomObject alloc] init];
|
|
|
|
|
object.attachment = attachment;
|
|
|
|
|
message.messageObject = object;
|
|
|
|
|
NSString *sessionId = [NSString stringWithFormat:@"%ld",self.hostDelegate.getRoomInfo.roomId];
|
|
|
|
|
//构造会话
|
|
|
|
|
NIMSession *session = [NIMSession session:sessionId type:NIMSessionTypeChatroom];
|
|
|
|
|
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
[XNDJTDDLoadingTool showErrorWithMessage:msg];
|
|
|
|
|
}
|
2025-03-21 16:19:07 +08:00
|
|
|
|
} roomUid:roomUid uid:uid type:type roomUids:@""];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - XPRoomRecommendViewDelegate
|
|
|
|
|
- (void)xPRoomRecommendViewReport {
|
2023-09-22 17:43:21 +08:00
|
|
|
|
TTActionSheetConfig *action = [TTActionSheetConfig normalTitle:YMLocalizedString(@"RoomHeaderView10") clickAction:^{
|
|
|
|
|
[FFPopup dismissPopupForView:self.recommendRoomView animated:NO];
|
|
|
|
|
[self.hostDelegate requesstShieldingAction];
|
|
|
|
|
}];
|
|
|
|
|
TTActionSheetConfig *action1 = [TTActionSheetConfig normalTitle:YMLocalizedString(@"RoomHeaderView12") clickAction:^{
|
|
|
|
|
[FFPopup dismissPopupForView:self.recommendRoomView animated:NO];
|
2024-10-08 11:47:06 +08:00
|
|
|
|
XPWebViewController * webVC = [[XPWebViewController alloc] initWithRoomUID:@(self.hostDelegate.getRoomInfo.uid).stringValue];
|
2023-09-22 17:43:21 +08:00
|
|
|
|
NSString *urlstr = [NSString stringWithFormat:@"%@?reportUid=%ld&source=ROOM", URLWithType(kReportRoomURL),self.hostDelegate.getRoomInfo.uid];
|
|
|
|
|
webVC.url = urlstr;
|
|
|
|
|
[[self.hostDelegate getCurrentNav] pushViewController:webVC animated:YES];
|
|
|
|
|
}];
|
|
|
|
|
[TTPopup actionSheetWithItems:@[action,action1]];
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)xPRoomRecommendViewMiniRoom {
|
|
|
|
|
[FFPopup dismissPopupForView:self.recommendRoomView animated:NO];
|
|
|
|
|
[self.hostDelegate miniRoom];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)xPRoomRecommendViewExitRoom {
|
|
|
|
|
[FFPopup dismissPopupForView:self.recommendRoomView animated:NO];
|
|
|
|
|
[self.hostDelegate exitRoom];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)xPRoomRecommendViewJumpToRoom:(NSString *)roomUid {
|
|
|
|
|
[FFPopup dismissPopupForView:self.recommendRoomView animated:NO];
|
|
|
|
|
[self.hostDelegate exitRoom];
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
|
[XPRoomViewController openRoom:roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Getters And Setters
|
|
|
|
|
- (UIButton *)settingButton {
|
2023-09-22 17:43:21 +08:00
|
|
|
|
if (!_settingButton) {
|
|
|
|
|
_settingButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
2025-03-21 16:19:07 +08:00
|
|
|
|
[_settingButton setImage:kImage(@"room_info_setting") forState:UIControlStateNormal];
|
2023-09-22 17:43:21 +08:00
|
|
|
|
[_settingButton addTarget:self action:@selector(settingButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
[_settingButton setEnlargeEdgeWithTop:8 right:8 bottom:8 left:8];
|
|
|
|
|
}
|
|
|
|
|
return _settingButton;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-03-21 16:19:07 +08:00
|
|
|
|
- (UIButton *)shareButton {
|
|
|
|
|
if (!_shareButton) {
|
|
|
|
|
_shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[_shareButton setImage:[UIImage imageNamed:@"room_share"] forState:UIControlStateNormal];
|
|
|
|
|
[_shareButton addTarget:self action:@selector(shareButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
[_shareButton setEnlargeEdgeWithTop:8 right:8 bottom:8 left:8];
|
|
|
|
|
}
|
|
|
|
|
return _shareButton;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-27 21:31:00 +08:00
|
|
|
|
- (UIButton *)topicButton {
|
|
|
|
|
if (!_topicButton) {
|
|
|
|
|
_topicButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[_topicButton setImage:[UIImage imageNamed:@"room_header_topic_icon"] forState:UIControlStateNormal];
|
|
|
|
|
[_topicButton addTarget:self action:@selector(topicButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
[_topicButton setEnlargeEdgeWithTop:8 right:8 bottom:8 left:8];
|
|
|
|
|
}
|
|
|
|
|
return _topicButton;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
- (UIButton *)collectButton {
|
2023-09-22 17:43:21 +08:00
|
|
|
|
if (!_collectButton) {
|
|
|
|
|
_collectButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
2024-04-17 16:02:42 +08:00
|
|
|
|
[_collectButton setImage:kImage(@"ms_room_top_no_collect") forState:UIControlStateNormal];
|
|
|
|
|
[_collectButton setImage:kImage(@"ms_room_top_collect") forState:UIControlStateSelected];
|
2023-09-22 17:43:21 +08:00
|
|
|
|
_collectButton.hidden = YES;
|
2024-04-17 16:02:42 +08:00
|
|
|
|
[_collectButton setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
|
2023-09-22 17:43:21 +08:00
|
|
|
|
[_collectButton addTarget:self action:@selector(collectButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
}
|
|
|
|
|
return _collectButton;
|
|
|
|
|
}
|
2024-04-17 16:02:42 +08:00
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
- (UIStackView *)nickStackView {
|
2023-09-22 17:43:21 +08:00
|
|
|
|
if (!_nickStackView) {
|
|
|
|
|
_nickStackView = [[UIStackView alloc] init];
|
|
|
|
|
_nickStackView.axis = UILayoutConstraintAxisVertical;
|
|
|
|
|
_nickStackView.distribution = UIStackViewDistributionFill;
|
|
|
|
|
_nickStackView.alignment = UIStackViewAlignmentLeading;
|
2024-05-21 14:17:30 +08:00
|
|
|
|
_nickStackView.spacing = 4;
|
2023-09-22 17:43:21 +08:00
|
|
|
|
}
|
|
|
|
|
return _nickStackView;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIStackView *)titleStackView {
|
2023-09-22 17:43:21 +08:00
|
|
|
|
if (!_titleStackView) {
|
|
|
|
|
_titleStackView = [[UIStackView alloc] init];
|
|
|
|
|
_titleStackView.axis = UILayoutConstraintAxisHorizontal;
|
|
|
|
|
_titleStackView.distribution = UIStackViewDistributionFill;
|
|
|
|
|
_titleStackView.alignment = UIStackViewAlignmentCenter;
|
|
|
|
|
_titleStackView.spacing = 5;
|
|
|
|
|
}
|
|
|
|
|
return _titleStackView;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (MarqueeLabel *)titleLabel{
|
2023-09-22 17:43:21 +08:00
|
|
|
|
if (!_titleLabel) {
|
|
|
|
|
_titleLabel = [[MarqueeLabel alloc] init];
|
|
|
|
|
_titleLabel.scrollDuration = 8.0;
|
|
|
|
|
_titleLabel.fadeLength = 6.0f;
|
2024-05-21 14:17:30 +08:00
|
|
|
|
_titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightBold];
|
|
|
|
|
_titleLabel.textColor = UIColorFromRGB(0xEFEBF3);
|
2023-07-14 18:50:55 +08:00
|
|
|
|
_titleLabel.userInteractionEnabled = YES;
|
2023-09-22 17:43:21 +08:00
|
|
|
|
}
|
|
|
|
|
return _titleLabel;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-09-17 18:44:26 +08:00
|
|
|
|
- (UIImageView *)noGiftEffectImageView {
|
|
|
|
|
if (!_noGiftEffectImageView) {
|
|
|
|
|
_noGiftEffectImageView = [[UIImageView alloc] init];
|
|
|
|
|
_noGiftEffectImageView.userInteractionEnabled = YES;
|
|
|
|
|
_noGiftEffectImageView.image = [UIImage imageNamed:@"room_info_disable_gift_effect"];
|
|
|
|
|
_noGiftEffectImageView.hidden = YES;
|
2023-09-22 17:43:21 +08:00
|
|
|
|
}
|
2025-09-17 18:44:26 +08:00
|
|
|
|
return _noGiftEffectImageView;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIImageView *)lockRoomImageView {
|
2023-09-22 17:43:21 +08:00
|
|
|
|
if (!_lockRoomImageView) {
|
|
|
|
|
_lockRoomImageView = [[UIImageView alloc] init];
|
|
|
|
|
_lockRoomImageView.userInteractionEnabled = YES;
|
|
|
|
|
_lockRoomImageView.image = [UIImage imageNamed:@"room_info_lock_room"];
|
|
|
|
|
_lockRoomImageView.hidden = YES;
|
|
|
|
|
}
|
|
|
|
|
return _lockRoomImageView;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIStackView *)onlineStackView {
|
2023-09-22 17:43:21 +08:00
|
|
|
|
if (!_onlineStackView) {
|
|
|
|
|
_onlineStackView = [[UIStackView alloc] init];
|
|
|
|
|
_onlineStackView.axis = UILayoutConstraintAxisHorizontal;
|
|
|
|
|
_onlineStackView.distribution = UIStackViewDistributionFill;
|
|
|
|
|
_onlineStackView.alignment = UIStackViewAlignmentCenter;
|
|
|
|
|
_onlineStackView.spacing = 2;
|
|
|
|
|
}
|
|
|
|
|
return _onlineStackView;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (YYLabel *)idLabel {
|
2023-09-22 17:43:21 +08:00
|
|
|
|
if (!_idLabel) {
|
|
|
|
|
_idLabel = [[YYLabel alloc] init];
|
2024-05-21 14:17:30 +08:00
|
|
|
|
_idLabel.textColor = [UIColor whiteColor];
|
|
|
|
|
_idLabel.font = [UIFont systemFontOfSize:9 weight:UIFontWeightBold];
|
|
|
|
|
|
2023-09-22 17:43:21 +08:00
|
|
|
|
}
|
|
|
|
|
return _idLabel;
|
2023-07-14 18:50:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (XPRoomRecommendView *)recommendRoomView {
|
|
|
|
|
if (!_recommendRoomView) {
|
|
|
|
|
_recommendRoomView = [[XPRoomRecommendView alloc] init];
|
|
|
|
|
self.recommendRoomView.delegate = self;
|
|
|
|
|
}
|
|
|
|
|
return _recommendRoomView;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-22 17:43:21 +08:00
|
|
|
|
- (UIButton *)backBtn{
|
|
|
|
|
if (!_backBtn){
|
|
|
|
|
_backBtn = [UIButton new];
|
2024-06-27 21:31:00 +08:00
|
|
|
|
[_backBtn setBackgroundImage:[[UIImage imageNamed:@"common_nav_back_white"] ms_SetImageForRTL] forState:UIControlStateNormal];
|
2023-09-22 17:43:21 +08:00
|
|
|
|
[_backBtn addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
2024-06-27 21:31:00 +08:00
|
|
|
|
// [_backBtn setCornerWithLeftTopCorner:10 rightTopCorner:10 bottomLeftCorner:10 bottomRightCorner:10 size:CGSizeMake(20,20)];
|
|
|
|
|
[_backBtn setEnlargeEdgeWithTop:5 right:5 bottom:5 left:5];
|
|
|
|
|
|
2023-09-22 17:43:21 +08:00
|
|
|
|
}
|
|
|
|
|
return _backBtn;
|
|
|
|
|
}
|
2024-05-21 14:17:30 +08:00
|
|
|
|
- (NetImageView *)avatarView{
|
|
|
|
|
if(!_avatarView){
|
|
|
|
|
NetImageConfig *config = [NetImageConfig new];
|
|
|
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
|
|
|
_avatarView = [[NetImageView alloc]initWithConfig:config];
|
|
|
|
|
_avatarView.layer.cornerRadius = 31/2;
|
|
|
|
|
_avatarView.layer.masksToBounds = YES;
|
|
|
|
|
_avatarView.layer.borderWidth = 1;
|
|
|
|
|
_avatarView.layer.borderColor = [UIColor whiteColor].CGColor;
|
|
|
|
|
}
|
|
|
|
|
return _avatarView;
|
|
|
|
|
}
|
2024-12-28 15:41:56 +08:00
|
|
|
|
|
|
|
|
|
- (NetImageView *)levelImageView{
|
|
|
|
|
if(!_levelImageView){
|
|
|
|
|
_levelImageView = [[NetImageView alloc]init];
|
|
|
|
|
}
|
|
|
|
|
return _levelImageView;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-17 18:44:26 +08:00
|
|
|
|
#pragma mark - Turbo Mode Methods
|
|
|
|
|
|
|
|
|
|
- (void)setupTurboModeNotifications {
|
|
|
|
|
// 监听 Turbo Mode 礼物特效开关状态变化
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
|
selector:@selector(handleTurboGiftEffectsStateChanged:)
|
|
|
|
|
name:kTurboGiftEffectsEnabledChanged
|
|
|
|
|
object:nil];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)updateGiftEffectImageViewVisibility {
|
|
|
|
|
RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo;
|
|
|
|
|
if (!roomInfo) return;
|
|
|
|
|
|
|
|
|
|
NSString *roomId = @(roomInfo.roomId).stringValue;
|
|
|
|
|
BOOL turboGiftEffectsEnabled = [[TurboModeStateManager sharedManager] isGiftEffectsEnabledForRoom:roomId];
|
|
|
|
|
|
2025-09-18 14:30:21 +08:00
|
|
|
|
// 当 turboGiftEffectsEnabled 为 NO 时,显示 noGiftEffectImageView
|
|
|
|
|
// 只使用 turboGiftEffectsEnabled 状态,不依赖 roomInfo.hasAnimationEffect
|
|
|
|
|
BOOL shouldShow = !turboGiftEffectsEnabled;
|
2025-09-17 18:44:26 +08:00
|
|
|
|
self.noGiftEffectImageView.hidden = !shouldShow;
|
|
|
|
|
|
2025-09-18 14:30:21 +08:00
|
|
|
|
NSLog(@"🎮 RoomHeaderView: giftEffectImageView 显示状态更新 - 房间ID: %@, turboGiftEffects: %@, 显示: %@",
|
|
|
|
|
roomId, turboGiftEffectsEnabled ? @"开启" : @"关闭", shouldShow ? @"是" : @"否");
|
2025-09-17 18:44:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)handleTurboGiftEffectsStateChanged:(NSNotification *)notification {
|
|
|
|
|
NSLog(@"🎮 RoomHeaderView: 收到 Turbo Mode 礼物特效状态变化通知");
|
|
|
|
|
[self updateGiftEffectImageViewVisibility];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)dealloc {
|
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-14 18:50:55 +08:00
|
|
|
|
@end
|