Skip to content

Commit

Permalink
提交 1.10.7 版本
Browse files Browse the repository at this point in the history
  • Loading branch information
PYFer committed Mar 8, 2023
1 parent abe14bb commit 37063f3
Show file tree
Hide file tree
Showing 32 changed files with 1,497 additions and 67 deletions.
4 changes: 2 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ target 'PolyvLiveScenesDemo' do
use_frameworks!

# 保利威 多场景 SDK
pod 'PLVLiveScenesSDK', '1.10.6'
pod 'PLVLiveScenesSDK', '1.10.7'

# 保利威 手机开播场景 需依赖的库
pod 'PLVBytedEffectSDK', '4.3.1'
Expand All @@ -25,6 +25,6 @@ end
target 'PLVScreenShareExtension' do
use_frameworks!
pod 'PLVBusinessSDK', '1.10.4', :subspecs => ['AbstractBSH','ReplayKitExt']
pod 'PLVFoundationSDK', '1.10.6'
pod 'PLVFoundationSDK', '1.10.7'
pod 'TXLiteAVSDK_TRTC', '9.3.10763'
end
58 changes: 50 additions & 8 deletions PolyvLiveScenesDemo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ - (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];

if (self.hasLayoutSubView) { // 调整布局
CGFloat height = PLVLCKeyboardToolViewHeight + P_SafeAreaBottomEdgeInsets();
self.tableView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds) - height);
CGFloat height = [self.keyboardToolView getKeyboardToolViewHeight] + P_SafeAreaBottomEdgeInsets();
[self refreshTableViewFrame];

CGFloat keyboardToolOriginY = CGRectGetHeight(self.view.bounds) - height;
[self.keyboardToolView changeFrameForNewOriginY:keyboardToolOriginY];
Expand All @@ -122,7 +122,7 @@ - (void)viewWillLayoutSubviews {
[self.keyboardToolView updateTextViewAndButton];
}

self.receiveNewMessageView.frame = CGRectMake(0, self.keyboardToolView.frame.origin.y - 28, CGRectGetWidth(self.view.bounds), 28);
[self refreshReceiveNewMessageViewFrame];

if (![self currentIsFullScreen]) {
[self refreshLikeButtonViewFrame];
Expand All @@ -133,11 +133,11 @@ - (void)viewWillLayoutSubviews {

- (void)viewDidLayoutSubviews {
if (!self.hasLayoutSubView) { // 初次布局
CGFloat height = PLVLCKeyboardToolViewHeight + P_SafeAreaBottomEdgeInsets();
CGFloat height = [self.keyboardToolView getKeyboardToolViewHeight] + P_SafeAreaBottomEdgeInsets();
CGRect inputRect = CGRectMake(0, CGRectGetHeight(self.view.bounds) - height, CGRectGetWidth(self.view.bounds), height);
[self.keyboardToolView addAtView:self.view frame:inputRect];
self.receiveNewMessageView.frame = CGRectMake(0, inputRect.origin.y - 28, CGRectGetWidth(self.view.bounds), 28);
self.tableView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds) - height);
[self refreshTableViewFrame];
self.playbackNotifyView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 40);

[self arrangeTopMarqueeViewFrame];
Expand All @@ -148,18 +148,19 @@ - (void)viewDidLayoutSubviews {

[self refreshLikeButtonViewFrame];
[self refreshCardPushButtonViewFrame];
// [self refreshIarEntranceViewFrame];
}
}

- (void)refreshLikeButtonViewFrame{
CGFloat height = PLVLCKeyboardToolViewHeight + P_SafeAreaBottomEdgeInsets();
CGFloat height = [self.keyboardToolView getKeyboardToolViewHeight] + 8 + P_SafeAreaBottomEdgeInsets();
CGRect inputRect = CGRectMake(0, CGRectGetHeight(self.view.bounds) - height, CGRectGetWidth(self.view.bounds), height);
CGFloat rightPadding = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad ? 20.0 : 16.0; // 右边距
self.likeButtonView.frame = CGRectMake(self.view.bounds.size.width - PLVLCLikeButtonViewWidth - rightPadding, inputRect.origin.y - 17 - PLVLCLikeButtonViewHeight, PLVLCLikeButtonViewWidth, PLVLCLikeButtonViewHeight);
}

- (void)refreshCardPushButtonViewFrame{
CGFloat height = PLVLCKeyboardToolViewHeight + P_SafeAreaBottomEdgeInsets();
CGFloat height = [self.keyboardToolView getKeyboardToolViewHeight] + P_SafeAreaBottomEdgeInsets();
CGRect inputRect = CGRectMake(0, CGRectGetHeight(self.view.bounds) - height, CGRectGetWidth(self.view.bounds), height);
CGFloat rightPadding = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad ? 20.0 : 16.0; // 右边距
CGFloat originX = self.view.bounds.size.width - PLVLCCardPushButtonViewWidth - rightPadding;
Expand All @@ -168,6 +169,16 @@ - (void)refreshCardPushButtonViewFrame{
self.cardPushButtonView.frame = CGRectMake(originX, originY, PLVLCCardPushButtonViewWidth, PLVLCCardPushButtonViewHeight);
}

- (void)refreshTableViewFrame {
CGFloat height = [self.keyboardToolView getKeyboardToolViewHeight] + P_SafeAreaBottomEdgeInsets();
self.tableView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds) - height);
}

- (void)refreshReceiveNewMessageViewFrame {
self.receiveNewMessageView.frame = CGRectMake(0, self.keyboardToolView.frame.origin.y - 28, CGRectGetWidth(self.view.bounds), 28);
}


#pragma mark - Getter & Setter

