-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated new conversation Handling Moved components to be in features branch Updated title components Bumped RN SDK Commented out api header work
- Loading branch information
Showing
26 changed files
with
1,072 additions
and
368 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import React, { memo, useCallback, useMemo } from "react"; | ||
import { ConversationTitleDumb } from "../../features/conversations/components/ConversationTitleDumb"; | ||
import { useGroupNameQuery } from "@queries/useGroupNameQuery"; | ||
import { ConversationTopic } from "@xmtp/react-native-sdk"; | ||
import { useCurrentAccount } from "@data/store/accountsStore"; | ||
import { NativeStackNavigationProp } from "@react-navigation/native-stack"; | ||
import { NavigationParamList } from "@screens/Navigation/Navigation"; | ||
import { ImageStyle, Platform } from "react-native"; | ||
import { useRouter } from "@navigation/useNavigation"; | ||
import { useGroupPhotoQuery } from "@queries/useGroupPhotoQuery"; | ||
import Avatar from "@components/Avatar"; | ||
import { AvatarSizes } from "@styles/sizes"; | ||
import { ThemedStyle, useAppTheme } from "@theme/useAppTheme"; | ||
import { GroupAvatarDumb } from "@components/GroupAvatar"; | ||
import { useConversationTitleLongPress } from "../../features/conversations/hooks/useConversationTitleLongPress"; | ||
import { useGroupMembersAvatarData } from "../../features/conversations/hooks/useGroupMembersAvatarData"; | ||
|
||
type GroupConversationTitleProps = { | ||
topic: ConversationTopic; | ||
}; | ||
|
||
type UseUserInteractionProps = { | ||
topic: ConversationTopic; | ||
navigation: NativeStackNavigationProp<NavigationParamList>; | ||
}; | ||
|
||
const useUserInteraction = ({ navigation, topic }: UseUserInteractionProps) => { | ||
const onPress = useCallback(() => { | ||
// textInputRef?.current?.blur(); | ||
navigation.push("Group", { topic }); | ||
}, [navigation, topic]); | ||
|
||
const onLongPress = useConversationTitleLongPress(topic); | ||
|
||
return { onPress, onLongPress }; | ||
}; | ||
|
||
export const GroupConversationTitle = memo( | ||
({ topic }: GroupConversationTitleProps) => { | ||
const currentAccount = useCurrentAccount()!; | ||
|
||
const { data: groupName, isLoading: groupNameLoading } = useGroupNameQuery( | ||
currentAccount, | ||
topic! | ||
); | ||
|
||
const { data: groupPhoto, isLoading: groupPhotoLoading } = | ||
useGroupPhotoQuery(currentAccount, topic!); | ||
|
||
const { data: memberData } = useGroupMembersAvatarData({ topic }); | ||
|
||
const navigation = useRouter(); | ||
|
||
const { themed } = useAppTheme(); | ||
|
||
const { onPress, onLongPress } = useUserInteraction({ | ||
topic, | ||
navigation, | ||
}); | ||
|
||
const displayAvatar = !groupPhotoLoading && !groupNameLoading; | ||
|
||
const avatarComponent = useMemo(() => { | ||
if (displayAvatar) return null; | ||
return groupPhoto ? ( | ||
<Avatar | ||
uri={groupPhoto} | ||
size={AvatarSizes.conversationTitle} | ||
style={themed($avatar)} | ||
/> | ||
) : ( | ||
<GroupAvatarDumb | ||
members={memberData} | ||
size={AvatarSizes.conversationTitle} | ||
style={themed($avatar)} | ||
/> | ||
); | ||
}, [displayAvatar, groupPhoto, memberData, themed]); | ||
|
||
return ( | ||
<ConversationTitleDumb | ||
title={groupName ?? undefined} | ||
onLongPress={onLongPress} | ||
onPress={onPress} | ||
avatarComponent={avatarComponent} | ||
/> | ||
); | ||
} | ||
); | ||
|
||
const $avatar: ThemedStyle<ImageStyle> = (theme) => ({ | ||
marginRight: Platform.OS === "android" ? theme.spacing.lg : theme.spacing.xxs, | ||
marginLeft: Platform.OS === "ios" ? theme.spacing.zero : -theme.spacing.xxs, | ||
}); |
Oops, something went wrong.