import React from 'react'; import { View, I18nManager } from 'react-native'; import NoRatingElement from './NoRatingElement'; import { isAndroid } from '../helper/utils'; import { elementStyle } from '../theme/styles'; import type { HalfRatingProps } from '../types/ratingTypes'; const HalfRatingElement: React.FC = ({ size, children, enableMask, rtlMode, unratedColor, // fraction, // for exact fraction }) => { // (I18nManager.isRTL && !isRTL):- if whole app is RTL and user passed 'ltr' then gesture will work opposite const isOnlyRatingRTL = (rtlMode && !I18nManager.isRTL) || (I18nManager.isRTL && !rtlMode); const androidRTL = isAndroid && isOnlyRatingRTL; // when android RTL is device based or forced, it works different, so inverting the condition on that case const handleRtlAndroid = I18nManager.isRTL ? androidRTL : !androidRTL; let padding = React.isValidElement(children) && children?.props?.style?.width ? (size - children?.props.style.width) / 2 : 0; if (isNaN(padding)) { padding = 0; } return ( {/* TODO:- improve this so it can support wide varity of elements */} {enableMask ? ( {children} {children} ) : ( children )} ); }; export default React.memo(HalfRatingElement);