个播房请求上麦,弹出关注主播窗口

This commit is contained in:
chenguilong
2022-02-15 17:23:18 +08:00
parent 0ce0b911ad
commit 8d9ece2829
12 changed files with 673 additions and 25 deletions

View File

@@ -113,6 +113,9 @@
9B0086C627BA392B0032BD2B /* AnchorStageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0086C527BA392B0032BD2B /* AnchorStageView.m */; }; 9B0086C627BA392B0032BD2B /* AnchorStageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0086C527BA392B0032BD2B /* AnchorStageView.m */; };
9B0086CA27BA4F570032BD2B /* AnchorMicroView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0086C927BA4F570032BD2B /* AnchorMicroView.m */; }; 9B0086CA27BA4F570032BD2B /* AnchorMicroView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0086C927BA4F570032BD2B /* AnchorMicroView.m */; };
9B0E1C5926E77022005D4442 /* BaseNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0E1C5826E77022005D4442 /* BaseNavigationController.m */; }; 9B0E1C5926E77022005D4442 /* BaseNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0E1C5826E77022005D4442 /* BaseNavigationController.m */; };
9B7B605B27BB53060070BB72 /* XPAnchorAudienceUpMicView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7B605A27BB53060070BB72 /* XPAnchorAudienceUpMicView.m */; };
9B7B606227BB96E40070BB72 /* XPRoomAnchorInfoCardView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7B606127BB96E40070BB72 /* XPRoomAnchorInfoCardView.m */; };
9B7B606627BBA0EE0070BB72 /* XPAnchorAttentSendInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7B606527BBA0EE0070BB72 /* XPAnchorAttentSendInfo.m */; };
9B7D804A2753783D003DAC0C /* SessionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7D80492753783D003DAC0C /* SessionViewController.m */; }; 9B7D804A2753783D003DAC0C /* SessionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7D80492753783D003DAC0C /* SessionViewController.m */; };
9B7D804D27537950003DAC0C /* MessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7D804C27537950003DAC0C /* MessageCell.m */; }; 9B7D804D27537950003DAC0C /* MessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7D804C27537950003DAC0C /* MessageCell.m */; };
9B7D80502753AA9D003DAC0C /* UITableView+NIMScrollToBottom.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7D804E2753AA9D003DAC0C /* UITableView+NIMScrollToBottom.m */; }; 9B7D80502753AA9D003DAC0C /* UITableView+NIMScrollToBottom.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7D804E2753AA9D003DAC0C /* UITableView+NIMScrollToBottom.m */; };
@@ -637,6 +640,12 @@
9B0086C927BA4F570032BD2B /* AnchorMicroView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AnchorMicroView.m; sourceTree = "<group>"; }; 9B0086C927BA4F570032BD2B /* AnchorMicroView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AnchorMicroView.m; sourceTree = "<group>"; };
9B0E1C5726E77022005D4442 /* BaseNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseNavigationController.h; sourceTree = "<group>"; }; 9B0E1C5726E77022005D4442 /* BaseNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseNavigationController.h; sourceTree = "<group>"; };
9B0E1C5826E77022005D4442 /* BaseNavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseNavigationController.m; sourceTree = "<group>"; }; 9B0E1C5826E77022005D4442 /* BaseNavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseNavigationController.m; sourceTree = "<group>"; };
9B7B605927BB53060070BB72 /* XPAnchorAudienceUpMicView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPAnchorAudienceUpMicView.h; sourceTree = "<group>"; };
9B7B605A27BB53060070BB72 /* XPAnchorAudienceUpMicView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XPAnchorAudienceUpMicView.m; sourceTree = "<group>"; };
9B7B606027BB96E40070BB72 /* XPRoomAnchorInfoCardView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPRoomAnchorInfoCardView.h; sourceTree = "<group>"; };
9B7B606127BB96E40070BB72 /* XPRoomAnchorInfoCardView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XPRoomAnchorInfoCardView.m; sourceTree = "<group>"; };
9B7B606427BBA0EE0070BB72 /* XPAnchorAttentSendInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPAnchorAttentSendInfo.h; sourceTree = "<group>"; };
9B7B606527BBA0EE0070BB72 /* XPAnchorAttentSendInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPAnchorAttentSendInfo.m; sourceTree = "<group>"; };
9B7D80482753783D003DAC0C /* SessionViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SessionViewController.h; sourceTree = "<group>"; }; 9B7D80482753783D003DAC0C /* SessionViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SessionViewController.h; sourceTree = "<group>"; };
9B7D80492753783D003DAC0C /* SessionViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SessionViewController.m; sourceTree = "<group>"; }; 9B7D80492753783D003DAC0C /* SessionViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SessionViewController.m; sourceTree = "<group>"; };
9B7D804B27537950003DAC0C /* MessageCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessageCell.h; sourceTree = "<group>"; }; 9B7D804B27537950003DAC0C /* MessageCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessageCell.h; sourceTree = "<group>"; };
@@ -1926,6 +1935,27 @@
path = Anchor; path = Anchor;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
9B7B605827BB52FD0070BB72 /* AnchorView */ = {
isa = PBXGroup;
children = (
9B7B606327BBA0D40070BB72 /* Model */,
9B7B606027BB96E40070BB72 /* XPRoomAnchorInfoCardView.h */,
9B7B606127BB96E40070BB72 /* XPRoomAnchorInfoCardView.m */,
9B7B605927BB53060070BB72 /* XPAnchorAudienceUpMicView.h */,
9B7B605A27BB53060070BB72 /* XPAnchorAudienceUpMicView.m */,
);
path = AnchorView;
sourceTree = "<group>";
};
9B7B606327BBA0D40070BB72 /* Model */ = {
isa = PBXGroup;
children = (
9B7B606427BBA0EE0070BB72 /* XPAnchorAttentSendInfo.h */,
9B7B606527BBA0EE0070BB72 /* XPAnchorAttentSendInfo.m */,
);
path = Model;
sourceTree = "<group>";
};
9B7D804727537819003DAC0C /* Session */ = { 9B7D804727537819003DAC0C /* Session */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@@ -2992,6 +3022,7 @@
E8AEAED8271413530017FCE0 /* View */ = { E8AEAED8271413530017FCE0 /* View */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9B7B605827BB52FD0070BB72 /* AnchorView */,
E8412F9A2779BAC2006E1101 /* Setting */, E8412F9A2779BAC2006E1101 /* Setting */,
E84150B027747A7400A7F548 /* FirstRecharge */, E84150B027747A7400A7F548 /* FirstRecharge */,
E81C1B1327705EF00020D1E4 /* ArrangeMic */, E81C1B1327705EF00020D1E4 /* ArrangeMic */,
@@ -3946,6 +3977,7 @@
E8AC723A26F49AAE007D6E91 /* XPMineNotifyStatus.m in Sources */, E8AC723A26F49AAE007D6E91 /* XPMineNotifyStatus.m in Sources */,
18E7B33226F317A20064BC9B /* XPWebViewController.m in Sources */, 18E7B33226F317A20064BC9B /* XPWebViewController.m in Sources */,
E8AEAEF927141CA30017FCE0 /* RoomHeaderView.m in Sources */, E8AEAEF927141CA30017FCE0 /* RoomHeaderView.m in Sources */,
9B7B606627BBA0EE0070BB72 /* XPAnchorAttentSendInfo.m in Sources */,
E81C1B29277069DD0020D1E4 /* XPArrangeMicEmptyTableViewCell.m in Sources */, E81C1B29277069DD0020D1E4 /* XPArrangeMicEmptyTableViewCell.m in Sources */,
E8AC721C26F4720B007D6E91 /* XPMineSettingPresent.m in Sources */, E8AC721C26F4720B007D6E91 /* XPMineSettingPresent.m in Sources */,
E88B5CA526FB088600DA9178 /* XPMineTeenagerViewController.m in Sources */, E88B5CA526FB088600DA9178 /* XPMineTeenagerViewController.m in Sources */,
@@ -3960,6 +3992,7 @@
186A536926FC6F2E00D67B2C /* XPShareView.m in Sources */, 186A536926FC6F2E00D67B2C /* XPShareView.m in Sources */,
186A534C26FC6ED900D67B2C /* TTAlertView.m in Sources */, 186A534C26FC6ED900D67B2C /* TTAlertView.m in Sources */,
E866B6E52759F96F009B002A /* XPMiniRoomView.m in Sources */, E866B6E52759F96F009B002A /* XPMiniRoomView.m in Sources */,
9B7B605B27BB53060070BB72 /* XPAnchorAudienceUpMicView.m in Sources */,
E8B825BF26E9E57D009E8E9F /* LoginTicketInfo.m in Sources */, E8B825BF26E9E57D009E8E9F /* LoginTicketInfo.m in Sources */,
E8E7DAE82744F5EF00C631CC /* XPGiftStorage.m in Sources */, E8E7DAE82744F5EF00C631CC /* XPGiftStorage.m in Sources */,
E87AE7FC277AAC450037823A /* XPRoomTagPresenter.m in Sources */, E87AE7FC277AAC450037823A /* XPRoomTagPresenter.m in Sources */,
@@ -4029,6 +4062,7 @@
18E7B29026EA0E6B0064BC9B /* FlutterBoost+Xplan.m in Sources */, 18E7B29026EA0E6B0064BC9B /* FlutterBoost+Xplan.m in Sources */,
E8B846DC26FDE24300A777FE /* RechargeListModel.m in Sources */, E8B846DC26FDE24300A777FE /* RechargeListModel.m in Sources */,
E884C36C2743951B00E1EBED /* GiftReceiveInfoModel.m in Sources */, E884C36C2743951B00E1EBED /* GiftReceiveInfoModel.m in Sources */,
9B7B606227BB96E40070BB72 /* XPRoomAnchorInfoCardView.m in Sources */,
E8395334276A03C300CF2F24 /* XPMineDressUpPresenter.m in Sources */, E8395334276A03C300CF2F24 /* XPMineDressUpPresenter.m in Sources */,
189DD75926E6003C00AB55B1 /* Api.m in Sources */, 189DD75926E6003C00AB55B1 /* Api.m in Sources */,
E8133916273E532D00708B66 /* XPGiftItemCollectionViewCell.m in Sources */, E8133916273E532D00708B66 /* XPGiftItemCollectionViewCell.m in Sources */,

View File

@@ -43,7 +43,7 @@ typedef NS_ENUM(NSUInteger, CustomMessageType) {
///首充奖励 ///首充奖励
CustomMessageType_First_Recharge_Reward = 76, CustomMessageType_First_Recharge_Reward = 76,
///个播房观众点击空坑位,房主收到请求上麦提示 ///个播房观众点击空坑位,房主收到请求上麦提示
Custom_Noti_Header_AnchorRoom_AudienceUpMic = 86, CustomMessageType_AnchorRoom_AudienceUpMic = 86,
}; };

View File

@@ -0,0 +1,22 @@
//
// XPAnchorAttentSendInfo.h
// xplan-ios
//
// Created by GreenLand on 2022/2/15.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPAnchorAttentSendInfo : NSObject
@property (assign, nonatomic) NSInteger uid;
@property (copy, nonatomic) NSString *nick;
@property (assign, nonatomic) NSInteger targetUid;
@property (copy, nonatomic) NSString *targetNick;
@property(nonatomic, strong)NSDictionary *encodeAttachemt;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,24 @@
//
// XPAnchorAttentSendInfo.m
// xplan-ios
//
// Created by GreenLand on 2022/2/15.
//
#import "XPAnchorAttentSendInfo.h"
@implementation XPAnchorAttentSendInfo
- (NSDictionary *)encodeAttachemt {
NSDictionary *dict = @{@"uid" :@(self.uid),
@"data":@{
@"nick":self.nick == nil ? @"" : self.nick,
@"targetUid":@(self.targetUid),
@"targetNick":self.targetNick == nil ? @"" : self.targetNick,
}
};
return dict;
}
@end

View File

@@ -0,0 +1,24 @@
//
// TTAnchorAudienceUpMicView.h
// PlanetStar
//
// Created by GreenLand on 2021/12/29.
// Copyright © 2021 WUJIE INTERACTIVE. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "RoomHostDelegate.h"
NS_ASSUME_NONNULL_BEGIN
@class UserInfoModel;
@interface XPAnchorAudienceUpMicView : UIView<RoomHostDelegate>
- (instancetype)initWithFrame:(CGRect)frame delegate:(id<RoomHostDelegate>)delegate;
@property (nonatomic, strong) UserInfoModel *info;
@property (nonatomic, weak, readonly) id<RoomHostDelegate> hostDelegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,220 @@
//
// TTAnchorAudienceUpMicView.m
// PlanetStar
//
// Created by GreenLand on 2021/12/29.
// Copyright © 2021 WUJIE INTERACTIVE. All rights reserved.
//
#import "XPAnchorAudienceUpMicView.h"
///Third
#import <Masonry/Masonry.h>
#import <ReactiveObjC/ReactiveObjC.h>
#import <NIMSDK/NIMSDK.h>
///Tool
#import "TTPopup.h"
#import "ThemeColor.h"
#import "UIImage+Utils.h"
#import "NetImageView.h"
///Model
#import "MicroQueueModel.h"
#import "AttachmentModel.h"
#import "RoomInfoModel.h"
#import "UserInfoModel.h"
@interface XPAnchorAudienceUpMicView()
//
@property (nonatomic, strong) NetImageView *avatarImageView;
//
@property (nonatomic, strong) UILabel *nickLabel;
//
@property (nonatomic, strong) UILabel *descripLabel;
//
@property (nonatomic, strong) UIButton *cancelButton;
//
@property (nonatomic, strong) UIButton *confirmButton;
@property (nonatomic, weak) id<RoomHostDelegate> hostDelegate;
@end
@implementation XPAnchorAudienceUpMicView
- (instancetype)initWithFrame:(CGRect)frame delegate:(nonnull id<RoomHostDelegate>)delegate{
if (self = [super initWithFrame:frame]) {
self.hostDelegate = delegate;
[self setUpUI];
[self setupConstraints];
[self setEvents];
}
return self;
}
- (void)setUpUI {
self.backgroundColor = [UIColor whiteColor];
self.layer.cornerRadius = 12;
self.layer.masksToBounds = YES;
[self addSubview:self.avatarImageView];
[self addSubview:self.nickLabel];
[self addSubview:self.descripLabel];
[self addSubview:self.cancelButton];
[self addSubview:self.confirmButton];
}
- (void)setupConstraints {
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(16);
make.width.height.mas_equalTo(80);
}];
[self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.avatarImageView.mas_bottom).mas_offset(4);
make.centerX.mas_equalTo(self.mas_centerX);
make.height.mas_equalTo(18);
}];
[self.descripLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.mas_centerX);
make.height.mas_equalTo(40);
make.top.mas_equalTo(self.nickLabel.mas_bottom).mas_offset(6);
make.left.mas_equalTo(20);
}];
[self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.descripLabel.mas_bottom).offset(12);
make.width.mas_equalTo(126);
make.right.mas_equalTo(self.mas_centerX).mas_offset(-8);
make.height.mas_equalTo(38);
}];
[self.confirmButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.cancelButton);
make.width.mas_equalTo(126);
make.left.mas_equalTo(self.cancelButton.mas_right).mas_offset(16);
make.height.mas_equalTo(38);
}];
}
- (void)setEvents {
@weakify(self);
[[self.confirmButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
@strongify(self);
NSDictionary *micQueue = [self.hostDelegate getMicroQueue];
NSString *position = [self findFreePositionWithMic:micQueue];
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
RoomInfoModel *roomInfo = [self.hostDelegate getRoomInfo];
NSString *roomId = [NSString stringWithFormat:@"%zd", roomInfo.roomId];
request.roomId = roomId;
NSString* uid = [NSString stringWithFormat:@"%ld", self.info.uid];
request.userIds = @[uid];
[[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
NIMChatroomMember * member = members.firstObject;
[self dismiss];
if (!member) return;
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
[dic setValue:position forKey:@"micPosition"];
[dic setValue:member.userId forKey:@"uid"];
AttachmentModel *attachement = [[AttachmentModel alloc]init];
attachement.first = CustomMessageType_Queue;
attachement.second = Custom_Message_Sub_Queue_Invite;
attachement.data = dic;
NIMMessage *message = [[NIMMessage alloc]init];
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachement;
message.messageObject = object;
//
NIMSession *session = [NIMSession session:roomId type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
}];
}];
[[self.cancelButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
[self dismiss];
}];
}
- (void)setInfo:(UserInfoModel *)info {
_info = info;
self.avatarImageView.imageUrl = info.avatar;
self.nickLabel.text = info.nick;
}
- (void)dismiss {
[TTPopup dismiss];
}
- (NSString *)findFreePositionWithMic:(NSDictionary *)micQueue {
if (micQueue != nil && micQueue.allKeys.count > 0) {
NSArray *keys = [micQueue allKeys];
if (keys.count > 0) {
for (NSString *key in keys) {
MicroQueueModel* model = [micQueue objectForKey:key];
if (!model.userInfo) {
return key;
}
}
}
}
return nil;
}
#pragma mark - views
- (NetImageView *)avatarImageView {
if (!_avatarImageView) {
NetImageConfig * config = [[NetImageConfig alloc] init];
config.imageType = ImageTypeUserIcon;
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
_avatarImageView.layer.cornerRadius = 40;
_avatarImageView.layer.masksToBounds = YES;
}
return _avatarImageView;
}
- (UILabel *)nickLabel {
if (!_nickLabel) {
_nickLabel = [[UILabel alloc] init];
_nickLabel.textColor = [ThemeColor mainTextColor];
_nickLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightBold];
}
return _nickLabel;
}
- (UILabel *)descripLabel {
if (!_descripLabel) {
_descripLabel = [[UILabel alloc] init];
_descripLabel.text = @"TA悄悄点击了嘉宾位置\n需要邀请TA上麦互动吗";
_descripLabel.textColor = [ThemeColor textThirdColor];
_descripLabel.textAlignment = NSTextAlignmentCenter;
_descripLabel.font = [UIFont systemFontOfSize:12];
_descripLabel.numberOfLines = 0;
}
return _descripLabel;
}
- (UIButton *)cancelButton {
if (!_cancelButton) {
_cancelButton = [[UIButton alloc] init];
[_cancelButton setTitle:@"取消" forState:UIControlStateNormal];
_cancelButton.layer.cornerRadius = 19;
_cancelButton.layer.masksToBounds = YES;
_cancelButton.titleLabel.font = [UIFont systemFontOfSize:14];
[_cancelButton setTitleColor:[ThemeColor cancelButtonTextColor] forState:UIControlStateNormal];
[_cancelButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor cancelButtonGradientStartColor], [ThemeColor cancelButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
}
return _cancelButton;
}
- (UIButton *)confirmButton {
if (!_confirmButton) {
_confirmButton = [[UIButton alloc] init];
[_confirmButton setTitle:@"确认" forState:UIControlStateNormal];
_confirmButton.layer.cornerRadius = 19;
_confirmButton.layer.masksToBounds = YES;
_confirmButton.titleLabel.font = [UIFont systemFontOfSize:14];
[_confirmButton setTitleColor:UIColorFromRGB(0xffffff) forState:UIControlStateNormal];
[_confirmButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
}
return _confirmButton;
}
@end

View File

@@ -0,0 +1,24 @@
//
// TTRoomAnchorInfoCardView.h
// PlanetStar
//
// Created by GreenLand on 2021/6/28.
// Copyright © 2021 WUJIE INTERACTIVE. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class UserInfoModel;
@interface XPRoomAnchorInfoCardView : UIView
@property (nonatomic, strong) UserInfoModel *userInfo;
@property (nonatomic, strong) UserInfoModel *targetUserInfo;
@property (nonatomic, assign) NSInteger roomId;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,207 @@
//
// TTRoomAnchorInfoCardView.m
// PlanetStar
//
// Created by GreenLand on 2021/6/28.
// Copyright © 2021 WUJIE INTERACTIVE. All rights reserved.
//
#import "XPRoomAnchorInfoCardView.h"
///Third
#import <Masonry/Masonry.h>
#import "TTPopup.h"
///Tool
#import "XCHUDTool.h"
#import <ReactiveObjC/ReactiveObjC.h>
#import "XPMacro.h"
#import "ThemeColor.h"
#import "UIImage+Utils.h"
#import "Api+UserCard.h"
#import "AccountInfoStorage.h"
///View
#import "NetImageView.h"
///Model
#import "UserInfoModel.h"
#import "XPAnchorAttentSendInfo.h"
#import "AttachmentModel.h"
@interface XPRoomAnchorInfoCardView()
@property (nonatomic, strong) UIButton *closeBtn;//
@property (nonatomic, strong) NetImageView *avatarImageView;//
@property (nonatomic, strong) UILabel *nameLabel;//
@property (nonatomic, strong) UILabel *descLabel;//
@property (nonatomic, strong) UIButton *followBtn;//
@end
@implementation XPRoomAnchorInfoCardView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self initView];
[self initConstraint];
}
return self;
}
- (void)initView {
self.backgroundColor = [UIColor whiteColor];
[self addSubview:self.closeBtn];
[self addSubview:self.avatarImageView];
[self addSubview:self.nameLabel];
[self addSubview:self.descLabel];
[self addSubview:self.followBtn];
}
- (void)initConstraint {
CGFloat margin = 16;
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(margin);
make.top.mas_equalTo(margin);
make.width.height.mas_equalTo(30);
}];
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.mas_centerX);
make.width.height.mas_equalTo(80);
make.top.mas_equalTo(55);
}];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.avatarImageView.mas_bottom).mas_offset(10);
make.centerX.mas_equalTo(self.mas_centerX);
make.left.mas_equalTo(margin);
}];
[self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.nameLabel.mas_bottom).mas_offset(30);
make.centerX.mas_equalTo(self.mas_centerX);
}];
[self.followBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(kSafeAreaBottomHeight > 0 ? -kSafeAreaBottomHeight : -20);
make.centerX.mas_equalTo(self.mas_centerX);
make.width.mas_equalTo(225);
make.height.mas_equalTo(30);
}];
}
- (void)setUserInfo:(UserInfoModel *)userInfo {
_userInfo = userInfo;
}
- (void)setTargetUserInfo:(UserInfoModel *)targetUserInfo {
_targetUserInfo = targetUserInfo;
self.avatarImageView.imageUrl = targetUserInfo.avatar;
self.nameLabel.text = targetUserInfo.nick;
}
- (void)drawRect:(CGRect)rect {
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(15, 15)];
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.path = path.CGPath;
self.layer.mask = maskLayer;
}
- (void)layoutSubviews {
[super layoutSubviews];
CGFloat imageWidth = _followBtn.imageView.frame.size.width;
CGFloat space = 5.f; //
_followBtn.titleEdgeInsets = UIEdgeInsetsMake(0, imageWidth + space,0,imageWidth + space);
}
- (void)followBtnClick:(UIButton *)btn {
NSString * uid = [[AccountInfoStorage instance] getUid];
NSString * ticket = [[AccountInfoStorage instance] getTicket];
NSString * type = @"1";
[Api attentionCompletion:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
[self.followBtn setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor cancelButtonGradientStartColor], [ThemeColor cancelButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
[self.followBtn setTitle:@"已关注" forState:UIControlStateNormal];
[self.followBtn setTitleColor:[ThemeColor cancelButtonTextColor] forState:UIControlStateNormal];
XPAnchorAttentSendInfo *info = [[XPAnchorAttentSendInfo alloc] init];
info.uid = self.userInfo.uid;
info.targetNick = self.targetUserInfo.nick;
info.targetUid = self.targetUserInfo.uid;
info.nick = self.userInfo.nick;
AttachmentModel *attachment = [[AttachmentModel alloc]init];
attachment.first = CustomMessageType_Room_Tip;
attachment.second = Custom_Message_Sub_Room_Tip_Attention_Owner;
attachment.data = info.encodeAttachemt;
NIMMessage *message = [[NIMMessage alloc]init];
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachment;
message.messageObject = object;
//
NIMSession *session = [NIMSession session:[NSString stringWithFormat:@"%zd", self.roomId] type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[TTPopup dismiss];
});
}
} uid:uid likedUid:[NSString stringWithFormat:@"%zd", self.userInfo.uid] ticket:ticket type:type];
}
- (void)close:(UIButton *)btn {
[TTPopup dismiss];
}
#pragma mark - lazy
- (UIButton *)closeBtn {
if (!_closeBtn) {
_closeBtn = [UIButton buttonWithType:UIButtonTypeCustom] ;
[_closeBtn setImage:[UIImage imageNamed:@"messageChat_popup_game_close_slices"] forState:UIControlStateNormal];
[_closeBtn addTarget:self action:@selector(close:) forControlEvents:UIControlEventTouchUpInside];
}
return _closeBtn;
}
- (NetImageView *)avatarImageView {
if (!_avatarImageView) {
NetImageConfig * config = [[NetImageConfig alloc] init];
config.imageType = ImageTypeUserIcon;
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
_avatarImageView.layer.cornerRadius = 40;
_avatarImageView.layer.masksToBounds = YES;
}
return _avatarImageView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.font = [UIFont boldSystemFontOfSize:14];
_nameLabel.textColor = [ThemeColor mainTextColor];
_nameLabel.textAlignment = NSTextAlignmentCenter;
}
return _nameLabel;
}
- (UILabel *)descLabel {
if (!_descLabel) {
_descLabel = [[UILabel alloc] init];
_descLabel.font = [UIFont boldSystemFontOfSize:14];
_descLabel.textColor = [ThemeColor textThirdColor];
_descLabel.textAlignment = NSTextAlignmentCenter;
_descLabel.text = @"点击加关注,下次直播不迷路~";
}
return _descLabel;
}
- (UIButton *)followBtn {
if (!_followBtn) {
_followBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_followBtn setImage:[UIImage imageNamed:@"personalAnchor_add"] forState:UIControlStateNormal];
[_followBtn setTitle:@"关注" forState:UIControlStateNormal];
[_followBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:15]];
[_followBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_followBtn.layer.cornerRadius = 15;
_followBtn.layer.masksToBounds = YES;
[_followBtn addTarget:self action:@selector(followBtnClick:) forControlEvents:UIControlEventTouchUpInside];
[_followBtn setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
}
return _followBtn;
}
@end

