Skip to content

Commit c7a0557

Browse files
guangyaoguangyao
authored andcommitted
add 名片消息
1 parent 3a30f41 commit c7a0557

File tree

6 files changed

+113
-0
lines changed

6 files changed

+113
-0
lines changed

ios/RCTAuroraIMUI.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
4E77A3C81F30840000098CAF /* IMUITextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E77A3941F30840000098CAF /* IMUITextView.swift */; };
139139
4E77A3C91F30840000098CAF /* IMUIVideoMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E77A3951F30840000098CAF /* IMUIVideoMessageCell.swift */; };
140140
4E77A3CA1F30840000098CAF /* IMUIVoiceMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E77A3961F30840000098CAF /* IMUIVoiceMessageCell.swift */; };
141+
4E9CE01C1F9DDB1E005FC8A7 /* IMUICardMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E9CE01B1F9DDB1E005FC8A7 /* IMUICardMessageCell.swift */; };
141142
4EC4F96D1F46F0B1000C5CA6 /* MenuPopOverView.h in Headers */ = {isa = PBXBuildFile; fileRef = 4EC4F96B1F46F0B1000C5CA6 /* MenuPopOverView.h */; settings = {ATTRIBUTES = (Public, ); }; };
142143
4EC4F96E1F46F0B1000C5CA6 /* MenuPopOverView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EC4F96C1F46F0B1000C5CA6 /* MenuPopOverView.m */; };
143144
623EA9A21EE55D0800EC43AE /* RCTAuroraIMUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 623EA9991EE55D0800EC43AE /* RCTAuroraIMUI.framework */; };
@@ -318,6 +319,7 @@
318319
4E77A3941F30840000098CAF /* IMUITextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IMUITextView.swift; sourceTree = "<group>"; };
319320
4E77A3951F30840000098CAF /* IMUIVideoMessageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IMUIVideoMessageCell.swift; sourceTree = "<group>"; };
320321
4E77A3961F30840000098CAF /* IMUIVoiceMessageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IMUIVoiceMessageCell.swift; sourceTree = "<group>"; };
322+
4E9CE01B1F9DDB1E005FC8A7 /* IMUICardMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IMUICardMessageCell.swift; sourceTree = "<group>"; };
321323
4EC4F96B1F46F0B1000C5CA6 /* MenuPopOverView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuPopOverView.h; sourceTree = "<group>"; };
322324
4EC4F96C1F46F0B1000C5CA6 /* MenuPopOverView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MenuPopOverView.m; sourceTree = "<group>"; };
323325
6239E6641EDDB1F700B9AC9C /* libAuroraIMUI.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAuroraIMUI.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -657,6 +659,7 @@
657659
4E5274CD1F3C0925005FB9B9 /* IMUILocationMessageCell.swift */,
658660
4E34C33A1F3D8AB600AF4B73 /* IMUINotificationMessageCell.swift */,
659661
4E5274D11F3C5CE2005FB9B9 /* IMUIRedPacketMessageCell.swift */,
662+
4E9CE01B1F9DDB1E005FC8A7 /* IMUICardMessageCell.swift */,
660663
4E34C3381F3D45CA00AF4B73 /* IMUITransferMessageCell.swift */,
661664
4E34C33C1F3DA73900AF4B73 /* IMUIRedPacketOpenMessageCell.swift */,
662665
4E31CB2C1F5E8ED6007C3096 /* IMUIUnKnownMessageCell.swift */,
@@ -984,6 +987,7 @@
984987
4E49AE1F1F34762200B50439 /* NIMInputEmoticonButton.m in Sources */,
985988
4E49AD861F34176100B50439 /* RNCustomInputView.m in Sources */,
986989
4E49AD9E1F34178000B50439 /* UIView+Extend.m in Sources */,
990+
4E9CE01C1F9DDB1E005FC8A7 /* IMUICardMessageCell.swift in Sources */,
987991
4E77A3A51F30840000098CAF /* IMUIAudioPlayerHelper.swift in Sources */,
988992
4E77A3C11F30840000098CAF /* IMUIImageMessageCell.swift in Sources */,
989993
4E49ADD71F341BB400B50439 /* MyCacheImageView.m in Sources */,

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Models/IMUIMessageModel.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import UIKit
1919
case redpacket
2020
case transfer
2121
case url
22+
case card
2223
case account_notice
2324
case redpacketOpen
2425
case unknown
@@ -179,6 +180,9 @@ open class IMUIMessageModel: NSObject, IMUIMessageModelProtocol {
179180
bubbleContentSize = CGSize(width: UIScreen.main.bounds.width, height: 40)
180181
isShowAvatar = false
181182
break
183+
case .card:
184+
bubbleContentSize = CGSize(width: UIScreen.main.bounds.width*0.65, height: UIScreen.main.bounds.width*0.65*0.35)
185+
break
182186
case .unknown:
183187
bubbleContentSize = CGSize(width: UIScreen.main.bounds.width, height: 40)
184188
isShowAvatar = false
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
//
2+
// IMUICardMessageCell.swift
3+
// RCTAuroraIMUI
4+
//
5+
// Created by Dowin on 2017/10/23.
6+
// Copyright © 2017年 HXHG. All rights reserved.
7+
//
8+
9+
10+
import UIKit
11+
12+
class IMUICardMessageCell: IMUIBaseMessageCell {
13+
14+
var backView = UIView()
15+
var iconImg = MyCacheImageView()
16+
var nameLable = UILabel()
17+
var lineView = UIView()
18+
var titleLable = UILabel()
19+
let screenW = UIScreen.main.bounds.size.width
20+
21+
override init(frame: CGRect) {
22+
super.init(frame: frame)
23+
backView.backgroundColor = UIColor.white
24+
iconImg.contentMode = UIViewContentMode.scaleAspectFill
25+
nameLable.textColor = UIColor.black
26+
nameLable.font = UIFont.systemFont(ofSize: (screenW * 18 / 375))
27+
lineView.backgroundColor = UIColor.init(red: 230/255.0, green: 230/255.0, blue: 230/255.0, alpha: 1.0)
28+
titleLable.textColor = UIColor.gray
29+
titleLable.font = UIFont.systemFont(ofSize: (screenW * 11 / 375))
30+
31+
bubbleView.addSubview(backView)
32+
backView.addSubview(iconImg)
33+
backView.addSubview(nameLable)
34+
backView.addSubview(lineView)
35+
backView.addSubview(titleLable)
36+
}
37+
38+
required init?(coder aDecoder: NSCoder) {
39+
fatalError("init(coder:) has not been implemented")
40+
}
41+
42+
override func layoutSubviews() {
43+
super.layoutSubviews()
44+
}
45+
46+
override func presentCell(with message: IMUIMessageModelProtocol, viewCache: IMUIReuseViewCache , delegate: IMUIMessageMessageCollectionViewDelegate?) {
47+
super.presentCell(with: message, viewCache: viewCache, delegate: delegate)
48+
let layout = message.layout
49+
50+
self.backView.frame = CGRect(origin: CGPoint.zero, size: layout.bubbleFrame.size)
51+
let tmpDict = message.customDict
52+
let strTitle = tmpDict.object(forKey: "type") as! String
53+
let name = tmpDict.object(forKey: "name") as! String
54+
let imgPath = tmpDict.object(forKey: "imgPath") as! String
55+
titleLable.text = strTitle
56+
nameLable.text = name
57+
iconImg.setImageURL(imgPath, placeholderImage: "defaultHead")
58+
59+
let lineY = layout.bubbleFrame.size.height * 0.78
60+
let contentX = layout.bubbleFrame.size.width * 0.06
61+
let contentWH = layout.bubbleFrame.size.width * 0.2
62+
let contentY = (lineY - contentWH)*0.5
63+
iconImg.frame = CGRect(x:contentX,y:contentY,width:contentWH,height:contentWH)
64+
let nameX = contentX*2 + contentWH
65+
let nameW = layout.bubbleFrame.size.width - nameX
66+
nameLable.frame = CGRect(x:nameX,y:contentY,width:nameW,height:contentWH)
67+
68+
lineView.frame = CGRect(x:0,y:lineY,width:layout.bubbleFrame.size.width,height:1)
69+
70+
let tmpSize = self.heightWithFont(font: UIFont.systemFont(ofSize: (screenW * 11 / 375)), fixedWidth: layout.bubbleFrame.size.width, text: strTitle)
71+
let titleX = contentX + (contentWH - tmpSize.width)*0.5
72+
let titleH = layout.bubbleFrame.size.height - lineY
73+
titleLable.frame = CGRect(x:titleX,y:lineY,width:tmpSize.width,height:titleH)
74+
75+
}
76+
77+
func heightWithFont(font : UIFont, fixedWidth : CGFloat, text : String) -> CGSize {
78+
guard text.characters.count > 0 && fixedWidth > 0 else {
79+
80+
return CGSize.zero
81+
}
82+
let size = CGSize(width:fixedWidth, height:CGFloat(MAXFLOAT))
83+
let rect = text.boundingRect(with: size, options:.usesLineFragmentOrigin, attributes: [NSFontAttributeName : font], context:nil)
84+
85+
return rect.size
86+
}
87+
88+
}
89+
90+

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Views/IMUIMessageBubbleView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ enum IMUIMessageBubbleType {
1919
case url
2020
case account_notice
2121
case redpacketOpen
22+
case card
2223

2324
}
2425

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Views/IMUIMessageCollectionView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ open class IMUIMessageCollectionView: UIView {
8787
self.messageCollectionView.register(IMUIRedPacketOpenMessageCell.self, forCellWithReuseIdentifier: IMUIRedPacketOpenMessageCell.self.description())
8888
self.messageCollectionView.register(IMUIUnKnownMessageCell.self, forCellWithReuseIdentifier: IMUIUnKnownMessageCell.self.description())
8989
self.messageCollectionView.register(IMUIBaseMessageHeadCell.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "headView")
90+
self.messageCollectionView.register(IMUICardMessageCell.self, forCellWithReuseIdentifier: IMUICardMessageCell.self.description())
9091

9192
self.messageCollectionView.isScrollEnabled = true
9293
NotificationCenter.default.addObserver(self, selector: #selector(clickStopPlayActivity(notification:)), name: NSNotification.Name(rawValue: "StopPlayActivity"), object: nil)
@@ -248,6 +249,11 @@ extension IMUIMessageCollectionView: UICollectionViewDelegate, UICollectionViewD
248249
case .redpacketOpen:
249250
cellIdentify = IMUIRedPacketOpenMessageCell.self.description()
250251
break
252+
253+
case .card:
254+
cellIdentify = IMUICardMessageCell.self.description()
255+
break
256+
251257
case .unknown:
252258
cellIdentify = IMUIUnKnownMessageCell.self.description()
253259
break

ios/RCTAuroraIMUI/MyMessageModel.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ open class RCTMessageModel: IMUIMessageModel {
3232
static let kMsgTypeUrl = "url"
3333
static let kMsgTypeAccountNotifce = "account_notice"
3434
static let kMsgTypeRedpacketOpen = "redpacketOpen"
35+
static let kMsgTypeCard = "card"
3536
static let kMsgTypeUnKnow = "unknown"
3637

3738

@@ -229,6 +230,9 @@ open class RCTMessageModel: IMUIMessageModel {
229230
}else if typeString == RCTMessageModel.kMsgTypeRedpacketOpen {
230231
msgType = .redpacketOpen
231232
customDict = messageDic.object(forKey: RCTMessageModel.kMsgKeyExtend) as! NSMutableDictionary
233+
}else if typeString == RCTMessageModel.kMsgTypeCard{
234+
msgType = .card
235+
customDict = messageDic.object(forKey: RCTMessageModel.kMsgKeyExtend) as! NSMutableDictionary
232236
}else{
233237
msgType = .unknown
234238
}
@@ -358,6 +362,10 @@ open class RCTMessageModel: IMUIMessageModel {
358362
messageDic.setValue(RCTMessageModel.kMsgTypeRedpacketOpen, forKey: RCTMessageModel.kMsgKeyMsgType)
359363
messageDic.setValue(self.customDict, forKey: RCTMessageModel.kMsgKeyExtend)
360364
break
365+
case .card:
366+
messageDic.setValue(RCTMessageModel.kMsgTypeCard, forKey: RCTMessageModel.kMsgKeyMsgType)
367+
messageDic.setValue(self.customDict, forKey: RCTMessageModel.kMsgKeyExtend)
368+
break
361369
case .unknown:
362370
messageDic.setValue(RCTMessageModel.kMsgTypeUnKnow, forKey: RCTMessageModel.kMsgKeyMsgType)
363371
break

0 commit comments

Comments
 (0)