Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New InputBarAccessoryView #83

Closed
nathantannar4 opened this issue Aug 25, 2017 · 8 comments
Closed

New InputBarAccessoryView #83

nathantannar4 opened this issue Aug 25, 2017 · 8 comments
Assignees
Milestone

Comments

@nathantannar4
Copy link
Member

A new re-written accessory view to be used to create robust and customizable MessageInputBar's

@SD10 SD10 added this to the 0.6.0 milestone Aug 25, 2017
@hyouuu
Copy link
Contributor

hyouuu commented Aug 26, 2017

1 minor issue I found with the current inputAccessoryView is that, if you return too many times that the textView expands above the screen top, you cannot scroll to the top of the message ;)

@nathantannar4
Copy link
Member Author

Yes that is not in the new one I made. There is a maxHeight variable that can be used to correct that

@hyouuu
Copy link
Contributor

hyouuu commented Aug 26, 2017

Cool - or make it scrollable if beyond screen?

@nathantannar4
Copy link
Member Author

Once it reaches the maxHeight the textview becomes scrollable. Same way the iMessage app works

@etoledom
Copy link
Contributor

When the textView grows and reaches maxHeight, after sending the message it doesn't go back to the original size.

@nathantannar4
Copy link
Member Author

nathantannar4 commented Aug 31, 2017

Good catch @etoledom . I have isolated the bug to changing the UITextView.isScrollEnabled: Bool property. For some reason it doesn't let the view resize, possibly due to the auto layout constraints? I am not sure.

This can be corrected by forcing a temp heightAnchor on the InputTextView.

Set the property in setupConstraints(): textViewLayoutSet?.height = textView.heightAnchor.constraint(equalToConstant: 36)
And modify textViewDidChange() to include: textViewLayoutSet?.height?.isActive = textView.text.isEmpty

@nathantannar4
Copy link
Member Author

nathantannar4 commented Sep 1, 2017

Never mind that has bugs, call textView.invalidateIntrinsicContentSize() in

override open var intrinsicContentSize: CGSize {
        let sizeToFit = textView.sizeThatFits(CGSize(width: textView.bounds.width, height: .greatestFiniteMagnitude))
        var heightToFit = sizeToFit.height.rounded() + padding.top + padding.bottom + separatorLine.frame.height + tableViewHeightConstant
        if heightToFit >= maxHeight {
            textView.isScrollEnabled = true
            heightToFit = maxHeight
        } else {
            textView.isScrollEnabled = false
            textView.invalidateIntrinsicContentSize()
        }
        let size = CGSize(width: bounds.width, height: heightToFit)
        if previousIntrinsicContentSize != size {
            delegate?.inputBar(self, didChangeIntrinsicContentTo: size)
        }
        previousIntrinsicContentSize = size
        return size
    }

@SD10
Copy link
Member

SD10 commented Sep 1, 2017

Closing this as it is being implemented in #80 👍 Great work @nathantannar4 🎉

@SD10 SD10 closed this as completed Sep 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants