diff --git a/NEChatUIKit/NEChatUIKit.podspec b/NEChatUIKit/NEChatUIKit.podspec index 46d7d6d5..5e7ea6d8 100644 --- a/NEChatUIKit/NEChatUIKit.podspec +++ b/NEChatUIKit/NEChatUIKit.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |s| # s.name = 'NEChatUIKit' - s.version = '10.3.0' + s.version = '10.4.0' s.summary = 'Chat Module of IM.' # This description is used to generate tags and improve search results. @@ -43,7 +43,7 @@ TODO: Add long description of the pod here. s.resource = 'NEChatUIKit/Assets/**/*' s.dependency 'NEChatKit' - s.dependency 'NECommonUIKit', '9.7.0' + s.dependency 'NECommonUIKit', '9.7.3' s.dependency 'MJRefresh' s.dependency 'SDWebImageWebPCoder' s.dependency 'SDWebImageSVGKitPlugin' diff --git a/NEChatUIKit/NEChatUIKit/Classes/Base/BaseViewController/NEChatBaseViewController.swift b/NEChatUIKit/NEChatUIKit/Classes/Base/BaseViewController/NEChatBaseViewController.swift index 1f8e019f..432343c3 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Base/BaseViewController/NEChatBaseViewController.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Base/BaseViewController/NEChatBaseViewController.swift @@ -44,7 +44,7 @@ open class NEChatBaseViewController: UIViewController, UIGestureRecognizerDelega super.viewWillAppear(animated) // 配置项:会话界面是否展示标题栏 - if !NEKitChatConfig.shared.ui.messageProperties.showTitleBar { + if !ChatUIConfig.shared.messageProperties.showTitleBar { navigationController?.isNavigationBarHidden = true navigationView.removeFromSuperview() return @@ -61,7 +61,7 @@ open class NEChatBaseViewController: UIViewController, UIGestureRecognizerDelega override open func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = NEKitChatConfig.shared.ui.messageProperties.chatViewBackground ?? .white + view.backgroundColor = ChatUIConfig.shared.messageProperties.chatViewBackground ?? .white if let useSystemNav = NEConfigManager.instance.getParameter(key: useSystemNav) as? Bool, useSystemNav { topConstant = NEConstant.navigationAndStatusHeight diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/Controller/ChatViewController.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/Controller/ChatViewController.swift index aaa907ca..587ee22b 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/Controller/ChatViewController.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/Controller/ChatViewController.swift @@ -304,7 +304,7 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD isCurrentPage = true markNeedReadMsg() - if NEKitChatConfig.shared.ui.messageProperties.showTitleBar { + if ChatUIConfig.shared.messageProperties.showTitleBar { bodyTopViewTopConstant = topConstant } @@ -366,13 +366,14 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD let param = ["sessionId": viewModel.conversationId] Router.shared.use("ClearAtMessageRemind", parameters: param, closure: nil) + NotificationCenter.default.removeObserver(self) NETeamUserManager.shared.removeAllTeamInfo() } } open func setMoreButton() { - if NEKitChatConfig.shared.ui.messageProperties.showTitleBarRightIcon { - let image = NEKitChatConfig.shared.ui.messageProperties.titleBarRightRes ?? UIImage.ne_imageNamed(name: "three_point") + if ChatUIConfig.shared.messageProperties.showTitleBarRightIcon { + let image = ChatUIConfig.shared.messageProperties.titleBarRightRes ?? UIImage.ne_imageNamed(name: "three_point") addRightAction(image, #selector(toSetting), self) navigationView.setMoreButtonImage(image) } else { @@ -460,7 +461,7 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD expandMoreAction() - if let customController = NEKitChatConfig.shared.ui.customController { + if let customController = ChatUIConfig.shared.customController { customController(self) } } @@ -609,8 +610,8 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD } // 配置项自定义 items - if let chatPopMenu = NEKitChatConfig.shared.ui.chatPopMenu { - chatPopMenu(&items, model) + if let chatPopMenu = ChatUIConfig.shared.chatPopMenu { + chatPopMenu(self, &items, model) } // 供用户自定义 items @@ -731,8 +732,8 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD /// 设置按钮点击事件 override open func toSetting() { // 自定义设置按钮点击事件 - if let block = NEKitChatConfig.shared.ui.messageProperties.titleBarRightClick { - block() + if let block = ChatUIConfig.shared.messageProperties.titleBarRightClick { + block(self) return } @@ -1137,9 +1138,9 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD } open func didSelectMoreCell(cell: NEInputMoreCell) { - if let delegate = cell.cellData?.customDelegate as? AnyObject, let action = cell.cellData?.action { + if let action = cell.cellData?.action { // 用户自定义更多面板按钮 - _ = delegate.perform(action) + action(self, cell.cellData) return } @@ -1534,8 +1535,8 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD if isFile == true { let imgSize_MB = Double(pngImage?.count ?? 0) / 1e6 NEALog.infoLog(ModuleName + " " + ChatViewController.className(), desc: #function + "imgSize_MB: \(imgSize_MB) MB") - if imgSize_MB > NEKitChatConfig.shared.ui.fileSizeLimit { - showToast(String(format: chatLocalizable("fileSize_over_limit"), "\(NEKitChatConfig.shared.ui.fileSizeLimit)")) + if imgSize_MB > ChatUIConfig.shared.fileSizeLimit { + showToast(String(format: chatLocalizable("fileSize_over_limit"), "\(ChatUIConfig.shared.fileSizeLimit)")) } else { viewModel.sendFileMessage(filePath: imageUrl.relativePath, displayName: imageName) { [weak self] message, error, progress in @@ -1640,8 +1641,8 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD let fileAttributes = try FileManager.default.attributesOfItem(atPath: desPath) if let size_B = fileAttributes[FileAttributeKey.size] as? Double { let size_MB = size_B / 1e6 - if size_MB > NEKitChatConfig.shared.ui.fileSizeLimit { - showToast(String(format: chatLocalizable("fileSize_over_limit"), "\(NEKitChatConfig.shared.ui.fileSizeLimit)")) + if size_MB > ChatUIConfig.shared.fileSizeLimit { + showToast(String(format: chatLocalizable("fileSize_over_limit"), "\(ChatUIConfig.shared.fileSizeLimit)")) try? FileManager.default.removeItem(atPath: desPath) } else { viewModel.sendFileMessage(filePath: desPath, @@ -1692,17 +1693,30 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD controller.dismiss(animated: true) } - // MARK: - ChatviewModelDelegate + // MARK: - ChatViewModelDelegate /// 本端即将发送消息状态回调,此时消息还未发送,可对消息进行修改或者拦截发送 /// 来源: 发送消息, 插入消息 - /// - Parameter message: 消息 - /// - Parameter completion: 是否继续发送消息 - public func readySendMessage(_ message: V2NIMMessage, _ completion: @escaping (Bool) -> Void) { - if let block = NEKitChatConfig.shared.ui.onSendMessage { - completion(block(message, self)) + /// - Parameter param: 消息参数,包含消息和发送参数 + /// - Returns: (修改后的)消息参数,若消息参数为 nil,则表示拦截该消息不发送 + public func beforeSend(_ param: MessageSendParams) -> MessageSendParams? { + if let block = ChatKitClient.shared.beforeSend { + let p = block(self, param) + return p + } else { + return param + } + } + + /// 本端即将发送消息状态回调,此时消息还未发送,可对消息进行修改或者拦截发送 + /// 来源: 发送消息, 插入消息 + /// - Parameter param: 消息参数,包含消息和发送参数 + /// - Parameter completion: (修改后的)消息参数,若消息参数为 nil,则表示拦截该消息不发送 + public func beforeSend(_ param: MessageSendParams, _ completion: @escaping (MessageSendParams?) -> Void) { + if let block = ChatKitClient.shared.beforeSendCompletion { + block(self, param, completion) } else { - completion(true) + completion(param) } } @@ -2152,8 +2166,8 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD removeOperationView() // 配置项拦截 - if let popMenuClick = NEKitChatConfig.shared.ui.popMenuClick { - popMenuClick(item) + if let popMenuClick = ChatUIConfig.shared.popMenuClick { + popMenuClick(self, item) return } @@ -2299,6 +2313,15 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD } if let message = weakSelf?.viewModel.operationModel?.message { + // 校验消息可撤回时间 + let date = Date() + let currentTime = date.timeIntervalSince1970 + let reTime = ChatUIConfig.shared.getReeditTimeGap() + if Int(currentTime - message.createTime) >= reTime * 60 { + weakSelf?.showToast(chatLocalizable("ravokable_time_expired")) + return + } + if weakSelf?.viewModel.operationModel?.type == .text { weakSelf?.viewModel.operationModel?.isReedit = true } @@ -2816,7 +2839,7 @@ open class ChatViewController: NEChatBaseViewController, UINavigationControllerD /// 输入框【更多】按钮点击事件,子类重写 @discardableResult open func expandMoreAction() -> [NEMoreItemModel] { - var items = NEChatUIKitClient.instance.getMoreActionData(sessionType: V2NIMConversationIdUtil.conversationType(viewModel.conversationId)) + var items = NEChatUIKitClient.instance.getMoreActionData(sessionType: V2NIMConversationIdUtil.conversationType(viewModel.conversationId), self) if NEChatKitClient.instance.delegate == nil { items = items.filter { item in if item.type == .location { @@ -3498,8 +3521,8 @@ extension ChatViewController: ChatBaseCellDelegate { } open func didTapMessageView(_ cell: UITableViewCell, _ model: MessageContentModel?, _ replyModel: MessageModel?) { - if let tapClick = NEKitChatConfig.shared.ui.messageItemClick { - tapClick(cell, model) + if let tapClick = ChatUIConfig.shared.messageItemClick { + tapClick(self, cell, model) return } diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/Controller/MultiForwardViewController.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/Controller/MultiForwardViewController.swift index a8bd6a86..4a08ae88 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/Controller/MultiForwardViewController.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/Controller/MultiForwardViewController.swift @@ -236,8 +236,8 @@ open class MultiForwardViewController: NEChatBaseViewController, UINavigationCon // MARK: ChatBaseCellDelegate open func didTapMessageView(_ cell: UITableViewCell, _ model: MessageContentModel?, _ replyModel: MessageModel?) { - if let tapClick = NEKitChatConfig.shared.ui.messageItemClick { - tapClick(cell, model) + if let tapClick = ChatUIConfig.shared.messageItemClick { + tapClick(self, cell, model) return } diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/Emoji/NEEmotionTool.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/Emoji/NEEmotionTool.swift index 72d49860..3171d71a 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/Emoji/NEEmotionTool.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/Emoji/NEEmotionTool.swift @@ -33,13 +33,13 @@ open class NEEmotionTool: NSObject { /// - offset: 偏移量 /// - Returns: 替换表情后的富文本 class func getAttWithStr(str: String, font: UIFont, - _ offset: CGPoint = CGPoint(x: 0, y: -3)) -> NSMutableAttributedString { + _ offset: CGPoint = CGPoint(x: 0, y: -4)) -> NSMutableAttributedString { let regularArr = getRegularArray(str: str) let emoticons = NIMInputEmoticonManager.shared .emoticonCatalog(catalogID: NIMKit_EmojiCatalog)?.emoticons let attStr = NSMutableAttributedString(string: str, attributes: [ NSAttributedString.Key.font: font, - .foregroundColor: NEKitChatConfig.shared.ui.messageProperties.messageTextColor, + .foregroundColor: ChatUIConfig.shared.messageProperties.messageTextColor, ]) if let regArr = regularArr, regArr.count > 0, let targetEmotions = emoticons { diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/Helper/ChatMessageHelper.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/Helper/ChatMessageHelper.swift index 8c70f13b..24087010 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/Helper/ChatMessageHelper.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/Helper/ChatMessageHelper.swift @@ -604,7 +604,7 @@ public class ChatMessageHelper: NSObject { } let text = message?.text ?? "" - let messageTextFont = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.messageTextSize) + let messageTextFont = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.messageTextSize) // 兼容老的表情消息,如果前面有表情而位置计算异常则回退回老的解析 var notFound = false diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/CollectionMessageModel.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/CollectionMessageModel.swift index a54f342b..9aa9ec92 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/CollectionMessageModel.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/CollectionMessageModel.swift @@ -39,8 +39,8 @@ open class CollectionMessageModel: NSObject { open func cellHeight(contenttMaxW: CGFloat) -> CGFloat { var height = chatmodel.contentSize.height - let titleFont: UIFont = .systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.pinMessageTextSize, weight: .semibold) - let bodyFont: UIFont = .systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.pinMessageTextSize) + let titleFont: UIFont = .systemFont(ofSize: ChatUIConfig.shared.messageProperties.pinMessageTextSize, weight: .semibold) + let bodyFont: UIFont = .systemFont(ofSize: ChatUIConfig.shared.messageProperties.pinMessageTextSize) let maxSize = CGSize(width: contenttMaxW, height: CGFloat.greatestFiniteMagnitude) if let textModel = chatmodel as? MessageTextModel { diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageCallRecordModel.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageCallRecordModel.swift index f4c4a91a..7cba39e5 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageCallRecordModel.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageCallRecordModel.swift @@ -69,7 +69,7 @@ open class MessageCallRecordModel: MessageContentModel { attributeStr?.addAttribute(NSAttributedString.Key.font, value: messageTextFont, range: NSMakeRange(0, attributeStr?.length ?? 0)) - attributeStr?.addAttribute(NSAttributedString.Key.foregroundColor, value: NEKitChatConfig.shared.ui.messageProperties.messageTextColor, range: NSMakeRange(0, attributeStr?.length ?? 0)) + attributeStr?.addAttribute(NSAttributedString.Key.foregroundColor, value: ChatUIConfig.shared.messageProperties.messageTextColor, range: NSMakeRange(0, attributeStr?.length ?? 0)) } let textSize = NSAttributedString.getRealSize(attributeStr, messageTextFont, messageMaxSize) diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageContentModel.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageContentModel.swift index 9fd3c011..b449393a 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageContentModel.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageContentModel.swift @@ -76,13 +76,16 @@ open class MessageContentModel: NSObject, MessageModel { didSet { if isRevoked { type = .revoke + + // 校验撤回消息可编辑时间 if let time = message?.createTime { let date = Date() let currentTime = date.timeIntervalSince1970 - if currentTime - time > 60 * 2 { + if Int(currentTime - time) > ChatUIConfig.shared.revokeEditTimeGap * 60 { timeOut = true } } + // 只有文本消息,才计算可编辑按钮的宽度 if let isSend = message?.isSelf, isSend, message?.messageType == .MESSAGE_TYPE_TEXT, timeOut == false { contentSize = CGSize(width: 218, height: chat_min_h) @@ -121,7 +124,7 @@ open class MessageContentModel: NSObject, MessageModel { } } - public let messageTextFont = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.messageTextSize) + public let messageTextFont = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.messageTextSize) public let messageMaxSize = CGSize(width: chat_content_maxW, height: CGFloat.greatestFiniteMagnitude) public required init(message: V2NIMMessage?) { @@ -129,7 +132,7 @@ open class MessageContentModel: NSObject, MessageModel { if message?.conversationType == .CONVERSATION_TYPE_TEAM, let senderId = ChatMessageHelper.getSenderId(message), !IMKitClient.instance.isMe(senderId) { - fullNameHeight = NEKitChatConfig.shared.ui.messageProperties.showTeamMessageNick ? 20 : 0 + fullNameHeight = ChatUIConfig.shared.messageProperties.showTeamMessageNick ? 20 : 0 } height = contentSize.height + chat_content_margin * 2 + fullNameHeight + chat_pin_height } diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageRichTextModel.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageRichTextModel.swift index e5dc8115..79a411b1 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageRichTextModel.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageRichTextModel.swift @@ -27,7 +27,7 @@ open class MessageRichTextModel: MessageTextModel { type = .custom customType = customRichTextType - let font = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.messageTextSize, weight: .semibold) + let font = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.messageTextSize, weight: .semibold) titleAttributeStr = NEEmotionTool.getAttWithStr( str: title, font: font diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageTipsModel.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageTipsModel.swift index d10a3457..401fe82f 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageTipsModel.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/MessageTipsModel.swift @@ -23,9 +23,9 @@ open class MessageTipsModel: MessageContentModel { } } - var font: UIFont = .systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.timeTextSize) + var font: UIFont = .systemFont(ofSize: ChatUIConfig.shared.messageProperties.timeTextSize) if ChatMessageHelper.isAISender(message) { - font = .systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.messageTextSize) + font = .systemFont(ofSize: ChatUIConfig.shared.messageProperties.messageTextSize) } let textSize = String.getRealSize(text, font, messageMaxSize) diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/NEMoreItemModel.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/NEMoreItemModel.swift index 02b1c45e..aeaa74e0 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/NEMoreItemModel.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/NEMoreItemModel.swift @@ -30,11 +30,8 @@ open class NEMoreItemModel: NSObject { // 对应的单元类型 public var type: NEMoreActionType? - // 代理类 - public weak var customDelegate: AnyObject? - // 动态事件 - public var action: Selector? + public var action: ((ChatViewController, NEMoreItemModel?) -> Void)? // 自定义图标 public var customImage: UIImage? diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/NEPinMessageModel.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/NEPinMessageModel.swift index 1c58064f..64695d68 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/NEPinMessageModel.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/Model/NEPinMessageModel.swift @@ -41,8 +41,8 @@ open class NEPinMessageModel: NSObject { open func cellHeight(pinContentMaxW: CGFloat) -> CGFloat { var height = chatmodel.contentSize.height - let titleFont: UIFont = .systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.pinMessageTextSize, weight: .semibold) - let bodyFont: UIFont = .systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.pinMessageTextSize) + let titleFont: UIFont = .systemFont(ofSize: ChatUIConfig.shared.messageProperties.pinMessageTextSize, weight: .semibold) + let bodyFont: UIFont = .systemFont(ofSize: ChatUIConfig.shared.messageProperties.pinMessageTextSize) let maxSize = CGSize(width: pinContentMaxW, height: CGFloat.greatestFiniteMagnitude) if let textModel = chatmodel as? MessageTextModel { diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/CollectionCell/NEBaseCollectionMessageAudioCell.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/CollectionCell/NEBaseCollectionMessageAudioCell.swift index 940feb3a..40a3e3f0 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/CollectionCell/NEBaseCollectionMessageAudioCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/CollectionCell/NEBaseCollectionMessageAudioCell.swift @@ -37,9 +37,9 @@ class NEBaseCollectionMessageAudioCell: NEBaseCollectionMessageCell { override open func setupCommonUI() { super.setupCommonUI() - let receiveImage = NEKitChatConfig.shared.ui.messageProperties.leftBubbleBg ?? UIImage.ne_imageNamed(name: "chat_message_receive") + let receiveImage = ChatUIConfig.shared.messageProperties.leftBubbleBg ?? UIImage.ne_imageNamed(name: "chat_message_receive") bubbleImage.image = receiveImage? - .resizableImage(withCapInsets: NEKitChatConfig.shared.ui.messageProperties.backgroundImageCapInsets) + .resizableImage(withCapInsets: ChatUIConfig.shared.messageProperties.backgroundImageCapInsets) bubbleImage.translatesAutoresizingMaskIntoConstraints = false backView.addSubview(bubbleImage) contentWidth = bubbleImage.widthAnchor.constraint(equalToConstant: chat_content_maxW) @@ -60,7 +60,7 @@ class NEBaseCollectionMessageAudioCell: NEBaseCollectionMessageCell { audioImageView.heightAnchor.constraint(equalToConstant: 28), ]) - audioTimeLabel.font = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.pinMessageTextSize) + audioTimeLabel.font = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.pinMessageTextSize) audioTimeLabel.textAlignment = .left audioTimeLabel.textColor = UIColor.ne_darkText audioTimeLabel.translatesAutoresizingMaskIntoConstraints = false diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/CollectionCell/NEBaseCollectionMessageRichTextCell.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/CollectionCell/NEBaseCollectionMessageRichTextCell.swift index dcaf5b2d..fe410ff0 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/CollectionCell/NEBaseCollectionMessageRichTextCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/CollectionCell/NEBaseCollectionMessageRichTextCell.swift @@ -10,7 +10,7 @@ class NEBaseCollectionMessageRichTextCell: NEBaseCollectionMessageTextCell { /// 换行文本 public lazy var collectionTitleLabel: UILabel = { let label = UILabel() - label.font = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.pinMessageTextSize) + label.font = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.pinMessageTextSize) label.textColor = .ne_darkText label.translatesAutoresizingMaskIntoConstraints = false label.isUserInteractionEnabled = true diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/CollectionCell/NEBaseCollectionMessageTextCell.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/CollectionCell/NEBaseCollectionMessageTextCell.swift index 8de34c7f..7d706383 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/CollectionCell/NEBaseCollectionMessageTextCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/CollectionCell/NEBaseCollectionMessageTextCell.swift @@ -10,7 +10,7 @@ class NEBaseCollectionMessageTextCell: NEBaseCollectionMessageCell { /// 内容文本 public lazy var collectionContentLabel: UILabel = { let label = UILabel() - label.font = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.pinMessageTextSize) + label.font = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.pinMessageTextSize) label.textColor = .ne_darkText label.translatesAutoresizingMaskIntoConstraints = false label.isUserInteractionEnabled = true diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/NEBaseChatMessageCell.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/NEBaseChatMessageCell.swift index 99a19b95..8b869593 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/NEBaseChatMessageCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/NEBaseChatMessageCell.swift @@ -91,7 +91,7 @@ open class NEBaseChatMessageCell: NEChatBaseCell { // 已读未读点击手势 private var tapGesture: UITapGestureRecognizer? - public let messageTextFont = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.messageTextSize) + public let messageTextFont = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.messageTextSize) override public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) @@ -112,12 +112,12 @@ open class NEBaseChatMessageCell: NEChatBaseCell { } open func initProperty() { - timeLabel.font = .systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.timeTextSize) - timeLabel.textColor = NEKitChatConfig.shared.ui.messageProperties.timeTextColor + timeLabel.font = .systemFont(ofSize: ChatUIConfig.shared.messageProperties.timeTextSize) + timeLabel.textColor = ChatUIConfig.shared.messageProperties.timeTextColor timeLabel.textAlignment = .center timeLabel.translatesAutoresizingMaskIntoConstraints = false timeLabel.accessibilityIdentifier = "id.messageTipText" - timeLabel.backgroundColor = .white + timeLabel.backgroundColor = .clear // avatar avatarImageLeft.backgroundColor = UIColor(hexString: "#537FF4") @@ -137,13 +137,13 @@ open class NEBaseChatMessageCell: NEChatBaseCell { // name nameLabelLeft.textAlignment = .center nameLabelLeft.translatesAutoresizingMaskIntoConstraints = false - nameLabelLeft.font = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.userNickTextSize) - nameLabelLeft.textColor = NEKitChatConfig.shared.ui.messageProperties.userNickColor + nameLabelLeft.font = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.userNickTextSize) + nameLabelLeft.textColor = ChatUIConfig.shared.messageProperties.userNickColor nameLabelRight.textAlignment = .center nameLabelRight.translatesAutoresizingMaskIntoConstraints = false - nameLabelRight.font = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.userNickTextSize) - nameLabelRight.textColor = NEKitChatConfig.shared.ui.messageProperties.userNickColor + nameLabelRight.font = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.userNickTextSize) + nameLabelRight.textColor = ChatUIConfig.shared.messageProperties.userNickColor // fullName fullNameLabel.translatesAutoresizingMaskIntoConstraints = false @@ -152,17 +152,17 @@ open class NEBaseChatMessageCell: NEChatBaseCell { fullNameLabel.accessibilityIdentifier = "id.fullNameLabel" // bubbleImage - bubbleImageLeft.backgroundColor = NEKitChatConfig.shared.ui.messageProperties.receiveMessageBg - var image = NEKitChatConfig.shared.ui.messageProperties.leftBubbleBg ?? UIImage.ne_imageNamed(name: "chat_message_receive") + bubbleImageLeft.backgroundColor = ChatUIConfig.shared.messageProperties.receiveMessageBg + var image = ChatUIConfig.shared.messageProperties.leftBubbleBg ?? UIImage.ne_imageNamed(name: "chat_message_receive") bubbleImageLeft.image = image? - .resizableImage(withCapInsets: NEKitChatConfig.shared.ui.messageProperties.backgroundImageCapInsets) + .resizableImage(withCapInsets: ChatUIConfig.shared.messageProperties.backgroundImageCapInsets) bubbleImageLeft.translatesAutoresizingMaskIntoConstraints = false bubbleImageLeft.isUserInteractionEnabled = true - bubbleImageRight.backgroundColor = NEKitChatConfig.shared.ui.messageProperties.selfMessageBg - image = NEKitChatConfig.shared.ui.messageProperties.rightBubbleBg ?? UIImage.ne_imageNamed(name: "chat_message_send") + bubbleImageRight.backgroundColor = ChatUIConfig.shared.messageProperties.selfMessageBg + image = ChatUIConfig.shared.messageProperties.rightBubbleBg ?? UIImage.ne_imageNamed(name: "chat_message_send") bubbleImageRight.image = image? - .resizableImage(withCapInsets: NEKitChatConfig.shared.ui.messageProperties.backgroundImageCapInsets) + .resizableImage(withCapInsets: ChatUIConfig.shared.messageProperties.backgroundImageCapInsets) bubbleImageRight.translatesAutoresizingMaskIntoConstraints = false bubbleImageRight.isUserInteractionEnabled = true @@ -376,12 +376,12 @@ open class NEBaseChatMessageCell: NEChatBaseCell { } open func initSubviewsLayout() { - if NEKitChatConfig.shared.ui.messageProperties.avatarType == .cycle { + if ChatUIConfig.shared.messageProperties.avatarType == .cycle { avatarImageRight.layer.cornerRadius = 16.0 avatarImageLeft.layer.cornerRadius = 16.0 - } else if NEKitChatConfig.shared.ui.messageProperties.avatarCornerRadius > 0 { - avatarImageRight.layer.cornerRadius = NEKitChatConfig.shared.ui.messageProperties.avatarCornerRadius - avatarImageLeft.layer.cornerRadius = NEKitChatConfig.shared.ui.messageProperties.avatarCornerRadius + } else if ChatUIConfig.shared.messageProperties.avatarCornerRadius > 0 { + avatarImageRight.layer.cornerRadius = ChatUIConfig.shared.messageProperties.avatarCornerRadius + avatarImageLeft.layer.cornerRadius = ChatUIConfig.shared.messageProperties.avatarCornerRadius } else { avatarImageRight.layer.cornerRadius = 16.0 avatarImageLeft.layer.cornerRadius = 16.0 @@ -539,7 +539,7 @@ open class NEBaseChatMessageCell: NEChatBaseCell { if receiptEnable, !model.isRevoked, SettingRepo.shared.getShowReadStatus(), - NEKitChatConfig.shared.ui.messageProperties.showP2pMessageStatus == true { + ChatUIConfig.shared.messageProperties.showP2pMessageStatus == true { readView.isHidden = false if model.readCount == 1, model.unreadCount == 0 { readView.progress = 1 @@ -555,13 +555,13 @@ open class NEBaseChatMessageCell: NEChatBaseCell { if receiptEnable, !model.isRevoked, SettingRepo.shared.getShowReadStatus(), - NEKitChatConfig.shared.ui.messageProperties.showTeamMessageStatus == true { + ChatUIConfig.shared.messageProperties.showTeamMessageStatus == true { readView.isHidden = false var total = NETeamUserManager.shared.getTeamInfo()?.memberCount ?? 0 if model.readCount + model.unreadCount != 0 { total = model.readCount + model.unreadCount + 1 } - if total >= NEKitChatConfig.shared.maxReadingNum { + if total >= ChatUIConfig.shared.maxReadingNum { readView.isHidden = true return } @@ -617,8 +617,7 @@ open class NEBaseChatMessageCell: NEChatBaseCell { pinLabel.isHidden = !model.isPined pinImage.isHidden = !model.isPined - contentView.backgroundColor = model.isPined ? NEKitChatConfig.shared.ui - .messageProperties.signalBgColor : .clear + contentView.backgroundColor = model.isPined ? ChatUIConfig.shared.messageProperties.signalBgColor : .clear if model.isPined { let pinText = model.message?.conversationType == .CONVERSATION_TYPE_P2P ? chatLocalizable("pin_text_P2P") : chatLocalizable("pin_text_team") if model.pinAccount == nil { diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/NEBaseChatMessageTipCell.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/NEBaseChatMessageTipCell.swift index 2cda53ba..2fad2c49 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/NEBaseChatMessageTipCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/NEBaseChatMessageTipCell.swift @@ -13,8 +13,8 @@ open class NEBaseChatMessageTipCell: UITableViewCell { /// 时间 public lazy var timeLabel: UILabel = { let label = UILabel() - label.font = .systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.timeTextSize) - label.textColor = NEKitChatConfig.shared.ui.messageProperties.timeTextColor + label.font = .systemFont(ofSize: ChatUIConfig.shared.messageProperties.timeTextSize) + label.textColor = ChatUIConfig.shared.messageProperties.timeTextColor label.textAlignment = .center label.translatesAutoresizingMaskIntoConstraints = false label.accessibilityIdentifier = "id.messageTipText" @@ -24,8 +24,8 @@ open class NEBaseChatMessageTipCell: UITableViewCell { /// 内容 public lazy var contentLabel: UILabel = { let label = UILabel() - label.font = .systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.timeTextSize) - label.textColor = NEKitChatConfig.shared.ui.messageProperties.timeTextColor + label.font = .systemFont(ofSize: ChatUIConfig.shared.messageProperties.timeTextSize) + label.textColor = ChatUIConfig.shared.messageProperties.timeTextColor label.textAlignment = .center label.numberOfLines = 0 label.translatesAutoresizingMaskIntoConstraints = false diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageAudioCell.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageAudioCell.swift index 3b3b4694..4071bf74 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageAudioCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageAudioCell.swift @@ -23,9 +23,9 @@ open class NEBasePinMessageAudioCell: NEBasePinMessageCell { override open func setupUI() { super.setupUI() - let image = NEKitChatConfig.shared.ui.messageProperties.leftBubbleBg ?? UIImage.ne_imageNamed(name: "chat_message_receive") + let image = ChatUIConfig.shared.messageProperties.leftBubbleBg ?? UIImage.ne_imageNamed(name: "chat_message_receive") bubbleImage.image = image? - .resizableImage(withCapInsets: NEKitChatConfig.shared.ui.messageProperties.backgroundImageCapInsets) + .resizableImage(withCapInsets: ChatUIConfig.shared.messageProperties.backgroundImageCapInsets) bubbleImage.translatesAutoresizingMaskIntoConstraints = false bubbleImage.isUserInteractionEnabled = true backView.addSubview(bubbleImage) @@ -54,7 +54,7 @@ open class NEBasePinMessageAudioCell: NEBasePinMessageCell { audioImageView.animationImages = [leftImage1, leftmage2, leftmage3] } - audioTimeLabel.font = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.pinMessageTextSize) + audioTimeLabel.font = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.pinMessageTextSize) audioTimeLabel.textColor = UIColor.ne_darkText audioTimeLabel.textAlignment = .left audioTimeLabel.translatesAutoresizingMaskIntoConstraints = false diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageMultiForwardCell.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageMultiForwardCell.swift index beafbff7..729dea7b 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageMultiForwardCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageMultiForwardCell.swift @@ -26,7 +26,7 @@ open class NEBasePinMessageMultiForwardCell: NEBasePinMessageCell { super.setupUI() // let image = UIImage.ne_imageNamed(name: "chat_message_receive") // backViewLeft.image = image? -// .resizableImage(withCapInsets: NEKitChatConfig.shared.ui.messageProperties.backgroundImageCapInsets) +// .resizableImage(withCapInsets: ChatUIConfig.shared.messageProperties.backgroundImageCapInsets) backViewLeft.layer.cornerRadius = 8 backViewLeft.layer.borderColor = multiForwardborderColor.cgColor backViewLeft.layer.borderWidth = 1 diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageRichTextCell.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageRichTextCell.swift index 37cdd91f..be28fbac 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageRichTextCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageRichTextCell.swift @@ -8,7 +8,7 @@ import UIKit open class NEBasePinMessageRichTextCell: NEBasePinMessageTextCell { public lazy var titleLabel: UILabel = { let label = UILabel() - label.font = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.pinMessageTextSize) + label.font = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.pinMessageTextSize) label.textColor = .ne_darkText label.translatesAutoresizingMaskIntoConstraints = false label.isUserInteractionEnabled = true diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageTextCell.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageTextCell.swift index 6bf09770..d47586af 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageTextCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/Cell/PinCell/NEBasePinMessageTextCell.swift @@ -8,7 +8,7 @@ import UIKit open class NEBasePinMessageTextCell: NEBasePinMessageCell { public lazy var contentLabel: UILabel = { let label = UILabel() - label.font = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.pinMessageTextSize) + label.font = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.pinMessageTextSize) label.textColor = .ne_darkText label.translatesAutoresizingMaskIntoConstraints = false label.isUserInteractionEnabled = true diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/ChatView/NEAITranslateView.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/ChatView/NEAITranslateView.swift index e2232179..a5eaa4d2 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/ChatView/NEAITranslateView.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/ChatView/NEAITranslateView.swift @@ -2,7 +2,6 @@ // Use of this source code is governed by a MIT license that can be // found in the LICENSE file. -import Lottie import NECommonUIKit import UIKit @@ -171,8 +170,8 @@ open class NEAITranslateView: UIView, NEGrowingTextViewDelegate { }() /// 标题栏 loading 动画 - public lazy var loadingAnimationView: LottieAnimationView = { - let view = LottieAnimationView(name: "ne_loading_data", bundle: coreLoader.bundle) + public lazy var loadingAnimationView: NELottieAnimationView = { + let view = NELottieAnimationView(name: "ne_loading_data", bundle: coreLoader.bundle) view.translatesAutoresizingMaskIntoConstraints = false view.loopMode = .loop view.contentMode = .scaleAspectFill diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/ChatView/NEBaseChatInputView.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/ChatView/NEBaseChatInputView.swift index a25c5cf6..3da8c3dd 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/View/ChatView/NEBaseChatInputView.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/View/ChatView/NEBaseChatInputView.swift @@ -290,7 +290,7 @@ open class NEBaseChatInputView: UIView, ChatRecordViewDelegate, open func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { - textView.typingAttributes = [NSAttributedString.Key.foregroundColor: NEKitChatConfig.shared.ui.messageProperties.messageTextColor, + textView.typingAttributes = [NSAttributedString.Key.foregroundColor: ChatUIConfig.shared.messageProperties.messageTextColor, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)] if chatInpuMode == .normal || chatInpuMode == .multipleSend, text == "\n" { diff --git a/NEChatUIKit/NEChatUIKit/Classes/Chat/ViewModel/ChatViewModel.swift b/NEChatUIKit/NEChatUIKit/Classes/Chat/ViewModel/ChatViewModel.swift index c903d955..90c7458a 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Chat/ViewModel/ChatViewModel.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Chat/ViewModel/ChatViewModel.swift @@ -15,8 +15,14 @@ public protocol ChatViewModelDelegate: NSObjectProtocol { /// 本端即将发送消息状态回调,此时消息还未发送,可对消息进行修改或者拦截发送 /// 来源: 发送消息, 插入消息 /// - Parameter message: 消息 - /// - Parameter completion: 是否继续发送消息 - @objc optional func readySendMessage(_ message: V2NIMMessage, _ completion: @escaping (Bool) -> Void) + /// - Parameter completion: 是否继续发送消息、要发送的消息、消息发送参数 + @objc optional func beforeSend(_ param: MessageSendParams) -> MessageSendParams? + + /// 本端即将发送消息状态回调,此时消息还未发送,可对消息进行修改或者拦截发送 + /// 来源: 发送消息, 插入消息 + /// - Parameter message: 消息 + /// - Parameter completion: 是否继续发送消息、要发送的消息、消息发送参数 + @objc optional func beforeSend(_ param: MessageSendParams, _ completion: @escaping (MessageSendParams?) -> Void) /// 消息发送中,此时消息已经发送 /// - Parameters: @@ -176,6 +182,7 @@ open class ChatViewModel: NSObject { /// 添加监听 open func addListener() { chatRepo.addChatListener(self) + chatRepo.addMessageSendListener(self) if IMKitConfigCenter.shared.enableAIUser { AIRepo.shared.addAIListener(self) @@ -184,6 +191,7 @@ open class ChatViewModel: NSObject { deinit { chatRepo.removeChatListener(self) + chatRepo.removeMessageSendListener(self) if IMKitConfigCenter.shared.enableAIUser { AIRepo.shared.removeAIListener(self) @@ -2221,17 +2229,29 @@ open class ChatViewModel: NSObject { } } -// MARK: - NEChatListener +// MARK: - NEMessageListener -extension ChatViewModel: NEChatListener { +extension ChatViewModel: NEMessageListener { /// 本端即将发送消息状态回调,此时消息还未发送,可对消息进行修改或者拦截发送 /// 来源: 发送消息, 插入消息 - /// - Parameter message: 消息 - /// - Parameter completion: 是否继续发送消息 - public func readySendMessage(_ message: V2NIMMessage, _ completion: @escaping (Bool) -> Void) { - delegate?.readySendMessage?(message, completion) + /// - Parameter param: 消息参数,包含消息和发送参数 + /// - Returns: (修改后的)消息参数,若消息参数为 nil,则表示拦截该消息不发送 + public func beforeSend(_ param: MessageSendParams) -> MessageSendParams? { + delegate?.beforeSend?(param) } + /// 本端即将发送消息状态回调,此时消息还未发送,可对消息进行修改或者拦截发送 + /// 来源: 发送消息, 插入消息 + /// - Parameter param: 消息参数,包含消息和发送参数 + /// - Parameter completion: (修改后的)消息参数,若消息参数为 nil,则表示拦截该消息不发送 + public func beforeSend(_ param: MessageSendParams, _ completion: @escaping (MessageSendParams?) -> Void) { + delegate?.beforeSend?(param, completion) + } +} + +// MARK: - NEChatListener + +extension ChatViewModel: NEChatListener { /// 本端发送消息状态回调 /// 来源: 发送消息, 插入消息 /// - Parameter message: 消息 diff --git a/NEChatUIKit/NEChatUIKit/Classes/ChatConfig/ChatUIConfig.swift b/NEChatUIKit/NEChatUIKit/Classes/ChatConfig/ChatUIConfig.swift index 1c72ce9c..2f8c067f 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/ChatConfig/ChatUIConfig.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/ChatConfig/ChatUIConfig.swift @@ -14,38 +14,60 @@ import UIKit case cycle // 圆形 } +/// 消息模块自定义配置 @objcMembers public class ChatUIConfig: NSObject { + public static let shared = ChatUIConfig() + /// 消息页面的 UI 个性化定制 - public var messageItemClick: ((UITableViewCell, MessageContentModel?) -> Void)? + public var messageItemClick: ((NEChatBaseViewController, UITableViewCell, MessageContentModel?) -> Void)? /// 消息页面的 UI 个性化定制 public var messageProperties = MessageProperties() /// 文本输入框下方 tab 按钮定制 - public var chatInputBar: ((inout [UIButton]) -> Void)? + public var chatInputBar: ((ChatViewController?, inout [UIButton]) -> Void)? /// 【更多】区域功能列表 - public var chatInputMenu: ((inout [NEMoreItemModel]) -> Void)? + public var chatInputMenu: ((ChatViewController, inout [NEMoreItemModel]) -> Void)? /// 消息长按弹出菜单回调, 回调中会返回长按弹出菜单列表 - public var chatPopMenu: ((inout [OperationItem], MessageContentModel?) -> Void)? + public var chatPopMenu: ((ChatViewController, inout [OperationItem], MessageContentModel?) -> Void)? /// 消息长按弹出菜单点击事件回调 - public var popMenuClick: ((OperationItem) -> Void)? + public var popMenuClick: ((ChatViewController, OperationItem) -> Void)? /// 消息列表的视图控制器回调,回调中会返回消息列表的视图控制器 public var customController: ((ChatViewController) -> Void)? - /// 消息列表发送消息时的视图控制器回调 - /// 回调参数:消息体和消息列表的视图控制器 - /// 返回值:是否继续发送消息 - public var onSendMessage: ((V2NIMMessage, ChatViewController) -> Bool)? - - /// 用户可自定义参数 + /* + * 用户可自定义参数 + */ - // 发送文件大小限制(单位:MB) + /// 发送文件大小限制(单位:MB) public var fileSizeLimit: Double = 200 + + /// 群未读显示限制数,默认超过200人不显示已读未读进度 + public var maxReadingNum = 200 + + /// 撤回消息可重新编辑时间 (单位:min) + public var revokeEditTimeGap: Int = 2 + + /// 消息可撤回时间 (单位:min) + private var revokeTimeGap: Int = 10080 + + /// 设置消息可撤回时间 (单位:min) + /// 周期为[2, 7*24*60] 分钟, 超过最大值, 修正为最大值, 最小值修正到2分钟 + public func setRevokeTimeGap(_ time: Int) { + revokeTimeGap = max(time, 2) // >= 2 min + revokeTimeGap = min(revokeTimeGap, 10080) // <= 7 d + } + + /// 获取消息可撤回时间 (单位:min) + /// 周期为[2, 7*24*60] 分钟 + public func getReeditTimeGap() -> Int { + revokeTimeGap + } } /// 消息页面的 UI 个性化定制 @@ -109,7 +131,7 @@ public class MessageProperties: NSObject { // 设置标题栏右侧图标按钮展示图标 public var titleBarRightRes: UIImage? // 标题栏右侧图标的点击事件 - public var titleBarRightClick: (() -> Void)? + public var titleBarRightClick: ((ChatViewController) -> Void)? // 设置会话界面背景色 public var chatViewBackground: UIColor? } diff --git a/NEChatUIKit/NEChatUIKit/Classes/ChatConfig/NEKitChatConfig.swift b/NEChatUIKit/NEChatUIKit/Classes/ChatConfig/NEKitChatConfig.swift deleted file mode 100644 index f29d9027..00000000 --- a/NEChatUIKit/NEChatUIKit/Classes/ChatConfig/NEKitChatConfig.swift +++ /dev/null @@ -1,18 +0,0 @@ - -// Copyright (c) 2022 NetEase, Inc. All rights reserved. -// Use of this source code is governed by a MIT license that can be -// found in the LICENSE file. - -import UIKit - -@objcMembers -public class NEKitChatConfig: NSObject { - public static let shared = NEKitChatConfig() - - public var maxReadingNum = 200 // 群未读显示限制数,默认超过200人不显示已读未读进度 - - // chat UI配置相关 - public var ui = ChatUIConfig() - - // chat 其他配置 待扩展 -} diff --git a/NEChatUIKit/NEChatUIKit/Classes/Common/NEChatUIKitClient.swift b/NEChatUIKit/NEChatUIKit/Classes/Common/NEChatUIKitClient.swift index 61fdf866..47e42289 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/Common/NEChatUIKitClient.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/Common/NEChatUIKitClient.swift @@ -58,7 +58,7 @@ open class NEChatUIKitClient: NSObject { /// 获取更多面板数据 /// - Returns: 返回更多操作数据 - open func getMoreActionData(sessionType: V2NIMConversationType) -> [NEMoreItemModel] { + open func getMoreActionData(sessionType: V2NIMConversationType, _ viewController: ChatViewController) -> [NEMoreItemModel] { var more = [NEMoreItemModel]() for model in moreAction { if model.type != .rtc { @@ -68,8 +68,8 @@ open class NEChatUIKitClient: NSObject { } } - if let chatInputMenu = NEKitChatConfig.shared.ui.chatInputMenu { - chatInputMenu(&more) + if let chatInputMenu = ChatUIConfig.shared.chatInputMenu { + chatInputMenu(viewController, &more) } return more diff --git a/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/CollectionCell/FunCollectionMessageAudioCell.swift b/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/CollectionCell/FunCollectionMessageAudioCell.swift index 25ac2849..5d992bdf 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/CollectionCell/FunCollectionMessageAudioCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/CollectionCell/FunCollectionMessageAudioCell.swift @@ -31,8 +31,8 @@ class FunCollectionMessageAudioCell: NEBaseCollectionMessageAudioCell { override open func setupCommonUI() { super.setupCommonUI() setFunStyle() - let image = NEKitChatConfig.shared.ui.messageProperties.leftBubbleBg ?? UIImage.ne_imageNamed(name: "fun_pin_message_audio_bg") + let image = ChatUIConfig.shared.messageProperties.leftBubbleBg ?? UIImage.ne_imageNamed(name: "fun_pin_message_audio_bg") bubbleImage.image = image? - .resizableImage(withCapInsets: NEKitChatConfig.shared.ui.messageProperties.backgroundImageCapInsets) + .resizableImage(withCapInsets: ChatUIConfig.shared.messageProperties.backgroundImageCapInsets) } } diff --git a/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageBaseCell.swift b/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageBaseCell.swift index 95d6004a..5f0eff5f 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageBaseCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageBaseCell.swift @@ -14,13 +14,13 @@ open class FunChatMessageBaseCell: NEBaseChatMessageCell { readView.borderLayer.strokeColor = UIColor.funChatThemeColor.cgColor readView.sectorLayer.fillColor = UIColor.funChatThemeColor.cgColor - var image = NEKitChatConfig.shared.ui.messageProperties.leftBubbleBg ?? UIImage.ne_imageNamed(name: "chat_message_receive_fun") + var image = ChatUIConfig.shared.messageProperties.leftBubbleBg ?? UIImage.ne_imageNamed(name: "chat_message_receive_fun") bubbleImageLeft.image = image? - .resizableImage(withCapInsets: NEKitChatConfig.shared.ui.messageProperties.backgroundImageCapInsets) + .resizableImage(withCapInsets: ChatUIConfig.shared.messageProperties.backgroundImageCapInsets) - image = NEKitChatConfig.shared.ui.messageProperties.rightBubbleBg ?? UIImage.ne_imageNamed(name: "chat_message_send_fun") + image = ChatUIConfig.shared.messageProperties.rightBubbleBg ?? UIImage.ne_imageNamed(name: "chat_message_send_fun") bubbleImageRight.image = image? - .resizableImage(withCapInsets: NEKitChatConfig.shared.ui.messageProperties.backgroundImageCapInsets) + .resizableImage(withCapInsets: ChatUIConfig.shared.messageProperties.backgroundImageCapInsets) selectedButton.setImage(.ne_imageNamed(name: "fun_select"), for: .selected) } @@ -37,12 +37,12 @@ open class FunChatMessageBaseCell: NEBaseChatMessageCell { } override open func initSubviewsLayout() { - if NEKitChatConfig.shared.ui.messageProperties.avatarType == .cycle { + if ChatUIConfig.shared.messageProperties.avatarType == .cycle { avatarImageRight.layer.cornerRadius = 21.0 avatarImageLeft.layer.cornerRadius = 21.0 - } else if NEKitChatConfig.shared.ui.messageProperties.avatarCornerRadius > 0 { - avatarImageRight.layer.cornerRadius = NEKitChatConfig.shared.ui.messageProperties.avatarCornerRadius - avatarImageLeft.layer.cornerRadius = NEKitChatConfig.shared.ui.messageProperties.avatarCornerRadius + } else if ChatUIConfig.shared.messageProperties.avatarCornerRadius > 0 { + avatarImageRight.layer.cornerRadius = ChatUIConfig.shared.messageProperties.avatarCornerRadius + avatarImageLeft.layer.cornerRadius = ChatUIConfig.shared.messageProperties.avatarCornerRadius } else { avatarImageRight.layer.cornerRadius = 4 avatarImageLeft.layer.cornerRadius = 4 diff --git a/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageMultiForwardCell.swift b/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageMultiForwardCell.swift index cbacf99f..18f4541b 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageMultiForwardCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageMultiForwardCell.swift @@ -32,7 +32,7 @@ open class FunChatMessageMultiForwardCell: FunChatMessageBaseCell { bubbleImageLeft.image = nil let image = UIImage.ne_imageNamed(name: "multiForward_message_receive_fun") backViewLeft.image = image? - .resizableImage(withCapInsets: NEKitChatConfig.shared.ui.messageProperties.backgroundImageCapInsets) + .resizableImage(withCapInsets: ChatUIConfig.shared.messageProperties.backgroundImageCapInsets) bubbleImageLeft.addSubview(backViewLeft) NSLayoutConstraint.activate([ @@ -103,7 +103,7 @@ open class FunChatMessageMultiForwardCell: FunChatMessageBaseCell { bubbleImageRight.image = nil let image = UIImage.ne_imageNamed(name: "multiForward_message_send_fun") backViewRight.image = image? - .resizableImage(withCapInsets: NEKitChatConfig.shared.ui.messageProperties.backgroundImageCapInsets) + .resizableImage(withCapInsets: ChatUIConfig.shared.messageProperties.backgroundImageCapInsets) bubbleImageRight.addSubview(backViewRight) NSLayoutConstraint.activate([ diff --git a/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageRevokeCell.swift b/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageRevokeCell.swift index 645d1e5e..a0b9a1fb 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageRevokeCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageRevokeCell.swift @@ -96,10 +96,11 @@ open class FunChatMessageRevokeCell: FunChatMessageBaseCell { let isSend = IMKitClient.instance.isMe(model.message?.senderId) let revokeLabel = isSend ? revokeLabelRight : revokeLabelLeft + // 校验撤回消息可编辑时间 if let time = model.message?.createTime { let date = Date() let currentTime = date.timeIntervalSince1970 - if currentTime - time >= 60 * 2 { + if Int(currentTime - time) >= ChatUIConfig.shared.revokeEditTimeGap * 60 { model.timeOut = true } } diff --git a/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageRichTextCell.swift b/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageRichTextCell.swift index 8a3c542e..370b6297 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageRichTextCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageRichTextCell.swift @@ -17,7 +17,7 @@ open class FunChatMessageRichTextCell: FunChatMessageReplyCell { label.contentInset = .zero label.textContainer.lineFragmentPadding = 0.0 label.isUserInteractionEnabled = false - label.font = .systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.messageTextSize, weight: .semibold) + label.font = .systemFont(ofSize: ChatUIConfig.shared.messageProperties.messageTextSize, weight: .semibold) label.backgroundColor = .clear label.accessibilityIdentifier = "id.messageTitle" @@ -37,7 +37,7 @@ open class FunChatMessageRichTextCell: FunChatMessageReplyCell { label.contentInset = .zero label.textContainer.lineFragmentPadding = 0.0 label.isUserInteractionEnabled = false - label.font = .systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.messageTextSize, weight: .semibold) + label.font = .systemFont(ofSize: ChatUIConfig.shared.messageProperties.messageTextSize, weight: .semibold) label.backgroundColor = .clear label.accessibilityIdentifier = "id.messageTitle" diff --git a/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageTextCell.swift b/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageTextCell.swift index fb9c54bc..9d6485e4 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageTextCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/FunChatMessageTextCell.swift @@ -189,7 +189,7 @@ extension FunChatMessageTextCell: UITextViewDelegate { // textView 垂直居中 func contentSizeToFit(_ contentLabel: UITextView, _ model: MessageTextModel) { - let messageTextFont = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.messageTextSize) + let messageTextFont = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.messageTextSize) let messageMaxSize = CGSize(width: chat_content_maxW, height: CGFloat.greatestFiniteMagnitude) let titleSize = NSAttributedString.getRealSize(contentLabel.attributedText, messageTextFont, messageMaxSize) diff --git a/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/PinCell/FunPinMessageAudioCell.swift b/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/PinCell/FunPinMessageAudioCell.swift index e07ecd30..60488129 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/PinCell/FunPinMessageAudioCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/FunUI/Cell/PinCell/FunPinMessageAudioCell.swift @@ -13,8 +13,8 @@ open class FunPinMessageAudioCell: NEBasePinMessageAudioCell { backRightConstraint?.constant = 0 backView.layer.cornerRadius = 0 headerView.layer.cornerRadius = 4.0 - let image = NEKitChatConfig.shared.ui.messageProperties.leftBubbleBg ?? UIImage.ne_imageNamed(name: "fun_pin_message_audio_bg") + let image = ChatUIConfig.shared.messageProperties.leftBubbleBg ?? UIImage.ne_imageNamed(name: "fun_pin_message_audio_bg") bubbleImage.image = image? - .resizableImage(withCapInsets: NEKitChatConfig.shared.ui.messageProperties.backgroundImageCapInsets) + .resizableImage(withCapInsets: ChatUIConfig.shared.messageProperties.backgroundImageCapInsets) } } diff --git a/NEChatUIKit/NEChatUIKit/Classes/FunUI/Controller/FunTeamChatViewController.swift b/NEChatUIKit/NEChatUIKit/Classes/FunUI/Controller/FunTeamChatViewController.swift index 1247f09b..55dcf4e3 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/FunUI/Controller/FunTeamChatViewController.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/FunUI/Controller/FunTeamChatViewController.swift @@ -31,11 +31,6 @@ open class FunTeamChatViewController: FunChatViewController, TeamChatViewModelDe super.init(coder: coder) } - deinit { - NotificationCenter.default.removeObserver(self) - NETeamUserManager.shared.removeAllTeamInfo() - } - override open func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) onCurrentPage = true diff --git a/NEChatUIKit/NEChatUIKit/Classes/FunUI/View/FunRecordAudioView.swift b/NEChatUIKit/NEChatUIKit/Classes/FunUI/View/FunRecordAudioView.swift index d8373bb1..1f929361 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/FunUI/View/FunRecordAudioView.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/FunUI/View/FunRecordAudioView.swift @@ -2,7 +2,6 @@ // Use of this source code is governed by a MIT license that can be // found in the LICENSE file. -@_implementationOnly import Lottie import UIKit @objc @@ -26,8 +25,8 @@ open class FunRecordAudioView: UIView { public var minRecordProgressWidth: CGFloat = 165.0 - lazy var lottieView: LottieAnimationView = { - let lottie = LottieAnimationView(name: "fun_vioce_data", bundle: coreLoader.bundle) + lazy var lottieView: NELottieAnimationView = { + let lottie = NELottieAnimationView(name: "fun_vioce_data", bundle: coreLoader.bundle) lottie.translatesAutoresizingMaskIntoConstraints = false lottie.loopMode = .loop lottie.contentMode = .scaleToFill diff --git a/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Cell/ChatMessageMultiForwardCell.swift b/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Cell/ChatMessageMultiForwardCell.swift index 1ee7209d..5c813d64 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Cell/ChatMessageMultiForwardCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Cell/ChatMessageMultiForwardCell.swift @@ -30,7 +30,7 @@ open class ChatMessageMultiForwardCell: NormalChatMessageBaseCell { bubbleImageLeft.image = nil let image = UIImage.ne_imageNamed(name: "multiForward_message_receive") backViewLeft.image = image? - .resizableImage(withCapInsets: NEKitChatConfig.shared.ui.messageProperties.backgroundImageCapInsets) + .resizableImage(withCapInsets: ChatUIConfig.shared.messageProperties.backgroundImageCapInsets) bubbleImageLeft.addSubview(backViewLeft) NSLayoutConstraint.activate([ backViewLeft.leftAnchor.constraint(equalTo: bubbleImageLeft.leftAnchor), @@ -100,7 +100,7 @@ open class ChatMessageMultiForwardCell: NormalChatMessageBaseCell { bubbleImageRight.image = nil let image = UIImage.ne_imageNamed(name: "multiForward_message_send") backViewRight.image = image? - .resizableImage(withCapInsets: NEKitChatConfig.shared.ui.messageProperties.backgroundImageCapInsets) + .resizableImage(withCapInsets: ChatUIConfig.shared.messageProperties.backgroundImageCapInsets) bubbleImageRight.addSubview(backViewRight) NSLayoutConstraint.activate([ backViewRight.leftAnchor.constraint(equalTo: bubbleImageRight.leftAnchor), diff --git a/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Cell/ChatMessageRevokeCell.swift b/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Cell/ChatMessageRevokeCell.swift index 8102d941..5f058cb0 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Cell/ChatMessageRevokeCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Cell/ChatMessageRevokeCell.swift @@ -96,10 +96,12 @@ open class ChatMessageRevokeCell: NormalChatMessageBaseCell { override open func setModel(_ model: MessageContentModel, _ isSend: Bool) { let isSend = IMKitClient.instance.isMe(model.message?.senderId) + + // 校验撤回消息可编辑时间 if let time = model.message?.createTime { let date = Date() let currentTime = date.timeIntervalSince1970 - if currentTime - time >= 60 * 2 { + if Int(currentTime - time) >= ChatUIConfig.shared.revokeEditTimeGap * 60 { model.timeOut = true } } diff --git a/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Cell/ChatMessageRichTextCell.swift b/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Cell/ChatMessageRichTextCell.swift index c6a36a6e..cdce4410 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Cell/ChatMessageRichTextCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Cell/ChatMessageRichTextCell.swift @@ -18,7 +18,7 @@ open class ChatMessageRichTextCell: ChatMessageReplyCell { label.contentInset = .zero label.textContainer.lineFragmentPadding = 0.0 label.isUserInteractionEnabled = false - label.font = .systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.messageTextSize, weight: .semibold) + label.font = .systemFont(ofSize: ChatUIConfig.shared.messageProperties.messageTextSize, weight: .semibold) label.backgroundColor = .clear label.accessibilityIdentifier = "id.messageTitle" @@ -38,7 +38,7 @@ open class ChatMessageRichTextCell: ChatMessageReplyCell { label.contentInset = .zero label.textContainer.lineFragmentPadding = 0.0 label.isUserInteractionEnabled = false - label.font = .systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.messageTextSize, weight: .semibold) + label.font = .systemFont(ofSize: ChatUIConfig.shared.messageProperties.messageTextSize, weight: .semibold) label.backgroundColor = .clear label.accessibilityIdentifier = "id.messageTitle" diff --git a/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Cell/ChatMessageTextCell.swift b/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Cell/ChatMessageTextCell.swift index 9935f333..2cc39d0d 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Cell/ChatMessageTextCell.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Cell/ChatMessageTextCell.swift @@ -192,7 +192,7 @@ extension ChatMessageTextCell: UITextViewDelegate { // textView 垂直居中 func contentSizeToFit(_ contentLabel: UITextView, _ model: MessageTextModel) { - let messageTextFont = UIFont.systemFont(ofSize: NEKitChatConfig.shared.ui.messageProperties.messageTextSize) + let messageTextFont = UIFont.systemFont(ofSize: ChatUIConfig.shared.messageProperties.messageTextSize) let messageMaxSize = CGSize(width: chat_content_maxW, height: CGFloat.greatestFiniteMagnitude) let titleSize = NSAttributedString.getRealSize(contentLabel.attributedText, messageTextFont, messageMaxSize) diff --git a/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Controller/TeamChatViewController.swift b/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Controller/TeamChatViewController.swift index 24fc900a..a27b5469 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Controller/TeamChatViewController.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/NormalUI/Controller/TeamChatViewController.swift @@ -33,11 +33,6 @@ open class TeamChatViewController: NormalChatViewController, TeamChatViewModelDe super.init(coder: coder) } - deinit { - NotificationCenter.default.removeObserver(self) - NETeamUserManager.shared.removeAllTeamInfo() - } - override open func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) onCurrentPage = true diff --git a/NEChatUIKit/NEChatUIKit/Classes/NormalUI/View/ChatInpuView.swift b/NEChatUIKit/NEChatUIKit/Classes/NormalUI/View/ChatInpuView.swift index 45559500..928489fd 100644 --- a/NEChatUIKit/NEChatUIKit/Classes/NormalUI/View/ChatInpuView.swift +++ b/NEChatUIKit/NEChatUIKit/Classes/NormalUI/View/ChatInpuView.swift @@ -57,8 +57,8 @@ open class ChatInputView: NEBaseChatInputView { items.append(button) } - if let chatInputBar = NEKitChatConfig.shared.ui.chatInputBar { - chatInputBar(&items) + if let chatInputBar = ChatUIConfig.shared.chatInputBar { + chatInputBar(parentContainerViewController() as? ChatViewController, &items) } stackView = UIStackView(arrangedSubviews: items) diff --git a/NEContactUIKit/NEContactUIKit.podspec b/NEContactUIKit/NEContactUIKit.podspec index 025ad722..dbf110a9 100644 --- a/NEContactUIKit/NEContactUIKit.podspec +++ b/NEContactUIKit/NEContactUIKit.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'NEContactUIKit' - s.version = '10.3.0' + s.version = '10.4.0' s.summary = 'Netease XKit' # This description is used to generate tags and improve search results. @@ -33,6 +33,6 @@ Pod::Spec.new do |s| s.source_files = 'NEContactUIKit/Classes/**/*' s.resource = 'NEContactUIKit/Assets/**/*' s.dependency 'NEChatKit' - s.dependency 'NECommonUIKit', '9.7.0' + s.dependency 'NECommonUIKit', '9.7.3' s.dependency 'MJRefresh' end diff --git a/NEContactUIKit/NEContactUIKit/Classes/ContactConfig/ContactUIConfig.swift b/NEContactUIKit/NEContactUIKit/Classes/ContactConfig/ContactUIConfig.swift index 2204d81f..d1fc14a7 100644 --- a/NEContactUIKit/NEContactUIKit/Classes/ContactConfig/ContactUIConfig.swift +++ b/NEContactUIKit/NEContactUIKit/Classes/ContactConfig/ContactUIConfig.swift @@ -11,8 +11,11 @@ import UIKit case cycle // 圆形 } +/// 通讯录模块自定义配置 @objcMembers public class ContactUIConfig: NSObject { + public static let shared = ContactUIConfig() + // 标题栏文案 public var title: String? @@ -35,22 +38,22 @@ public class ContactUIConfig: NSObject { public var titleBarRight2Res: UIImage? /// 标题栏最右侧按钮点击事件 - public var titleBarRightClick: (() -> Void)? + public var titleBarRightClick: ((NEBaseContactViewController) -> Void)? /// 标题栏次最右侧按钮点击事件 - public var titleBarRight2Click: (() -> Void)? + public var titleBarRight2Click: ((NEBaseContactViewController) -> Void)? /// 是否在通讯录界面显示头部模块 public var showHeader = true /// 通讯录列表头部模块的数据回调 - public var headerData: (([ContactHeadItem]) -> Void)? + public var headerData: ((NEBaseContactViewController, inout [ContactHeadItem]) -> Void)? /// 通讯录列表头部模块 cell 点击事件 - public var headerItemClick: ((ContactInfo, IndexPath) -> Void)? + public var headerItemClick: ((NEBaseContactViewController, ContactInfo, IndexPath) -> Void)? /// 通讯录列表好友 cell 点击事件 - public var friendItemClick: ((ContactInfo, IndexPath) -> Void)? + public var friendItemClick: ((NEBaseContactViewController, ContactInfo, IndexPath) -> Void)? /// 通讯录好友列表的 UI 个性化定制 public var contactProperties = ContactProperties() diff --git a/NEContactUIKit/NEContactUIKit/Classes/ContactConfig/NEKitContactConfig.swift b/NEContactUIKit/NEContactUIKit/Classes/ContactConfig/NEKitContactConfig.swift deleted file mode 100644 index 5083ba6c..00000000 --- a/NEContactUIKit/NEContactUIKit/Classes/ContactConfig/NEKitContactConfig.swift +++ /dev/null @@ -1,14 +0,0 @@ - -// Copyright (c) 2022 NetEase, Inc. All rights reserved. -// Use of this source code is governed by a MIT license that can be -// found in the LICENSE file. - -import UIKit - -@objcMembers -public class NEKitContactConfig: NSObject { - public static let shared = NEKitContactConfig() - - // contact UI配置相关 - public var ui = ContactUIConfig() -} diff --git a/NEContactUIKit/NEContactUIKit/Classes/FunUI/Cell/FunContactSelectedCell.swift b/NEContactUIKit/NEContactUIKit/Classes/FunUI/Cell/FunContactSelectedCell.swift index 9cad7bc0..d46a28c7 100644 --- a/NEContactUIKit/NEContactUIKit/Classes/FunUI/Cell/FunContactSelectedCell.swift +++ b/NEContactUIKit/NEContactUIKit/Classes/FunUI/Cell/FunContactSelectedCell.swift @@ -28,10 +28,10 @@ open class FunContactSelectedCell: NEBaseContactSelectedCell { } override open func initSubviewsLayout() { - if NEKitContactConfig.shared.ui.contactProperties.avatarType == .cycle { + if ContactUIConfig.shared.contactProperties.avatarType == .cycle { avatarImageView.layer.cornerRadius = 20.0 - } else if NEKitContactConfig.shared.ui.contactProperties.avatarCornerRadius > 0 { - avatarImageView.layer.cornerRadius = NEKitContactConfig.shared.ui.contactProperties.avatarCornerRadius + } else if ContactUIConfig.shared.contactProperties.avatarCornerRadius > 0 { + avatarImageView.layer.cornerRadius = ContactUIConfig.shared.contactProperties.avatarCornerRadius } else { avatarImageView.layer.cornerRadius = 4.0 // Fun UI } @@ -39,7 +39,7 @@ open class FunContactSelectedCell: NEBaseContactSelectedCell { override open func setConfig() { super.setConfig() - titleLabel.font = .systemFont(ofSize: NEKitContactConfig.shared.ui.contactProperties.itemTitleSize > 0 ? NEKitContactConfig.shared.ui.contactProperties.itemTitleSize : 17) + titleLabel.font = .systemFont(ofSize: ContactUIConfig.shared.contactProperties.itemTitleSize > 0 ? ContactUIConfig.shared.contactProperties.itemTitleSize : 17) } override open func setModel(_ model: ContactInfo) { diff --git a/NEContactUIKit/NEContactUIKit/Classes/FunUI/Cell/FunContactTableViewCell.swift b/NEContactUIKit/NEContactUIKit/Classes/FunUI/Cell/FunContactTableViewCell.swift index 24c58d33..5fd6f29a 100644 --- a/NEContactUIKit/NEContactUIKit/Classes/FunUI/Cell/FunContactTableViewCell.swift +++ b/NEContactUIKit/NEContactUIKit/Classes/FunUI/Cell/FunContactTableViewCell.swift @@ -27,10 +27,10 @@ open class FunContactTableViewCell: NEBaseContactTableViewCell { } override open func initSubviewsLayout() { - if NEKitContactConfig.shared.ui.contactProperties.avatarType == .cycle { + if ContactUIConfig.shared.contactProperties.avatarType == .cycle { avatarImageView.layer.cornerRadius = 20.0 - } else if NEKitContactConfig.shared.ui.contactProperties.avatarCornerRadius > 0 { - avatarImageView.layer.cornerRadius = NEKitContactConfig.shared.ui.contactProperties.avatarCornerRadius + } else if ContactUIConfig.shared.contactProperties.avatarCornerRadius > 0 { + avatarImageView.layer.cornerRadius = ContactUIConfig.shared.contactProperties.avatarCornerRadius } else { avatarImageView.layer.cornerRadius = 4.0 // Fun UI } @@ -38,7 +38,7 @@ open class FunContactTableViewCell: NEBaseContactTableViewCell { override open func setConfig() { super.setConfig() - titleLabel.font = .systemFont(ofSize: NEKitContactConfig.shared.ui.contactProperties.itemTitleSize > 0 ? NEKitContactConfig.shared.ui.contactProperties.itemTitleSize : 17) + titleLabel.font = .systemFont(ofSize: ContactUIConfig.shared.contactProperties.itemTitleSize > 0 ? ContactUIConfig.shared.contactProperties.itemTitleSize : 17) } override open func setModel(_ model: ContactInfo) { diff --git a/NEContactUIKit/NEContactUIKit/Classes/FunUI/ViewController/FunContactSelectedViewController.swift b/NEContactUIKit/NEContactUIKit/Classes/FunUI/ViewController/FunContactSelectedViewController.swift index 08d909f2..4288ec8a 100644 --- a/NEContactUIKit/NEContactUIKit/Classes/FunUI/ViewController/FunContactSelectedViewController.swift +++ b/NEContactUIKit/NEContactUIKit/Classes/FunUI/ViewController/FunContactSelectedViewController.swift @@ -44,7 +44,7 @@ open class FunContactSelectedViewController: NEBaseContactSelectedViewController .dequeueReusableHeaderFooterView( withIdentifier: "\(NSStringFromClass(ContactSectionView.self))" ) as! ContactSectionView - sectionView.titleLabel.textColor = NEKitContactConfig.shared.ui.contactProperties.indexTitleColor ?? .ne_greyText + sectionView.titleLabel.textColor = ContactUIConfig.shared.contactProperties.indexTitleColor ?? .ne_greyText sectionView.line.isHidden = true sectionView.titleLabel.text = viewModel.contacts[section].initial return sectionView diff --git a/NEContactUIKit/NEContactUIKit/Classes/FunUI/ViewController/FunContactViewController.swift b/NEContactUIKit/NEContactUIKit/Classes/FunUI/ViewController/FunContactViewController.swift index 2330fefc..82826168 100644 --- a/NEContactUIKit/NEContactUIKit/Classes/FunUI/ViewController/FunContactViewController.swift +++ b/NEContactUIKit/NEContactUIKit/Classes/FunUI/ViewController/FunContactViewController.swift @@ -20,7 +20,7 @@ open class FunContactViewController: NEBaseContactViewController { override public init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: nil, bundle: nil) var contactHeaders = [ContactHeadItem]() - if NEKitContactConfig.shared.ui.showHeader { + if ContactUIConfig.shared.showHeader { contactHeaders = [ ContactHeadItem( name: localizable("validation_message"), @@ -54,8 +54,8 @@ open class FunContactViewController: NEBaseContactViewController { )) } - if let headerDataCallback = NEKitContactConfig.shared.ui.headerData { - headerDataCallback(contactHeaders) + if let headerDataCallback = ContactUIConfig.shared.headerData { + headerDataCallback(self, &contactHeaders) } } viewModel = ContactViewModel(contactHeaders: contactHeaders) @@ -69,7 +69,8 @@ open class FunContactViewController: NEBaseContactViewController { super.init(coder: coder) } - deinit { + override open func didMove(toParent parent: UIViewController?) { + super.didMove(toParent: parent) if let searchViewGestures = searchView.gestureRecognizers { for gesture in searchViewGestures { searchView.removeGestureRecognizer(gesture) @@ -157,7 +158,7 @@ extension FunContactViewController { override open func initSystemNav() { edgesForExtendedLayout = [] let addItem = UIBarButtonItem( - image: NEKitContactConfig.shared.ui.titleBarRightRes ?? UIImage.ne_imageNamed(name: "funAdd"), + image: ContactUIConfig.shared.titleBarRightRes ?? UIImage.ne_imageNamed(name: "funAdd"), style: .plain, target: self, action: #selector(goToFindFriend) @@ -167,7 +168,7 @@ extension FunContactViewController { navigationItem.rightBarButtonItems = [addItem] navigationView.addBtn.setImage(UIImage.ne_imageNamed(name: "funAdd"), for: .normal) - if !NEKitContactConfig.shared.ui.showTitleBarRightIcon { + if !ContactUIConfig.shared.showTitleBarRightIcon { navigationItem.rightBarButtonItems = [] navigationView.addBtn.isHidden = true } diff --git a/NEContactUIKit/NEContactUIKit/Classes/Multiselect/Cell/NEBaseSelectCell.swift b/NEContactUIKit/NEContactUIKit/Classes/Multiselect/Cell/NEBaseSelectCell.swift index 07d7bed4..ec4edccd 100644 --- a/NEContactUIKit/NEContactUIKit/Classes/Multiselect/Cell/NEBaseSelectCell.swift +++ b/NEContactUIKit/NEContactUIKit/Classes/Multiselect/Cell/NEBaseSelectCell.swift @@ -85,7 +85,7 @@ open class NEBaseSelectCell: NEBaseContactViewCell { /// 设置文案字体字号 open func setConfig() { - titleLabel.textColor = NEKitContactConfig.shared.ui.contactProperties.itemTitleColor + titleLabel.textColor = ContactUIConfig.shared.contactProperties.itemTitleColor nameLabel.font = UIFont.systemFont(ofSize: 14.0) nameLabel.textColor = UIColor.white } diff --git a/NEContactUIKit/NEContactUIKit/Classes/NormalUI/Cell/ContactSelectedCell.swift b/NEContactUIKit/NEContactUIKit/Classes/NormalUI/Cell/ContactSelectedCell.swift index 4bfc8cb7..b15499e0 100644 --- a/NEContactUIKit/NEContactUIKit/Classes/NormalUI/Cell/ContactSelectedCell.swift +++ b/NEContactUIKit/NEContactUIKit/Classes/NormalUI/Cell/ContactSelectedCell.swift @@ -18,7 +18,7 @@ open class ContactSelectedCell: NEBaseContactSelectedCell { override open func setConfig() { super.setConfig() - titleLabel.font = .systemFont(ofSize: NEKitContactConfig.shared.ui.contactProperties.itemTitleSize > 0 ? NEKitContactConfig.shared.ui.contactProperties.itemTitleSize : 14) + titleLabel.font = .systemFont(ofSize: ContactUIConfig.shared.contactProperties.itemTitleSize > 0 ? ContactUIConfig.shared.contactProperties.itemTitleSize : 14) } override open func setupCommonCircleHeader() { diff --git a/NEContactUIKit/NEContactUIKit/Classes/NormalUI/Cell/ContactTableViewCell.swift b/NEContactUIKit/NEContactUIKit/Classes/NormalUI/Cell/ContactTableViewCell.swift index 04dac9d2..877b6e4f 100644 --- a/NEContactUIKit/NEContactUIKit/Classes/NormalUI/Cell/ContactTableViewCell.swift +++ b/NEContactUIKit/NEContactUIKit/Classes/NormalUI/Cell/ContactTableViewCell.swift @@ -12,7 +12,7 @@ import UIKit open class ContactTableViewCell: NEBaseContactTableViewCell { override open func setConfig() { super.setConfig() - titleLabel.font = .systemFont(ofSize: NEKitContactConfig.shared.ui.contactProperties.itemTitleSize > 0 ? NEKitContactConfig.shared.ui.contactProperties.itemTitleSize : 14) + titleLabel.font = .systemFont(ofSize: ContactUIConfig.shared.contactProperties.itemTitleSize > 0 ? ContactUIConfig.shared.contactProperties.itemTitleSize : 14) } override open func commonUI() { diff --git a/NEContactUIKit/NEContactUIKit/Classes/NormalUI/Cell/SelectCell.swift b/NEContactUIKit/NEContactUIKit/Classes/NormalUI/Cell/SelectCell.swift index b0f685be..83bc8571 100644 --- a/NEContactUIKit/NEContactUIKit/Classes/NormalUI/Cell/SelectCell.swift +++ b/NEContactUIKit/NEContactUIKit/Classes/NormalUI/Cell/SelectCell.swift @@ -29,7 +29,7 @@ open class SelectCell: NEBaseSelectCell { /// 重写设置文案字体方案 override open func setConfig() { super.setConfig() - titleLabel.font = .systemFont(ofSize: NEKitContactConfig.shared.ui.contactProperties.itemTitleSize > 0 ? NEKitContactConfig.shared.ui.contactProperties.itemTitleSize : 14) + titleLabel.font = .systemFont(ofSize: ContactUIConfig.shared.contactProperties.itemTitleSize > 0 ? ContactUIConfig.shared.contactProperties.itemTitleSize : 14) } /// 重写设置头像方法 diff --git a/NEContactUIKit/NEContactUIKit/Classes/NormalUI/ViewController/ContactViewController.swift b/NEContactUIKit/NEContactUIKit/Classes/NormalUI/ViewController/ContactViewController.swift index cd45d6c5..d09efb29 100644 --- a/NEContactUIKit/NEContactUIKit/Classes/NormalUI/ViewController/ContactViewController.swift +++ b/NEContactUIKit/NEContactUIKit/Classes/NormalUI/ViewController/ContactViewController.swift @@ -11,7 +11,7 @@ open class ContactViewController: NEBaseContactViewController { override public init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: nil, bundle: nil) var contactHeaders = [ContactHeadItem]() - if NEKitContactConfig.shared.ui.showHeader { + if ContactUIConfig.shared.showHeader { contactHeaders = [ ContactHeadItem( name: localizable("validation_message"), @@ -45,8 +45,8 @@ open class ContactViewController: NEBaseContactViewController { )) } - if let headerDataCallback = NEKitContactConfig.shared.ui.headerData { - headerDataCallback(contactHeaders) + if let headerDataCallback = ContactUIConfig.shared.headerData { + headerDataCallback(self, &contactHeaders) } } viewModel = ContactViewModel(contactHeaders: contactHeaders) @@ -108,14 +108,14 @@ extension ContactViewController { override open func initSystemNav() { super.initSystemNav() let addItem = UIBarButtonItem( - image: NEKitContactConfig.shared.ui.titleBarRightRes ?? UIImage.ne_imageNamed(name: "add"), + image: ContactUIConfig.shared.titleBarRightRes ?? UIImage.ne_imageNamed(name: "add"), style: .plain, target: self, action: #selector(goToFindFriend) ) addItem.tintColor = UIColor(hexString: "333333") let searchItem = UIBarButtonItem( - image: NEKitContactConfig.shared.ui.titleBarRight2Res ?? UIImage.ne_imageNamed(name: "contact_search"), + image: ContactUIConfig.shared.titleBarRight2Res ?? UIImage.ne_imageNamed(name: "contact_search"), style: .plain, target: self, action: #selector(searchContact) @@ -124,25 +124,25 @@ extension ContactViewController { searchItem.tintColor = UIColor(hexString: "333333") navigationItem.rightBarButtonItems = [addItem, searchItem] - if !NEKitContactConfig.shared.ui.showTitleBarRight2Icon { + if !ContactUIConfig.shared.showTitleBarRight2Icon { navigationItem.rightBarButtonItems = [addItem] navigationView.searchBtn.isHidden = true } - if !NEKitContactConfig.shared.ui.showTitleBarRightIcon { + if !ContactUIConfig.shared.showTitleBarRightIcon { navigationItem.rightBarButtonItems = [searchItem] navigationView.addBtn.isHidden = true } let brandBarBtn = UIButton() - brandBarBtn.setTitle(NEKitContactConfig.shared.ui.title ?? localizable("contact"), for: .normal) - brandBarBtn.setTitleColor(NEKitContactConfig.shared.ui.titleColor ?? UIColor.black, for: .normal) + brandBarBtn.setTitle(ContactUIConfig.shared.title ?? localizable("contact"), for: .normal) + brandBarBtn.setTitleColor(ContactUIConfig.shared.titleColor ?? UIColor.black, for: .normal) brandBarBtn.titleLabel?.font = NEConstant.textFont("PingFangSC-Medium", 20) let brandBtn = UIBarButtonItem(customView: brandBarBtn) navigationItem.leftBarButtonItem = brandBtn navigationView.brandBtn.setImage(nil, for: .normal) - navigationView.brandBtn.setTitle(NEKitContactConfig.shared.ui.title ?? localizable("contact"), for: .normal) - navigationView.brandBtn.setTitleColor(NEKitContactConfig.shared.ui.titleColor ?? UIColor.black, for: .normal) + navigationView.brandBtn.setTitle(ContactUIConfig.shared.title ?? localizable("contact"), for: .normal) + navigationView.brandBtn.setTitleColor(ContactUIConfig.shared.titleColor ?? UIColor.black, for: .normal) navigationView.brandBtn.titleEdgeInsets = UIEdgeInsets.zero } } diff --git a/NEContactUIKit/NEContactUIKit/Classes/Views/Cell/NEBaseContactTableViewCell.swift b/NEContactUIKit/NEContactUIKit/Classes/Views/Cell/NEBaseContactTableViewCell.swift index 06d4dddc..0f295b4d 100644 --- a/NEContactUIKit/NEContactUIKit/Classes/Views/Cell/NEBaseContactTableViewCell.swift +++ b/NEContactUIKit/NEContactUIKit/Classes/Views/Cell/NEBaseContactTableViewCell.swift @@ -71,17 +71,17 @@ open class NEBaseContactTableViewCell: NEBaseContactViewCell, ContactCellDataPro } open func initSubviewsLayout() { - if NEKitContactConfig.shared.ui.contactProperties.avatarType == .cycle { + if ContactUIConfig.shared.contactProperties.avatarType == .cycle { avatarImageView.layer.cornerRadius = 18.0 - } else if NEKitContactConfig.shared.ui.contactProperties.avatarCornerRadius > 0 { - avatarImageView.layer.cornerRadius = NEKitContactConfig.shared.ui.contactProperties.avatarCornerRadius + } else if ContactUIConfig.shared.contactProperties.avatarCornerRadius > 0 { + avatarImageView.layer.cornerRadius = ContactUIConfig.shared.contactProperties.avatarCornerRadius } else { avatarImageView.layer.cornerRadius = 18.0 // Normal UI } } open func setConfig() { - titleLabel.textColor = NEKitContactConfig.shared.ui.contactProperties.itemTitleColor + titleLabel.textColor = ContactUIConfig.shared.contactProperties.itemTitleColor nameLabel.font = UIFont.systemFont(ofSize: 14.0) nameLabel.textColor = UIColor.white } diff --git a/NEContactUIKit/NEContactUIKit/Classes/Views/ContactSectionView.swift b/NEContactUIKit/NEContactUIKit/Classes/Views/ContactSectionView.swift index fceebfdb..146911a8 100644 --- a/NEContactUIKit/NEContactUIKit/Classes/Views/ContactSectionView.swift +++ b/NEContactUIKit/NEContactUIKit/Classes/Views/ContactSectionView.swift @@ -23,7 +23,7 @@ open class ContactSectionView: UITableViewHeaderFooterView { contentView.backgroundColor = .white titleLabel.translatesAutoresizingMaskIntoConstraints = false titleLabel.backgroundColor = .white - titleLabel.textColor = NEKitContactConfig.shared.ui.contactProperties.indexTitleColor ?? UIColor.ne_emptyTitleColor + titleLabel.textColor = ContactUIConfig.shared.contactProperties.indexTitleColor ?? UIColor.ne_emptyTitleColor titleLabel.font = UIFont.systemFont(ofSize: 14.0) contentView.addSubview(titleLabel) NSLayoutConstraint.activate([ @@ -34,7 +34,7 @@ open class ContactSectionView: UITableViewHeaderFooterView { ]) line.translatesAutoresizingMaskIntoConstraints = false - line.backgroundColor = NEKitContactConfig.shared.ui.contactProperties.divideLineColor + line.backgroundColor = ContactUIConfig.shared.contactProperties.divideLineColor contentView.addSubview(line) NSLayoutConstraint.activate([ line.leftAnchor.constraint(equalTo: titleLabel.leftAnchor), diff --git a/NEContactUIKit/NEContactUIKit/Classes/Views/NEBaseContactViewController.swift b/NEContactUIKit/NEContactUIKit/Classes/Views/NEBaseContactViewController.swift index f8e90228..89e46c29 100644 --- a/NEContactUIKit/NEContactUIKit/Classes/Views/NEBaseContactViewController.swift +++ b/NEContactUIKit/NEContactUIKit/Classes/Views/NEBaseContactViewController.swift @@ -46,10 +46,10 @@ open class NEBaseContactViewController: UIViewController, UITableViewDelegate, U nav.translatesAutoresizingMaskIntoConstraints = false nav.delegate = self - if let addImg = NEKitContactConfig.shared.ui.titleBarRightRes { + if let addImg = ContactUIConfig.shared.titleBarRightRes { nav.addBtn.setImage(addImg, for: .normal) } - if let searchImg = NEKitContactConfig.shared.ui.titleBarRight2Res { + if let searchImg = ContactUIConfig.shared.titleBarRight2Res { nav.searchBtn.setImage(searchImg, for: .normal) } return nav @@ -166,6 +166,10 @@ open class NEBaseContactViewController: UIViewController, UITableViewDelegate, U loadData() viewModel.getAddApplicationUnreadCount(nil) + + if let customController = ContactUIConfig.shared.customController { + customController(self) + } } override open func viewDidLoad() { @@ -193,7 +197,7 @@ open class NEBaseContactViewController: UIViewController, UITableViewDelegate, U if let useSystemNav = NEConfigManager.instance.getParameter(key: useSystemNav) as? Bool, useSystemNav { navigationView.isHidden = true topConstant = 0 - if NEKitContactConfig.shared.ui.showTitleBar { + if ContactUIConfig.shared.showTitleBar { navigationController?.isNavigationBarHidden = false } else { navigationController?.isNavigationBarHidden = true @@ -203,7 +207,7 @@ open class NEBaseContactViewController: UIViewController, UITableViewDelegate, U } } else { navigationController?.isNavigationBarHidden = true - if NEKitContactConfig.shared.ui.showTitleBar { + if ContactUIConfig.shared.showTitleBar { navigationView.isHidden = false topConstant = NEConstant.navigationHeight } else { @@ -254,10 +258,6 @@ open class NEBaseContactViewController: UIViewController, UITableViewDelegate, U ]) bodyBottomViewHeightAnchor = bodyBottomView.heightAnchor.constraint(equalToConstant: bodyBottomViewHeight) bodyBottomViewHeightAnchor?.isActive = true - - if let customController = NEKitContactConfig.shared.ui.customController { - customController(self) - } } open func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { @@ -357,8 +357,8 @@ open class NEBaseContactViewController: UIViewController, UITableViewDelegate, U let info = viewModel.contacts[indexPath.section].contacts[indexPath.row] if info.contactCellType == ContactCellType.ContactOthers.rawValue { - if let headerItemClick = NEKitContactConfig.shared.ui.headerItemClick { - headerItemClick(info, indexPath) + if let headerItemClick = ContactUIConfig.shared.headerItemClick { + headerItemClick(self, info, indexPath) return } @@ -393,8 +393,8 @@ open class NEBaseContactViewController: UIViewController, UITableViewDelegate, U } } } else { - if let friendItemClick = NEKitContactConfig.shared.ui.friendItemClick { - friendItemClick(info, indexPath) + if let friendItemClick = ContactUIConfig.shared.friendItemClick { + friendItemClick(self, info, indexPath) return } @@ -445,16 +445,16 @@ extension NEBaseContactViewController { // MARK: TabNavigationViewDelegate open func searchAction() { - if let searchBlock = NEKitContactConfig.shared.ui.titleBarRight2Click { - searchBlock() + if let searchBlock = ContactUIConfig.shared.titleBarRight2Click { + searchBlock(self) return } searchContact() } open func didClickAddBtn() { - if let addBlock = NEKitContactConfig.shared.ui.titleBarRightClick { - addBlock() + if let addBlock = ContactUIConfig.shared.titleBarRightClick { + addBlock(self) return } goToFindFriend() diff --git a/NEContactUIKit/NEContactUIKit/Classes/Views/NEContactBaseViewController.swift b/NEContactUIKit/NEContactUIKit/Classes/Views/NEContactBaseViewController.swift index bdedb023..ec6789f3 100644 --- a/NEContactUIKit/NEContactUIKit/Classes/Views/NEContactBaseViewController.swift +++ b/NEContactUIKit/NEContactUIKit/Classes/Views/NEContactBaseViewController.swift @@ -55,7 +55,7 @@ open class NEContactBaseViewController: UIViewController, UIGestureRecognizerDel super.viewWillAppear(animated) // 配置项:会话界面是否展示标题栏 - if !NEKitContactConfig.shared.ui.showTitleBar { + if !ContactUIConfig.shared.showTitleBar { navigationController?.isNavigationBarHidden = true navigationView.removeFromSuperview() return diff --git a/NEConversationUIKit/NEConversationUIKit.podspec b/NEConversationUIKit/NEConversationUIKit.podspec index 49f67d69..eda380af 100644 --- a/NEConversationUIKit/NEConversationUIKit.podspec +++ b/NEConversationUIKit/NEConversationUIKit.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'NEConversationUIKit' - s.version = '10.3.0' + s.version = '10.4.0' s.summary = 'Netease XKit' # This description is used to generate tags and improve search results. @@ -38,7 +38,7 @@ TODO: Add long description of the pod here. 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' } - s.dependency 'NECommonUIKit', '9.7.0' + s.dependency 'NECommonUIKit', '9.7.3' s.dependency 'NEChatKit' s.dependency 'MJRefresh' end diff --git a/NEConversationUIKit/NEConversationUIKit/Classes/Common/ConversationColorExtension.swift b/NEConversationUIKit/NEConversationUIKit/Classes/Common/ConversationColorExtension.swift deleted file mode 100644 index 3b5932e5..00000000 --- a/NEConversationUIKit/NEConversationUIKit/Classes/Common/ConversationColorExtension.swift +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2022 NetEase, Inc. All rights reserved. -// Use of this source code is governed by a MIT license that can be -// found in the LICENSE file. - -import Foundation - -public extension UIColor { - // MARK: text color - - static let ne_darkText = UIColor(hexString: "#333333") - static let ne_greyText = UIColor(hexString: "#666666") - static let ne_lightText = UIColor(hexString: "#999999") - static let ne_blueText = UIColor(hexString: "#337EFF") - static let ne_redText = UIColor(hexString: "#E6605C") - static let ne_disableRedText = UIColor(hexString: "#E6605C", 0.5) - static let ne_backcolor = UIColor(hexString: "F2F4F5") - static let ne_emptyTitleColor = UIColor(hexString: "B3B7BC") - - // MARK: view background color - - static let ne_lightBackgroundColor = UIColor(hexString: "#EFF1F4") - static let ne_defautAvatarColor = UIColor(hexString: "#537FF4") - static let ne_greenColor = UIColor(hexString: "#42C294") - - // MARK: border color - - static let ne_borderColor = UIColor(hexString: "#DBDDE4") - - // MARK: line color - - static let ne_greyLine = UIColor(hexString: "#F5F8FC") - - static let ne_redColor = UIColor(hexString: "#F24957") -} diff --git a/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Cell/NEBaseConversationListCell.swift b/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Cell/NEBaseConversationListCell.swift index 3acd0e9b..e0916fd4 100644 --- a/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Cell/NEBaseConversationListCell.swift +++ b/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Cell/NEBaseConversationListCell.swift @@ -24,7 +24,7 @@ open class NEBaseConversationListCell: UITableViewCell { open func setupSubviews() { selectionStyle = .none - if let bgColor = NEKitConversationConfig.shared.ui.conversationProperties.itemBackground { + if let bgColor = ConversationUIConfig.shared.conversationProperties.itemBackground { backgroundColor = bgColor } @@ -144,7 +144,7 @@ open class NEBaseConversationListCell: UITableViewCell { let atStr = localizable("you_were_mentioned") mutaAttri.insert(NSAttributedString(string: atStr), at: 0) mutaAttri.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.ne_redText, range: NSMakeRange(0, atStr.count)) - mutaAttri.addAttribute(NSAttributedString.Key.font, value: UIFont.systemFont(ofSize: NEKitConversationConfig.shared.ui.conversationProperties.itemContentSize > 0 ? NEKitConversationConfig.shared.ui.conversationProperties.itemContentSize : 13), range: NSMakeRange(0, mutaAttri.length)) + mutaAttri.addAttribute(NSAttributedString.Key.font, value: UIFont.systemFont(ofSize: ConversationUIConfig.shared.conversationProperties.itemContentSize > 0 ? ConversationUIConfig.shared.conversationProperties.itemContentSize : 13), range: NSMakeRange(0, mutaAttri.length)) } } subTitleLabel.attributedText = mutaAttri @@ -258,8 +258,8 @@ open class NEBaseConversationListCell: UITableViewCell { public lazy var titleLabel: UILabel = { let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false - label.textColor = NEKitConversationConfig.shared.ui.conversationProperties.itemTitleColor - label.font = .systemFont(ofSize: NEKitConversationConfig.shared.ui.conversationProperties.itemTitleSize > 0 ? NEKitConversationConfig.shared.ui.conversationProperties.itemTitleSize : 16) + label.textColor = ConversationUIConfig.shared.conversationProperties.itemTitleColor + label.font = .systemFont(ofSize: ConversationUIConfig.shared.conversationProperties.itemTitleSize > 0 ? ConversationUIConfig.shared.conversationProperties.itemTitleSize : 16) label.text = "Oliver" label.accessibilityIdentifier = "id.name" return label @@ -269,8 +269,8 @@ open class NEBaseConversationListCell: UITableViewCell { public lazy var subTitleLabel: UILabel = { let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false - label.textColor = NEKitConversationConfig.shared.ui.conversationProperties.itemContentColor - label.font = UIFont.systemFont(ofSize: NEKitConversationConfig.shared.ui.conversationProperties.itemContentSize > 0 ? NEKitConversationConfig.shared.ui.conversationProperties.itemContentSize : 13) + label.textColor = ConversationUIConfig.shared.conversationProperties.itemContentColor + label.font = UIFont.systemFont(ofSize: ConversationUIConfig.shared.conversationProperties.itemContentSize > 0 ? ConversationUIConfig.shared.conversationProperties.itemContentSize : 13) label.accessibilityIdentifier = "id.message" return label }() @@ -279,8 +279,8 @@ open class NEBaseConversationListCell: UITableViewCell { public lazy var timeLabel: UILabel = { let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false - label.textColor = NEKitConversationConfig.shared.ui.conversationProperties.itemDateColor - label.font = .systemFont(ofSize: NEKitConversationConfig.shared.ui.conversationProperties.itemDateSize > 0 ? NEKitConversationConfig.shared.ui.conversationProperties.itemDateSize : 12) + label.textColor = ConversationUIConfig.shared.conversationProperties.itemDateColor + label.font = .systemFont(ofSize: ConversationUIConfig.shared.conversationProperties.itemDateSize > 0 ? ConversationUIConfig.shared.conversationProperties.itemDateSize : 12) label.textAlignment = .right label.accessibilityIdentifier = "id.time" return label diff --git a/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Cell/NEBaseConversationSearchCell.swift b/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Cell/NEBaseConversationSearchCell.swift index 7e584792..6b2f0dab 100644 --- a/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Cell/NEBaseConversationSearchCell.swift +++ b/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Cell/NEBaseConversationSearchCell.swift @@ -84,6 +84,6 @@ open class NEBaseConversationSearchCell: TextBaseCell { } func getRangeTextColor() -> UIColor { - UIColor.ne_blueText + UIColor.ne_normalTheme } } diff --git a/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Controller/NEBaseConversationController.swift b/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Controller/NEBaseConversationController.swift index f74dc83f..fe05cc08 100644 --- a/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Controller/NEBaseConversationController.swift +++ b/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Controller/NEBaseConversationController.swift @@ -57,28 +57,28 @@ open class NEBaseConversationController: UIViewController, UIGestureRecognizerDe nav.brandBtn.addTarget(self, action: #selector(brandBtnClick), for: .touchUpInside) - if let brandTitle = NEKitConversationConfig.shared.ui.titleBarTitle { + if let brandTitle = ConversationUIConfig.shared.titleBarTitle { nav.brandBtn.setTitle(brandTitle, for: .normal) } - if let brandTitleColor = NEKitConversationConfig.shared.ui.titleBarTitleColor { + if let brandTitleColor = ConversationUIConfig.shared.titleBarTitleColor { nav.brandBtn.setTitleColor(brandTitleColor, for: .normal) } - if !NEKitConversationConfig.shared.ui.showTitleBarLeftIcon { + if !ConversationUIConfig.shared.showTitleBarLeftIcon { nav.brandBtn.setImage(nil, for: .normal) // 如果左侧图标为空,则左侧文案左对齐 nav.brandBtn.layoutButtonImage(style: .left, space: 0) } - if let brandImg = NEKitConversationConfig.shared.ui.titleBarLeftRes { + if let brandImg = ConversationUIConfig.shared.titleBarLeftRes { nav.brandBtn.setImage(brandImg, for: .normal) if brandImg.size.width == 0, brandImg.size.height == 0 { // 如果左侧图标为空,则左侧文案左对齐 nav.brandBtn.layoutButtonImage(style: .left, space: 0) } } - if let rightImg = NEKitConversationConfig.shared.ui.titleBarRightRes { + if let rightImg = ConversationUIConfig.shared.titleBarRightRes { nav.addBtn.setImage(rightImg, for: .normal) } - if let right2Img = NEKitConversationConfig.shared.ui.titleBarRight2Res { + if let right2Img = ConversationUIConfig.shared.titleBarRight2Res { nav.searchBtn.setImage(right2Img, for: .normal) } return nav @@ -247,6 +247,10 @@ open class NEBaseConversationController: UIViewController, UIGestureRecognizerDe } } } + + if let customController = ConversationUIConfig.shared.customController { + customController(self) + } } override open func viewDidLoad() { @@ -275,7 +279,7 @@ open class NEBaseConversationController: UIViewController, UIGestureRecognizerDe if let useSystemNav = NEConfigManager.instance.getParameter(key: useSystemNav) as? Bool, useSystemNav { navigationView.isHidden = true topConstant = 0 - if NEKitConversationConfig.shared.ui.showTitleBar { + if ConversationUIConfig.shared.showTitleBar { navigationController?.isNavigationBarHidden = false } else { navigationController?.isNavigationBarHidden = true @@ -285,7 +289,7 @@ open class NEBaseConversationController: UIViewController, UIGestureRecognizerDe } } else { navigationController?.isNavigationBarHidden = true - if NEKitConversationConfig.shared.ui.showTitleBar { + if ConversationUIConfig.shared.showTitleBar { navigationView.isHidden = false topConstant = NEConstant.navigationHeight } else { @@ -357,10 +361,6 @@ open class NEBaseConversationController: UIViewController, UIGestureRecognizerDe for (key, value) in stickTopCellRegisterDic { stickTopCollcetionView.register(value, forCellWithReuseIdentifier: "\(key)") } - - if let customController = NEKitConversationConfig.shared.ui.customController { - customController(self) - } } open func initialConfig() { @@ -419,13 +419,13 @@ open class NEBaseConversationController: UIViewController, UIGestureRecognizerDe extension NEBaseConversationController: TabNavigationViewDelegate { /// 标题栏左侧按钮点击事件 func brandBtnClick() { - NEKitConversationConfig.shared.ui.titleBarLeftClick?() + ConversationUIConfig.shared.titleBarLeftClick?(self) } /// 点击搜索会话 open func searchAction() { - if let searchBlock = NEKitConversationConfig.shared.ui.titleBarRight2Click { - searchBlock() + if let searchBlock = ConversationUIConfig.shared.titleBarRight2Click { + searchBlock(self) return } @@ -475,8 +475,8 @@ extension NEBaseConversationController: TabNavigationViewDelegate { } open func didClickAddBtn() { - if let addBlock = NEKitConversationConfig.shared.ui.titleBarRightClick { - addBlock() + if let addBlock = ConversationUIConfig.shared.titleBarRightClick { + addBlock(self) return } @@ -670,8 +670,8 @@ extension NEBaseConversationController: UITableViewDelegate, UITableViewDataSour conversationModel = viewModel.conversationListData[indexPath.row] } - if let didClick = NEKitConversationConfig.shared.ui.itemClick, let model = conversationModel { - didClick(model, indexPath) + if let didClick = ConversationUIConfig.shared.itemClick, let model = conversationModel { + didClick(self, model, indexPath) return } @@ -686,19 +686,19 @@ extension NEBaseConversationController: UITableViewDelegate, UITableViewDataSour var rowActions = [UITableViewRowAction]() let deleteAction = UITableViewRowAction(style: .destructive, - title: NEKitConversationConfig.shared.ui.deleteButtonTitle) { action, indexPath in + title: ConversationUIConfig.shared.deleteButtonTitle) { action, indexPath in weakSelf?.deleteActionHandler(action: action, indexPath: indexPath) } // 置顶和取消置顶 let isTop = indexPath.section == 0 ? true : false // viewModel.stickTopInfos[session] != nil let topAction = UITableViewRowAction(style: .destructive, - title: isTop ? NEKitConversationConfig.shared.ui.stickTopButtonCancelTitle : - NEKitConversationConfig.shared.ui.stickTopButtonTitle) { action, indexPath in + title: isTop ? ConversationUIConfig.shared.stickTopButtonCancelTitle : + ConversationUIConfig.shared.stickTopButtonTitle) { action, indexPath in weakSelf?.topActionHandler(action: action, indexPath: indexPath, isTop: isTop) } - deleteAction.backgroundColor = NEKitConversationConfig.shared.ui.deleteButtonBackgroundColor ?? deleteButtonBackgroundColor - topAction.backgroundColor = NEKitConversationConfig.shared.ui.stickTopButtonBackgroundColor ?? NEConstant.hexRGB(0x337EFF) + deleteAction.backgroundColor = ConversationUIConfig.shared.deleteButtonBackgroundColor ?? deleteButtonBackgroundColor + topAction.backgroundColor = ConversationUIConfig.shared.stickTopButtonBackgroundColor ?? NEConstant.hexRGB(0x337EFF) rowActions.append(deleteAction) rowActions.append(topAction) @@ -743,8 +743,8 @@ extension NEBaseConversationController: UITableViewDelegate, UITableViewDataSour conversationModel = viewModel.conversationListData[indexPath.row] } - if let deleteButtonClick = NEKitConversationConfig.shared.ui.deleteButtonClick { - deleteButtonClick(conversationModel, indexPath) + if let deleteButtonClick = ConversationUIConfig.shared.deleteButtonClick { + deleteButtonClick(self, conversationModel, indexPath) return } @@ -788,8 +788,8 @@ extension NEBaseConversationController: UITableViewDelegate, UITableViewDataSour conversationModel = viewModel.conversationListData[indexPath.row] } - if let stickTopButtonClick = NEKitConversationConfig.shared.ui.stickTopButtonClick { - stickTopButtonClick(conversationModel, indexPath) + if let stickTopButtonClick = ConversationUIConfig.shared.stickTopButtonClick { + stickTopButtonClick(self, conversationModel, indexPath) return } diff --git a/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Controller/NEConversationBaseViewController.swift b/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Controller/NEConversationBaseViewController.swift index 6e76a364..d205c428 100644 --- a/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Controller/NEConversationBaseViewController.swift +++ b/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Controller/NEConversationBaseViewController.swift @@ -43,7 +43,7 @@ open class NEConversationBaseViewController: UIViewController, UIGestureRecogniz super.viewWillAppear(animated) // 配置项:会话界面是否展示标题栏 - if !NEKitConversationConfig.shared.ui.showTitleBar { + if !ConversationUIConfig.shared.showTitleBar { navigationController?.isNavigationBarHidden = true navigationView.removeFromSuperview() return diff --git a/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Model/NEConversationListModel.swift b/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Model/NEConversationListModel.swift index 2dd2db13..8417a111 100644 --- a/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Model/NEConversationListModel.swift +++ b/NEConversationUIKit/NEConversationUIKit/Classes/Conversation/Model/NEConversationListModel.swift @@ -18,7 +18,7 @@ public class NEConversationListModel: NSObject, Comparable { public var conversation: V2NIMConversation? { didSet { if let lastMessage = conversation?.lastMessage, lastMessage.messageType == .MESSAGE_TYPE_TEXT, let text = lastMessage.text { - lastMessageConent = NEChatKitClient.instance.getEmojString(text, NEKitConversationConfig.shared.ui.conversationProperties.itemContentSize > 0 ? NEKitConversationConfig.shared.ui.conversationProperties.itemContentSize : 13) + lastMessageConent = NEChatKitClient.instance.getEmojString(text, ConversationUIConfig.shared.conversationProperties.itemContentSize > 0 ? ConversationUIConfig.shared.conversationProperties.itemContentSize : 13) } else { lastMessageConent = nil } diff --git a/NEConversationUIKit/NEConversationUIKit/Classes/ConversationConfig/ConversationUIConfig.swift b/NEConversationUIKit/NEConversationUIKit/Classes/ConversationConfig/ConversationUIConfig.swift index 89910cf4..201fe066 100644 --- a/NEConversationUIKit/NEConversationUIKit/Classes/ConversationConfig/ConversationUIConfig.swift +++ b/NEConversationUIKit/NEConversationUIKit/Classes/ConversationConfig/ConversationUIConfig.swift @@ -12,8 +12,11 @@ public enum NEConversationAvatarType: Int { case cycle // 圆形 } +/// 会话模块自定义配置 @objcMembers public class ConversationUIConfig: NSObject { + public static let shared = ConversationUIConfig() + /// 是否展示界面顶部的标题栏 public var showTitleBar = true @@ -51,26 +54,26 @@ public class ConversationUIConfig: NSObject { /// 会话列表 cell 左划置顶按钮背景颜色 public var stickTopButtonBackgroundColor: UIColor? /// 会话列表 cell 左划置顶按钮点击事件 - public var stickTopButtonClick: ((NEConversationListModel?, IndexPath) -> Void)? + public var stickTopButtonClick: ((NEBaseConversationController, NEConversationListModel?, IndexPath) -> Void)? /// 会话列表 cell 左划删除按钮文案内容 public var deleteButtonTitle = localizable("delete") /// 会话列表 cell 左划删除按钮背景颜色 public var deleteButtonBackgroundColor: UIColor? /// 会话列表 cell 左划删除按钮点击事件 - public var deleteButtonClick: ((NEConversationListModel?, IndexPath) -> Void)? + public var deleteButtonClick: ((NEBaseConversationController, NEConversationListModel?, IndexPath) -> Void)? /// 标题栏左侧按钮点击事件 - public var titleBarLeftClick: (() -> Void)? + public var titleBarLeftClick: ((NEBaseConversationController) -> Void)? /// 标题栏最右侧按钮点击事件 - public var titleBarRightClick: (() -> Void)? + public var titleBarRightClick: ((NEBaseConversationController) -> Void)? /// 标题栏次最右侧按钮点击事件 - public var titleBarRight2Click: (() -> Void)? + public var titleBarRight2Click: ((NEBaseConversationController) -> Void)? /// 会话列表点击事件 - public var itemClick: ((NEConversationListModel?, IndexPath) -> Void)? + public var itemClick: ((NEBaseConversationController, NEConversationListModel?, IndexPath) -> Void)? /// 会话列表的视图控制器回调,回调中会返回会话列表的视图控制器 public var customController: ((NEBaseConversationController) -> Void)? diff --git a/NEConversationUIKit/NEConversationUIKit/Classes/ConversationConfig/NEKitConversationConfig.swift b/NEConversationUIKit/NEConversationUIKit/Classes/ConversationConfig/NEKitConversationConfig.swift deleted file mode 100644 index 2a009a7d..00000000 --- a/NEConversationUIKit/NEConversationUIKit/Classes/ConversationConfig/NEKitConversationConfig.swift +++ /dev/null @@ -1,14 +0,0 @@ - -// Copyright (c) 2022 NetEase, Inc. All rights reserved. -// Use of this source code is governed by a MIT license that can be -// found in the LICENSE file. - -import UIKit - -@objcMembers -public class NEKitConversationConfig: NSObject { - public static let shared = NEKitConversationConfig() - - // conversation ui 配置 - public var ui = ConversationUIConfig() -} diff --git a/NEConversationUIKit/NEConversationUIKit/Classes/FunUI/Cell/FunConversationListCell.swift b/NEConversationUIKit/NEConversationUIKit/Classes/FunUI/Cell/FunConversationListCell.swift index 2f9ebdfd..a2a8239a 100644 --- a/NEConversationUIKit/NEConversationUIKit/Classes/FunUI/Cell/FunConversationListCell.swift +++ b/NEConversationUIKit/NEConversationUIKit/Classes/FunUI/Cell/FunConversationListCell.swift @@ -30,7 +30,7 @@ open class FunConversationListCell: NEBaseConversationListCell { headImageView.heightAnchor.constraint(equalToConstant: 48), ]) - titleLabel.font = .systemFont(ofSize: NEKitConversationConfig.shared.ui.conversationProperties.itemTitleSize > 0 ? NEKitConversationConfig.shared.ui.conversationProperties.itemTitleSize : 17) + titleLabel.font = .systemFont(ofSize: ConversationUIConfig.shared.conversationProperties.itemTitleSize > 0 ? ConversationUIConfig.shared.conversationProperties.itemTitleSize : 17) NSLayoutConstraint.activate([ titleLabel.leftAnchor.constraint(equalTo: headImageView.rightAnchor, constant: 12), titleLabel.rightAnchor.constraint(equalTo: timeLabel.leftAnchor, constant: -5), @@ -54,10 +54,10 @@ open class FunConversationListCell: NEBaseConversationListCell { } override func initSubviewsLayout() { - if NEKitConversationConfig.shared.ui.conversationProperties.avatarType == .cycle { + if ConversationUIConfig.shared.conversationProperties.avatarType == .cycle { headImageView.layer.cornerRadius = 24.0 - } else if NEKitConversationConfig.shared.ui.conversationProperties.avatarCornerRadius > 0 { - headImageView.layer.cornerRadius = NEKitConversationConfig.shared.ui.conversationProperties.avatarCornerRadius + } else if ConversationUIConfig.shared.conversationProperties.avatarCornerRadius > 0 { + headImageView.layer.cornerRadius = ConversationUIConfig.shared.conversationProperties.avatarCornerRadius } else { headImageView.layer.cornerRadius = 4.0 } @@ -68,9 +68,9 @@ open class FunConversationListCell: NEBaseConversationListCell { contentModel = sessionModel if sessionModel?.conversation?.stickTop == true { - contentView.backgroundColor = NEKitConversationConfig.shared.ui.conversationProperties.itemStickTopBackground ?? .funConversationBackgroundColor + contentView.backgroundColor = ConversationUIConfig.shared.conversationProperties.itemStickTopBackground ?? .funConversationBackgroundColor } else { - contentView.backgroundColor = NEKitConversationConfig.shared.ui.conversationProperties.itemBackground ?? .white + contentView.backgroundColor = ConversationUIConfig.shared.conversationProperties.itemBackground ?? .white } } } diff --git a/NEConversationUIKit/NEConversationUIKit/Classes/FunUI/Cell/FunConversationSearchCell.swift b/NEConversationUIKit/NEConversationUIKit/Classes/FunUI/Cell/FunConversationSearchCell.swift index dcd3a5c4..cb1ea16d 100644 --- a/NEConversationUIKit/NEConversationUIKit/Classes/FunUI/Cell/FunConversationSearchCell.swift +++ b/NEConversationUIKit/NEConversationUIKit/Classes/FunUI/Cell/FunConversationSearchCell.swift @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT license that can be // found in the LICENSE file. +import NECommonKit import UIKit @objcMembers @@ -33,6 +34,6 @@ open class FunConversationSearchCell: NEBaseConversationSearchCell { } override func getRangeTextColor() -> UIColor { - UIColor.funConversationThemeColor + UIColor.ne_funTheme } } diff --git a/NEConversationUIKit/NEConversationUIKit/Classes/FunUI/Controller/FunConversationController.swift b/NEConversationUIKit/NEConversationUIKit/Classes/FunUI/Controller/FunConversationController.swift index 3488f113..ee02d154 100644 --- a/NEConversationUIKit/NEConversationUIKit/Classes/FunUI/Controller/FunConversationController.swift +++ b/NEConversationUIKit/NEConversationUIKit/Classes/FunUI/Controller/FunConversationController.swift @@ -43,7 +43,8 @@ open class FunConversationController: NEBaseConversationController { navigationView.titleBarBottomLine.isHidden = true } - deinit { + override open func didMove(toParent parent: UIViewController?) { + super.didMove(toParent: parent) if let searchViewGestures = searchView.gestureRecognizers { for gesture in searchViewGestures { searchView.removeGestureRecognizer(gesture) @@ -62,7 +63,7 @@ open class FunConversationController: NEBaseConversationController { navigationItem.rightBarButtonItems = [addBarItem] navigationView.searchBtn.isHidden = true - if !NEKitConversationConfig.shared.ui.showTitleBarRightIcon { + if !ConversationUIConfig.shared.showTitleBarRightIcon { navigationItem.rightBarButtonItems = [] navigationView.addBtn.isHidden = true } diff --git a/NEConversationUIKit/NEConversationUIKit/Classes/FunUI/FunConversationUIColor.swift b/NEConversationUIKit/NEConversationUIKit/Classes/FunUI/FunConversationUIColor.swift index ba7e9b40..c2428a12 100644 --- a/NEConversationUIKit/NEConversationUIKit/Classes/FunUI/FunConversationUIColor.swift +++ b/NEConversationUIKit/NEConversationUIKit/Classes/FunUI/FunConversationUIColor.swift @@ -7,7 +7,6 @@ import NECommonKit extension UIColor { static let funConversationPopViewBg = UIColor(hexString: "#4C4C4C") - static let funConversationThemeColor = UIColor.ne_funTheme static let funConversationBackgroundColor = UIColor(hexString: "#EDEDED") static let funConversationLineBorderColor = UIColor(hexString: "#E5E5E5") static let funConversationListLineBorderColor = UIColor(hexString: "#D8D8D8") diff --git a/NEConversationUIKit/NEConversationUIKit/Classes/NormalUI/Cell/ConversationListCell.swift b/NEConversationUIKit/NEConversationUIKit/Classes/NormalUI/Cell/ConversationListCell.swift index a633ddfb..dec4096d 100644 --- a/NEConversationUIKit/NEConversationUIKit/Classes/NormalUI/Cell/ConversationListCell.swift +++ b/NEConversationUIKit/NEConversationUIKit/Classes/NormalUI/Cell/ConversationListCell.swift @@ -36,10 +36,10 @@ open class ConversationListCell: NEBaseConversationListCell { } override func initSubviewsLayout() { - if NEKitConversationConfig.shared.ui.conversationProperties.avatarType == .cycle { + if ConversationUIConfig.shared.conversationProperties.avatarType == .cycle { headImageView.layer.cornerRadius = 21.0 - } else if NEKitConversationConfig.shared.ui.conversationProperties.avatarCornerRadius > 0 { - headImageView.layer.cornerRadius = NEKitConversationConfig.shared.ui.conversationProperties.avatarCornerRadius + } else if ConversationUIConfig.shared.conversationProperties.avatarCornerRadius > 0 { + headImageView.layer.cornerRadius = ConversationUIConfig.shared.conversationProperties.avatarCornerRadius } else { headImageView.layer.cornerRadius = 21.0 } @@ -48,9 +48,9 @@ open class ConversationListCell: NEBaseConversationListCell { override open func configureData(_ sessionModel: NEConversationListModel?) { super.configureData(sessionModel) if sessionModel?.conversation?.stickTop == true { - contentView.backgroundColor = NEKitConversationConfig.shared.ui.conversationProperties.itemStickTopBackground ?? UIColor(hexString: "0xF3F5F7") + contentView.backgroundColor = ConversationUIConfig.shared.conversationProperties.itemStickTopBackground ?? UIColor(hexString: "0xF3F5F7") } else { - contentView.backgroundColor = NEKitConversationConfig.shared.ui.conversationProperties.itemBackground ?? .white + contentView.backgroundColor = ConversationUIConfig.shared.conversationProperties.itemBackground ?? .white } } } diff --git a/NEConversationUIKit/NEConversationUIKit/Classes/NormalUI/Controller/ConversationController.swift b/NEConversationUIKit/NEConversationUIKit/Classes/NormalUI/Controller/ConversationController.swift index d3008e10..5583444e 100644 --- a/NEConversationUIKit/NEConversationUIKit/Classes/NormalUI/Controller/ConversationController.swift +++ b/NEConversationUIKit/NEConversationUIKit/Classes/NormalUI/Controller/ConversationController.swift @@ -62,12 +62,12 @@ open class ConversationController: NEBaseConversationController { spaceBarItem.width = NEConstant.screenInterval navigationItem.rightBarButtonItems = [addBarItem, spaceBarItem, searchBarItem] - if !NEKitConversationConfig.shared.ui.showTitleBarRight2Icon { + if !ConversationUIConfig.shared.showTitleBarRight2Icon { navigationView.searchBtn.isHidden = true navigationItem.rightBarButtonItems = [addBarItem] } - if !NEKitConversationConfig.shared.ui.showTitleBarRightIcon { + if !ConversationUIConfig.shared.showTitleBarRightIcon { navigationView.addBtn.isHidden = true navigationItem.rightBarButtonItems = [searchBarItem] } diff --git a/NEMapKit/NEMapKit.podspec b/NEMapKit/NEMapKit.podspec index b13eb79f..e7894e2b 100644 --- a/NEMapKit/NEMapKit.podspec +++ b/NEMapKit/NEMapKit.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'NEMapKit' - s.version = '10.3.0' + s.version = '10.4.0' s.summary = 'Netease XKit' # This description is used to generate tags and improve search results. @@ -36,5 +36,5 @@ TODO: Add long description of the pod here. s.dependency 'AMap3DMap' s.dependency 'AMapSearch' s.dependency 'AMapLocation' - s.dependency 'NEChatUIKit', '10.3.0' + s.dependency 'NEChatUIKit', '10.4.0' end diff --git a/NETeamUIKit/NETeamUIKit.podspec b/NETeamUIKit/NETeamUIKit.podspec index 4be2243e..d6ed6fb5 100644 --- a/NETeamUIKit/NETeamUIKit.podspec +++ b/NETeamUIKit/NETeamUIKit.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'NETeamUIKit' - s.version = '10.3.0' + s.version = '10.4.0' s.summary = 'Netease XKit' # This description is used to generate tags and improve search results. @@ -36,6 +36,6 @@ TODO: Add long description of the pod here. s.source_files = 'NETeamUIKit/Classes/**/*' s.resource = 'NETeamUIKit/Assets/**/*' - s.dependency 'NEChatUIKit', '10.3.0' + s.dependency 'NEChatUIKit', '10.4.0' end diff --git a/Podfile b/Podfile index ce7b5196..d8278c92 100644 --- a/Podfile +++ b/Podfile @@ -7,20 +7,20 @@ target 'app' do use_frameworks! # 基础库 - pod 'NIMSDK_LITE','10.3.1-beta' - pod 'NEChatKit', '10.3.1' +# pod 'NIMSDK_LITE','10.4.0-beta' + pod 'NEChatKit', '10.4.0' # UI 组件,依次为通讯录组件、会话列表组件、会话(聊天)组件、群相关设置组件 - pod 'NEChatUIKit', '10.3.1' - pod 'NEContactUIKit', '10.3.1' - pod 'NEConversationUIKit', '10.3.1' - pod 'NETeamUIKit', '10.3.1' + pod 'NEChatUIKit', '10.4.0' + pod 'NEContactUIKit', '10.4.0' + pod 'NEConversationUIKit', '10.4.0' + pod 'NETeamUIKit', '10.4.0' # 扩展库 - 地理位置组件 - pod 'NEMapKit', '10.3.1' + pod 'NEMapKit', '10.4.0' # 扩展库 - AI 划词搜索 - pod 'NEAISearchKit', '1.0.2' + pod 'NEAISearchKit', '1.0.3' # 扩展库 - 呼叫组件 pod 'NERtcCallKit/NOS_Special', '2.4.0' diff --git a/app.xcodeproj/project.pbxproj b/app.xcodeproj/project.pbxproj index c7fd716f..ea9b30df 100644 --- a/app.xcodeproj/project.pbxproj +++ b/app.xcodeproj/project.pbxproj @@ -651,7 +651,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 10.3.0; + MARKETING_VERSION = 10.4.0; PRODUCT_BUNDLE_IDENTIFIER = com.netease.yunxin.app.im; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -700,7 +700,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 10.3.0; + MARKETING_VERSION = 10.4.0; PRODUCT_BUNDLE_IDENTIFIER = com.netease.yunxin.app.im; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = inHouseYunxin; diff --git a/app/Custom/CustomConfig.swift b/app/Custom/CustomConfig.swift new file mode 100644 index 00000000..c933b58c --- /dev/null +++ b/app/Custom/CustomConfig.swift @@ -0,0 +1,372 @@ +//// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. + +import Foundation +import NEChatUIKit +import NEContactUIKit +import NEConversationUIKit + +/// 自定义配置项示例类 +public class CustomConfig { + public static let shared = CustomConfig() + + /// 通过配置项实现 UI 自定义,该方式不需要继承自 ChatViewController + public func configChatUIKit() { + ChatUIConfig.shared.messageProperties.avatarType = .cycle + ChatUIConfig.shared.messageProperties.avatarCornerRadius = 8.0 + ChatUIConfig.shared.messageProperties.signalBgColor = UIColor.yellow + ChatUIConfig.shared.messageProperties.selfMessageBg = UIColor.ne_greenText + ChatUIConfig.shared.messageProperties.receiveMessageBg = UIColor.ne_greenText + ChatUIConfig.shared.messageProperties.timeTextColor = UIColor.ne_darkText + ChatUIConfig.shared.messageProperties.timeTextSize = 18 + ChatUIConfig.shared.messageProperties.userNickColor = UIColor.ne_redText + ChatUIConfig.shared.messageProperties.userNickTextSize = 8.0 + ChatUIConfig.shared.messageProperties.messageTextColor = UIColor.ne_redColor + ChatUIConfig.shared.messageProperties.messageTextSize = 12 + ChatUIConfig.shared.messageProperties.rightBubbleBg = UIImage(named: "copy_right") + ChatUIConfig.shared.messageProperties.leftBubbleBg = UIImage(named: "copy_right") + ChatUIConfig.shared.messageProperties.showP2pMessageStatus = false + ChatUIConfig.shared.messageProperties.showTeamMessageStatus = false + // ChatUIConfig.shared.messageProperties.showTitleBar = false + // ChatUIConfig.shared.messageProperties.showTitleBarRightIcon = false + ChatUIConfig.shared.messageProperties.titleBarRightRes = UIImage(named: "copy_right") + ChatUIConfig.shared.messageProperties.titleBarRightClick = { viewController in + viewController.showToast("标题栏右侧图标的点击事件") + } + ChatUIConfig.shared.messageProperties.chatViewBackground = UIColor.ne_redText + + ChatUIConfig.shared.messageItemClick = { viewController, cell, model in + viewController.showToast("点击了消息: \(String(describing: model?.message?.text))") + } + + /// 文本输入框下方 tab 按钮定制 + ChatUIConfig.shared.chatInputBar = { [weak self] viewController, item in + // 修改 + let takePicBtn = item[2] + takePicBtn.setImage(nil, for: .normal) + takePicBtn.setTitle("拍照", for: .normal) + takePicBtn.setTitleColor(.blue, for: .normal) + takePicBtn.removeTarget(takePicBtn.superview, action: nil, for: .allEvents) + takePicBtn.addTarget(self, action: #selector(self?.customClick), for: .touchUpInside) + + // 新增 + let button = UIButton(type: .custom) + button.setTitle("新增", for: .normal) + button.setTitleColor(.blue, for: .normal) + button.addTarget(self, action: #selector(self?.customClick), for: .touchUpInside) + item.append(button) + } + + /// 【更多】区域功能列表自定义示例 + ChatUIConfig.shared.chatInputMenu = { viewController, menuList in + // 新增未知类型 + let itemNew = NEMoreItemModel() + itemNew.customImage = UIImage(named: "mine_collection") + itemNew.action = { viewController, item in + viewController.showToast("【更多】区域功能自定义点击事件") + } + itemNew.title = "新增" + menuList.append(itemNew) + + // 覆盖已有类型 + // 遍历 menuList, 根据type 覆盖已有类型 + for item in menuList { + if item.type == .rtc { + item.customImage = UIImage(named: "mine_setting") + itemNew.action = { viewController, item in + viewController.showToast("【更多】区域功能自定义点击事件") + } + item.type = .rtc + item.title = "覆盖" + } + } + + // 移除已有类型 + // 遍历 menuList, 根据type 移除已有类型 + for (i, item) in menuList.enumerated() { + if item.type == .file { + menuList.remove(at: i) + } + } + } + + /// 消息长按弹出菜单自定义 + ChatUIConfig.shared.chatPopMenu = { viewController, menuList, model in + // 遍历 menuList, 根据 type 覆盖已有类型 + // 将所有文本消息的【复制】替换成【粘贴】 + if model?.type == .text { + for item in menuList { + if item.type == .copy { + item.text = "粘贴" + } + } + } + } + + /// 消息长按弹出菜单点击事件回调,根据按钮类型进行区分 + ChatUIConfig.shared.popMenuClick = { viewController, item in + switch item.type { + case .copy: + // 更改【复制】类型按钮的点击事件 + viewController.showToast("自定义点击事件") + default: + break + } + } + + /// 消息列表的视图控制器回调,回调中会返回消息列表的视图控制器 + ChatUIConfig.shared.customController = { viewController in + // 更改导航栏背景色 + viewController.navigationView.backgroundColor = .gray + + // 顶部bodyTopView中添加自定义view(需要设置bodyTopView的高度) + self.customTopView.button.setTitle("通过配置项添加", for: .normal) + viewController.bodyTopView.backgroundColor = .purple + viewController.bodyTopView.addSubview(self.customTopView) + viewController.bodyTopViewHeight = 80 + + // 底部bodyBottomView中添加自定义view(需要设置bodyBottomView的高度) + self.customBottomView.button.setTitle("通过配置项添加", for: .normal) + viewController.bodyBottomView.backgroundColor = .purple + viewController.bodyBottomView.addSubview(self.customBottomView) + viewController.bodyBottomViewHeight = 60 + } + + /// 消息列表发送消息前的回调 + /// 回调参数:消息参数(包含消息和发送参数)和消息列表的视图控制器 + /// 返回值/回调值:(修改后的)消息参数,若消息参数为 nil,则表示拦截该消息不发送 + /// beforeSend 与 beforeSendCompletion 只能二设一,同时设置时优先使用 beforeSend + ChatKitClient.shared.beforeSend = { viewController, param in + param.message.text = (param.message.text ?? "") + "[拦截1]" + return param + } + + ChatKitClient.shared.beforeSendCompletion = { viewController, param, completion in + DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: DispatchWorkItem(block: { + param.message.text = (param.message.text ?? "") + "[拦截2]" + completion(param) + })) + } + } + + /// 通过配置项实现自定义,该方式不需要继承自 ContactViewController + public func configContactUIKit() { + /* + UI 属性自定义 + */ + + /// 头像圆角大小 + ContactUIConfig.shared.contactProperties.avatarCornerRadius = 4.0 + + /// 头像类型 + ContactUIConfig.shared.contactProperties.avatarType = .cycle + + // 标题栏文案 + ContactUIConfig.shared.title = "好友列表" + + /// 标题栏文案颜色 + ContactUIConfig.shared.titleColor = .purple + + // 通讯录好友标题大小 + ContactUIConfig.shared.contactProperties.itemTitleSize = 28 + + /// 通讯录好友标题颜色 + ContactUIConfig.shared.contactProperties.itemTitleColor = UIColor.red + + /// 是否展示标题栏 + ContactUIConfig.shared.showTitleBar = true + + /// 通讯录列表头部模块 cell 点击事件 + ContactUIConfig.shared.headerItemClick = { viewController, info, indexPath in + viewController.showToast("点击了头部模块中的第 \(indexPath.row) 个") + } + + /// 通讯录列表好友 cell 点击事件 + ContactUIConfig.shared.friendItemClick = { viewController, info, indexPath in + viewController.showToast("点击了好友列表中的: \(info.user?.showName() ?? "")") + } + + /// 是否展示标题栏的次最右侧图标 + ContactUIConfig.shared.showTitleBarRight2Icon = true + + /// 是否展示标题栏的最右侧图标 + ContactUIConfig.shared.showTitleBarRightIcon = true + + /// 标题栏的最右侧图标 + ContactUIConfig.shared.titleBarRightRes = UIImage(named: "person") + + /// 标题栏的次最右侧图标 + ContactUIConfig.shared.titleBarRight2Res = UIImage(named: "contact") + + /// 标题栏最右侧按钮点击事件,如果已经通过继承方式重写该点击事件, 则本方式会被覆盖 + ContactUIConfig.shared.titleBarRightClick = { viewController in + print("addItemAction") + } + + /// 标题栏次最右侧按钮点击事件,如果已经通过继承方式重写该点击事件, 则本方式会被覆盖 + ContactUIConfig.shared.titleBarRight2Click = { viewController in + print("searchItemAction") + } + + /// 通讯录间隔线颜色 + ContactUIConfig.shared.contactProperties.divideLineColor = UIColor.blue + + /// 检索标题字体颜色 + ContactUIConfig.shared.contactProperties.indexTitleColor = .green + + /* + 布局自定义 + */ + /// 自定义界面UI接口,回调中会传入会话列表界面的UI布局,您可以进行UI元素调整。 + ContactUIConfig.shared.customController = { viewController in + // 更改导航栏背景色 + viewController.navigationView.backgroundColor = .gray + + // 顶部bodyTopView中添加自定义view(需要设置bodyTopView的高度) + self.customTopView.button.setTitle("通过配置项添加", for: .normal) + viewController.bodyTopView.backgroundColor = .purple + viewController.bodyTopView.addSubview(self.customTopView) + viewController.bodyTopViewHeight = 80 + + // 底部bodyBottomView中添加自定义view(需要设置bodyBottomView的高度) + self.customBottomView.button.setTitle("通过配置项添加", for: .normal) + viewController.bodyBottomView.backgroundColor = .purple + viewController.bodyBottomView.addSubview(self.customBottomView) + viewController.bodyBottomViewHeight = 60 + } + } + + /// 通过配置项实现自定义,该方式不需要继承自 ConversationController + open func configConversationUIKit() { + /* + UI 属性自定义 + */ + + /// 头像圆角大小 + ConversationUIConfig.shared.conversationProperties.avatarCornerRadius = 4.0 + + /// 头像类型 + ConversationUIConfig.shared.conversationProperties.avatarType = .cycle + + /// 是否展示界面顶部的标题栏 + ConversationUIConfig.shared.showTitleBar = true + + /// 是否展示标题栏次最右侧图标 + ConversationUIConfig.shared.showTitleBarRight2Icon = true + + /// 是否展示标题栏最右侧图标 + ConversationUIConfig.shared.showTitleBarRightIcon = true + + // 自定义会话列表标题、图标 + ConversationUIConfig.shared.titleBarTitle = "消息" + ConversationUIConfig.shared.titleBarTitleColor = .purple + ConversationUIConfig.shared.titleBarLeftRes = UIImage() + + // 未被置顶的会话项的背景色 + ConversationUIConfig.shared.conversationProperties.itemBackground = .gray + + // 置顶的会话项的背景色 + ConversationUIConfig.shared.conversationProperties.itemStickTopBackground = .orange + + // 主标题字体大小 + ConversationUIConfig.shared.conversationProperties.itemTitleSize = 24 + + // 主标题字体大小 + ConversationUIConfig.shared.conversationProperties.itemTitleSize = 24 + + // 副标题字体大小 + ConversationUIConfig.shared.conversationProperties.itemContentSize = 18 + + // 主标题字体颜色 + ConversationUIConfig.shared.conversationProperties.itemTitleColor = UIColor.red + + // 副标题字体颜色 + ConversationUIConfig.shared.conversationProperties.itemContentColor = UIColor.blue + + /// 时间字体颜色 + ConversationUIConfig.shared.conversationProperties.itemDateColor = UIColor.green + + /// 时间字体大小 + ConversationUIConfig.shared.conversationProperties.itemDateSize = 14 + + /// 会话列表 cell 左划置顶按钮文案内容 + ConversationUIConfig.shared.stickTopButtonTitle = "左侧" + /// 会话列表 cell 左划取消置顶按钮文案内容(会话置顶后生效) + ConversationUIConfig.shared.stickTopButtonCancelTitle = "左侧1" + /// 会话列表 cell 左划置顶按钮背景颜色 + ConversationUIConfig.shared.stickTopButtonBackgroundColor = UIColor.brown + /// 会话列表 cell 左划置顶按钮点击事件 + ConversationUIConfig.shared.stickTopButtonClick = { viewController, model, indexPath in + viewController.showToast("会话列表 cell 左划置顶按钮点击事件") + } + + /// 会话列表 cell 左划删除按钮文案内容 + ConversationUIConfig.shared.deleteButtonTitle = "右侧" + /// 会话列表 cell 左划删除按钮背景颜色 + ConversationUIConfig.shared.deleteButtonBackgroundColor = UIColor.purple + /// 会话列表 cell 左划删除按钮点击事件 + ConversationUIConfig.shared.deleteButtonClick = { viewController, model, indexPath in + viewController.showToast("会话列表 cell 左划删除按钮点击事件") + } + + /// 标题栏左侧按钮点击事件 + ConversationUIConfig.shared.titleBarLeftClick = { viewController in + viewController.showSingleAlert(message: "titleBarLeftClick") {} + } + + /// 标题栏最右侧按钮点击事件,如果已经通过继承方式重写该点击事件, 则本方式会被覆盖 + ConversationUIConfig.shared.titleBarRightClick = { viewController in + viewController.showToast("didClickAddBtn") + } + + /// 标题栏次最右侧按钮点击事件,如果已经通过继承方式重写该点击事件, 则本方式会被覆盖 + ConversationUIConfig.shared.titleBarRight2Click = { viewController in + viewController.showToast("didClickSearchBtn") + } + + /// 会话列表点击事件 + ConversationUIConfig.shared.itemClick = { viewController, model, indexPath in + viewController.showToast(model?.conversation?.name ?? "会话列表点击事件") + } + + /* + 布局自定义 + */ + /// 自定义界面UI接口,回调中会传入会话列表界面的UI布局,您可以进行UI元素调整。 + ConversationUIConfig.shared.customController = { viewController in + // 更改导航栏背景色 + viewController.navigationView.backgroundColor = .gray + + // 顶部bodyTopView中添加自定义view(需要设置bodyTopView的高度) + self.customTopView.button.setTitle("通过配置项添加", for: .normal) + viewController.bodyTopView.backgroundColor = .purple + viewController.bodyTopView.addSubview(self.customTopView) + viewController.bodyTopViewHeight = 80 + + // 底部bodyBottomView中添加自定义view(需要设置bodyBottomView的高度) + self.customBottomView.button.setTitle("通过配置项添加", for: .normal) + viewController.bodyBottomView.backgroundColor = .purple + viewController.bodyBottomView.addSubview(self.customBottomView) + viewController.bodyBottomViewHeight = 60 + } + } + + @objc func customClick(_ button: UIButton) { + button.viewContainingController()?.showToast("文本输入框下方 tab 按钮自定义点击事件") + } + + // MARK: lazy load + + public lazy var customTopView: CustomView = { + let view = CustomView(frame: CGRect(x: 0, y: 10, width: NEConstant.screenWidth, height: 40)) + view.backgroundColor = .blue + return view + }() + + public lazy var customBottomView: CustomView = { + let view = CustomView(frame: CGRect(x: 0, y: 10, width: NEConstant.screenWidth, height: 40)) + view.backgroundColor = .green + return view + }() +} diff --git a/app/Custom/CustomContactViewController.swift b/app/Custom/CustomContactViewController.swift index 7594059b..fc41cd9b 100644 --- a/app/Custom/CustomContactViewController.swift +++ b/app/Custom/CustomContactViewController.swift @@ -8,10 +8,10 @@ import NEContactUIKit public class CustomContactViewController: ContactViewController, NEBaseContactViewControllerDelegate { override public init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { /// 是否在通讯录界面显示头部模块 - NEKitContactConfig.shared.ui.showHeader = false + ContactUIConfig.shared.showHeader = false /// 通讯录列表头部模块的数据回调 - NEKitContactConfig.shared.ui.headerData = { headerData in + ContactUIConfig.shared.headerData = { viewController, headerData in headerData[0].name = "收到的验证消息" } @@ -25,102 +25,12 @@ public class CustomContactViewController: ContactViewController, NEBaseContactVi } override public func viewDidLoad() { - // 通过配置项实现自定义,该方式不需要继承自 ChatViewController - customByConfig() - // 通过重写实现自定义,该方式需要继承自 ChatViewController // customByOverread() super.viewDidLoad() } - /// 通过配置项实现自定义,该方式不需要继承自 ChatViewController - func customByConfig() { - /* - UI 属性自定义 - */ - - /// 头像圆角大小 - NEKitContactConfig.shared.ui.contactProperties.avatarCornerRadius = 4.0 - - /// 头像类型 - NEKitContactConfig.shared.ui.contactProperties.avatarType = .rectangle - - // 标题栏文案 - NEKitContactConfig.shared.ui.title = "好友列表" - - /// 标题栏文案颜色 - NEKitContactConfig.shared.ui.titleColor = .purple - - // 通讯录好友标题大小 - NEKitContactConfig.shared.ui.contactProperties.itemTitleSize = 28 - - /// 通讯录好友标题颜色 - NEKitContactConfig.shared.ui.contactProperties.itemTitleColor = UIColor.red - - /// 是否展示标题栏 - NEKitContactConfig.shared.ui.showTitleBar = true - - /// 通讯录列表头部模块 cell 点击事件 - NEKitContactConfig.shared.ui.headerItemClick = { info, indexPath in - self.showToast("点击了头部模块中的第 \(indexPath.row) 个") - } - - /// 通讯录列表好友 cell 点击事件 - NEKitContactConfig.shared.ui.friendItemClick = { info, indexPath in - self.showToast("点击了好友列表中的: \(info.user?.showName() ?? "")") - } - - /// 是否展示标题栏的次最右侧图标 - NEKitContactConfig.shared.ui.showTitleBarRight2Icon = true - - /// 是否展示标题栏的最右侧图标 - NEKitContactConfig.shared.ui.showTitleBarRightIcon = true - - /// 标题栏的最右侧图标 - NEKitContactConfig.shared.ui.titleBarRightRes = UIImage(named: "person") - - /// 标题栏的次最右侧图标 - NEKitContactConfig.shared.ui.titleBarRight2Res = UIImage(named: "contact") - - /// 标题栏最右侧按钮点击事件,如果已经通过继承方式重写该点击事件, 则本方式会被覆盖 - NEKitContactConfig.shared.ui.titleBarRightClick = { - print("addItemAction") - } - - /// 标题栏次最右侧按钮点击事件,如果已经通过继承方式重写该点击事件, 则本方式会被覆盖 - NEKitContactConfig.shared.ui.titleBarRight2Click = { - print("searchItemAction") - } - - /// 通讯录间隔线颜色 - NEKitContactConfig.shared.ui.contactProperties.divideLineColor = UIColor.blue - - /// 检索标题字体颜色 - NEKitContactConfig.shared.ui.contactProperties.indexTitleColor = .green - - /* - 布局自定义 - */ - /// 自定义界面UI接口,回调中会传入会话列表界面的UI布局,您可以进行UI元素调整。 - NEKitContactConfig.shared.ui.customController = { viewController in - // 更改导航栏背景色 - viewController.navigationView.backgroundColor = .gray - - // 顶部bodyTopView中添加自定义view(需要设置bodyTopView的高度) - self.customTopView.button.setTitle("通过配置项添加", for: .normal) - viewController.bodyTopView.backgroundColor = .purple - viewController.bodyTopView.addSubview(self.customTopView) - viewController.bodyTopViewHeight = 80 - - // 底部bodyBottomView中添加自定义view(需要设置bodyBottomView的高度) - self.customBottomView.button.setTitle("通过配置项添加", for: .normal) - viewController.bodyBottomView.backgroundColor = .purple - viewController.bodyBottomView.addSubview(self.customBottomView) - viewController.bodyBottomViewHeight = 60 - } - } - /// 通过重写实现自定义布局(这种方式需要继承,从而拿到父类属性) func customByOverread() { // 顶部bodyTopView中添加自定义view(需要设置bodyTopView的高度) diff --git a/app/Custom/CustomConversationController.swift b/app/Custom/CustomConversationController.swift index 21e380dd..912ee674 100644 --- a/app/Custom/CustomConversationController.swift +++ b/app/Custom/CustomConversationController.swift @@ -19,130 +19,12 @@ open class CustomConversationController: ConversationController, NEBaseConversat } override public func viewDidLoad() { - // 通过配置项实现自定义,该方式不需要继承自 ChatViewController - customByConfig() - // 通过重写实现自定义,该方式需要继承自 ChatViewController // customByOverread() super.viewDidLoad() } - /// 通过配置项实现自定义(这种方式不需要继承就可以实现 UI 自定义) - open func customByConfig() { - /* - UI 属性自定义 - */ - - /// 头像圆角大小 - NEKitConversationConfig.shared.ui.conversationProperties.avatarCornerRadius = 4.0 - - /// 头像类型 - NEKitConversationConfig.shared.ui.conversationProperties.avatarType = .rectangle - - /// 是否展示界面顶部的标题栏 - NEKitConversationConfig.shared.ui.showTitleBar = true - - /// 是否展示标题栏次最右侧图标 - NEKitConversationConfig.shared.ui.showTitleBarRight2Icon = true - - /// 是否展示标题栏最右侧图标 - NEKitConversationConfig.shared.ui.showTitleBarRightIcon = true - - // 自定义会话列表标题、图标 - NEKitConversationConfig.shared.ui.titleBarTitle = "消息" - NEKitConversationConfig.shared.ui.titleBarTitleColor = .purple - NEKitConversationConfig.shared.ui.titleBarLeftRes = UIImage() - - // 未被置顶的会话项的背景色 - NEKitConversationConfig.shared.ui.conversationProperties.itemBackground = .gray - - // 置顶的会话项的背景色 - NEKitConversationConfig.shared.ui.conversationProperties.itemStickTopBackground = .orange - - // 主标题字体大小 - NEKitConversationConfig.shared.ui.conversationProperties.itemTitleSize = 24 - - // 主标题字体大小 - NEKitConversationConfig.shared.ui.conversationProperties.itemTitleSize = 24 - - // 副标题字体大小 - NEKitConversationConfig.shared.ui.conversationProperties.itemContentSize = 18 - - // 主标题字体颜色 - NEKitConversationConfig.shared.ui.conversationProperties.itemTitleColor = UIColor.red - - // 副标题字体颜色 - NEKitConversationConfig.shared.ui.conversationProperties.itemContentColor = UIColor.blue - - /// 时间字体颜色 - NEKitConversationConfig.shared.ui.conversationProperties.itemDateColor = UIColor.green - - /// 时间字体大小 - NEKitConversationConfig.shared.ui.conversationProperties.itemDateSize = 14 - - /// 会话列表 cell 左划置顶按钮文案内容 - NEKitConversationConfig.shared.ui.stickTopButtonTitle = "左侧" - /// 会话列表 cell 左划取消置顶按钮文案内容(会话置顶后生效) - NEKitConversationConfig.shared.ui.stickTopButtonCancelTitle = "左侧1" - /// 会话列表 cell 左划置顶按钮背景颜色 - NEKitConversationConfig.shared.ui.stickTopButtonBackgroundColor = UIColor.brown - /// 会话列表 cell 左划置顶按钮点击事件 - NEKitConversationConfig.shared.ui.stickTopButtonClick = { model, indexPath in - self.showToast("会话列表 cell 左划置顶按钮点击事件") - } - - /// 会话列表 cell 左划删除按钮文案内容 - NEKitConversationConfig.shared.ui.deleteButtonTitle = "右侧" - /// 会话列表 cell 左划删除按钮背景颜色 - NEKitConversationConfig.shared.ui.deleteButtonBackgroundColor = UIColor.purple - /// 会话列表 cell 左划删除按钮点击事件 - NEKitConversationConfig.shared.ui.deleteButtonClick = { model, indexPath in - self.showToast("会话列表 cell 左划删除按钮点击事件") - } - - /// 标题栏左侧按钮点击事件 - NEKitConversationConfig.shared.ui.titleBarLeftClick = { - self.showSingleAlert(message: "titleBarLeftClick") {} - } - - /// 标题栏最右侧按钮点击事件,如果已经通过继承方式重写该点击事件, 则本方式会被覆盖 - NEKitConversationConfig.shared.ui.titleBarRightClick = { - self.showToast("didClickAddBtn") - } - - /// 标题栏次最右侧按钮点击事件,如果已经通过继承方式重写该点击事件, 则本方式会被覆盖 - NEKitConversationConfig.shared.ui.titleBarRight2Click = { - self.showToast("didClickSearchBtn") - } - - /// 会话列表点击事件 - NEKitConversationConfig.shared.ui.itemClick = { model, indexPath in - self.showToast(model?.conversation?.name ?? "会话列表点击事件") - } - - /* - 布局自定义 - */ - /// 自定义界面UI接口,回调中会传入会话列表界面的UI布局,您可以进行UI元素调整。 - NEKitConversationConfig.shared.ui.customController = { viewController in - // 更改导航栏背景色 - viewController.navigationView.backgroundColor = .gray - - // 顶部bodyTopView中添加自定义view(需要设置bodyTopView的高度) - self.customTopView.button.setTitle("通过配置项添加", for: .normal) - viewController.bodyTopView.backgroundColor = .purple - viewController.bodyTopView.addSubview(self.customTopView) - viewController.bodyTopViewHeight = 80 - - // 底部bodyBottomView中添加自定义view(需要设置bodyBottomView的高度) - self.customBottomView.button.setTitle("通过配置项添加", for: .normal) - viewController.bodyBottomView.backgroundColor = .purple - viewController.bodyBottomView.addSubview(self.customBottomView) - viewController.bodyBottomViewHeight = 60 - } - } - /// 通过重写实现自定义布局(这种方式需要继承,拿到父类属性) open func customByOverread() { // 实现协议(重写tabbar点击事件) diff --git a/app/Custom/CustomP2PChatViewController.swift b/app/Custom/CustomP2PChatViewController.swift index 76a34103..32b81a52 100644 --- a/app/Custom/CustomP2PChatViewController.swift +++ b/app/Custom/CustomP2PChatViewController.swift @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT license that can be // found in the LICENSE file. +import NEChatKit import NEChatUIKit import NIMSDK import UIKit @@ -12,11 +13,8 @@ class CustomP2PChatViewController: P2PChatViewController { // 自定义消息cell绑定需要放在 super.viewDidLoad() 之前 NEChatUIKitClient.instance.regsiterCustomCell(["\(customMessageType)": CustomChatCell.self]) - // 通过配置项实现自定义,该方式不需要继承自 ChatViewController - customByConfig() - // 通过重写实现自定义,该方式需要继承自 ChatViewController -// customByOverread() + customByOverread() super.viewDidLoad() @@ -24,138 +22,6 @@ class CustomP2PChatViewController: P2PChatViewController { customMessage() } - /// 通过配置项实现 UI 自定义,该方式不需要继承自 ChatViewController - func customByConfig() { - NEKitChatConfig.shared.ui.messageProperties.avatarType = .rectangle - NEKitChatConfig.shared.ui.messageProperties.avatarCornerRadius = 8.0 - NEKitChatConfig.shared.ui.messageProperties.signalBgColor = UIColor.ne_backcolor - NEKitChatConfig.shared.ui.messageProperties.selfMessageBg = UIColor.ne_greenText - NEKitChatConfig.shared.ui.messageProperties.receiveMessageBg = UIColor.ne_greenText - NEKitChatConfig.shared.ui.messageProperties.timeTextColor = UIColor.ne_redText - NEKitChatConfig.shared.ui.messageProperties.timeTextSize = 18 - NEKitChatConfig.shared.ui.messageProperties.userNickColor = UIColor.ne_redText - NEKitChatConfig.shared.ui.messageProperties.userNickTextSize = 8.0 - NEKitChatConfig.shared.ui.messageProperties.messageTextColor = UIColor.ne_redColor - NEKitChatConfig.shared.ui.messageProperties.messageTextSize = 12 - NEKitChatConfig.shared.ui.messageProperties.rightBubbleBg = UIImage(named: "copy_right") - NEKitChatConfig.shared.ui.messageProperties.leftBubbleBg = UIImage(named: "copy_right") - NEKitChatConfig.shared.ui.messageProperties.showP2pMessageStatus = false - NEKitChatConfig.shared.ui.messageProperties.showTeamMessageStatus = false -// NEKitChatConfig.shared.ui.messageProperties.showTitleBar = false -// NEKitChatConfig.shared.ui.messageProperties.showTitleBarRightIcon = false - NEKitChatConfig.shared.ui.messageProperties.titleBarRightRes = UIImage(named: "copy_right") - NEKitChatConfig.shared.ui.messageProperties.titleBarRightClick = { [weak self] in - self?.showToast("标题栏右侧图标的点击事件") - } - NEKitChatConfig.shared.ui.messageProperties.chatViewBackground = UIColor.ne_redText - - NEKitChatConfig.shared.ui.messageItemClick = { [weak self] cell, model in - self?.showToast("点击了消息: \(String(describing: model?.message?.text))") - } - - /// 文本输入框下方 tab 按钮定制 - NEKitChatConfig.shared.ui.chatInputBar = { [weak self] item in - // 修改 - let takePicBtn = item[2] - takePicBtn.setImage(nil, for: .normal) - takePicBtn.setTitle("拍照", for: .normal) - takePicBtn.setTitleColor(.blue, for: .normal) - takePicBtn.removeTarget(takePicBtn.superview, action: nil, for: .allEvents) - takePicBtn.addTarget(self, action: #selector(self?.customClick), for: .touchUpInside) - - // 新增 - let button = UIButton(type: .custom) - button.setTitle("新增", for: .normal) - button.setTitleColor(.blue, for: .normal) - button.addTarget(self, action: #selector(self?.customClick), for: .touchUpInside) - item.append(button) - } - - /// 【更多】区域功能列表自定义示例 - NEKitChatConfig.shared.ui.chatInputMenu = { [weak self] menuList in - // 新增未知类型 - let itemNew = NEMoreItemModel() - itemNew.customImage = UIImage(named: "mine_collection") - itemNew.customDelegate = self - itemNew.action = #selector(self?.customClick) - itemNew.title = "新增" - menuList.append(itemNew) - - // 覆盖已有类型 - // 遍历 menuList, 根据type 覆盖已有类型 - for item in menuList { - if item.type == .rtc { - item.customImage = UIImage(named: "mine_setting") - item.customDelegate = self - item.action = #selector(self?.customClick) - item.type = .rtc - item.title = "覆盖" - } - } - - // 移除已有类型 - // 遍历 menuList, 根据type 移除已有类型 - for (i, item) in menuList.enumerated() { - if item.type == .file { - menuList.remove(at: i) - } - } - } - - /// 消息长按弹出菜单自定义 - NEKitChatConfig.shared.ui.chatPopMenu = { menuList, model in - // 遍历 menuList, 根据 type 覆盖已有类型 - // 将所有文本消息的【复制】替换成【粘贴】 - if model?.type == .text { - for item in menuList { - if item.type == .copy { - item.text = "粘贴" - } - } - } - } - - /// 消息长按弹出菜单点击事件回调,根据按钮类型进行区分 - NEKitChatConfig.shared.ui.popMenuClick = { [weak self] item in - switch item.type { - case .copy: - // 更改【复制】类型按钮的点击事件 - self?.customClick() - default: - break - } - } - - /// 消息列表的视图控制器回调,回调中会返回消息列表的视图控制器 - NEKitChatConfig.shared.ui.customController = { viewController in - // 更改导航栏背景色 - viewController.navigationView.backgroundColor = .gray - - // 顶部bodyTopView中添加自定义view(需要设置bodyTopView的高度) - self.customTopView.button.setTitle("通过配置项添加", for: .normal) - viewController.bodyTopView.backgroundColor = .purple - viewController.bodyTopView.addSubview(self.customTopView) - viewController.bodyTopViewHeight = 80 - - // 底部bodyBottomView中添加自定义view(需要设置bodyBottomView的高度) - self.customBottomView.button.setTitle("通过配置项添加", for: .normal) - viewController.bodyBottomView.backgroundColor = .purple - viewController.bodyBottomView.addSubview(self.customBottomView) - viewController.bodyBottomViewHeight = 60 - } - - /// 消息列表发送消息时的视图控制器回调 - /// 回调参数:消息体和消息列表的视图控制器 - /// 返回值:是否继续发送消息 - NEKitChatConfig.shared.ui.onSendMessage = { message, ViewController in - if let text = message.text, text.starts(with: "哈") { - ViewController.showToast(text) - return false - } - return true - } - } - /// 通过重写实现自定义布局(这种方式需要继承,从而拿到父类属性) func customByOverread() { // 聊天页顶部导航栏下方扩展视图示例 @@ -185,8 +51,9 @@ class CustomP2PChatViewController: P2PChatViewController { // 新增未知类型 let itemNew = NEMoreItemModel() itemNew.customImage = UIImage(named: "mine_collection") - itemNew.customDelegate = self - itemNew.action = #selector(customClick) + itemNew.action = { viewController, item in + viewController.showToast("【更多】区域功能自定义点击事件") + } itemNew.title = "新增" NEChatUIKitClient.instance.moreAction.append(itemNew) @@ -196,8 +63,9 @@ class CustomP2PChatViewController: P2PChatViewController { if item.type == .rtc { let itemReplace = NEChatUIKitClient.instance.moreAction[i] itemReplace.customImage = UIImage(named: "mine_setting") - itemReplace.customDelegate = self - itemReplace.action = #selector(customClick) + itemReplace.action = { viewController, item in + viewController.showToast("【更多】区域功能自定义点击事件") + } itemReplace.type = .rtc itemReplace.title = "覆盖" } @@ -245,10 +113,6 @@ class CustomP2PChatViewController: P2PChatViewController { } } - @objc func customClick() { - showToast("自定义点击事件") - } - func customBottomBar() { let subviews = chatInputView.stackView.subviews for view in subviews { diff --git a/app/Mine/View/BirthdayDatePickerView.swift b/app/Mine/View/BirthdayDatePickerView.swift index c6a1bd16..17ccba52 100644 --- a/app/Mine/View/BirthdayDatePickerView.swift +++ b/app/Mine/View/BirthdayDatePickerView.swift @@ -15,7 +15,7 @@ public class BirthdayDatePickerView: UIView { let button = UIButton() button.translatesAutoresizingMaskIntoConstraints = false button.setTitle(NSLocalizedString("cancel", comment: ""), for: .normal) - button.setTitleColor(UIColor.ne_blueText, for: .normal) + button.setTitleColor(UIColor.ne_normalTheme, for: .normal) button.titleLabel?.font = UIFont.systemFont(ofSize: 14) button.addTarget(self, action: #selector(removeFromSuperview), for: .touchUpInside) return button @@ -25,7 +25,7 @@ public class BirthdayDatePickerView: UIView { let button = UIButton(type: .custom) button.translatesAutoresizingMaskIntoConstraints = false button.setTitle(commonLocalizable("ok"), for: .normal) - button.setTitleColor(UIColor.ne_blueText, for: .normal) + button.setTitleColor(UIColor.ne_normalTheme, for: .normal) button.titleLabel?.font = UIFont.systemFont(ofSize: 14) button.addTarget(self, action: #selector(sureBtnClick), for: .touchUpInside) return button