Commit 72fef683efb7002d8732e7efbfb8c1084fdc6f82

Authored by 张旭
1 parent a4a54f89

聊天室页面搭建

Showing 20 changed files with 350 additions and 94 deletions
LiveVideoCloud/LiveVideoCloud.xcodeproj/project.pbxproj
... ... @@ -158,6 +158,7 @@
158 158 D2888DB11E6EC05F003A77C8 /* TempViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB01E6EC05F003A77C8 /* TempViewController.m */; };
159 159 D2888DB41E6EC154003A77C8 /* HomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB31E6EC154003A77C8 /* HomeViewController.m */; };
160 160 D2888DB71E6EC1B8003A77C8 /* LVCMyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2888DB61E6EC1B8003A77C8 /* LVCMyViewController.m */; };
  161 + D2A803081E80BD6F009D6F1C /* TopToolView.m in Sources */ = {isa = PBXBuildFile; fileRef = D2A803071E80BD6F009D6F1C /* TopToolView.m */; };
161 162 /* End PBXBuildFile section */
162 163  
163 164 /* Begin PBXContainerItemProxy section */
... ... @@ -508,6 +509,8 @@
508 509 D2888DB31E6EC154003A77C8 /* HomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeViewController.m; sourceTree = "<group>"; };
509 510 D2888DB51E6EC1B8003A77C8 /* LVCMyViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCMyViewController.h; sourceTree = "<group>"; };
510 511 D2888DB61E6EC1B8003A77C8 /* LVCMyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCMyViewController.m; sourceTree = "<group>"; };
  512 + D2A803061E80BD6F009D6F1C /* TopToolView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopToolView.h; sourceTree = "<group>"; };
  513 + D2A803071E80BD6F009D6F1C /* TopToolView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopToolView.m; sourceTree = "<group>"; };
511 514 /* End PBXFileReference section */
512 515  
513 516 /* Begin PBXFrameworksBuildPhase section */
... ... @@ -1256,6 +1259,8 @@
1256 1259 D22830F81E77C2A700627701 /* TopToolView */ = {
1257 1260 isa = PBXGroup;
1258 1261 children = (
  1262 + D2A803061E80BD6F009D6F1C /* TopToolView.h */,
  1263 + D2A803071E80BD6F009D6F1C /* TopToolView.m */,
1259 1264 );
1260 1265 path = TopToolView;
1261 1266 sourceTree = "<group>";
... ... @@ -1664,6 +1669,7 @@
1664 1669 D2029CD01E6EADE10027CD92 /* SearchPresenter.m in Sources */,
1665 1670 D2888DB71E6EC1B8003A77C8 /* LVCMyViewController.m in Sources */,
1666 1671 D2029CBE1E6EADE10027CD92 /* SDWebImagePrefetcher.m in Sources */,
  1672 + D2A803081E80BD6F009D6F1C /* TopToolView.m in Sources */,
1667 1673 810B65011E779B1F00133E15 /* MASLayoutConstraint.m in Sources */,
1668 1674 D2029CCE1E6EADE10027CD92 /* SearchRecomListModel.m in Sources */,
1669 1675 D2029CA11E6EADE10027CD92 /* NSString+MJExtension.m in Sources */,
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/BottomToolView/BottomToolView.h
... ... @@ -16,7 +16,7 @@ typedef NS_ENUM(NSInteger, BtnClickType) {//底部按钮类型
16 16  
17 17 @protocol bottomBtnDeledate <NSObject>
18 18  
19   -- (void)bottomActionWithType:(BtnClickType)btnType;
  19 +- (void)bottomActionWithType:(BtnClickType)btnType button:(UIButton *)button;
20 20  
21 21 @end
22 22 @interface BottomToolView : BaseView
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/BottomToolView/BottomToolView.m
... ... @@ -31,22 +31,22 @@
31 31 #pragma mark - buttonClick
32 32 - (void)chatAction
33 33 {
34   - if ([self.delegate respondsToSelector:@selector(bottomActionWithType:)]) {
35   - [self.delegate bottomActionWithType:BtnClickTypeChat];
  34 + if ([self.delegate respondsToSelector:@selector(bottomActionWithType:button:)]) {
  35 + [self.delegate bottomActionWithType:BtnClickTypeChat button:self.chatBtn];
36 36 }
37 37 }
38 38  
39 39 - (void)privateChatAction
40 40 {
41   - if ([self.delegate respondsToSelector:@selector(bottomActionWithType:)]) {
42   - [self.delegate bottomActionWithType:BtnClickTypePriChat];
  41 + if ([self.delegate respondsToSelector:@selector(bottomActionWithType:button:)]) {
  42 + [self.delegate bottomActionWithType:BtnClickTypePriChat button:self.privateChatBtn];
43 43 }
44 44 }
45 45  
46 46 - (void)giftAction
47 47 {
48   - if ([self.delegate respondsToSelector:@selector(bottomActionWithType:)]) {
49   - [self.delegate bottomActionWithType:BtnClickTypeGift];
  48 + if ([self.delegate respondsToSelector:@selector(bottomActionWithType:button:)]) {
  49 + [self.delegate bottomActionWithType:BtnClickTypeGift button:self.giftBtn];
50 50 }
51 51 }
52 52  
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatMsgModel/chatMsgModel.h
... ... @@ -14,9 +14,11 @@
14 14 @property (nonatomic ,copy ) NSString * _Nullable name;//姓名
15 15 @property (nonatomic ,copy ) NSString * _Nullable content;//内容
16 16  
  17 +@property (nonatomic ,assign) CGFloat level;//等级
17 18 @property (nonatomic ,assign) CGFloat cellWidth;//内容宽度
18 19 @property (nonatomic ,assign) CGFloat cellHeight;//内容高度
19 20  
20 21 @property (nonatomic) BOOL isMine;//消息是否是自己发送
  22 +@property (nonatomic ,copy) NSString * _Nullable ID;//唯一标识
21 23  
22 24 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatMsgModel/chatMsgModel.m
... ... @@ -17,16 +17,16 @@
17 17 //如果计算过高度,直接返回
18 18 if (_cellHeight) return _cellHeight;
19 19  
20   - //头像
21   - _cellHeight = 40;
  20 + _cellHeight = 0;
  21 + NSString *content = [NSString stringWithFormat:@"%@:%@",self.name,self.content];
22 22 //文字
23   - CGFloat textMaxW = self.cellWidth - 2 * ChatCellMargin;
  23 + CGFloat textMaxW = self.cellWidth;
24 24 CGSize textMaxSize = CGSizeMake(textMaxW, MAXFLOAT);
25   - CGSize textSize = [self.content boundingRectWithSize:textMaxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:16]} context:nil].size;
  25 + CGSize textSize = [content boundingRectWithSize:textMaxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14]} context:nil].size;
26 26  
27 27 //底部空隙
28 28 _cellHeight += textSize.height + ChatCellMargin;
29   - // NSLog(@"cellHeight = %f",_cellHeight);
  29 + NSLog(@"cellHeight = %f",_cellHeight);
30 30 return _cellHeight;
31 31 }
32 32 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatViews/chatListCell.h
... ... @@ -8,8 +8,16 @@
8 8  
9 9 #import "BaseTableViewCell.h"
10 10 @class chatMsgModel;
  11 +
  12 +@protocol userClickDelegate <NSObject>
  13 +
  14 +- (void)userClickWithModel:(chatMsgModel *)model;
  15 +
  16 +@end
  17 +
