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

how to add icon beside see more/less text #39

Open
iamhaaamed opened this issue Aug 20, 2021 · 2 comments
Open

how to add icon beside see more/less text #39

iamhaaamed opened this issue Aug 20, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@iamhaaamed
Copy link

iamhaaamed commented Aug 20, 2021

how can I add icon beside see more/less text?
I have used customTextComponent like this:

<ReadMore seeMoreStyle={styles.button} seeLessStyle={styles.button} numberOfLines={3} customTextComponent={props => ( <> <Text {...props} /> <MaterialCommunityIcon name="chevron-down" size={Spacing.large} color={Colors.blueViolet} /> </> )}> {userInfo.about_me} </ReadMore>

but it's not working properly:
https://i.imgur.com/CktRJtN.png
https://i.imgur.com/HFHGHrq.png

@fawaz-ahmed
Copy link
Owner

fawaz-ahmed commented Aug 20, 2021

@iamhaamed To pass any custom text component, you pass like this
customTextComponent={Text}
It means it will use this component to display the underlying text.
Same component is then used to render the main text itself, see more text and see less text.

You can try this, though I haven't tested myself:

<ReadMore
  seeMoreStyle={styles.button}
  seeLessStyle={styles.button}
  numberOfLines={3}
  seeMoreText={(
    <>
      {'see more'}
      <MaterialCommunityIcon name="chevron-down" size={Spacing.large} color={Colors.blueViolet} />
    </>
  )}
  >
  {userInfo.about_me}
</ReadMore>

@iamhaaamed
Copy link
Author

iamhaaamed commented Aug 20, 2021

Thank you it is working now, but it seems we have alignment issue for See more because marginTop and paddingTop is not working properly:

<ReadMore seeMoreStyle={styles.button} seeLessStyle={styles.button} numberOfLines={3} seeMoreText={ <> <Text style={[styles.button]}>See more</Text> <View> <MaterialCommunityIcon style={{marginTop: Spacing.smallest}} name="chevron-down" size={Spacing.large} color={Colors.blueViolet} /> </View> </> } seeLessText={ <View style={{ flexDirection: 'row', justifyContent: 'center', alignItems: 'center', }}> <Text style={styles.button}>See less</Text> <MaterialCommunityIcon name="chevron-down" size={Spacing.large} color={Colors.blueViolet} /> </View> }> {userInfo.about_me} </ReadMore>

https://imgur.com/XfXUJUf

@fawaz-ahmed fawaz-ahmed added the enhancement New feature or request label May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants