import { Circle } from '@Root/Components/Circle' import React, { useContext } from 'react' import Icon from 'react-native-vector-icons/Ionicons' import { ThemeContext } from 'styled-components' import { CellContent, IconAscii, IconCircleContainer, IconContainerLeft, IconContainerRight, IconGraphicContainer, RegularText, SubText, SubTextContainer, Text, TextContainer, Touchable, } from './SideMenuCell.styled' import { SideMenuOption, SideMenuOptionIconDescriptionType } from './SideMenuSection' const renderIcon = (desc: SideMenuOption['iconDesc'], color: string) => { if (!desc) { return null } if (desc.type === SideMenuOptionIconDescriptionType.Icon && desc.name) { return ( ) } if (desc.type === SideMenuOptionIconDescriptionType.Ascii) { return {desc.value} } if (desc.type === SideMenuOptionIconDescriptionType.Circle) { return ( ) } if (desc.type === SideMenuOptionIconDescriptionType.CustomComponent) { return desc.value } return * } export const SideMenuCell: React.FC = props => { const theme = useContext(ThemeContext) const colorForTextClass = (textClass: SideMenuOption['textClass']) => { if (!textClass) { return undefined } return { info: theme.stylekitInfoColor, danger: theme.stylekitDangerColor, warning: theme.stylekitWarningColor, }[textClass] } const hasIcon = props.iconDesc const iconSide = hasIcon && props.iconDesc?.side ? props.iconDesc.side : hasIcon ? 'left' : null return ( {iconSide === 'left' && ( {renderIcon(props.iconDesc, theme.stylekitInfoColor)} )} {props.subtext && ( {props.subtext} )} {props.text} {props.children} {iconSide === 'right' && ( {renderIcon(props.iconDesc, theme.stylekitInfoColor)} )} ) }