import React, { createContext, useContext, ReactNode } from 'react';

interface AppContextType {
  isStandalone: boolean;
  exitFullscreen?: () => void;
}

const AppContext = createContext<AppContextType | undefined>(undefined);

export function AppProvider({ 
  children, 
  isStandalone, 
  exitFullscreen 
}: { 
  children: ReactNode; 
  isStandalone: boolean; 
  exitFullscreen?: () => void;
}) {
  return (
    <AppContext.Provider value={{ isStandalone, exitFullscreen }}>
      {children}
    </AppContext.Provider>
  );
}

export function useApp() {
  const context = useContext(AppContext);
  if (context === undefined) {
    throw new Error('useApp must be used within an AppProvider');
  }
  return context;
}
