diff --git a/frontend/src/views/ControlPostView.tsx b/frontend/src/views/ControlPostView.tsx index 73d0317..570cffe 100644 --- a/frontend/src/views/ControlPostView.tsx +++ b/frontend/src/views/ControlPostView.tsx @@ -204,6 +204,33 @@ export const ControlPostView: React.FC = () => { const [isSubmitting, setIsSubmitting] = useState(false); const [clock, setClock] = useState(''); + // Capturador del evento de instalación PWA (Samsung Galaxy Tab / Android / Windows) + const [deferredInstallPrompt, setDeferredInstallPrompt] = useState(null); + + useEffect(() => { + const handleBeforeInstallPrompt = (e: Event) => { + e.preventDefault(); + setDeferredInstallPrompt(e); + console.log('PWA: beforeinstallprompt disponible para instalación'); + }; + + window.addEventListener('beforeinstallprompt', handleBeforeInstallPrompt); + + return () => { + window.removeEventListener('beforeinstallprompt', handleBeforeInstallPrompt); + }; + }, []); + + const handleInstallPWA = async () => { + if (!deferredInstallPrompt) return; + deferredInstallPrompt.prompt(); + const { outcome } = await deferredInstallPrompt.userChoice; + console.log(`PWA: resultado de instalación -> ${outcome}`); + if (outcome === 'accepted') { + setDeferredInstallPrompt(null); + } + }; + // Reloj digital en tiempo real @@ -1234,6 +1261,26 @@ export const ControlPostView: React.FC = () => { ● + {/* Botón de Instalación Directa PWA (Solo visible cuando Chrome/Android detecta elegibilidad) */} + {deferredInstallPrompt && ( + + )} + {/* Botón Selector Tema Claro / Oscuro */}