import React, { useState, useRef, useEffect } from "react"; import { View, Text, Platform } from "react-native"; interface TooltipProps { text: string; children: React.ReactElement; } export function Tooltip({ text, children }: TooltipProps) { const [showTooltip, setShowTooltip] = useState(false); const [position, setPosition] = useState({ top: 0, left: 0 }); const containerRef = useRef(null); // Only show tooltips on web platform if (Platform.OS !== "web") { return children; } const handleMouseEnter = (e: any) => { if (containerRef.current) { const rect = containerRef.current.getBoundingClientRect(); setPosition({ top: rect.top - 40, left: rect.left + rect.width / 2 + 20, }); setShowTooltip(true); } }; const handleMouseLeave = () => { setShowTooltip(false); }; return ( {children} {showTooltip && ( {text} )} ); }