import React, { useMemo } from 'react'; // import { Platform, Text, View } from 'react-native'; import { Text, View } from 'react-native'; import { applyStyles, textStyles } from '../../utils/styles'; import { useInheritedFocusedStyle } from '../../context/FocusContext'; import { iconPathsByName } from '../../utils/iconMap'; import { resolveSymbolGlyph } from '../../utils/symbolGlyphs'; let SvgComponent: React.ComponentType | null = null; let SvgPathComponent: React.ComponentType | null = null; // if (!Platform.isTV) { try { const reactNativeSvg = require('react-native-svg'); SvgComponent = reactNativeSvg.default ?? reactNativeSvg.Svg ?? null; SvgPathComponent = reactNativeSvg.Path ?? null; } catch { SvgComponent = null; SvgPathComponent = null; } // } interface Props { component: any; scaleFactor: number; parentDirection?: string; } export const NamiSymbol: React.FC = ({ component, scaleFactor, parentDirection }) => { const isFocused = useInheritedFocusedStyle(); const containerStyle = applyStyles(component, scaleFactor, isFocused, parentDirection); const symbolStyle = textStyles(component, scaleFactor, isFocused); const svgPaths = useMemo(() => iconPathsByName(component.name), [component.name]); const value = resolveSymbolGlyph(component.name) || (component.text ?? ''); const iconSize = typeof symbolStyle.fontSize === 'number' ? symbolStyle.fontSize : 16 * scaleFactor; const iconColor = typeof symbolStyle.color === 'string' ? symbolStyle.color : '#ffffff'; const iconMarginTop = typeof symbolStyle.lineHeight === 'number' ? symbolStyle.lineHeight / 10 : iconSize * 0.12; const canRenderSvg = Boolean(svgPaths && SvgComponent && SvgPathComponent); const resolvedSvgPaths = svgPaths ?? []; if (!svgPaths && !value) return null; return ( {canRenderSvg ? ( {(() => { const SafeSvgComponent = SvgComponent as React.ComponentType; const SafeSvgPathComponent = SvgPathComponent as React.ComponentType; return ( {resolvedSvgPaths.map((d, index) => ( ))} ); })()} ) : ( {value} )} ); };