- (UITableView *)tableView {
Expand Down Expand Up @@ -201,8 +212,8 @@ - (PLVLCKeyboardToolView *)keyboardToolView {
if (!_keyboardToolView) {
_keyboardToolView = [[PLVLCKeyboardToolView alloc] init];
_keyboardToolView.delegate = self;
_keyboardToolView.hiddenBulletin = ([PLVRoomDataManager sharedManager].roomData.videoType != PLVChannelVideoType_Live);
if (self.playbackEnable) { //聊天重放时不支持发言
_keyboardToolView.hiddenBulletin = ([PLVRoomDataManager sharedManager].roomData.videoType == PLVChannelVideoType_Playback);
if ([PLVRoomDataManager sharedManager].roomData.videoType == PLVChannelVideoType_Playback) { //回放时不支持发言
[_keyboardToolView changePlaceholderText:@"聊天室暂时关闭"];
}
}
Expand Down Expand Up @@ -826,7 +837,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
#pragma mark - PLVLCKeyboardToolView Delegate

- (BOOL)keyboardToolView_shouldInteract:(PLVLCKeyboardToolView *)toolView {
return !self.playbackEnable; //聊天回放时,不支持发言以及打赏、送礼等互动
return [PLVRoomDataManager sharedManager].roomData.videoType == PLVChannelVideoType_Live; // 聊天回放时,不支持发言以及打赏、送礼等互动
}

- (void)keyboardToolView:(PLVLCKeyboardToolView *)toolView popBoard:(BOOL)show {
Expand Down Expand Up @@ -910,6 +921,18 @@ - (void)keyboardToolView_openReward:(PLVLCKeyboardToolView *)toolView {
[[NSNotificationCenter defaultCenter] postNotificationName:PLVLCChatroomOpenRewardViewNotification object:nil];
}

- (void)keyboardToolView_showIarEntranceView:(PLVLCKeyboardToolView *)iarEntranceView show:(BOOL)show {
CGRect rect = self.keyboardToolView.frame;
if (show) {
rect.size.height += 36;
} else {
rect.size.height -= 36;
}
self.keyboardToolView.frame = rect;
[self.keyboardToolView updateTextViewAndButton];
[self.view layoutIfNeeded];
}

#pragma mark - PLVLCLikeButtonView Delegate

- (void)didTapLikeButton:(PLVLCLikeButtonView *)likeButtonView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@ - (void)notifyDelegatesDidSendMessage:(PLVChatModel *)model {
}

- (void)notifyDelegatesDidReceiveMessages:(NSArray <PLVChatModel *> *)modelArray {
if ([PLVRoomDataManager sharedManager].roomData.videoType == PLVChannelVideoType_Playback) {
return;
}
if (!modelArray || ![modelArray isKindOfClass:[NSArray class]] || [modelArray count] == 0) {
return;
}
Expand Down Expand Up @@ -457,18 +460,27 @@ - (void)notifyDelegatesLoadHistoryFailure {
}

- (void)notifyDelegatesForLoginUsers:(NSArray <PLVChatUser *> * _Nullable )userArray {
if ([PLVRoomDataManager sharedManager].roomData.videoType == PLVChannelVideoType_Playback) {
return;
}
dispatch_async(multicastQueue, ^{
[self->multicastDelegate chatroomManager_loginUsers:userArray];
});
}

- (void)notifyDelegatesForManagerMessage:(NSString *)content {
if ([PLVRoomDataManager sharedManager].roomData.videoType == PLVChannelVideoType_Playback) {
return;
}
dispatch_async(multicastQueue, ^{
[self->multicastDelegate chatroomManager_managerMessage:content];
});
}

- (void)notifyDelegatesForDanmu:(NSString *)content {
if ([PLVRoomDataManager sharedManager].roomData.videoType == PLVChannelVideoType_Playback) {
return;
}
dispatch_async(multicastQueue, ^{
[self->multicastDelegate chatroomManager_danmu:content];
});
Expand Down Expand Up @@ -693,6 +705,10 @@ - (void)chatroomPresenter_loadHistoryFailure {
}

- (void)chatroomPresenter_didReceiveChatModels:(NSArray <PLVChatModel *> *)modelArray {
if ([PLVRoomDataManager sharedManager].roomData.videoType == PLVChannelVideoType_Playback) {
return;
}

[self addPublicChatModels:modelArray];
[self cacheManagerMessages:modelArray];
[self cacheDanmu:modelArray];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// PLVLCIarEntranceView.h
// PolyvLiveScenesDemo
//
// Created by Dhan on 2023/2/21.
// Copyright © 2023 PLV. All rights reserved.
//

#import <UIKit/UIKit.h>

#define PLVLCIarEntranceViewHeight (28.0)

NS_ASSUME_NONNULL_BEGIN

@class PLVLCIarEntranceView;

@protocol PLVLCIarEntranceViewDelegate <NSObject>

/// 打开互动应用模块
- (void)iarEntranceView_openInteractApp:(PLVLCIarEntranceView *)iarEntranceView eventName:(NSString *)eventName;

@end

@interface PLVLCIarEntranceView : UIView

@property (nonatomic, weak) id<PLVLCIarEntranceViewDelegate> delegate;

/// 更新按钮数据(根据传入的数据动态更新按钮)
/// @param dataArray 前端传入的按钮数据
- (void)updateIarEntranceButtonDataArray:(NSArray *)dataArray;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
//
// PLVLCIarEntranceView.m
// PolyvLiveScenesDemo
//
// Created by Dhan on 2023/2/21.
// Copyright © 2023 PLV. All rights reserved.
//

#import "PLVLCIarEntranceView.h"
#import "PLVLCUtils.h"
#import <SDWebImage/UIButton+WebCache.h>
#import <PLVFoundationSDK/PLVFoundationSDK.h>

static NSString *kIarEntranceViewCellIdentifier = @"kIarEntranceViewCellIdentifier";
static NSInteger kItemCountPerSection = 1;
static CGFloat kCellButtonWidth = 68.0;
static CGFloat kCellButtonHeight = 28.0;
static CGFloat kCellLabelPadding = 4.0;

@interface PLVLCLCIarEntranceCollectionViewCell : UICollectionViewCell

@property (nonatomic, strong) UIButton *iarEntranceButton;

@end

@implementation PLVLCLCIarEntranceCollectionViewCell

#pragma mark - Life Cycle

- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.iarEntranceButton = [UIButton buttonWithType:UIButtonTypeCustom];
self.iarEntranceButton.frame = CGRectMake(0.0, 0.0, kCellButtonWidth, kCellButtonHeight);
self.iarEntranceButton.titleLabel.font = [UIFont systemFontOfSize:12.0];
[self.iarEntranceButton setBackgroundColor:PLV_UIColorFromRGBA(@"#000000", 0.16)];
[self.iarEntranceButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
self.iarEntranceButton.imageView.contentMode = UIViewContentModeScaleAspectFit;;
self.iarEntranceButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[self.iarEntranceButton setTitleEdgeInsets:UIEdgeInsetsMake(0, kCellLabelPadding, 0, 0)];
[self.iarEntranceButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, kCellLabelPadding)];
self.iarEntranceButton.layer.masksToBounds = YES;
self.iarEntranceButton.layer.cornerRadius = 12;

[self.contentView addSubview:self.iarEntranceButton];
}
return self;
}

@end

@interface PLVLCIarEntranceView () <UICollectionViewDataSource>

@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) UICollectionViewFlowLayout *flowLayout;
@property (nonatomic, strong) NSArray *dynamicDataArray;

@end

@implementation PLVLCIarEntranceView

#pragma mark - Life Cycle

- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {

self.backgroundColor = [UIColor colorWithRed:0x1a/255.0 green:0x1b/255.0 blue:0x1f/255.0 alpha:1.0];
self.flowLayout = [[UICollectionViewFlowLayout alloc] init];
self.flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
self.flowLayout.itemSize = CGSizeMake(kCellButtonWidth, kCellButtonHeight);
self.flowLayout.minimumInteritemSpacing = 8.0;
self.flowLayout.sectionInset = UIEdgeInsetsMake(0, 16, 0, 0);

CGRect rect = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, kCellButtonHeight);
self.collectionView = [[UICollectionView alloc] initWithFrame:rect collectionViewLayout:self.flowLayout];
self.collectionView.backgroundColor = [UIColor clearColor];
[self.collectionView registerClass:[PLVLCLCIarEntranceCollectionViewCell class] forCellWithReuseIdentifier:kIarEntranceViewCellIdentifier];
self.collectionView.dataSource = self;
self.collectionView.showsHorizontalScrollIndicator = NO;
self.collectionView.showsVerticalScrollIndicator = NO;
[self addSubview:self.collectionView];
}
return self;
}

- (void)layoutSubviews {
[super layoutSubviews];
CGRect rect = CGRectMake(0, 0, self.frame.size.width, kCellButtonHeight);
self.collectionView.frame = rect;
}

#pragma mark - [ Public Method ]

- (void)updateIarEntranceButtonDataArray:(NSArray *)dataArray {
NSMutableArray *showDataArray = [NSMutableArray array];
for (NSInteger index = 0; index < dataArray.count; index++) {
NSDictionary *dict = dataArray[index];
if ([PLVFdUtil checkDictionaryUseable:dict]) {
BOOL isShow = PLV_SafeBoolForDictKey(dict, @"isShow");
NSString *title = PLV_SafeStringForDictKey(dict, @"title");
if (isShow && [PLVFdUtil checkStringUseable:title] && [title isEqualToString:@"问卷"]) {
[showDataArray addObject:dict];
}
}
}
_dynamicDataArray = showDataArray;
self.hidden = !showDataArray.count;
[self.collectionView reloadData];
}

#pragma mark - UICollectionView DataSource

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView*)collectionView {
return kItemCountPerSection;
}

- (NSInteger)collectionView:(UICollectionView*)collectionView numberOfItemsInSection:(NSInteger)section {
return self.dynamicDataArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView*)collectionView cellForItemAtIndexPath:(NSIndexPath*)indexPath {
PLVLCLCIarEntranceCollectionViewCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:kIarEntranceViewCellIdentifier forIndexPath:indexPath];
cell.iarEntranceButton.tag = indexPath.item;
[self updateIarEntranceButton:cell.iarEntranceButton];
[cell.iarEntranceButton addTarget:self action:@selector(iarEntranceButtonAction:) forControlEvents:UIControlEventTouchUpInside];

return cell;
}

