import { useState } from 'react'
import { usePWAInstall } from '@/hooks/usePWAInstall'
import { usePlatform } from '@/hooks/usePlatform'
import { CloseIcon, ShareIcon, PlusCircleIcon } from '@/components/icons'
import { useTranslation } from '@/lib/use-translation'
export function InstallPrompt() {
const { t } = useTranslation()
const { canInstall, canInstallIOS, promptInstall, dismissInstall, isStandalone } = usePWAInstall()
const { isTelegram, haptic } = usePlatform()
const [showIOSGuide, setShowIOSGuide] = useState(false)
if (isTelegram || isStandalone) {
return null
}
// iOS Safari install guide
if (canInstallIOS) {
if (showIOSGuide) {
return (
{t('install.title')}
1
Tap the Share button in the toolbar
2
Scroll down and tap Add to Home Screen
3
Tap Add in the top right corner
)
}
return (
{t('install.title')}
{t('install.description')}
)
}
// Chrome/Edge install prompt
if (!canInstall) {
return null
}
const handleInstall = async () => {
haptic.impact('light')
const success = await promptInstall()
if (success) {
haptic.notification('success')
}
}
return (
{t('install.title')}
{t('install.description')}
)
}