|
@@ -63,13 +63,6 @@ class ChatViewController: UITableViewController {
|
|
lazy var navBarTap: UITapGestureRecognizer = {
|
|
lazy var navBarTap: UITapGestureRecognizer = {
|
|
UITapGestureRecognizer(target: self, action: #selector(chatProfilePressed))
|
|
UITapGestureRecognizer(target: self, action: #selector(chatProfilePressed))
|
|
}()
|
|
}()
|
|
-
|
|
|
|
- private lazy var scrollDownButton: UIButton = {
|
|
|
|
- let button = UIButton(frame: .zero)
|
|
|
|
- button.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
- button.addTarget(self, action: #selector(onScrollDownButtonPressed), for: .touchUpInside)
|
|
|
|
- return button
|
|
|
|
- }()
|
|
|
|
|
|
|
|
private var locationStreamingItem: UIBarButtonItem = {
|
|
private var locationStreamingItem: UIBarButtonItem = {
|
|
let indicator = LocationStreamingIndicator()
|
|
let indicator = LocationStreamingIndicator()
|
|
@@ -340,7 +333,7 @@ class ChatViewController: UITableViewController {
|
|
self.highlightedMsg = nil
|
|
self.highlightedMsg = nil
|
|
self.isInitial = false
|
|
self.isInitial = false
|
|
self.ignoreInputBarChange = false
|
|
self.ignoreInputBarChange = false
|
|
- self.scrollDownButton.isHidden = self.isLastRowVisible()
|
|
|
|
|
|
+ self.messageInputBar.scrollDownButton.isHidden = self.isLastRowVisible()
|
|
}
|
|
}
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
@@ -441,10 +434,6 @@ class ChatViewController: UITableViewController {
|
|
}
|
|
}
|
|
|
|
|
|
handleUserVisibility(isVisible: true)
|
|
handleUserVisibility(isVisible: true)
|
|
- if let view = UIApplication.shared.keyWindow {
|
|
|
|
- view.addSubview(scrollDownButton)
|
|
|
|
- setupScrollDownButton()
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
override func viewWillDisappear(_ animated: Bool) {
|
|
override func viewWillDisappear(_ animated: Bool) {
|
|
@@ -476,10 +465,6 @@ class ChatViewController: UITableViewController {
|
|
nc.removeObserver(self, name: UIApplication.willResignActiveNotification, object: nil)
|
|
nc.removeObserver(self, name: UIApplication.willResignActiveNotification, object: nil)
|
|
audioController.stopAnyOngoingPlaying()
|
|
audioController.stopAnyOngoingPlaying()
|
|
|
|
|
|
-
|
|
|
|
- if let view = UIApplication.shared.keyWindow, scrollDownButton.isDescendant(of: view) {
|
|
|
|
- scrollDownButton.removeFromSuperview()
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
|
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
|
@@ -617,7 +602,7 @@ class ChatViewController: UITableViewController {
|
|
showAvatar: showAvatar,
|
|
showAvatar: showAvatar,
|
|
showName: showName)
|
|
showName: showName)
|
|
|
|
|
|
- scrollDownButton.isHidden = isLastRowVisible()
|
|
|
|
|
|
+ messageInputBar.scrollDownButton.isHidden = isLastRowVisible()
|
|
|
|
|
|
return cell
|
|
return cell
|
|
}
|
|
}
|
|
@@ -735,7 +720,6 @@ class ChatViewController: UITableViewController {
|
|
}
|
|
}
|
|
|
|
|
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
|
- scrollDownButton.layer.borderColor = DcColors.colorDisabled.cgColor
|
|
|
|
messageInputBar.inputTextView.layer.borderColor = DcColors.colorDisabled.cgColor
|
|
messageInputBar.inputTextView.layer.borderColor = DcColors.colorDisabled.cgColor
|
|
}
|
|
}
|
|
|
|
|
|
@@ -839,8 +823,7 @@ class ChatViewController: UITableViewController {
|
|
return tableView.indexPathsForVisibleRows?.contains(lastIndexPath) ?? false
|
|
return tableView.indexPathsForVisibleRows?.contains(lastIndexPath) ?? false
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- @objc func onScrollDownButtonPressed() {
|
|
|
|
|
|
+ private func scrollToBottom() {
|
|
scrollToBottom(animated: true)
|
|
scrollToBottom(animated: true)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -942,6 +925,7 @@ class ChatViewController: UITableViewController {
|
|
if let inputTextView = messageInputBar.inputTextView as? ChatInputTextView {
|
|
if let inputTextView = messageInputBar.inputTextView as? ChatInputTextView {
|
|
inputTextView.imagePasteDelegate = self
|
|
inputTextView.imagePasteDelegate = self
|
|
}
|
|
}
|
|
|
|
+ messageInputBar.onScrollDownButtonPressed = scrollToBottom
|
|
}
|
|
}
|
|
|
|
|
|
private func evaluateInputBar(draft: DraftModel) {
|
|
private func evaluateInputBar(draft: DraftModel) {
|
|
@@ -1000,21 +984,6 @@ class ChatViewController: UITableViewController {
|
|
item.backgroundColor = DcColors.colorDisabled
|
|
item.backgroundColor = DcColors.colorDisabled
|
|
})}
|
|
})}
|
|
}
|
|
}
|
|
-
|
|
|
|
- func setupScrollDownButton() {
|
|
|
|
- NSLayoutConstraint.activate([
|
|
|
|
- scrollDownButton.constraintAlignBottomTo(tableView, paddingBottom: 64),
|
|
|
|
- scrollDownButton.constraintAlignTrailingTo(tableView, paddingTrailing: 12),
|
|
|
|
- scrollDownButton.constraintHeightTo(40),
|
|
|
|
- scrollDownButton.constraintWidthTo(40)
|
|
|
|
- ])
|
|
|
|
- scrollDownButton.backgroundColor = DcColors.defaultBackgroundColor
|
|
|
|
- scrollDownButton.setImage(UIImage(named: "ic_scrolldown")?.sd_tintedImage(with: .systemBlue), for: .normal)
|
|
|
|
- scrollDownButton.layer.cornerRadius = 20
|
|
|
|
- scrollDownButton.layer.borderColor = DcColors.colorDisabled.cgColor
|
|
|
|
- scrollDownButton.layer.borderWidth = 1
|
|
|
|
- scrollDownButton.layer.masksToBounds = true
|
|
|
|
- }
|
|
|
|
|
|
|
|
@objc private func chatProfilePressed() {
|
|
@objc private func chatProfilePressed() {
|
|
if chatId != DC_CHAT_ID_DEADDROP {
|
|
if chatId != DC_CHAT_ID_DEADDROP {
|