import { useState } from 'react'; import { Platform, StyleSheet, View } from 'react-native'; import { r, radius, useThemedStyles } from '../../../theme'; import { GlassLayer } from '../GlassLayer'; import { GlassGroup } from '../GlassLayer/GlassGroup'; import { nativeFallbackStyles, useNativeFallbackLight, } from '../../../theme/nativeFallbackStyles'; import { makeStyles } from './styles'; import type { ActionMenuPopoverCardProps } from './types'; export function ActionMenuPopoverCard({ children, pointer, style, contentStyle, testID, }: ActionMenuPopoverCardProps) { const styles = useThemedStyles(makeStyles); const fallbackLight = useNativeFallbackLight(); const [width, setWidth] = useState(0); const pointerWidth = Math.min(r(26), width); const pointerHeight = (pointerWidth * 14) / 26; const half = pointerWidth / 2; // Web 没有 SDK 材质融合,箭头恰好接边,避免重复叠色形成亮缝。 const overlap = Platform.OS === 'web' ? 0 : r(1); const inset = Math.min(radius['3xl'] + half, width / 2); const offset = pointer && Number.isFinite(pointer.offset) ? Math.max(inset, Math.min(pointer.offset, width - inset)) : width / 2; return ( setWidth(event.nativeEvent.layout.width)} > {pointer && width > 0 ? ( ) : null} {children} ); }