Skip to content

Commit 61f8bab

Browse files
guangyaoguangyao
authored andcommitted
增加了黑名单、非好友提醒
1 parent 2587121 commit 61f8bab

File tree

6 files changed

+86
-16
lines changed

6 files changed

+86
-16
lines changed

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Layout/IMUIMessageCellLayout.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ open class IMUIMessageCellLayout: NSObject, IMUIMessageCellLayoutProtocal {
3030

3131
public static var cellWidth: CGFloat = 0
3232

33-
public static var cellContentInset: UIEdgeInsets = UIEdgeInsets(top: 0, left: 10, bottom: 10, right: 10)
33+
public static var cellContentInset: UIEdgeInsets = UIEdgeInsets(top: 5, left: 10, bottom:
34+
5, right: 10)
3435

3536
public static var statusViewSize: CGSize = CGSize(width: 30, height: 30)
3637

@@ -230,9 +231,7 @@ open class IMUIMessageCellLayout: NSObject, IMUIMessageCellLayoutProtocal {
230231
let timeWidth = IMUIMessageCellLayout.cellWidth -
231232
cellContentInset.left -
232233
cellContentInset.right
233-
234-
235-
234+
236235
return CGRect(x: cellContentInset.left,
237236
y: cellContentInset.top,
238237
width: timeWidth,
@@ -293,7 +292,9 @@ open class IMUIMessageCellLayout: NSObject, IMUIMessageCellLayoutProtocal {
293292
}
294293
if !isNeedShowInComingAvatar {
295294
bubbleX = 0
296-
bubbleY = bubbleY + 10
295+
if isNeedShowTime{
296+
bubbleY = bubbleY+5
297+
}
297298
}
298299
return CGRect(x: bubbleX,
299300
y: bubbleY,

ios/RCTAuroraIMUI/IMUIMessageCollectionView/M80AttributedLabel/M80AttributedLabel/M80AttributedLabel.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ - (CGSize)getTheLabelBubbleSize:(CGSize)maxSize{
654654
}else{
655655
tmpW = tmpW + 3;
656656
}
657-
if (tmpH < 40) {
657+
if (tmpH < 35) {
658658
tmpH = 40;
659659
}else{
660660
tmpH += 20;

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Models/IMUIMessageModel.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ open class IMUIMessageModel: NSObject, IMUIMessageModelProtocol {
158158
bubbleContentSize = CGSize(width: locationW, height: UIScreen.main.bounds.width*0.625*0.5+tmpSize.height+15 )
159159
break
160160
case .notification:
161-
bubbleContentSize = CGSize(width: UIScreen.main.bounds.width, height: 40)
161+
let strTitle = self.customDict.object(forKey: "tipMsg") as! String
162+
let tmpSize = heightWithFont(font: UIFont.systemFont(ofSize: 12), fixedWidth: (screenW*0.8), text: strTitle)
163+
bubbleContentSize = CGSize(width: UIScreen.main.bounds.width, height: tmpSize.height+10)
162164
isShowAvatar = false
163165
break
164166
case .redpacket:
@@ -171,7 +173,7 @@ open class IMUIMessageModel: NSObject, IMUIMessageModelProtocol {
171173
bubbleContentSize = CGSize(width: 100, height: 100)
172174
break
173175
case .account_notice:
174-
bubbleContentSize = CGSize(width: 200, height: 30)
176+
bubbleContentSize = CGSize(width: 200, height: 40)
175177
break
176178
case .redpacketOpen:
177179
bubbleContentSize = CGSize(width: UIScreen.main.bounds.width, height: 40)

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Views/IMUIBaseMessageCell.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ enum IMUIMessageCellType {
1414
case outgoing
1515
}
1616

17-
open class IMUIBaseMessageCell: UICollectionViewCell, IMUIMessageCellProtocal,MenuPopOverViewDelegate {
17+
open class IMUIBaseMessageCell: UICollectionViewCell, IMUIMessageCellProtocal,MenuPopOverViewDelegate,UIAlertViewDelegate {
1818
public var bubbleView: IMUIMessageBubbleView
1919
lazy var avatarImage = MyCacheImageView()
2020
lazy var timeBackView = UIView()
@@ -294,9 +294,18 @@ open class IMUIBaseMessageCell: UICollectionViewCell, IMUIMessageCellProtocal,Me
294294

295295

296296
func tapSatusView() {
297-
self.delegate?.messageCollectionView?(didTapStatusViewInCell: self, model: self.message!)
297+
let alter = UIAlertView.init(title: "重发该消息?", message: "", delegate: self, cancelButtonTitle: "取消", otherButtonTitles: "确定")
298+
alter.show()
298299
}
299300

301+
public func alertView(_ alertView:UIAlertView, clickedButtonAt buttonIndex: Int){
302+
if(buttonIndex==alertView.cancelButtonIndex){
303+
print("取消")
304+
}else{
305+
self.delegate?.messageCollectionView?(didTapStatusViewInCell: self, model: self.message!)
306+
}
307+
}
308+
300309
func didDisAppearCell() {
301310
}
302311

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Views/IMUINotificationMessageCell.swift

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@ class IMUINotificationMessageCell: IMUIBaseMessageCell {
1414
var titleLable = UILabel()
1515
var backView = UIView()
1616
let screenW = UIScreen.main.bounds.size.width
17+
// let labelGest = UITapGestureRecognizer.init()
1718

1819
override init(frame: CGRect) {
1920
super.init(frame: frame)
2021
titleLable.textColor = UIColor.white
2122
titleLable.font = UIFont.systemFont(ofSize: 12)
22-
titleLable.textAlignment = NSTextAlignment.center
23+
// titleLable.font = UIFont.init(name: "helvetica", size: 12)
24+
titleLable.numberOfLines = 0
25+
titleLable.isUserInteractionEnabled = true
2326
backView.backgroundColor = UIColor.init(red: 206/255.0, green: 206/255.0, blue: 206/255.0, alpha: 1)
2427
backView.layer.cornerRadius = 5
2528
backView.clipsToBounds = true
2629
backView.addSubview(titleLable)
30+
// labelGest.addTarget(self, action: #selector(self.clickTapValidation(sender:)))
2731
bubbleView.addSubview(backView)
2832
}
2933

@@ -40,12 +44,25 @@ class IMUINotificationMessageCell: IMUIBaseMessageCell {
4044
let layout = message.layout
4145
let tmpDict = message.customDict
4246
let strTitle = tmpDict.object(forKey: "tipMsg") as! String
43-
self.titleLable.text = strTitle
4447
let titleSize = sizeWithFont(font: UIFont.systemFont(ofSize: 12), text: strTitle, maxWidth: layout.bubbleFrame.size.width*0.8)
48+
if titleSize.height < 20{//一行
49+
titleLable.textAlignment = NSTextAlignment.center
50+
}else{
51+
titleLable.textAlignment = NSTextAlignment.left
52+
}
53+
4554
let titleX = (layout.bubbleFrame.size.width - titleSize.width - 10) * 0.5
46-
let titleY = (layout.bubbleFrame.size.height - titleSize.height - 10) * 0.3
47-
self.backView.frame = CGRect(origin: CGPoint(x:titleX, y:titleY), size: CGSize(width:titleSize.width+10, height:titleSize.height+10));
48-
self.titleLable.frame = self.backView.bounds
55+
let titleY = (layout.bubbleFrame.size.height - titleSize.height - 10) * 0.5
56+
self.backView.frame = CGRect(origin: CGPoint(x:titleX, y:titleY), size: CGSize(width:titleSize.width+10, height:titleSize.height+10))
57+
self.titleLable.frame = CGRect(origin: CGPoint(x:5, y:5), size: CGSize(width:titleSize.width, height:titleSize.height))
58+
let attString = NSMutableAttributedString.init(string: strTitle)
59+
// if strTitle.hasSuffix("发送朋友验证"){
60+
// self.titleLable.addGestureRecognizer(labelGest)
61+
// let tmpArr = rangesOf(searchString: "发送朋友验证", inString: strTitle)
62+
// let tmpR:NSRange = tmpArr.lastObject as! NSRange
63+
// attString.addAttribute(NSForegroundColorAttributeName, value: UIColor.init(red: 35/255.0, green: 141/255.0, blue: 250/255.0, alpha: 1), range: tmpR)
64+
// }
65+
self.titleLable.attributedText = attString
4966

5067
}
5168
func sizeWithFont(font : UIFont, text : String, maxWidth: CGFloat) -> CGSize {
@@ -60,6 +77,48 @@ class IMUINotificationMessageCell: IMUIBaseMessageCell {
6077

6178
return rect.size
6279
}
80+
81+
func rangesOf(searchString : String, inString : String ) -> NSMutableArray {
82+
let results : NSMutableArray = NSMutableArray.init()
83+
let nsInStr = inString as NSString
84+
var searchRange = NSMakeRange(0, nsInStr.length)
85+
while nsInStr.range(of: searchString, options: NSString.CompareOptions(rawValue: 0), range: searchRange).location != NSNotFound {
86+
let tmpRange = nsInStr.range(of: searchString, options: NSString.CompareOptions(rawValue: 0), range: searchRange)
87+
results.add(tmpRange)
88+
searchRange = NSMakeRange(NSMaxRange(tmpRange), nsInStr.length - NSMaxRange(tmpRange))
89+
}
90+
return results
91+
}
92+
93+
func clickTapValidation(sender : UITapGestureRecognizer){
94+
let touchPoint = sender.location(in: self.titleLable)
95+
let path:CGMutablePath = CGMutablePath()
96+
path.addRect(CGRect(x:0, y:0, width:self.titleLable.frame.size.width, height:self.titleLable.frame.size.height))
97+
let framesetter = CTFramesetterCreateWithAttributedString(self.titleLable.attributedText!)
98+
let ctframe = CTFramesetterCreateFrame(framesetter, CFRangeMake(0, 0), path, nil)
99+
//获取行数
100+
let lines:NSArray = CTFrameGetLines(ctframe)
101+
print("line:\(CFArrayGetCount(lines)) line:\(self.titleLable.numberOfLines) height:\(self.titleLable.frame.size.height)")
102+
let numOfLine:NSInteger = self.titleLable.numberOfLines > 0 ? min(self.titleLable.numberOfLines, CFArrayGetCount(lines)) : CFArrayGetCount(lines)
103+
if numOfLine != 0 {
104+
var lineOrigins:[CGPoint] = Array(repeating:.zero,count:numOfLine)
105+
CTFrameGetLineOrigins(ctframe, CFRangeMake(0, numOfLine), &lineOrigins)
106+
for i in 0..<numOfLine{
107+
var baseLineOri = lineOrigins[i]
108+
baseLineOri.y = self.titleLable.frame.height - baseLineOri.y
109+
let line:CTLine = lines[i] as! CTLine
110+
var ascent:CGFloat = 0.0
111+
var descent:CGFloat = 0.0
112+
var leading:CGFloat = 0.0
113+
let lineWidth:CGFloat = CGFloat(CTLineGetTypographicBounds(line, &ascent, &descent, &leading))
114+
let lineFrame = CGRect(x:baseLineOri.x, y:baseLineOri.y-ascent, width:lineWidth, height:ascent+descent)
115+
if lineFrame.contains(touchPoint){
116+
let index = CTLineGetStringIndexForPosition(line, touchPoint)
117+
print("index:\(index)")
118+
}
119+
}
120+
}
121+
}
63122
}
64123

65124

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Views/IMUIRedPacketOpenMessageCell.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ class IMUIRedPacketOpenMessageCell: IMUIBaseMessageCell {
120120
searchRange = NSMakeRange(NSMaxRange(tmpRange), nsInStr.length - NSMaxRange(tmpRange))
121121
}
122122
return results
123-
124123
}
125124

126125
}

0 commit comments

Comments
 (0)