Commit dc312ebc authored by 彭云飞's avatar 彭云飞
Browse files

LIVE-39451【iOS】多场景1.x 封装RN插件——iOS端

parent 73a0b0ff

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
......@@ -3,9 +3,12 @@ platform :ios, '9.0'
target 'PolyvRNCloudClassDemo' do
use_frameworks!
pod 'Masonry', '~> 1.1.0'
# 保利威 多场景 SDK
pod 'PLVLiveScenesSDK', '1.2.4'
# 保利威 UI源码 需依赖的库
pod 'SDWebImage', '4.4.0'
pod 'PolyvCloudClassSDK', '0.16.2'
pod 'MJRefresh', '~> 3.5.0'
# 执行 npm install 命令之后,有可能会自动生成下面这两行配置,需要把这两行配置删掉或者注释掉
# pod 'RNReanimated', :path => '../node_modules/react-native-reanimated'
......
PODS:
- AgoraRtcEngine_iOS (2.9.0.107)
- Masonry (1.1.0)
- PolyvAliHttpDNS (1.7.4):
- PolyvAliHttpDNS/AlicloudHttpDNS (= 1.7.4)
- PolyvAliHttpDNS/AlicloudUtils (= 1.7.4)
- PolyvAliHttpDNS/UTDID (= 1.7.4)
- PolyvAliHttpDNS/AlicloudHttpDNS (1.7.4)
- PolyvAliHttpDNS/AlicloudUtils (1.7.4)
- PolyvAliHttpDNS/UTDID (1.7.4)
- PolyvBusinessSDK/Core (0.15.0):
- PolyvFoundationSDK (~> 0.12.0)
- PolyvCloudClassSDK (0.16.2):
- PolyvCloudClassSDK/Core (= 0.16.2)
- PolyvCloudClassSDK/Player (= 0.16.2)
- PolyvCloudClassSDK/ThirdPart (= 0.16.2)
- PolyvCloudClassSDK/Core (0.16.2):
- PolyvBusinessSDK/Core (~> 0.15.0)
- PolyvCloudClassSDK/Player (0.16.2):
- PolyvIJKPlayer (~> 0.9.1)
- PolyvCloudClassSDK/ThirdPart (0.16.2):
- MJRefresh (3.5.0)
- PLVLiveScenesSDK (1.2.4):
- PLVLiveScenesSDK/BaseSDK (= 1.2.4)
- PLVLiveScenesSDK/Core (= 1.2.4)
- PLVLiveScenesSDK/OtherPart (= 1.2.4)
- PLVLiveScenesSDK/Player (= 1.2.4)
- PLVLiveScenesSDK/BaseSDK (1.2.4):
- PolyvBusinessSDK/BaseSDK (~> 1.2.3)
- PolyvBusinessSDK/Core (~> 1.2.3)
- PLVLiveScenesSDK/Core (1.2.4)
- PLVLiveScenesSDK/OtherPart (1.2.4):
- AgoraRtcEngine_iOS (= 2.9.0.107)
- PolyvAliHttpDNS (~> 1.7.3)
- PolyvAliHttpDNS (~> 1.8.0)
- Socket.IO-Client-Swift (~> 14.0.0)
- PolyvFoundationSDK (0.12.1)
- PolyvIJKPlayer (0.9.2)
- UCloudRtcSdk (= 1.8.0)
- PLVLiveScenesSDK/Player (1.2.4):
- PolyvIJKPlayer (~> 0.9.1)
- PolyvAliHttpDNS (1.8.0):
- PolyvAliHttpDNS/AlicloudHttpDNS (= 1.8.0)
- PolyvAliHttpDNS/AlicloudUtils (= 1.8.0)
- PolyvAliHttpDNS/UTDID (= 1.8.0)
- PolyvAliHttpDNS/AlicloudHttpDNS (1.8.0)
- PolyvAliHttpDNS/AlicloudUtils (1.8.0)
- PolyvAliHttpDNS/UTDID (1.8.0)
- PolyvBusinessSDK/BaseSDK (1.2.3):
- PolyvFoundationSDK (~> 1.2.2)
- PolyvBusinessSDK/Core (1.2.3)
- PolyvFoundationSDK (1.2.2)
- PolyvIJKPlayer (0.9.3)
- SDWebImage (4.4.0):
- SDWebImage/Core (= 4.4.0)
- SDWebImage/Core (4.4.0)
- Socket.IO-Client-Swift (14.0.0):
- Starscream (~> 3.0.6)
- Starscream (3.0.6)
- UCloudRtcSdk (1.8.0)
DEPENDENCIES:
- Masonry (~> 1.1.0)
- PolyvCloudClassSDK (= 0.16.2)
- MJRefresh (~> 3.5.0)
- PLVLiveScenesSDK (= 1.2.4)
- SDWebImage (= 4.4.0)
SPEC REPOS:
trunk:
- AgoraRtcEngine_iOS
- Masonry
- MJRefresh
- PLVLiveScenesSDK
- PolyvAliHttpDNS
- PolyvBusinessSDK
- PolyvCloudClassSDK
- PolyvFoundationSDK
- PolyvIJKPlayer
- SDWebImage
- Socket.IO-Client-Swift
- Starscream
- UCloudRtcSdk
SPEC CHECKSUMS:
AgoraRtcEngine_iOS: f295cc362f18a98a59464c7485a1de1dad4847f2
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
PolyvAliHttpDNS: 6e7783feba44d25abc4f9584da83f93e7e4ef957
PolyvBusinessSDK: 33c19f17c948d1a1078ebefc160e5bb6e5f423d3
PolyvCloudClassSDK: 8cb6c10966ffe6a469a85b5668f6a2336513aacc
PolyvFoundationSDK: e04eb9e32d267f37009d55e48a0d4a269c9ee2ec
PolyvIJKPlayer: 2a3c55373b145173ae64b1fc23d1eca51e5aad16
MJRefresh: 6afc955813966afb08305477dd7a0d9ad5e79a16
PLVLiveScenesSDK: 2e23c55ba09024e11d0605cd2ecafee8472885a2
PolyvAliHttpDNS: 370a8ac4f6eb1ae598618bb6a48b1fd4d6542ea0
PolyvBusinessSDK: 63d9aa5a44f3eed1dbc25e1371d75e4f186b344d
PolyvFoundationSDK: 9558489752a9251a2be594e0a7ba96b42b74adf3
PolyvIJKPlayer: d843e30e8d63b33497af60229881168a96c562a7
SDWebImage: b534502786e43dde36dfcaee89356fe6df30e203
Socket.IO-Client-Swift: 21e6a8a23a7d367d5ddfab6cbbd3c679cf3c25d6
Starscream: ef3ece99d765eeccb67de105bfa143f929026cf5
UCloudRtcSdk: 4891702984544e902024316a103164772abd5987
PODFILE CHECKSUM: 6eff13f13f8d4646531eae27c6de181e6686cd84
PODFILE CHECKSUM: ffdf7977d535be75c0b68cc0efdb34465eeda945
COCOAPODS: 1.10.0
COCOAPODS: 1.10.1
//
// FTPageController.h
// FTPageController
//
// Created by ftao on 04/01/2018.
// Copyright © 2018 easefun. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol FTPageControllerDelegate;
/**
自定义分页控制器
*/
@interface FTPageController : UIViewController
@property (nonatomic, weak) id<FTPageControllerDelegate> delegate;
@property (nonatomic, assign, readonly) CGFloat barHeight;
@property (nonatomic, strong, readonly) NSMutableArray *titles;
@property (nonatomic, strong, readonly) NSMutableArray *controllers;
@property (nonatomic, strong, readonly) UIView *touchLineView;
@property (nonatomic, assign) BOOL circulation;
/**
设置分页控制器
@param titles 子控制器标题
@param controllers 子控制器
*/
- (void)setTitles:(NSArray<NSString *> *)titles
controllers:(NSArray<UIViewController *> *)controllers
barHeight:(CGFloat)barHeight
touchHeight:(CGFloat)touchHeight;
/**
新增页
@param title 页标题
@param controller 页控制器
*/
- (void)addPageWithTitle:(NSString *)title controller:(UIViewController *)controller;
/**
插入页在指定位置
@param title 页标题
@param controller 页控制器
@param index 位置(大于最大数量时,则插入至最后)
*/
- (void)insertPageWithTitle:(NSString *)title controller:(UIViewController *)controller atIndex:(NSUInteger)index;
/**
移除页控制器
@param index 位置
*/
- (void)removePageAtIndex:(NSUInteger)index;
/// 改变大小
- (void)changeFrame;
/// 是否圆角
- (void)cornerRadius:(BOOL)flag;
- (void)scrollEnable:(BOOL)enable;
@end
@protocol FTPageControllerDelegate <NSObject>
- (BOOL)canMoveChatroom:(FTPageController *)pageController;
- (void)moveChatroom:(FTPageController *)pageController toPointY:(CGFloat)pointY;
- (void)moveChatroom:(FTPageController *)pageController;
@end
//
// FTPageController.m
// FTPageController
//
// Created by ftao on 04/01/2018.
// Copyright © 2018 easefun. All rights reserved.
//
#import "FTPageController.h"
#import "FTTitleViewCell.h"
#define kWidth [UIScreen mainScreen].bounds.size.width
static NSString *TitleCellIdentifier = @"PageTitleCell";
@interface FTPageController () <UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UIPageViewControllerDataSource,UIPageViewControllerDelegate>
@property (nonatomic, assign) CGFloat barHeight;
@property (nonatomic, assign) CGFloat touchHeight;
@property (nonatomic, strong) UICollectionView *titleCollectionView;
@property (nonatomic, strong) UIPageViewController *pageViewController;
@property (nonatomic, strong) NSMutableArray *titles;
@property (nonatomic, strong) NSMutableArray *controllers;
@property (nonatomic, strong) UIBezierPath *basePath;
@property (nonatomic, strong) UIBezierPath *maskPath;
@property (nonatomic, strong) UIView *touchView;
@property (nonatomic, strong) UIView *touchLineView;
@property (nonatomic, strong) UIView *topLineView;
@property (nonatomic) NSUInteger nextIndex;
@property (nonatomic, assign) BOOL canMove;
@property (nonatomic, assign) CGPoint lastPoint;
@end
@implementation FTPageController {
CGFloat _titleItemWidth;
NSIndexPath *_selectedIndexPath;
}
#pragma mark - Initialize
- (void)setTitles:(NSArray<NSString *> *)titles
controllers:(NSArray<UIViewController *> *)controllers
barHeight:(CGFloat)barHeight
touchHeight:(CGFloat)touchHeight {
self.barHeight = barHeight;
self.touchHeight = touchHeight;
_selectedIndexPath = [NSIndexPath indexPathForItem:0 inSection:0];
self.titles = [[NSMutableArray alloc] initWithArray:titles];
self.controllers = [[NSMutableArray alloc] initWithArray:controllers];
[self setupTitles];
[self setupPageController];
[self.view bringSubviewToFront:self.topLineView];
}
- (void)changeFrame {
self.pageViewController.view.frame = CGRectMake(0, self.barHeight, kWidth, CGRectGetHeight(self.view.bounds) - self.barHeight);
}
-(void)setupPageController {
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
self.pageViewController.view.frame = CGRectMake(0, self.barHeight, kWidth, CGRectGetHeight(self.view.bounds) - self.barHeight);
self.pageViewController.dataSource = self;
self.pageViewController.delegate =self;
NSArray *initControllers = @[self.controllers[0]];
[self.pageViewController setViewControllers:initControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
[self.view addSubview:self.pageViewController.view];
[self addChildViewController:self.pageViewController];
self.pageViewController.view.clipsToBounds = NO;
for (UIView *subview in self.pageViewController.view.subviews) {
subview.clipsToBounds = NO;
}
}
-(void)setupTitles {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
self.titleCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, self.touchHeight, kWidth, self.barHeight - self.touchHeight) collectionViewLayout:layout];
self.titleCollectionView.backgroundColor = [UIColor whiteColor];
self.titleCollectionView.dataSource = self;
self.titleCollectionView.delegate = self;
self.titleCollectionView.allowsSelection = YES;
[self.view addSubview:self.titleCollectionView];
self.titleCollectionView.showsVerticalScrollIndicator = NO;
self.titleCollectionView.showsHorizontalScrollIndicator = NO;
[self.titleCollectionView registerClass:[FTTitleViewCell class] forCellWithReuseIdentifier:TitleCellIdentifier];
if (self.touchHeight > 0.0) {
[self addTouchView];
}
}
- (void)addTouchView {
self.touchView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, self.touchHeight)];
self.touchView.backgroundColor = [UIColor whiteColor];
self.touchView.layer.mask = [[CAShapeLayer alloc] init];
self.touchView.layer.mask.frame = self.touchView.bounds;
[self.view addSubview:self.touchView];
self.basePath = [UIBezierPath bezierPathWithRect:self.touchView.bounds];
self.maskPath = [UIBezierPath bezierPathWithRoundedRect:self.touchView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(8.0, 8.0)];
self.touchLineView = [[UIView alloc] initWithFrame:CGRectMake((self.touchView.bounds.size.width - 50.0) * 0.5, 5.0, 50.0, 5.0)];
self.touchLineView.backgroundColor = [UIColor colorWithWhite:234.0 / 255.0 alpha:1.0];
self.touchLineView.layer.cornerRadius = 2.5;
[self.touchView addSubview:self.touchLineView];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
[self.touchView addGestureRecognizer:tap];
self.lastPoint = self.view.bounds.origin;
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGestureRecognizer:)];
[self.touchView addGestureRecognizer:panGestureRecognizer];
}
- (void)cornerRadius:(BOOL)flag {
if (flag) {
((CAShapeLayer *)self.touchView.layer.mask).path = self.maskPath.CGPath;
} else {
((CAShapeLayer *)self.touchView.layer.mask).path = self.basePath.CGPath;
}
}
- (void)tapAction {
if (self.delegate && [self.delegate respondsToSelector:@selector(moveChatroom:)]) {
[self.delegate moveChatroom:self];
}
}
#pragma mark - gesture
- (void)handlePanGestureRecognizer:(UIPanGestureRecognizer*)gestureRecognizer {
CGPoint p = [gestureRecognizer locationInView:self.view.superview];
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
if (self.delegate && [self.delegate respondsToSelector:@selector(canMoveChatroom:)]) {
self.canMove = [self.delegate canMoveChatroom:self];
}
} else if (gestureRecognizer.state == UIGestureRecognizerStateChanged) {
if (self.canMove && self.delegate && [self.delegate respondsToSelector:@selector(moveChatroom:toPointY:)]) {
[self.delegate moveChatroom:self toPointY:p.y - self.lastPoint.y];
}
} else {
if (self.canMove) {
self.canMove = NO;
[self tapAction];
}
}
self.lastPoint = p;
}
#pragma mark - Public methods
- (void)addPageWithTitle:(NSString *)title controller:(UIViewController *)controller {
if (title && controller) {
[self.titles addObject:title];
[self.controllers addObject:controller];
[self.titleCollectionView reloadData];
}
}
- (void)insertPageWithTitle:(NSString *)title controller:(UIViewController *)controller atIndex:(NSUInteger)index {
if (title && controller) {
if (index > self.titles.count) {
index = self.titles.count;
}
[self.titles insertObject:title atIndex:index];
[self.controllers insertObject:controller atIndex:index];
[self.titleCollectionView reloadData];
}
}
- (void)removePageAtIndex:(NSUInteger)index {
if (index < self.titles.count) {
[self.titles removeObjectAtIndex:index];
[self.controllers removeObjectAtIndex:index];
[self.titleCollectionView reloadData];
}
}
- (void)scrollEnable:(BOOL)enable {
dispatch_async(dispatch_get_main_queue(), ^{
UIScrollView *scrollView;
for(id subview in self.pageViewController.view.subviews) {
if([subview isKindOfClass:UIScrollView.class]) {
scrollView=subview;
break;
}
}
scrollView.scrollEnabled = enable;
});
}
#pragma mark - Life Cycle
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor colorWithWhite:31.0 / 255.0 alpha:1.0];
self.topLineView = [[UIView alloc] initWithFrame:CGRectMake(0, self.barHeight - 1, kWidth, 1)];
self.topLineView.backgroundColor = [UIColor colorWithRed:243.0/255.0 green:243.0/255.0 blue:244.0/255.0 alpha:1.0];
[self.view addSubview:self.topLineView];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - <UICollectionViewDataSource>
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.titles.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
FTTitleViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:TitleCellIdentifier forIndexPath:indexPath];
cell.titleLabel.text = self.titles[indexPath.item];
[cell setClicked:[indexPath compare:_selectedIndexPath]==NSOrderedSame];
return cell;
}
#pragma mark - <UICollectionViewLayout>
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
return 0;
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake([FTTitleViewCell cellWidth], collectionView.frame.size.height);
}
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
return UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0);
}
#pragma mark - <UICollectionViewDeleaget>
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
if ([indexPath compare:_selectedIndexPath] == NSOrderedSame) {
return;
}
_selectedIndexPath = indexPath;
[collectionView reloadData];
FTTitleViewCell *cell = (FTTitleViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
[cell setClicked:YES];
// 跳转到指定页面
NSArray *showController = @[self.controllers[indexPath.item]];
[self.pageViewController setViewControllers:showController direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:^(BOOL finished) {
//NSLog(@"setViewControllers finished."); // first low
}];
[collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES];
}
-(void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath {
FTTitleViewCell *cell = (FTTitleViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
[cell setClicked:NO];
}
#pragma mark - <UIPageViewControllerDataSource>
-(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {
NSUInteger index = [self indexOfViewController:viewController];
if (index == NSNotFound ) {
return nil;
}
if (index == 0 && self.circulation) {
return [self viewControllerAtIndex:(self.controllers.count-1)];
}
index --;
return [self viewControllerAtIndex:index];
}
-(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {
NSUInteger index = [self indexOfViewController:viewController];
if (index == NSNotFound ) {
return nil;
}
index ++;
if (index == self.controllers.count && self.circulation) {
return [self viewControllerAtIndex:0];
}
if (index > self.controllers.count) {
return nil;
}
return [self viewControllerAtIndex:index];
}
#pragma mark - <UIPageViewControllerDelegate>
-(void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray *)pendingViewControllers {
NSUInteger index = [self indexOfViewController:pendingViewControllers.firstObject];
self.nextIndex = index;
}
-(void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed {
if (completed) {
NSUInteger index = [self indexOfViewController:previousViewControllers.firstObject];
if (index != self.nextIndex) {
[self deselectTitle:index];
[self selectedTitle:self.nextIndex];
}
}
}
#pragma mark - Private methods
// 选择标题(视图加载之后设置)
-(void)selectedTitle:(NSUInteger)index {
_selectedIndexPath = [NSIndexPath indexPathForItem:index inSection:0];
[self.titleCollectionView selectItemAtIndexPath:_selectedIndexPath animated:NO scrollPosition:UICollectionViewScrollPositionCenteredHorizontally];
FTTitleViewCell *cell = (FTTitleViewCell *)[self.titleCollectionView cellForItemAtIndexPath:_selectedIndexPath];
[cell setClicked:YES];
}
// 取消选择的标题
-(void)deselectTitle:(NSUInteger)index {
NSIndexPath *deselectedPath = [NSIndexPath indexPathForItem:index inSection:0];
[self.titleCollectionView deselectItemAtIndexPath:deselectedPath animated:NO];
FTTitleViewCell *cell = (FTTitleViewCell *)[self.titleCollectionView cellForItemAtIndexPath:deselectedPath];
[cell setClicked:NO];
}
-(UIViewController *)viewControllerAtIndex:(NSUInteger)index {
if (index == NSNotFound || index >=self.controllers.count ) {
return nil;
}
return self.controllers[index];
}
-(NSUInteger)indexOfViewController:(UIViewController *)viewController {
return [self.controllers indexOfObject:viewController];
}
@end
//
// FTTitleViewCell.h
// FTPageController
//
// Created by ftao on 04/01/2018.
// Copyright © 2018 easefun. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface FTTitleViewCell : UICollectionViewCell
@property (nonatomic, assign) BOOL clicked;
@property (strong, nonatomic) UILabel *titleLabel;
@property (strong, nonatomic) UIView *indicatorView;
+ (CGFloat)cellWidth;
@end
//
// FTTitleViewCell.m
// FTPageController
//
// Created by ftao on 04/01/2018.
// Copyright © 2018 easefun. All rights reserved.
//
#import "FTTitleViewCell.h"
@implementation FTTitleViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
self.clicked = NO;
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
CGFloat width = frame.size.width;
CGFloat height = frame.size.height;
_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, -5, width, height)];
_titleLabel.textColor = [UIColor darkGrayColor];
_titleLabel.font = [UIFont boldSystemFontOfSize:16];
_titleLabel.textAlignment = NSTextAlignmentCenter;
_titleLabel.numberOfLines = 1;
[self addSubview:_titleLabel];
float indicatorViewW = 32.0;
float indicatorViewH = 3.0;
_indicatorView = [[UIView alloc] initWithFrame:CGRectMake((width - indicatorViewW) / 2.0, height - indicatorViewH, indicatorViewW, indicatorViewH)];
_indicatorView.backgroundColor = [UIColor colorWithRed:33/255.0 green:150/255.0 blue:243/255.0 alpha:1.0];
[self addSubview:_indicatorView];
_indicatorView.hidden = YES;
_indicatorView.layer.cornerRadius = 1.5;
_indicatorView.layer.masksToBounds = YES;
}
return self;
}
- (void)setClicked:(BOOL)clicked {
_clicked = clicked;
_indicatorView.hidden = !clicked;
_titleLabel.textColor = clicked ? [UIColor colorWithRed:33/255.0 green:150/255.0 blue:243/255.0 alpha:1.0] : [UIColor darkGrayColor];
}
+ (CGFloat)cellWidth {
return 90.0;
}
@end
//
// PLVEmotionModel.h
// BCKeyBoardDemo
//
// Created by ftao on 2017/1/13.
// Copyright © 2017年 io.hzlzh.yunshouyi. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface PLVEmojiModel : NSObject
// emoji 符号(字符串)
@property (nonatomic, copy) NSString *text;
// emoji 图片名称
@property (nonatomic, copy) NSString *imagePNG;
/**
生成一个表情模型
*/
+ (instancetype)modelWithDictionary:(NSDictionary *)data;
@end
@interface PLVEmojiManager : NSObject
/// 表情字典数据
@property (nonatomic) NSMutableDictionary *emotionDictionary;
/// 表情模型数据
@property (nonatomic) NSMutableArray<PLVEmojiModel *> *allEmojiModels;
/**
获取单例emoji管理者
*/
+ (instancetype)sharedManager;
/**
获取emoji名称的图片
@param pngName emoji名称
@return emoji图片
*/
- (UIImage *)imageForEmotionPNGName:(NSString *)pngName;
/**
将表情文本转为属性字符串
@param text 表情文本
@param font 文本d大小
@return 属性字符串
*/
- (NSMutableAttributedString *)convertTextEmotionToAttachment:(NSString *)text font:(UIFont *)font;
/**
将已进行过格式处理的 NSMutableAttributedString 类型的表情文本转为属性字符串
@param attributeString 表情文本
@param font 文本d大小
@return 属性字符串
*/
- (NSMutableAttributedString *)convertTextEmotionToAttachmentWithAttributedString:(NSMutableAttributedString *)attributeString
font:(UIFont *)font;
@end
//
// PLVEmotionModel.m
// BCKeyBoardDemo
//
// Created by ftao on 2017/1/13.
// Copyright © 2017年 io.hzlzh.yunshouyi. All rights reserved.
//
#import "PLVEmojiManager.h"
#define CREATE_SHARED_MANAGER(CLASS_NAME) \
+ (instancetype)sharedManager { \
static CLASS_NAME *_instance; \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
_instance = [[CLASS_NAME alloc] init]; \
}); \
\
return _instance; \
}
@implementation PLVEmojiModel
+ (instancetype)modelWithDictionary:(NSDictionary *)data {
PLVEmojiModel *model = [PLVEmojiModel new];
model.text = [NSString stringWithFormat:@"[%@]",data[@"text"]];
model.imagePNG = data[@"image"];
return model;
}
@end
@interface PLVEmojiManager ()
@property (nonatomic, strong) NSBundle *emotionBundle;
@property (nonatomic, strong) NSRegularExpression *regularExpression;
@end
@implementation PLVEmojiManager
CREATE_SHARED_MANAGER(PLVEmojiManager)
- (NSBundle *)emotionBundle {
if (!_emotionBundle) {
_emotionBundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"Emotion" ofType:@"bundle"]];
}
return _emotionBundle;
}
- (NSRegularExpression *)regularExpression {
if (!_regularExpression) {
_regularExpression = [NSRegularExpression regularExpressionWithPattern:@"\\[[^\\[]{1,5}\\]" options:kNilOptions error:nil];
}
return _regularExpression;
}
- (NSMutableArray<PLVEmojiModel *> *)allEmojiModels {
if (!_allEmojiModels) {
[self loadEmotions];
}
return _allEmojiModels;
}
- (NSMutableDictionary *)emotionDictionary {
if (!_emotionDictionary) {
[self loadEmotions];
}
return _emotionDictionary;
}
#pragma mark - public
- (UIImage *)imageForEmotionPNGName:(NSString *)pngName {
return [UIImage imageNamed:pngName inBundle:self.emotionBundle compatibleWithTraitCollection:nil];
}
- (NSMutableAttributedString *)convertTextEmotionToAttachment:(NSString *)text font:(UIFont *)font {
NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:text attributes:@{NSFontAttributeName:font}];
return [self convertTextEmotionToAttachmentWithAttributedString:attributeString font:font];
}
- (NSMutableAttributedString *)convertTextEmotionToAttachmentWithAttributedString:(NSMutableAttributedString *)attributeString
font:(UIFont *)font {
NSArray<NSTextCheckingResult *> *matchArray = [self.regularExpression matchesInString:attributeString.string options:kNilOptions range:NSMakeRange(0, attributeString.length)];
NSUInteger offset = 0;
for (NSTextCheckingResult *result in matchArray) {
NSRange range = NSMakeRange(result.range.location - offset, result.range.length);
NSTextAttachment *attachMent = [[NSTextAttachment alloc] init];
NSString *imageText = [attributeString.string substringWithRange:NSMakeRange(range.location, range.length)];
NSString *imageName = self.emotionDictionary[imageText];
UIImage *image = [self imageForEmotionPNGName:imageName];
attachMent.image = image;
attachMent.bounds = CGRectMake(0, font.descender, font.lineHeight, font.lineHeight);
NSAttributedString *emojiAttrStr = [NSAttributedString attributedStringWithAttachment:attachMent];
[attributeString replaceCharactersInRange:range withAttributedString:emojiAttrStr];
offset += result.range.length - emojiAttrStr.length;
}
return attributeString;
}
#pragma mark - private
- (void)loadEmotions {
self.allEmojiModels = [NSMutableArray array];
self.emotionDictionary = [NSMutableDictionary dictionary];
NSString *path = [[NSBundle mainBundle] pathForResource:@"Emotions" ofType:@"plist"];
NSArray<NSDictionary *> *groups = [NSArray arrayWithContentsOfFile:path]; // 获取plist文件内容
for (NSDictionary *group in groups) {
if ([group[@"type"] isEqualToString:@"emoji"]) {
NSArray<NSDictionary *> *items = group[@"items"];
for (NSDictionary *item in items) {
PLVEmojiModel *model = [PLVEmojiModel modelWithDictionary:item];
[self.allEmojiModels addObject:model];
self.emotionDictionary[model.text] = model.imagePNG;
}
}
}
}
@end
/************************************************************
* * EaseMob CONFIDENTIAL
* __________________
* Copyright (C) 2013-2014 EaseMob Technologies. All rights reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of EaseMob Technologies.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from EaseMob Technologies.
*/
#import <UIKit/UIKit.h>
#import "PLVFacialView.h"
@protocol DXFaceDelegate <FacialViewDelegate>
@required
// 选择表情
- (void)selectedEmoji:(PLVEmojiModel *)emojiModel;
// 删除事件
- (void)deleteEvent;
- (void)sendEvent;
@end
@interface PLVFaceView : UIView <FacialViewDelegate>
@property (nonatomic, weak) id<DXFaceDelegate> delegate;
- (BOOL)stringIsFace:(NSString *)string;
- (void)sendBtnEnable:(BOOL)enable;
@end
/************************************************************
* * EaseMob CONFIDENTIAL
* __________________
* Copyright (C) 2013-2014 EaseMob Technologies. All rights reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of EaseMob Technologies.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from EaseMob Technologies.
*/
#import "PLVFaceView.h"
@interface PLVFaceView ()
{
PLVFacialView *_facialView;
}
@end
@implementation PLVFaceView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor whiteColor];
_facialView = [[PLVFacialView alloc] initWithFrame: CGRectMake(5, 5, frame.size.width - 10, 190.0)];
[_facialView loadFacialView:1 size:CGSizeMake(30, 30)];
_facialView.delegate = self;
[self addSubview:_facialView];
}
return self;
}
- (void)sendBtnEnable:(BOOL)enable {
[_facialView sendBtnEnable:enable];
}
#pragma mark - FacialViewDelegate
- (void)selectedFacialView:(PLVEmojiModel *)emojiModel{
if (_delegate) {
[_delegate selectedEmoji:emojiModel];
}
}
- (void)deleteEmoji {
if (_delegate) {
[_delegate deleteEvent];
}
}
- (void)send {
if (self.delegate) {
[self.delegate sendEvent];
}
}
#pragma mark - public
- (BOOL)stringIsFace:(NSString *)string
{
if ([_facialView.faces containsObject:string]) {
return YES;
}
return NO;
}
@end
/************************************************************
* * EaseMob CONFIDENTIAL
* __________________
* Copyright (C) 2013-2014 EaseMob Technologies. All rights reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of EaseMob Technologies.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from EaseMob Technologies.
*/
#import <UIKit/UIKit.h>
#import "PLVEmojiManager.h"
@protocol FacialViewDelegate
@optional
- (void)selectedFacialView:(PLVEmojiModel *)emojiModel;
- (void)deleteEmoji;
- (void)send;
@end
@interface PLVFacialView : UIView
@property(nonatomic) id<FacialViewDelegate> delegate;
@property(strong, nonatomic, readonly) NSArray *faces;
-(void)loadFacialView:(int)page size:(CGSize)size;
- (void)sendBtnEnable:(BOOL)enable;
@end
/************************************************************
* * EaseMob CONFIDENTIAL
* __________________
* Copyright (C) 2013-2014 EaseMob Technologies. All rights reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of EaseMob Technologies.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from EaseMob Technologies.
*/
#import "PLVFacialView.h"
#import "PLVKeyboardTool.h"
@interface PLVFacialView ()
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) UIButton *sendBtn;
@property (nonatomic, strong) NSTimer *timer;
@end
@implementation PLVFacialView {
NSArray *_faces;
}
#pragma mark - Rewrite
- (UIScrollView *)scrollView {
if (!_scrollView) {
_scrollView = [[UIScrollView alloc] init];
[self addSubview:_scrollView];
_scrollView.frame = CGRectMake(0.0, 0.0, self.bounds.size.width * 6.0 / 7.0, self.bounds.size.height);
_scrollView.contentSize = CGSizeMake(CGRectGetWidth(self.scrollView.bounds) * 4.0, CGRectGetHeight(self.scrollView.bounds));
_scrollView.pagingEnabled = YES;
}
return _scrollView;
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_faces = [PLVEmojiManager sharedManager].allEmojiModels;
}
return self;
}
#pragma mark - Public
-(void)loadFacialView:(int)page size:(CGSize)size {
int maxRow = 5;
int maxCol = 6;
CGFloat itemWidth = self.scrollView.bounds.size.width / maxCol;
CGFloat itemHeight = self.scrollView.bounds.size.height / maxRow;
for (int index = 0, row = 0; index < [_faces count]; row++) {
int page = row / maxRow;
CGFloat addtionWidth = page * CGRectGetWidth(self.scrollView.bounds);
int decreaseRow = page * maxRow;
for (int col = 0; col < maxCol; col++, index ++) {
if (index < [_faces count]) {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[self.scrollView addSubview:button];
[button setBackgroundColor:[UIColor clearColor]];
[button setFrame:CGRectMake(col * itemWidth + addtionWidth, (row-decreaseRow) * itemHeight, itemWidth, itemHeight)];
button.showsTouchWhenHighlighted = YES;
button.tag = index;
[button addTarget:self action:@selector(selected:) forControlEvents:UIControlEventTouchUpInside];
PLVEmojiModel *emojiModel = [_faces objectAtIndex:index];
[button setImage:[[PLVEmojiManager sharedManager] imageForEmotionPNGName:emojiModel.imagePNG] forState:UIControlStateNormal];
} else {
break;
}
}
}
UIButton *delBtn = [UIButton buttonWithType:UIButtonTypeCustom];
delBtn.layer.cornerRadius = 5.0;
delBtn.backgroundColor = [UIColor colorWithRed:234.0 / 255.0 green:234.0/ 255.0 blue:234.0/ 255.0 alpha:1.0];
delBtn.frame = CGRectMake(self.scrollView.frame.origin.x + self.scrollView.frame.size.width, 5.0, itemWidth - 5.0, itemHeight - 5.0);
[delBtn setImage:[PLVKeyboardTool getImageWithImageName:@"plv_backspace"] forState:UIControlStateNormal];
[delBtn addTarget:self action:@selector(delBtnTouchBegin:)forControlEvents:UIControlEventTouchDown];
[delBtn addTarget:self action:@selector(delBtnTouchEnd:)forControlEvents:UIControlEventTouchUpInside];
[delBtn addTarget:self action:@selector(delBtnTouchEnd:)forControlEvents:UIControlEventTouchUpOutside];
[self addSubview:delBtn];
self.sendBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.sendBtn.layer.cornerRadius = 5.0;
self.sendBtn.enabled = NO;
self.sendBtn.backgroundColor = [UIColor colorWithRed:234.0 / 255.0 green:234.0/ 255.0 blue:234.0/ 255.0 alpha:1.0];
self.sendBtn.frame = CGRectMake(delBtn.frame.origin.x, delBtn.frame.origin.y + delBtn.frame.size.height + 10.0, itemWidth - 5.0, itemHeight * 4.0 - 15.0);
[self.sendBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[self.sendBtn setTitleColor:[UIColor colorWithRed:123.0 / 255.0 green:128.0/ 255.0 blue:135.0/ 255.0 alpha:1.0] forState:UIControlStateDisabled];
[self.sendBtn setTitle:@"发送" forState:UIControlStateNormal];
[self.sendBtn addTarget:self action:@selector(sendAction:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:self.sendBtn];
}
- (void)sendBtnEnable:(BOOL)enable {
self.sendBtn.enabled = enable;
if (enable) {
self.sendBtn.backgroundColor = [UIColor colorWithRed:43.0/ 255.0 green:152.0/ 255.0 blue:240.0/ 255.0 alpha:1.0];
} else {
self.sendBtn.backgroundColor = [UIColor colorWithRed:234.0 / 255.0 green:234.0/ 255.0 blue:234.0/ 255.0 alpha:1.0];
}
}
#pragma mark - Actions
- (void)delBtnTouchBegin:(id)sender {
self.timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(handleTimer:) userInfo:nil repeats:YES];
[self.timer fire];
}
- (void)delBtnTouchEnd:(id)sender {
[self.timer invalidate];
self.timer = nil;
}
- (void)handleTimer:(id)sender {
if (_delegate) {
[_delegate deleteEmoji];
}
}
- (void)sendAction:(UIButton *)sender {
if (self.delegate) {
[self.delegate send];
}
}
-(void)selected:(UIButton *)bt {
if (_delegate) {
[_delegate selectedFacialView:[_faces objectAtIndex:bt.tag]];
}
}
@end
//
// PLVKeyboardMoreView.h
// PolyvCloudClassDemo
//
// Created by zykhbl on 2018/11/29.
// Copyright © 2018 polyv. All rights reserved.
//
#import <UIKit/UIKit.h>
@protocol PLVKeyboardMoreViewDelegate;
@interface PLVKeyboardMoreView : UIView
@property (nonatomic, weak) id<PLVKeyboardMoreViewDelegate> delegate;
/// 是否允许发送图片 默认NO;YES-显示发图按钮,NO-隐藏发图按钮
@property (nonatomic, assign) BOOL viewerSendImgEnabled;
/// 是否显示公告按钮
@property (nonatomic, assign) BOOL enabelBulletin;
- (void)reloadDate;
@end
@protocol PLVKeyboardMoreViewDelegate <NSObject>
- (void)openAlbum:(PLVKeyboardMoreView *)moreView;
- (void)shoot:(PLVKeyboardMoreView *)moreView;
- (void)readBulletin:(PLVKeyboardMoreView *)moreView;
- (void)onlyTeacher:(PLVKeyboardMoreView *)moreView on:(BOOL)on;
@end
//
// PLVKeyboardMoreView.m
// PolyvCloudClassDemo
//
// Created by zykhbl on 2018/11/29.
// Copyright © 2018 polyv. All rights reserved.
//
#import "PLVKeyboardMoreView.h"
#import "PLVKeyboardTool.h"
#define PLVMoreCollectionViewCellIdentifier @"PLVMoreCollectionViewCellIdentifier"
#define CellWidth 54.0
#define CellHeight 74.0
#define NumberOfItemsInSection 1
@interface PLVMoreCollectionViewCell : UICollectionViewCell
@property (nonatomic, strong) UIButton *moreBtn;
- (void)changeTitleStyle;
@end
@implementation PLVMoreCollectionViewCell
#pragma mark - life cycle
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.moreBtn.frame = CGRectMake(0.0, 0.0, CellWidth, CellHeight);
self.moreBtn.titleLabel.font = [UIFont systemFontOfSize:12.0];
[self.moreBtn setTitleColor:[UIColor colorWithRed:130.0 /255.0 green:130.0 /255.0 blue:130.0 /255.0 alpha:1.0] forState:UIControlStateNormal];
[self addSubview:self.moreBtn];
}
return self;
}
#pragma mark - public
- (void)changeTitleStyle {
self.moreBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[self.moreBtn setImageEdgeInsets:UIEdgeInsetsMake(-20.0, 0.0, 0.0, 0.0)];
[self.moreBtn setTitleEdgeInsets:UIEdgeInsetsMake(55.0, -CellWidth, 0.0, 0.0)];
}
@end
@interface PLVKeyboardMoreView () <UICollectionViewDataSource, UICollectionViewDelegate>
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) UICollectionViewFlowLayout *flowLayout;
@property (nonatomic, strong) UIButton * onlyTearchButton;
@end
@implementation PLVKeyboardMoreView
#pragma mark - life cycle
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor whiteColor];
self.flowLayout = [[UICollectionViewFlowLayout alloc] init];
self.flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
self.flowLayout.itemSize = CGSizeMake(CellWidth, CellHeight);
float totalWidth = CellWidth * 4;
float totalPadding = [UIScreen mainScreen].bounds.size.width - totalWidth;
float paddingScale = totalPadding / 159.0;
float padding = 15.9 * paddingScale;
self.flowLayout.sectionInset = UIEdgeInsetsMake(15.9, padding, 15.9, padding);
self.collectionView = [[UICollectionView alloc] initWithFrame:self.bounds collectionViewLayout:self.flowLayout];
[self.collectionView registerClass:[PLVMoreCollectionViewCell class] forCellWithReuseIdentifier:PLVMoreCollectionViewCellIdentifier];
self.collectionView.backgroundColor = [UIColor clearColor];
self.collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.collectionView.dataSource = self;
self.collectionView.delegate = self;
self.collectionView.showsHorizontalScrollIndicator = NO;
self.collectionView.showsVerticalScrollIndicator = NO;
[self addSubview:self.collectionView];
}
return self;
}
#pragma mark - UICollectionViewDataSource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView*)collectionView {
NSUInteger number = 1;
if (self.viewerSendImgEnabled)
number += 2;
if (self.enabelBulletin)
number += 1;
return number;
}
- (NSInteger)collectionView:(UICollectionView*)collectionView numberOfItemsInSection:(NSInteger)section {
return 1;
}
- (__kindof UICollectionViewCell*)collectionView:(UICollectionView*)collectionView cellForItemAtIndexPath:(NSIndexPath*)indexPath {
PLVMoreCollectionViewCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:PLVMoreCollectionViewCellIdentifier forIndexPath:indexPath];
NSInteger index = indexPath.row + indexPath.section * NumberOfItemsInSection;
if (self.viewerSendImgEnabled) {
if (index == 0) {
[cell.moreBtn setImage:[PLVKeyboardTool getImageWithImageName:@"plv_album.png"] forState:UIControlStateNormal];
[cell.moreBtn setTitle:@"照片" forState:UIControlStateNormal];
[cell.moreBtn addTarget:self action:@selector(openAlbum:) forControlEvents:UIControlEventTouchUpInside];
} else if (index == 1) {
[cell.moreBtn setImage:[PLVKeyboardTool getImageWithImageName:@"plv_shoot.png"] forState:UIControlStateNormal];
[cell.moreBtn setTitle:@"拍摄" forState:UIControlStateNormal];
[cell.moreBtn addTarget:self action:@selector(shoot:) forControlEvents:UIControlEventTouchUpInside];
}else if (index == 2) {
[cell.moreBtn setImage:[PLVKeyboardTool getImageWithImageName:@"plv_notice.png"] forState:UIControlStateNormal];
[cell.moreBtn setTitle:@"公告" forState:UIControlStateNormal];
[cell.moreBtn addTarget:self action:@selector(readBulletin:) forControlEvents:UIControlEventTouchUpInside];
}else if (index == 3) {
[cell.moreBtn setImage:[PLVKeyboardTool getImageWithImageName:@"plv_input_user_normal"] forState:UIControlStateNormal];
[cell.moreBtn setImage:[PLVKeyboardTool getImageWithImageName:@"plv_input_user_select"] forState:UIControlStateSelected];
[cell.moreBtn setTitle:@"只看讲师" forState:UIControlStateNormal];
[cell.moreBtn addTarget:self action:@selector(onlyTeacher:) forControlEvents:UIControlEventTouchUpInside];
self.onlyTearchButton = cell.moreBtn;
}
} else if (self.enabelBulletin) {
if (index == 0) {
[cell.moreBtn setImage:[PLVKeyboardTool getImageWithImageName:@"plv_notice.png"] forState:UIControlStateNormal];
[cell.moreBtn setTitle:@"公告" forState:UIControlStateNormal];
[cell.moreBtn addTarget:self action:@selector(readBulletin:) forControlEvents:UIControlEventTouchUpInside];
}else if (index == 1) {
[cell.moreBtn setImage:[PLVKeyboardTool getImageWithImageName:@"plv_input_user_normal"] forState:UIControlStateNormal];
[cell.moreBtn setImage:[PLVKeyboardTool getImageWithImageName:@"plv_input_user_select"] forState:UIControlStateSelected];
[cell.moreBtn setTitle:@"只看讲师" forState:UIControlStateNormal];
[cell.moreBtn addTarget:self action:@selector(onlyTeacher:) forControlEvents:UIControlEventTouchUpInside];
self.onlyTearchButton = cell.moreBtn;
}
}
[cell changeTitleStyle];
return cell;
}
#pragma mark - Action
- (IBAction)openAlbum:(id)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(openAlbum:)]) {
[self.delegate openAlbum:self];
}
}
- (IBAction)shoot:(id)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(shoot:)]) {
[self.delegate shoot:self];
}
}
- (IBAction)readBulletin:(id)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(readBulletin:)]) {
[self.delegate readBulletin:self];
}
}
- (IBAction)onlyTeacher:(id)sender {
self.onlyTearchButton.selected = !self.onlyTearchButton.selected;
if (self.delegate && [self.delegate respondsToSelector:@selector(onlyTeacher:on:)]) {
[self.delegate onlyTeacher:self on:self.onlyTearchButton.selected];
}
}
#pragma mark - UICollectionViewDelegateFlowLayout
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
CGSize size = CGSizeMake(0.0, self.collectionView.bounds.size.height);
if (section == 0) {
size = CGSizeMake(self.flowLayout.sectionInset.left, self.collectionView.bounds.size.height);
}
return size;
}
- (CGSize)collectionView:(UICollectionView*)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
CGSize size = CGSizeMake(0.0, self.collectionView.bounds.size.height);
return size;
}
#pragma mark - Public
- (void)reloadDate {
[self.collectionView reloadData];
}
@end
//
// PLVKeyboardTool.h
// PolyvCloudClassDemo
//
// Created by Lincal on 2020/5/19.
// Copyright © 2020 polyv. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface PLVKeyboardTool : NSObject
+ (UIImage *)getImageWithImageName:(NSString *)imageName;
@end
NS_ASSUME_NONNULL_END
//
// PLVKeyboardTool.m
// PolyvCloudClassDemo
//
// Created by Lincal on 2020/5/19.
// Copyright © 2020 polyv. All rights reserved.
//
#import "PLVKeyboardTool.h"
@implementation PLVKeyboardTool
+ (UIImage *)getImageWithImageName:(NSString *)imageName{
UIImage * img;
if (imageName && [imageName isKindOfClass:NSString.class] && imageName.length > 0) {
NSString * bundlePath = [[NSBundle bundleForClass:[self class]].resourcePath stringByAppendingPathComponent:@"/PLVKeyboardSkin.bundle"];
NSBundle * bundle = [NSBundle bundleWithPath:bundlePath];
img = [UIImage imageNamed:imageName inBundle:bundle compatibleWithTraitCollection:nil];
}
return img;
}
@end
//
// PLVTextInputView.h
// PolyvCloudClassDemo
//
// Created by zykhbl on 2018/9/7.
// Copyright © 2018年 polyv. All rights reserved.
//
#import <UIKit/UIKit.h>
#define TEXT_MAX_COUNT 200
/// 键盘类型
typedef NS_ENUM(NSInteger, PLVTextInputViewType) {
/// 普通公聊类型
PLVTextInputViewTypeNormalPublic = 1,
/// 云课堂公聊类型
PLVTextInputViewTypeCloudClassPublic = 2,
/// 私聊/咨询提问类型
PLVTextInputViewTypePrivate = 3,
/// 直播回放类型
PLVTextInputViewTypePlayback = 4
};
/// 键盘状态
typedef NS_ENUM(NSInteger, PLVTextInputViewState) {
/// 正常状态
PLVTextInputViewStateNormal,
/// 系统键盘
PLVTextInputViewStateSystem,
/// 表情键盘
PLVTextInputViewStateEmoji,
/// 显示更多
PLVTextInputViewStateMore,
};
@protocol PLVTextInputViewDelegate;
@interface PLVTextInputView : UIView
@property (nonatomic, weak) id<PLVTextInputViewDelegate> delegate;
/// 键盘弹出时,输入控件加载在整个APP的主窗口上
@property (nonatomic, weak) UIView *tapSuperView;
/// 连麦时,外层需要调整吧输入控件frame的Y坐标
@property (nonatomic, assign) CGFloat originY;
/// 连麦时,外层改变输入控件的frame时,需要判断输入控件是否是up的弹出状态
@property (nonatomic, assign) BOOL up;
/// 是否展示礼物打赏按钮,默认NO
@property (nonatomic, assign) BOOL showGiftButton;
/// 是否隐藏送花按钮,默认NO
@property (nonatomic, assign) BOOL hideFlowerButton;
/// 键盘类型
@property (nonatomic, assign) PLVTextInputViewType type;
/// 键盘状态
@property (nonatomic, assign) PLVTextInputViewState inputState;
/// 只看讲师模式禁止其他按钮交互
@property (nonatomic, assign) BOOL disableOtherButtonsInTeacherMode;
/**
加载视图
@param type 键盘模式
@param enableMore 显示更多按钮
*/
- (void)loadViews:(PLVTextInputViewType)type enableMore:(BOOL)enableMore;
/**
隐藏键盘
*/
- (void)tapAction;
/**
释放资源,退出前调用
*/
- (void)clearResource;
@end
@protocol PLVTextInputViewDelegate <NSObject>
@optional
- (BOOL)textInputViewShouldBeginEditing:(PLVTextInputView *)inputView;
- (void)textInputView:(PLVTextInputView *)inputView followKeyboardAnimation:(BOOL)flag;
- (void)textInputView:(PLVTextInputView *)inputView didSendText:(NSString *)text;
- (void)sendFlower:(PLVTextInputView *)inputView;
- (void)textInputView:(PLVTextInputView *)inputView onlyTeacher:(BOOL)on;
- (void)textInputView:(PLVTextInputView *)inputView giftButtonClick:(BOOL)open;
- (void)openAlbum:(PLVTextInputView *)inputView;
- (void)shoot:(PLVTextInputView *)inputView;
- (void)readBulletin:(PLVTextInputView *)inputView;
@end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment