import React, { useState } from 'react'; import { GridLayout, useTracks, LayoutContextProvider, Chat } from '@livekit/components-react'; import { Track, Room } from 'livekit-client'; import { ParticipantTile } from './ParticipantTile'; import { CustomControlBar } from '@/app/custom/CustomControlBar'; import { SettingsMenu } from './SettingsMenu'; import ParticipantList from '@/app/custom/ParticipantList'; import { CustomLayoutContextProvider } from '@/app/contexts/layout-context'; import '../styles/Chat.css'; interface CustomVideoLayoutProps { room: Room; roomName: string; } export const CustomVideoLayout: React.FC = ({ room, roomName }) => { const [showChat, setShowChat] = useState(false); const [showSettings, setShowSettings] = useState(false); const [showParticipantsList, setShowParticipantsList] = useState(false); const tracks = useTracks( [ { source: Track.Source.Camera, withPlaceholder: true }, { source: Track.Source.ScreenShare, withPlaceholder: false }, ], { onlySubscribed: false }, ); return ( { if (showChat) setShowChat(false); setShowParticipantsList((prev) => !prev); }, }, isChatOpen: { state: showChat, dispatch: () => { if (showParticipantsList) setShowParticipantsList(false); setShowChat((prev) => !prev); }, }, }} > {}, }, widget: { state: { showChat, showSettings, unreadMessages: 0, }, dispatch: (action: any) => { if ('msg' in action && action.msg === 'toggle_settings') { setShowSettings((prev) => !prev); } if ('msg' in action && action.msg === 'toggle_chat') { if (showParticipantsList) setShowParticipantsList(false); setShowChat((prev) => !prev); } if ('msg' in action && action.msg === 'toggle_participants_list') { if (showChat) setShowChat(false); setShowParticipantsList((prev) => !prev); } }, }, }} >
{' '}
{showParticipantsList && } {showChat && }
); }; export default CustomVideoLayout;