import React, { useState } from 'react'; import { LayoutContextProvider, TrackReferenceOrPlaceholder } from '@livekit/components-react'; import { CustomLayoutContextProvider } from '@/app/contexts/layout-context'; import { PinAction } from '@livekit/components-react/dist/context/pin-context'; import { PanelTopInactive, Pi } from 'lucide-react'; interface CustomVideoLayoutContextProviderProps { children: React.ReactNode; } export const CustomVideoLayoutContextProvider: React.FC = ({ children, }) => { const [showChat, setShowChat] = useState(false); const [showSettings, setShowSettings] = useState(false); const [showParticipantsList, setShowParticipantsList] = useState(false); const [pinnedTracks, setPinnedTracks] = useState(); const toggleParticipantsList = () => { if (showChat) setShowChat(false); setShowParticipantsList((prev) => !prev); }; const toggleChat = () => { if (showParticipantsList) setShowParticipantsList(false); setShowChat((prev) => !prev); }; const toggleSettings = () => { setShowSettings((prev) => !prev); }; return ( { if (action.msg === 'set_pin') { setPinnedTracks([action.trackReference]); } if (action.msg === 'clear_pin') { setPinnedTracks([]); } }, }, widget: { state: { showChat, showSettings, unreadMessages: 0, }, dispatch: (action: any) => { switch (action && action.msg) { case 'toggle_settings': toggleSettings(); break; case 'toggle_chat': toggleChat(); break; case 'toggle_participants_list': toggleParticipantsList(); break; } }, }, }} > {children} ); };