diff --git a/native/chat/multimedia-message-tooltip-button.react.js b/native/chat/multimedia-message-tooltip-button.react.js index 04424f1d5..9bd663c5a 100644 --- a/native/chat/multimedia-message-tooltip-button.react.js +++ b/native/chat/multimedia-message-tooltip-button.react.js @@ -1,185 +1,183 @@ // @flow import * as React from 'react'; import Animated, { type SharedValue, useAnimatedStyle, interpolate, + Extrapolate, } from 'react-native-reanimated'; import { chatMessageItemHasEngagement } from 'lib/shared/chat-message-item-utils.js'; import { useViewerAlreadySelectedMessageReactions, useCanCreateReactionFromMessage, } from 'lib/shared/reaction-utils.js'; import { TooltipInlineEngagement } from './inline-engagement.react.js'; import { InnerMultimediaMessage } from './inner-multimedia-message.react.js'; import { MessageHeader } from './message-header.react.js'; import MessageTooltipButtonAvatar from './message-tooltip-button-avatar.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 { 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, Extrapolate } = Animated; - function noop() {} type Props = { +navigation: AppNavigationProp<'MultimediaMessageTooltipModal'>, +route: TooltipRoute<'MultimediaMessageTooltipModal'>, - +progress: Node, +progressV2: SharedValue, +isOpeningSidebar: boolean, }; function MultimediaMessageTooltipButton(props: Props): React.Node { const { navigation, route, progressV2, isOpeningSidebar } = 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 = useAnimatedStyle(() => { const bottom = initialCoordinates.height; 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, windowWidth]); const inlineEngagement = React.useMemo(() => { if (!chatMessageItemHasEngagement(item, item.threadInfo.id)) { return null; } return ( ); }, [initialCoordinates, isOpeningSidebar, item, progressV2, windowWidth]); const innerMultimediaMessage = React.useMemo( () => ( ), [item, navigation.goBackOnce, verticalBounds], ); const { messageInfo, threadInfo, reactions } = item; const canCreateReactionFromMessage = useCanCreateReactionFromMessage( threadInfo, messageInfo, ); const sendReaction = useSendReaction(messageInfo.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} {innerMultimediaMessage} {inlineEngagement} ); } export default MultimediaMessageTooltipButton; diff --git a/native/chat/robotext-message-tooltip-button.react.js b/native/chat/robotext-message-tooltip-button.react.js index cecf7676c..93e99fe7b 100644 --- a/native/chat/robotext-message-tooltip-button.react.js +++ b/native/chat/robotext-message-tooltip-button.react.js @@ -1,155 +1,153 @@ // @flow import * as React from 'react'; import Animated, { type SharedValue, interpolate, useAnimatedStyle, + Extrapolate, } 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, Extrapolate } = Animated; - type Props = { +navigation: AppNavigationProp<'RobotextMessageTooltipModal'>, +route: TooltipRoute<'RobotextMessageTooltipModal'>, - +progress: Node, +progressV2: SharedValue, ... }; function RobotextMessageTooltipButton(props: Props): React.Node { 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 = useAnimatedStyle(() => { const bottom = initialCoordinates.height; 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, 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; diff --git a/native/chat/text-message-tooltip-button.react.js b/native/chat/text-message-tooltip-button.react.js index ef8e90210..d24df5e62 100644 --- a/native/chat/text-message-tooltip-button.react.js +++ b/native/chat/text-message-tooltip-button.react.js @@ -1,191 +1,189 @@ // @flow import * as React from 'react'; import Animated, { type SharedValue, useAnimatedStyle, interpolate, + Extrapolate, } from 'react-native-reanimated'; import { chatMessageItemHasEngagement } from 'lib/shared/chat-message-item-utils.js'; import { useViewerAlreadySelectedMessageReactions, useCanCreateReactionFromMessage, } from 'lib/shared/reaction-utils.js'; import { TooltipInlineEngagement } from './inline-engagement.react.js'; import { InnerTextMessage } from './inner-text-message.react.js'; import { MessageHeader } from './message-header.react.js'; import { MessageListContextProvider } from './message-list-types.js'; import { MessagePressResponderContext } from './message-press-responder-context.js'; import MessageTooltipButtonAvatar from './message-tooltip-button-avatar.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 { 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, Extrapolate } = Animated; - type Props = { +navigation: AppNavigationProp<'TextMessageTooltipModal'>, +route: TooltipRoute<'TextMessageTooltipModal'>, - +progress: Node, +progressV2: SharedValue, +isOpeningSidebar: boolean, }; function TextMessageTooltipButton(props: Props): React.Node { const { navigation, route, progressV2, isOpeningSidebar } = 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, threadColorOverride, isThreadColorDarkOverride, } = useAnimatedMessageTooltipButton({ sourceMessage: item, initialCoordinates, messageListVerticalBounds: verticalBounds, progressV2, targetInputBarHeight: sidebarInputBarHeight, }); const headerStyle = useAnimatedStyle(() => { const bottom = initialCoordinates.height; 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, windowWidth]); const messagePressResponderContext = React.useMemo( () => ({ onPressMessage: navigation.goBackOnce, }), [navigation.goBackOnce], ); const inlineEngagement = React.useMemo(() => { if (!chatMessageItemHasEngagement(item, item.threadInfo.id)) { return null; } return ( ); }, [initialCoordinates, isOpeningSidebar, item, progressV2, windowWidth]); const { messageInfo, threadInfo, reactions } = item; const canCreateReactionFromMessage = useCanCreateReactionFromMessage( threadInfo, messageInfo, ); const sendReaction = useSendReaction(messageInfo.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} {inlineEngagement} ); } export default TextMessageTooltipButton; diff --git a/native/tooltip/tooltip.react.js b/native/tooltip/tooltip.react.js index f89a8d7fc..1b8641971 100644 --- a/native/tooltip/tooltip.react.js +++ b/native/tooltip/tooltip.react.js @@ -1,545 +1,541 @@ // @flow import type { RouteProp } from '@react-navigation/core'; import * as Haptics from 'expo-haptics'; import invariant from 'invariant'; import * as React from 'react'; import { View, TouchableWithoutFeedback, Platform, Keyboard, } from 'react-native'; -import Animated, { +import { interpolate, useAnimatedStyle, useSharedValue, type SharedValue, + Extrapolate, } from 'react-native-reanimated'; import { TooltipContextProvider, TooltipContext, } from './tooltip-context.react.js'; import BaseTooltipItem, { type TooltipItemBaseProps, } from './tooltip-item.react.js'; import { ChatContext } from '../chat/chat-context.js'; import SWMansionIcon from '../components/swmansion-icon.react.js'; import type { AppNavigationProp } from '../navigation/app-navigator.react.js'; import { OverlayContext } from '../navigation/overlay-context.js'; import type { TooltipModalParamList } from '../navigation/route-names.js'; import { useSelector } from '../redux/redux-utils.js'; import { useStyles } from '../themes/colors.js'; import { type VerticalBounds, type LayoutCoordinates, } from '../types/layout-types.js'; import type { LayoutEvent } from '../types/react-native.js'; import { AnimatedView, type ViewStyle, type WritableAnimatedStyleObj, type ReanimatedTransform, type AnimatedStyleObj, } from '../types/styles.js'; -const { Node, Extrapolate } = Animated; - const unboundStyles = { backdrop: { backgroundColor: 'black', bottom: 0, left: 0, position: 'absolute', right: 0, top: 0, }, container: { flex: 1, }, contentContainer: { flex: 1, overflow: 'hidden', }, icon: { color: 'modalForegroundLabel', }, itemContainer: { alignItems: 'center', flex: 1, flexDirection: 'row', justifyContent: 'center', padding: 10, }, itemContainerFixed: { flexDirection: 'column', }, items: { backgroundColor: 'tooltipBackground', borderRadius: 5, overflow: 'hidden', }, itemsFixed: { flex: 1, flexDirection: 'row', }, triangleDown: { borderBottomColor: 'transparent', borderBottomWidth: 0, borderLeftColor: 'transparent', borderLeftWidth: 10, borderRightColor: 'transparent', borderRightWidth: 10, borderStyle: 'solid', borderTopColor: 'tooltipBackground', borderTopWidth: 10, height: 10, top: Platform.OS === 'android' ? -1 : 0, width: 10, }, triangleUp: { borderBottomColor: 'tooltipBackground', borderBottomWidth: 10, borderLeftColor: 'transparent', borderLeftWidth: 10, borderRightColor: 'transparent', borderRightWidth: 10, borderStyle: 'solid', borderTopColor: 'transparent', borderTopWidth: 0, bottom: Platform.OS === 'android' ? -1 : 0, height: 10, width: 10, }, }; export type TooltipParams = { ...CustomProps, +presentedFrom: string, +initialCoordinates: LayoutCoordinates, +verticalBounds: VerticalBounds, +tooltipLocation?: 'above' | 'below' | 'fixed', +margin?: number, +visibleEntryIDs?: $ReadOnlyArray, +chatInputBarHeight?: number, +hideTooltip?: boolean, }; export type TooltipRoute> = RouteProp< TooltipModalParamList, RouteName, >; export type TooltipProps = { +navigation: AppNavigationProp, +route: TooltipRoute, }; type ButtonProps = { ...Base, - +progress: Node, +progressV2: SharedValue, +isOpeningSidebar: boolean, }; export type TooltipMenuProps = { ...TooltipProps, +tooltipItem: React.ComponentType, }; function createTooltip< RouteName: $Keys, TooltipPropsType: TooltipProps = TooltipProps, >( ButtonComponent: React.ComponentType>, MenuComponent: React.ComponentType>, ): React.ComponentType { function Tooltip( props: $ReadOnly<{ ...TooltipPropsType, +hideTooltip: () => mixed, }>, ) { const dimensions = useSelector(state => state.dimensions); const overlayContext = React.useContext(OverlayContext); const chatContext = React.useContext(ChatContext); const { params } = props.route; const { tooltipLocation } = params; const isFixed = tooltipLocation === 'fixed'; const { hideTooltip, ...navAndRouteForFlow } = props; React.useEffect(() => { Haptics.impactAsync(); }, []); const { goBackOnce } = props.navigation; const closeTooltip = React.useCallback(() => { goBackOnce(); if (isFixed) { hideTooltip(); } }, [isFixed, hideTooltip, goBackOnce]); const styles = useStyles(unboundStyles); const boundTooltipItem = React.useCallback( (innerProps: TooltipItemBaseProps) => { const containerStyle = isFixed ? [styles.itemContainer, styles.itemContainerFixed] : styles.itemContainer; return ( ); }, [isFixed, styles, closeTooltip], ); const tooltipContext = React.useContext(TooltipContext); invariant(tooltipContext, 'TooltipContext should be set in Tooltip'); const margin = React.useMemo(() => { const customMargin = params.margin; return customMargin !== null && customMargin !== undefined ? customMargin : 20; }, [params.margin]); const tooltipHeight = React.useMemo(() => { if (tooltipLocation === 'fixed') { return fixedTooltipHeight; } else { return getTooltipHeight(tooltipContext.getNumVisibleEntries()); } }, [tooltipLocation, tooltipContext]); const computedTooltipLocation = React.useMemo(() => { if (tooltipLocation) { return tooltipLocation; } const { initialCoordinates, verticalBounds } = params; const { y, height } = initialCoordinates; const contentTop = y; const contentBottom = y + height; const boundsTop = verticalBounds.y; const boundsBottom = verticalBounds.y + verticalBounds.height; const fullHeight = tooltipHeight + margin; if ( contentBottom + fullHeight > boundsBottom && contentTop - fullHeight > boundsTop ) { return 'above'; } return 'below'; }, [margin, tooltipHeight, params, tooltipLocation]); invariant(overlayContext, 'Tooltip should have OverlayContext'); - const { position, positionV2 } = overlayContext; - invariant(position, 'position should be defined in tooltip'); + const { positionV2 } = overlayContext; invariant(positionV2, 'position should be defined in tooltip'); const tooltipHorizontalOffset = useSharedValue(0); const opacityStyle: AnimatedStyleObj = useAnimatedStyle(() => { const backdropOpacity = interpolate( positionV2.value, [0, 1], [0, 0.7], Extrapolate.CLAMP, ); return { opacity: backdropOpacity, }; }); const contentContainerStyle: ViewStyle = React.useMemo(() => { const { verticalBounds } = params; const fullScreenHeight = dimensions.height; const top = verticalBounds.y; const bottom = fullScreenHeight - verticalBounds.y - verticalBounds.height; return { ...styles.contentContainer, marginTop: top, marginBottom: bottom, }; }, [dimensions.height, params, styles.contentContainer]); const buttonStyle: ViewStyle = React.useMemo(() => { const { initialCoordinates, verticalBounds } = params; const { x, y, width, height } = initialCoordinates; return { width: Math.ceil(width), height: Math.ceil(height), marginTop: y - verticalBounds.y, marginLeft: x, }; }, [params]); const tooltipContainerStyle: AnimatedStyleObj = useAnimatedStyle(() => { const { initialCoordinates, verticalBounds, chatInputBarHeight } = params; const { x, y, width, height } = initialCoordinates; const style: WritableAnimatedStyleObj = {}; style.position = 'absolute'; style.alignItems = 'center'; const tooltipContainerOpacity = interpolate( positionV2.value, [0, 0.1], [0, 1], Extrapolate.CLAMP, ); style.opacity = tooltipContainerOpacity; const invertedPosition = 1 - positionV2.value; const transform: Array = []; if (computedTooltipLocation !== 'fixed') { const tooltipHorizontal = invertedPosition * tooltipHorizontalOffset.value; transform.push({ translateX: tooltipHorizontal }); } const extraLeftSpace = x; const extraRightSpace = dimensions.width - width - x; if (extraLeftSpace < extraRightSpace) { style.left = 0; style.minWidth = width + 2 * extraLeftSpace; } else { style.right = 0; style.minWidth = width + 2 * extraRightSpace; } const inputBarHeight = chatInputBarHeight ?? 0; if (computedTooltipLocation === 'fixed') { const padding = 8; style.minWidth = dimensions.width - 16; style.left = 8; style.right = 8; style.bottom = dimensions.height - verticalBounds.height - verticalBounds.y - inputBarHeight + padding; const fixedTooltipVertical = invertedPosition * dimensions.height; transform.push({ translateY: fixedTooltipVertical }); } else if (computedTooltipLocation === 'above') { style.bottom = dimensions.height - Math.max(y, verticalBounds.y) + margin; const tooltipVerticalAbove = interpolate( positionV2.value, [0, 1], [margin + tooltipHeight / 2, 0], Extrapolate.CLAMP, ); transform.push({ translateY: tooltipVerticalAbove }); } else { style.top = Math.min(y + height, verticalBounds.y + verticalBounds.height) + margin; const tooltipVerticalBelow = interpolate( positionV2.value, [0, 1], [-margin - tooltipHeight / 2, 0], Extrapolate.CLAMP, ); transform.push({ translateY: tooltipVerticalBelow }); } if (computedTooltipLocation !== 'fixed') { const tooltipScale = interpolate( positionV2.value, [0, 0.2, 0.8, 1], [0, 0, 1, 1], Extrapolate.CLAMP, ); transform.push({ scale: tooltipScale }); } style.transform = transform; return style; }, [ dimensions.height, dimensions.width, params, computedTooltipLocation, margin, tooltipHeight, ]); const onPressMore = React.useCallback(() => { Keyboard.dismiss(); tooltipContext.showActionSheet(); }, [tooltipContext]); const renderMoreIcon = React.useCallback((): React.Node => { return ( ); }, [styles.icon]); const onTooltipContainerLayout = React.useCallback( (event: LayoutEvent) => { const { x, width } = params.initialCoordinates; const extraLeftSpace = x; const extraRightSpace = dimensions.width - width - x; const actualWidth = event.nativeEvent.layout.width; if (extraLeftSpace < extraRightSpace) { const minWidth = width + 2 * extraLeftSpace; tooltipHorizontalOffset.value = (minWidth - actualWidth) / 2; } else { const minWidth = width + 2 * extraRightSpace; tooltipHorizontalOffset.value = (actualWidth - minWidth) / 2; } }, [dimensions.width, params.initialCoordinates, tooltipHorizontalOffset], ); const backdropStyle = React.useMemo( () => [opacityStyle, styles.backdrop], [opacityStyle, styles.backdrop], ); const tooltipItemContainerStyle: Array = [styles.itemContainer]; if (computedTooltipLocation === 'fixed') { tooltipItemContainerStyle.push(styles.itemContainerFixed); } const items: Array = [ , ]; if (tooltipContext.shouldShowMore()) { items.push( , ); } let triangleStyle; const { initialCoordinates } = params; const { x, width } = initialCoordinates; const extraLeftSpace = x; const extraRightSpace = dimensions.width - width - x; if (extraLeftSpace < extraRightSpace) { triangleStyle = { alignSelf: 'flex-start', left: extraLeftSpace + (width - 20) / 2, }; } else { triangleStyle = { alignSelf: 'flex-end', right: extraRightSpace + (width - 20) / 2, }; } let triangleDown = null; let triangleUp = null; if (computedTooltipLocation === 'above') { triangleDown = ; } else if (computedTooltipLocation === 'below') { triangleUp = ; } const isOpeningSidebar = !!chatContext?.currentTransitionSidebarSourceID; const buttonProps: ButtonProps = { ...navAndRouteForFlow, - progress: position, progressV2: positionV2, isOpeningSidebar, }; const itemsStyles = [styles.items, styles.itemsFixed]; let tooltip = null; if (computedTooltipLocation !== 'fixed') { tooltip = ( {triangleUp} {items} {triangleDown} ); } else if (computedTooltipLocation === 'fixed' && !params.hideTooltip) { tooltip = ( {items} ); } return ( {tooltip} ); } function MemoizedTooltip(props: TooltipPropsType) { const { visibleEntryIDs } = props.route.params; const { goBackOnce } = props.navigation; const { setParams } = props.navigation; const hideTooltip = React.useCallback(() => { const paramsUpdate: any = { hideTooltip: true }; setParams(paramsUpdate); }, [setParams]); return ( ); } return React.memo(MemoizedTooltip); } function getTooltipHeight(numEntries: number): number { // 10 (triangle) + 37 * numEntries (entries) + numEntries - 1 (padding) return 9 + 38 * numEntries; } const fixedTooltipHeight: number = 53; export { createTooltip, fixedTooltipHeight };