import React, { FC, useContext, useMemo } from 'react'; import { View } from 'react-native'; import { DownTail, UpTail } from './Shape'; import styles from './styles'; import { BadgeRibbonProps } from './types'; import { ApplicationContext, MiniAppContext } from '../Context'; import { Text } from '../Text'; import { Colors } from '../Consts'; import { Image } from '../Image'; const BadgeRibbon: FC = ({ position = 'top_right', label = 'Label', isRound = false, style = {}, }) => { const { theme } = useContext(ApplicationContext); const context = useContext(MiniAppContext); const isRight = position === 'top_right' || position === 'bottom_right'; const isUpTail = position === 'bottom_left' || position === 'top_right'; const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false; const ribbonRotate = useMemo(() => (isRight ? '180deg' : '0deg'), [isRight]); const textRotate = ribbonRotate; const textMargin = useMemo(() => (isUpTail ? 4 : 0), [isUpTail]); const skewMargin = textMargin; const ribbonTransform = useMemo( () => [{ rotateZ: ribbonRotate }], [ribbonRotate], ); const textTransform = useMemo(() => [{ rotateZ: textRotate }], [textRotate]); const ribbonTail = isUpTail ? : ; const renderRoundContent = () => ( {label} ); const renderSkewContent = () => ( {label} ); const content = isRound ? renderRoundContent() : renderSkewContent(); return ( {ribbonTail} {content} ); }; export default BadgeRibbon;