import * as React from 'react'; import { StyleProp, View, ViewStyle } from 'react-native'; import { useColors } from '../../hook'; import { StatusType } from '../types'; type Point = { x: number; y: number; }; export function findIntersectionPoints(parentSize: number): Point[] { const sqrt2 = Math.sqrt(2); const halfA = parentSize / 2; const offset = (parentSize / 2) * (sqrt2 / 2); const intersection1: Point = { x: halfA + offset, y: halfA + offset, }; const intersection2: Point = { x: halfA - offset, y: halfA - offset, }; return [intersection1, intersection2]; } export type AvatarStatusProps = { parentSize: number; size?: number; childrenPaddingSize: number; scale: number; intersection?: Point; positionStyle?: 'bottomRight1' | 'bottomRight2'; containerStyle?: StyleProp; style?: StyleProp; status: string; AvatarStatusRender?: | React.FC<{ status: StatusType; style?: StyleProp; }> | React.MemoExoticComponent< (props: { status: StatusType; style?: StyleProp; }) => React.ReactElement >; }; export function AvatarStatus(props: AvatarStatusProps) { const { parentSize, childrenPaddingSize, scale, intersection = findIntersectionPoints(parentSize)[0], positionStyle = 'bottomRight1', containerStyle, style, AvatarStatusRender, status, } = props; const { getColor } = useColors({}); return ( {AvatarStatusRender ? ( ) : ( )} ); }