Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ please refer to [react-native-vector-icons installation guide](https://github.co

|Prop|Type|Description|Required|Default|
|---|---|---|---|---|
|**`testID`**|`string`|A unique identifier for this element to be used in UI Automation testing scripts. Each star can be accessed depending on its index. For example: `star-0`.|`No`|`undefined`|
|**`activeOpacity`**|`number`|Number between 0 a 1 to determine the opacity of the button.|`No`|`0.2`|
|**`animation`**|`string`|Add an animation to the stars when upon selection. Refer to [react-native-animatable](https://github.com/oblador/react-native-animatable) for the different animation types.|`No`|`undefined`|
|**`buttonStyle`**|`ViewPropTypes.style`|Style of the button containing the star.|`No`|*`{}`*|
Expand Down
4 changes: 4 additions & 0 deletions StarButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const iconSets = {
};

const propTypes = {
testID: ViewPropTypes.testID,
buttonStyle: ViewPropTypes.style,
disabled: PropTypes.bool.isRequired,
halfStarEnabled: PropTypes.bool.isRequired,
Expand Down Expand Up @@ -97,6 +98,7 @@ class StarButton extends Component {

renderIcon() {
const {
testID,
reversed,
starColor,
starIconName,
Expand All @@ -117,6 +119,7 @@ class StarButton extends Component {
if (typeof starIconName === 'string') {
iconElement = (
<Icon
testID={testID}
name={starIconName}
size={starSize}
color={starColor}
Expand All @@ -137,6 +140,7 @@ class StarButton extends Component {

iconElement = (
<Image
testID={testID}
source={starIconName}
style={iconStyles}
/>
Expand Down
7 changes: 6 additions & 1 deletion StarRating.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const ANIMATION_TYPES = [
];

const propTypes = {
testID: PropTypes.string,
activeOpacity: PropTypes.number,
animation: PropTypes.oneOf(ANIMATION_TYPES),
buttonStyle: ViewPropTypes.style,
Expand Down Expand Up @@ -57,6 +58,7 @@ const propTypes = {
};

const defaultProps = {
testID: undefined,
activeOpacity: 0.2,
animation: undefined,
buttonStyle: {},
Expand Down Expand Up @@ -95,6 +97,7 @@ class StarRating extends Component {

render() {
const {
testID,
activeOpacity,
animation,
buttonStyle,
Expand Down Expand Up @@ -145,9 +148,11 @@ class StarRating extends Component {
const starButtonElement = (
<AnimatableView
key={i}
test
ref={(node) => { this.starRef.push(node); }}
>
<StarButton
testID={`${testID}-${i}`}
activeOpacity={activeOpacity}
buttonStyle={buttonStyle}
disabled={disabled}
Expand Down Expand Up @@ -177,7 +182,7 @@ class StarRating extends Component {
}

return (
<View style={newContainerStyle} pointerEvents={disabled ? 'none' : 'auto'}>
<View style={newContainerStyle} pointerEvents={disabled ? 'none' : 'auto'} testID={testID}>
{starButtons}
</View>
);
Expand Down