From 862e923b520ce8fd3f9d21a90ecd2a86cac91f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E7=BB=A7=E8=B6=85?= <984065974@qq.com> Date: Mon, 13 May 2024 17:27:39 +0800 Subject: [PATCH 01/12] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index bd94036d..a23cc9a1 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ - [开发环境](#开发环境) - [安装](#安装) - [结构](#结构) +- [运行示例项](#运行示例项目) - [快速开始](#快速开始) - [注意事项](#注意事项) - [进阶用法](#进阶用法) @@ -107,6 +108,11 @@ Classes ├─ Theme // 主题相关组件,包括颜色、字体、换肤协议及其组件。 └─ Extension // 一些方便的系统类扩展。 ``` +# 运行示例项目 + +- 注册环信AppKey,详见 https://docs-im-beta.easemob.com/product/enable_and_configure_IM.html#%E8%8E%B7%E5%8F%96%E7%8E%AF%E4%BF%A1%E5%8D%B3%E6%97%B6%E9%80%9A%E8%AE%AF-im-%E7%9A%84%E4%BF%A1%E6%81%AF +- 在Appdelegate.swift 中找到 let option = ChatOptions(appkey: <#环信AppKey#>),将注册的AppKey填入其中。 +- 如果想要自定义的头像昵称显示信息,在LoginViewController.swift中找到loginAction方法后填入您要显示的当前用户id对应的昵称头像`profile.nickname` `profile.avatarURL`信息即可,然后运行项目即可 # 快速开始 From 8183f4851c850d66ada75592d9392fae20c51d66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E7=BB=A7=E8=B6=85?= <984065974@qq.com> Date: Mon, 13 May 2024 17:28:12 +0800 Subject: [PATCH 02/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a23cc9a1..77a95920 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ - [开发环境](#开发环境) - [安装](#安装) - [结构](#结构) -- [运行示例项](#运行示例项目) +- [运行示例项目](#运行示例项目) - [快速开始](#快速开始) - [注意事项](#注意事项) - [进阶用法](#进阶用法) From 526d1f0a46e44742ae5b63703ca9c4cf998c7df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E7=BB=A7=E8=B6=85?= <984065974@qq.com> Date: Mon, 13 May 2024 17:34:53 +0800 Subject: [PATCH 03/12] Update README.md --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 77a95920..eb7d0237 100644 --- a/README.md +++ b/README.md @@ -111,8 +111,14 @@ Classes # 运行示例项目 - 注册环信AppKey,详见 https://docs-im-beta.easemob.com/product/enable_and_configure_IM.html#%E8%8E%B7%E5%8F%96%E7%8E%AF%E4%BF%A1%E5%8D%B3%E6%97%B6%E9%80%9A%E8%AE%AF-im-%E7%9A%84%E4%BF%A1%E6%81%AF -- 在Appdelegate.swift 中找到 let option = ChatOptions(appkey: <#环信AppKey#>),将注册的AppKey填入其中。 -- 如果想要自定义的头像昵称显示信息,在LoginViewController.swift中找到loginAction方法后填入您要显示的当前用户id对应的昵称头像`profile.nickname` `profile.avatarURL`信息即可,然后运行项目即可 +- 在Appdelegate.swift 中找到 +```Swift +let option = ChatOptions(appkey: <#环信AppKey#>) +``` +将注册的AppKey填入其中。 +- 如果想要自定义的头像昵称显示信息,在LoginViewController.swift中找到loginAction方法后填入您要显示的当前用户id对应的昵称头像`profile.nickname` `profile.avatarURL`信息即可,然后运行项目即可,出现登录界面后需要您去创建用户以及获取用户token // 。 您也可以使用控制台生成的临时Token登录。 +// 在控制台生成用户和临时用户 token,请参见 +// https://docs-im-beta.easemob.com/product/enable_and_configure_IM.html#%E5%88%9B%E5%BB%BA-im-%E7%94%A8%E6%88%B7。 # 快速开始 From cce4874830584f1ff2047f798c3151f9e660c8da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E7=BB=A7=E8=B6=85?= <984065974@qq.com> Date: Mon, 13 May 2024 17:36:45 +0800 Subject: [PATCH 04/12] Update README.md --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index eb7d0237..ba159fb8 100644 --- a/README.md +++ b/README.md @@ -110,15 +110,14 @@ Classes ``` # 运行示例项目 -- 注册环信AppKey,详见 https://docs-im-beta.easemob.com/product/enable_and_configure_IM.html#%E8%8E%B7%E5%8F%96%E7%8E%AF%E4%BF%A1%E5%8D%B3%E6%97%B6%E9%80%9A%E8%AE%AF-im-%E7%9A%84%E4%BF%A1%E6%81%AF +- [注册环信AppKey](https://docs-im-beta.easemob.com/product/enable_and_configure_IM.html#%E8%8E%B7%E5%8F%96%E7%8E%AF%E4%BF%A1%E5%8D%B3%E6%97%B6%E9%80%9A%E8%AE%AF-im-%E7%9A%84%E4%BF%A1%E6%81%AF) - 在Appdelegate.swift 中找到 ```Swift let option = ChatOptions(appkey: <#环信AppKey#>) ``` 将注册的AppKey填入其中。 -- 如果想要自定义的头像昵称显示信息,在LoginViewController.swift中找到loginAction方法后填入您要显示的当前用户id对应的昵称头像`profile.nickname` `profile.avatarURL`信息即可,然后运行项目即可,出现登录界面后需要您去创建用户以及获取用户token // 。 您也可以使用控制台生成的临时Token登录。 -// 在控制台生成用户和临时用户 token,请参见 -// https://docs-im-beta.easemob.com/product/enable_and_configure_IM.html#%E5%88%9B%E5%BB%BA-im-%E7%94%A8%E6%88%B7。 +- 如果想要自定义的头像昵称显示信息,在LoginViewController.swift中找到loginAction方法后填入您要显示的当前用户id对应的昵称头像`profile.nickname` `profile.avatarURL`信息即可,然后运行项目即可,出现登录界面后需要您去创建用户以及获取用户token // 。 [使用控制台生成的临时Token登录](https://docs-im-beta.easemob.com/product/enable_and_configure_IM.html#%E5%88%9B%E5%BB%BA-im-%E7%94%A8%E6%88%B7) + # 快速开始 From 637e0f379d913e6ca83423f0304e2aaff2ee135b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E7=BB=A7=E8=B6=85?= <984065974@qq.com> Date: Fri, 7 Jun 2024 17:01:56 +0800 Subject: [PATCH 05/12] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ba159fb8..83f1d4d5 100644 --- a/README.md +++ b/README.md @@ -395,6 +395,8 @@ EaseChatUIKitClient.shared.unregisterUserStateListener(self) # 自定义 +详细的自定义请参见wiki. + ## 1.修改可配置项 下面示例展示如何更改消息内容显示 From 18f5506c8d996d7baf173dcba5e9b5b66a264995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E7=BB=A7=E8=B6=85?= <984065974@qq.com> Date: Fri, 28 Jun 2024 10:32:22 +0800 Subject: [PATCH 06/12] Update ContactSearchResultController.swift --- .../Contact/Controllers/ContactSearchResultController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/EaseChatUIKit/Classes/UI/Components/Contact/Controllers/ContactSearchResultController.swift b/Sources/EaseChatUIKit/Classes/UI/Components/Contact/Controllers/ContactSearchResultController.swift index 2c950d5c..b16e2595 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Components/Contact/Controllers/ContactSearchResultController.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Components/Contact/Controllers/ContactSearchResultController.swift @@ -125,6 +125,7 @@ import UIKit if let item = self.searchResults[safe: indexPath.row] { item.selected = !item.selected self.selectClosure?(item) + self.searchController.isActive = false } self.tableView.reloadData() } From 8eb1448893e87b63496c835f94e1a44430b91a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E7=BB=A7=E8=B6=85?= <984065974@qq.com> Date: Tue, 9 Jul 2024 14:04:44 +0800 Subject: [PATCH 07/12] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 83f1d4d5..528f5870 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,6 @@ - [结构](#结构) - [运行示例项目](#运行示例项目) - [快速开始](#快速开始) -- [注意事项](#注意事项) - [进阶用法](#进阶用法) - [自定义](#自定义) - [主题](#主题) From fdcdeae5f4665fc32c23d99810196896b9bab927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E7=BB=A7=E8=B6=85?= <984065974@qq.com> Date: Tue, 9 Jul 2024 14:49:51 +0800 Subject: [PATCH 08/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 528f5870..c4dd6e9e 100644 --- a/README.md +++ b/README.md @@ -403,7 +403,7 @@ EaseChatUIKitClient.shared.unregisterUserStateListener(self) ```Swift // 可以通过增减显示内容数组中的项,改变消息样式某一部分的显示隐藏。 Appearance.chat.contentStyle = [.withReply,.withAvatar,.withNickName,.withDateAndTime] - // 创建ChatroomView,传入布局参数、底部工具栏扩展按钮模型协议数组等参数。 + let vc = ComponentsRegister.shared.MessageViewController.init(conversationId: <#在Console中创建用户的id#>, chatType: .chat) vc.modalPresentationStyle = .fullScreen ControllerStack.toDestination(vc: vc) From 6739192ce599e3ccc3250b80c559cdf44b35057c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E7=BB=A7=E8=B6=85?= <984065974@qq.com> Date: Wed, 17 Jul 2024 18:26:09 +0800 Subject: [PATCH 09/12] update --- .../Service/Client/EaseChatUIKitClient.swift | 2 +- .../Chat/Cells/TextMessageCell.swift | 2 +- .../Chat/ViewModel/MessageEntity.swift | 45 +++++++++---------- .../Chat/ViewModel/MessageListViewModel.swift | 5 +++ .../UI/Core/Foundation/ConsoleLog.swift | 2 +- 5 files changed, 30 insertions(+), 26 deletions(-) diff --git a/Sources/EaseChatUIKit/Classes/Service/Client/EaseChatUIKitClient.swift b/Sources/EaseChatUIKit/Classes/Service/Client/EaseChatUIKitClient.swift index 950ebe31..0f0b00f7 100644 --- a/Sources/EaseChatUIKit/Classes/Service/Client/EaseChatUIKitClient.swift +++ b/Sources/EaseChatUIKit/Classes/Service/Client/EaseChatUIKitClient.swift @@ -51,7 +51,7 @@ public let EaseChatUIKit_VERSION = "4.6.0" if let key = appKey { return ChatClient.shared().initializeSDK(with: ChatOptions(appkey: key)) } - return ChatError(description: "App key can't nil", code: .invalidAppkey) + return ChatError(description: "App key can't be nil", code: .invalidAppkey) } } diff --git a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Cells/TextMessageCell.swift b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Cells/TextMessageCell.swift index 758bffd2..599a313a 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Cells/TextMessageCell.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/Cells/TextMessageCell.swift @@ -22,7 +22,7 @@ import UIKit }() @objc open func createContent() -> UILabel { - UILabel(frame: .zero).backgroundColor(.clear).lineBreakMode(LanguageConvertor.chineseLanguage() ? .byCharWrapping:.byWordWrapping).numberOfLines(0) + UILabel(frame: .zero).backgroundColor(.clear).numberOfLines(0) } public private(set) lazy var edit: UIButton = { diff --git a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageEntity.swift b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageEntity.swift index 7449004d..f35768b0 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageEntity.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageEntity.swift @@ -260,7 +260,7 @@ public let callMessage = "rtcCallWithAgora" } open func textSize() -> CGSize { - let label = UILabel().numberOfLines(0).lineBreakMode(LanguageConvertor.chineseLanguage() ? .byCharWrapping:.byWordWrapping) + let label = UILabel().numberOfLines(0) let textAttribute = self.convertTextAttribute() label.attributedText = textAttribute var width = label.sizeThatFits(CGSize(width: self.historyMessage ? ScreenWidth-68:limitBubbleWidth-24, height: 9999)).width+(self.historyMessage ? 68:24) @@ -369,7 +369,7 @@ public let callMessage = "rtcCallWithAgora" return CGSize(width: self.historyMessage ? ScreenWidth-32:limitBubbleWidth, height: contactCardHeight) } else { if body.event == EaseChatUIKit_alert_message { - let label = UILabel().numberOfLines(0).lineBreakMode(LanguageConvertor.chineseLanguage() ? .byCharWrapping:.byWordWrapping) + let label = UILabel().numberOfLines(0) label.attributedText = self.convertTextAttribute() let size = label.sizeThatFits(CGSize(width: ScreenWidth-32, height: 9999)) return CGSize(width: ScreenWidth-32, height: size.height+50) @@ -399,13 +399,13 @@ public let callMessage = "rtcCallWithAgora" } if self.message.body.type != .text, self.message.body.type != .custom { text.append(NSAttributedString { - AttributedText(self.message.showType+self.message.showContent).foregroundColor(textColor).font(self.historyMessage ? UIFont.theme.bodyMedium:UIFont.theme.bodyLarge).lineHeight(multiple: 0.98, minimum: 18).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping) + AttributedText(self.message.showType+self.message.showContent).foregroundColor(textColor).font(self.historyMessage ? UIFont.theme.bodyMedium:UIFont.theme.bodyLarge).lineHeight(multiple: 0.98, minimum: 18) }) return text } if self.historyMessage,self.message.body.type == .custom { text.append(NSAttributedString { - AttributedText(self.message.showType+self.message.showContent).foregroundColor(textColor).font(self.historyMessage ? UIFont.theme.bodyMedium:UIFont.theme.bodyLarge).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping).lineHeight(multiple: 0.98, minimum: 18) + AttributedText(self.message.showType+self.message.showContent).foregroundColor(textColor).font(self.historyMessage ? UIFont.theme.bodyMedium:UIFont.theme.bodyLarge).lineHeight(multiple: 0.98, minimum: 18) }) return text } @@ -432,7 +432,7 @@ public let callMessage = "rtcCallWithAgora" default: text.append(NSAttributedString { - AttributedText(self.message.showType+self.message.showContent).foregroundColor(textColor).font(self.historyMessage ? UIFont.theme.bodyMedium:UIFont.theme.bodyLarge).lineHeight(multiple: 0.98, minimum: self.historyMessage ? 16:18).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping) + AttributedText(self.message.showType+self.message.showContent).foregroundColor(textColor).font(self.historyMessage ? UIFont.theme.bodyMedium:UIFont.theme.bodyLarge).lineHeight(multiple: 0.98, minimum: self.historyMessage ? 16:18) }) break } @@ -445,7 +445,7 @@ public let callMessage = "rtcCallWithAgora" } if self.message.mention.isEmpty { text.append(NSAttributedString { - AttributedText(result).foregroundColor(textColor).font(self.historyMessage ? UIFont.theme.bodyMedium:UIFont.theme.bodyLarge).lineHeight(multiple: 0.98, minimum: self.historyMessage ? 16:18).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping) + AttributedText(result).foregroundColor(textColor).font(self.historyMessage ? UIFont.theme.bodyMedium:UIFont.theme.bodyLarge).lineHeight(multiple: 0.98, minimum: self.historyMessage ? 16:18) }) } else { if self.message.mention == EaseChatUIKitContext.shared?.currentUserId ?? "" { @@ -462,7 +462,7 @@ public let callMessage = "rtcCallWithAgora" let mentionRange = content.lowercased().chat.rangeOfString(nickname ?? "") let range = NSMakeRange(mentionRange.location-1, mentionRange.length+1) let mentionAttribute = NSMutableAttributedString { - AttributedText(content).foregroundColor(textColor).font(self.historyMessage ? UIFont.theme.bodyMedium:UIFont.theme.bodyLarge).lineHeight(multiple: 0.98, minimum: self.historyMessage ? 16:18).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping) + AttributedText(content).foregroundColor(textColor).font(self.historyMessage ? UIFont.theme.bodyMedium:UIFont.theme.bodyLarge).lineHeight(multiple: 0.98, minimum: self.historyMessage ? 16:18) } if mentionRange.location != NSNotFound,mentionRange.length != NSNotFound { mentionAttribute.addAttribute(.foregroundColor, value: (Theme.style == .dark ? UIColor.theme.primaryColor6:UIColor.theme.primaryColor5), range: range) @@ -474,7 +474,7 @@ public let callMessage = "rtcCallWithAgora" let mentionRange = content.lowercased().chat.rangeOfString(self.message.mention.lowercased()) let range = NSMakeRange(mentionRange.location-1, mentionRange.length+1) let mentionAttribute = NSMutableAttributedString { - AttributedText(content).foregroundColor(textColor).font(self.historyMessage ? UIFont.theme.bodyMedium:UIFont.theme.bodyLarge).lineHeight(multiple: 0.98, minimum: self.historyMessage ? 16:18).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping) + AttributedText(content).foregroundColor(textColor).font(self.historyMessage ? UIFont.theme.bodyMedium:UIFont.theme.bodyLarge).lineHeight(multiple: 0.98, minimum: self.historyMessage ? 16:18) } if mentionRange.location != NSNotFound,mentionRange.length != NSNotFound { mentionAttribute.addAttribute(.foregroundColor, value: (Theme.style == .dark ? UIColor.theme.primaryColor6:UIColor.theme.primaryColor5), range: range) @@ -548,7 +548,7 @@ public let callMessage = "rtcCallWithAgora" var text = NSMutableAttributedString() if self.message.body.type != .text { text.append(NSAttributedString { - AttributedText(self.message.showType).foregroundColor(self.message.direction == .send ? Appearance.chat.sendTranslationColor:Appearance.chat.receiveTranslationColor).font(UIFont.theme.bodyLarge).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byWordWrapping).lineHeight(multiple: 0.98, minimum: 18) + AttributedText(self.message.showType).foregroundColor(self.message.direction == .send ? Appearance.chat.sendTranslationColor:Appearance.chat.receiveTranslationColor).font(UIFont.theme.bodyLarge).lineHeight(multiple: 0.98, minimum: 18) }) return text } else { @@ -557,7 +557,7 @@ public let callMessage = "rtcCallWithAgora" result = result.replacingOccurrences(of: key, with: value) } text.append(NSAttributedString { - AttributedText(result).foregroundColor(self.message.direction == .send ? Appearance.chat.sendTranslationColor:Appearance.chat.receiveTranslationColor).font(UIFont.theme.bodyLarge).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping).lineHeight(multiple: 0.98, minimum: 18) + AttributedText(result).foregroundColor(self.message.direction == .send ? Appearance.chat.sendTranslationColor:Appearance.chat.receiveTranslationColor).font(UIFont.theme.bodyLarge).lineHeight(multiple: 0.98, minimum: 18) }) let string = text.string as NSString for symbol in ChatEmojiConvertor.shared.emojis { @@ -568,7 +568,6 @@ public let callMessage = "rtcCallWithAgora" text.addAttribute(.font, value: UIFont.theme.bodyLarge, range: range) text.addAttribute(.foregroundColor, value: self.message.direction == .send ? Appearance.chat.sendTranslationColor:Appearance.chat.receiveTranslationColor, range: range) let paragraphStyle = NSMutableParagraphStyle() - paragraphStyle.lineBreakMode = Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping paragraphStyle.lineHeightMultiple = 0.98 text.addAttribute(.paragraphStyle, value: paragraphStyle, range: range) } @@ -580,8 +579,8 @@ public let callMessage = "rtcCallWithAgora" open func updateReplySize() -> CGSize { if let attributeContent = self.convertToReply() { if let attributeTitle = self.replyTitle,attributeContent.length > 0,attributeContent.string != "message doesn't exist".chat.localize { - let labelTitle = UILabel().numberOfLines(1).lineBreakMode(LanguageConvertor.chineseLanguage() ? .byCharWrapping:.byWordWrapping) - let labelContent = UILabel().numberOfLines(2).lineBreakMode(LanguageConvertor.chineseLanguage() ? .byCharWrapping:.byWordWrapping) + let labelTitle = UILabel().numberOfLines(1) + let labelContent = UILabel().numberOfLines(2) labelTitle.attributedText = attributeTitle labelContent.attributedText = attributeContent let titleSize = labelTitle.sizeThatFits(CGSize(width: limitBubbleWidth, height: 16)) @@ -592,7 +591,7 @@ public let callMessage = "rtcCallWithAgora" return CGSize(width: (titleSize.width > contentSize.width ? titleSize.width:contentSize.width)+24, height: contentSize.height+34) } } else { - let labelContent = UILabel().numberOfLines(2).lineBreakMode(LanguageConvertor.chineseLanguage() ? .byCharWrapping:.byWordWrapping) + let labelContent = UILabel().numberOfLines(2) labelContent.attributedText = attributeContent let contentSize = labelContent.sizeThatFits(CGSize(width: limitBubbleWidth, height: 36)) return CGSize(width: contentSize.width+10, height: contentSize.height+10) @@ -617,37 +616,37 @@ public let callMessage = "rtcCallWithAgora" switch quoteMessage.body.type { case .text: reply.append(NSAttributedString { - AttributedText(quoteMessage.showType).font(Font.theme.labelMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping) + AttributedText(quoteMessage.showType).font(Font.theme.labelMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5) }) case .image,.video,.combine,.location: reply.append(NSAttributedString { - AttributedText(quoteMessage.showType).font(Font.theme.labelMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping) + AttributedText(quoteMessage.showType).font(Font.theme.labelMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5) }) case .file,.voice: reply.append(NSAttributedString { - AttributedText(quoteMessage.showType).font(Font.theme.labelMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping) - AttributedText(quoteMessage.showContent).font(Font.theme.bodyMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping) + AttributedText(quoteMessage.showType).font(Font.theme.labelMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5) + AttributedText(quoteMessage.showContent).font(Font.theme.bodyMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5) }) case .custom: if let body = quoteMessage.body as? ChatCustomMessageBody,body.event == EaseChatUIKit_user_card_message { reply.append(NSAttributedString { - AttributedText(quoteMessage.showType).font(Font.theme.labelMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping) - AttributedText(quoteMessage.showContent).font(Font.theme.bodyMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping) + AttributedText(quoteMessage.showType).font(Font.theme.labelMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5) + AttributedText(quoteMessage.showContent).font(Font.theme.bodyMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5) }) } else { reply.append(NSAttributedString { - AttributedText("message doesn't exist".chat.localize).font(Font.theme.bodyMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping) + AttributedText("message doesn't exist".chat.localize).font(Font.theme.bodyMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5) }) } default: reply.append(NSAttributedString { - AttributedText("message doesn't exist".chat.localize).font(Font.theme.bodyMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping) + AttributedText("message doesn't exist".chat.localize).font(Font.theme.bodyMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5) }) } return reply } else { return NSAttributedString { - AttributedText("message doesn't exist".chat.localize).font(Font.theme.bodyMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byCharWrapping) + AttributedText("message doesn't exist".chat.localize).font(Font.theme.bodyMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5) } } } else { diff --git a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageListViewModel.swift b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageListViewModel.swift index 43da9d8f..a759b6af 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageListViewModel.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Components/Chat/ViewModel/MessageListViewModel.swift @@ -214,6 +214,11 @@ import UIKit if let userId = extensionInfo["uid"] as? String { customExt["uid"] = userId ext.removeValue(forKey: "uid") +// customExt["moderation"] = ["enable": true, +// "contents": [[ +// "type": "text", +// "data": "习近平"]] +// ].chat.jsonString } if let avatar = extensionInfo["avatar"] as? String { customExt["avatar"] = avatar diff --git a/Sources/EaseChatUIKit/Classes/UI/Core/Foundation/ConsoleLog.swift b/Sources/EaseChatUIKit/Classes/UI/Core/Foundation/ConsoleLog.swift index 636f4fed..fdd7ade5 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Core/Foundation/ConsoleLog.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Core/Foundation/ConsoleLog.swift @@ -57,7 +57,7 @@ private func consoleLog ( final class Log { static let logFileURL: URL = { let documentsDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! - return documentsDirectoryURL.appendingPathComponent("EaseChatUIKit.log") + return documentsDirectoryURL.appendingPathComponent("EaseChatUIKit\(EaseChatUIKit_VERSION).log") }() static func saveLog(_ message: String, file: StaticString = #file, function: StaticString = #function, line: UInt = #line) { From e744837f77d85bdc97f2cd326d5a16e1329b2a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E7=BB=A7=E8=B6=85?= <984065974@qq.com> Date: Tue, 30 Jul 2024 18:01:33 +0800 Subject: [PATCH 10/12] Create chatfeature_message.md --- Documentation/chatfeature_message.md | 170 +++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 Documentation/chatfeature_message.md diff --git a/Documentation/chatfeature_message.md b/Documentation/chatfeature_message.md new file mode 100644 index 00000000..f856a7ac --- /dev/null +++ b/Documentation/chatfeature_message.md @@ -0,0 +1,170 @@ +# 消息特性 + + + +本文介绍消息相关特性,包括消息复制、删除、撤回、编辑、引用、翻译、表情回复、话题和转发。 + +对于消息引用、翻译、话题和消息转发,你可以决定是否开启或关闭该特性。 + +消息 cell 包含如下显示模块: + +- 消息引用 +- 用户头像 +- 用户昵称 +- 消息时间 +- 消息话题 +- 表情回复 + +若不显示某个模块,可将其隐藏,示例代码如下: + +```swift +// 消息 cell 包含的显示模块 + @objc public enum MessageContentDisplayStyle: UInt { + case withReply = 1 + case withAvatar = 2 + case withNickName = 4 + case withDateAndTime = 8 + case withMessageThread = 16 + case withMessageReaction = 32 +} +// 若不显示,可将其隐藏。 +Appearance.chat.contentStyle: [MessageContentDisplayStyle] = [.withReply,.withAvatar,.withNickName,.withDateAndTime,.withMessageThread,.withMessageReaction] + + if hiddenTopic { + Appearance.chat.contentStyle.removeAll { $0 == .withMessageThread } + } + if hiddenReaction { + Appearance.chat.contentStyle.removeAll { $0 == .withMessageReaction } + } +``` + +## 消息复制 + +消息复制是指用户可以将一条消息复制到剪贴板。消息复制可以帮助用户将消息保存到其他地方,或将其粘贴到其他应用程序中。 + +![img](./IndicatorImages/Appearance_chat_messageLongPressedActions.png) + +## 消息删除 + +消息删除是指用户可以删除一条消息。消息删除可以帮助用户删除错误发送的消息,或删除不想保留的消息。 + +![img](./IndicatorImages/Appearance_chat_messageLongPressedActions.png) + +## 消息撤回 + +消息撤回是指用户可以撤回一条已发送的消息。消息撤回可以帮助用户撤回错误发送的消息,或撤回不想让其他用户看到的消息。 + +![img](./IndicatorImages/Appearance_chat_messageLongPressedActions.png) + +## 消息编辑 + +消息编辑是指用户可以编辑一条已发送的消息。消息编辑可以帮助用户纠正错误,或添加新信息。 + +![img](./IndicatorImages/Appearance_chat_messageLongPressedActions.png) + +## 消息引用 + +消息引用是指用户可以引用一条已发送的消息。消息引用可以帮助用户回复特定的消息,或强调特定的信息。 + +![img](./IndicatorImages/Appearance_chat_messageLongPressedActions.png) + +消息引用特性默认开启,若不需要可将其隐藏,示例代码如下: + +```Swift +Appearance.chat.contentStyle: [MessageContentDisplayStyle] = [.withReply,.withAvatar,.withNickName,.withDateAndTime,.withMessageThread,.withMessageReaction] + + if hiddenTopic { + Appearance.chat.contentStyle.removeAll { $0 == .withReply } + } +``` + +## 消息翻译 + +消息翻译是指用户可以将一条消息翻译成其他语言。消息翻译可以帮助使用不同语言的用户进行沟通。 + +目前,单群聊 UIKit 支持翻译文本消息。消息翻译的 UI 和逻辑部分在 `Appearance.swift` 中。 + +![img](./IndicatorImages/Appearance_chat_messageLongPressedActions.png) + +### 如何使用 + +使用该特性前,请确保在[环信即时通信控制台](https://console.easemob.com/user/login)上已申请试用该功能。 + +1. 开启消息翻译特性。 + +消息翻译特性在 `Appearance.swift` 中默认关闭,即 `Appearance.chat.enableTranslation` 的默认值为 `false`。要开启该特性,需将该参数设置为 `true`。 + +2. 设置翻译的目标语言。 + +单群聊 UiKit 的 `Appearance.swift` 中提供了 `Appearance.chat.targetLanguage` 设置目标翻译语言。 + +如果未设置翻译的目标语言,则默认使用中文。 + +更多翻译目标语言,请参考 [翻译语言支持](https://learn.microsoft.com/zh-cn/azure/ai-services/translator/language-support)。 + +示例代码如下: + +```Swift + + Appearance.chat.enableTranslation = true + + Appearance.chat.targetLanguage = .English + +``` + +## 表情回复 + +表情回复(即 Reaction)指用户可以使用表情符号回复消息。表情回复可以帮助用户表达情绪、态度、进行调查或投票。在单群聊 UIKit 中,用户可以长按单条消息触发消息拓展功能菜单,选择表情回复。 + +目前,单群聊 UIKit 支持 Reaction,可在 `Appearance.swift` 中开启或关闭。 + +![img](./IndicatorImages/Appearance_chat_messageLongPressedActions.png) + +### 如何使用 + +使用该特性前,请确保在[环信即时通信控制台](https://console.easemob.com/user/login)上已开通该功能。 + +消息表情回复特性在 `Appearance.swift` 中默认关闭,即 `Appearance.chat.contentStyle` 数组中默认不包含 `.withMessageReaction`。 + +要开启该特性,需在该数组中添加 `.withMessageReaction`。**注意不要重复添加**。 + +示例代码如下: + +```swift +Appearance.chat.contentStyle.append(.withMessageReaction) + +``` + +## 消息话题 + +消息话题(即 `Thread`)指用户可以在群组聊天中根据一条消息创建话题进行深入探讨,讨论和追踪特定项目任务,而不影响其他聊天内容。 + +单群聊 UIKit 中实现了 Thread,可在 `Appearance.swift` 中开启或关闭。 + +![img](./IndicatorImages/Appearance_chat_messageLongPressedActions.png) + +### 如何使用 + +使用该特性前,请确保在[环信即时通信控制台](https://console.easemob.com/user/login)上已开通该功能。 + +Thread 特性在 `Appearance.swift` 中默认关闭,即` Appearance.chat.contentStyle` 数组中默认不包含 `.withMessageThread`。 + +要开启该特性,需在该数组中添加 `.withMessageThread`。**注意不要重复添加**。 + +```swift +Appearance.chat.contentStyle.append(.withMessageThread) + +``` + +## 消息合并转发 + +消息转发指用户可以将消息转发给其他用户。你可以转发单条消息,也可以选择多条消息进行合并转发。 + +消息转发 UI 和逻辑部分结构如下: + +- `MessageMultiSelectedBottomBar.swift`:底部菜单 View。 +- `MessageListController.swift`:处理 UI 布局变更以及转发和删除的逻辑。 +- `MessageListController.swift`:消息选择帮助类用于记录选中的消息信息并提供获取方法。 + +![img](./IndicatorImages/Appearance_chat_messageLongPressedActions.png) + From ad8a5fb946c364c52e92ce1d53c8355b68c8e6b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E7=BB=A7=E8=B6=85?= <984065974@qq.com> Date: Fri, 16 Aug 2024 11:43:25 +0800 Subject: [PATCH 11/12] Update EaseChatUIKit.podspec --- EaseChatUIKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EaseChatUIKit.podspec b/EaseChatUIKit.podspec index b647aeab..060ff526 100644 --- a/EaseChatUIKit.podspec +++ b/EaseChatUIKit.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'EaseChatUIKit' - s.version = '4.7.0' + s.version = '4.8.0' s.summary = 'A easy for use ChatUIKit.' # This description is used to generate tags and improve search results. From 61106a0c1850196643a9443c1e233ab82ec1fdd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=8F=E6=98=8E?= <527725681@qq.com> Date: Fri, 16 Aug 2024 11:48:58 +0800 Subject: [PATCH 12/12] Delete chat-uikit.podspec --- chat-uikit.podspec | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 chat-uikit.podspec diff --git a/chat-uikit.podspec b/chat-uikit.podspec deleted file mode 100644 index d82fc98e..00000000 --- a/chat-uikit.podspec +++ /dev/null @@ -1,44 +0,0 @@ -Pod::Spec.new do |s| -s.name = 'chat-uikit' -s.version = '1.3.0' -s.summary = 'agora im UIKit' -s.homepage = 'https://github.com/AgoraIO-Usecase/AgoraChat-UIKit-ios' -s.description = <<-DESC -chat-uikit new version -DESC -s.license = { :type => 'MIT', :file => 'LICENSE' } -s.author = { 'agora' => 'dev@agora.com' } -s.source = { :git => 'https://github.com/AgoraIO-Usecase/AgoraChat-UIKit-ios.git', :tag => s.version.to_s} -s.ios.deployment_target = '13.0' - -s.xcconfig = {'ENABLE_BITCODE' => 'NO'} -s.resources = ['Sources/EaseChatUIKit/Classes/UI/**/*.bundle','Sources/EaseChatUIKit/Classes/UI/**/*.xcprivacy'] -s.dependency 'HyphenateChat','>= 4.6.0' -s.static_framework = true - -s.swift_version = '5.0' -s.prefix_header_contents = ' -# if __has_include () -#import -# else -#import "EaseChatUIKit-Bridge.h" -# endif -' -s.public_header_files = 'Sources/EaseChatUIKit/Classes/UI/Foundation/EaseChatUIKit-Bridge.h' - -s.preserve_paths = ['Sources/EaseChatUIKit/Classes/UI/Core/Foundation/third-party/**/*.a','Sources/EaseChatUIKit/Classes/UI/Core/Foundation/third-party/vo-amrwbenc/lib/*.a'] - - -s.vendored_libraries = ['Sources/EaseChatUIKit/Classes/UI/Core/Foundation/third-party/**/*.a','Sources/EaseChatUIKit/Classes/UI/Core/Foundation/third-party/vo-amrwbenc/lib/*.a'] - -s.xcconfig = { 'LIBRARY_SEARCH_PATHS' => '$(PODS_ROOT)/Sources/EaseChatUIKit/Classes/UI/Core/Foundation/third-party/**/*' } # - - -s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64', -'VALID_ARCHS' => 'arm64 armv7 x86_64' -} -s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } - -s.frameworks = 'UIKit', 'Foundation', 'Combine', 'AudioToolbox', 'AVFoundation','AVFAudio','Photos' - -end