react-native-ratings icon indicating copy to clipboard operation
react-native-ratings copied to clipboard

How to give space between two stars in react-native-ratings

Open nihp opened this issue 6 years ago • 27 comments

How to give space between two stars in react-native-ratings.

I have give padding, marginLeft and marginRight. But there is no way to give space between two elements.

nihp avatar Oct 31 '18 08:10 nihp

Same issue, need some padding between starts

arifo avatar Oct 31 '18 15:10 arifo

I don't think there is a way to do that right now, but should be easy enough with a containerProp. I can add that in the next release.. maybe this weekend?

Monte9 avatar Oct 31 '18 17:10 Monte9

just for the info: I have also noticed that in line 154 at rating.js styles.starContainer has not been defined https://github.com/Monte9/react-native-ratings/blob/93327ad36c2ac488a4431bb2fdbd90d56379ed0c/src/rating.js#L154

arifo avatar Oct 31 '18 17:10 arifo

Ah good catch. @arifo if you know what you need to do, can you submit a PR?

Monte9 avatar Oct 31 '18 19:10 Monte9

any updates on this?

a-eid avatar Nov 30 '18 07:11 a-eid

@Monte9 I really need to be able to add some padding between a custom .png i'm using (just like you'd do with stars). I've modified my .png file to create space to the left and right of my icon, but in the <Rating> component, they're still squished together. Please update in a new release!

chai86 avatar Oct 30 '19 22:10 chai86

@Monte9 I see you m8, try: containerStyle={{width:140}} maybe wrap it into a view if you need to move it a bit more (the component as a whole)

just found this out 2 mins ago so im not too sure how viable or flexable this is.

MannySauce avatar Oct 31 '19 03:10 MannySauce

@Monte9 && @chai86 I see you m8, try: containerStyle={{width:140}} maybe wrap it into a view if you need to move it a bit more (the component as a whole)

just found this out 2 mins ago so im not too sure how viable or flexable this is.

MannySauce avatar Oct 31 '19 03:10 MannySauce

@Monte9 && @chai86 I see you m8, try: containerStyle={{width:140}} maybe wrap it into a view if you need to move it a bit more (the component as a whole) just found this out 2 mins ago so im not too sure how viable or flexable this is.

Nope, any other ideas?

chai86 avatar Oct 31 '19 18:10 chai86

A part solution: The .png has to be a square. For example 256 x256 pixels, and some filler colour can be added to the sides of the image. However to add additional padding in the react-native-ratings module....remains to be resolved.

chai86 avatar Nov 01 '19 20:11 chai86

If you can sacrifice the pan gesture and will be okay with tap gesture then use AirbnbRating. Then in "node_modules/react-native-ratings/src/components/Star.js" add desired margin in styles variable defined at last.

const styles = StyleSheet.create( { starStyle: { margin: 3 } } );

3 is the default value but you can change it with your desired value.

anilkumartudu avatar Dec 20 '19 07:12 anilkumartudu

@anilkumartudu We should not modify it in node_modules

mrinal-roy avatar Jan 23 '20 06:01 mrinal-roy

@mrinal-roy-au2 Sorry my bad i totally understand you should not modify node-modules. So let me rephrase it a bit you can clone this repository, apply your changes and add your git URL as a dependency in package.json.

anilkumartudu avatar Jan 23 '20 06:01 anilkumartudu

@anilkumartudu Thanks. I forked and applied my changes and committed & pushed to my git repo. Now how will npm recognise my forked and committed repo through the package.json file dependency if it is not approved by npm? Will I have to first raise a PR and get PR approved by merging changes in the original npm repo? @Monte9 could you please reply to above question? (Whoever can at the earliest please). I have to deliver a build which can be done with my forked and changed files; but my colleagues cannot have it in their machines if it is not through npm library; so need this clarification how to go about it...

mrinal-roy avatar Jan 23 '20 10:01 mrinal-roy

@mrinal-roy-au2 Okay, so after applying changes and committing it to your repo just follow up this process. Hope this help you.

anilkumartudu avatar Jan 23 '20 11:01 anilkumartudu

Thank you @anilkumartudu very useful feature you shared and I am through with our application implementation !

mrinal-roy avatar Jan 23 '20 14:01 mrinal-roy

@mrinal-roy-au2 Glad to know that i was able to help you.

anilkumartudu avatar Jan 23 '20 14:01 anilkumartudu

@nihp , Have you tried with starStyle attribute for giving particular star style?

TrushalRank avatar May 27 '20 08:05 TrushalRank

@TrushalRank Rating component does not have starStyle props. It's for AirbnbRating component only.

bravemaster619 avatar Jun 26 '20 07:06 bravemaster619

I have fixed the space issue between stars. Set width in starContainerStyle with whatever you want. And justifyContent: 'space-between'. Looks great!

jingyazh avatar Jul 21 '21 14:07 jingyazh

I have a solution for this issue just provide a width to starContainerStyle according to you and add justifyContent: 'space-between' in starContainerStyle it will perfect for Eg => starContainerStyle={{ marginTop: hp('2%'), justifyContent: 'space-between', width: '80%', }}

hapSa000 avatar Dec 18 '21 11:12 hapSa000

I have fixed the space issue between stars. Set width in starContainerStyle with whatever you want. And justifyContent: 'space-between'. Looks great!

give the width to it like
width: 400, justifyContent: "space-evenly",

Dasu-Uthpala avatar Mar 03 '22 16:03 Dasu-Uthpala

@jingyazh @hapSa000 @Dasu-Uthpala i've tried the solution but i ended up getting like this, any idea to fix this anyone ? https://ibb.co/kQth1mN

iyadztabika avatar Apr 07 '22 02:04 iyadztabika

@iyadztabika starStyle did the trick for me.

This prop is not mentioned in the doc but was added in 2021 (see https://github.com/Monte9/react-native-ratings/issues/53).

https://github.com/Monte9/react-native-ratings/blob/854099c8b4a9b3215d51f8d60dff793e5775f96a/src/components/Star.tsx#L21

<AirbnbRating
  showRating={ false }
  defaultRating={ rating }
  starImage={ STAR_IMAGE }
  selectedColor={ selectedIconColor }
  size={ iconSize }
  starStyle={{ margin: X }} 👈 
  isDisabled
/>

pierregambaud avatar May 04 '22 14:05 pierregambaud

just do it. It will work for you starContainerStyle={{ width: 300, justifyContent: 'space-between' }}

MahmudHasanMenon avatar Jun 11 '22 08:06 MahmudHasanMenon

starContainerStyle={{ width: '100%', justifyContent: 'space-between', }}

AbdullahTechxpert avatar Sep 16 '22 12:09 AbdullahTechxpert

Just saying AbdullahTechxpert if you were to just copy-paste and change the CSS width format to "100%" from MahmudHasanMenon might as well have at least have had the common courtesy of adding the code styling to the response, sloppy way to plagiarise... and personally this solution didn't work for me :/ 🤔

ramirezStefano avatar Aug 26 '23 22:08 ramirezStefano