room vc 协议整理

This commit is contained in:
zu
2022-01-13 18:45:17 +08:00
committed by fengshuo
parent 2b73ded0cd
commit 5c14669e80
10 changed files with 92 additions and 20 deletions

View File

@@ -462,6 +462,7 @@
181D7F1F2727D9DB00B7C059 /* SocialStageView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SocialStageView.h; sourceTree = "<group>"; };
181D7F202727D9DB00B7C059 /* SocialStageView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SocialStageView.m; sourceTree = "<group>"; };
181D7F222727DB1E00B7C059 /* RoomHostDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RoomHostDelegate.h; sourceTree = "<group>"; };
1845C6412790320E00016EAC /* RoomAnimationProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RoomAnimationProtocol.h; sourceTree = "<group>"; };
18486211271EA9DA005FC5DC /* RtcManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RtcManager.h; sourceTree = "<group>"; };
18486212271EA9DA005FC5DC /* RtcManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RtcManager.m; sourceTree = "<group>"; };
18486214271EAA03005FC5DC /* RtcDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RtcDelegate.h; sourceTree = "<group>"; };
@@ -2972,6 +2973,12 @@
E8DEC9962764A51F0078CB70 /* MoreView */,
E838D99D275E1B6C0079E0B5 /* AnimationView */,
E82325EA274E2D52003A3332 /* UserCard */,
E8AEAEE827141ACC0017FCE0 /* RoomHeaderView */,
E8AEAEEA27141ACC0017FCE0 /* StageView */,
E8AEAEE627141ACC0017FCE0 /* MessageContainerView */,
E8AEAEE527141ACC0017FCE0 /* ActivityContainerView */,
E8AEAEE727141ACC0017FCE0 /* BaseUIContainerView */,
E8AEAEE927141ACC0017FCE0 /* MenuContainerView */,
E8AEAED4271412EC0017FCE0 /* XPRoomViewController.h */,
E8AEAED5271412EC0017FCE0 /* XPRoomViewController.m */,
E816C11327608A7500C84014 /* XPRoomMiniManager.h */,
@@ -2979,12 +2986,7 @@
181D7F222727DB1E00B7C059 /* RoomHostDelegate.h */,
180806F827298F9B001FD836 /* RoomGuestDelegate.h */,
186F8B472733F2AE007A17BC /* MicroQueueProtocol.h */,
E8AEAEE827141ACC0017FCE0 /* RoomHeaderView */,
E8AEAEEA27141ACC0017FCE0 /* StageView */,
E8AEAEE627141ACC0017FCE0 /* MessageContainerView */,
E8AEAEE527141ACC0017FCE0 /* ActivityContainerView */,
E8AEAEE727141ACC0017FCE0 /* BaseUIContainerView */,
E8AEAEE927141ACC0017FCE0 /* MenuContainerView */,
1845C6412790320E00016EAC /* RoomAnimationProtocol.h */,
180806F92729A354001FD836 /* ThemeColor+Room.h */,
180806FA2729A354001FD836 /* ThemeColor+Room.m */,
E866B6E32759F96F009B002A /* XPMiniRoomView.h */,

View File

