Skip to content

Commit 39318d9

Browse files
authored
Merge pull request #383 from maghzchenyu/im_stable
v8.9.0
2 parents a2dd6fa + c483b85 commit 39318d9

File tree

24 files changed

+296
-212
lines changed

24 files changed

+296
-212
lines changed

NEChatUIKit/NEChatUIKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
1616
#
1717

1818
s.name = 'NEChatUIKit'
19-
s.version = '9.7.0'
19+
s.version = '8.9.0'
2020
s.summary = 'Chat Module of IM.'
2121

2222
# This description is used to generate tags and improve search results.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x"
6+
},
7+
{
8+
"filename" : "location_default 1.png",
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"filename" : "location_default.png",
14+
"idiom" : "universal",
15+
"scale" : "3x"
16+
}
17+
],
18+
"info" : {
19+
"author" : "xcode",
20+
"version" : 1
21+
}
22+
}
34.8 KB
Loading
34.8 KB
Loading

NEChatUIKit/NEChatUIKit/Classes/Chat/Helper/ChatDeduplicationHelper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class ChatDeduplicationHelper: NSObject, NIMLoginManagerDelegate {
2727
}
2828

2929
public func onLogin(_ step: NIMLoginStep) {
30-
if step == .logout {
30+
if step == .logining {
3131
clearCache()
3232
}
3333
}

NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageCell.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ open class NEBasePinMessageCell: UITableViewCell {
4949
label.font = UIFont.systemFont(ofSize: 12.0)
5050
label.textColor = .ne_greyText
5151
label.translatesAutoresizingMaskIntoConstraints = false
52+
label.accessibilityIdentifier = "id.time"
5253
return label
5354
}()
5455

NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageLocationCell.swift

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,18 @@ open class NEBasePinMessageLocationCell: NEBasePinMessageCell {
3131
label.text = chatLocalizable("no_map_plugin")
3232
label.textAlignment = .center
3333
label.textColor = UIColor.ne_greyText
34+
label.isHidden = true
3435
return label
3536
}()
3637

38+
let pointImage = UIImageView()
39+
40+
public lazy var mapImageView: UIImageView = {
41+
let image = UIImageView()
42+
image.translatesAutoresizingMaskIntoConstraints = false
43+
return image
44+
}()
45+
3746
var mapView: UIView?
3847

3948
override open func awakeFromNib() {
@@ -91,34 +100,29 @@ open class NEBasePinMessageLocationCell: NEBasePinMessageCell {
91100
subTitleLabel.topAnchor.constraint(equalTo: locationTitleLabel.bottomAnchor, constant: 4),
92101
])
93102

94-
if let map = NEChatKitClient.instance.delegate?.getCellMapView?() as? UIView {
95-
mapView = map
96-
back.addSubview(map)
97-
map.translatesAutoresizingMaskIntoConstraints = false
98-
NSLayoutConstraint.activate([
99-
map.leftAnchor.constraint(equalTo: back.leftAnchor),
100-
map.bottomAnchor.constraint(equalTo: back.bottomAnchor),
101-
map.rightAnchor.constraint(equalTo: back.rightAnchor),
102-
map.topAnchor.constraint(equalTo: subTitleLabel.bottomAnchor, constant: 4),
103-
])
104-
105-
let pointImage = UIImageView()
106-
pointImage.translatesAutoresizingMaskIntoConstraints = false
107-
pointImage.image = coreLoader.loadImage("location_point")
108-
map.addSubview(pointImage)
109-
NSLayoutConstraint.activate([
110-
pointImage.centerXAnchor.constraint(equalTo: map.centerXAnchor),
111-
pointImage.bottomAnchor.constraint(equalTo: map.bottomAnchor, constant: -30),
112-
])
113-
} else {
114-
back.addSubview(emptyLabel)
115-
NSLayoutConstraint.activate([
116-
emptyLabel.leftAnchor.constraint(equalTo: back.leftAnchor),
117-
emptyLabel.rightAnchor.constraint(equalTo: back.rightAnchor),
118-
emptyLabel.bottomAnchor.constraint(equalTo: back.bottomAnchor, constant: -40),
119-
])
120-
}
121-
mapView?.isUserInteractionEnabled = false
103+
back.addSubview(mapImageView)
104+
NSLayoutConstraint.activate([
105+
mapImageView.leftAnchor.constraint(equalTo: back.leftAnchor),
106+
mapImageView.bottomAnchor.constraint(equalTo: back.bottomAnchor),
107+
mapImageView.rightAnchor.constraint(equalTo: back.rightAnchor),
108+
mapImageView.topAnchor.constraint(equalTo: subTitleLabel.bottomAnchor, constant: 4),
109+
])
110+
111+
pointImage.translatesAutoresizingMaskIntoConstraints = false
112+
pointImage.image = coreLoader.loadImage("location_point")
113+
mapImageView.addSubview(pointImage)
114+
NSLayoutConstraint.activate([
115+
pointImage.centerXAnchor.constraint(equalTo: mapImageView.centerXAnchor),
116+
pointImage.bottomAnchor.constraint(equalTo: mapImageView.bottomAnchor, constant: -30),
117+
])
118+
119+
back.addSubview(emptyLabel)
120+
NSLayoutConstraint.activate([
121+
emptyLabel.leftAnchor.constraint(equalTo: back.leftAnchor),
122+
emptyLabel.rightAnchor.constraint(equalTo: back.rightAnchor),
123+
emptyLabel.bottomAnchor.constraint(equalTo: back.bottomAnchor, constant: -40),
124+
])
125+
122126
if let gesture = contentGesture {
123127
back.addGestureRecognizer(gesture)
124128
}
@@ -129,8 +133,16 @@ open class NEBasePinMessageLocationCell: NEBasePinMessageCell {
129133
if let m = item.chatmodel as? MessageLocationModel {
130134
locationTitleLabel.text = m.title
131135
subTitleLabel.text = m.subTitle
132-
if let lat = m.lat, let lng = m.lng, let map = mapView {
133-
NEChatKitClient.instance.delegate?.setMapviewLocation?(lat: lat, lng: lng, mapview: map)
136+
if let lat = m.lat, let lng = m.lng {
137+
if let url = NEChatKitClient.instance.delegate?.getMapImageUrl?(lat: lat, lng: lng) {
138+
NELog.infoLog(className(), desc: #function + "location image url = \(url)")
139+
mapImageView.sd_setImage(with: URL(string: url))
140+
emptyLabel.isHidden = true
141+
pointImage.isHidden = false
142+
} else {
143+
emptyLabel.isHidden = false
144+
pointImage.isHidden = true
145+
}
134146
}
135147
}
136148
}

NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageTextCell.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ open class NEBasePinMessageTextCell: NEBasePinMessageCell {
1313
label.translatesAutoresizingMaskIntoConstraints = false
1414
label.isUserInteractionEnabled = true
1515
label.numberOfLines = 3
16+
label.accessibilityIdentifier = "id.message"
1617
return label
1718
}()
1819

NEChatUIKit/NEChatUIKit/Classes/Chat/View/ChatView/NEBaseChatInputView.swift

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ open class NEBaseChatInputView: UIView, ChatRecordViewDelegate,
267267
let addString = NEEmotionTool.getAttWithStr(str: text, font: .systemFont(ofSize: 16))
268268
mutaString.replaceCharacters(in: range, with: addString)
269269
textView.attributedText = mutaString
270+
textView.accessibilityValue = text
270271
DispatchQueue.main.async {
271272
textView.selectedRange = NSMakeRange(range.location + addString.length, 0)
272273
}
@@ -305,6 +306,9 @@ open class NEBaseChatInputView: UIView, ChatRecordViewDelegate,
305306
if let findRange = findShowPosition(range: range, attribute: textView.attributedText) {
306307
textView.selectedRange = NSMakeRange(findRange.location + findRange.length, 0)
307308
}
309+
310+
textView.scrollRangeToVisible(NSMakeRange(textView.selectedRange.location, 1))
311+
textView.accessibilityValue = getRealSendText(textView.attributedText)
308312
}
309313

310314
@available(iOS 10.0, *)
@@ -349,34 +353,12 @@ open class NEBaseChatInputView: UIView, ChatRecordViewDelegate,
349353
textView.deleteBackward()
350354
print("delete ward")
351355
} else {
352-
if let font = textView.font {
353-
let attribute = NEEmotionTool.getAttWithStr(
354-
str: description,
355-
font: font,
356-
CGPoint(x: 0, y: -4)
357-
)
358-
print("attribute : ", attribute)
359-
let mutaAttribute = NSMutableAttributedString()
360-
if let origin = textView.attributedText {
361-
mutaAttribute.append(origin)
362-
}
363-
attribute.enumerateAttribute(
364-
NSAttributedString.Key.attachment,
365-
in: NSMakeRange(0, attribute.length)
366-
) { value, range, stop in
367-
if let neAttachment = value as? NEEmotionAttachment {
368-
print("ne attachment bounds ", neAttachment.bounds)
369-
}
370-
}
371-
mutaAttribute.append(attribute)
372-
mutaAttribute.addAttribute(
373-
NSAttributedString.Key.font,
374-
value: font,
375-
range: NSMakeRange(0, mutaAttribute.length)
376-
)
377-
textView.attributedText = mutaAttribute
378-
textView.scrollRangeToVisible(NSMakeRange(textView.attributedText.length, 1))
379-
}
356+
let range = textView.selectedRange
357+
let attribute = NEEmotionTool.getAttWithStr(str: description, font: .systemFont(ofSize: 16))
358+
let mutaAttribute = NSMutableAttributedString(attributedString: textView.attributedText)
359+
mutaAttribute.insert(attribute, at: range.location)
360+
textView.attributedText = mutaAttribute
361+
textView.selectedRange = NSMakeRange(range.location + attribute.length, 0)
380362
}
381363
}
382364

NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageLocationCell.swift

Lines changed: 86 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ open class FunChatMessageLocationCell: FunChatMessageBaseCell {
3434
}()
3535

3636
public var mapViewLeft: UIView?
37+
38+
public var mapImageViewLeft: UIImageView = {
39+
let imageView = UIImageView()
40+
imageView.translatesAutoresizingMaskIntoConstraints = false
41+
imageView.contentMode = .scaleAspectFill
42+
imageView.clipsToBounds = true
43+
return imageView
44+
}()
45+
3746
let backgroundViewLeft = UIView()
3847

3948
// Right
@@ -64,8 +73,31 @@ open class FunChatMessageLocationCell: FunChatMessageBaseCell {
6473
}()
6574

6675
public var mapViewRight: UIView?
76+
77+
public var mapImageViewRight: UIImageView = {
78+
let imageView = UIImageView()
79+
imageView.translatesAutoresizingMaskIntoConstraints = false
80+
imageView.contentMode = .scaleAspectFill
81+
imageView.clipsToBounds = true
82+
return imageView
83+
}()
84+
6785
let backgroundViewRight = UIView()
6886

87+
lazy var pointImageRight: UIImageView = {
88+
let image = UIImageView()
89+
image.translatesAutoresizingMaskIntoConstraints = false
90+
image.image = coreLoader.loadImage("location_point")
91+
return image
92+
}()
93+
94+
lazy var pointImageLeft: UIImageView = {
95+
let image = UIImageView()
96+
image.translatesAutoresizingMaskIntoConstraints = false
97+
image.image = coreLoader.loadImage("location_point")
98+
return image
99+
}()
100+
69101
override public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
70102
super.init(style: style, reuseIdentifier: reuseIdentifier)
71103
commonUI()
@@ -122,33 +154,26 @@ open class FunChatMessageLocationCell: FunChatMessageBaseCell {
122154
subTitleLabelLeft.topAnchor.constraint(equalTo: titleLabelLeft.bottomAnchor, constant: 4),
123155
])
124156