11 18 @interface chatListCell : BaseTableViewCell
12 19  
13 20 - (void)loadUIWithModel:(chatMsgModel *)model;
14 21  
  22 +@property (nonatomic ,strong) id <userClickDelegate> delegate;
15 23 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatViews/chatListCell.m
... ... @@ -10,11 +10,8 @@
10 10 #import "chatMsgModel.h"
11 11 @interface chatListCell ()
12 12  
13   -@property (nonatomic ,strong) UIImageView * _Nullable iconImageView;//头像图片
14   -@property (nonatomic ,strong) UILabel * _Nullable nameLabel;//名字
  13 +@property (nonatomic ,strong) UIImageView * _Nullable iconImageView;//等级图片
15 14 @property (nonatomic ,strong) UILabel * _Nullable contentLabel;//内容
16   -@property (nonatomic ,strong) UIImageView * _Nullable lineImageView;//分割线
17   -
18 15 @property (nonatomic ,strong) chatMsgModel * _Nullable model;
19 16  
20 17 @end
... ... @@ -38,50 +35,54 @@
38 35  
39 36 [self bindView];//更新cell高度后再初始化UI
40 37 [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.icon] placeholderImage:nil];
41   - // self.iconImageView.backgroundColor = [UIColor greenColor];
42   - self.nameLabel.text = [NSString stringWithFormat:@"%@:",model.name];
43   - CGSize labelSize = [self.nameLabel labelSize];
44   - self.nameLabel.frame = CGRectMake(self.iconImageView.right + 10, self.iconImageView.top, labelSize.width, labelSize.height);
45   - self.nameLabel.centerY = self.iconImageView.centerY;
46   - self.contentLabel.text = model.content;
47   - CGSize contentLabelSize = [self.contentLabel labelSizeWithWidth:self.width - 2 * self.iconImageView.left];
48   - self.contentLabel.frame = CGRectMake(self.iconImageView.left, self.iconImageView.bottom + 10, contentLabelSize.width, contentLabelSize.height);
  38 + self.iconImageView.backgroundColor = ZXRandomColor;
  39 + self.contentLabel.text = [NSString stringWithFormat:@"%@:%@",model.name,model.content];
  40 + CGSize contentLabelSize = [self.contentLabel labelSizeWithWidth:self.width - self.iconImageView.right - 4];
  41 + self.contentLabel.frame = CGRectMake(20, 0, contentLabelSize.width, contentLabelSize.height);
  42 + self.contentLabel.centerY = self.height * 0.5;
  43 +
  44 + NSString *name = [NSString stringWithFormat:@"%@:",model.name];
  45 + NSString *content = model.content;
  46 + // 创建NSMutableAttributedString
  47 + NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:self.contentLabel.text];
  48 + // 设置文字颜色
  49 + [str addAttribute:NSForegroundColorAttributeName value:ZXRandomColor range:NSMakeRange(0, name.length)];
  50 + [str addAttribute:NSForegroundColorAttributeName value:[UIColor cyanColor] range:NSMakeRange(name.length, content.length)];
  51 + // 将配置好的NSMutableAttributedString传给attributedText属性
  52 + self.contentLabel.attributedText = str;
