import { useMemo } from 'react'; import { Avatar, Box, Button, Chip, Dialog, DialogContent, IconButton, Link, Tooltip, Typography, } from '@mui/material'; import CloseIcon from '@mui/icons-material/Close'; import FavoriteBorderIcon from '@mui/icons-material/FavoriteBorder'; import FavoriteIcon from '@mui/icons-material/Favorite'; import VerifiedIcon from '@mui/icons-material/Verified'; import DownloadIcon from '@mui/icons-material/Download'; import OpenInNewIcon from '@mui/icons-material/OpenInNew'; import ComputerIcon from '@mui/icons-material/Computer'; import { useAuth } from '../context/AuthContext'; function InstallModal({ open, onClose, app }) { const { isLoggedIn, isSpaceLiked, toggleLike } = useAuth(); // Detect Linux users const isLinux = useMemo(() => { if (typeof navigator === 'undefined') return false; const platform = navigator.platform?.toLowerCase() || ''; const userAgent = navigator.userAgent?.toLowerCase() || ''; return platform.includes('linux') || userAgent.includes('linux'); }, []); if (!app) return null; const appName = app.name || app.id?.split('/').pop(); const cardData = app.extra?.cardData || {}; const emoji = cardData.emoji || '📦'; const description = cardData.short_description || app.description || 'No description'; const deepLinkUrl = `reachymini://install/${appName}`; const spaceUrl = app.url || `https://huggingface.co/spaces/${app.id}`; const author = app.extra?.author || app.id?.split('/')?.[0] || null; const isOfficial = app.isOfficial; const baseLikes = app.extra?.likes || 0; const isLiked = isSpaceLiked(app.id); const displayedLikes = baseLikes + (isLiked ? 1 : 0); const lastModified = app.extra?.lastModified || null; const formattedDate = lastModified ? new Date(lastModified).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric', }) : null; const handleInstall = () => { window.location.href = deepLinkUrl; setTimeout(() => onClose(), 500); }; return ( {/* Close button outside modal */} {/* Header */} {/* App row */} {/* Emoji */} {emoji} {/* Info */} {/* Title */} {appName} {/* Meta row */} {author && ( {author.charAt(0).toUpperCase()} {author} )} {isOfficial && ( } label="Official" size="small" sx={{ height: 24, bgcolor: 'rgba(255, 149, 0, 0.1)', color: '#FF9500', fontWeight: 600, fontSize: 11, '& .MuiChip-icon': { color: '#FF9500', ml: 0.5 }, '& .MuiChip-label': { px: 1 }, }} /> )} {/* Stats row */} toggleLike(app.id)} sx={{ display: 'flex', alignItems: 'center', gap: 0.5, border: 'none', bgcolor: 'transparent', cursor: 'pointer', p: 0.5, m: -0.5, borderRadius: '6px', transition: 'all 0.15s ease', '&:hover': { bgcolor: 'rgba(236, 72, 153, 0.08)', }, }} > {isLiked ? ( ) : ( )} {displayedLikes} {formattedDate && ( Updated {formattedDate} )} {/* Description - intégrée au bloc info */} {description} {/* Divider */} {/* Desktop App Requirement Block */} {/* All platforms: Normal install flow */} Reachy Mini Desktop App required No robot? Try it in simulation mode – no hardware needed! Download the desktop app → {/* Linux Beta Notice */} {isLinux && ( Linux support is currently in Beta — please report any issues on{' '} GitHub {' '}or{' '} Discord. )} {/* Actions */} ); } export default InstallModal;