import * as React from 'react' import { AccessibilityInfo, findNodeHandle, Pressable, Text as RNText, View, } from 'react-native' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {FocusScope} from '@tamagui/focus-scope' import {IStep, Labels} from 'rn-tourguide' import {useWebBodyScrollLock} from '#/lib/hooks/useWebBodyScrollLock' import {useA11y} from '#/state/a11y' import {Logo} from '#/view/icons/Logo' import {atoms as a, useTheme} from '#/alf' import {Button, ButtonText} from '#/components/Button' import {leading, Text} from '#/components/Typography' const stopPropagation = (e: any) => e.stopPropagation() export interface TooltipComponentProps { isFirstStep?: boolean isLastStep?: boolean currentStep: IStep labels?: Labels handleNext?: () => void handlePrev?: () => void handleStop?: () => void } export function TooltipComponent({ isLastStep, handleNext, handleStop, currentStep, labels, }: TooltipComponentProps) { const t = useTheme() const {_} = useLingui() const btnRef = React.useRef(null) const textRef = React.useRef(null) const {screenReaderEnabled} = useA11y() useWebBodyScrollLock(true) const focusTextNode = () => { const node = textRef.current ? findNodeHandle(textRef.current) : undefined if (node) { AccessibilityInfo.setAccessibilityFocus(node) } } // handle initial focus immediately on mount React.useLayoutEffect(() => { focusTextNode() }, []) // handle focus between steps const innerHandleNext = () => { handleNext?.() setTimeout(() => focusTextNode(), 200) } return ( true} onTouchEnd={stopPropagation} style={[ t.atoms.bg, a.px_lg, a.py_lg, a.flex_col, a.gap_md, a.rounded_sm, a.shadow_md, {maxWidth: 300}, ]}> {screenReaderEnabled && ( )} Quick tip {currentStep.text} {!isLastStep ? ( ) : ( )} {screenReaderEnabled && ( )} ) }