import React from 'react'; import type { StyleProp, ViewStyle } from 'react-native'; import { View } from 'react-native'; import { Avatar, Icon, useUIKitTheme } from '@sendbird/uikit-react-native-foundation'; import { SendbirdBaseChannel, getMembersExcludeMe, isDefaultCoverImage } from '@sendbird/uikit-utils'; import { useSendbirdChat } from '../hooks/useContext'; type Props = { channel: SendbirdBaseChannel; size: number; containerStyle?: StyleProp; }; const ChannelCover = ({ channel, ...avatarProps }: Props) => { const { currentUser } = useSendbirdChat(); const { colors } = useUIKitTheme(); if (channel.isGroupChannel()) { // custom channel cover if (!isDefaultCoverImage(channel.coverUrl) || !currentUser) { return ; } // broadcast channel cover if (channel.isBroadcast) { return ( ); } // no members, use anonymous profile if (channel.memberCount <= 1) { return ; } // 1:1, use member profile if (channel.memberCount === 2) { const otherUserProfile = channel.members.filter((m) => m.userId !== currentUser.userId)?.[0]?.profileUrl; return ; } // group, use members profile return ( {getMembersExcludeMe(channel, currentUser?.userId).map((m) => ( ))} ); } if (channel.isOpenChannel()) { // channel cover return ; } return ; }; export default ChannelCover;