49 53  
50   - self.lineImageView.frame = CGRectMake(self.iconImageView.left, self.contentLabel.bottom + 5, self.width - self.iconImageView.left * 2, 1);
  54 + UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(detailInfo)];
  55 + [self.contentLabel addGestureRecognizer:gesture];
51 56 }
52 57  
53 58 - (void)bindView
54 59 {
55   - self.iconImageView.frame = CGRectMake(10, 10, 30, 30);
56   - self.nameLabel.frame = CGRectMake(self.iconImageView.right + 10, self.iconImageView.top, self.width - self.iconImageView.right - 20, 25);
57   - self.nameLabel.centerY = self.iconImageView.centerY;
58   - self.contentLabel.frame = CGRectMake(self.iconImageView.left, self.iconImageView.bottom + 10, self.width - 2 * self.iconImageView.left, 25);
  60 + self.iconImageView.frame = CGRectMake(4, 0, 16, 10);
  61 + self.contentLabel.frame = CGRectMake(self.iconImageView.right + 4, 0, self.width - 20, 25);
  62 + self.contentLabel.centerY = self.height * 0.5;
  63 + self.iconImageView.centerY = 13.353516;
  64 +// NSLog(@"Y:%f",self.contentLabel.centerY);//13.353516
59 65 }
60 66  
61   -#pragma mark - getter
62   -- (UILabel * _Nullable)nameLabel
  67 +- (void)detailInfo
