import { Restricted } from '@stream-io/video-react-bindings'; import React, { useState } from 'react'; import { CallControlsButton } from './CallControlsButton'; import { OwnCapability } from '@stream-io/video-client'; import { ButtonTestIds } from '../../../constants/TestIds'; import { IconWrapper, Reaction } from '../../../icons'; import { ReactionsPicker } from './internal/ReactionsPicker'; import { type LayoutChangeEvent, type LayoutRectangle } from 'react-native'; import { useTheme } from '../../../contexts/ThemeContext'; import { type StreamReactionType } from '../CallContent'; /** * Props for the Reaction button */ export type ReactionsButtonProps = { /** * Supported Reactions to be sent while in the call. */ supportedReactions?: StreamReactionType[]; /** * Handler to be called when the reaction button is pressed. */ onPressHandler?: () => void; }; /** * Button to display the list of Reactions supported in the call. * On press, it opens a view that can be used to send Reaction. */ export const ReactionsButton = ({ supportedReactions, onPressHandler, }: ReactionsButtonProps) => { const [showReactionsPicker, setShowReactionsPicker] = useState(false); const [reactionsButtonLayoutRectangle, setReactionsButtonLayoutRectangle] = useState(); const { theme: { colors }, } = useTheme(); // This is for the reaction picker const onReactionsButtonLayout = (event: LayoutChangeEvent) => { const layout = event.nativeEvent.layout; setReactionsButtonLayoutRectangle((prev) => { if ( prev && prev.width === layout.width && prev.height === layout.height && prev.x === layout.x && prev.y === layout.y ) { return prev; } return layout; }); }; const reactionsButtonHandler = () => { if (onPressHandler) { onPressHandler(); return; } setShowReactionsPicker(true); }; return ( <> {showReactionsPicker && ( { setShowReactionsPicker(false); }} /> )} ); };