Skip to content

Commit

Permalink
Merge pull request #383 from maghzchenyu/im_stable
Browse files Browse the repository at this point in the history
v8.9.0
  • Loading branch information
shine2008 committed Feb 21, 2024
2 parents a2dd6fa + c483b85 commit 39318d9
Show file tree
Hide file tree
Showing 24 changed files with 296 additions and 212 deletions.
2 changes: 1 addition & 1 deletion NEChatUIKit/NEChatUIKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = 'NEChatUIKit'
s.version = '9.7.0'
s.version = '8.9.0'
s.summary = 'Chat Module of IM.'

# This description is used to generate tags and improve search results.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "location_default 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "location_default.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ChatDeduplicationHelper: NSObject, NIMLoginManagerDelegate {
}

public func onLogin(_ step: NIMLoginStep) {
if step == .logout {
if step == .logining {
clearCache()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ open class NEBasePinMessageCell: UITableViewCell {
label.font = UIFont.systemFont(ofSize: 12.0)
label.textColor = .ne_greyText
label.translatesAutoresizingMaskIntoConstraints = false
label.accessibilityIdentifier = "id.time"
return label
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,18 @@ open class NEBasePinMessageLocationCell: NEBasePinMessageCell {
label.text = chatLocalizable("no_map_plugin")
label.textAlignment = .center
label.textColor = UIColor.ne_greyText
label.isHidden = true
return label
}()

let pointImage = UIImageView()

public lazy var mapImageView: UIImageView = {
let image = UIImageView()
image.translatesAutoresizingMaskIntoConstraints = false
return image
}()

var mapView: UIView?

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

if let map = NEChatKitClient.instance.delegate?.getCellMapView?() as? UIView {
mapView = map
back.addSubview(map)
map.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
map.leftAnchor.constraint(equalTo: back.leftAnchor),
map.bottomAnchor.constraint(equalTo: back.bottomAnchor),
map.rightAnchor.constraint(equalTo: back.rightAnchor),
map.topAnchor.constraint(equalTo: subTitleLabel.bottomAnchor, constant: 4),
])

let pointImage = UIImageView()
pointImage.translatesAutoresizingMaskIntoConstraints = false
pointImage.image = coreLoader.loadImage("location_point")
map.addSubview(pointImage)
NSLayoutConstraint.activate([
pointImage.centerXAnchor.constraint(equalTo: map.centerXAnchor),
pointImage.bottomAnchor.constraint(equalTo: map.bottomAnchor, constant: -30),
])
} else {
back.addSubview(emptyLabel)
NSLayoutConstraint.activate([
emptyLabel.leftAnchor.constraint(equalTo: back.leftAnchor),
emptyLabel.rightAnchor.constraint(equalTo: back.rightAnchor),
emptyLabel.bottomAnchor.constraint(equalTo: back.bottomAnchor, constant: -40),
])
}
mapView?.isUserInteractionEnabled = false
back.addSubview(mapImageView)
NSLayoutConstraint.activate([
mapImageView.leftAnchor.constraint(equalTo: back.leftAnchor),
mapImageView.bottomAnchor.constraint(equalTo: back.bottomAnchor),
mapImageView.rightAnchor.constraint(equalTo: back.rightAnchor),
mapImageView.topAnchor.constraint(equalTo: subTitleLabel.bottomAnchor, constant: 4),
])

pointImage.translatesAutoresizingMaskIntoConstraints = false
pointImage.image = coreLoader.loadImage("location_point")
mapImageView.addSubview(pointImage)
NSLayoutConstraint.activate([
pointImage.centerXAnchor.constraint(equalTo: mapImageView.centerXAnchor),
pointImage.bottomAnchor.constraint(equalTo: mapImageView.bottomAnchor, constant: -30),
])

back.addSubview(emptyLabel)
NSLayoutConstraint.activate([
emptyLabel.leftAnchor.constraint(equalTo: back.leftAnchor),
emptyLabel.rightAnchor.constraint(equalTo: back.rightAnchor),
emptyLabel.bottomAnchor.constraint(equalTo: back.bottomAnchor, constant: -40),
])

if let gesture = contentGesture {
back.addGestureRecognizer(gesture)
}
Expand All @@ -129,8 +133,16 @@ open class NEBasePinMessageLocationCell: NEBasePinMessageCell {
if let m = item.chatmodel as? MessageLocationModel {
locationTitleLabel.text = m.title
subTitleLabel.text = m.subTitle
if let lat = m.lat, let lng = m.lng, let map = mapView {
NEChatKitClient.instance.delegate?.setMapviewLocation?(lat: lat, lng: lng, mapview: map)
if let lat = m.lat, let lng = m.lng {
if let url = NEChatKitClient.instance.delegate?.getMapImageUrl?(lat: lat, lng: lng) {
NELog.infoLog(className(), desc: #function + "location image url = \(url)")
mapImageView.sd_setImage(with: URL(string: url))
emptyLabel.isHidden = true
pointImage.isHidden = false
} else {
emptyLabel.isHidden = false
pointImage.isHidden = true
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ open class NEBasePinMessageTextCell: NEBasePinMessageCell {
label.translatesAutoresizingMaskIntoConstraints = false
label.isUserInteractionEnabled = true
label.numberOfLines = 3
label.accessibilityIdentifier = "id.message"
return label
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ open class NEBaseChatInputView: UIView, ChatRecordViewDelegate,
let addString = NEEmotionTool.getAttWithStr(str: text, font: .systemFont(ofSize: 16))
mutaString.replaceCharacters(in: range, with: addString)
textView.attributedText = mutaString
textView.accessibilityValue = text
DispatchQueue.main.async {
textView.selectedRange = NSMakeRange(range.location + addString.length, 0)
}
Expand Down Expand Up @@ -305,6 +306,9 @@ open class NEBaseChatInputView: UIView, ChatRecordViewDelegate,
if let findRange = findShowPosition(range: range, attribute: textView.attributedText) {
textView.selectedRange = NSMakeRange(findRange.location + findRange.length, 0)
}

textView.scrollRangeToVisible(NSMakeRange(textView.selectedRange.location, 1))
textView.accessibilityValue = getRealSendText(textView.attributedText)
}

@available(iOS 10.0, *)
Expand Down Expand Up @@ -349,34 +353,12 @@ open class NEBaseChatInputView: UIView, ChatRecordViewDelegate,
textView.deleteBackward()
print("delete ward")
} else {
if let font = textView.font {
let attribute = NEEmotionTool.getAttWithStr(
str: description,
font: font,
CGPoint(x: 0, y: -4)
)
print("attribute : ", attribute)
let mutaAttribute = NSMutableAttributedString()
if let origin = textView.attributedText {
mutaAttribute.append(origin)
}
attribute.enumerateAttribute(
NSAttributedString.Key.attachment,
in: NSMakeRange(0, attribute.length)
) { value, range, stop in
if let neAttachment = value as? NEEmotionAttachment {
print("ne attachment bounds ", neAttachment.bounds)
}
}
mutaAttribute.append(attribute)
mutaAttribute.addAttribute(
NSAttributedString.Key.font,
value: font,
range: NSMakeRange(0, mutaAttribute.length)
)
textView.attributedText = mutaAttribute
textView.scrollRangeToVisible(NSMakeRange(textView.attributedText.length, 1))
}
let range = textView.selectedRange
let attribute = NEEmotionTool.getAttWithStr(str: description, font: .systemFont(ofSize: 16))
let mutaAttribute = NSMutableAttributedString(attributedString: textView.attributedText)
mutaAttribute.insert(attribute, at: range.location)
textView.attributedText = mutaAttribute
textView.selectedRange = NSMakeRange(range.location + attribute.length, 0)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ open class FunChatMessageLocationCell: FunChatMessageBaseCell {
}()

public var mapViewLeft: UIView?

public var mapImageViewLeft: UIImageView = {
let imageView = UIImageView()
imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
return imageView
}()

let backgroundViewLeft = UIView()

// Right
Expand Down Expand Up @@ -64,8 +73,31 @@ open class FunChatMessageLocationCell: FunChatMessageBaseCell {
}()

public var mapViewRight: UIView?

public var mapImageViewRight: UIImageView = {
let imageView = UIImageView()
imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
return imageView
}()

let backgroundViewRight = UIView()

lazy var pointImageRight: UIImageView = {
let image = UIImageView()
image.translatesAutoresizingMaskIntoConstraints = false
image.image = coreLoader.loadImage("location_point")
return image
}()

lazy var pointImageLeft: UIImageView = {
let image = UIImageView()
image.translatesAutoresizingMaskIntoConstraints = false
image.image = coreLoader.loadImage("location_point")
return image
}()

override public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
commonUI()
Expand Down Expand Up @@ -122,33 +154,26 @@ open class FunChatMessageLocationCell: FunChatMessageBaseCell {
subTitleLabelLeft.topAnchor.constraint(equalTo: titleLabelLeft.bottomAnchor, constant: 4),
])

if let map = NEChatKitClient.instance.delegate?.getCellMapView?() as? UIView {
mapViewLeft = map
backgroundViewLeft.addSubview(map)
map.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
map.leftAnchor.constraint(equalTo: backgroundViewLeft.leftAnchor),
map.bottomAnchor.constraint(equalTo: backgroundViewLeft.bottomAnchor),
map.rightAnchor.constraint(equalTo: backgroundViewLeft.rightAnchor),
map.topAnchor.constraint(equalTo: subTitleLabelLeft.bottomAnchor, constant: 4),
])

let pointImage = UIImageView()
pointImage.translatesAutoresizingMaskIntoConstraints = false
pointImage.image = coreLoader.loadImage("location_point")
map.addSubview(pointImage)
NSLayoutConstraint.activate([
pointImage.centerXAnchor.constraint(equalTo: map.centerXAnchor),
pointImage.bottomAnchor.constraint(equalTo: map.bottomAnchor, constant: -30),
])
} else {
backgroundViewLeft.addSubview(emptyLabelLeft)
NSLayoutConstraint.activate([
emptyLabelLeft.leftAnchor.constraint(equalTo: backgroundViewLeft.leftAnchor),
emptyLabelLeft.rightAnchor.constraint(equalTo: backgroundViewLeft.rightAnchor),
emptyLabelLeft.bottomAnchor.constraint(equalTo: backgroundViewLeft.bottomAnchor, constant: -40),
])
}
backgroundViewLeft.addSubview(mapImageViewLeft)
NSLayoutConstraint.activate([
mapImageViewLeft.leftAnchor.constraint(equalTo: backgroundViewLeft.leftAnchor),
mapImageViewLeft.bottomAnchor.constraint(equalTo: backgroundViewLeft.bottomAnchor),
mapImageViewLeft.rightAnchor.constraint(equalTo: backgroundViewLeft.rightAnchor),
mapImageViewLeft.topAnchor.constraint(equalTo: subTitleLabelLeft.bottomAnchor, constant: 4),
])

mapImageViewLeft.addSubview(pointImageLeft)
NSLayoutConstraint.activate([
pointImageLeft.centerXAnchor.constraint(equalTo: mapImageViewLeft.centerXAnchor),
pointImageLeft.bottomAnchor.constraint(equalTo: mapImageViewLeft.bottomAnchor, constant: -30),
])

backgroundViewLeft.addSubview(emptyLabelLeft)
NSLayoutConstraint.activate([
emptyLabelLeft.leftAnchor.constraint(equalTo: backgroundViewLeft.leftAnchor),
emptyLabelLeft.rightAnchor.constraint(equalTo: backgroundViewLeft.rightAnchor),
emptyLabelLeft.bottomAnchor.constraint(equalTo: backgroundViewLeft.bottomAnchor, constant: -40),
])
}

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

if let map = NEChatKitClient.instance.delegate?.getCellMapView?() as? UIView {
mapViewRight = map
backgroundViewRight.addSubview(map)
map.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
map.leftAnchor.constraint(equalTo: backgroundViewRight.leftAnchor),
map.bottomAnchor.constraint(equalTo: backgroundViewRight.bottomAnchor),
map.rightAnchor.constraint(equalTo: backgroundViewRight.rightAnchor),
map.topAnchor.constraint(equalTo: subTitleLabelRight.bottomAnchor, constant: 4),
])

let pointImage = UIImageView()
pointImage.translatesAutoresizingMaskIntoConstraints = false
pointImage.image = coreLoader.loadImage("location_point")
map.addSubview(pointImage)
NSLayoutConstraint.activate([
pointImage.centerXAnchor.constraint(equalTo: map.centerXAnchor),
pointImage.bottomAnchor.constraint(equalTo: map.bottomAnchor, constant: -30),
])
} else {
backgroundViewRight.addSubview(emptyLabelRight)
NSLayoutConstraint.activate([
emptyLabelRight.leftAnchor.constraint(equalTo: backgroundViewRight.leftAnchor),
emptyLabelRight.rightAnchor.constraint(equalTo: backgroundViewRight.rightAnchor),
emptyLabelRight.bottomAnchor.constraint(equalTo: backgroundViewRight.bottomAnchor, constant: -40),
])
}
backgroundViewRight.addSubview(mapImageViewRight)
NSLayoutConstraint.activate([
mapImageViewRight.leftAnchor.constraint(equalTo: backgroundViewRight.leftAnchor),
mapImageViewRight.bottomAnchor.constraint(equalTo: backgroundViewRight.bottomAnchor),
mapImageViewRight.rightAnchor.constraint(equalTo: backgroundViewRight.rightAnchor),
mapImageViewRight.topAnchor.constraint(equalTo: subTitleLabelRight.bottomAnchor, constant: 4),
])

mapImageViewRight.addSubview(pointImageRight)
NSLayoutConstraint.activate([
pointImageRight.centerXAnchor.constraint(equalTo: mapImageViewRight.centerXAnchor),
pointImageRight.bottomAnchor.constraint(equalTo: mapImageViewRight.bottomAnchor, constant: -30),
])

backgroundViewRight.addSubview(emptyLabelRight)
NSLayoutConstraint.activate([
emptyLabelRight.leftAnchor.constraint(equalTo: backgroundViewRight.leftAnchor),
emptyLabelRight.rightAnchor.constraint(equalTo: backgroundViewRight.rightAnchor),
emptyLabelRight.bottomAnchor.constraint(equalTo: backgroundViewRight.bottomAnchor, constant: -40),
])
}

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

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

let emptyLabel = isSend ? emptyLabelRight : emptyLabelLeft
let pointImage = isSend ? pointImageRight : pointImageLeft

if let m = model as? MessageLocationModel {
titleLabel.text = m.title
subTitleLabel.text = m.subTitle
if let lat = m.lat, let lng = m.lng, let map = mapView {
NEChatKitClient.instance.delegate?.setMapviewLocation?(lat: lat, lng: lng, mapview: map)
if let lat = m.lat, let lng = m.lng {
if let url = NEChatKitClient.instance.delegate?.getMapImageUrl?(lat: lat, lng: lng) {
NELog.infoLog(className(), desc: #function + "location image url = \(url)")
mapImageView.sd_setImage(with: URL(string: url), placeholderImage: coreLoader.loadImage("chat_map_default"))
emptyLabel.isHidden = true
pointImage.isHidden = false
} else {
emptyLabel.isHidden = false
pointImage.isHidden = true
}
}
}
}
Expand Down
Loading

0 comments on commit 39318d9

Please sign in to comment.