63 68 {
64   - if (!_nameLabel)
65   - {
66   - _nameLabel = [[UILabel alloc] init];
67   - _nameLabel.textAlignment = NSTextAlignmentLeft;
68   - _nameLabel.textColor = [UIColor redColor];
69   - _nameLabel.font = [UIFont systemFontOfSize:15.f];
70   - [self addSubview:_nameLabel];
  69 + if ([self.delegate respondsToSelector:@selector(userClickWithModel:)]) {
  70 + [self.delegate userClickWithModel:self.model];
71 71 }
72   - return _nameLabel;
73 72 }
74 73  
  74 +#pragma mark - getter
75 75 - (UILabel * _Nullable)contentLabel
76 76 {
77 77 if (!_contentLabel)
78 78 {
79 79 _contentLabel = [[UILabel alloc] init];
80 80 _contentLabel.textAlignment = NSTextAlignmentLeft;
81   - _contentLabel.textColor = [UIColor lightGrayColor];
  81 + _contentLabel.textColor = [UIColor blackColor];
82 82 _contentLabel.numberOfLines = 0;
83   - _contentLabel.font = [UIFont systemFontOfSize:12.f];
  83 + _contentLabel.font = [UIFont systemFontOfSize:14.f];
84 84 [self addSubview:_contentLabel];
  85 + _contentLabel.userInteractionEnabled = YES;
85 86 }
86 87 return _contentLabel;
87 88 }
... ... @@ -98,18 +99,6 @@
98 99 return _iconImageView;
99 100 }
100 101  
101   -- (UIImageView * _Nullable)lineImageView
102   -{
103   - if (!_lineImageView)
104   - {
105   - _lineImageView = [[UIImageView alloc] init];
106   - _lineImageView.image = [UIImage imageNamed:@"分割线(聊天复用)"];
107   - [self addSubview:_lineImageView];
108   - }
109   - return _lineImageView;
110   -}
111   -
112   -
113 102 /*
114 103 // Only override drawRect: if you perform custom drawing.
115 104 // An empty implementation adversely affects performance during animation.
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftAnimOperation.m
... ... @@ -33,6 +33,11 @@
33 33 + (GiftAnimOperation *)addGiftAnimOperationWithGiftModel:(GiftModel *)model animContentView:(UIView *)animContentView{
34 34  
35 35 GiftAnimOperation *giftAnimOperation = [[GiftAnimOperation alloc]initWithGiftModel:model animContentView:animContentView];
  36 +
  37 + if (model.giftStyle == GiftStyleFighter) {
  38 + [[NSNotificationCenter defaultCenter] addObserver:giftAnimOperation selector:@selector(fighterAnimationDidStart) name:NSNotificationAnimationDidStart object:nil];
  39 + [[NSNotificationCenter defaultCenter] addObserver:giftAnimOperation selector:@selector(fighterAnimationDidStop) name:NSNotificationAnimationDidStop object:nil];
  40 + }
36 41 return giftAnimOperation;
37 42 }
38 43  
... ... @@ -101,7 +106,6 @@
101 106  
102 107 [self didChangeValueForKey:@"isFinished"];
103 108 }];
104   -
105 109 });
106 110 }
107 111  
... ... @@ -113,18 +117,23 @@
113 117  
114 118 [self.giftFighterView addAnimationsMoveToPoint:CGPointMake(SCREEN_WIDTH, 60) endPoint:CGPointMake( -500, 600)];
115 119 [self.animContentView addSubview:self.giftFighterView];
116   -
117   - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(12 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
118   - [self willChangeValueForKey:@"isFinished"];
119   -
120   - _finished = YES;
121   -
122   - [self didChangeValueForKey:@"isFinished"];
123   -
124   - });
125 120 });
126 121 }
127 122  
  123 +- (void)fighterAnimationDidStart
  124 +{
  125 +
  126 +}
  127 +
  128 +- (void)fighterAnimationDidStop
  129 +{
  130 + [self willChangeValueForKey:@"isFinished"];
  131 +
  132 + _finished = YES;
  133 +
  134 + [self didChangeValueForKey:@"isFinished"];
  135 +}
  136 +
128 137 - (void)planeAnimation
129 138 {
130 139 weakself
... ... @@ -142,7 +151,6 @@
142 151  
143 152 [self didChangeValueForKey:@"isFinished"];
144 153 }];
145   -
146 154 });
147 155 }
148 156  
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftAnimationAction.h
... ... @@ -8,6 +8,9 @@
8 8  
9 9 #import <UIKit/UIKit.h>
10 10  
  11 +static NSString *NSNotificationAnimationDidStart = @"NSNotificationAnimationDidStart";
  12 +
  13 +static NSString *NSNotificationAnimationDidStop = @"NSNotificationAnimationDidStop";
11 14 /**
12 15 动画完成回调
13 16 */
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftResource/NHFighterView+animDelegagte.m
... ... @@ -13,14 +13,12 @@
13 13  
14 14 - (void)animationDidStart:(CAAnimation *)anim
15 15 {
16   - NSLog(@"did start");
  16 + [[NSNotificationCenter defaultCenter] postNotificationName:NSNotificationAnimationDidStart object:nil];
17 17 }
18 18  
19 19 - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
20 20 {
21   -// _giftAnimationCompletion();
22   -
23   - NSLog(@"did stop");
  21 + [[NSNotificationCenter defaultCenter] postNotificationName:NSNotificationAnimationDidStop object:nil];
24 22 }
25 23  
26 24 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/LVCAnimationManager.h
... ... @@ -32,4 +32,9 @@
32 32 @param speed 每s执行的次数
33 33 */
34 34 - (void)bubblingWithCenterPoint:(CGPoint)centerPoint toView:(UIView *_Nonnull)toView speed:(CGFloat)speed;
  35 +
  36 +- (void)suspend;
  37 +
  38 +- (void)resume;
  39 +
