From a909b02e370d0349c766beaeeeee2587769d03b0 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 21 Dec 2025 19:23:14 -0500 Subject: [PATCH] update frontend --- src/pwaInstall.js | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/src/pwaInstall.js b/src/pwaInstall.js index 600e819..9da9cd1 100644 --- a/src/pwaInstall.js +++ b/src/pwaInstall.js @@ -2,46 +2,39 @@ let deferredPrompt = null; window.addEventListener('beforeinstallprompt', (e) => { - // Empêche le prompt par défaut e.preventDefault(); deferredPrompt = e; console.log('PWA install prompt ready'); }); -// Fonction pour déclencher l’install (tu peux l’appeler sur un bouton) export function promptInstall() { if (deferredPrompt) { deferredPrompt.prompt(); - deferredPrompt.userChoice.then((choiceResult) => { - if (choiceResult.outcome === 'accepted') { - console.log('PWA installed'); - } else { - console.log('PWA dismissed'); - } + deferredPrompt.userChoice.then((choice) => { + console.log('Install outcome:', choice.outcome); deferredPrompt = null; }); + } else { + console.log('No install prompt available'); } } -// Ajoute un bouton "Installer l’app" dans ton UI (optionnel) -export function addInstallButton() { +// Exporte la fonction pour ajouter le bouton dans TopBar +export function addPwaInstallButton(container) { const btn = document.createElement('button'); - btn.textContent = 'Installer SocioWire'; - btn.style.position = 'fixed'; - btn.style.bottom = '20px'; - btn.style.right = '20px'; - btn.style.padding = '10px 20px'; + btn.innerHTML = ' Installer'; + btn.style.marginLeft = '8px'; + btn.style.padding = '5px 10px'; + btn.style.fontSize = '12px'; btn.style.background = '#0ea5e9'; btn.style.color = 'white'; btn.style.border = 'none'; - btn.style.borderRadius = '8px'; + btn.style.borderRadius = '999px'; btn.style.cursor = 'pointer'; - btn.style.zIndex = '9999'; + btn.style.display = 'flex'; + btn.style.alignItems = 'center'; + btn.style.gap = '6px'; + btn.style.boxShadow = '0 2px 8px rgba(0,0,0,0.3)'; btn.onclick = promptInstall; - document.body.appendChild(btn); + container.appendChild(btn); } - -// Détection si déjà installé (cache) -if (window.matchMedia('(display-mode: standalone)').matches || navigator.standalone) { - console.log('App already installed'); -} \ No newline at end of file