View File

@@ -8,6 +8,8 @@
#import "XPRoomFunctionContainerView.h" #import "XPRoomFunctionContainerView.h"
///Third ///Third
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
#import <ReactiveObjC/ReactiveObjC.h>
#import <NIMSDK/NIMSDK.h>
///Tool ///Tool
#import "XPMacro.h" #import "XPMacro.h"
#import "AccountInfoStorage.h" #import "AccountInfoStorage.h"
@@ -17,12 +19,16 @@
#import "Api+Room.h" #import "Api+Room.h"
#import "XCHudTool.h" #import "XCHudTool.h"
#import "XPHtmlUrl.h" #import "XPHtmlUrl.h"
#import "Api+Mine.h"
///Model ///Model
#import "RoomInfoModel.h" #import "RoomInfoModel.h"
#import "MicroQueueModel.h" #import "MicroQueueModel.h"
#import "UserInfoModel.h" #import "UserInfoModel.h"
#import "AttachmentModel.h"
///View ///View
#import "XPRoomHalfWebView.h" #import "XPRoomHalfWebView.h"
#import "XPAnchorAudienceUpMicView.h"
#import "XPRoomAnchorInfoCardView.h"
@interface XPRoomFunctionContainerView () @interface XPRoomFunctionContainerView ()
///host ///host
@property (nonatomic,weak) id<RoomHostDelegate>delegate; @property (nonatomic,weak) id<RoomHostDelegate>delegate;
@@ -30,6 +36,8 @@
@property (nonatomic,strong) UIButton *contributionButton; @property (nonatomic,strong) UIButton *contributionButton;
/// ///
@property (nonatomic,strong) UIButton *datingProgresButton; @property (nonatomic,strong) UIButton *datingProgresButton;
///
@property (nonatomic, strong) dispatch_source_t followAnchorTimer;
@end @end
@implementation XPRoomFunctionContainerView @implementation XPRoomFunctionContainerView
@@ -94,6 +102,39 @@
} }
} }
- (void)onRoomEntered {
RoomInfoModel * roomInfo = self.delegate.getRoomInfo;
NSString * roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
if (roomInfo.type == RoomType_Anchor && ![[AccountInfoStorage instance].getUid isEqualToString:roomUid]) {//
NSString * uid = [[AccountInfoStorage instance] getUid];
[Api attentionStatusCompletion:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {//
BOOL isLike = ((NSNumber *)data.data).boolValue;
if (!isLike) {
[self setFollowAnchorTimer];
}
} uid:uid isLikeUid:roomUid];
}
}
- (void)handleNIMCustomMessage:(NIMMessage *)message {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_AnchorRoom_AudienceUpMic) {
UserInfoModel *model = [UserInfoModel modelWithJSON:attachment.data];
XPAnchorAudienceUpMicView *upMicView = [[XPAnchorAudienceUpMicView alloc] initWithFrame:CGRectMake(0, 0, 300, 226) delegate:self.delegate];
upMicView.info = model;
TTPopupConfig *config = [[TTPopupConfig alloc] init];
config.filterIdentifier = @"audienceRequestUpMic";
config.shouldFilterPopup = YES;
config.contentView = upMicView;
config.style = TTPopupStyleAlert;
[TTPopup popupWithConfig:config];
}
}
}
#pragma mark - Event Response #pragma mark - Event Response
- (void)contributionButtonAction:(UIButton *)sender { - (void)contributionButtonAction:(UIButton *)sender {
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid]; NSString * roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid];
@@ -131,6 +172,54 @@
}];} }];}
#pragma mark -
- (void)setFollowAnchorTimer {
if (self.followAnchorTimer != nil) {
dispatch_source_cancel(self.followAnchorTimer);
}
#ifdef DEBUG
NSInteger totalTime = 5;
#else
NSInteger totalTime = 420;
#endif
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
self.followAnchorTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
dispatch_source_set_timer(self.followAnchorTimer,dispatch_walltime(NULL, totalTime*NSEC_PER_SEC), totalTime*NSEC_PER_SEC, 0); //
@weakify(self);
dispatch_source_set_event_handler(self.followAnchorTimer, ^{
dispatch_async(dispatch_get_main_queue(), ^{
@strongify(self);
dispatch_source_cancel(self.followAnchorTimer);
RoomInfoModel* roomInfo = self.delegate.getRoomInfo;
NSString *roomUid = [NSString stringWithFormat:@"%zd", roomInfo.uid];
NSString * uid = [[AccountInfoStorage instance] getUid];
[Api attentionStatusCompletion:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
BOOL isLike = ((NSNumber *)data.data).boolValue;
if (!isLike) { //
if (self.window) {
[self showFollowAnchorView];
}
}
} uid:uid isLikeUid:roomUid];
});
});
dispatch_resume(self.followAnchorTimer);
}
//
- (void)showFollowAnchorView {
RoomInfoModel* roomInfo = self.delegate.getRoomInfo;
NSString *roomUid = [NSString stringWithFormat:@"%zd", roomInfo.uid];
[Api getUserInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
UserInfoModel *userInfo = [UserInfoModel modelWithDictionary:data.data];
XPRoomAnchorInfoCardView *view = [[XPRoomAnchorInfoCardView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 300)];
view.userInfo = self.delegate.getUserInfo;
view.targetUserInfo = userInfo;
view.roomId =roomInfo.roomId;
[TTPopup popupView:view style:TTPopupStyleActionSheet];
} uid:roomUid];
}
#pragma mark - Getters And Setters #pragma mark - Getters And Setters
- (UIButton *)contributionButton { - (UIButton *)contributionButton {
if (!_contributionButton) { if (!_contributionButton) {

View File

@@ -158,12 +158,7 @@
// 2.1 // 2.1
if (member.type == NIMTeamMemberTypeOwner) { if (member.type == NIMTeamMemberTypeOwner) {
// 2.1.2 / // 2.1.2 /
NSString * lockTitle; NSString * lockTitle = micModel.microState.posState == MicroPosStateType_Free ? @"锁麦" : @"解锁";
if (roomInfo.roomModeType == RoomModeType_Open_Micro_Mode || roomInfo.roomModeType == RoomModeType_Open_Blind) {
lockTitle = micModel.microState.posState == MicroPosStateType_Free ? @"切换为排麦" : @"切换为自由麦";
} else {
lockTitle = micModel.microState.posState == MicroPosStateType_Free ? @"锁麦" : @"解锁";
}
TTActionSheetConfig *lockMic = [TTActionSheetConfig normalTitle:lockTitle clickAction:^{ TTActionSheetConfig *lockMic = [TTActionSheetConfig normalTitle:lockTitle clickAction:^{
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid]; NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
NSString * state = micModel.microState.posState == MicroPosStateType_Free ? @"1" : @"0"; NSString * state = micModel.microState.posState == MicroPosStateType_Free ? @"1" : @"0";
@@ -213,7 +208,7 @@
- (void)sendMessageToRoomOwnerWithUserModel:(UserInfoModel *)userInfo { - (void)sendMessageToRoomOwnerWithUserModel:(UserInfoModel *)userInfo {
NIMMessage * message = [[NIMMessage alloc] init]; NIMMessage * message = [[NIMMessage alloc] init];
AttachmentModel * attachMent = [[AttachmentModel alloc] init]; AttachmentModel * attachMent = [[AttachmentModel alloc] init];
attachMent.first = Custom_Noti_Header_AnchorRoom_AudienceUpMic; attachMent.first = CustomMessageType_AnchorRoom_AudienceUpMic;
attachMent.data = [userInfo model2dictionary]; attachMent.data = [userInfo model2dictionary];
NIMCustomObject *object = [[NIMCustomObject alloc] init]; NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachMent; object.attachment = attachMent;

View File

@@ -16,6 +16,7 @@
self.giftValueView.hidden = YES; self.giftValueView.hidden = YES;
} }
///
- (void)showLeaveMode:(BOOL)isLeaveMode { - (void)showLeaveMode:(BOOL)isLeaveMode {
} }
@@ -37,18 +38,20 @@
self.avatarImageView.backgroundColor = [UIColor colorWithPatternImage:newImage]; self.avatarImageView.backgroundColor = [UIColor colorWithPatternImage:newImage];
} }
/// ///
if (userInfo) { if (position == -1) {
if ([self.subviews containsObject:self.leaveLabel]) { if (userInfo) {
[self.leaveLabel removeFromSuperview]; if ([self.subviews containsObject:self.leaveLabel]) {
} [self.leaveLabel removeFromSuperview];
} else { }
if (![self.subviews containsObject:self.leaveLabel]) { } else {
[self insertSubview:self.leaveLabel belowSubview:self.giftValueView]; if (![self.subviews containsObject:self.leaveLabel]) {
[self.leaveLabel mas_makeConstraints:^(MASConstraintMaker *make) { [self insertSubview:self.leaveLabel belowSubview:self.giftValueView];
make.edges.mas_equalTo(self.avatarImageView); [self.leaveLabel mas_makeConstraints:^(MASConstraintMaker *make) {
}]; make.edges.mas_equalTo(self.avatarImageView);
self.leaveLabel.layer.cornerRadius = 150 * 0.5; }];
self.leaveLabel.layer.masksToBounds = YES; self.leaveLabel.layer.cornerRadius = 150 * 0.5;
self.leaveLabel.layer.masksToBounds = YES;
}
} }
} }
} }

View File

@@ -133,7 +133,6 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
[self.view addSubview:self.activityContainerView]; [self.view addSubview:self.activityContainerView];
[self.view addSubview:self.functionView]; [self.view addSubview:self.functionView];
[self.view addSubview:self.animationView]; [self.view addSubview:self.animationView];
} }
- (void)initSubViewConstraints { - (void)initSubViewConstraints {
@@ -225,8 +224,14 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
[self.stageView removeFromSuperview]; [self.stageView removeFromSuperview];
self.stageView = nil; self.stageView = nil;
self.stageView = [[AnchorStageView alloc] initWithDelegate:self]; self.stageView = [[AnchorStageView alloc] initWithDelegate:self];
} else if(self.roomInfo.type == RoomType_Game) {
[self.stageView removeFromSuperview];
self.stageView = nil;
self.stageView = [[SocialStageView alloc] initWithDelegate:self];
} else { } else {
return; [self.stageView removeFromSuperview];
self.stageView = nil;
self.stageView = [[SocialStageView alloc] initWithDelegate:self];
} }
} }
if (!self.stageView.superview) { if (!self.stageView.superview) {
@@ -315,9 +320,10 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
[self.roomHeaderView onRoomUpdate]; [self.roomHeaderView onRoomUpdate];
[self.activityContainerView onRoomUpdate]; [self.activityContainerView onRoomUpdate];
[self.menuContainerView onRoomUpdate]; [self.menuContainerView onRoomUpdate];
if ([XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {// 退 [self.functionView onRoomEntered];
[self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo]; if ([XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {// 退
} else { [self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo];
} else {
//退 //退
[self.stageView onRoomEntered]; [self.stageView onRoomEntered];
} }