import React from 'react'; import {View, StyleSheet, ViewStyle} from 'react-native'; import Icon from './icon'; import {$Colors} from './style'; export type StarsProps = { starLevel: number; style?: ViewStyle; }; const stars = ['1', '2', '3', '4', '5']; const colors = [$Colors.fourth, $Colors.fourth, $Colors.fourth, $Colors.third, $Colors.secondary]; const Stars: React.FC = ({starLevel, style}) => { const level = Math.round(starLevel); const _color = colors[level-1]; return ( {stars.map((item, index) => ( index ? _color : $Colors.lighterText}]} key={item} /> ))} ); }; export default React.memo(Stars, (prev, next) => { return prev.starLevel === next.starLevel; }); const styles = StyleSheet.create({ wrapper: { display: 'flex', flexDirection: 'row', height: 12, }, star: { marginRight: 1, fontSize: 12, }, });