import { Fragment, FC, ReactNode } from "react"; import { View, ViewStyle } from "react-native"; interface IconBackgroundProps { size: number; glowColor: string; variant?: "circuit" | "matrix" | "glitch" | "nodes" | "grid"; children?: ReactNode; } // Consolidated star data const STARS = [ { x: 0.1, y: 0.1, size: 1, opacity: 0.3 }, { x: 0.9, y: 0.1, size: 1.2, opacity: 0.5 }, { x: 0.05, y: 0.3, size: 0.8, opacity: 0.4 }, { x: 0.95, y: 0.35, size: 1, opacity: 0.3 }, { x: 0.15, y: 0.85, size: 1, opacity: 0.5 }, { x: 0.85, y: 0.9, size: 1.2, opacity: 0.4 }, ]; interface CircuitVariant { lines: { x: number; width: number; height: number; opacity: number }[]; nodes: { x: number; y: number }[]; } interface NodesVariant { nodes: { x: number; y: number }[]; } interface GridVariant { lines: number[]; } interface MatrixVariant { lines: number[]; rain: number[]; } interface GlitchVariant { lines: number[]; scan: number[]; } type VariantData = { circuit: CircuitVariant; nodes: NodesVariant; grid: GridVariant; matrix: MatrixVariant; glitch: GlitchVariant; }; const VARIANT_DATA: VariantData = { circuit: { lines: [ { x: 0.5, width: 0.5, height: 0.9, opacity: 0.15 }, { x: 0.25, width: 0.3, height: 0.7, opacity: 0.1 }, { x: 0.75, width: 0.3, height: 0.7, opacity: 0.1 }, ], nodes: [ { x: 0.5, y: 0.15 }, { x: 0.25, y: 0.25 }, { x: 0.75, y: 0.25 }, { x: 0.5, y: 0.5 }, { x: 0.25, y: 0.6 }, { x: 0.75, y: 0.6 }, ], }, nodes: { nodes: [ { x: 0.2, y: 0.2 }, { x: 0.8, y: 0.2 }, { x: 0.15, y: 0.5 }, { x: 0.85, y: 0.5 }, { x: 0.2, y: 0.8 }, { x: 0.8, y: 0.8 }, ], }, grid: { lines: [0.2, 0.35, 0.5, 0.65, 0.8], }, matrix: { lines: [0.2, 0.35, 0.5, 0.65, 0.8], rain: [0.25, 0.5, 0.75], }, glitch: { lines: [0.2, 0.35, 0.5, 0.65, 0.8], scan: [0.3, 0.7], }, }; export const IconBackground: FC = ({ size, glowColor, variant = "circuit", children, }) => { const scale = size / 24; const renderStars = () => ( <> {STARS.map((star, i) => ( ))} ); const renderVariant = () => { const data = VARIANT_DATA[variant]; if (!data) return null; if (variant === "circuit") { const circuitData = data as CircuitVariant; return ( <> {circuitData.lines.map((line, i) => ( ))} {circuitData.nodes.map((node, i) => ( ))} ); } if (variant === "nodes") { const nodesData = data as NodesVariant; return ( <> {nodesData.nodes.map((node, i) => ( ))} ); } if (variant === "grid" || variant === "matrix") { const gridData = data as GridVariant | MatrixVariant; return ( <> {gridData.lines.map((pos, i) => ( ))} ); } if (variant === "glitch") { const glitchData = data as GlitchVariant; return ( <> {glitchData.lines.map((y, i) => ( ))} {glitchData.scan.map((y, i) => ( ))} ); } return null; }; return ( {renderStars()} {renderVariant()} {children} ); };