125-
if let map = NEChatKitClient.instance.delegate?.getCellMapView?() as? UIView {
126-
mapViewLeft = map
127-
backgroundViewLeft.addSubview(map)
128-
map.translatesAutoresizingMaskIntoConstraints = false
129-
NSLayoutConstraint.activate([
130-
map.leftAnchor.constraint(equalTo: backgroundViewLeft.leftAnchor),
131-
map.bottomAnchor.constraint(equalTo: backgroundViewLeft.bottomAnchor),
132-
map.rightAnchor.constraint(equalTo: backgroundViewLeft.rightAnchor),
133-
map.topAnchor.constraint(equalTo: subTitleLabelLeft.bottomAnchor, constant: 4),
134-
])
135-
136-
let pointImage = UIImageView()
137-
pointImage.translatesAutoresizingMaskIntoConstraints = false
138-
pointImage.image = coreLoader.loadImage("location_point")
139-
map.addSubview(pointImage)
140-
NSLayoutConstraint.activate([
141-
pointImage.centerXAnchor.constraint(equalTo: map.centerXAnchor),
142-
pointImage.bottomAnchor.constraint(equalTo: map.bottomAnchor, constant: -30),
143-
])
144-
} else {
145-
backgroundViewLeft.addSubview(emptyLabelLeft)
146-
NSLayoutConstraint.activate([
147-
emptyLabelLeft.leftAnchor.constraint(equalTo: backgroundViewLeft.leftAnchor),
148-
emptyLabelLeft.rightAnchor.constraint(equalTo: backgroundViewLeft.rightAnchor),
149-
emptyLabelLeft.bottomAnchor.constraint(equalTo: backgroundViewLeft.bottomAnchor, constant: -40),
150-
])
151-
}
157+
backgroundViewLeft.addSubview(mapImageViewLeft)
158+
NSLayoutConstraint.activate([
159+
mapImageViewLeft.leftAnchor.constraint(equalTo: backgroundViewLeft.leftAnchor),
160+
mapImageViewLeft.bottomAnchor.constraint(equalTo: backgroundViewLeft.bottomAnchor),
161+
mapImageViewLeft.rightAnchor.constraint(equalTo: backgroundViewLeft.rightAnchor),
162+
mapImageViewLeft.topAnchor.constraint(equalTo: subTitleLabelLeft.bottomAnchor, constant: 4),
163+
])
164+
165+
mapImageViewLeft.addSubview(pointImageLeft)
166+
NSLayoutConstraint.activate([
167+
pointImageLeft.centerXAnchor.constraint(equalTo: mapImageViewLeft.centerXAnchor),
168+
pointImageLeft.bottomAnchor.constraint(equalTo: mapImageViewLeft.bottomAnchor, constant: -30),
169+
])
170+
171+
backgroundViewLeft.addSubview(emptyLabelLeft)
172+
NSLayoutConstraint.activate([
173+
emptyLabelLeft.leftAnchor.constraint(equalTo: backgroundViewLeft.leftAnchor),
174+
emptyLabelLeft.rightAnchor.constraint(equalTo: backgroundViewLeft.rightAnchor),
175+
emptyLabelLeft.bottomAnchor.constraint(equalTo: backgroundViewLeft.bottomAnchor, constant: -40),
176+
])
152177
}
153178

