diff --git a/native/chat/robotext-message-tooltip-button.react.js b/native/chat/robotext-message-tooltip-button.react.js index f9cd8e026..cecf7676c 100644 --- a/native/chat/robotext-message-tooltip-button.react.js +++ b/native/chat/robotext-message-tooltip-button.react.js @@ -1,150 +1,155 @@ // @flow import * as React from 'react'; -import Animated, { type SharedValue } from 'react-native-reanimated'; +import Animated, { + type SharedValue, + interpolate, + useAnimatedStyle, +} from 'react-native-reanimated'; import { chatMessageItemEngagementTargetMessageInfo } from 'lib/shared/chat-message-item-utils.js'; import { useViewerAlreadySelectedMessageReactions, useCanCreateReactionFromMessage, } from 'lib/shared/reaction-utils.js'; import { InnerRobotextMessage } from './inner-robotext-message.react.js'; import { useSendReaction } from './reaction-message-utils.js'; import ReactionSelectionPopover from './reaction-selection-popover.react.js'; import SidebarInputBarHeightMeasurer from './sidebar-input-bar-height-measurer.react.js'; import { Timestamp } from './timestamp.react.js'; import { useAnimatedMessageTooltipButton } from './utils.js'; import EmojiKeyboard from '../components/emoji-keyboard.react.js'; import type { EmojiSelection } from '../components/emoji-keyboard.react.js'; import type { AppNavigationProp } from '../navigation/app-navigator.react.js'; import { useSelector } from '../redux/redux-utils.js'; import { useTooltipActions } from '../tooltip/tooltip-hooks.js'; import type { TooltipRoute } from '../tooltip/tooltip.react.js'; -const { Node, interpolateNode, Extrapolate } = Animated; +const { Node, Extrapolate } = Animated; type Props = { +navigation: AppNavigationProp<'RobotextMessageTooltipModal'>, +route: TooltipRoute<'RobotextMessageTooltipModal'>, +progress: Node, +progressV2: SharedValue, ... }; function RobotextMessageTooltipButton(props: Props): React.Node { - const { navigation, route, progress, progressV2 } = props; + const { navigation, route, progressV2 } = props; const windowWidth = useSelector(state => state.dimensions.width); const [sidebarInputBarHeight, setSidebarInputBarHeight] = React.useState(null); const onInputBarMeasured = React.useCallback((height: number) => { setSidebarInputBarHeight(height); }, []); const { item, verticalBounds, initialCoordinates } = route.params; const { style: messageContainerStyle } = useAnimatedMessageTooltipButton({ sourceMessage: item, initialCoordinates, messageListVerticalBounds: verticalBounds, progressV2, targetInputBarHeight: sidebarInputBarHeight, }); - const headerStyle = React.useMemo(() => { + const headerStyle = useAnimatedStyle(() => { const bottom = initialCoordinates.height; - const opacity = interpolateNode(progress, { - inputRange: [0, 0.05], - outputRange: [0, 1], - extrapolate: Extrapolate.CLAMP, - }); + const opacity = interpolate( + progressV2.value, + [0, 0.05], + [0, 1], + Extrapolate.CLAMP, + ); return { opacity, position: 'absolute', left: -initialCoordinates.x, width: windowWidth, bottom, }; - }, [initialCoordinates.height, initialCoordinates.x, progress, windowWidth]); + }, [initialCoordinates.height, initialCoordinates.x, windowWidth]); const { threadInfo, reactions } = item; const engagementTargetMessageInfo = chatMessageItemEngagementTargetMessageInfo(item); const canCreateReactionFromMessage = useCanCreateReactionFromMessage( threadInfo, engagementTargetMessageInfo, ); const sendReaction = useSendReaction( engagementTargetMessageInfo?.id, threadInfo, reactions, ); const [emojiPickerOpen, setEmojiPickerOpen] = React.useState(false); const openEmojiPicker = React.useCallback(() => { setEmojiPickerOpen(true); }, []); const reactionSelectionPopover = React.useMemo(() => { if (!canCreateReactionFromMessage) { return null; } return ( ); }, [ navigation, route, openEmojiPicker, canCreateReactionFromMessage, sendReaction, ]); const tooltipRouteKey = route.key; const { dismissTooltip } = useTooltipActions(navigation, tooltipRouteKey); const onEmojiSelected = React.useCallback( (emoji: EmojiSelection) => { sendReaction(emoji.emoji); dismissTooltip(); }, [sendReaction, dismissTooltip], ); const alreadySelectedEmojis = useViewerAlreadySelectedMessageReactions(reactions); return ( <> {reactionSelectionPopover} ); } export default RobotextMessageTooltipButton;