Skip to content

Commit 4872910

Browse files
zsw666张诗文
andauthored
v10.4.0 (#406)
* add sample code * update Podfile * v10.4.0 --------- Co-authored-by: 张诗文 <zhangshiwen@corp.netease.com>
1 parent a3b9a07 commit 4872910

83 files changed

Lines changed: 740 additions & 729 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

NEChatUIKit/NEChatUIKit.podspec

Lines changed: 2 additions & 2 deletions
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 = '10.3.0'
19+
s.version = '10.4.0'
2020
s.summary = 'Chat Module of IM.'
2121

2222
# This description is used to generate tags and improve search results.
@@ -43,7 +43,7 @@ TODO: Add long description of the pod here.
4343

4444
s.resource = 'NEChatUIKit/Assets/**/*'
4545
s.dependency 'NEChatKit'
46-
s.dependency 'NECommonUIKit', '9.7.0'
46+
s.dependency 'NECommonUIKit', '9.7.3'
4747
s.dependency 'MJRefresh'
4848
s.dependency 'SDWebImageWebPCoder'
4949
s.dependency 'SDWebImageSVGKitPlugin'

NEChatUIKit/NEChatUIKit/Classes/Base/BaseViewController/NEChatBaseViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ open class NEChatBaseViewController: UIViewController, UIGestureRecognizerDelega
4444
super.viewWillAppear(animated)
4545

4646
// 配置项:会话界面是否展示标题栏
47-
if !NEKitChatConfig.shared.ui.messageProperties.showTitleBar {
47+
if !ChatUIConfig.shared.messageProperties.showTitleBar {
4848
navigationController?.isNavigationBarHidden = true
4949
navigationView.removeFromSuperview()
5050
return
@@ -61,7 +61,7 @@ open class NEChatBaseViewController: UIViewController, UIGestureRecognizerDelega
6161

6262
override open func viewDidLoad() {
6363
super.viewDidLoad()
64-
view.backgroundColor = NEKitChatConfig.shared.ui.messageProperties.chatViewBackground ?? .white
64+
view.backgroundColor = ChatUIConfig.shared.messageProperties.chatViewBackground ?? .white
6565

6666
if let useSystemNav = NEConfigManager.instance.getParameter(key: useSystemNav) as? Bool, useSystemNav {
6767
topConstant = NEConstant.navigationAndStatusHeight

NEChatUIKit/NEChatUIKit/Classes/Chat/Controller/ChatViewController.swift

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
304304
isCurrentPage = true
305305
markNeedReadMsg()
306306

307-
if NEKitChatConfig.shared.ui.messageProperties.showTitleBar {
307+
if ChatUIConfig.shared.messageProperties.showTitleBar {
308308
bodyTopViewTopConstant = topConstant
309309
}
310310

@@ -366,13 +366,14 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
366366
let param = ["sessionId": viewModel.conversationId]
367367
Router.shared.use("ClearAtMessageRemind", parameters: param, closure: nil)
368368

369+
NotificationCenter.default.removeObserver(self)
369370
NETeamUserManager.shared.removeAllTeamInfo()
370371
}
371372
}
372373

373374
open func setMoreButton() {
374-
if NEKitChatConfig.shared.ui.messageProperties.showTitleBarRightIcon {
375-
let image = NEKitChatConfig.shared.ui.messageProperties.titleBarRightRes ?? UIImage.ne_imageNamed(name: "three_point")
375+
if ChatUIConfig.shared.messageProperties.showTitleBarRightIcon {
376+
let image = ChatUIConfig.shared.messageProperties.titleBarRightRes ?? UIImage.ne_imageNamed(name: "three_point")
376377
addRightAction(image, #selector(toSetting), self)
377378
navigationView.setMoreButtonImage(image)
378379
} else {
@@ -460,7 +461,7 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
460461

461462
expandMoreAction()
462463

463-
if let customController = NEKitChatConfig.shared.ui.customController {
464+
if let customController = ChatUIConfig.shared.customController {
464465
customController(self)
465466
}
466467
}
@@ -609,8 +610,8 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
609610
}
610611

611612
// 配置项自定义 items
612-
if let chatPopMenu = NEKitChatConfig.shared.ui.chatPopMenu {
613-
chatPopMenu(&items, model)
613+
if let chatPopMenu = ChatUIConfig.shared.chatPopMenu {
614+
chatPopMenu(self, &items, model)
614615
}
615616

616617
// 供用户自定义 items
@@ -731,8 +732,8 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
731732
/// 设置按钮点击事件
732733
override open func toSetting() {
733734
// 自定义设置按钮点击事件
734-
if let block = NEKitChatConfig.shared.ui.messageProperties.titleBarRightClick {
735-
block()
735+
if let block = ChatUIConfig.shared.messageProperties.titleBarRightClick {
736+
block(self)
736737
return
737738
}
738739

@@ -1137,9 +1138,9 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
11371138
}
11381139

11391140
open func didSelectMoreCell(cell: NEInputMoreCell) {
1140-
if let delegate = cell.cellData?.customDelegate as? AnyObject, let action = cell.cellData?.action {
1141+
if let action = cell.cellData?.action {
11411142
// 用户自定义更多面板按钮
1142-
_ = delegate.perform(action)
1143+
action(self, cell.cellData)
11431144
return
11441145
}
11451146

@@ -1534,8 +1535,8 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
15341535
if isFile == true {
15351536
let imgSize_MB = Double(pngImage?.count ?? 0) / 1e6
15361537
NEALog.infoLog(ModuleName + " " + ChatViewController.className(), desc: #function + "imgSize_MB: \(imgSize_MB) MB")
1537-
if imgSize_MB > NEKitChatConfig.shared.ui.fileSizeLimit {
1538-
showToast(String(format: chatLocalizable("fileSize_over_limit"), "\(NEKitChatConfig.shared.ui.fileSizeLimit)"))
1538+
if imgSize_MB > ChatUIConfig.shared.fileSizeLimit {
1539+
showToast(String(format: chatLocalizable("fileSize_over_limit"), "\(ChatUIConfig.shared.fileSizeLimit)"))
15391540
} else {
15401541
viewModel.sendFileMessage(filePath: imageUrl.relativePath,
15411542
displayName: imageName) { [weak self] message, error, progress in
@@ -1640,8 +1641,8 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
16401641
let fileAttributes = try FileManager.default.attributesOfItem(atPath: desPath)
16411642
if let size_B = fileAttributes[FileAttributeKey.size] as? Double {
16421643
let size_MB = size_B / 1e6
1643-
if size_MB > NEKitChatConfig.shared.ui.fileSizeLimit {
1644-
showToast(String(format: chatLocalizable("fileSize_over_limit"), "\(NEKitChatConfig.shared.ui.fileSizeLimit)"))
1644+
if size_MB > ChatUIConfig.shared.fileSizeLimit {
1645+
showToast(String(format: chatLocalizable("fileSize_over_limit"), "\(ChatUIConfig.shared.fileSizeLimit)"))
16451646
try? FileManager.default.removeItem(atPath: desPath)
16461647
} else {
16471648
viewModel.sendFileMessage(filePath: desPath,
@@ -1692,17 +1693,30 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
16921693
controller.dismiss(animated: true)
16931694
}
16941695

1695-
// MARK: - ChatviewModelDelegate
1696+
// MARK: - ChatViewModelDelegate
16961697

16971698
/// 本端即将发送消息状态回调,此时消息还未发送,可对消息进行修改或者拦截发送
16981699
/// 来源: 发送消息, 插入消息
1699-
/// - Parameter message: 消息
1700-
/// - Parameter completion: 是否继续发送消息
1701-
public func readySendMessage(_ message: V2NIMMessage, _ completion: @escaping (Bool) -> Void) {
1702-
if let block = NEKitChatConfig.shared.ui.onSendMessage {
1703-
completion(block(message, self))
1700+
/// - Parameter param: 消息参数,包含消息和发送参数
1701+
/// - Returns: (修改后的)消息参数,若消息参数为 nil,则表示拦截该消息不发送
1702+
public func beforeSend(_ param: MessageSendParams) -> MessageSendParams? {
1703+
if let block = ChatKitClient.shared.beforeSend {
1704+
let p = block(self, param)
1705+
return p
1706+
} else {
1707+
return param
1708+
}
1709+
}
1710+
1711+
/// 本端即将发送消息状态回调,此时消息还未发送,可对消息进行修改或者拦截发送
1712+
/// 来源: 发送消息, 插入消息
1713+
/// - Parameter param: 消息参数,包含消息和发送参数
1714+
/// - Parameter completion: (修改后的)消息参数,若消息参数为 nil,则表示拦截该消息不发送
1715+
public func beforeSend(_ param: MessageSendParams, _ completion: @escaping (MessageSendParams?) -> Void) {
1716+
if let block = ChatKitClient.shared.beforeSendCompletion {
1717+
block(self, param, completion)
17041718
} else {
1705-
completion(true)
1719+
completion(param)
17061720
}
17071721
}
17081722

@@ -2152,8 +2166,8 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
21522166
removeOperationView()
21532167

21542168
// 配置项拦截
2155-
if let popMenuClick = NEKitChatConfig.shared.ui.popMenuClick {
2156-
popMenuClick(item)
2169+
if let popMenuClick = ChatUIConfig.shared.popMenuClick {
2170+
popMenuClick(self, item)
21572171
return
21582172
}
21592173

@@ -2299,6 +2313,15 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
22992313
}
23002314

23012315
if let message = weakSelf?.viewModel.operationModel?.message {
2316+
// 校验消息可撤回时间
2317+
let date = Date()
2318+
let currentTime = date.timeIntervalSince1970
2319+
let reTime = ChatUIConfig.shared.getReeditTimeGap()
2320+
if Int(currentTime - message.createTime) >= reTime * 60 {
2321+
weakSelf?.showToast(chatLocalizable("ravokable_time_expired"))
2322+
return
2323+
}
2324+
23022325
if weakSelf?.viewModel.operationModel?.type == .text {
23032326
weakSelf?.viewModel.operationModel?.isReedit = true
23042327
}
@@ -2816,7 +2839,7 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD
28162839
/// 输入框【更多】按钮点击事件,子类重写
28172840
@discardableResult
28182841
open func expandMoreAction() -> [NEMoreItemModel] {
2819-
var items = NEChatUIKitClient.instance.getMoreActionData(sessionType: V2NIMConversationIdUtil.conversationType(viewModel.conversationId))
2842+
var items = NEChatUIKitClient.instance.getMoreActionData(sessionType: V2NIMConversationIdUtil.conversationType(viewModel.conversationId), self)
28202843
if NEChatKitClient.instance.delegate == nil {
28212844
items = items.filter { item in
28222845
if item.type == .location {
@@ -3498,8 +3521,8 @@ extension ChatViewController: ChatBaseCellDelegate {
34983521
}
34993522

35003523
open func didTapMessageView(_ cell: UITableViewCell, _ model: MessageContentModel?, _ replyModel: MessageModel?) {
3501-
if let tapClick = NEKitChatConfig.shared.ui.messageItemClick {
3502-
tapClick(cell, model)
3524+
if let tapClick = ChatUIConfig.shared.messageItemClick {
3525+
tapClick(self, cell, model)
35033526
return
35043527
}
35053528

NEChatUIKit/NEChatUIKit/Classes/Chat/Controller/MultiForwardViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ open class MultiForwardViewController: NEChatBaseViewController, UINavigationCon
236236
// MARK: ChatBaseCellDelegate
237237

238238
open func didTapMessageView(_ cell: UITableViewCell, _ model: MessageContentModel?, _ replyModel: MessageModel?) {
239-
if let tapClick = NEKitChatConfig.shared.ui.messageItemClick {
240-
tapClick(cell, model)
239+
if let tapClick = ChatUIConfig.shared.messageItemClick {
240+
tapClick(self, cell, model)
241241
return
242242
}
243243

NEChatUIKit/NEChatUIKit/Classes/Chat/Emoji/NEEmotionTool.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ open class NEEmotionTool: NSObject {
3333
/// - offset: 偏移量
3434
/// - Returns: 替换表情后的富文本
3535
class func getAttWithStr(str: String, font: UIFont,
36-
_ offset: CGPoint = CGPoint(x: 0, y: -3)) -> NSMutableAttributedString {
36+
_ offset: CGPoint = CGPoint(x: 0, y: -4)) -> NSMutableAttributedString {
3737
let regularArr = getRegularArray(str: str)
3838
let emoticons = NIMInputEmoticonManager.shared
3939
.emoticonCatalog(catalogID: NIMKit_EmojiCatalog)?.emoticons
4040
let attStr = NSMutableAttributedString(string: str, attributes: [
4141
NSAttributedString.Key.font: font,
42-
.foregroundColor: NEKitChatConfig.shared.ui.messageProperties.messageTextColor,
42+
.foregroundColor: ChatUIConfig.shared.messageProperties.messageTextColor,
4343
])
4444

4545
if let regArr = regularArr, regArr.count > 0, let targetEmotions = emoticons {

NEChatUIKit/NEChatUIKit/Classes/Chat/Helper/ChatMessageHelper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ public class ChatMessageHelper: NSObject {
604604
}
605605

606606
let text = message?.text ?? ""
607-
let messageTextFont = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.messageTextSize)
607+
let messageTextFont = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.messageTextSize)
608608

609609
// 兼容老的表情消息,如果前面有表情而位置计算异常则回退回老的解析
610610
var notFound = false

NEChatUIKit/NEChatUIKit/Classes/Chat/Model/CollectionMessageModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ open class CollectionMessageModel: NSObject {
3939

4040
open func cellHeight(contenttMaxW: CGFloat) -> CGFloat {
4141
var height = chatmodel.contentSize.height
42-
let titleFont: UIFont = .systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.pinMessageTextSize, weight: .semibold)
43-
let bodyFont: UIFont = .systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.pinMessageTextSize)
42+
let titleFont: UIFont = .systemFont(ofSize: ChatUIConfig.shared.messageProperties.pinMessageTextSize, weight: .semibold)
43+
let bodyFont: UIFont = .systemFont(ofSize: ChatUIConfig.shared.messageProperties.pinMessageTextSize)
4444
let maxSize = CGSize(width: contenttMaxW, height: CGFloat.greatestFiniteMagnitude)
4545

4646
if let textModel = chatmodel as? MessageTextModel {

NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageCallRecordModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ open class MessageCallRecordModel: MessageContentModel {
6969

7070
attributeStr?.addAttribute(NSAttributedString.Key.font, value: messageTextFont, range: NSMakeRange(0, attributeStr?.length ?? 0))
7171

72-
attributeStr?.addAttribute(NSAttributedString.Key.foregroundColor, value: NEKitChatConfig.shared.ui.messageProperties.messageTextColor, range: NSMakeRange(0, attributeStr?.length ?? 0))
72+
attributeStr?.addAttribute(NSAttributedString.Key.foregroundColor, value: ChatUIConfig.shared.messageProperties.messageTextColor, range: NSMakeRange(0, attributeStr?.length ?? 0))
7373
}
7474

7575
let textSize = NSAttributedString.getRealSize(attributeStr, messageTextFont, messageMaxSize)

NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageContentModel.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,16 @@ open class MessageContentModel: NSObject, MessageModel {
7676
didSet {
7777
if isRevoked {
7878
type = .revoke
79+
80+
// 校验撤回消息可编辑时间
7981
if let time = message?.createTime {
8082
let date = Date()
8183
let currentTime = date.timeIntervalSince1970
82-
if currentTime - time > 60 * 2 {
84+
if Int(currentTime - time) > ChatUIConfig.shared.revokeEditTimeGap * 60 {
8385
timeOut = true
8486
}
8587
}
88+
8689
// 只有文本消息,才计算可编辑按钮的宽度
8790
if let isSend = message?.isSelf, isSend, message?.messageType == .MESSAGE_TYPE_TEXT, timeOut == false {
8891
contentSize = CGSize(width: 218, height: chat_min_h)
@@ -121,15 +124,15 @@ open class MessageContentModel: NSObject, MessageModel {
121124
}
122125
}
123126

124-
public let messageTextFont = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.messageTextSize)
127+
public let messageTextFont = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.messageTextSize)
125128
public let messageMaxSize = CGSize(width: chat_content_maxW, height: CGFloat.greatestFiniteMagnitude)
126129

127130
public required init(message: V2NIMMessage?) {
128131
self.message = message
129132
if message?.conversationType == .CONVERSATION_TYPE_TEAM,
130133
let senderId = ChatMessageHelper.getSenderId(message),
131134
!IMKitClient.instance.isMe(senderId) {
132-
fullNameHeight = NEKitChatConfig.shared.ui.messageProperties.showTeamMessageNick ? 20 : 0
135+
fullNameHeight = ChatUIConfig.shared.messageProperties.showTeamMessageNick ? 20 : 0
133136
}
134137
height = contentSize.height + chat_content_margin * 2 + fullNameHeight + chat_pin_height
135138
}

NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageRichTextModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ open class MessageRichTextModel: MessageTextModel {
2727
type = .custom
2828
customType = customRichTextType
2929

30-
let font = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.messageTextSize, weight: .semibold)
30+
let font = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.messageTextSize, weight: .semibold)
3131
titleAttributeStr = NEEmotionTool.getAttWithStr(
3232
str: title,
3333
font: font

0 commit comments

Comments
 (0)