ChatSecure / ChatSecure-iOS

ChatSecure is a free and open source encrypted chat client for iOS that supports OTR and OMEMO encryption over XMPP.
https://chatsecure.org
Other
3.13k stars 1.03k forks source link

Fix safeAreaInsets in JSQMessagesViewController for iPhone X support #874

Open chrisballinger opened 7 years ago

chrisballinger commented 7 years ago

For an example, see the below picture where the messageInputBar overlaps the new "home button bar" area.

screen shot 2017-10-31 at 4 41 24 pm
chrisballinger commented 7 years ago

For reference: https://github.com/MessageKit/MessageKit/blob/9ff1a122c33231d88a4654e1b11b85e1bb0ccf08/Sources/Controllers/MessagesViewController.swift#L130

    /// Sets the constraints of the `MessagesCollectionView`.
    private func setupConstraints() {
        messagesCollectionView.translatesAutoresizingMaskIntoConstraints = false

        let top = messagesCollectionView.topAnchor.constraint(equalTo: view.topAnchor, constant: topLayoutGuide.length)
        let bottom = messagesCollectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
        if #available(iOS 11.0, *) {
            let leading = messagesCollectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor)
            let trailing = messagesCollectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor)
            NSLayoutConstraint.activate([top, bottom, trailing, leading])
        } else {
            let leading = messagesCollectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor)
            let trailing = messagesCollectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor)
            NSLayoutConstraint.activate([top, bottom, trailing, leading])
        }
    }
JonyMateos commented 4 years ago

The previous solution doesn't seem to work with Objective-C.

I've found a different workaround, here are the steps: