Skip to content

Commit bc12694

Browse files
guangyaoguangyao
authored andcommitted
Fix
1 parent 6bb2d03 commit bc12694

File tree

9 files changed

+128
-24
lines changed

9 files changed

+128
-24
lines changed

ios/RCTAuroraIMUI.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
4E49AE2D1F3476E500B50439 /* NIMInputEmoticonDefine.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E49AE2C1F3476E500B50439 /* NIMInputEmoticonDefine.h */; settings = {ATTRIBUTES = (Public, ); }; };
5858
4E49AE301F3476F800B50439 /* NSString+NIMKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E49AE2E1F3476F800B50439 /* NSString+NIMKit.h */; };
5959
4E49AE311F3476F800B50439 /* NSString+NIMKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E49AE2F1F3476F800B50439 /* NSString+NIMKit.m */; };
60+
4E4EB3A01F5112F6009A5AF8 /* IMUIBaseMessageHeadCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E4EB39F1F5112F6009A5AF8 /* IMUIBaseMessageHeadCell.swift */; };
6061
4E5274CE1F3C0925005FB9B9 /* IMUILocationMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E5274CD1F3C0925005FB9B9 /* IMUILocationMessageCell.swift */; };
6162
4E5274D21F3C5CE2005FB9B9 /* IMUIRedPacketMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E5274D11F3C5CE2005FB9B9 /* IMUIRedPacketMessageCell.swift */; };
6263
4E77A3A51F30840000098CAF /* IMUIAudioPlayerHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E77A3681F30840000098CAF /* IMUIAudioPlayerHelper.swift */; };
@@ -189,6 +190,7 @@
189190
4E49AE2C1F3476E500B50439 /* NIMInputEmoticonDefine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NIMInputEmoticonDefine.h; sourceTree = "<group>"; };
190191
4E49AE2E1F3476F800B50439 /* NSString+NIMKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+NIMKit.h"; sourceTree = "<group>"; };
191192
4E49AE2F1F3476F800B50439 /* NSString+NIMKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+NIMKit.m"; sourceTree = "<group>"; };
193+
4E4EB39F1F5112F6009A5AF8 /* IMUIBaseMessageHeadCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IMUIBaseMessageHeadCell.swift; sourceTree = "<group>"; };
192194
4E5274CD1F3C0925005FB9B9 /* IMUILocationMessageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IMUILocationMessageCell.swift; sourceTree = "<group>"; };
193195
4E5274D11F3C5CE2005FB9B9 /* IMUIRedPacketMessageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IMUIRedPacketMessageCell.swift; sourceTree = "<group>"; };
194196
4E77A3681F30840000098CAF /* IMUIAudioPlayerHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IMUIAudioPlayerHelper.swift; sourceTree = "<group>"; };
@@ -479,6 +481,7 @@
479481
isa = PBXGroup;
480482
children = (
481483
4E77A38C1F30840000098CAF /* IMUIBaseMessageCell.swift */,
484+
4E4EB39F1F5112F6009A5AF8 /* IMUIBaseMessageHeadCell.swift */,
482485
4E77A38D1F30840000098CAF /* IMUIImageMessageCell.swift */,
483486
4E77A38E1F30840000098CAF /* IMUILiveVideoMessageCell.swift */,
484487
4E77A38F1F30840000098CAF /* IMUIMessageBubbleView.swift */,
@@ -783,6 +786,7 @@
783786
4E77A3B61F30840000098CAF /* IMUIMessageModel.swift in Sources */,
784787
4E77A3BE1F30840000098CAF /* IMUIUserProtocol.swift in Sources */,
785788
4E49AE231F34764100B50439 /* NIMInputEmoticonTabView.m in Sources */,
789+
4E4EB3A01F5112F6009A5AF8 /* IMUIBaseMessageHeadCell.swift in Sources */,
786790
4E466F941F3ADECF0014451B /* M80AttributedLabelAttachment.m in Sources */,
787791
4E77A3BC1F30840000098CAF /* IMUIMessageModelProtocol.swift in Sources */,
788792
4E77A3C31F30840000098CAF /* IMUIMessageBubbleView.swift in Sources */,

