37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
// Metro module 8739 (f8740).
|
|
import { useRef, useState, useCallback, useMemo, useEffect } from "react";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import { useTooltip } from "../../../design/components/Tooltip/native/useTooltip.native";
|
|
import { PressableOpacity } from "../../../design/void/Pressables/native/Pressables";
|
|
const hitSlop = {
|
|
top: 14,
|
|
bottom: 14,
|
|
left: 14,
|
|
right: 14
|
|
};
|
|
export function DynamicBadgeTooltip(props) {
|
|
const { children, accessibilityLabel, tooltipPosition = "bottom" } = props;
|
|
const position = tooltipPosition;
|
|
const ref = useRef(null);
|
|
const [state, setState] = useState(false);
|
|
const label = intl.string(t.dCou7i);
|
|
const callback = useCallback(() => {
|
|
setState(false);
|
|
}, []);
|
|
useTooltip(ref, useMemo(() => ({
|
|
position,
|
|
label,
|
|
visible: state,
|
|
onPress: callback
|
|
}), [position, label, state, callback]));
|
|
useEffect(() => {
|
|
if (state) {
|
|
let c26279_0 = setTimeout(() => setState(false), 2500);
|
|
return () => clearTimeout(c26279_0);
|
|
}
|
|
}, [state]);
|
|
return <PressableOpacity ref={ref} onPress={useCallback(() => {
|
|
setState((prevState) => !prevState);
|
|
}, [])} hitSlop={hitSlop} accessibilityRole="button" accessibilityLabel={accessibilityLabel} accessibilityHint={label}>{children}</PressableOpacity>;
|
|
}
|