35 40 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/LVCAnimationManager.m
... ... @@ -81,4 +81,20 @@ static LVCAnimationManager * __singleton__;
81 81 [self.toView bubblingWithImage:[UIImage imageNamed:loveImageName] center:self.centerPoint];
82 82 [self.toView bubblingWithImages:__singleton__.images center:self.centerPoint];
83 83 }
  84 +
  85 +/**
  86 + 暂停飘心
  87 + */
  88 +- (void)suspend
  89 +{
  90 + [self.link setPaused:YES];
  91 +}
  92 +
  93 +/**
  94 + 恢复飘心
  95 + */
  96 +- (void)resume
  97 +{
  98 + [self.link setPaused:NO];
  99 +}
84 100 @end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/LiveBaseView.m
... ... @@ -16,6 +16,7 @@
16 16 #import "LVCAnimationManager.h"
17 17 #import "chatListCell.h"
18 18 #import "chatMsgModel.h"
  19 +#import "TopToolView.h"
19 20  
20 21 #define BottomToolHeight 60
21 22  
... ... @@ -25,7 +26,7 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
25 26 PopTypePriMessage //私信弹窗
26 27 };
27 28  
28   -@interface LiveBaseView ()<bottomBtnDeledate,PresentViewDelegate,UIScrollViewDelegate,UITableViewDelegate,UITableViewDataSource>
  29 +@interface LiveBaseView ()<bottomBtnDeledate,PresentViewDelegate,UIScrollViewDelegate,UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate,userClickDelegate>
29 30  
30 31 @property (nonatomic ,strong ) UIScrollView * _Nullable scrollView;
31 32 @property (nonatomic ,strong ,readwrite) UIView * _Nullable animationBaseView;//展示层View
... ... @@ -36,6 +37,11 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
36 37 @property (nonatomic ,assign ) PopType popType;
37 38 @property (nonatomic ,strong) UITableView * _Nullable chatTableView;
38 39 @property (nonatomic ,strong) NSMutableArray * _Nullable chatMsgArray;//聊天消息数组
  40 +@property (nonatomic ,strong) TopToolView * _Nullable topToolsView;
  41 +@property (nonatomic ,strong) UIView * _Nullable commentsView;
  42 +@property (nonatomic ,strong) UITextField * _Nullable commentText;
  43 +@property (nonatomic ,assign) CGFloat offsetHeight;
  44 +@property (nonatomic ,strong) UISwitch * _Nullable barrageSwitch;
39 45  
40 46 @end
41 47  
... ... @@ -52,26 +58,105 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
52 58 [self addSubview:self.closeBtn];
53 59 [self addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureClick:)]];
54 60 [[LVCAnimationManager shareManager] bubblingWithCenterPoint:CGPointMake(SCREEN_WIDTH - 50, SCREEN_HEIGHT - 50) toView:self.animationBaseView speed:1];
55   -// ChatView *chatView = [[ChatView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - 150, 200, 100)];
56   -// chatView.backgroundColor = ZXRandomColor;
57   -// [self addSubview:chatView];
  61 +
58 62 [self.animationBaseView addSubview:self.chatTableView];
59   - self.chatTableView.backgroundColor = ZXRandomColor;
60   - chatMsgModel *model = [[chatMsgModel alloc] init];
61   - model.name = @"张旭";
62   - [self.chatMsgArray addObject:model];
  63 + self.chatTableView.backgroundColor = [UIColor whiteColor];
  64 + self.chatTableView.alpha = 0.7;
  65 +
  66 + [self.animationBaseView addSubview:self.topToolsView];
  67 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
  68 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHidden:) name:UIKeyboardWillHideNotification object:nil];