@@ -12,7 +12,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface XPRoomAnimationView : XPRoomAnimationHitView <RoomGuestDelegate>
- (instancetype)initWithdelegate:(id<RoomHostDelegate>)delegate;
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -95,7 +95,7 @@
[[NIMSDK sharedSDK].broadcastManager removeDelegate:self];
}
- (instancetype)initWithdelegate:(id<RoomHostDelegate>)delegate {
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
self = [super init];
if (self) {
[[NIMSDK sharedSDK].broadcastManager addDelegate:self];
@@ -192,8 +192,8 @@
NSString * targetUid= [NSString stringWithFormat:@"%ld", datingModel.targetUid];
NSString * uid= [NSString stringWithFormat:@"%ld", datingModel.uid];
if (datingModel.hasHeart || datingModel.hasSelectUser) {
datingModel.originPoint = [self.delegate centerForUserAtUid:uid];
datingModel.targetPoint = [self.delegate centerForUserAtUid:targetUid];
datingModel.originPoint = [self.delegate animationPointAtStageViewByUid:uid];
datingModel.targetPoint = [self.delegate animationPointAtStageViewByUid:targetUid];
}
XPRoomDatingAnimationView * datingView = [[XPRoomDatingAnimationView alloc] init];
[self.highLevleView addSubview:datingView];
@@ -448,7 +448,7 @@
///
- (CGPoint)getGiftAnimationPoint:(NSString *)uid isEnd:(BOOL)isEnd{
CGPoint point = [self.delegate centerForUserAtUid:uid];
CGPoint point = [self.delegate animationPointAtStageViewByUid:uid];
//
if (point.x <= 0 || point.y <= 0) {
if (isEnd) {

View File

@@ -2,7 +2,7 @@
// MicroQueueProtocol.h
// xplan-ios
//
// Created by apple on 2021/11/4.
// Created by zu on 2021/11/4.
//
#import <Foundation/Foundation.h>
@@ -11,11 +11,28 @@ NS_ASSUME_NONNULL_BEGIN
@class MicroQueueModel;
/** 麦序数据的协议。
RoomVC 的子 View 之间的通信协议,通过 RoomHostDelegate 和 RoomGuestDelegate 继承实现。
调用方向:
- getMicroQueueRoomVC 子 View —> RoomHostDelegate —> StageView
- onMicroQueueUpdateStageView —> RoomHostDelegate —> RoomVC 子 View
*/
@protocol MicroQueueProtocol <NSObject>
@optional
/**
* 获取麦序。
*/
- (NSMutableDictionary<NSString *, MicroQueueModel *>*)getMicroQueue;
/**
* 麦序更新通知。
*/
- (void)onMicroQueueUpdate:(NSMutableDictionary<NSString *, MicroQueueModel *>*)queue;
- (CGPoint)centerForUserAtUid:(NSString *)uid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,29 @@
//
// RoomAnimationProtocol.h
// xplan-ios
//
// Created by zu on 2022/1/13.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/** XPRoomAnimationView 用到的协议。
RoomVC 的子 View 之间的通信协议,通过 RoomHostDelegate 和 RoomGuestDelegate 继承实现。
调用方向XPRoomAnimationView —> RoomHostDelegate —> RoomAnimationProtocolRoomGuestDelegate继承
*/
@protocol RoomAnimationProtocol <NSObject>
@optional
/**
* StageView 专用。
*/
- (CGPoint)animationPointAtStageViewByUid:(NSString *)uid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -6,13 +6,25 @@
//
#import <Foundation/Foundation.h>
#import "MicroQueueProtocol.h"
#import "RoomAnimationProtocol.h"
@class NIMMessage;
@class AttachmentModel;
NS_ASSUME_NONNULL_BEGIN
@protocol RoomGuestDelegate <NSObject, MicroQueueProtocol>
/** RoomVC 子 View 的通用协议。
调用方向RoomVC —> RoomGuestDelegate
**Note:**
继承 MicroQueueProtocol、RoomAnimationProtocol 等协议用于子 View 做实现。
实现后的调用方向:子 View —> RoomHostDelegate —> XXXProtocolRoomGuestDelegate
*/
@protocol RoomGuestDelegate <NSObject, MicroQueueProtocol, RoomAnimationProtocol>
@optional
@@ -22,6 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)handleNIMNotificationMessage:(NIMMessage *)message;
- (void)handleNIMCustomMessage:(NIMMessage *)message;
- (void)handleNIMTextMessage:(NIMMessage *)message;
@end
NS_ASSUME_NONNULL_END

View File

@@ -7,13 +7,24 @@
#import <Foundation/Foundation.h>
#import "MicroQueueProtocol.h"
#import "RoomAnimationProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@class RoomInfoModel;
@class UserInfoModel;
@protocol RoomHostDelegate <NSObject, MicroQueueProtocol>
/** RoomVC 与子 View 之间的通信协议。
调用方向:子 View —> RoomHostDelegate。
**Note:**
继承 MicroQueueProtocol、RoomAnimationProtocol 等协议是为了做桥接。
实现后的调用方向:子 View —> RoomHostDelegate —> XXXProtocolRoomGuestDelegate
*/
@protocol RoomHostDelegate <NSObject, MicroQueueProtocol, RoomAnimationProtocol>
- (RoomInfoModel*)getRoomInfo;
- (UserInfoModel*)getUserInfo;

View File

@@ -104,7 +104,7 @@
return ownerHeight + marginV1 + mcHeight + marginV2 + mcHeight + marginV3;
}
- (CGPoint)centerForUserAtUid:(NSString *)uid {
- (CGPoint)animationPointAtStageViewByUid:(NSString *)uid {
NSInteger index = [self getIndexByUid:uid];
CGPoint point = CGPointZero;
if (index == 0) {

View File

@@ -72,7 +72,7 @@
return ownerHeight + marginV1 + mcHeight + marginV2 + mcHeight + marginV2;
}
- (CGPoint)centerForUserAtUid:(NSString *)uid {
- (CGPoint)animationPointAtStageViewByUid:(NSString *)uid {
NSInteger index = [self getIndexByUid:uid];
CGPoint point = CGPointZero;
if (index == 0) {

View File

@@ -568,8 +568,8 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
[self.functionView onRoomUpdate];
}
- (CGPoint)centerForUserAtUid:(NSString *)uid {
return [self.stageView centerForUserAtUid:uid];
- (CGPoint)animationPointAtStageViewByUid:(NSString *)uid {
return [self.stageView animationPointAtStageViewByUid:uid];
}
#pragma mark - XPRoomSettingInputViewDelegate
@@ -643,7 +643,7 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
- (XPRoomAnimationView *)animationView {
if (!_animationView) {
_animationView = [[XPRoomAnimationView alloc] initWithdelegate:self];
_animationView = [[XPRoomAnimationView alloc] initWithDelegate:self];
}
return _animationView;
}