ios/RCTAuroraIMUI/DWCustomView/RNCustomInputView.m

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ - (void)changeMenuView{
5555
CGFloat inputH = inpuntBar.inputViewHeight + inpuntBar.menuViewH;
5656
inpuntBar.height = inputH;
5757
showType = 1;
58+
if(!inpuntBar.onFeatureView) { return; }
59+
inpuntBar.onFeatureView(@{@"inputHeight":@(inpuntBar.height),@"showType":@(showType)});
5860
}else{
5961
inpuntBar.height = inpuntBar.inputViewHeight;
6062
[inpuntBar.inputGrowView becomeFirstResponder];
6163
}
62-
if(!inpuntBar.onFeatureView) { return; }
63-
inpuntBar.onFeatureView(@{@"inputHeight":@(inpuntBar.height),@"showType":@(showType)});
6464
}
6565
//显示ExpressionView
6666
- (void)changExpressionView{
@@ -79,15 +79,15 @@ - (void)changExpressionView{
7979
inpuntBar.expressionView.hidden = NO;
8080
CGFloat inputH = inpuntBar.inputViewHeight + expressionViewH;
8181
inpuntBar.height = inputH;
82-
showType = 2;
83-
82+
showType = 0;
83+
if(!inpuntBar.onFeatureView) { return; }
84+
inpuntBar.onFeatureView(@{@"inputHeight":@(inpuntBar.height),@"showType":@(showType)});
8485
}else{
8586
inpuntBar.expressionView.hidden = YES;
8687
inpuntBar.height = inpuntBar.inputViewHeight;
8788
[inpuntBar.inputGrowView becomeFirstResponder];
8889
}
89-
if(!inpuntBar.onFeatureView) { return; }
90-
inpuntBar.onFeatureView(@{@"inputHeight":@(inpuntBar.height),@"showType":@(showType)});
90+
9191
}
9292

9393
- (void)changeRecordView{
@@ -101,21 +101,22 @@ - (void)changeRecordView{
101101
inpuntBar.recordBtn.hidden = NO;
102102
inpuntBar.inputGrowView.hidden = YES;
103103
inpuntBar.toolH = inpuntBar.defaultToolHeight;
104+
if(!inpuntBar.onFeatureView) { return; }
105+
inpuntBar.onFeatureView(@{@"inputHeight":@(inpuntBar.height),@"showType":@(0)});
104106
}else{
105107
inpuntBar.recordBtn.hidden = YES;
106108
inpuntBar.inputGrowView.hidden = NO;
107109
inpuntBar.toolH = inpuntBar.inputViewHeight;
108110
inpuntBar.height = inpuntBar.inputViewHeight;
109111
[inpuntBar.inputGrowView becomeFirstResponder];
110112
}
111-
if(!inpuntBar.onFeatureView) { return; }
112-
inpuntBar.onFeatureView(@{@"inputHeight":@(inpuntBar.height),@"showType":@(0)});
113+
113114
}
114115

