Commit ccdc9079 authored by Steven杜宇's avatar Steven杜宇

// AI

parent 661245a8
...@@ -57,6 +57,11 @@ class YHAIMainChatViewController: YHBaseViewController { ...@@ -57,6 +57,11 @@ class YHAIMainChatViewController: YHBaseViewController {
} }
} }
} }
v.keyBoardChangeBlock = {
[weak self] isKeyBoardShow in
guard let self = self else { return }
self.scrollToBottom()
}
return v return v
}() }()
...@@ -94,10 +99,12 @@ class YHAIMainChatViewController: YHBaseViewController { ...@@ -94,10 +99,12 @@ class YHAIMainChatViewController: YHBaseViewController {
func scrollToBottom() { func scrollToBottom() {
self.tableView.reloadData { self.tableView.reloadData {
if self.messages.count > 0 {
let indexPath = IndexPath(row: self.messages.count-1, section: 0) let indexPath = IndexPath(row: self.messages.count-1, section: 0)
self.tableView.scrollToRow(at: indexPath, at: .bottom, animated: true) self.tableView.scrollToRow(at: indexPath, at: .bottom, animated: true)
} }
} }
}
func sendMessage(_ text: String) { func sendMessage(_ text: String) {
self.manager.getMainChatConversationId { self.manager.getMainChatConversationId {
......
...@@ -61,6 +61,11 @@ class YHAIRobotChatViewController: YHBaseViewController { ...@@ -61,6 +61,11 @@ class YHAIRobotChatViewController: YHBaseViewController {
} }
} }
} }
v.keyBoardChangeBlock = {
[weak self] isKeyBoardShow in
guard let self = self else { return }
self.scrollToBottom()
}
return v return v
}() }()
...@@ -106,10 +111,12 @@ class YHAIRobotChatViewController: YHBaseViewController { ...@@ -106,10 +111,12 @@ class YHAIRobotChatViewController: YHBaseViewController {
func scrollToBottom() { func scrollToBottom() {
self.tableView.reloadData { self.tableView.reloadData {
if self.messages.count > 0 {
let indexPath = IndexPath(row: self.messages.count-1, section: 0) let indexPath = IndexPath(row: self.messages.count-1, section: 0)
self.tableView.scrollToRow(at: indexPath, at: .bottom, animated: true) self.tableView.scrollToRow(at: indexPath, at: .bottom, animated: true)
} }
} }
}
func sendMessage(_ text: String) { func sendMessage(_ text: String) {
YHAIChatConfiguration.defaultConfig.removeThinkingMessageFromChatList(&messages) YHAIChatConfiguration.defaultConfig.removeThinkingMessageFromChatList(&messages)
......
...@@ -190,6 +190,7 @@ class YHAITabViewController: YHBaseViewController { ...@@ -190,6 +190,7 @@ class YHAITabViewController: YHBaseViewController {
@objc func didJumoToAIChat() { @objc func didJumoToAIChat() {
jumpToItemIndex(itemIndex: 1) jumpToItemIndex(itemIndex: 1)
mainChatVC.bottomInputView.showKeyBoard()
} }
} }
......
...@@ -129,6 +129,10 @@ class YHAITextInputView: UIView { ...@@ -129,6 +129,10 @@ class YHAITextInputView: UIView {
NotificationCenter.default.removeObserver(self) NotificationCenter.default.removeObserver(self)
} }
func showKeyBoard() {
self.textView.becomeFirstResponder()
}
func createUI() { func createUI() {
self.addSubview(whiteView) self.addSubview(whiteView)
...@@ -187,6 +191,8 @@ class YHAITextInputView: UIView { ...@@ -187,6 +191,8 @@ class YHAITextInputView: UIView {
} }
self.setNeedsLayout() self.setNeedsLayout()
self.layoutIfNeeded() self.layoutIfNeeded()
keyBoardChangeBlock?(isKeyboardShow)
} }
} }
} }
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