Commit 6bd7d157 authored by DavidHuang's avatar DavidHuang

1、IM消息 @某人 高亮

2、删除不使用的代码
parent 618097b5
...@@ -64,14 +64,12 @@ private extension YHPreviewWorkExpViewController { ...@@ -64,14 +64,12 @@ private extension YHPreviewWorkExpViewController {
// MARK: - UITableViewDelegate 和 UITableViewDataSource // MARK: - UITableViewDelegate 和 UITableViewDataSource
extension YHPreviewWorkExpViewController { extension YHPreviewWorkExpViewController {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// return previewVM.arrDataForWorkExpInfo.count
return previewVM.arrDataForWorkExpInfoNew.count return previewVM.arrDataForWorkExpInfoNew.count
} }
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withClass: YHPreviewInfoCell.self) let cell = tableView.dequeueReusableCell(withClass: YHPreviewInfoCell.self)
cell.selectionStyle = .none cell.selectionStyle = .none
// cell.model = previewVM.arrDataForWorkExpInfo[indexPath.row]
if !previewVM.arrDataForWorkExpInfoNew.isEmpty,indexPath.row < previewVM.arrDataForWorkExpInfoNew.count { if !previewVM.arrDataForWorkExpInfoNew.isEmpty,indexPath.row < previewVM.arrDataForWorkExpInfoNew.count {
cell.model = previewVM.arrDataForWorkExpInfoNew[indexPath.row] cell.model = previewVM.arrDataForWorkExpInfoNew[indexPath.row]
} }
......
...@@ -434,7 +434,7 @@ private extension YHPreviewViewModel { ...@@ -434,7 +434,7 @@ private extension YHPreviewViewModel {
arr1.append(contentsOf: [tmp1,tmp2,tmp3,tmp4,tmp5,tmp6,tmp7,tmp8,tmp9,tmp10,tmp11,tmp12,tmp13,tmp14,tmp15,tmp16]) arr1.append(contentsOf: [tmp1,tmp2,tmp3,tmp4,tmp5,tmp6,tmp7,tmp8,tmp9,tmp10,tmp11,tmp12,tmp13,tmp14,tmp15,tmp16])
} }
let dataModel1 = YHWorkExpDataModel(title: "davidhuangTest1", data: arr1) let dataModel1 = YHWorkExpDataModel(title: "", data: arr1)
var arr2 : [YHPreviewQuestionAndAnswerModel] = [] var arr2 : [YHPreviewQuestionAndAnswerModel] = []
do { do {
...@@ -445,7 +445,7 @@ private extension YHPreviewViewModel { ...@@ -445,7 +445,7 @@ private extension YHPreviewViewModel {
arr2.append(contentsOf: [tmp1,tmp2,tmp3]) arr2.append(contentsOf: [tmp1,tmp2,tmp3])
} }
let dataModel2 = YHWorkExpDataModel(title: "davidhuangTest2", data: arr2) let dataModel2 = YHWorkExpDataModel(title: "", data: arr2)
var arr3 : [Any] = [] var arr3 : [Any] = []
do { do {
......
...@@ -64,14 +64,12 @@ private extension YHGCPreviewWorkExpViewController { ...@@ -64,14 +64,12 @@ private extension YHGCPreviewWorkExpViewController {
// MARK: - UITableViewDelegate 和 UITableViewDataSource // MARK: - UITableViewDelegate 和 UITableViewDataSource
extension YHGCPreviewWorkExpViewController { extension YHGCPreviewWorkExpViewController {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// return previewVM.arrDataForWorkExpInfo.count
return previewVM.arrDataForWorkExpInfoNew.count return previewVM.arrDataForWorkExpInfoNew.count
} }
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withClass: YHPreviewInfoCell.self) let cell = tableView.dequeueReusableCell(withClass: YHPreviewInfoCell.self)
cell.selectionStyle = .none cell.selectionStyle = .none
// cell.model = previewVM.arrDataForWorkExpInfo[indexPath.row]
if !previewVM.arrDataForWorkExpInfoNew.isEmpty,indexPath.row < previewVM.arrDataForWorkExpInfoNew.count { if !previewVM.arrDataForWorkExpInfoNew.isEmpty,indexPath.row < previewVM.arrDataForWorkExpInfoNew.count {
cell.model = previewVM.arrDataForWorkExpInfoNew[indexPath.row] cell.model = previewVM.arrDataForWorkExpInfoNew[indexPath.row]
} }
......
...@@ -428,7 +428,7 @@ private extension YHGCPreviewViewModel { ...@@ -428,7 +428,7 @@ private extension YHGCPreviewViewModel {
arr1.append(contentsOf: [tmp1,tmp2,tmp3,tmp4,tmp5,tmp6,tmp7,tmp8,tmp9,tmp10,tmp11,tmp12,tmp13,tmp14,tmp15,tmp16]) arr1.append(contentsOf: [tmp1,tmp2,tmp3,tmp4,tmp5,tmp6,tmp7,tmp8,tmp9,tmp10,tmp11,tmp12,tmp13,tmp14,tmp15,tmp16])
} }
let dataModel1 = YHWorkExpDataModel(title: "davidhuangTest1", data: arr1) let dataModel1 = YHWorkExpDataModel(title: "", data: arr1)
var arr2 : [YHPreviewQuestionAndAnswerModel] = [] var arr2 : [YHPreviewQuestionAndAnswerModel] = []
do { do {
...@@ -439,7 +439,7 @@ private extension YHGCPreviewViewModel { ...@@ -439,7 +439,7 @@ private extension YHGCPreviewViewModel {
arr2.append(contentsOf: [tmp1,tmp2,tmp3]) arr2.append(contentsOf: [tmp1,tmp2,tmp3])
} }
let dataModel2 = YHWorkExpDataModel(title: "davidhuangTest2", data: arr2) let dataModel2 = YHWorkExpDataModel(title: "", data: arr2)
var arr3 : [Any] = [] var arr3 : [Any] = []
do { do {
......
...@@ -62,10 +62,29 @@ class YHLiveMessageCell: UITableViewCell { ...@@ -62,10 +62,29 @@ class YHLiveMessageCell: UITableViewCell {
} }
} }
func configureNormalMessage(_ nickname: String, _ content: String, isAnchor: Bool) { func configureNormalMessage(_ nickname: String, _ content: String,highlightTxt : String = "", isAnchor: Bool = false) {
let nickAtt = isAnchor ? ASAttributedString(string: nickname + ":", .foreground(UIColor(hexString: "#FFE3BB") ?? UIColor.white), .font(UIFont.PFSC_R(ofSize: 13))) : ASAttributedString(string: nickname + ":", .foreground(UIColor.white.withAlphaComponent(0.65)), .font(UIFont.PFSC_R(ofSize: 13))) if highlightTxt.isEmpty {
let contentAtt = ASAttributedString(string: content, .foreground(UIColor.white), .font(UIFont.PFSC_R(ofSize: 13))) let nickAtt = isAnchor ? ASAttributedString(string: nickname + ":", .foreground(UIColor(hexString: "#FFE3BB") ?? UIColor.white), .font(UIFont.PFSC_R(ofSize: 13))) : ASAttributedString(string: nickname + ":", .foreground(UIColor.white.withAlphaComponent(0.65)), .font(UIFont.PFSC_R(ofSize: 13)))
contentLabel.attributed.text = nickAtt + contentAtt let contentAtt = ASAttributedString(string: content, .foreground(UIColor.white), .font(UIFont.PFSC_R(ofSize: 13)))
contentLabel.attributed.text = nickAtt + contentAtt
} else {
let nickAtt = isAnchor ? ASAttributedString(string: nickname + ":", .foreground(UIColor(hexString: "#FFE3BB") ?? UIColor.white), .font(UIFont.PFSC_R(ofSize: 13))) : ASAttributedString(string: nickname + ":", .foreground(UIColor.white.withAlphaComponent(0.65)), .font(UIFont.PFSC_R(ofSize: 13)))
var contentAtt = ASAttributedString(string: content, .foreground(UIColor.white), .font(UIFont.PFSC_R(ofSize: 13)))
if content.starts(with: highlightTxt, caseSensitive: false) {
contentAtt = ""
var content2 = content
let part1 = ASAttributedString(string: highlightTxt, .foreground(UIColor.white.withAlphaComponent(0.65)),.font(UIFont.PFSC_R(ofSize: 13)))
let part2Str = content2.slice(at: highlightTxt.count)
let part2 = ASAttributedString(string: part2Str, .foreground(UIColor.white),.font(UIFont.PFSC_R(ofSize: 13)))
contentLabel.attributed.text = nickAtt + part1 + part2
} else {
contentLabel.attributed.text = nickAtt + contentAtt
}
}
} }
func configureTipsMessage(_ tips: String) { func configureTipsMessage(_ tips: String) {
......
...@@ -110,15 +110,17 @@ extension YHLiveMessageListView: UITableViewDelegate, UITableViewDataSource { ...@@ -110,15 +110,17 @@ extension YHLiveMessageListView: UITableViewDelegate, UITableViewDataSource {
cell.contentView.transform = CGAffineTransform(rotationAngle: .pi) cell.contentView.transform = CGAffineTransform(rotationAngle: .pi)
var nickName: String = "" var nickName: String = ""
var content: String = "" var content: String = ""
var highlight : String = ""
if let ext = message.ext { if let ext = message.ext {
nickName = ext["fromNickName"] as? String ?? "YinHe" nickName = ext["fromNickName"] as? String ?? "YinHe"
highlight = ext["replyTo"] as? String ?? ""
} }
if let body = message.body as? EMTextMessageBody, body.type == .text { if let body = message.body as? EMTextMessageBody, body.type == .text {
printLog(body.text) printLog(body.text)
printLog("\(nickName) : \(body.text)") printLog("\(nickName) : \(body.text)")
content = body.text content = body.text
let isAnchor = nickName == anchorName let isAnchor = nickName == anchorName
cell.configureNormalMessage(nickName, content, isAnchor: isAnchor) cell.configureNormalMessage(nickName, content,highlightTxt: highlight, isAnchor: isAnchor)
} else if let body = message.body as? EMCustomMessageBody, body.event == YHChatRoomCustomLocal.tipsEvent, let customExt = body.customExt, let tips = customExt[YHChatRoomCustomLocal.tipsKey] { } else if let body = message.body as? EMCustomMessageBody, body.event == YHChatRoomCustomLocal.tipsEvent, let customExt = body.customExt, let tips = customExt[YHChatRoomCustomLocal.tipsKey] {
cell.configureTipsMessage(tips) cell.configureTipsMessage(tips)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment