import React from 'react'; import { hasScreenShare } from '@stream-io/video-client'; import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings'; import { StyleSheet, View, type ViewStyle } from 'react-native'; import { usePaginatedLayoutSortPreset } from '../../../hooks/usePaginatedLayoutSortPreset'; import { useTheme } from '../../../contexts'; import { VideoRenderer as DefaultVideoRenderer, type VideoRendererProps, } from '../../Participant'; import type { ScreenShareOverlayProps } from '../../utility/ScreenShareOverlay'; /** * Props for the LivestreamLayout component. */ export type LivestreamLayoutProps = { /* * Check if device is in landscape mode. * This will apply the landscape mode styles to the component. */ landscape?: boolean; /** * Component to customize the video component of the participant. */ VideoRenderer?: React.ComponentType | null; /** * Component to customize the ScreenShareOverlay. */ ScreenShareOverlay?: React.ComponentType | null; }; /** * The LivestreamLayout component presents the live stream video layout. */ export const LivestreamLayout = ({ landscape, VideoRenderer = DefaultVideoRenderer, ScreenShareOverlay, }: LivestreamLayoutProps) => { const { useParticipants, useHasOngoingScreenShare } = useCallStateHooks(); const call = useCall(); const { theme: { colors, livestreamLayout }, } = useTheme(); const participants = useParticipants(); const [currentSpeaker] = participants; const hasOngoingScreenShare = useHasOngoingScreenShare(); const presenter = hasOngoingScreenShare ? participants.find(hasScreenShare) : undefined; usePaginatedLayoutSortPreset(call); const landScapeStyles: ViewStyle = { flexDirection: landscape ? 'row' : 'column', }; return ( {VideoRenderer && hasOngoingScreenShare && presenter && (presenter.isLocalParticipant && ScreenShareOverlay ? ( ) : ( ))} {VideoRenderer && !hasOngoingScreenShare && currentSpeaker && ( )} ); }; const styles = StyleSheet.create({ container: { flex: 1, }, });