diff --git a/Example/EaseChatUIKit.xcodeproj/xcuserdata/zhujichao1.xcuserdatad/xcschemes/xcschememanagement.plist b/Example/EaseChatUIKit.xcodeproj/xcuserdata/zhujichao1.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..53a518b1 --- /dev/null +++ b/Example/EaseChatUIKit.xcodeproj/xcuserdata/zhujichao1.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + EaseChatUIKit_Example.xcscheme_^#shared#^_ + + orderHint + 3 + + + + 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..b6ced274 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).lineBreakMode(.byWordWrapping) 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).lineBreakMode(.byWordWrapping) 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).lineBreakMode(.byWordWrapping) }) 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).lineBreakMode(.byWordWrapping).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).lineBreakMode(.byWordWrapping) }) 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).lineBreakMode(.byWordWrapping) }) } 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).lineBreakMode(Appearance.chat.targetLanguage == .Chinese ? .byCharWrapping:.byWordWrapping) } 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).lineBreakMode(.byWordWrapping) } 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).lineBreakMode(.byWordWrapping).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).lineBreakMode(.byWordWrapping).lineHeight(multiple: 0.98, minimum: 18) }) let string = text.string as NSString for symbol in ChatEmojiConvertor.shared.emojis { @@ -568,7 +568,7 @@ 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.lineBreakMode = .byWordWrapping paragraphStyle.lineHeightMultiple = 0.98 text.addAttribute(.paragraphStyle, value: paragraphStyle, range: range) } @@ -580,8 +580,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).lineBreakMode(.byWordWrapping) + let labelContent = UILabel().numberOfLines(2).lineBreakMode(.byWordWrapping) labelTitle.attributedText = attributeTitle labelContent.attributedText = attributeContent let titleSize = labelTitle.sizeThatFits(CGSize(width: limitBubbleWidth, height: 16)) @@ -592,7 +592,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).lineBreakMode(.byWordWrapping) labelContent.attributedText = attributeContent let contentSize = labelContent.sizeThatFits(CGSize(width: limitBubbleWidth, height: 36)) return CGSize(width: contentSize.width+10, height: contentSize.height+10) @@ -617,37 +617,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).lineBreakMode(.byWordWrapping) }) 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).lineBreakMode(.byWordWrapping) }) 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).lineBreakMode(.byWordWrapping) + AttributedText(quoteMessage.showContent).font(Font.theme.bodyMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5).lineBreakMode(.byWordWrapping) }) 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).lineBreakMode(.byWordWrapping) + AttributedText(quoteMessage.showContent).font(Font.theme.bodyMedium).foregroundColor(Theme.style == .dark ? Color.theme.neutralColor6:Color.theme.neutralColor5).lineBreakMode(.byWordWrapping) }) } 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).lineBreakMode(.byWordWrapping) }) } 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).lineBreakMode(.byWordWrapping) }) } 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).lineBreakMode(.byWordWrapping) } } } else { diff --git a/Sources/EaseChatUIKit/Classes/UI/Components/Contact/Cells/DetailInfoListCell.swift b/Sources/EaseChatUIKit/Classes/UI/Components/Contact/Cells/DetailInfoListCell.swift index bfcd18c3..61ba0fca 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Components/Contact/Cells/DetailInfoListCell.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Components/Contact/Cells/DetailInfoListCell.swift @@ -61,7 +61,7 @@ import UIKit self.titleLabel.frame = CGRect(x: 16, y: 16, width: (self.frame.width/2.0-22), height: 22) self.detailLabel.frame = CGRect(x: self.frame.width/2.0, y: 16, width: (self.frame.width/2.0-36), height: 22) self.switchMenu.frame = CGRect(x: self.frame.width-62, y: (self.contentView.frame.height-30)/2.0, width: 50, height: 30) - self.separatorLine.frame = CGRect(x: 16, y: self.contentView.frame.height-0.5, width: self.contentView.frame.width, height: 0.5) + self.separatorLine.frame = CGRect(x: 16, y: self.contentView.frame.height-0.5, width: self.frame.width, height: 0.5) } @objc public func refresh(info: DetailInfo) { diff --git a/Sources/EaseChatUIKit/Classes/UI/Core/UIKit/Commons/Appearance.swift b/Sources/EaseChatUIKit/Classes/UI/Core/UIKit/Commons/Appearance.swift index e3820584..beb827eb 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Core/UIKit/Commons/Appearance.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Core/UIKit/Commons/Appearance.swift @@ -96,11 +96,13 @@ import UIKit public var moreActions: [ActionSheetItemProtocol] = [] /// Shown menus on ``ConversationListController`` right item clicked. - public var listMoreActions: [ActionSheetItemProtocol] = [ - ActionSheetItem(title: "new_chat_button_click_menu_selectcontacts".chat.localize, type: .normal, tag: "SelectContacts", image: UIImage(named: "chatWith", in: .chatBundle, with: nil)), - ActionSheetItem(title: "new_chat_button_click_menu_addcontacts".chat.localize, type: .normal, tag: "AddContact", image: UIImage(named: "person_add_fill", in: .chatBundle, with: nil)?.withTintColor(UIColor.theme.primaryColor5)), - ActionSheetItem(title: "new_chat_button_click_menu_creategroup".chat.localize, type: .normal, tag: "CreateGroup", image: UIImage(named: "create_group", in: .chatBundle, with: nil)?.withTintColor(UIColor.theme.primaryColor5)) - ] + lazy public var listMoreActions: [ActionSheetItemProtocol] = { + [ + ActionSheetItem(title: "new_chat_button_click_menu_selectcontacts".chat.localize, type: .normal, tag: "SelectContacts", image: UIImage(named: "chatWith", in: .chatBundle, with: nil)), + ActionSheetItem(title: "new_chat_button_click_menu_addcontacts".chat.localize, type: .normal, tag: "AddContact", image: UIImage(named: "person_add_fill", in: .chatBundle, with: nil)?.withTintColor(UIColor.theme.primaryColor5)), + ActionSheetItem(title: "new_chat_button_click_menu_creategroup".chat.localize, type: .normal, tag: "CreateGroup", image: UIImage(named: "create_group", in: .chatBundle, with: nil)?.withTintColor(UIColor.theme.primaryColor5)) + ] + }() } @objcMembers final public class ChatAppearance: NSObject { @@ -121,19 +123,21 @@ import UIKit public var contentStyle: [MessageContentDisplayStyle] = [.withReply,.withAvatar,.withNickName,.withDateAndTime] /// ActionSheet data source of the message being long pressed.``ActionSheetItemProtocol`` - public var messageLongPressedActions: [ActionSheetItemProtocol] = [ - ActionSheetItem(title: "barrage_long_press_menu_copy".chat.localize, type: .normal,tag: "Copy",image: UIImage(named: "message_action_copy", in: .chatBundle, with: nil)), - ActionSheetItem(title: "barrage_long_press_menu_edit".chat.localize, type: .normal,tag: "Edit",image: UIImage(named: "message_action_edit", in: .chatBundle, with: nil)), - ActionSheetItem(title: "barrage_long_press_menu_reply".chat.localize, type: .normal,tag: "Reply",image: UIImage(named: "message_action_reply", in: .chatBundle, with: nil)), - ActionSheetItem(title: "barrage_long_press_menu_delete".chat.localize, type: .normal,tag: "Delete",image: UIImage(named: "message_action_delete", in: .chatBundle, with: nil)), - ActionSheetItem(title: "barrage_long_press_menu_recall".chat.localize, type: .normal,tag: "Recall",image: UIImage(named: "message_action_recall", in: .chatBundle, with: nil)), - ActionSheetItem(title: "barrage_long_press_menu_report".chat.localize, type: .normal,tag: "Report",image: UIImage(named: "message_action_report", in: .chatBundle, with: nil)), - ActionSheetItem(title: "barrage_long_press_menu_translate".chat.localize, type: .normal,tag: "Translate",image: UIImage(named: "message_action_translation", in: .chatBundle, with: nil)), - ActionSheetItem(title: "barrage_long_press_menu_show_original_text".chat.localize, type: .normal,tag: "OriginalText",image: UIImage(named: "message_action_translation", in: .chatBundle, with: nil)), - ActionSheetItem(title: "barrage_long_press_menu_multi_select".chat.localize, type: .normal,tag: "MultiSelect",image: UIImage(named: "message_action_multi_select", in: .chatBundle, with: nil)), - ActionSheetItem(title: "barrage_long_press_menu_topic".chat.localize, type: .normal,tag: "Topic",image: UIImage(named: "message_action_topic", in: .chatBundle, with: nil)), - ActionSheetItem(title: "barrage_long_press_menu_forward".chat.localize, type: .normal,tag: "Forward",image: UIImage(named: "message_action_forward", in: .chatBundle, with: nil)), - ] + lazy public var messageLongPressedActions: [ActionSheetItemProtocol] = { + [ + ActionSheetItem(title: "barrage_long_press_menu_copy".chat.localize, type: .normal,tag: "Copy",image: UIImage(named: "message_action_copy", in: .chatBundle, with: nil)), + ActionSheetItem(title: "barrage_long_press_menu_edit".chat.localize, type: .normal,tag: "Edit",image: UIImage(named: "message_action_edit", in: .chatBundle, with: nil)), + ActionSheetItem(title: "barrage_long_press_menu_reply".chat.localize, type: .normal,tag: "Reply",image: UIImage(named: "message_action_reply", in: .chatBundle, with: nil)), + ActionSheetItem(title: "barrage_long_press_menu_delete".chat.localize, type: .normal,tag: "Delete",image: UIImage(named: "message_action_delete", in: .chatBundle, with: nil)), + ActionSheetItem(title: "barrage_long_press_menu_recall".chat.localize, type: .normal,tag: "Recall",image: UIImage(named: "message_action_recall", in: .chatBundle, with: nil)), + ActionSheetItem(title: "barrage_long_press_menu_report".chat.localize, type: .normal,tag: "Report",image: UIImage(named: "message_action_report", in: .chatBundle, with: nil)), + ActionSheetItem(title: "barrage_long_press_menu_translate".chat.localize, type: .normal,tag: "Translate",image: UIImage(named: "message_action_translation", in: .chatBundle, with: nil)), + ActionSheetItem(title: "barrage_long_press_menu_show_original_text".chat.localize, type: .normal,tag: "OriginalText",image: UIImage(named: "message_action_translation", in: .chatBundle, with: nil)), + ActionSheetItem(title: "barrage_long_press_menu_multi_select".chat.localize, type: .normal,tag: "MultiSelect",image: UIImage(named: "message_action_multi_select", in: .chatBundle, with: nil)), + ActionSheetItem(title: "barrage_long_press_menu_topic".chat.localize, type: .normal,tag: "Topic",image: UIImage(named: "message_action_topic", in: .chatBundle, with: nil)), + ActionSheetItem(title: "barrage_long_press_menu_forward".chat.localize, type: .normal,tag: "Forward",image: UIImage(named: "message_action_forward", in: .chatBundle, with: nil)), + ] + }() /// The mirror type of the language code of LanguageType.``LanguageType`` public var targetLanguage: LanguageType = .Chinese @@ -145,7 +149,9 @@ import UIKit public var reportSelectionTags: [String] = ["tag1","tag2","tag3","tag4","tag5","tag6","tag7","tag8","tag9"] /// The label for message reporting reason. - public var reportSelectionReasons: [String] = ["violation_reason_1".chat.localize,"violation_reason_2".chat.localize,"violation_reason_3".chat.localize,"violation_reason_4".chat.localize,"violation_reason_5".chat.localize,"violation_reason_6".chat.localize,"violation_reason_7".chat.localize,"violation_reason_8".chat.localize,"violation_reason_9".chat.localize] + lazy public var reportSelectionReasons: [String] = { + ["violation_reason_1".chat.localize,"violation_reason_2".chat.localize,"violation_reason_3".chat.localize,"violation_reason_4".chat.localize,"violation_reason_5".chat.localize,"violation_reason_6".chat.localize,"violation_reason_7".chat.localize,"violation_reason_8".chat.localize,"violation_reason_9".chat.localize] + }() // /// Replace the emoji resource.``ChatEmojiConvertor`` // /// - Parameters: @@ -153,12 +159,14 @@ import UIKit // public var emojiMap: Dictionary = Dictionary() /// A menu item pops up when you click the `+` button on the input box - public var inputExtendActions: [ActionSheetItemProtocol] = [ - ActionSheetItem(title: "input_extension_menu_photo".chat.localize, type: .normal,tag: "Photo",image: UIImage(named: "photo", in: .chatBundle, with: nil)), - ActionSheetItem(title: "input_extension_menu_camera".chat.localize, type: .normal,tag: "Camera",image: UIImage(named: "camera_fill", in: .chatBundle, with: nil)), - ActionSheetItem(title: "input_extension_menu_file".chat.localize, type: .normal,tag: "File",image: UIImage(named: "file", in: .chatBundle, with: nil)), - ActionSheetItem(title: "input_extension_menu_contact".chat.localize, type: .normal,tag: "Contact",image: UIImage(named: "person_single_fill", in: .chatBundle, with: nil)) - ] + lazy public var inputExtendActions: [ActionSheetItemProtocol] = { + [ + ActionSheetItem(title: "input_extension_menu_photo".chat.localize, type: .normal,tag: "Photo",image: UIImage(named: "photo", in: .chatBundle, with: nil)), + ActionSheetItem(title: "input_extension_menu_camera".chat.localize, type: .normal,tag: "Camera",image: UIImage(named: "camera_fill", in: .chatBundle, with: nil)), + ActionSheetItem(title: "input_extension_menu_file".chat.localize, type: .normal,tag: "File",image: UIImage(named: "file", in: .chatBundle, with: nil)), + ActionSheetItem(title: "input_extension_menu_contact".chat.localize, type: .normal,tag: "Contact",image: UIImage(named: "person_single_fill", in: .chatBundle, with: nil)) + ] + }() /// Setting this property changes the date format displayed within a single session. public var dateFormatToday = "HH:mm" @@ -235,13 +243,17 @@ import UIKit public var headerRowHeight = CGFloat(60) /// The header items of the contact list. - public var listHeaderExtensionActions: [ContactListHeaderItemProtocol] = [ - ContactListHeaderItem(featureIdentify: "NewFriendRequest", featureName: "New Request".chat.localize, featureIcon: nil), - ContactListHeaderItem(featureIdentify: "GroupChats", featureName: "Joined Groups".chat.localize, featureIcon: nil) - ] + lazy public var listHeaderExtensionActions: [ContactListHeaderItemProtocol] = { + [ + ContactListHeaderItem(featureIdentify: "NewFriendRequest", featureName: "New Request".chat.localize, featureIcon: nil), + ContactListHeaderItem(featureIdentify: "GroupChats", featureName: "Joined Groups".chat.localize, featureIcon: nil) + ] + }() /// The contact info header extension items. - public var detailExtensionActionItems: [ContactListHeaderItemProtocol] = [ContactListHeaderItem(featureIdentify: "Chat", featureName: "Chat".chat.localize, featureIcon: UIImage(named: "chatTo", in: .chatBundle, with: nil)),ContactListHeaderItem(featureIdentify: "SearchMessages", featureName: "SearchMessages".chat.localize, featureIcon: UIImage(named: "search_history_messages", in: .chatBundle, with: nil))] + lazy public var detailExtensionActionItems: [ContactListHeaderItemProtocol] = { + [ContactListHeaderItem(featureIdentify: "Chat", featureName: "Chat".chat.localize, featureIcon: UIImage(named: "chatTo", in: .chatBundle, with: nil)),ContactListHeaderItem(featureIdentify: "SearchMessages", featureName: "SearchMessages".chat.localize, featureIcon: UIImage(named: "search_history_messages", in: .chatBundle, with: nil))] + }() // ,ContactListHeaderItem(featureIdentify: "AudioCall", featureName: "AudioCall".chat.localize, featureIcon: UIImage(named: "voice_call", in: .chatBundle, with: nil)),ContactListHeaderItem(featureIdentify: "VideoCall", featureName: "VideoCall".chat.localize, featureIcon: UIImage(named: "video_call", in: .chatBundle, with: nil)) /// ActionSheet menu configuration items after clicking more buttons in a single session side sliding menu. @@ -249,5 +261,7 @@ import UIKit /// `let translate = ActionSheetItem(title: "translate", type: .normal,tag: "Translate")` /// `translate.action = { }` /// `Appearance.conversation.moreActions.append(translate)` - public var moreActions: [ActionSheetItemProtocol] = [ActionSheetItem(title: "contact_details_extend_button_delete".chat.localize, type: .destructive, tag: "contact_delete")] + lazy public var moreActions: [ActionSheetItemProtocol] = { + [ActionSheetItem(title: "contact_details_extend_button_delete".chat.localize, type: .destructive, tag: "contact_delete")] + }() } diff --git a/Sources/EaseChatUIKit/Classes/UI/Core/UIKit/Commons/LanguageConvertor.swift b/Sources/EaseChatUIKit/Classes/UI/Core/UIKit/Commons/LanguageConvertor.swift index 43e5df49..4c656783 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Core/UIKit/Commons/LanguageConvertor.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Core/UIKit/Commons/LanguageConvertor.swift @@ -49,8 +49,7 @@ public enum LanguageType: String { } static func chineseLanguage() -> Bool { - guard var lang = NSLocale.preferredLanguages.first else { return false } - if lang.contains("zh") { + if Appearance.ease_chat_language.rawValue.contains("zh") { return true } else { return false diff --git a/Sources/EaseChatUIKit/Classes/UI/Core/UIKit/Commons/PlaceHolderTextView.swift b/Sources/EaseChatUIKit/Classes/UI/Core/UIKit/Commons/PlaceHolderTextView.swift index 193fe8ce..b0d17715 100644 --- a/Sources/EaseChatUIKit/Classes/UI/Core/UIKit/Commons/PlaceHolderTextView.swift +++ b/Sources/EaseChatUIKit/Classes/UI/Core/UIKit/Commons/PlaceHolderTextView.swift @@ -75,7 +75,11 @@ import UIKit newRect.size.width = size.width+20 newRect.size.height = size.height newRect.origin.x = self.contentInset.left - newRect.origin.y = (rect.height-size.height)/2.0 + if rect.height < 70 { + newRect.origin.y = (rect.height-size.height)/2.0 + } else { + newRect.origin.y = self.contentInset.top + } (self.placeHolder as NSString).draw(in: newRect, withAttributes: [.font: self.font ?? UIFont.theme.bodyLarge,.foregroundColor: self.placeHolderColor]) }