Revert "The topbar in chatConversationViewSwift remains displayed when the keyboard is open"

This reverts commit 3265e27eb1.
This commit is contained in:
Benoit Martins 2023-07-20 10:29:27 +02:00
parent 806975edeb
commit 5113a74839
2 changed files with 19 additions and 34 deletions

View file

@ -24,7 +24,6 @@ import DropDown
import PhotosUI
import AVFoundation
import EmojiPicker
import IQKeyboardManager
class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControllerDelegate, UIDocumentPickerDelegate, UICompositeViewDelegate, UICollectionViewDataSource, UICollectionViewDelegate, UIImagePickerControllerDelegate, EmojiPickerDelegate, CoreDelegate & UINavigationControllerDelegate{ // Replaces ChatConversationView
@ -316,10 +315,6 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll
}
*/
}
override func viewDidAppear(_ animated: Bool) {
IQKeyboardManager.shared().isEnabled = false
}
override func viewWillDisappear(_ animated: Bool) {
if friendDelegate != nil {

View file

@ -82,11 +82,6 @@ class BackActionsNavigationView: UIViewController {
var stackView = UIStackView()
var stackViewReply = UIStackView()
let keyWindow = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
var constraintKeyboard : NSLayoutConstraint? = nil
var constraintKeyboardHidden : NSLayoutConstraint? = nil
func viewDidLoad(backAction : @escaping () -> Void,
action1 : @escaping () -> Void,
@ -100,6 +95,7 @@ class BackActionsNavigationView: UIViewController {
self.action2 = action2
self.view.addSubview(topBar)
//topBar.alignParentTop().height(top_bar_height).matchParentSideBorders().done()
topBar.alignParentTop().height(top_bar_height).done()
topBar.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor).isActive = true
topBar.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor).isActive = true
@ -169,20 +165,15 @@ class BackActionsNavigationView: UIViewController {
stackView.alignment = .center;
stackView.spacing = 1;
//stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(stackView)
stackView.alignParentTop().done()
if keyWindow != nil && keyWindow!.safeAreaInsets.bottom != 0.0 {
if constraintKeyboardHidden == nil {
constraintKeyboardHidden = stackView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: -keyWindow!.safeAreaInsets.bottom/2)
}
constraintKeyboardHidden?.isActive = true
//stackView.alignParentTop().alignParentBottom().matchParentSideBorders().done()
let keyWindow = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
if keyWindow != nil {
stackView.alignParentTop().alignParentBottom(withMargin: keyWindow!.safeAreaInsets.top/3).done()
}else{
if constraintKeyboardHidden == nil {
constraintKeyboardHidden = stackView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor)
}
constraintKeyboardHidden?.isActive = true
stackView.alignParentTop().alignParentBottom().done()
}
stackView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor).isActive = true
stackView.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor).isActive = true
@ -257,8 +248,8 @@ class BackActionsNavigationView: UIViewController {
mediaSelector.isHidden = true
stackView.addArrangedSubview(messageView)
if keyWindow != nil && keyWindow!.safeAreaInsets.bottom != 0.0 {
message_height = 66 - ((keyWindow!.safeAreaInsets.bottom/2)/2)
if keyWindow != nil {
message_height = 66 - ((keyWindow!.safeAreaInsets.top/3)/2)
}
messageView.alignParentBottom().height(message_height).matchParentSideBorders().done()
@ -448,22 +439,21 @@ class BackActionsNavigationView: UIViewController {
}
@objc func keyboardWillShow(notification: NSNotification) {
if constraintKeyboardHidden?.isActive != false {
constraintKeyboardHidden?.isActive = false
if let keyboardSize = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
constraintKeyboard = stackView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -keyboardSize.height)
constraintKeyboard?.isActive = true
} else {
constraintKeyboard = stackView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
constraintKeyboard?.isActive = true
if let keyboardSize = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
if topBar.frame.origin.y == 0 {
let keyWindow = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
if keyWindow != nil {
topBar.frame.origin.y += keyboardSize.height - keyWindow!.safeAreaInsets.top/3
}else{
topBar.frame.origin.y += keyboardSize.height
}
}
}
}
@objc func keyboardWillHide(notification: NSNotification) {
if constraintKeyboard?.isActive != false {
constraintKeyboard?.isActive = false
constraintKeyboardHidden?.isActive = true
if topBar.frame.origin.y != 0 {
topBar.frame.origin.y = 0
}
}
}