115116
#pragma mark -- DWIputBarDelegate
116117
//点击按钮
117118
- (void)inputBarClickBtn:(UIButton *)btn{
118-
NSLog(@"%zd",btn.tag);
119+
NSLog(@"~inputBarClickBtn:%zd",btn.tag);
119120
switch (btn.tag) {
120121
case DWInputBarControlBtnTypeRecord:
121122
{

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Models/IMUIMessageModel.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,20 @@ open class IMUIMessageModel: NSObject, IMUIMessageModelProtocol {
143143
bubbleContentSize = CGSize(width: 120, height: 160)
144144
break
145145
case .location:
146-
let locationW = UIScreen.main.bounds.width*0.7
146+
let locationW = UIScreen.main.bounds.width*0.625
147147
let strTitle = self.customDict.object(forKey: "title") as! String
148148
let tmpSize = heightWithFont(font: UIFont.systemFont(ofSize: (screenW * 13 / 375)), fixedWidth: (locationW-15), text: strTitle)
149-
bubbleContentSize = CGSize(width: locationW, height: UIScreen.main.bounds.width*0.35+tmpSize.height+15 )
149+
bubbleContentSize = CGSize(width: locationW, height: UIScreen.main.bounds.width*0.625*0.5+tmpSize.height+15 )
150150
break
151151
case .notification:
152152
bubbleContentSize = CGSize(width: UIScreen.main.bounds.width, height: 40)
153153
isShowAvatar = false
154154
break
155155
case .redpacket:
156-
bubbleContentSize = CGSize(width: UIScreen.main.bounds.width*0.7, height: UIScreen.main.bounds.width*0.245)
156+
bubbleContentSize = CGSize(width: UIScreen.main.bounds.width*0.62, height: UIScreen.main.bounds.width*0.62*0.35)
157157
break
158158
case .transfer:
159-
bubbleContentSize = CGSize(width: UIScreen.main.bounds.width*0.7, height: UIScreen.main.bounds.width*0.245)
159+
bubbleContentSize = CGSize(width: UIScreen.main.bounds.width*0.62, height: UIScreen.main.bounds.width*0.62*0.35)
160160
break
161161
case .url:
162162
bubbleContentSize = CGSize(width: 100, height: 100)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// IMUIBaseMessageHeadCell.swift
3+
// RCTAuroraIMUI
4+
//
5+
// Created by Dowin on 2017/8/26.
6+
// Copyright © 2017年 HXHG. All rights reserved.
7+
//
8+
9+
//
10+
11+
import UIKit
12+
13+
open class IMUIBaseMessageHeadCell: UICollectionViewCell {
14+
var actView: UIActivityIndicatorView!
15+
16+
override init(frame: CGRect) {
17+
super.init(frame: frame)
18+
self.backgroundColor = UIColor.clear
19+
actView = UIActivityIndicatorView.init(activityIndicatorStyle: UIActivityIndicatorViewStyle.gray)
20+
actView.hidesWhenStopped = true
21+
self.addSubview(self.actView)
22+
self.setupSubViews()
23+
}
24+
25+
public func playActView(){
26+
self.actView.startAnimating()
27+
}
28+
29+
public func stopActView(){
30+
self.actView.stopAnimating()
31+
}
32+
33+
fileprivate func setupSubViews() {
34+
self.actView.center = CGPoint(x:UIScreen.main.bounds.size.width*0.5,y:5)
35+
36+
37+
}
38+
39+
required public init?(coder aDecoder: NSCoder) {
40+
fatalError("init(coder:) has not been implemented")
41+
}
42+
43+
}

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Views/IMUIMessageCollectionView.swift

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ import UIKit
1010

1111

1212
open class IMUIMessageCollectionView: UIView {
13-
13+
1414
@IBOutlet var view: UIView!
1515
@IBOutlet open weak var messageCollectionView: UICollectionView!
1616
var isPull = false
1717
var viewCache = IMUIReuseViewCache()
18+
var headView = IMUIBaseMessageHeadCell()
1819

1920
// React Native Property ---->
2021
var action: Array<Any> {
@@ -44,8 +45,9 @@ open class IMUIMessageCollectionView: UIView {
4445
view.frame = self.bounds
4546
self.chatDataManager = IMUIChatDataManager()
4647
self.setupMessageCollectionView()
48+
4749
}
48-
50+
4951
required public init?(coder aDecoder: NSCoder) {
5052
super.init(coder: aDecoder)
5153

@@ -80,8 +82,11 @@ open class IMUIMessageCollectionView: UIView {
8082
self.messageCollectionView.register(IMUIRedPacketMessageCell.self, forCellWithReuseIdentifier: IMUIRedPacketMessageCell.self.description())
8183
self.messageCollectionView.register(IMUITransferMessageCell.self, forCellWithReuseIdentifier: IMUITransferMessageCell.self.description())
8284
self.messageCollectionView.register(IMUIRedPacketOpenMessageCell.self, forCellWithReuseIdentifier: IMUIRedPacketOpenMessageCell.self.description())
85+
self.messageCollectionView.register(IMUIBaseMessageHeadCell.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "headView")
8386

8487
self.messageCollectionView.isScrollEnabled = true
88+
89+
NotificationCenter.default.addObserver(self, selector: #selector(clickStopPlayActivity(notification:)), name: NSNotification.Name(rawValue: "StopPlayActivity"), object: nil)
8590
}
8691

8792
open subscript(index: Int) -> IMUIMessageModelProtocol {
@@ -138,13 +143,15 @@ open class IMUIMessageCollectionView: UIView {
138143
}
139144

140145
open func insertMessages(with messages:[IMUIMessageModel]) {
146+
141147
self.chatDataManager.insertMessages(with: messages)
142148
self.messageCollectionView.reloadData()
143-
var scrollIndex = messages.count
144-
if scrollIndex>1 {
145-
scrollIndex = scrollIndex - 1
146-
}
149+
let scrollIndex = messages.count
150+
// if scrollIndex>1 {
151+
// scrollIndex = scrollIndex
152+
// }
147153
self.scrollTo(index: scrollIndex)
154+
148155
}
149156

150157
open func updateMessage(with message:IMUIMessageModel) {
@@ -154,6 +161,16 @@ open class IMUIMessageCollectionView: UIView {
154161
self.messageCollectionView.reloadItems(at: [indexPath])
155162
}
156163
}
164+
deinit {
165+
NotificationCenter.default.removeObserver(self)
166+
}
167+
168+
//通知方法
169+
func clickStopPlayActivity(notification: Notification){
170+
DispatchQueue.main.async(execute: {
171+
self.headView.stopActView()
172+
})
173+
}
157174
}
158175

159176
// MARK: - UICollectionViewDelegate, UICollectionViewDataSource
@@ -247,20 +264,38 @@ extension IMUIMessageCollectionView: UICollectionViewDelegate, UICollectionViewD
247264
self.delegate?.messageCollectionView?(collectionView, didEndDisplaying: didEndDisplaying, forItemAt: forItemAt, model: messageModel)
248265
}
249266
}
250-
}
267+
268+
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
269+
return CGSize(width: UIScreen.main.bounds.width, height: 30)
270+
}
251271

272+
public func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
273+
let headCell = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "headView", for: indexPath) as! IMUIBaseMessageHeadCell
274+
self.headView = headCell
275+
return headCell
276+
}
277+
278+
}
252279

253280

254281
extension IMUIMessageCollectionView: UIScrollViewDelegate {
255282
public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
256283
self.delegate?.messageCollectionView?(self.messageCollectionView)
257284
}
258285
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
286+
DispatchQueue.main.async(execute: {
287+
self.headView.playActView()
288+
})
259289
if scrollView.contentOffset.y < -30 {
260290
isPull = true
261291
}else if scrollView.contentOffset.y == 0 && isPull{
292+
262293
isPull = false
263294
self.delegate?.messageCollectionView?(reloadMoreData:"")
295+
}else{
296+
DispatchQueue.main.async(execute: {
297+
self.headView.stopActView()
298+
})
264299
}
265300
}
266301

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Views/IMUIRedPacketMessageCell.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ class IMUIRedPacketMessageCell: IMUIBaseMessageCell {
2323
contentLable.textColor = UIColor.white
2424
contentLable.font = UIFont.systemFont(ofSize: (screenW * 16 / 375))
2525
tipsLabel.textColor = UIColor.white
26-
tipsLabel.font = UIFont.systemFont(ofSize: (screenW * 15 / 375))
26+
tipsLabel.font = UIFont.systemFont(ofSize: (screenW * 12 / 375))
2727
tipsLabel.text = "领取红包"
2828
titleLable.textColor = UIColor.gray
29-
titleLable.font = UIFont.systemFont(ofSize: (screenW * 16 / 375))
29+
titleLable.font = UIFont.systemFont(ofSize: (screenW * 12 / 375))
3030
titleLable.text = "红包"
3131
titleLable.textAlignment = NSTextAlignment.center
3232

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Views/IMUIRedPacketOpenMessageCell.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,44 @@ class IMUIRedPacketOpenMessageCell: IMUIBaseMessageCell {
2222
var contView = UIView()
2323
var titleLable = UILabel()
2424
var redImg = UIImageView()
25+
var tapRedView = UIView()
26+
var redGesture = UITapGestureRecognizer.init()
2527
let screenW = UIScreen.main.bounds.size.width
2628
override init(frame: CGRect) {
2729
super.init(frame: frame)
2830
titleLable.textColor = UIColor.white
2931
titleLable.font = UIFont.systemFont(ofSize: (screenW * 13 / 375))
3032
titleLable.textAlignment = NSTextAlignment.center
33+
self.redGesture.addTarget(self, action: #selector(self.clickTapRedView))
34+
tapRedView.isUserInteractionEnabled = true
35+
tapRedView.addGestureRecognizer(self.redGesture)
36+
self.redGesture.numberOfTapsRequired = 1
3137
redImg.image = UIImage.init(named: "packet_tip")
3238
contView.backgroundColor = UIColor.init(red: 200/255.0, green: 200/255.0, blue: 200/255.0, alpha: 0.7)
3339
contView.layer.cornerRadius = 5
3440
contView.clipsToBounds = true
3541
contView.addSubview(redImg)
3642
contView.addSubview(titleLable)
37-
43+
contView.addSubview(tapRedView)
3844
bubbleView.addSubview(contView)
3945
}
4046

4147
required init?(coder aDecoder: NSCoder) {
4248
fatalError("init(coder:) has not been implemented")
4349
}
4450

51+
override func tapBubbleView() {
52+
53+
}
54+
4555
override func layoutSubviews() {
4656
super.layoutSubviews()
4757
}
4858

59+
func clickTapRedView() {
60+
self.delegate?.messageCollectionView?(didTapMessageBubbleInCell: self, model: self.message!)
61+
}
62+
4963
override func presentCell(with message: IMUIMessageModelProtocol, viewCache: IMUIReuseViewCache , delegate: IMUIMessageMessageCollectionViewDelegate?) {
5064
super.presentCell(with: message, viewCache: viewCache, delegate: delegate)
5165
let layout = message.layout
@@ -55,6 +69,7 @@ class IMUIRedPacketOpenMessageCell: IMUIBaseMessageCell {
5569
let tmpArr = rangesOf(searchString: "红包", inString: strTitle)
5670

5771
for tmpR in tmpArr {
72+
5873
attString.addAttribute(NSForegroundColorAttributeName, value: UIColor.init(red: 216/255.0, green: 38/255.0, blue: 23/255.0, alpha: 1), range: tmpR as! NSRange)
5974
}
6075

@@ -65,6 +80,9 @@ class IMUIRedPacketOpenMessageCell: IMUIBaseMessageCell {
6580
redImg.frame = CGRect(origin: CGPoint(x:6, y:3), size: CGSize(width:14, height:18))
6681
contView.frame = CGRect(origin: CGPoint(x:contentX, y:contentY), size: CGSize(width:titleW+24, height:24))
6782
self.titleLable.frame = CGRect(origin: CGPoint(x:22, y:0), size: CGSize(width:titleW, height:24))
83+
self.tapRedView.frame.size = CGSize(width:40,height:24)
84+
self.tapRedView.frame.origin = CGPoint(x:titleW-16,y:0)
85+
self.tapRedView.backgroundColor = UIColor.clear
6886

6987
}
7088
func widthWithFont(font : UIFont, text : String, maxWidth: CGFloat) -> CGFloat {

ios/RCTAuroraIMUI/RCTAuroraIMUIModule.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#define kClickLongTouchShowMenu @"kClickLongTouchShowMenuNotification"
3131
#define kStopPlayVoice @"kStopPlayVoice"
3232

33-
3433
@interface RCTAuroraIMUIModule : NSObject <RCTBridgeModule>
3534

3635
@end

ios/RCTAuroraIMUI/RCTAuroraIMUIModule.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,8 @@ - (id)init {
8484
[[NSNotificationCenter defaultCenter] postNotificationName:kStopPlayVoice object: nil];
8585
}
8686

87+
RCT_EXPORT_METHOD(stopPlayActivity) {
88+
[[NSNotificationCenter defaultCenter] postNotificationName:@"StopPlayActivity" object: nil];
89+
}
90+
8791
@end

0 commit comments

Comments
 (0)