import React, { useCallback, useState, useMemo } from 'react'; import type { LayoutChangeEvent } from 'react-native'; import { Platform } from 'react-native'; import { ForeignObject, G } from 'react-native-svg'; import Box from '../../Box'; import Typography from '../../Typography'; import type { AxisCoordinates } from '../types'; import { useTheme } from '../../../theme'; type EmptyStateProps = { coordinates: AxisCoordinates; content: string; }; const EmptyStateText = ({ content }: { content: string }) => { return ( {content} ); }; const EmptyState = ({ content, coordinates }: EmptyStateProps) => { const [textSize, setTextSize] = useState({ width: 0, height: 0 }); const { xStart, xEnd, yStart, yEnd } = coordinates; const theme = useTheme(); const { sizes: { defaultWebEmptyStateWidth, defaultWebEmptyStateHeight }, } = theme.__hd__.chart; const centerPosition = useMemo(() => { const centerX = xStart + (xEnd - xStart) / 2; const centerY = yStart + (yEnd - yStart) / 2; return { centerX, centerY }; }, [xStart, xEnd, yStart, yEnd]); const onTextLayout = useCallback((event: LayoutChangeEvent) => { const { width, height } = event.nativeEvent.layout; setTextSize({ width, height }); }, []); return ( {Platform.OS === 'web' ? ( ) : ( )} ); }; export default EmptyState;