diff --git a/src/pages/AIChat.tsx b/src/pages/AIChat.tsx index 4be3fe6..10028d6 100644 --- a/src/pages/AIChat.tsx +++ b/src/pages/AIChat.tsx @@ -10,6 +10,7 @@ import { useToast } from '@/hooks/use-toast'; import GlitchText from '@/components/GlitchText'; import MessageContent from '@/components/MessageContent'; import { AI_PROVIDERS, AIProvider, getProvider, CUSTOM_API_STORAGE_KEY } from '@/lib/aiProviders'; +import { useBrowserFullscreen } from '@/hooks/useGameDimensions'; import { DropdownMenu, DropdownMenuContent, @@ -104,21 +105,30 @@ const AIChat = () => { } }, [customApiConfig]); - // Exit fullscreen on Escape key + const isMobile = typeof window !== 'undefined' && window.innerWidth < 768; + const { enterFullscreen, exitFullscreen } = useBrowserFullscreen(); + // Exit fullscreen on Escape key useEffect(() => { const handleEscape = (e: KeyboardEvent) => { if (e.key === 'Escape' && isFullscreen) { setIsFullscreen(false); + exitFullscreen(); playSound('click'); } }; window.addEventListener('keydown', handleEscape); return () => window.removeEventListener('keydown', handleEscape); - }, [isFullscreen, playSound]); + }, [isFullscreen, playSound, exitFullscreen]); - const toggleFullscreen = () => { - setIsFullscreen(prev => !prev); + const toggleFullscreen = async () => { + if (!isFullscreen) { + setIsFullscreen(true); + await enterFullscreen(); + } else { + setIsFullscreen(false); + await exitFullscreen(); + } playSound('click'); }; @@ -379,21 +389,21 @@ const AIChat = () => { transition={{ duration: 0.5 }} className={`flex flex-col ${ isFullscreen - ? 'fixed inset-0 z-50 bg-background p-4 md:p-8' + ? 'fixed inset-0 z-50 bg-background p-3 md:p-8 overflow-hidden' : 'h-full' }`} > -
No messages yet.
@@ -549,7 +559,7 @@ const AIChat = () => {