Browse Source

in landscape mode, take bottom safe area insets into account

cyberta 3 năm trước cách đây
mục cha
commit
1b0ba93b17
1 tập tin đã thay đổi với 14 bổ sung2 xóa
  1. 14 2
      deltachat-ios/Chat/ChatViewController.swift

+ 14 - 2
deltachat-ios/Chat/ChatViewController.swift

@@ -338,9 +338,15 @@ class ChatViewController: UITableViewController {
         }
         if !isDismissing {
             self.tableView.becomeFirstResponder()
+            var bottomInsets = self.messageInputBar.intrinsicContentSize.height + self.messageInputBar.keyboardHeight
+            if UIApplication.shared.statusBarOrientation.isLandscape,
+               let root = UIApplication.shared.keyWindow?.rootViewController {
+                // in landscape we need to take safeAreaInsets into account, in portrait they're already part of the keyboard height
+                bottomInsets += root.view.safeAreaInsets.bottom
+            }
             self.tableView.contentInset = UIEdgeInsets(top: self.getTopInsetHeight(),
                                                        left: 0,
-                                                       bottom: self.messageInputBar.intrinsicContentSize.height + self.messageInputBar.keyboardHeight,
+                                                       bottom: bottomInsets,
                                                        right: 0)
 
             if let msgId = self.highlightedMsg, self.messageIds.firstIndex(of: msgId) != nil {
@@ -1657,9 +1663,15 @@ extension ChatViewController: InputBarAccessoryViewDelegate {
         if isDismissing {
             return
         }
+        var bottomInsets = size.height + messageInputBar.keyboardHeight
+        if UIApplication.shared.statusBarOrientation.isLandscape,
+           let root = UIApplication.shared.keyWindow?.rootViewController {
+            // in landscape we need to take safeAreaInsets into account, in portrait they're already part of the keyboard height
+            bottomInsets += root.view.safeAreaInsets.bottom
+        }
         self.tableView.contentInset = UIEdgeInsets(top: self.getTopInsetHeight(),
                                                    left: 0,
-                                                   bottom: size.height + messageInputBar.keyboardHeight,
+                                                   bottom: bottomInsets,
                                                    right: 0)
         if isLastRowVisible() && !tableView.isDragging && !tableView.isDecelerating  && highlightedMsg == nil && !ignoreInputBarChange {
             scrollToBottom()