63 69 }
64 70 return self;
65 71 }
66 72  
67   -#pragma mark - bottomBtnDelegate
68   -- (void)bottomActionWithType:(BtnClickType)btnType
  73 +- (void)keyboardWillShow:(NSNotification *)notify {
  74 +
  75 + NSDictionary *userInfo = notify.userInfo;
  76 + CGRect newFrameKeyboard = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];//变化前的frame
  77 + [UIView animateWithDuration:0.25 animations:^{
  78 + self.animationBaseView.top = - newFrameKeyboard.size.height + self.bottomToolView.height;
  79 + }];
  80 + self.bottomToolView.hidden = YES;
  81 +}
  82 +
  83 +- (void)keyboardWillHidden:(NSNotification *)notify {
  84 +
  85 + [UIView animateWithDuration:0.1 animations:^{
  86 + self.animationBaseView.top = 0;
  87 + [self.animationBaseView setNeedsDisplay];
  88 + }];
  89 + self.bottomToolView.hidden = NO;
  90 +}
  91 +
  92 +#pragma mark - UITextFieldDelegate
  93 +- (BOOL)textFieldShouldReturn:(UITextField *)textField
  94 +{
  95 + if (![textField.text isEqualToString:@""]) {
  96 + //send message
  97 + NSLog(@"send message");
  98 + textField.text = @"";
  99 + }
  100 + [textField resignFirstResponder];
  101 + return YES;
  102 +}
  103 +
  104 +- (void)createCommentsView {
  105 + if (!_commentsView) {
  106 +
  107 + _commentsView = [[UIView alloc] initWithFrame:CGRectMake(0.0, SCREEN_HEIGHT - 340.0, SCREEN_WIDTH, 40.0)];
  108 + _commentsView.backgroundColor = [UIColor clearColor];
  109 +
  110 + UIImageView *bgView = [[UIImageView alloc] initWithFrame:_commentsView.bounds];
  111 + bgView.image = [[UIImage imageNamed:@"textInputBgColor"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0) resizingMode:UIImageResizingModeStretch];
  112 + bgView.alpha = 0.6;
  113 + bgView.userInteractionEnabled = YES;
  114 + [_commentsView addSubview:bgView];
  115 +
  116 + _barrageSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(10, 10, 40, 30)];
  117 + _barrageSwitch.tintColor = [UIColor orangeColor];
  118 + _barrageSwitch.onTintColor = [UIColor orangeColor];
  119 + _barrageSwitch.thumbTintColor = [UIColor lightGrayColor];
  120 + _barrageSwitch.centerY = _commentsView.height * 0.5;
  121 + [bgView addSubview:_barrageSwitch];
  122 +
  123 + UIButton *sendBtn = [[UIButton alloc] initWithFrame:CGRectMake(_commentsView.width - 80, 0, 80, _commentsView.height)];
  124 + [sendBtn addTarget:self action:@selector(sendClick) forControlEvents:UIControlEventTouchUpInside];
  125 + [sendBtn setTitle:@"发送" forState:UIControlStateNormal];
  126 + [sendBtn setTitleColor:[UIColor cyanColor] forState:UIControlStateNormal];
  127 + [bgView addSubview:sendBtn];
  128 +
  129 + _commentText = [[UITextField alloc] initWithFrame:CGRectMake(_barrageSwitch.right + 20, 5, _commentsView.width - _barrageSwitch.right - 20 - 100, _commentsView.height - 10)];
  130 + _commentText.layer.borderColor = [UIColor blueColor].CGColor;
  131 + _commentText.layer.borderWidth = 1.0;
  132 + _commentText.layer.cornerRadius = 2.0;
  133 + _commentText.layer.masksToBounds = YES;
  134 + _commentText.inputAccessoryView = _commentsView;
  135 + _commentText.backgroundColor = [UIColor clearColor];
  136 + _commentText.returnKeyType = UIReturnKeySend;
  137 + _commentText.delegate = self;
  138 + _commentText.font = [UIFont systemFontOfSize:15.0];
  139 + [bgView addSubview:_commentText];
  140 + }
  141 + [[[UIApplication sharedApplication]keyWindow] addSubview:_commentsView];//添加到window上,在视图以外
  142 + [_commentText becomeFirstResponder];
  143 +}
  144 +
  145 +- (void)showCommentText {
  146 + [self createCommentsView];
  147 + [_commentText becomeFirstResponder];//再次让textView成为第一响应者
  148 +}
  149 +
  150 +#pragma mark - bottomBtnActionDelegate
  151 +- (void)bottomActionWithType:(BtnClickType)btnType button:(UIButton *)button
