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

Changing access modifier of requiredInputTextViewHeight from public to open? #253

Open
MyAnJuN opened this issue Jan 19, 2024 · 5 comments

Comments

@MyAnJuN
Copy link

MyAnJuN commented Jan 19, 2024

1. my feature request related to a problem
i have a feature, that's adds a emojiButton into middleContentView. so i set a customeView which contains inputTextView and emojiButton,and call setMiddleContentView(self.customeView, animated: false). it works,but maxTextViewHeight = 88 did't works. so i read the source code, find that problem lies in the following code snipped.

IMG_79F91966B5C2-1

    public var requiredInputTextViewHeight: CGFloat {
        guard middleContentView == inputTextView else {
            return middleContentView?.intrinsicContentSize.height ?? 0
        }
        let maxTextViewSize = CGSize(width: inputTextView.bounds.width, height: .greatestFiniteMagnitude)
        return inputTextView.sizeThatFits(maxTextViewSize).height.rounded(.down)
    }

2. solution
Because i set customeView so middleContentView == inputTextView alwals false. so i need override this requiredInputTextViewHeight property in the following code snipped.

    public var requiredInputTextViewHeight: CGFloat {
        let maxTextViewSize = CGSize(width: inputTextView.bounds.width, height: .greatestFiniteMagnitude)
        return inputTextView.sizeThatFits(maxTextViewSize).height.rounded(.down)
    }

but it's access modifier is public, so can changing it to open?

@nathantannar4
Copy link
Owner

It is expected that custom views provide an intrinsicContentSize. Are you able to implement intrinsicContentSize on your custom view?

@MyAnJuN
Copy link
Author

MyAnJuN commented Feb 1, 2024

Currently, my custom view is not defined as a separate class. It is just defined as a UIView. Are you suggesting that I need to create a custom class that inherits from InputTextView and override intrinsicContentSize?

@nathantannar4
Copy link
Owner

You don't need to inherit from InputTextView, you can just inherit from UIView

@MyAnJuN
Copy link
Author

MyAnJuN commented Feb 2, 2024

After applying the suggested modifications, the intrinsicContentSize of the custom view limits the height. However, the height of the view still increases as the input text grows in UI.

    override var intrinsicContentSize: CGSize {
        let maxTextViewSize = CGSize(width: inputTextView.bounds.width, height: .greatestFiniteMagnitude)
        let height = inputTextView.sizeThatFits(maxTextViewSize).height.rounded(.down)
        return CGSize(width: size.width, height: min(height, 88))
    }

@nathantannar4
Copy link
Owner

Sorry I'm unclear as to what the problem is and what you have changed.

However, the height of the view still increases as the input text grows in UI

Are you trying to limit how high the input text view can grow?

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

No branches or pull requests

2 participants