#pragma mark - Action

- (void)iarEntranceButtonAction:(UIButton *)button {
NSInteger index = button.tag;
NSDictionary *dict = self.dynamicDataArray[index];
NSString *eventName = PLV_SafeStringForDictKey(dict, @"event");
if (self.delegate && [self.delegate respondsToSelector:@selector(iarEntranceView_openInteractApp:eventName:)]) {
[self.delegate iarEntranceView_openInteractApp:self eventName:eventName];
}
}

#pragma mark - Private Method

- (void)updateIarEntranceButton:(UIButton *)button {
NSInteger index = button.tag;
NSDictionary *dict = self.dynamicDataArray[index];
NSString *buttonTitle = PLV_SafeStringForDictKey(dict, @"title");
[button setTitle:buttonTitle forState:UIControlStateNormal];
[button setTitle:buttonTitle forState:UIControlStateSelected];
if (![PLVFdUtil checkStringUseable:buttonTitle]) {
return;
} else if ([buttonTitle isEqualToString:@"问卷"]) {
[button setImage:[PLVLCUtils imageForChatroomResource:@"plvlc_iarentrance_questionnaire"] forState:UIControlStateNormal];
[button setImage:[PLVLCUtils imageForChatroomResource:@"plvlc_iarentrance_questionnaire"] forState:UIControlStateNormal];
}
}

@end
Loading

0 comments on commit 37063f3

Please sign in to comment.