this works but we need to expose also the maxCompressed height and the minHeight

This commit is contained in:
Mauro Romito
2022-11-10 15:41:36 +01:00
parent 49869ccd02
commit af2e9f2153
2 changed files with 26 additions and 13 deletions

View File

@@ -34,10 +34,7 @@ class WysiwygInputToolbarView: MXKRoomInputToolbarView, NibLoadable, HtmlRoomInp
// MARK: Private
private var keyboardHeight: CGFloat = .zero {
didSet {
let height = UIScreen.main.bounds.height
let finalHeight = height - keyboardHeight - 138
// TODO: Set the maxHeight in the wysiwygViewModel once exposed
return
updateTextViewHeight()
}
}
private var voiceMessageToolbarView: VoiceMessageToolbarView?
@@ -159,6 +156,7 @@ class WysiwygInputToolbarView: MXKRoomInputToolbarView, NibLoadable, HtmlRoomInp
name: UIResponder.keyboardWillShowNotification,
object: nil
)
NotificationCenter.default.addObserver(self, selector: #selector(deviceDidRotate), name: UIDevice.orientationDidChangeNotification, object: nil)
}
override func customizeRendering() {
@@ -169,6 +167,7 @@ class WysiwygInputToolbarView: MXKRoomInputToolbarView, NibLoadable, HtmlRoomInp
override func dismissKeyboard() {
self.viewModel.dismissKeyboard()
}
func showKeyboard() {
self.viewModel.showKeyboard()
@@ -187,6 +186,12 @@ class WysiwygInputToolbarView: MXKRoomInputToolbarView, NibLoadable, HtmlRoomInp
}
}
@objc private func deviceDidRotate(_ notification: Notification) {
DispatchQueue.main.async {
self.updateTextViewHeight()
}
}
private func updateToolbarHeight(wysiwygHeight: CGFloat) {
self.heightConstraint.constant = wysiwygHeight
toolbarViewDelegate?.roomInputToolbarView?(self, heightDidChanged: wysiwygHeight, completion: nil)
@@ -233,6 +238,14 @@ class WysiwygInputToolbarView: MXKRoomInputToolbarView, NibLoadable, HtmlRoomInp
wysiwygViewModel.textColor = theme.colors.primaryContent
}
private func updateTextViewHeight() {
let height = UIScreen.main.bounds.height
let barOffset: CGFloat = 68
let toolbarHeight: CGFloat = 118
let finalHeight = height - keyboardHeight - toolbarHeight - barOffset
wysiwygViewModel.maxExpandedHeight = finalHeight
}
// MARK: - HtmlRoomInputToolbarViewProtocol
var isEncryptionEnabled = false {
didSet {