import React from "react"; /** * Compact PWA install button for the header. * - Shows π² icon when install prompt is available (Chrome/Edge on Android & desktop). * - Shows iOS Safari instructions tooltip on click when on iOS. * - Hidden when app is already installed (standalone mode). * - After install: auto-hidden via appinstalled event. */ export const PwaInstallButton = ({ onInstall, isInstalled, isInstallAvailable }) => { const [showTip, setShowTip] = React.useState(false); const tipRef = React.useRef(null); // Detect iOS (no beforeinstallprompt, but can be added to home screen) const isIOS = typeof navigator !== "undefined" && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; const handleInstallClick = async () => { if (isInstallAvailable && onInstall) { await onInstall(); } else { // Show instruction tip for iOS or unsupported browsers setShowTip((prev) => !prev); } }; // Close tip on outside click React.useEffect(() => { if (!showTip) return; const handler = (e) => { if (tipRef.current && !tipRef.current.contains(e.target)) { setShowTip(false); } }; document.addEventListener("click", handler); return () => document.removeEventListener("click", handler); }, [showTip]); // Don't render if already installed as PWA β AFTER all hooks if (isInstalled) return null; return (
Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ° Π½Π° iOS
Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ°
ΠΠ°ΠΆΠΌΠΈΡΠ΅ Π·Π½Π°ΡΠΎΠΊ π² Π² Π°Π΄ΡΠ΅ΡΠ½ΠΎΠΉ ΡΡΡΠΎΠΊΠ΅ Π±ΡΠ°ΡΠ·Π΅ΡΠ° ΠΈΠ»ΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠΉΡΠ΅ ΠΌΠ΅Π½Ρ Β«Π£ΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅Β».
> )}