mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +08:00
Init Chat Logical Flow
This commit is contained in:
+12
@@ -21,6 +21,18 @@ extension InputEditView {
|
|||||||
cancellables.forEach { $0.cancel() }
|
cancellables.forEach { $0.cancel() }
|
||||||
cancellables.removeAll()
|
cancellables.removeAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func reset() {
|
||||||
|
text = ""
|
||||||
|
attachments = []
|
||||||
|
}
|
||||||
|
|
||||||
|
func duplicate() -> ViewModel {
|
||||||
|
let ans = ViewModel()
|
||||||
|
ans.text = text
|
||||||
|
ans.attachments = attachments
|
||||||
|
return ans
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+28
@@ -119,5 +119,33 @@ public class IntelligentsChatController: UIViewController {
|
|||||||
|
|
||||||
@objc func send() {
|
@objc func send() {
|
||||||
assert(Thread.isMainThread)
|
assert(Thread.isMainThread)
|
||||||
|
inputBox.isUserInteractionEnabled = false
|
||||||
|
progressView.startAnimating()
|
||||||
|
progressView.isHidden = false
|
||||||
|
progressView.alpha = 0
|
||||||
|
UIView.animate(withDuration: 0.3) {
|
||||||
|
self.inputBox.editor.alpha = 0
|
||||||
|
self.progressView.alpha = 1
|
||||||
|
} completion: { _ in
|
||||||
|
let viewModel = self.inputBox.editor.viewModel.duplicate()
|
||||||
|
self.inputBox.editor.viewModel.reset()
|
||||||
|
DispatchQueue.global().async {
|
||||||
|
self.sendSyncEx(viewModel: viewModel)
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
UIView.animate(withDuration: 0.3) {
|
||||||
|
self.inputBox.editor.alpha = 1
|
||||||
|
self.progressView.alpha = 0
|
||||||
|
} completion: { _ in
|
||||||
|
self.inputBox.isUserInteractionEnabled = true
|
||||||
|
self.progressView.stopAnimating()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func sendSyncEx(viewModel: InputEditView.ViewModel) {
|
||||||
|
let text = viewModel.text
|
||||||
|
let images = viewModel.attachments
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user