fawaz-ahmed / react-native-read-more

React native library to show text in a condensed way and expand when needed. Drop in replacement for Text component and highly customizable. Can be used with expo or native cli for react native.
https://www.npmjs.com/package/@fawazahmed/react-native-read-more
MIT License
274 stars 37 forks source link

Support optional custom function when See More pressed #63

Closed ChrisLFieldsII closed 2 years ago

ChrisLFieldsII commented 2 years ago

Hello,

I am using this component in a project and it works perfectly!

There is one use case I needed and had to use patch-package to add for my project, and that is the ability to use a custom function when "See More" is clicked.

For example, when "See More" is clicked, instead of expanding text, open up a modal.

Here is an example video of this functionality.

Here is the patch that I applied to achieve this.

I can open up a PR if you believe this is functionality that would improve the package.

Thanks.

fawaz-ahmed commented 2 years ago

Hi @ChrisLFieldsII I like the idea. Also I reviewed the patch file and the video. Looks like a nice addition we can have.

I'd just say the name onToggle isn't a best fit. It should be something like blockedToggle or onSeeMoreBlocked or something which will indicate the purpose in a better way.

Having said that a PR would be highly appreciated!!

ChrisLFieldsII commented 2 years ago

I agree on the naming!

I can name it onSeeMoreBlocked and document that when a function is passed, this prop will disable the default See More toggling and use the custom callback instead.

I'll try to open a PR this weekend for it.

fawaz-ahmed commented 2 years ago

@ChrisLFieldsII wonderful.

Once you're about to raise a PR, just make sure to update these: 1 In package.json update version 2.3.5 to 2.3.6 2 Update the newly added prop in readme.md

Thanks,

fawaz-ahmed commented 2 years ago

Thanks @ChrisLFieldsII , the feature is published. Ver 2.3.6

ChrisLFieldsII commented 2 years ago

Awesome!

Thanks for the package, saved us quite a bit of time @fawaz-ahmed