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

"more" text alignment issue when we passed font size for more text #62

Closed patidararvind closed 1 year ago

patidararvind commented 2 years ago

Please could you give solution for that issue . Thanks Simulator Screen Shot - iPhone 13 - 2022-04-21 at 06 49 16

My code <ReadMore style={[styles.text, descText]} numberOfLines={numberOfLineDisplay} seeMoreText={'more'} seeLessText={'less'} seeMoreOverlapCount={0} allowFontScaling={false} // seeMoreStyle={styles.text} seeLessStyle={[styles.lessText, 'less']} seeMoreStyle={[styles.moreText, 'more']}> <ParsedText style={[styles.text, descriptionTxt]} parse={[ {pattern: tagRegex, renderText: renderTagText}, {pattern: urlRegex, renderText: renderURLText}, ]} childrenProps={{allowFontScaling: false}}> {descriptions} {/ {readMore ? descriptions : descriptions.substring(0, character)} /}

Style const styles = StyleSheet.create({ text: { fontSize: 16, paddingVertical: '2%', fontFamily: fonts.RRegular, color: colors.lightBlackColor, }, moreText: { color: 'gray', fontFamily: fonts.RRegular, fontSize: 12, }, lessText: { color: 'gray', fontSize: 12, }, });

fawaz-ahmed commented 2 years ago

Hi @patidararvind , thanks for sharing this. The styles you are passing seem to have a text value in the array:

seeLessStyle={[styles.lessText, 'less']}
seeMoreStyle={[styles.moreText, 'more']}

Can you please remove it and test ?

Replace:

seeLessStyle={[styles.lessText, 'less']}
seeMoreStyle={[styles.moreText, 'more']}

with

seeLessStyle={styles.lessText}
seeMoreStyle={styles.moreText}

In any case I will try to reproduce this (maybe over the weekend, cannot guarantee a timeline) and post back here. If the above fix resolves the issue, then please respond in the thread. Thanks,

fawaz-ahmed commented 1 year ago

Closing issue due to no response.