Commit 0884fac0 authored by Steven杜宇's avatar Steven杜宇

// AI

parent 91244bed
...@@ -347,43 +347,47 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource ...@@ -347,43 +347,47 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let message = messages[indexPath.row] if 0 <= indexPath.row, indexPath.row < messages.count {
let msgType = message.getType() let message = messages[indexPath.row]
if !message.isTextMessage() { let msgType = message.getType()
return UITableView.automaticDimension if !message.isTextMessage() {
} return UITableView.automaticDimension
}
let text = message.body.contentText // 要显示的文本内容
let font = UIFont.PFSC_R(ofSize: 14) // 字体大小 let text = message.body.contentText // 要显示的文本内容
let maxWidth = KScreenWidth-20*2-16*2 // 最大宽度限制 let font = UIFont.PFSC_R(ofSize: 14) // 字体大小
let maxWidth = KScreenWidth-20*2-16*2 // 最大宽度限制
let attributes = [NSAttributedString.Key.font : font] as [NSAttributedString.Key : Any]
let size = (text as NSString).boundingRect(with: CGSize(width: maxWidth, height: .greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: attributes, context: nil).size let attributes = [NSAttributedString.Key.font : font] as [NSAttributedString.Key : Any]
let size = (text as NSString).boundingRect(with: CGSize(width: maxWidth, height: .greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: attributes, context: nil).size
var textHeight = ceil(size.height) var textHeight = ceil(size.height)
if textHeight < 20.0 { if textHeight < 20.0 {
textHeight = 20.0 textHeight = 20.0
} }
if message.isSelf || message.getType() == .recommendText { if message.isSelf || msgType == .recommendText {
return textHeight + 16.0*2 + 16.0 return textHeight + 16.0*2 + 16.0
} }
let complete = message.isDone let complete = message.isDone
let isNeedShowCopyView = complete let isNeedShowCopyView = complete
let isNeedShowLoadingView = !complete let isNeedShowLoadingView = !complete
var resultHeight = textHeight+16.0*2.0 var resultHeight = textHeight+16.0*2.0
if isNeedShowLoadingView { if isNeedShowLoadingView {
resultHeight += (18+6) resultHeight += (18+6)
}
if isNeedShowCopyView {
resultHeight += (16+37)
} else {
resultHeight += 16
}
return resultHeight
} }
if isNeedShowCopyView { return UITableView.automaticDimension
resultHeight += (16+37)
} else {
resultHeight += 16
}
return resultHeight
} }
......
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