Commit aea4fd7dba98b52b3b5e104dddb8ca0dcc4698a9

Authored by 王军波
2 parents 1a6759d4 ebb60740

Merge branch 'master' of bj.gitlab.cnlive.com:ios-team/LiveVideoCloud

Showing 22 changed files with 704 additions and 272 deletions
LiveVideoCloud/LiveVideoCloud.xcodeproj/project.pbxproj
... ... @@ -141,7 +141,6 @@
141 141 D2029D091E6EAE2E0027CD92 /* Foundation+Log.m in Sources */ = {isa = PBXBuildFile; fileRef = D2029CF21E6EAE2E0027CD92 /* Foundation+Log.m */; };
142 142 D2029D0A1E6EAE2E0027CD92 /* ZXServerUrl.m in Sources */ = {isa = PBXBuildFile; fileRef = D2029CFE1E6EAE2E0027CD92 /* ZXServerUrl.m */; };
143 143 D2029D161E6EB00D0027CD92 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D2029D151E6EB00D0027CD92 /* AppDelegate.m */; };
144   - D207BE9E1E84BD68006A0CE8 /* BarrageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D207BE9D1E84BD68006A0CE8 /* BarrageManager.m */; };
145 144 D207BEA11E84C1EC006A0CE8 /* AnimationBaseView.m in Sources */ = {isa = PBXBuildFile; fileRef = D207BEA01E84C1EC006A0CE8 /* AnimationBaseView.m */; };
146 145 D217A24A1E7B76C7003B44CB /* PresentView.m in Sources */ = {isa = PBXBuildFile; fileRef = D217A2471E7B76C7003B44CB /* PresentView.m */; };
147 146 D217A24B1E7B76C7003B44CB /* PresentViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D217A2491E7B76C7003B44CB /* PresentViewCell.m */; };
... ... @@ -187,6 +186,7 @@
187 186 D2888DB11E6EC05F003A77C8 /* TempViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB01E6EC05F003A77C8 /* TempViewController.m */; };
188 187 D2888DB41E6EC154003A77C8 /* HomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB31E6EC154003A77C8 /* HomeViewController.m */; };
189 188 D2888DB71E6EC1B8003A77C8 /* LVCMyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB61E6EC1B8003A77C8 /* LVCMyViewController.m */; };
  189 + D29E81ED1E88DC5B008C9906 /* PriChatCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D29E81EC1E88DC5B008C9906 /* PriChatCell.m */; };
