import { Bot, Box, Braces, Briefcase, Building2, Code2, Cpu, Database, Folder, Gauge, Globe, Layers, type LucideIcon, Package, Palette, Rocket, Server, // `Shapes` is lucide's own export name; exempted in config/oxlint-anti-slop.json. Shapes, Sparkles, SquareTerminal, Wrench } from 'lucide-react-native' import { useState } from 'react' import { Image, StyleSheet, Text, View } from 'react-native' import type { MobileRenderableRepoIcon } from '../host-screen/host-screen-reply-schema' import { colors, radii } from '../theme/mobile-theme' import { useMobileColorScheme } from '../theme/use-mobile-color-scheme' // Match desktop repo-icon picker’s lucide glyphs so mobile project headers retain chosen icons. const REPO_LUCIDE_ICONS: Record = { Folder, Code2, SquareTerminal, Bot, Package, Database, Globe, Server, Layers, Box, Braces, Briefcase, Building2, Cpu, Gauge, Palette, Rocket, Shapes, Sparkles, Wrench } type Props = { // Accept decoded catalog icon fields (type/src/label/emoji/name), not unused source; RepoIcon remains compatible. repoIcon?: MobileRenderableRepoIcon | null size?: number color?: string } // Render desktop-style custom image/emoji/lucide with Folder fallback, never bare project dot. export function MobileRepoIcon({ repoIcon, size = 14, color = colors.textSecondary }: Props) { useMobileColorScheme() // Keyed by src so a changed icon gets a fresh try; the page shell refuses every https load. const [failedSrc, setFailedSrc] = useState(null) if (repoIcon?.type === 'image' && repoIcon.src !== failedSrc) { const { src } = repoIcon return ( setFailedSrc(src)} /> ) } if (repoIcon?.type === 'emoji') { return {repoIcon.emoji} } const Icon = (repoIcon?.type === 'lucide' && REPO_LUCIDE_ICONS[repoIcon.name]) || Folder return ( ) } const styles = StyleSheet.create({ emoji: { textAlign: 'center' }, glyph: { alignItems: 'center', justifyContent: 'center' } })