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

Consider custom middleContentView height #265

Merged
merged 2 commits into from
Oct 15, 2024

Conversation

PhilipDukhov
Copy link
Contributor

@PhilipDukhov PhilipDukhov commented Jul 19, 2024

This fixes #264

I'm not sure if it's a proper fix for the library, but it works good in my case.

I believe the code above the fix is still needed to manage inputTextView.isScrollEnabled state with the height constraint, so it shouldn't be placed in else statement.

var inputTextViewHeight = requiredInputTextViewHeight
if inputTextViewHeight >= maxTextViewHeight {
if !isOverMaxTextViewHeight {
textViewHeightAnchor?.isActive = true
inputTextView.isScrollEnabled = true
isOverMaxTextViewHeight = true
}
inputTextViewHeight = maxTextViewHeight
} else {
if isOverMaxTextViewHeight {
textViewHeightAnchor?.isActive = false || shouldForceTextViewMaxHeight
inputTextView.isScrollEnabled = false
isOverMaxTextViewHeight = false
inputTextView.invalidateIntrinsicContentSize()
}
}


if let middleContentView, middleContentView != inputTextView {
inputTextViewHeight = middleContentView.intrinsicContentSize.height
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I think this is right. Replacing the middle content view is def very experimental, and this was a missed edge case.

I think we should optimize this tho, so that we skip calculating inputTextViewHeight if the middleContentView != inputTextView

@PhilipDukhov
Copy link
Contributor Author

I think we should optimize this tho, so that we skip calculating inputTextViewHeight if the middleContentView != inputTextView

you mean caching middleContentView.intrinsicContentSize operation result?

do you think it should be done in this PR?

Even with your approval I don't have access to merge this in

@PhilipDukhov
Copy link
Contributor Author

@nathantannar4 please check the last comment!

@nathantannar4 nathantannar4 merged commit 215edf4 into nathantannar4:master Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom middleContentView height is not considered
2 participants