154179
open func commonUIRight() {
@@ -192,33 +217,26 @@ open class FunChatMessageLocationCell: FunChatMessageBaseCell {
192217
subTitleLabelRight.topAnchor.constraint(equalTo: titleLabelRight.bottomAnchor, constant: 4),
193218
])
194219

195-
if let map = NEChatKitClient.instance.delegate?.getCellMapView?() as? UIView {
196-
mapViewRight = map
197-
backgroundViewRight.addSubview(map)
198-
map.translatesAutoresizingMaskIntoConstraints = false
199-
NSLayoutConstraint.activate([
200-
map.leftAnchor.constraint(equalTo: backgroundViewRight.leftAnchor),
201-
map.bottomAnchor.constraint(equalTo: backgroundViewRight.bottomAnchor),
202-
map.rightAnchor.constraint(equalTo: backgroundViewRight.rightAnchor),
203-
map.topAnchor.constraint(equalTo: subTitleLabelRight.bottomAnchor, constant: 4),
204-
])
205-
206-
let pointImage = UIImageView()
207-
pointImage.translatesAutoresizingMaskIntoConstraints = false
208-
pointImage.image = coreLoader.loadImage("location_point")
209-
map.addSubview(pointImage)
210-
NSLayoutConstraint.activate([
211-
pointImage.centerXAnchor.constraint(equalTo: map.centerXAnchor),
212-
pointImage.bottomAnchor.constraint(equalTo: map.bottomAnchor, constant: -30),
213-
])
214-
} else {
215-
backgroundViewRight.addSubview(emptyLabelRight)
216-
NSLayoutConstraint.activate([
217-
emptyLabelRight.leftAnchor.constraint(equalTo: backgroundViewRight.leftAnchor),
218-
emptyLabelRight.rightAnchor.constraint(equalTo: backgroundViewRight.rightAnchor),
219-
emptyLabelRight.bottomAnchor.constraint(equalTo: backgroundViewRight.bottomAnchor, constant: -40),
220-
])
221-
}
220+
backgroundViewRight.addSubview(mapImageViewRight)
221+
NSLayoutConstraint.activate([
222+
mapImageViewRight.leftAnchor.constraint(equalTo: backgroundViewRight.leftAnchor),
223+
mapImageViewRight.bottomAnchor.constraint(equalTo: backgroundViewRight.bottomAnchor),
224+
mapImageViewRight.rightAnchor.constraint(equalTo: backgroundViewRight.rightAnchor),
225+
mapImageViewRight.topAnchor.constraint(equalTo: subTitleLabelRight.bottomAnchor, constant: 4),
226+
])
227+
228+
mapImageViewRight.addSubview(pointImageRight)
229+
NSLayoutConstraint.activate([
230+
pointImageRight.centerXAnchor.constraint(equalTo: mapImageViewRight.centerXAnchor),
231+
pointImageRight.bottomAnchor.constraint(equalTo: mapImageViewRight.bottomAnchor, constant: -30),
232+
])
233+
234+
backgroundViewRight.addSubview(emptyLabelRight)
235+
NSLayoutConstraint.activate([
236+
emptyLabelRight.leftAnchor.constraint(equalTo: backgroundViewRight.leftAnchor),
237+
emptyLabelRight.rightAnchor.constraint(equalTo: backgroundViewRight.rightAnchor),
238+
emptyLabelRight.bottomAnchor.constraint(equalTo: backgroundViewRight.bottomAnchor, constant: -40),
239+
])
222240
}
223241

224242
override open func showLeftOrRight(showRight: Bool) {
@@ -233,14 +251,26 @@ open class FunChatMessageLocationCell: FunChatMessageBaseCell {
233251
let subTitleLabel = isSend ? subTitleLabelRight : subTitleLabelLeft
234252
let mapView = isSend ? mapViewRight : mapViewLeft
235253
let bubbleW = isSend ? bubbleWRight : bubbleWLeft
254+
let mapImageView = isSend ? mapImageViewRight : mapImageViewLeft
236255

237256
bubbleW?.constant = kScreenWidth <= 320 ? 222 : 242 // 适配小屏幕
238257

258+
let emptyLabel = isSend ? emptyLabelRight : emptyLabelLeft
259+
let pointImage = isSend ? pointImageRight : pointImageLeft
260+
239261
if let m = model as? MessageLocationModel {
240262
titleLabel.text = m.title
241263
subTitleLabel.text = m.subTitle
242-
if let lat = m.lat, let lng = m.lng, let map = mapView {
243-
NEChatKitClient.instance.delegate?.setMapviewLocation?(lat: lat, lng: lng, mapview: map)
264+
if let lat = m.lat, let lng = m.lng {
265+
if let url = NEChatKitClient.instance.delegate?.getMapImageUrl?(lat: lat, lng: lng) {
266+
NELog.infoLog(className(), desc: #function + "location image url = \(url)")
267+
mapImageView.sd_setImage(with: URL(string: url), placeholderImage: coreLoader.loadImage("chat_map_default"))
268+
emptyLabel.isHidden = true
269+
pointImage.isHidden = false
270+
} else {
271+
emptyLabel.isHidden = false
272+
pointImage.isHidden = true
273+
}
244274
}
245275
}
246276
}

0 commit comments

Comments
 (0)