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

// AI

parent 91244bed
......@@ -347,43 +347,47 @@ extension YHAIMainChatViewController: UITableViewDelegate, UITableViewDataSource
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let message = messages[indexPath.row]
let msgType = message.getType()
if !message.isTextMessage() {
return UITableView.automaticDimension
}
let text = message.body.contentText // 要显示的文本内容
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
if 0 <= indexPath.row, indexPath.row < messages.count {
let message = messages[indexPath.row]
let msgType = message.getType()
if !message.isTextMessage() {
return UITableView.automaticDimension
}
let text = message.body.contentText // 要显示的文本内容
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
var textHeight = ceil(size.height)
if textHeight < 20.0 {
textHeight = 20.0
}
if message.isSelf || message.getType() == .recommendText {
return textHeight + 16.0*2 + 16.0
}
let complete = message.isDone
let isNeedShowCopyView = complete
let isNeedShowLoadingView = !complete
var resultHeight = textHeight+16.0*2.0
if isNeedShowLoadingView {
resultHeight += (18+6)
var textHeight = ceil(size.height)
if textHeight < 20.0 {
textHeight = 20.0
}
if message.isSelf || msgType == .recommendText {
return textHeight + 16.0*2 + 16.0
}
let complete = message.isDone
let isNeedShowCopyView = complete
let isNeedShowLoadingView = !complete
var resultHeight = textHeight+16.0*2.0
if isNeedShowLoadingView {
resultHeight += (18+6)
}
if isNeedShowCopyView {
resultHeight += (16+37)
} else {
resultHeight += 16
}
return resultHeight
}
if isNeedShowCopyView {
resultHeight += (16+37)
} else {
resultHeight += 16
}
return resultHeight
return UITableView.automaticDimension
}
......
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