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

Feature: support for passing element instead of images.

Open ritz078 opened this issue 7 years ago • 6 comments

ritz078 avatar Oct 21 '17 16:10 ritz078

Any particular use case? @ritz078

f0rr0 avatar Nov 07 '17 03:11 f0rr0

I want to use react-native-vector-icon instead of images. So I will need to pass the element.

ritz078 avatar Nov 10 '17 08:11 ritz078

I also need this so I can change the tintColor of the image I'm passing. I'd prefer it to be a component though, rather than an element, that leaves one with even more flexibility:

const star = require('./my-star.png');

<Rating
  selectedStar={() => <Image source={star} style={{ tintColor: 'yellow' }} />}
  unselectedStar={() => <Image source={star} style={{ tintColor: 'black' }} />}
/>

mxstbr avatar Dec 02 '17 19:12 mxstbr

@ritz078 @mxstbr how do you propose to handle the sizing of the supplied component? Currently, the rating component accepts a starStyle prop which handles the styling. To accommodate the supplied image component, the parent view needs to be of similar dimensions.

f0rr0 avatar Dec 03 '17 00:12 f0rr0

Hi, I created a pull request for this here: PR, I simply allow the props to either be an image or an element.

Sample usage:

import Icon from 'react-native-vector-icons/FontAwesome';

<Rating
  ...
  selectedStar={<Icon name="star" size={iconSize ? iconSize : 25} color="#EFB881" />}
  unselectedStar={<Icon name="star" size={iconSize ? iconSize : 25} color="#C9C9C9" />}
/>

jeffraux avatar Sep 06 '18 05:09 jeffraux

@jeffraux apologies for not seeing this earlier, I will get back to you on the PR by the end of this week. Currently on vacay. Thank you for taking this up

f0rr0 avatar Nov 13 '18 00:11 f0rr0