import { CallingState } from '@stream-io/video-client'; import { useCall, useCallStateHooks } from '@stream-io/video-react-bindings'; import React from 'react'; import { StyleSheet, View } from 'react-native'; import { CallContent as DefaultCallContent, type CallContentProps, } from '../CallContent'; import { IncomingCall as DefaultIncomingCall, type IncomingCallProps, } from './IncomingCall'; import { OutgoingCall as DefaultOutgoingCall, type OutgoingCallProps, } from './OutgoingCall'; import { CallLeftIndicator as DefaultCallLeftIndicator, type CallLeftIndicatorProps, } from './CallLeftIndicator'; import { CallPreparingIndicator as DefaultCallPreparingIndicator, type CallPreparingIndicatorProps, } from './CallPreparingIndicator'; import { useTheme } from '../../../contexts'; /** * Props for the RingingCallContent component */ export type RingingCallContentProps = { /** * Prop to customize the IncomingCall component in the RingingCallContent. */ IncomingCall?: React.ComponentType | null; /** * Prop to customize the OutgoingCall component in the RingingCallContent. */ OutgoingCall?: React.ComponentType | null; /** * Prop to customize the accepted CallContent component in the RingingCallContent. This is shown after the call is accepted. */ CallContent?: React.ComponentType | null; /** * Prop to override the component shown when the call is left. */ CallLeftIndicator?: React.ComponentType | null; /** * Prop to override the component shown when the call is in idle state. */ CallPreparingIndicator?: React.ComponentType | null; /** * Check if device is in landscape mode. * This will apply the landscape mode styles to the component. */ landscape?: boolean; /** * Callback to handle the back icon press event * in CallLeftIndicator and CallPreparingIndicator components. */ onBackPress?: () => void; }; const RingingCallPanel = ({ IncomingCall = DefaultIncomingCall, OutgoingCall = DefaultOutgoingCall, CallContent = DefaultCallContent, CallLeftIndicator = DefaultCallLeftIndicator, CallPreparingIndicator = DefaultCallPreparingIndicator, landscape, onBackPress, callingState, }: RingingCallContentProps & { callingState: CallingState }) => { const call = useCall(); const isCallCreatedByMe = call?.isCreatedByMe; switch (callingState) { case CallingState.RINGING: return isCallCreatedByMe ? OutgoingCall && : IncomingCall && ; case CallingState.LEFT: return ( CallLeftIndicator && ); case CallingState.IDLE: return ( CallPreparingIndicator && ( ) ); default: return CallContent && ; } }; /** * Component to show the Incoming, Outgoing and CalContent component depending upon the Call states when the call is in ringing mode. */ export const RingingCallContent = (props: RingingCallContentProps) => { const { theme: { ringingCallContent }, } = useTheme(); const { useCallCallingState } = useCallStateHooks(); const callingState = useCallCallingState(); return ( ); };