190 190 D29D88481E88C53300543A03 /* LVCUGCLivePrepareView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29D88471E88C53300543A03 /* LVCUGCLivePrepareView.m */; };
191 191 D2A089E81E89FA720071412C /* LVCUGCLivePlayerCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A089E71E89FA720071412C /* LVCUGCLivePlayerCell.m */; };
192 192 D2A803081E80BD6F009D6F1C /* TopToolView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A803071E80BD6F009D6F1C /* TopToolView.m */; };
... ... @@ -522,8 +522,6 @@
522 522 D2029CFF1E6EAE2E0027CD92 /* UtilKits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UtilKits.h; sourceTree = "<group>"; };
523 523 D2029D121E6EAF8D0027CD92 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
524 524 D2029D151E6EB00D0027CD92 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
525   - D207BE9C1E84BD68006A0CE8 /* BarrageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BarrageManager.h; sourceTree = "<group>"; };
526   - D207BE9D1E84BD68006A0CE8 /* BarrageManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BarrageManager.m; sourceTree = "<group>"; };
527 525 D207BE9F1E84C1EC006A0CE8 /* AnimationBaseView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationBaseView.h; sourceTree = "<group>"; };
528 526 D207BEA01E84C1EC006A0CE8 /* AnimationBaseView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnimationBaseView.m; sourceTree = "<group>"; };
529 527 D217A2451E7B76C7003B44CB /* PresentModelAble.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PresentModelAble.h; sourceTree = "<group>"; };
... ... @@ -610,6 +608,8 @@
610 608 D2888DB31E6EC154003A77C8 /* HomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeViewController.m; sourceTree = "<group>"; };
611 609 D2888DB51E6EC1B8003A77C8 /* LVCMyViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCMyViewController.h; sourceTree = "<group>"; };
612 610 D2888DB61E6EC1B8003A77C8 /* LVCMyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCMyViewController.m; sourceTree = "<group>"; };
  611 + D29E81EB1E88DC5B008C9906 /* PriChatCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PriChatCell.h; sourceTree = "<group>"; };
  612 + D29E81EC1E88DC5B008C9906 /* PriChatCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PriChatCell.m; sourceTree = "<group>"; };
613 613 D29D88461E88C53300543A03 /* LVCUGCLivePrepareView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLivePrepareView.h; sourceTree = "<group>"; };
614 614 D29D88471E88C53300543A03 /* LVCUGCLivePrepareView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCUGCLivePrepareView.m; sourceTree = "<group>"; };
615 615 D2A089E61E89FA720071412C /* LVCUGCLivePlayerCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCUGCLivePlayerCell.h; sourceTree = "<group>"; };
... ... @@ -1330,15 +1330,6 @@
1330 1330 path = AppDelegate;
1331 1331 sourceTree = "<group>";
1332 1332 };
1333   - D207BE9B1E84BD3E006A0CE8 /* BarrageManager */ = {
1334   - isa = PBXGroup;
1335   - children = (
1336   - D207BE9C1E84BD68006A0CE8 /* BarrageManager.h */,
1337   - D207BE9D1E84BD68006A0CE8 /* BarrageManager.m */,
1338   - );
1339   - path = BarrageManager;
1340   - sourceTree = "<group>";
1341   - };
1342 1333 D217A2441E7B76C7003B44CB /* Present */ = {
1343 1334 isa = PBXGroup;
1344 1335 children = (
... ... @@ -1365,7 +1356,6 @@
1365 1356 D22830F61E77C26C00627701 /* Chat */ = {
1366 1357 isa = PBXGroup;
1367 1358 children = (
1368   - D207BE9B1E84BD3E006A0CE8 /* BarrageManager */,
1369 1359 D2B7B24E1E8247B500ED084E /* ChatBarrageManager */,
1370 1360 D236968F1E7FC83800E4BF71 /* ChatMsgModel */,
1371 1361 D22830F71E77C27A00627701 /* ChatViews */,
... ... @@ -1432,6 +1422,8 @@
1432 1422 children = (
1433 1423 D24571611E83C40B00AA85D6 /* PrivateView.h */,
1434 1424 D24571621E83C40B00AA85D6 /* PrivateView.m */,
  1425 + D29E81EB1E88DC5B008C9906 /* PriChatCell.h */,
  1426 + D29E81EC1E88DC5B008C9906 /* PriChatCell.m */,
1435 1427 );
1436 1428 path = PrivateView;
1437 1429 sourceTree = "<group>";
... ... @@ -1903,6 +1895,7 @@
1903 1895 810B65061E779B1F00133E15 /* View+MASAdditions.m in Sources */,
1904 1896 D2029D161E6EB00D0027CD92 /* AppDelegate.m in Sources */,
1905 1897 D2029CB71E6EADE10027CD92 /* NSData+ImageContentType.m in Sources */,
  1898 + D29E81ED1E88DC5B008C9906 /* PriChatCell.m in Sources */,
1906 1899 D2029CD01E6EADE10027CD92 /* SearchPresenter.m in Sources */,
1907 1900 D2888DB71E6EC1B8003A77C8 /* LVCMyViewController.m in Sources */,
1908 1901 D2029CBE1E6EADE10027CD92 /* SDWebImagePrefetcher.m in Sources */,
... ... @@ -1995,7 +1988,6 @@
1995 1988 D217A24A1E7B76C7003B44CB /* PresentView.m in Sources */,
1996 1989 D22830F11E778C0F00627701 /* LiveBaseView.m in Sources */,
1997 1990 D2029CBA1E6EADE10027CD92 /* SDWebImageDecoder.m in Sources */,
1998   - D207BE9E1E84BD68006A0CE8 /* BarrageManager.m in Sources */,
1999 1991 8112D4311E7927A5002E00F6 /* LVCPlayerLoadingView.m in Sources */,
2000 1992 D2029D081E6EAE2E0027CD92 /* ZXDeviceInfo.m in Sources */,
2001 1993 D24571631E83C40B00AA85D6 /* PrivateView.m in Sources */,
... ...
LiveVideoCloud/LiveVideoCloud/AppDelegate/AppDelegate.m
... ... @@ -27,20 +27,20 @@
27 27  
28 28 //初始化聊天SDK并连接服务器
29 29 [[CNLiveChatManager sharedCNLiveChatManager] initWithAppKey:AppKey appId:AppId];
30   - [[CNLiveChatManager sharedCNLiveChatManager] connectServerSuccess:^{
31   - NSLog(@"连接服务器-----success");
  30 +// [[CNLiveChatManager sharedCNLiveChatManager] connectServerSuccess:^{
  31 +// NSLog(@"连接服务器-----success");
  32 +// } error:^(CNLiveChatConnectErrorCode errors) {
  33 +// NSLog(@"连接服务器失败-----%ld", errors);
  34 +// }];
  35 + // 20170327 20170328
  36 + CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:@"20170328" name:@"20170328" portrait:@""];
  37 + [[CNLiveChatManager sharedCNLiveChatManager] loginServer:userInfo success:^(NSString *userId) {
  38 + NSLog(@"连接服务器-----success");
  39 +
32 40 } error:^(CNLiveChatConnectErrorCode errors) {
33 41 NSLog(@"连接服务器失败-----%ld", errors);
34   - }];;
35   -
36   - [self.window makeKeyAndVisible];
37   -
38   - [[CNLiveChatManager sharedCNLiveChatManager] initWithAppKey:AppKey appId:AppId];
39   - [[CNLiveChatManager sharedCNLiveChatManager] connectServerSuccess:^{
40   - NSLog(@"connectSuccess");
41   - } error:^(CNLiveChatConnectErrorCode errors) {
42   - NSLog(@"errors%ld",errors);
43 42 }];
  43 + [self.window makeKeyAndVisible];
44 44  
45 45 return YES;
46 46 }
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/AnimationBaseView.m
... ... @@ -7,7 +7,7 @@
7 7 //
8 8  
9 9 #import "AnimationBaseView.h"
10   -#import "ChatBarrageView.h"
  10 +
11 11  
12 12 @implementation AnimationBaseView
13 13  
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/BounceView.m
... ... @@ -8,6 +8,7 @@
8 8  
9 9 #import "BounceView.h"
10 10 #import "userInfoModel.h"
  11 +#import "LiveBaseView.h"
11 12  
12 13 @interface BounceView ()
13 14  
... ... @@ -60,21 +61,24 @@
60 61 - (void)closeClick
61 62 {
62 63 [Tools closeBouces];
  64 + [[LiveBaseView liveBaseView] bounceBtnType:BounceBtnTypeHome model:_model];
63 65 }
64 66  
65 67 - (void)aiteHeBtnClick
66 68 {
67   - NSLog(@"aiteHeBtnClick");
  69 + [Tools closeBouces];
  70 + [[LiveBaseView liveBaseView] bounceBtnType:BounceBtnTypeAite model:_model];
68 71 }
69 72  
70 73 - (void)privateChatClick
71 74 {
72   - NSLog(@"privateChatClick");
  75 + [Tools closeBouces];
  76 + [[LiveBaseView liveBaseView] bounceBtnType:BounceBtnTypePriChat model:_model];
73 77 }
74 78  
75 79 - (void)homeBtnClick
76 80 {
77   - NSLog(@"homeBtnClick");
  81 + [Tools closeBouces];
78 82 }
79 83  
80 84 - (UIImageView *)icon
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/BarrageManager/BarrageManager.h deleted 100644 → 0
1   -//
2   -// BarrageManager.h
3   -// LiveVideoCloud
4   -//
5   -// Created by 张旭 on 2017/3/24.
6   -// Copyright © 2017年 cnlive. All rights reserved.
7   -//
8   -
9   -#import <Foundation/Foundation.h>
10   -@class chatMsgModel;
11   -@class ChatBarrageView;
12   -#import "AnimationBaseView.h"
13   -@interface BarrageManager : NSObject <TouchPointDelegate>
14   -
15   -/**
16   - 初始化管理类
17   - @return 当前manager
18   - */
19   -+ (instancetype)sharedManager;
20   -
21   -- (ChatBarrageView *)addAnimationWithModel:(chatMsgModel *)model animContentView:(UIView *)animContentView;
22   -
23   -@end
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/BarrageManager/BarrageManager.m deleted 100644 → 0
1   -//
2   -// BarrageManager.m
3   -// LiveVideoCloud
4   -//
5   -// Created by 张旭 on 2017/3/24.
6   -// Copyright © 2017年 cnlive. All rights reserved.
7   -//
8   -
9   -#import "BarrageManager.h"
10   -#import "chatMsgModel.h"
11   -#import "ChatBarrageView.h"
12   -
13   -@interface BarrageManager ()<CAAnimationDelegate>
14   -
15   -@property (nonatomic ,strong) NSTimer * _Nullable timer;
16   -@property (nonatomic ,strong) ChatBarrageView *_Nullable barrageView;
17   -@property (nonatomic ,strong) AnimationBaseView * _Nullable animBaseView;
18   -@property (nonatomic ,assign) CGRect barrCurrentRect;
19   -
20   -@end
21   -@implementation BarrageManager
22   -
23   -/**
24   - 初始化管理类
25   - @return 当前manager
26   - */
27   -+ (instancetype)sharedManager{
28   -
29   - static BarrageManager *manager;
30   -
31   - static dispatch_once_t onceToken;
32   - dispatch_once(&onceToken, ^{
33   - manager = [[BarrageManager alloc] init];
34   - });
35   - return manager;
36   -}
37   -
38   -//- (AnimationBaseView *)animBaseView
39   -//{
40   -// if (!_animBaseView)
41   -// {
42   -// _animBaseView = [[AnimationBaseView alloc] init];
43   -// }
44   -// return _animBaseView;
45   -//}
46   -
47   -/**
48   - 根据实际model添加动画
49   -
50   - @param model modelobj
51   - */
52   -- (ChatBarrageView *)addAnimationWithModel:(chatMsgModel *)model animContentView:(UIView *)animContentView
53   -{
54   - ChatBarrageView *barrageView = [ChatBarrageView barrageViewWithPoint:CGPointMake(SCREEN_WIDTH + 50, 100)];
55   - barrageView.backgroundColor = [UIColor blackColor];
56   - [animContentView addSubview:barrageView];
57   - self.barrageView = barrageView;
58   - self.animBaseView = (AnimationBaseView *)animContentView;
59   -
60   - barrageView.model = model;
61   -
62   - [self animationWithDuration:8
63   - YValues:@[ @(SCREEN_WIDTH + 50), @(-(200))]
64   - keyTimes:@[@0.0, @1.0]
65   - timingFunctions:@[
66   - [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear],
67   - ]
68   - addView:barrageView];
69   - [self createTimer];
70   - self.animBaseView.isBarrage = YES;
71   -
72   -// [UIView animateWithDuration:10 animations:^{
73   -//
74   -// barrageView.left = - 200;
75   -// } completion:^(BOOL finished) {
76   -// [self stopTimer];
77   -// [barrageView removeFromSuperview];
78   -// NSLog(@"finished");
79   -// }];
80   - return barrageView;
81   -}
82   -
83   -// 实时监测 ,也可以用循环定时器
84   -- (void)createTimer{
85   - if (!self.timer) {
86   - self.timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(jianCe) userInfo:nil repeats:YES];
87   - }
88   -}
89   -- (void) jianCe{
90   - CGRect rect = [[self.barrageView.layer presentationLayer ]frame]; // view指动画中移动的view
91   - self.barrCurrentRect = rect;
92   -// NSLog(@"箭%@",NSStringFromCGRect(rect));
93   -}
94   -
95   -- (void)stopTimer
96   -{
97   - if(self.timer)
98   - {
99   - [self.timer invalidate];
100   - self.timer = nil;
101   - }
102   -}
103   -
104   -#pragma mark - touchPointDelegate
105   -- (void)touchPoint:(CGPoint)touchPoint
106   -{
107   - CGFloat dxLeft = touchPoint.x - self.barrCurrentRect.origin.x;// >0
108   - CGFloat dxRight = touchPoint.x - self.barrCurrentRect.origin.x - self.barrCurrentRect.size.width;// < 0
109   - CGFloat dyLeft = touchPoint.y - self.barrCurrentRect.origin.y;// >0
110   - CGFloat dyRight = touchPoint.y - self.barrCurrentRect.origin.y - self.barrCurrentRect.size.height;// <0
111   -
112   - if (dxLeft > 0 && dxRight < 0 && dyLeft > 0 && dyRight < 0) {
113   - //在当前矩形区域内
114   -// NSLog(@"在当前矩形区域内");
115   - [self.barrageView barrageViewClickWithModel:self.barrageView.model];
116   - }else
117   - {
118   -// NSLog(@"不在当前矩形区域内");
119   - }
120   -}
121   -
122   -- (void)animationWithDuration:(float)duration YValues:(NSArray *)YValues keyTimes:(NSArray *)keyTimes timingFunctions:(NSArray *)timingFunctions addView:(UIView *)addView{
123   - CAKeyframeAnimation *rocketAnim = [CAKeyframeAnimation animation];
124   - rocketAnim.keyPath = @"position.x";
125   - rocketAnim.values = YValues;
126   - rocketAnim.keyTimes = keyTimes;
127   - rocketAnim.timingFunctions = timingFunctions;
128   - rocketAnim.duration = duration;
129   - rocketAnim.fillMode = kCAFillModeForwards;
130   - rocketAnim.removedOnCompletion = NO;
131   - rocketAnim.delegate = self;
132   - [addView.layer addAnimation:rocketAnim forKey:@"positionY"];
133   -}
134   -
135   -- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{
136   - NSLog(@"didStop");
137   - [self stopTimer];
138   - [self.barrageView removeFromSuperview];
139   - self.animBaseView.isBarrage = NO;
140   -}
141   -@end
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatBarrageManager/ChatBarrageView.h
... ... @@ -8,6 +8,7 @@
8 8  
9 9 #import "ChatBarrageAnimAction.h"
10 10  
  11 +
11 12 @class AnimationBaseView;
12 13 @class chatMsgModel;
13 14 @interface ChatBarrageView : ChatBarrageAnimAction
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatMsgModel/chatMsgModel.h
... ... @@ -21,4 +21,9 @@
21 21 @property (nonatomic) BOOL isMine;//消息是否是自己发送
22 22 @property (nonatomic ,copy) NSString * _Nullable ID;//唯一标识
23 23  
  24 +/////
  25 +@property (nonatomic ,assign) CGFloat priCellHeight;
  26 +@property (nonatomic ,assign) CGFloat priCellWidth;
  27 +
  28 +
24 29 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatMsgModel/chatMsgModel.m
... ... @@ -22,11 +22,29 @@
22 22 //文字
23 23 CGFloat textMaxW = self.cellWidth;
24 24 CGSize textMaxSize = CGSizeMake(textMaxW, MAXFLOAT);
25   - CGSize textSize = [content boundingRectWithSize:textMaxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14]} context:nil].size;
  25 + CGSize textSize = [content boundingRectWithSize:textMaxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:kContentFont]} context:nil].size;
