-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRating.js
32 lines (28 loc) · 864 Bytes
/
Rating.js
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
import React, { useState } from 'react';
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
import { FontAwesome } from '@expo/vector-icons';
import { tw } from 'react-native-tailwindcss';
const Rating = ({ rating }) => {
const [selectedRating, setSelectedRating] = useState(rating);
const handleRating = (selected) => {
setSelectedRating(selected);
};
return (
<View style={tw.flexRow}>
{[1, 2, 3, 4, 5].map((star) => (
<TouchableOpacity
key={star}
style={[tw.mR2]}
onPress={() => handleRating(star)}
>
<FontAwesome
name={star <= selectedRating ? 'star' : 'star-o'}
size={24}
color={star <= selectedRating ? '#FFD700' : 'black'}
/>
</TouchableOpacity>
))}
</View>
);
};
export default Rating;