import { KeepAwake, LivestreamProvider, Player, PlayerProps, PlayerProvider, Text, ThemeProvider, usePlayerStore, zero, } from "@streamplace/components"; import { DesktopUi } from "components/mobile/desktop-ui"; import { FullscreenProvider } from "contexts/FullscreenContext"; import { useEffect, useState } from "react"; import { View } from "react-native"; const { layout, flex } = zero; function IdViewer({ reqid }) { const id = usePlayerStore((p) => p.id, reqid); return ( {reqid} {id} ); } export default function MultiScreen({ route }) { const config = route.params?.config; if (typeof config !== "string") { return ; } const [rows, setRows] = useState[][]>([]); const [error, setError] = useState(null); useEffect(() => { try { let nearestSquareExpo = 1; const playerProps = JSON.parse( config as string, ) as Partial[]; while (Math.pow(nearestSquareExpo, 2) < playerProps.length) { nearestSquareExpo += 1; } const rows: Partial[][] = []; let idx = 0; for (let i = 0; i < nearestSquareExpo; i += 1) { const row: Partial[] = []; for (let j = 0; j < nearestSquareExpo; j += 1) { if (playerProps[idx]) { row.push(playerProps[idx]); } else { row.push(null); } idx += 1; } rows.push(row); } setRows(rows); } catch (e) { setError(e.message); } }, [config]); if (error) { return {error}; } return ( {rows.map((players, i) => ( {players.map((props, j) => ( {props === null ? ( ) : ( )} ))} ))} ); }