26 26  
27 27 //底部空隙
28 28 _cellHeight += textSize.height + ChatCellMargin;
29 29 // NSLog(@"cellHeight = %f",_cellHeight);
30 30 return _cellHeight;
31 31 }
  32 +
  33 +- (CGFloat)priCellHeight
  34 +{
  35 + //如果计算过高度,直接返回
  36 + if (_priCellHeight) return _priCellHeight;
  37 +
  38 + _priCellHeight = 0;
  39 + NSString *content = self.content;
  40 + //文字
  41 + CGFloat textMaxW = self.priCellWidth;
  42 + CGSize textMaxSize = CGSizeMake(textMaxW, MAXFLOAT);
  43 + CGSize textSize = [content boundingRectWithSize:textMaxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:kContentFont]} context:nil].size;
  44 +
  45 + //底部空隙
  46 + _priCellHeight += textSize.height + 5;
  47 +// NSLog(@"pricellHeight = %f",_priCellHeight);
  48 + return _priCellHeight;
  49 +}
32 50 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/LVCInteractionController.m
... ... @@ -32,7 +32,7 @@
32 32 {
33 33 if (!_liveBaseView)
34 34 {
35   - _liveBaseView = [[LiveBaseView alloc] initWithFrame:SCREEN_RECT];
  35 + _liveBaseView = [LiveBaseView liveBaseView];
36 36 _liveBaseView.viewController = self;
37 37 _liveBaseView.backgroundColor = [UIColor clearColor];
38 38 }
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/LiveBaseView.h
... ... @@ -9,9 +9,20 @@
9 9 #import "BaseView.h"
10 10 @class PresentView;
11 11 @class AnimationBaseView;
  12 +
  13 +typedef NS_ENUM(NSInteger, BounceBtnType) {//弹窗按钮类型
  14 + BounceBtnTypeAite = 1,//@TA按钮点击
  15 + BounceBtnTypePriChat ,//私聊按钮点击
  16 + BounceBtnTypeHome ,//主页按钮点击
  17 +};
  18 +
12 19 @interface LiveBaseView : BaseView
13 20  
14 21 @property (nonatomic ,strong) UIViewController * _Nullable viewController;
15 22 @property (nonatomic ,strong ,readonly) PresentView * _Nullable presentView;
16 23 @property (nonatomic ,strong ,readonly) AnimationBaseView * _Nullable animationBaseView;
  24 +
  25 ++ (instancetype _Nullable)liveBaseView;
  26 +
  27 +- (void)bounceBtnType:(BounceBtnType)btnType model:(userInfoModel *_Nonnull)model;
17 28 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/LiveBaseView.m
... ... @@ -20,7 +20,6 @@
20 20 #import "ChatBarrageManager.h"
21 21 #import "userInfoModel.h"
22 22 #import "PrivateView.h"
23   -//#import "BarrageManager.h"
24 23 #import "ChatBarrageView.h"
25 24 #import "AnimationBaseView.h"
26 25  
... ... @@ -35,7 +34,7 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
35 34 PopTypePriMessage //私信弹窗
36 35 };
37 36  
38   -@interface LiveBaseView ()<bottomBtnDeledate,PresentViewDelegate,UIScrollViewDelegate,UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate,userClickDelegate,CNLiveChatManagerDelegate>
  37 +@interface LiveBaseView ()<bottomBtnDeledate,PresentViewDelegate,UIScrollViewDelegate,UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate,userClickDelegate,CNLiveChatManagerDelegate,PopViewDelegate>