69 152 {
70 153 switch (btnType) {
71 154 case BtnClickTypeChat:
72 155 {
73 156 self.popType = PopTypeChat;
74 157  
  158 + [self showCommentText];
  159 + [[LVCAnimationManager shareManager] suspend];
75 160 }
76 161 break;
77 162 case BtnClickTypePriChat:
... ... @@ -82,6 +167,7 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
82 167 case BtnClickTypeGift:
83 168 {
84 169 self.popType = PopTypeGift;
  170 + [[LVCAnimationManager shareManager] suspend];
85 171 [self hiddenView:YES];
86 172 GiftListView *giftListView = [[GiftListView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - 250, SCREEN_WIDTH, 250) liveBaseView:self];
87 173 [self addSubview:giftListView];
... ... @@ -93,8 +179,6 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
93 179 giftBg.centerY = giftListView.height * 0.5;
94 180 giftBg.alpha = 0.4;
95 181 [giftListView addSubview:giftBg];
96   -
97   -
98 182 }
99 183 break;
100 184 default:
... ... @@ -109,6 +193,9 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
109 193 self.chatTableView.hidden = isHidden;
110 194 }
111 195  
  196 +/**
  197 + 清除当前pop的弹窗
  198 + */
112 199 - (void)clearCurrentPopView
113 200 {
114 201 switch (self.popType) {
... ... @@ -118,6 +205,7 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
118 205  
119 206 self.giftPopView.frame = CGRectMake(0, SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT);
120 207 [self hiddenView:NO];
  208 + [[LVCAnimationManager shareManager] resume];
121 209 } completion:^(BOOL finished) {
122 210 [self.giftPopView removeFromSuperview];
123 211 }];
... ... @@ -125,7 +213,8 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
125 213 break;
126 214 case PopTypeChat:
127 215 {
128   -
  216 + [self.commentText resignFirstResponder];
  217 + [[LVCAnimationManager shareManager] resume];
129 218 }
130 219 break;
131 220 case PopTypePriMessage:
... ... @@ -136,8 +225,32 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
136 225 default:
137 226 break;
138 227 }
139   -
140 228 }
  229 +
  230 +
  231 +#pragma mark - buttonClick
  232 +- (void)tapGestureClick:(UITapGestureRecognizer *)gesture
  233 +{
  234 + [[LVCAnimationManager shareManager] bubblingWithCenterPoint:CGPointMake(SCREEN_WIDTH - 50, SCREEN_HEIGHT - 50) toView:self.animationBaseView];
  235 + [self clearCurrentPopView];
  236 +}
  237 +
  238 +- (void)closeAction
  239 +{
  240 + [self.viewController.navigationController popViewControllerAnimated:YES];
  241 +}
  242 +
  243 +- (void)sendClick
  244 +{
  245 + [self textFieldShouldReturn:self.commentText];
  246 +}
  247 +
  248 +#pragma mark - userDetailDelegate
  249 +- (void)userClickWithModel:(chatMsgModel *)model
  250 +{
  251 + NSLog(@"点击人:%@",model.name);
  252 +}
  253 +
141 254 #pragma mark - 聊天消息列表
142 255 #pragma mark - UITableViewDataSource
143 256  
... ... @@ -149,6 +262,7 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
149 262 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
150 263 {
151 264 chatListCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([chatListCell class]) forIndexPath:indexPath];
  265 + cell.delegate = self;
152 266 [cell loadUIWithModel:self.chatMsgArray[indexPath.row]];
153 267 return cell;
154 268 }
... ... @@ -183,18 +297,6 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
183 297 NSLog(@"%@礼物的连送动画执行完成", model.giftName);
184 298 }
185 299  
186   -#pragma mark - buttonClick
187   -- (void)tapGestureClick:(UITapGestureRecognizer *)gesture
188   -{
189   - [[LVCAnimationManager shareManager] bubblingWithCenterPoint:CGPointMake(SCREEN_WIDTH - 50, SCREEN_HEIGHT - 50) toView:self.animationBaseView];
190   - [self clearCurrentPopView];
191   -}
192   -
193   -- (void)closeAction
194   -{
195   - [self.viewController.navigationController popViewControllerAnimated:YES];
196   -}
197   -
198 300 #pragma mark - UIScrollViewDelegate
199 301 - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
200 302 {
... ... @@ -247,6 +349,15 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
247 349 return _presentView;
248 350 }
249 351  
  352 +- (UISwitch *)barrageSwitch
  353 +{
  354 + if (!_barrageSwitch)
  355 + {
  356 + _barrageSwitch = [[UISwitch alloc] init];
  357 + }
  358 + return _barrageSwitch;
  359 +}
  360 +
250 361 - (BottomToolView *)bottomToolView
251 362 {
252 363 if (!_bottomToolView)
... ... @@ -259,6 +370,15 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
259 370 return _bottomToolView;
260 371 }
261 372  
  373 +- (TopToolView *)topToolsView
  374 +{
  375 + if (!_topToolsView)
  376 + {
  377 + _topToolsView = [[TopToolView alloc] initWithFrame:CGRectMake(10, 20, 150, 30)];
  378 + _topToolsView.backgroundColor = ZXRandomColor;
  379 + }
  380 + return _topToolsView;
  381 +}
