-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathRating.js
More file actions
46 lines (41 loc) · 1.14 KB
/
Rating.js
File metadata and controls
46 lines (41 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React from 'react';
import PropTypes from 'prop-types';
import { AirbnbRating } from 'react-native-ratings';
import {
View, StyleSheet, Text
} from 'react-native';
export default function Rating(props) {
const {
name, meta, style, value = 0, onChangeInputValue, isMandatory
} = props;
const recordRating = rating => onChangeInputValue(rating);
return (
<View key={name} style={{borderWidth:0, alignItems:'flex-start'}}>
<Text style={styles.text}>{`${meta.label} ${isMandatory ? '*' : ''}`}</Text>
<AirbnbRating
isDisabled={meta.disabled}
onFinishRating={recordRating}
starContainerStyle={[ style, styles.rating, {borderWidth:0, marginTop:15, marginLeft:15} ]}
count={meta.count || 5}
defaultRating={value}
showRating={false}
size={30}
/>
</View>
);
}
const styles = StyleSheet.create({
text: {
marginLeft: 10,
marginTop: 10,
},
rating: {
}
});
Rating.propTypes = {
name: PropTypes.string.isRequired,
meta: PropTypes.object.isRequired,
style: PropTypes.object,
onChangeInputValue: PropTypes.func,
isMandatory: PropTypes.bool
};