39 38  
40 39 @property (nonatomic ,strong ) UIScrollView * _Nullable scrollView;
41 40 @property (nonatomic ,strong ,readwrite) AnimationBaseView * _Nullable animationBaseView;//展示层View
... ... @@ -53,14 +52,23 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
53 52 @property (nonatomic ,assign ) CGFloat offsetHeight;
54 53 @property (nonatomic ,strong ) UISwitch * _Nullable barrageSwitch;
55 54 @property (nonatomic ,strong ) ChatBarrageManager * _Nullable chatManager;
56   -//@property (nonatomic ,strong ) BarrageManager * _Nullable barrManager;
57   -
58 55 @property (nonatomic ,strong) ChatBarrageView * _Nullable barrageView;
59 56  
60 57 @end
61 58  
62 59 @implementation LiveBaseView
63 60  
  61 ++ (instancetype _Nullable)liveBaseView
  62 +{
  63 + static LiveBaseView *liveBaseView;
  64 +
  65 + static dispatch_once_t onceToken;
  66 + dispatch_once(&onceToken, ^{
  67 + liveBaseView = [[LiveBaseView alloc] initWithFrame:SCREEN_RECT];
  68 + });
  69 + return liveBaseView;
  70 +}
  71 +
64 72 - (instancetype)initWithFrame:(CGRect)frame
65 73 {
66 74 if (self = [super initWithFrame:frame]) {
... ... @@ -79,8 +87,8 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
79 87 self.chatTableView.alpha = 0.7;
80 88  
81 89 [self.animationBaseView addSubview:self.topToolsView];
82   - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
83   - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHidden:) name:UIKeyboardWillHideNotification object:nil];
  90 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:self];
  91 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHidden:) name:UIKeyboardWillHideNotification object:self];
84 92  
85 93 [CNLiveChatManager sharedCNLiveChatManager].delegate = self;
86 94 [[CNLiveChatManager sharedCNLiveChatManager] joinChatRoom:@"1234" messageCount:10 success:^(NSString *targetId) {
... ... @@ -95,22 +103,25 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
95 103 }
96 104  
97 105 - (void)keyboardWillShow:(NSNotification *)notify {
98   -
99   - NSDictionary *userInfo = notify.userInfo;
100   - CGRect newFrameKeyboard = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];//变化前的frame
101   - [UIView animateWithDuration:0.25 animations:^{
102   - self.animationBaseView.top = - newFrameKeyboard.size.height + self.bottomToolView.height;
103   - }];
104   - self.bottomToolView.hidden = YES;
  106 + if ([notify.object isKindOfClass:[LiveBaseView class]]) {
  107 +
  108 + NSDictionary *userInfo = notify.userInfo;
  109 + CGRect newFrameKeyboard = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];//变化前的frame
  110 + [UIView animateWithDuration:0.25 animations:^{
  111 + self.animationBaseView.top = - newFrameKeyboard.size.height + self.bottomToolView.height;
  112 + }];
  113 + self.bottomToolView.hidden = YES;
  114 + }
105 115 }
106 116  
107 117 - (void)keyboardWillHidden:(NSNotification *)notify {
108   -
109   - [UIView animateWithDuration:0.1 animations:^{
110   - self.animationBaseView.top = 0;
111   - [self.animationBaseView setNeedsDisplay];
112   - }];
113   - self.bottomToolView.hidden = NO;
  118 + if ([notify.object isKindOfClass:[LiveBaseView class]]) {
  119 + [UIView animateWithDuration:0.1 animations:^{
  120 + self.animationBaseView.top = 0;
  121 + [self.animationBaseView setNeedsDisplay];
  122 + }];
  123 + self.bottomToolView.hidden = NO;
  124 + }
114 125 }
115 126  
116 127 - (void)createCommentsView {
... ... @@ -211,9 +222,34 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
211 222 textField.text = @"";
212 223 }
213 224 [textField resignFirstResponder];
  225 +
214 226 return YES;
215 227 }
216 228  
  229 +- (void)bounceBtnType:(BounceBtnType)btnType model:(userInfoModel *_Nonnull)model
  230 +{
  231 + switch (btnType) {
  232 + case BounceBtnTypeAite:
  233 + {
  234 + [self bottomActionWithType:BtnClickTypeChat button:nil];
  235 + _commentText.text = [NSString stringWithFormat:@"@%@ ",model.name];
  236 + }
  237 + break;
  238 + case BounceBtnTypePriChat:
  239 + {
  240 + [self bottomActionWithType:BtnClickTypePriChat button:nil];
  241 + }
  242 + break;
  243 + case BounceBtnTypeHome:
  244 + {
  245 +
  246 + }
  247 + break;
  248 + default:
  249 + break;
  250 + }
  251 +}
  252 +