262 382 - (UITableView *)chatTableView
263 383 {
264 384 if (!_chatTableView) {
... ... @@ -279,7 +399,17 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型
279 399 - (NSMutableArray *)chatMsgArray
280 400 {
281 401 if (!_chatMsgArray) {
  402 +
282 403 _chatMsgArray = [NSMutableArray array];
  404 + NSArray *names = [NSArray arrayWithObjects:@"张旭",@"老大",@"老六",@"什么人",@"金光",@"银光",@"阳光", nil];
  405 + NSArray *contents = [NSArray arrayWithObjects:@"阿萨德请问发群里发",@"阿萨德请问发群里发发染发我if顽皮的发球局平均分配WiF",@"阿萨德请问发群里发发染发我if顽皮的发球局平均分配WiFi我if为打破我姐夫我批发价为破房间我批发价我批发价为 爱神的箭怕我的哦期",@"里发发染发我if顽",@"金光神的箭怕我的哦期间",@"银光",@"阳光神的箭怕我的哦期间", nil];
  406 + for (int i = 0 ; i < names.count; i ++) {
  407 + chatMsgModel *model = [[chatMsgModel alloc] init];
  408 + model.name = names[i];
  409 + model.content = contents[i];
  410 + model.cellWidth = self.chatTableView.width - 20;
  411 + [self.chatMsgArray addObject:model];
  412 + }
283 413 }
284 414 return _chatMsgArray;
285 415 }
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/TopToolView/TopToolView.h 0 → 100644
  1 +//
  2 +// TopToolView.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by 张旭 on 2017/3/21.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface TopToolView : UIView
  12 +
  13 +- (instancetype)initWithFrame:(CGRect)frame isHost:(BOOL)isHost;
  14 +@end
... ...
LiveVideoCloud/LiveVideoCloud/Classes/Sections/InteractionSections/TopToolView/TopToolView.m 0 → 100644
  1 +//
  2 +// TopToolView.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by 张旭 on 2017/3/21.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "TopToolView.h"
  10 +
  11 +@implementation TopToolView
  12 +
  13 +- (instancetype)initWithFrame:(CGRect)frame isHost:(BOOL)isHost
  14 +{
  15 + if (self = [super initWithFrame:frame]) {
  16 +
  17 + if (isHost) {
  18 + //主播端没有自己头像
  19 +
  20 +
  21 + }else
  22 + {//观众端有主播头像
  23 +
  24 +
  25 + }
  26 + }
  27 + return self;
  28 +}
  29 +
  30 +/*
  31 +// Only override drawRect: if you perform custom drawing.
  32 +// An empty implementation adversely affects performance during animation.
  33 +- (void)drawRect:(CGRect)rect {
  34 + // Drawing code
  35 +}
  36 +*/
  37 +
  38 +@end
... ...
LiveVideoCloud/LiveVideoCloud/PrefixHeader.pch
... ... @@ -25,6 +25,7 @@
25 25 #import "AFNetworking.h"
26 26 #import "Masonry.h"
27 27 #import <CNLivePlayerSDK/CNLiveWebcastManager.h>
  28 + #import <CNLiveMsgTools/CNLiveMsgManager.h>
28 29  
29 30 #if TARGET_OS_IPHONE
30 31  
... ...
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/Chat/Contents.json 0 → 100644
  1 +{
  2 + "info" : {
  3 + "version" : 1,
  4 + "author" : "xcode"
  5 + }
  6 +}
0 7 \ No newline at end of file
... ...
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/Chat/textInputBgColor.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "textInputBgColor.png",
  6 + "scale" : "1x"
  7 + },
  8 + {
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
  15 + }
  16 + ],
  17 + "info" : {
  18 + "version" : 1,
  19 + "author" : "xcode"
  20 + },
  21 + "properties" : {
  22 + "template-rendering-intent" : "original"
  23 + }
  24 +}
0 25 \ No newline at end of file
... ...
LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/Chat/textInputBgColor.imageset/textInputBgColor.png 0 → 100644

1014 Bytes

LiveVideoCloud/LiveVideoCloud/animation.xcassets/Interaction/Gift/fighter_small80.imageset/Contents.json
... ... @@ -4,6 +4,14 @@
4 4 "idiom" : "universal",
5 5 "filename" : "fighter_small80.png",
6 6 "scale" : "1x"
  7 + },
  8 + {
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
7 15 }
8 16 ],
9 17 "info" : {
... ...