import * as React from 'react'; import { View } from 'react-native'; import type { DataModel } from '../../chat'; import { useColors } from '../../hook'; import { useI18nContext } from '../../i18n'; import { usePaletteContext } from '../../theme'; import { IconButton, Text2Button } from '../../ui/Button'; import { PressableHighlight } from '../../ui/Pressable'; import { HighText } from '../../ui/Text'; import { Avatar } from '../Avatar'; import type { ContactSearchModel } from '../ContactList'; import type { ListSearchItemProps } from './types'; export function ListSearchItem( props: ListSearchItemProps ) { const { searchType } = props; if (searchType === 'create-group' || searchType === 'add-group-member') { const p = props as any as ListSearchItemProps; return ; } else if (searchType === 'forward-message') { const p = props as any as ListSearchItemProps; return ; } return ; } export function DefaultListSearchItem< ComponentModel extends DataModel = DataModel, >(props: ListSearchItemProps) { const { data, keyword, onClicked } = props; const { colors } = usePaletteContext(); const { getColor } = useColors({ t2: { light: colors.neutral[5], dark: colors.neutral[6], }, }); return ( { onClicked?.(data); }} > ); } export function StateListSearchItem( props: ListSearchItemProps ) { const { data, keyword, onClicked } = props; const { checked, onCheckClicked, disable } = data; const { colors } = usePaletteContext(); const { getColor } = useColors({ t2: { light: colors.neutral[5], dark: colors.neutral[6], }, }); return ( { if (checked !== undefined) { if (disable !== true) { onCheckClicked?.(data); } } else { onClicked?.(data); } }} > {checked !== undefined ? ( { if (disable !== true) { onCheckClicked?.(data); } }} /> ) : null} ); } export function ForwardListSearchItem( props: ListSearchItemProps ) { const { data, keyword, searchType } = props; const { forwarded, onClickedForward } = data; const { tr } = useI18nContext(); const { colors } = usePaletteContext(); const { getColor } = useColors({ t2: { light: colors.neutral[5], dark: colors.neutral[6], }, btn_bg: { light: colors.neutral[95], dark: colors.neutral[2], }, }); const _onForwardClicked = React.useCallback(() => { if (searchType === 'forward-message' && forwarded !== true) { onClickedForward?.(data); } }, [data, forwarded, onClickedForward, searchType]); return ( {searchType === 'forward-message' ? ( <> { onClickedForward?.(data); }} /> ) : null} ); }