217 253 #pragma mark - bottomBtnActionDelegate
218 254 - (void)bottomActionWithType:(BtnClickType)btnType button:(UIButton *)button
219 255 {
... ... @@ -251,9 +287,15 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
251 287 - (void)showPrivateView
252 288 {
253 289 PrivateView *privateView = [PrivateView privateView];
254   - privateView.backgroundColor = [UIColor yellowColor];
  290 + privateView.backgroundColor = [UIColor whiteColor];
255 291 [self addSubview:privateView];
  292 + privateView.delegate = self;
256 293 self.giftPopView = privateView;
  294 + [UIView animateWithDuration:0.5 animations:^{
  295 + privateView.top -= 300;
  296 + } completion:^(BOOL finished) {
  297 +
  298 + }];
257 299 }
258 300  
259 301 - (void)hiddenView:(BOOL)isHidden
... ... @@ -288,12 +330,22 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
288 330 break;
289 331 case PopTypePriMessage:
290 332 {
291   - [UIView animateWithDuration:0.25 animations:^{
292   -
293   - self.giftPopView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT);
294   - [self hiddenView:NO];
295   - } completion:^(BOOL finished) {
296   - }];
  333 + if (((PrivateView *)self.giftPopView).isEditing) {
  334 + //正在编辑
  335 + [(PrivateView *)self.giftPopView endCurrentEditing];
  336 +
  337 + }else//已结束编辑
  338 + {
  339 + [UIView animateWithDuration:0.25 animations:^{
  340 +
  341 + self.giftPopView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, 300);
  342 + [self hiddenView:NO];
  343 + } completion:^(BOOL finished) {
  344 +
  345 + [self.giftPopView removeFromSuperview];
  346 + }];
  347 + }
  348 +
297 349 }
298 350 break;
299 351 default:
... ... @@ -345,6 +397,12 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
345 397 }];
346 398 }
347 399  
  400 +#pragma mark - PriClosePopViewDelegate
  401 +- (void)closeCurrentPopView
  402 +{
  403 + [self clearCurrentPopView];
  404 +}
  405 +
