房间分享

This commit is contained in:
liyuhua
2023-09-22 17:43:21 +08:00
parent 210124d1e5
commit 4dfc17afa5
22 changed files with 860 additions and 638 deletions

View File

@@ -1,33 +1,27 @@
//
// YMRoomInfoView.m
// YUMI
// XPRoomInfoView.m
// xplan-ios
//
// Created by YUMI on 2021/10/11.
// Created by on 2021/10/11.
//
#import "RoomHeaderView.h"
///Third
#import <NIMSDK/NIMSDK.h>
#import <Masonry/Masonry.h>
#import <YYText/YYLabel.h>
#import "TTPopup.h"
#import <FFPopup/FFPopup.h>
#import "HttpRequestHelper.h"
///Tool
#import "UIImage+Utils.h"
#import "UIButton+EnlargeTouchArea.h"
#import "YUMIMacroUitls.h"
#import "ThemeColor+Room.h"
#import "TTPopup.h"
#import "XNDJTDDLoadingTool.h"
#import "YUMIHtmlUrl.h"
#import "AccountInfoStorage.h"
#import "HttpRequestHelper.h"
#import "Api+Room.h"
#import "XCCurrentVCStackManager.h"
#import "StatisticsServiceHelper.h"
#import "NSMutableDictionary+Saft.h"
#import "ClientConfig.h"
///Model
#import "RoomInfoModel.h"
#import "UserInfoModel.h"
@@ -43,9 +37,6 @@
#import "XPRoomViewController.h"
@interface RoomHeaderView ()<XCShareViewDelegate, XPRoomRecommendViewDelegate>
///
@property (nonatomic, strong) UIButton *backButton;
///
@property (nonatomic,strong) UIStackView *nickStackView;
///
@@ -64,56 +55,44 @@
@property (nonatomic,strong) YYLabel *idLabel;
///
@property (nonatomic,strong) UIButton *collectButton;
///
@property (nonatomic,strong) UIButton *cancelButton;
///
@property (nonatomic,strong) UIButton *shareButton;
///
@property (nonatomic,strong) UIButton *settingButton;
///
@property (nonatomic, weak) id<RoomHostDelegate> hostDelegate;
///
@property (nonatomic, strong) XPRoomRecommendView *recommendRoomView;
///
@property (nonatomic,strong) UIButton *backBtn;
///
@property (nonatomic, assign) BOOL hadShowCollectInScreen;
@end
@implementation RoomHeaderView
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
self = [super init];
if (self) {
self = [super init];
if (self) {
_hostDelegate = delegate;
[self initSubViews];
[self initSubViewConstraints];
}
return self;
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Event Response
- (void)backButtonAction:(UIButton *)sender {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_return_click eventAttributes:@{@"roomUid" : @(self.hostDelegate.getRoomInfo.uid)}];
[self.hostDelegate miniRoom];
}
- (void)shareButtonAction:(UIButton *)sender{
[self showSharePanel];
[self showSharePanel];
}
- (void)settingButtonAction:(UIButton *)sender {
if (![ClientConfig shareConfig].canOpen) {
TTActionSheetConfig *exit = [TTActionSheetConfig normalTitle:YMLocalizedString(@"RoomHeaderView0") clickAction:^{
[self.hostDelegate exitRoom];
}];
TTActionSheetConfig *report = [TTActionSheetConfig normalTitle:YMLocalizedString(@"RoomHeaderView1") clickAction:^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"RoomHeaderView2")];
});
}];
[TTPopup actionSheetWithItems:@[exit, report]];
return;
}
self.recommendRoomView.frame = CGRectMake(KScreenWidth, 0, 250, KScreenHeight);
FFPopup *popup = [FFPopup popupWithContentView:self.recommendRoomView];
popup.showType = FFPopupShowType_SlideInFromRight;
@@ -139,271 +118,282 @@
}
- (void)onlineTapRecognizer {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_online_list_click eventAttributes:@{@"roomUid" : @(self.hostDelegate.getRoomInfo.uid)}];
XPRoomOnLineViewController * onlineVC = [[XPRoomOnLineViewController alloc] initWithDelegate:self.hostDelegate];
[self.hostDelegate.getCurrentNav pushViewController:onlineVC animated:YES];
XPRoomOnLineViewController * onlineVC = [[XPRoomOnLineViewController alloc] initWithDelegate:self.hostDelegate];
[self.hostDelegate.getCurrentNav pushViewController:onlineVC animated:YES];
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.backButton];
[self addSubview:self.nickStackView];
[self addSubview:self.collectButton];
[self addSubview:self.settingButton];
[self.nickStackView addArrangedSubview:self.titleStackView];
[self.nickStackView addArrangedSubview:self.onlineStackView];
[self.onlineStackView addArrangedSubview:self.greenDotView];
[self.onlineStackView addArrangedSubview:self.idLabel];
[self.titleStackView addArrangedSubview:self.titleLabel];
[self.titleStackView addArrangedSubview:self.giftEffectImageView];
[self.titleStackView addArrangedSubview:self.lockRoomImageView];
[self addSubview:self.nickStackView];
[self addSubview:self.collectButton];
[self addSubview:self.cancelButton];
[self addSubview:self.shareButton];
[self addSubview:self.settingButton];
[self addSubview:self.backBtn];
[self.nickStackView addArrangedSubview:self.titleStackView];
[self.nickStackView addArrangedSubview:self.onlineStackView];
[self.onlineStackView addArrangedSubview:self.greenDotView];
[self.onlineStackView addArrangedSubview:self.idLabel];
[self.titleStackView addArrangedSubview:self.titleLabel];
[self.titleStackView addArrangedSubview:self.giftEffectImageView];
[self.titleStackView addArrangedSubview:self.lockRoomImageView];
}
- (void)initSubViewConstraints {
[self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(14);
make.height.width.equalTo(@22);
make.centerY.mas_equalTo(self.settingButton);
}];
//
[self.settingButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-15);
//
[self.settingButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-15);
make.bottom.mas_equalTo(-11);
make.width.height.mas_equalTo(22);
}];
[self.collectButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.settingButton);
make.right.equalTo(self.settingButton.mas_left).offset(-8);
make.width.height.mas_equalTo(22);
}];
[self.nickStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(22);
}];
[self.shareButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.settingButton.mas_left).offset(-15);
make.centerY.mas_equalTo(self.settingButton);
make.left.mas_equalTo(self.backButton.mas_right).offset(10);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_lessThanOrEqualTo(100);
make.width.height.mas_equalTo(22);
}];
[self.collectButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.settingButton);
make.left.equalTo(self.nickStackView.mas_right).offset(6);
make.size.mas_equalTo(CGSizeMake(52, 23));
}];
[self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.collectButton);
}];
[self.nickStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.settingButton);
make.left.mas_equalTo(self).offset(35);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_lessThanOrEqualTo(100);
make.height.mas_equalTo(21);
}];
[self.greenDotView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(3,3));
}];
}];
[self.greenDotView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(3,3));
}];
[self.idLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(14);
}];
[self.giftEffectImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(10,10));
}];
[self.lockRoomImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(10,10));
}];
[self.giftEffectImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(10,10));
}];
[self.lockRoomImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(10,10));
}];
[self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(15);
make.height.width.mas_equalTo(20);
make.centerY.mas_equalTo(self.settingButton);
}];
}
#pragma mark - RoomGuestDelegate
- (void)onRoomEntered {
RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo;
///
[[[NIMSDK sharedSDK] chatroomManager] fetchChatroomInfo:[NSString stringWithFormat:@"%ld", (long)self.hostDelegate.getRoomInfo.roomId] completion:^(NSError * _Nullable error, NIMChatroom * _Nullable chatroom) {
if (error == nil) {
self.idLabel.text = [NSString stringWithFormat:YMLocalizedString(@"RoomHeaderView3"), (long)(chatroom.onlineUserCount > 0 ? chatroom.onlineUserCount : 0), (long)roomInfo.erbanNo];
} else {
self.idLabel.text = [NSString stringWithFormat:YMLocalizedString(@"RoomHeaderView3"), (long)(roomInfo.onlineNum > 0 ? roomInfo.onlineNum : 0), (long)roomInfo.erbanNo];
}
}];
if (roomInfo) {
self.titleLabel.text = roomInfo.title;
self.giftEffectImageView.hidden = roomInfo.hasAnimationEffect;
if (roomInfo.uid == [AccountInfoStorage instance].getUid.integerValue) {
self.collectButton.hidden = YES;
} else {
self.collectButton.hidden = NO;
self.collectButton.selected = roomInfo.isRoomFans;
}
self.lockRoomImageView.hidden = roomInfo.roomPwd.length <= 0;
}
if (![ClientConfig shareConfig].canOpen) {
self.onlineStackView.hidden = YES;
}
RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo;
///
[[[NIMSDK sharedSDK] chatroomManager] fetchChatroomInfo:[NSString stringWithFormat:@"%ld", (long)self.hostDelegate.getRoomInfo.roomId] completion:^(NSError * _Nullable error, NIMChatroom * _Nullable chatroom) {
if (error == nil) {
self.idLabel.text = [NSString stringWithFormat:YMLocalizedString(@"RoomHeaderView0"), (long)(chatroom.onlineUserCount > 0 ? chatroom.onlineUserCount : 0), (long)roomInfo.erbanNo];
} else {
self.idLabel.text = [NSString stringWithFormat:YMLocalizedString(@"RoomHeaderView1"), (long)(roomInfo.onlineNum > 0 ? roomInfo.onlineNum : 0), (long)roomInfo.erbanNo];
}
}];
if (roomInfo) {
self.titleLabel.text = roomInfo.title;
self.giftEffectImageView.hidden = roomInfo.hasAnimationEffect;
if (roomInfo.uid == [AccountInfoStorage instance].getUid.integerValue) {
self.collectButton.hidden = YES;
self.cancelButton.hidden = YES;
} else {
self.collectButton.hidden = roomInfo.isRoomFans;
self.cancelButton.hidden = !roomInfo.isRoomFans;
}
self.lockRoomImageView.hidden = roomInfo.roomPwd.length <= 0;
}
}
- (void)onRoomUpdate {
RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo;
self.titleLabel.text = roomInfo.title;
self.idLabel.text = [NSString stringWithFormat:YMLocalizedString(@"RoomHeaderView3"), (long)(roomInfo.onlineNum > 0 ? roomInfo.onlineNum : 0), (long)roomInfo.erbanNo];
self.giftEffectImageView.hidden = roomInfo.hasAnimationEffect;
if (roomInfo.uid == [AccountInfoStorage instance].getUid.integerValue) {
self.collectButton.hidden = YES;
} else {
self.collectButton.hidden = NO;
self.collectButton.selected = roomInfo.isRoomFans;
}
self.lockRoomImageView.hidden = roomInfo.roomPwd.length <= 0;
if (![ClientConfig shareConfig].canOpen) {
self.onlineStackView.hidden = YES;
}
RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo;
self.titleLabel.text = roomInfo.title;
self.idLabel.text = [NSString stringWithFormat:YMLocalizedString(@"RoomHeaderView2"), (long)(roomInfo.onlineNum > 0 ? roomInfo.onlineNum : 0), (long)roomInfo.erbanNo];
self.giftEffectImageView.hidden = roomInfo.hasAnimationEffect;
if (roomInfo.uid == [AccountInfoStorage instance].getUid.integerValue) {
self.collectButton.hidden = YES;
self.cancelButton.hidden = YES;
} else {
self.collectButton.hidden = roomInfo.isRoomFans;
self.cancelButton.hidden = !roomInfo.isRoomFans;
}
self.lockRoomImageView.hidden = roomInfo.roomPwd.length <= 0;
}
#pragma mark - Event Response
- (void)showSharePanel {
XPShareItem *cycle = [XPShareItem itemWitTag:XPShareItemTagMoments title:YMLocalizedString(@"RoomHeaderView6") imageName:@"share_wechat_circle_normal" disableImageName:@"share_wechat_circle_disable"];
XPShareItem *wechat = [XPShareItem itemWitTag:XPShareItemTagWeChat title:YMLocalizedString(@"RoomHeaderView7") imageName:@"share_wechat_normal" disableImageName:@"share_wechat_disable"];
XPShareItem *qq = [XPShareItem itemWitTag:XPShareItemTagQQ title:YMLocalizedString(@"RoomHeaderView8") imageName:@"share_qq_normal" disableImageName:@"share_qq_disable"];
XPShareItem *qqzone = [XPShareItem itemWitTag:XPShareItemTagQQZone title:YMLocalizedString(@"RoomHeaderView9") imageName:@"share_qqzone_normal" disableImageName:@"share_qqzone_disable"];
NSArray * items = @[wechat,cycle, qq, qqzone];
RoomInfoModel * roomInfo = [self.hostDelegate getRoomInfo];
XPShareInfoModel * shareInfo = [[XPShareInfoModel alloc] init];
shareInfo.shareTitle = YMLocalizedString(@"RoomHeaderView10");
shareInfo.shareContent = [NSString stringWithFormat:YMLocalizedString(@"RoomHeaderView11"), roomInfo.title];
shareInfo.shareImageUrl = [self.hostDelegate getRoomInfo].avatar;
shareInfo.type = ShareType_Room;
shareInfo.roomUid = roomInfo.uid;
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * urlString = [NSString stringWithFormat:@"%@/%@?shareUid=%@&uid=%ld&room_name=%@&room_id=%ld&room_avatar=%@&share_name=%@",API_HOST_URL,URLWithType(kShareRoomURL),uid,roomInfo.uid,roomInfo.title,roomInfo.erbanNo,roomInfo.avatar,roomInfo.nick];
shareInfo.shareUrl = urlString;
CGFloat margin = 15;
CGSize itemSize = CGSizeMake((KScreenWidth-2*margin)/4, 65);
XPShareView *shareView = [[XPShareView alloc] initWithItems:items itemSize:itemSize shareInfo:shareInfo];
shareView.delegate = self;
[TTPopup popupView:shareView style:TTPopupStyleActionSheet];
XPShareItem *cycle = [XPShareItem itemWitTag:XPShareItemTagFaceBook title:@"FaceBook" imageName:@"share_fb" disableImageName:@"share_fb"];
XPShareItem *wechat = [XPShareItem itemWitTag:XPShareItemTagLine title:@"Line" imageName:@"share_line" disableImageName:@"share_line"];
XPShareItem *qq = [XPShareItem itemWitTag:XPShareItemTagCopyLink title:YMLocalizedString(@"RoomHeaderView3") imageName:@"share_copy_link" disableImageName:@"share_copy_link"];
NSArray * items = @[wechat,cycle, qq];
RoomInfoModel * roomInfo = [self.hostDelegate getRoomInfo];
XPShareInfoModel * shareInfo = [[XPShareInfoModel alloc] init];
shareInfo.shareTitle = YMLocalizedString(@"RoomHeaderView4");
shareInfo.shareContent = YMLocalizedString(@"RoomHeaderView5");
shareInfo.shareImageUrl = [self.hostDelegate getRoomInfo].avatar;
shareInfo.type = ShareType_Room;
shareInfo.roomUid = roomInfo.uid;
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * urlString = [NSString stringWithFormat:@"%@/%@?shareUid=%@&uid=%ld&room_name=%@&room_id=%ld&room_avatar=%@&share_name=%@",API_HOST_URL,URLWithType(kShareRoomURL),uid,roomInfo.uid,roomInfo.title,roomInfo.erbanNo,roomInfo.avatar,roomInfo.nick];
urlString = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
shareInfo.shareUrl = urlString;
CGFloat margin = 15;
CGSize itemSize = CGSizeMake((KScreenWidth-2*margin)/4, 65);
XPShareView *shareView = [[XPShareView alloc] initWithItems:items itemSize:itemSize shareInfo:shareInfo];
shareView.delegate = self;
[TTPopup popupView:shareView style:TTPopupStyleActionSheet];
}
///
- (void)saveShare:(XPShareInfoModel *)shareInfo {
NSMutableDictionary *params = [NSMutableDictionary dictionary];
NSString *uid = [AccountInfoStorage instance].getUid;
NSString *ticket = [AccountInfoStorage instance].getTicket;
[params safeSetObject:uid forKey:@"uid"];
[params safeSetObject:@(shareInfo.shareType) forKey:@"shareType"];
[params safeSetObject:ticket forKey:@"ticket"];
[params safeSetObject:@(shareInfo.type) forKey:@"sharePageId"];
if (shareInfo.shareUrl.length > 0) {
[params safeSetObject:shareInfo.shareUrl forKey:@"shareUrl"];
}
if (shareInfo.roomUid > 0) {
[params safeSetObject:@(shareInfo.roomUid) forKey:@"targetUid"];
}
[HttpRequestHelper POST:@"usershare/save" params:params success:^(BaseModel * _Nonnull data) {
} failure:^(NSInteger resCode, NSString * _Nonnull message) {
}];
NSMutableDictionary *params = [NSMutableDictionary dictionary];
NSString *uid = [AccountInfoStorage instance].getUid;
NSString *ticket = [AccountInfoStorage instance].getTicket;
[params setObject:uid forKey:@"uid"];
[params setObject:@(shareInfo.shareType) forKey:@"shareType"];
[params setObject:ticket forKey:@"ticket"];
[params setObject:@(shareInfo.type) forKey:@"sharePageId"];
if (shareInfo.shareUrl.length > 0) {
[params setObject:shareInfo.shareUrl forKey:@"shareUrl"];
}
if (shareInfo.roomUid > 0) {
[params setObject:@(shareInfo.roomUid) forKey:@"targetUid"];
}
[HttpRequestHelper POST:@"usershare/save" params:params success:^(BaseModel * _Nonnull data) {
} failure:^(NSInteger resCode, NSString * _Nonnull message) {
}];
}
- (void)collectButtonAction:(UIButton *)sender {
NSString * type = sender.selected ? @"2" : @"1";
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
[Api collectRoom:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
sender.selected= !sender.selected;
if ([type isEqualToString:@"1"]) {///
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_collect_icon_click eventAttributes:@{@"roomUid" : @(self.hostDelegate.getRoomInfo.uid)}];
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"RoomHeaderView12")];
NSString * type = sender == self.cancelButton ? @"2" : @"1";
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
[Api collectRoom:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
self.collectButton.hidden = !self.collectButton.hidden;
self.cancelButton.hidden = !self.cancelButton.hidden;
if ([type isEqualToString:@"1"]) {///
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"RoomHeaderView6")];
if (self.hadShowCollectInScreen) {
return;
}
self.hadShowCollectInScreen = YES;
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
[dic safeSetObject:[AccountInfoStorage instance].getUid forKey:@"uid"];
[dic safeSetObject:self.hostDelegate.getUserInfo.nick forKey:@"nick"];
[dic safeSetObject:[NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid] forKey:@"targetUid"];
[dic safeSetObject: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];
}
} roomUid:roomUid uid:uid type:type roomUids:NULL];
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];
}
} roomUid:roomUid uid:uid type:type roomUids:NULL];
}
#pragma mark - XCShareViewDelegate
- (void)shareView:(XPShareView *)shareView shareFail:(NSString *)message {
[TTPopup dismiss];
[XNDJTDDLoadingTool showErrorWithMessage:message];
[TTPopup dismiss];
[XNDJTDDLoadingTool showErrorWithMessage:message];
}
- (void)shareView:(XPShareView *)shareView didSuccess:(XPShareInfoModel *)shareInfo{
[TTPopup dismiss];
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"RoomHeaderView13")];
AttachmentModel * attachMent = [[AttachmentModel alloc] init];
attachMent.first = CustomMessageType_Room_Tip;
attachMent.second = Custom_Message_Sub_Room_Tip_ShareRoom;
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
NSString * uid = [AccountInfoStorage instance].getUid;
[dic safeSetObject:uid forKey:@"uid"];
NSMutableDictionary * userDic = [NSMutableDictionary dictionary];
UserInfoModel * userInfo = [self.hostDelegate getUserInfo];
RoomInfoModel * roomInfo = [self.hostDelegate getRoomInfo];
[userDic safeSetObject:roomInfo.nick.length > 0 ? roomInfo.nick : @"" forKey:@"targetNick"];
[userDic safeSetObject:@(roomInfo.uid) forKey:@"targetUid"];
[userDic safeSetObject:userInfo.nick.length > 0 ? userInfo.nick : @"" forKey:@"nick"];
[dic safeSetObject:userDic forKey:@"data"];
attachMent.data = dic;
NSString *sessionID = [NSString stringWithFormat:@"%ld", [self.hostDelegate getRoomInfo].roomId];
NIMMessage *message = [[NIMMessage alloc]init];
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachMent;
message.messageObject = object;
//
NIMSession *session = [NIMSession session:sessionID type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
///
[self saveShare:shareInfo];
[TTPopup dismiss];
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"RoomHeaderView7")];
AttachmentModel * attachMent = [[AttachmentModel alloc] init];
attachMent.first = CustomMessageType_Room_Tip;
attachMent.second = Custom_Message_Sub_Room_Tip_ShareRoom;
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
NSString * uid = [AccountInfoStorage instance].getUid;
[dic setValue:uid forKey:@"uid"];
NSMutableDictionary * userDic = [NSMutableDictionary dictionary];
UserInfoModel * userInfo = [self.hostDelegate getUserInfo];
RoomInfoModel * roomInfo = [self.hostDelegate getRoomInfo];
[userDic setValue:roomInfo.nick.length > 0 ? roomInfo.nick : @"" forKey:@"targetNick"];
[userDic setValue:@(roomInfo.uid) forKey:@"targetUid"];
[userDic setValue:userInfo.nick.length > 0 ? userInfo.nick : @"" forKey:@"nick"];
[dic setValue:userDic forKey:@"data"];
attachMent.data = dic;
NSString *sessionID = [NSString stringWithFormat:@"%ld", [self.hostDelegate getRoomInfo].roomId];
NIMMessage *message = [[NIMMessage alloc]init];
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachMent;
message.messageObject = object;
//
NIMSession *session = [NIMSession session:sessionID type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
///
[self saveShare:shareInfo];
}
- (void)shareViewDidClickCancel:(XPShareView *)shareView {
[TTPopup dismiss];
[TTPopup dismiss];
}
#pragma mark - XPRoomRecommendViewDelegate
- (void)xPRoomRecommendViewReport {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_icon_click eventAttributes:@{@"reportRoom" : @(self.hostDelegate.getRoomInfo.uid)}];
[FFPopup dismissPopupForView:self.recommendRoomView animated:NO];
XPWebViewController * webVC = [[XPWebViewController alloc] init];
NSString *urlstr = [NSString stringWithFormat:@"%@?reportUid=%ld&source=ROOM", URLWithType(kReportRoomURL),self.hostDelegate.getRoomInfo.uid];
webVC.url = urlstr;
[[self.hostDelegate getCurrentNav] pushViewController:webVC animated:YES];
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];
XPWebViewController * webVC = [[XPWebViewController alloc] init];
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]];
}
- (void)xPRoomRecommendViewMiniRoom {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_icon_click eventAttributes:@{@"miniRoom" : @(self.hostDelegate.getRoomInfo.uid)}];
[FFPopup dismissPopupForView:self.recommendRoomView animated:NO];
[self.hostDelegate miniRoom];
}
- (void)xPRoomRecommendViewExitRoom {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_icon_click eventAttributes:@{@"exitRoom" : @(self.hostDelegate.getRoomInfo.uid)}];
[FFPopup dismissPopupForView:self.recommendRoomView animated:NO];
[self.hostDelegate exitRoom];
}
- (void)xPRoomRecommendViewShare {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_icon_click eventAttributes:@{@"shareRoom" : @(self.hostDelegate.getRoomInfo.uid)}];
[FFPopup dismissPopupForView:self.recommendRoomView animated:NO];
[self showSharePanel];
}
- (void)xPRoomRecommendViewJumpToRoom:(NSString *)roomUid {
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_icon_click eventAttributes:@{@"jumpToRoom" : 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(), ^{
@@ -412,123 +402,140 @@
}
#pragma mark - Getters And Setters
- (UIButton *)backButton{
if (!_backButton) {
_backButton = [[UIButton alloc] init];
[_backButton setImage:[UIImage imageNamed:@"room_info_back"] forState:UIControlStateNormal];
[_backButton addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[_backButton setEnlargeEdgeWithTop:15 right:15 bottom:15 left:15];
- (UIButton *)shareButton {
if(!_shareButton){
_shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_shareButton setImage:[UIImage imageNamed:@"room_info_share"] forState:UIControlStateNormal];
[_shareButton addTarget:self action:@selector(shareButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[_shareButton setEnlargeEdgeWithTop:8 right:8 bottom:8 left:8];
}
return _backButton;
return _shareButton;
}
- (UIButton *)settingButton {
if (!_settingButton) {
_settingButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_settingButton setImage:[UIImage imageNamed:@"room_info_setting"] forState:UIControlStateNormal];
[_settingButton addTarget:self action:@selector(settingButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[_settingButton setEnlargeEdgeWithTop:8 right:8 bottom:8 left:8];
}
return _settingButton;
if (!_settingButton) {
_settingButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_settingButton setImage:[UIImage imageNamed:@"room_info_setting"] forState:UIControlStateNormal];
[_settingButton addTarget:self action:@selector(settingButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[_settingButton setEnlargeEdgeWithTop:8 right:8 bottom:8 left:8];
}
return _settingButton;
}
- (UIButton *)collectButton {
if (!_collectButton) {
_collectButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_collectButton setImage:[UIImage imageNamed:@"room_collect_normal"] forState:UIControlStateNormal];
[_collectButton setImage:[UIImage imageNamed:@"room_collect_selected"] forState:UIControlStateSelected];
[_collectButton addTarget:self action:@selector(collectButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[_collectButton setEnlargeEdgeWithTop:8 right:8 bottom:8 left:8];
_collectButton.adjustsImageWhenHighlighted = NO;
_collectButton.hidden = YES;
}
return _collectButton;
if (!_collectButton) {
_collectButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_collectButton setTitle:YMLocalizedString(@"RoomHeaderView8") forState:UIControlStateNormal];
[_collectButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_collectButton.titleLabel.font = [UIFont systemFontOfSize:12];
_collectButton.backgroundColor = UIColorFromRGB(0x67D7D7);
_collectButton.layer.masksToBounds = YES;
_collectButton.layer.cornerRadius = 23 / 2.0;
_collectButton.hidden = YES;
[_collectButton addTarget:self action:@selector(collectButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _collectButton;
}
-(UIButton *)cancelButton{
if (!_cancelButton){
_cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_cancelButton setTitle:YMLocalizedString(@"RoomHeaderView9") forState:UIControlStateNormal];
[_cancelButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.9] forState:UIControlStateNormal];
_cancelButton.titleLabel.font = [UIFont systemFontOfSize:12];
[_cancelButton setBackgroundImage:[UIImage new] forState:UIControlStateNormal];
_cancelButton.backgroundColor = [UIColor colorWithWhite:1 alpha:0.3];
_cancelButton.layer.masksToBounds = YES;
_cancelButton.layer.cornerRadius = 23 / 2.0;
_cancelButton.hidden = YES;
[_cancelButton addTarget:self action:@selector(collectButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _cancelButton;
}
- (UIStackView *)nickStackView {
if (!_nickStackView) {
_nickStackView = [[UIStackView alloc] init];
_nickStackView.axis = UILayoutConstraintAxisVertical;
_nickStackView.distribution = UIStackViewDistributionFill;
_nickStackView.alignment = UIStackViewAlignmentLeading;
}
return _nickStackView;
if (!_nickStackView) {
_nickStackView = [[UIStackView alloc] init];
_nickStackView.axis = UILayoutConstraintAxisVertical;
_nickStackView.distribution = UIStackViewDistributionFill;
_nickStackView.alignment = UIStackViewAlignmentLeading;
}
return _nickStackView;
}
- (UIStackView *)titleStackView {
if (!_titleStackView) {
_titleStackView = [[UIStackView alloc] init];
_titleStackView.axis = UILayoutConstraintAxisHorizontal;
_titleStackView.distribution = UIStackViewDistributionFill;
_titleStackView.alignment = UIStackViewAlignmentCenter;
_titleStackView.spacing = 5;
}
return _titleStackView;
if (!_titleStackView) {
_titleStackView = [[UIStackView alloc] init];
_titleStackView.axis = UILayoutConstraintAxisHorizontal;
_titleStackView.distribution = UIStackViewDistributionFill;
_titleStackView.alignment = UIStackViewAlignmentCenter;
_titleStackView.spacing = 5;
}
return _titleStackView;
}
- (MarqueeLabel *)titleLabel{
if (!_titleLabel) {
_titleLabel = [[MarqueeLabel alloc] init];
_titleLabel.scrollDuration = 8.0;
_titleLabel.fadeLength = 6.0f;
_titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Bold" size:15];
_titleLabel.textColor = [DJDKMIMOMColor roomOwnerNickColor];
if (!_titleLabel) {
_titleLabel = [[MarqueeLabel alloc] init];
_titleLabel.scrollDuration = 8.0;
_titleLabel.fadeLength = 6.0f;
_titleLabel.font = [UIFont systemFontOfSize:14];
_titleLabel.textColor = [DJDKMIMOMColor roomOwnerNickColor];
_titleLabel.userInteractionEnabled = YES;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onlineTapRecognizer)];
[_titleLabel addGestureRecognizer:tap];
}
return _titleLabel;
}
return _titleLabel;
}
- (UIImageView *)giftEffectImageView {
if (!_giftEffectImageView) {
_giftEffectImageView = [[UIImageView alloc] init];
_giftEffectImageView.userInteractionEnabled = YES;
_giftEffectImageView.image = [UIImage imageNamed:@"room_info_gift_effect"];
}
return _giftEffectImageView;
if (!_giftEffectImageView) {
_giftEffectImageView = [[UIImageView alloc] init];
_giftEffectImageView.userInteractionEnabled = YES;
_giftEffectImageView.image = [UIImage imageNamed:@"room_info_gift_effect"];
}
return _giftEffectImageView;
}
- (UIImageView *)lockRoomImageView {
if (!_lockRoomImageView) {
_lockRoomImageView = [[UIImageView alloc] init];
_lockRoomImageView.userInteractionEnabled = YES;
_lockRoomImageView.image = [UIImage imageNamed:@"room_info_lock_room"];
_lockRoomImageView.hidden = YES;
}
return _lockRoomImageView;
if (!_lockRoomImageView) {
_lockRoomImageView = [[UIImageView alloc] init];
_lockRoomImageView.userInteractionEnabled = YES;
_lockRoomImageView.image = [UIImage imageNamed:@"room_info_lock_room"];
_lockRoomImageView.hidden = YES;
}
return _lockRoomImageView;
}
- (UIStackView *)onlineStackView {
if (!_onlineStackView) {
_onlineStackView = [[UIStackView alloc] init];
_onlineStackView.axis = UILayoutConstraintAxisHorizontal;
_onlineStackView.distribution = UIStackViewDistributionFill;
_onlineStackView.alignment = UIStackViewAlignmentCenter;
_onlineStackView.spacing = 2;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onlineTapRecognizer)];
[_onlineStackView addGestureRecognizer:tap];
}
return _onlineStackView;
if (!_onlineStackView) {
_onlineStackView = [[UIStackView alloc] init];
_onlineStackView.axis = UILayoutConstraintAxisHorizontal;
_onlineStackView.distribution = UIStackViewDistributionFill;
_onlineStackView.alignment = UIStackViewAlignmentCenter;
_onlineStackView.spacing = 2;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onlineTapRecognizer)];
[_onlineStackView addGestureRecognizer:tap];
}
return _onlineStackView;
}
- (UIView *)greenDotView {
if (!_greenDotView) {
_greenDotView = [[UIView alloc] init];
_greenDotView.backgroundColor = [DJDKMIMOMColor roomOnLineIdenColor];
_greenDotView.layer.masksToBounds = YES;
_greenDotView.layer.cornerRadius = 1.5;
}
return _greenDotView;
if (!_greenDotView) {
_greenDotView = [[UIView alloc] init];
_greenDotView.backgroundColor = [DJDKMIMOMColor roomOnLineIdenColor];
_greenDotView.layer.masksToBounds = YES;
_greenDotView.layer.cornerRadius = 1.5;
}
return _greenDotView;
}
- (YYLabel *)idLabel {
if (!_idLabel) {
_idLabel = [[YYLabel alloc] init];
_idLabel.textColor = [DJDKMIMOMColor roomOwnerNickColor];
_idLabel.font = [UIFont systemFontOfSize:10];
}
return _idLabel;
if (!_idLabel) {
_idLabel = [[YYLabel alloc] init];
_idLabel.textColor = [DJDKMIMOMColor roomOnLineIdenColor];
_idLabel.font = [UIFont systemFontOfSize:10];
}
return _idLabel;
}
- (XPRoomRecommendView *)recommendRoomView {
@@ -539,4 +546,14 @@
return _recommendRoomView;
}
- (UIButton *)backBtn{
if (!_backBtn){
_backBtn = [UIButton new];
[_backBtn setBackgroundImage:[UIImage imageNamed:@"common_nav_back_white"] forState:UIControlStateNormal];
[_backBtn addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[_backBtn setCornerWithLeftTopCorner:10 rightTopCorner:10 bottomLeftCorner:10 bottomRightCorner:10 size:CGSizeMake(20,20)];
}
return _backBtn;
}
@end