348 406 #pragma mark - CNLiveChatManagerDelegate
349 407 /**
350 408 连接状态的的监听器
... ... @@ -387,40 +445,70 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
387 445 - (void)onReceived:(CNLiveChatMessage *)message
388 446 {
389 447 // NSLog(@"onReceived");
390   - NSDictionary *JSONDic = [Tools dictionaryWithJsonString:message.messageContent];
391   - NSString *content = [JSONDic objectForKey:message_content];
392   -
393   - //将消息显示到列表中
394   - chatMsgModel *model = [[chatMsgModel alloc] init];
395   - model.name = message.userInfo.name;
396   - model.content = content;
397   - model.ID = message.targetId;
398   - model.icon = message.userInfo.portraitUri;
399   - model.cellWidth = self.chatTableView.width - 20;
400   - [self.chatMsgArray addObject:model];
401   - [self.chatTableView reloadData];
402   -
403   - NSInteger section = [self.chatTableView numberOfSections];
404   - if (section < 1) return;
405   - NSInteger row = [self.chatTableView numberOfRowsInSection:section - 1];
406   - if (row < 1) return;
407   - NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row - 1 inSection:section - 1];
408   - [self.chatTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
409   - [self.chatTableView reloadData];
410   -
411   - NSInteger isBarrage = [[JSONDic objectForKey:message_barrage] integerValue];
412   -
413   - if (isBarrage) {//此条消息飘弹幕
414   -
415   - chatMsgModel *barrageModel = [[chatMsgModel alloc] init];
416   - barrageModel.name = message.userInfo.name;
417   - barrageModel.content = content;
418   - barrageModel.icon = message.userInfo.portraitUri;
419   -// self.barrageView = [self.barrManager addAnimationWithModel:barrageModel animContentView:self.animationBaseView];
420   - [self.chatManager addAnimationWithModel:barrageModel animContentView:self.animationBaseView];//self.barrageView =
  448 + switch (message.conversationType) {
  449 + case CNLive_ConversationType_CHATROOM:
  450 + {
  451 + NSDictionary *JSONDic = [Tools dictionaryWithJsonString:message.messageContent];
  452 + NSString *content = [JSONDic objectForKey:message_content];
  453 +
  454 + //将消息显示到列表中
  455 + chatMsgModel *model = [[chatMsgModel alloc] init];
  456 + model.name = message.userInfo.name;
  457 + model.content = content;
  458 + model.ID = message.targetId;
  459 + model.icon = message.userInfo.portraitUri;
  460 + model.cellWidth = self.chatTableView.width - 20;
  461 + [self.chatMsgArray addObject:model];
  462 + [self.chatTableView reloadData];
  463 +
  464 + NSInteger section = [self.chatTableView numberOfSections];
  465 + if (section < 1) return;
  466 + NSInteger row = [self.chatTableView numberOfRowsInSection:section - 1];
  467 + if (row < 1) return;
  468 + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row - 1 inSection:section - 1];
  469 + [self.chatTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
  470 + [self.chatTableView reloadData];
  471 +
  472 + NSInteger isBarrage = [[JSONDic objectForKey:message_barrage] integerValue];
  473 +
  474 + if (isBarrage) {//此条消息飘弹幕
  475 +
  476 + chatMsgModel *barrageModel = [[chatMsgModel alloc] init];
  477 + barrageModel.name = message.userInfo.name;
  478 + barrageModel.content = content;
  479 + barrageModel.icon = message.userInfo.portraitUri;
  480 + [self.chatManager addAnimationWithModel:barrageModel animContentView:self.animationBaseView];
  481 + }
  482 + }
  483 + break;
  484 + case CNLive_ConversationType_PRIVATE:
  485 + {
  486 + NSDictionary *JSONDic = [Tools dictionaryWithJsonString:message.messageContent];
  487 + NSString *content = [JSONDic objectForKey:message_content];
  488 + PrivateView *privateView = [PrivateView privateView];
421 489  
422   - self.animationBaseView.delegate = self.chatManager;
423   -// self.animationBaseView.barrageView = self.barrageView;
  490 + //将消息显示到列表中
  491 + chatMsgModel *model = [[chatMsgModel alloc] init];
  492 + model.name = message.userInfo.name;
  493 + model.isMine = NO;
  494 + model.content = content;
  495 + model.ID = message.targetId;
  496 + model.icon = message.userInfo.portraitUri;
  497 + model.priCellWidth = privateView.tableView.width * 0.5 - 30;
  498 + [privateView.chatArray addObject:model];
  499 + [privateView.tableView reloadData];
  500 +
  501 + NSInteger section = [privateView.tableView numberOfSections];
  502 + if (section < 1) return;
  503 + NSInteger row = [privateView.tableView numberOfRowsInSection:section - 1];
  504 + if (row < 1) return;
  505 + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row - 1 inSection:section - 1];
  506 + [privateView.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
  507 + [privateView.tableView reloadData];
  508 + }
  509 + break;
  510 + default:
  511 + break;
424 512 }
425 513 }
426 514  
... ... @@ -558,8 +646,7 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
558 646 {
559 647 if (!_topToolsView)
560 648 {
561   - _topToolsView = [[TopToolView alloc] initWithFrame:CGRectMake(10, 20, 150, 30)];
562   - _topToolsView.backgroundColor = ZXRandomColor;
  649 + _topToolsView = [[TopToolView alloc] initWithFrame:CGRectMake(10, 20, 100, 30) isHost:NO];
563 650 }
564 651 return _topToolsView;
565 652 }
... ... @@ -575,7 +662,6 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
575 662 tableView.showsHorizontalScrollIndicator = NO;
576 663 tableView.bounces = NO;
577 664 tableView.backgroundColor = [UIColor clearColor];
578   - tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
579 665 _chatTableView = tableView;
580 666 }
581 667 return _chatTableView;
... ... @@ -629,14 +715,6 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
629 715 return _giftListView;
630 716 }
631 717  
632   -//- (BarrageManager *)barrManager
633   -//{
634   -// if (!_barrManager)
635   -// {
636   -// _barrManager = [BarrageManager sharedManager];
637   -// }
638   -// return _barrManager;
639   -//}
640 718 - (ChatBarrageManager *)chatManager
641 719 {
642 720 if (!_chatManager)
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/PrivateView/PriChatCell.h 0 → 100644
  1 +//
  2 +// PriChatCell.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by 张旭 on 2017/3/27.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "BaseTableViewCell.h"
  10 +
  11 +@class chatMsgModel;
  12 +@interface PriChatCell : BaseTableViewCell
  13 +
  14 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/PrivateView/PriChatCell.m 0 → 100644
  1 +//
  2 +// PriChatCell.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by 张旭 on 2017/3/27.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "PriChatCell.h"
  10 +#import "chatMsgModel.h"
  11 +
  12 +#define CHAT_POP_WIDTH 260
  13 +
  14 +@interface PriChatCell ()
  15 +
  16 +@property (nonatomic ,strong) chatMsgModel * _Nullable model;
  17 +@property (nonatomic ,strong) UIImageView * _Nullable icon;
  18 +@property (nonatomic ,strong) UILabel * _Nullable content;
  19 +
  20 +@end
  21 +
  22 +@implementation PriChatCell
  23 +
  24 +- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  25 +{
  26 + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  27 + if (self) {
  28 + self.backgroundColor = [UIColor clearColor];
  29 + self.selectionStyle = UITableViewCellSelectionStyleNone;
  30 + }
  31 + return self;
  32 +}
  33 +
  34 +- (void)loadUIWithModel:(chatMsgModel *)model
  35 +{
  36 + _model = model;
  37 + [self bindView];
  38 + [self.icon sd_setImageWithURL:[NSURL URLWithString:model.icon] placeholderImage:nil];
  39 + self.content.text = model.content;
  40 +}
  41 +
  42 +- (void)bindView
  43 +{
  44 + if (_model.isMine) {
  45 + self.icon.frame = CGRectMake(self.width - 30, 6, 25, 25);
  46 + NSLog(@"self.icon.centerY%f",self.height * 0.5);//13.353516
  47 + self.icon.centerY = (self.height - 25)*0.5 + 12.5;//13.353516;
  48 + self.content.frame = CGRectMake(self.width - 30 - 5 - CHAT_POP_WIDTH, 2.5, CHAT_POP_WIDTH, self.height - 5);
  49 + self.content.backgroundColor = [UIColor blueColorZX];
  50 +
  51 + }else{
  52 + self.icon.frame = CGRectMake(5, 6, 25, 25);
  53 + self.icon.centerY = (self.height - 25)*0.5 + 12.5;//13.353516;
  54 + self.content.frame = CGRectMake(5 + 30, 2.5, CHAT_POP_WIDTH, self.height - 5);
  55 + self.content.backgroundColor = [UIColor greenColor];
  56 + }
  57 +}
  58 +
  59 +#pragma mark - getter
  60 +- (UILabel * _Nullable)content
  61 +{
  62 + if (!_content)
  63 + {
  64 + _content = [[UILabel alloc] init];
  65 + _content.textAlignment = NSTextAlignmentLeft;
  66 + _content.textColor = [UIColor blackColor];
  67 + _content.numberOfLines = 0;
  68 + _content.font = [UIFont systemFontOfSize:kContentFont];
  69 + _content.layer.cornerRadius = 10;
  70 + _content.layer.masksToBounds = YES;
  71 + [self addSubview:_content];
  72 + }
  73 + return _content;
  74 +}
  75 +
  76 +- (UIImageView * _Nullable)icon
  77 +{
  78 + if (!_icon)
  79 + {
  80 + _icon = [[UIImageView alloc] init];
  81 + _icon.layer.masksToBounds = YES;
  82 + _icon.layer.cornerRadius = 15.f;
  83 + [self addSubview:_icon];
  84 + }
  85 + return _icon;
  86 +}
  87 +
  88 +- (void)awakeFromNib {
  89 + [super awakeFromNib];
  90 + // Initialization code
  91 +}
  92 +
  93 +- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  94 + [super setSelected:selected animated:animated];
  95 +
  96 + // Configure the view for the selected state
  97 +}
  98 +
  99 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/PrivateView/PrivateView.h
... ... @@ -8,8 +8,24 @@
8 8  
9 9 #import <UIKit/UIKit.h>
10 10  
  11 +
  12 +@protocol PopViewDelegate <NSObject>
  13 +
  14 +- (void)closeCurrentPopView;
  15 +
  16 +@end
  17 +
11 18 @interface PrivateView : UIView
12 19  
13   -+ (instancetype)privateView;
  20 ++ (instancetype _Nonnull)privateView;
  21 +
  22 +- (void)endCurrentEditing;
  23 +
  24 +@property (nonatomic ,assign) BOOL isEditing;
  25 +
  26 +@property (nonatomic ,strong) _Nonnull id <PopViewDelegate> delegate;
  27 +@property (nonatomic ,strong) UITableView * _Nullable tableView;
  28 +
  29 +@property (nonatomic ,strong) NSMutableArray * _Nullable chatArray;
14 30  
15 31 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/PrivateView/PrivateView.m
... ... @@ -7,13 +7,252 @@
7 7 //
8 8  
9 9 #import "PrivateView.h"
  10 +#import "PriChatCell.h"
  11 +#import "chatMsgModel.h"
  12 +
  13 +@interface PrivateView ()<UITextFieldDelegate,UITableViewDelegate,UITableViewDataSource>
  14 +
  15 +@property (nonatomic ,strong) UILabel * _Nullable nameLbl;
  16 +@property (nonatomic ,strong) UIButton * _Nullable closeBtn;
  17 +
  18 +@property (nonatomic ,strong) UIImageView * _Nullable bottomTool;
  19 +@property (nonatomic ,strong) UIButton * _Nullable sendBtn;
  20 +@property (nonatomic ,strong) UITextField * _Nullable textField;
  21 +
  22 +@end
10 23  
11 24 @implementation PrivateView
12 25  
  26 +static NSString *message_content = @"message_content";
  27 +
13 28 + (instancetype)privateView
14 29 {
15   - return [[PrivateView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - 300, SCREEN_WIDTH, 300)];
  30 + static PrivateView *privateView;
  31 +
  32 + static dispatch_once_t onceToken;
  33 + dispatch_once(&onceToken, ^{
  34 + privateView = [[PrivateView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, 300)];
  35 + });
  36 + return privateView;
  37 +}
  38 +
  39 +- (instancetype)initWithFrame:(CGRect)frame
  40 +{
  41 + if (self = [super initWithFrame:frame]) {
  42 +
  43 + [self addSubview:self.tableView];
  44 + [self addSubview:self.nameLbl];
  45 + [self.bottomTool addSubview:self.sendBtn];
  46 + [self.bottomTool addSubview:self.textField];
  47 +
  48 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:self];
  49 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHidden:) name:UIKeyboardWillHideNotification object:self];
  50 + }
  51 + return self;
  52 +}
  53 +
  54 +- (void)closeAction
  55 +{
  56 + if ([self.delegate respondsToSelector:@selector(closeCurrentPopView)]) {
  57 + [self.delegate closeCurrentPopView];
  58 + }
  59 +}
  60 +
  61 +- (void)sendClick
  62 +{
  63 + [self textFieldShouldReturn:self.textField];
  64 +}
  65 +
  66 +- (void)keyboardWillShow:(NSNotification *)notify {
  67 +
  68 + if ([notify.object isKindOfClass:[PrivateView class]]) {
  69 + NSDictionary *userInfo = notify.userInfo;
  70 + CGRect newFrameKeyboard = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];//变化前的frame
  71 + [UIView animateWithDuration:0.25 animations:^{
  72 + self.top = SCREEN_HEIGHT - newFrameKeyboard.size.height - self.height;
  73 + }];
  74 + self.isEditing = YES;
  75 + NSLog(@"showtop:%f",self.top);
  76 + }
  77 +}
  78 +
  79 +- (void)keyboardWillHidden:(NSNotification *)notify {
  80 +
  81 + if ([notify.object isKindOfClass:[PrivateView class]]) {
  82 + [UIView animateWithDuration:0.1 animations:^{
  83 + self.top = SCREEN_HEIGHT - 300;
  84 + }];
  85 + NSLog(@"hiddentop:%f",self.top);
  86 + self.isEditing = NO;
  87 + }
  88 +}
  89 +
  90 +#pragma mark - UITextFieldDelegate
  91 +- (BOOL)textFieldShouldReturn:(UITextField *)textField
  92 +{
  93 + if (![textField.text isEqualToString:@""]) {
  94 +
  95 + NSDictionary *dic = @{message_content:textField.text};
  96 + weakself
  97 + NSString *message = [Tools dictionaryToJson:dic];
  98 + [[CNLiveChatManager sharedCNLiveChatManager] sendMessage:message type:CNLive_ConversationType_PRIVATE targetId:@"20170327" success:^(CNLiveChatMessage *message) {
  99 +
  100 + dispatch_async(dispatch_get_main_queue(), ^{
  101 + strongself
  102 + NSDictionary *JSONDic = [Tools dictionaryWithJsonString:message.messageContent];
  103 + NSString *content = [JSONDic objectForKey:message_content];
  104 +
  105 + //将消息显示到列表中
  106 + chatMsgModel *model = [[chatMsgModel alloc] init];
  107 + model.name = message.userInfo.name;
  108 + model.isMine = YES;
  109 + model.content = content;
  110 + model.ID = message.targetId;
  111 + model.icon = message.userInfo.portraitUri;
  112 + model.priCellWidth = self.tableView.width * 0.5 - 30;
  113 + // model.sendTime;//发送时间
  114 + [self.chatArray addObject:model];
  115 + [self.tableView reloadData];
  116 +
  117 + NSInteger section = [self.tableView numberOfSections];
  118 + if (section < 1) return;
  119 + NSInteger row = [self.tableView numberOfRowsInSection:section - 1];
  120 + if (row < 1) return;
  121 + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row - 1 inSection:section - 1];
  122 + [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
  123 + [self.tableView reloadData];
  124 +
  125 + });
  126 + } error:^(CNLiveChatErrorCode errors, NSString *messageId, NSString *targetId) {
  127 + NSLog(@"%@",messageId);
  128 + }];
  129 +
  130 + textField.text = @"";
  131 + }
  132 + [textField resignFirstResponder];
  133 + return YES;
  134 +}
  135 +
  136 +- (void)endCurrentEditing
  137 +{
  138 + self.top = SCREEN_HEIGHT - 300;
  139 + [self.textField resignFirstResponder];
  140 +}
  141 +
  142 +#pragma mark - 私聊消息列表
  143 +#pragma mark - UITableViewDataSource
  144 +
  145 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  146 +{
  147 + return self.chatArray.count;
16 148 }
  149 +
  150 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  151 +{
  152 + PriChatCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([PriChatCell class]) forIndexPath:indexPath];
  153 + [cell loadUIWithModel:self.chatArray[indexPath.row]];
  154 + return cell;
  155 +}
  156 +
  157 +#pragma mark - UITableViewDelegate
  158 +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  159 +{
  160 + return [self.chatArray[indexPath.row] priCellHeight];
  161 +}
  162 +
  163 +- (NSMutableArray *)chatArray
  164 +{
  165 + if (!_chatArray)
  166 + {
  167 + _chatArray = [[NSMutableArray alloc] init];
  168 + }
  169 + return _chatArray;
  170 +}
  171 +
  172 +- (UILabel *)nameLbl
  173 +{
  174 + if (!_nameLbl)
  175 + {
  176 + _nameLbl = [[UILabel alloc] initWithFrame:CGRectMake(100, 5, self.width - 100, 30)];
  177 + _nameLbl.centerX = self.width * 0.5;
  178 + _nameLbl.text = @"哈哈哈主播的名字";
  179 + [_nameLbl setTextColor:[UIColor cyanColor]];
  180 + _nameLbl.numberOfLines = 1;
  181 + _nameLbl.textAlignment = NSTextAlignmentCenter;
  182 + }
  183 + return _nameLbl;
  184 +}
  185 +
  186 +- (UIButton *)closeBtn
  187 +{
  188 + if (!_closeBtn)
  189 + {
  190 + UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  191 + closeBtn.frame = CGRectMake(SCREEN_WIDTH - 41,10, 31, 30);
  192 + [closeBtn setImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal];
  193 + [closeBtn setImage:[UIImage imageNamed:@"close"] forState:UIControlStateHighlighted];
  194 + [closeBtn addTarget:self action:@selector(closeAction) forControlEvents:UIControlEventTouchUpInside];
  195 + _closeBtn = closeBtn;
  196 + [self addSubview:_closeBtn];
  197 +
  198 + }
  199 + return _closeBtn;
  200 +}
  201 +
  202 +- (UITableView *)tableView
  203 +{
  204 + if (!_tableView)
  205 + {
  206 + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.closeBtn.bottom + 10, self.width, self.height - self.closeBtn.bottom - 10 - self.bottomTool.height)];
  207 + [_tableView registerClass:[PriChatCell class] forCellReuseIdentifier:NSStringFromClass([PriChatCell class])];
  208 + _tableView.delegate = self;
  209 + _tableView.dataSource = self;
  210 + _tableView.showsVerticalScrollIndicator = NO;
  211 + _tableView.showsHorizontalScrollIndicator = NO;
  212 + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  213 + _tableView.bounces = NO;
  214 + _tableView.backgroundColor = [UIColor clearColor];
  215 + }
  216 + return _tableView;
  217 +}
  218 +
  219 +- (UIImageView *)bottomTool
  220 +{
  221 + if (!_bottomTool)
  222 + {
  223 + _bottomTool = [[UIImageView alloc] initWithFrame:CGRectMake(0, self.height - 40, self.width, 40)];
  224 + _bottomTool.image = [[UIImage imageNamed:@"priToolBg"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0) resizingMode:UIImageResizingModeStretch];
  225 + _bottomTool.userInteractionEnabled = YES;
  226 +
  227 + [self addSubview:_bottomTool];
  228 + }
  229 + return _bottomTool;
  230 +}
  231 +
  232 +- (UIButton *)sendBtn
  233 +{
  234 + if (!_sendBtn)
  235 + {
  236 + _sendBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.bottomTool.width - 60, 4, 60, self.bottomTool.height - 8)];
  237 + [_sendBtn setTitle:@"发送" forState:UIControlStateNormal];
  238 + [_sendBtn setTitleColor:[UIColor cyanColor] forState:UIControlStateNormal];
  239 + [_sendBtn addTarget:self action:@selector(sendClick) forControlEvents:UIControlEventTouchUpInside];
  240 + }
  241 + return _sendBtn;
  242 +}
  243 +
  244 +- (UITextField *)textField
  245 +{
  246 + if (!_textField)
  247 + {
  248 + _textField = [[UITextField alloc] initWithFrame:CGRectMake(4, 4, self.bottomTool.width - self.sendBtn.width - 8, self.bottomTool.height - 8)];
  249 + _textField.borderStyle = UITextBorderStyleLine;
  250 + _textField.returnKeyType = UIReturnKeySend;
  251 + _textField.delegate = self;
  252 + }
  253 + return _textField;
  254 +}
  255 +
17 256 /*
18 257 // Only override drawRect: if you perform custom drawing.
19 258 // An empty implementation adversely affects performance during animation.
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/TopToolView/TopToolView.h
... ... @@ -8,7 +8,10 @@
8 8  
9 9 #import <UIKit/UIKit.h>
10 10  
  11 +@class userInfoModel;
11 12 @interface TopToolView : UIView
12 13  
13   -- (instancetype)initWithFrame:(CGRect)frame isHost:(BOOL)isHost;
  14 +- (instancetype _Nonnull)initWithFrame:(CGRect)frame isHost:(BOOL)isHost;
  15 +
  16 +@property (nonatomic ,strong) userInfoModel * _Nullable model;
14 17 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/TopToolView/TopToolView.m
... ... @@ -7,26 +7,96 @@
7 7 //
8 8  
9 9 #import "TopToolView.h"
  10 +#import "userInfoModel.h"
  11 +
  12 +@interface TopToolView ()
  13 +
  14 +@property (nonatomic ,strong) UIImageView * _Nullable icon;
  15 +@property (nonatomic ,strong) UIImageView * _Nullable bgView;
  16 +@property (nonatomic ,strong) UILabel * _Nullable stateLbl;
  17 +//@property (nonatomic ,strong) UILabel * _Nullable numberLbl;
  18 +
  19 +@end
10 20  
11 21 @implementation TopToolView
12 22  
13 23 - (instancetype)initWithFrame:(CGRect)frame isHost:(BOOL)isHost
14 24 {
15 25 if (self = [super initWithFrame:frame]) {
16   -
  26 +
  27 + [self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)]];
  28 + [self addSubview:self.bgView];
  29 + [self addSubview:self.stateLbl];
17 30 if (isHost) {
18 31 //主播端没有自己头像
19 32  
20   -
21 33 }else
22 34 {//观众端有主播头像
23   -
24   -
  35 + [self addSubview:self.icon];
25 36 }
26 37 }
27 38 return self;
28 39 }
29 40  
  41 +- (void)setModel:(userInfoModel *)model
  42 +{
  43 + _model = model;
  44 + [_icon zx_setHeader:model.icon];
  45 +}
  46 +
  47 +- (void)tapClick:(UITapGestureRecognizer *)gesture
  48 +{
  49 + userInfoModel *userModel = [[userInfoModel alloc ]init];
  50 + userModel.name = @"职业主播";
  51 + userModel.icon = @"http://b.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=f0c5c08030d3d539c16807c70fb7c566/8ad4b31c8701a18bbef9f231982f07082838feba.jpg";
  52 + userModel.sign = @"哈哈啊哈哈啊哈哈,这是我的签名~";
  53 + userModel.uId = @"123124";
  54 +
  55 + [Tools showBouncedWithModel:userModel callBackBlock:^(UIView * _Nullable bounceView) {
  56 +
  57 + }];
  58 +}
  59 +
  60 +- (UIImageView *)icon
  61 +{
  62 + if (!_icon)
  63 + {
  64 + _icon = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
  65 + _icon.backgroundColor = ZXRandomColor;
  66 + _icon.layer.masksToBounds = YES;
  67 + _icon.layer.cornerRadius = _icon.height * 0.5;
  68 + [_icon zx_setHeader:@"http://b.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=f0c5c08030d3d539c16807c70fb7c566/8ad4b31c8701a18bbef9f231982f07082838feba.jpg"];
  69 + }
  70 + return _icon;
  71 +}
  72 +
  73 +- (UIImageView *)bgView
  74 +{
  75 + if (!_bgView)
  76 + {
  77 + _bgView = [[UIImageView alloc] initWithFrame:self.bounds];
  78 + _bgView.backgroundColor = ZXRandomColor;
  79 + _bgView.layer.masksToBounds = YES;
  80 + _bgView.layer.cornerRadius = _bgView.height * 0.5;
  81 +
  82 + }
  83 + return _bgView;
  84 +}
  85 +
  86 +- (UILabel *)stateLbl
  87 +{
  88 + if (!_stateLbl)
  89 + {
  90 + _stateLbl = [[UILabel alloc] initWithFrame:CGRectMake(self.icon.right + 5, 0, 60, 20)];
  91 + _stateLbl.textAlignment = NSTextAlignmentCenter;
  92 + _stateLbl.textColor = [UIColor whiteColor];
  93 + _stateLbl.text = @"直播";//直播 精彩回放
  94 + _stateLbl.height = [_stateLbl labelSize].height;
  95 + _stateLbl.font = [UIFont systemFontOfSize:kDetailContentFont];
  96 + }
  97 + return _stateLbl;
  98 +}
  99 +
30 100 /*
31 101 // Only override drawRect: if you perform custom drawing.
32 102 // An empty implementation adversely affects performance during animation.
... ...
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/close.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "idiom" : "universal",
  9 + "scale" : "2x"
  10 + },
  11 + {
  12 + "idiom" : "universal",
  13 + "scale" : "3x"
  14 + },
  15 + {
  16 + "idiom" : "iphone",
  17 + "scale" : "1x"
  18 + },
  19 + {
  20 + "idiom" : "iphone",
  21 + "filename" : "close.png",
  22 + "scale" : "2x"
  23 + },
  24 + {
  25 + "idiom" : "iphone",
  26 + "scale" : "3x"
  27 + }
  28 + ],
  29 + "info" : {
  30 + "version" : 1,
  31 + "author" : "xcode"
  32 + }
  33 +}
0 34 \ No newline at end of file
... ...
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/close.imageset/close.png 0 → 100644

2.47 KB

LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/priToolBg.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "priToolBg.png",
  6 + "scale" : "1x"
  7 + }
  8 + ],
  9 + "info" : {
  10 + "version" : 1,
  11 + "author" : "xcode"
  12 + }
  13 +}
0 14 \ No newline at end of file
... ...
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/priToolBg.imageset/priToolBg.png 0 → 100644

1.53 KB