diff --git a/design-system/Menu/Menu.tsx b/design-system/dropdown-menu/dropdown-menu.tsx similarity index 85% rename from design-system/Menu/Menu.tsx rename to design-system/dropdown-menu/dropdown-menu.tsx index 742e6c28a..417e8031d 100644 --- a/design-system/Menu/Menu.tsx +++ b/design-system/dropdown-menu/dropdown-menu.tsx @@ -8,20 +8,28 @@ import { Platform, StyleProp, ViewStyle } from "react-native"; import { Pressable } from "../Pressable"; import { useAppTheme } from "@/theme/useAppTheme"; import { Haptics } from "@/utils/haptics"; -import { getInlinedItem } from "./Menu.utils"; +import { getInlinedItem } from "./dropdown-menu.utils"; -export type IMenuAction = Omit & { +export type IDropdownMenuAction = Omit< + RNMenuAction, + "titleColor" | "imageColor" +> & { color?: string; }; -type MenuProps = { - actions: IMenuAction[]; +type IDropdownMenuProps = { + actions: IDropdownMenuAction[]; children: React.ReactNode; style?: StyleProp; onPress?: (actionId: string) => void; }; -export const Menu = ({ children, actions, style, onPress }: MenuProps) => { +export const DropdownMenu = ({ + children, + actions, + style, + onPress, +}: IDropdownMenuProps) => { const { theme } = useAppTheme(); const themedActions: RNMenuAction[] = useMemo(() => { diff --git a/design-system/Menu/Menu.utils.tsx b/design-system/dropdown-menu/dropdown-menu.utils.tsx similarity index 100% rename from design-system/Menu/Menu.utils.tsx rename to design-system/dropdown-menu/dropdown-menu.utils.tsx diff --git a/features/conversation-list/conversation-list.screen-header.tsx b/features/conversation-list/conversation-list.screen-header.tsx index 35d642773..eaa3f85b9 100644 --- a/features/conversation-list/conversation-list.screen-header.tsx +++ b/features/conversation-list/conversation-list.screen-header.tsx @@ -13,16 +13,48 @@ import { Text } from "@/design-system/Text"; import { usePreferredName } from "@/hooks/usePreferredName"; import { translate } from "@/i18n"; import { useHeader } from "@/navigation/use-header"; -import { useAppTheme } from "@/theme/useAppTheme"; +import { ThemedStyle, useAppTheme } from "@/theme/useAppTheme"; import { shortDisplayName } from "@/utils/str"; import { useAccountsProfiles } from "@/utils/useAccountsProfiles"; import { useNavigation } from "@react-navigation/native"; -import React from "react"; -import { Alert, Platform } from "react-native"; -import { Menu } from "@/design-system/Menu/Menu"; +import React, { useCallback } from "react"; +import { Alert, ViewStyle } from "react-native"; +import { DropdownMenu } from "@/design-system/dropdown-menu/dropdown-menu"; + +const $dropDownMenu: ThemedStyle = (theme) => ({ + paddingVertical: theme.spacing.sm, + paddingRight: theme.spacing.sm, +}); + +const $iconContainer: ThemedStyle = (theme) => ({ + width: theme.spacing.container.small, + height: theme.spacing.container.small, +}); + +const $rowContainer: ThemedStyle = (theme) => ({ + alignItems: "center", + columnGap: theme.spacing.xxxs, +}); + +const $rightContainer: ThemedStyle = (theme) => ({ + alignItems: "center", + columnGap: theme.spacing.xxs, +}); + +const $newConversationContainer: ViewStyle = { + marginBottom: 4, // The square.and.pencil icon is not centered with the qrcode if we don't have this margin +}; + +const $titleContainer: ViewStyle = { + alignItems: "center", +}; + +const $avatarContainer: ThemedStyle = (theme) => ({ + padding: theme.spacing.xxs, +}); export function useHeaderWrapper() { - const { theme } = useAppTheme(); + const { theme, themed } = useAppTheme(); const navigation = useNavigation(); const currentAccount = useCurrentAccount(); const preferredName = usePreferredName(currentAccount!); @@ -30,16 +62,29 @@ export function useHeaderWrapper() { const accountsProfiles = useAccountsProfiles(); const setCurrentAccount = useAccountsStore((s) => s.setCurrentAccount); + const onDropdownPress = useCallback( + (actionId: string) => { + if (actionId === "all-chats") { + Alert.alert("Coming soon"); + } else if (actionId === "new-account") { + navigation.navigate("NewAccountNavigator"); + } else if (actionId === "app-settings") { + Alert.alert("Coming soon"); + } + + // Pressed on an account + else { + setCurrentAccount(actionId, false); + } + }, + [navigation, setCurrentAccount] + ); + useHeader( { safeAreaEdges: ["top"], RightActionComponent: ( - + { @@ -47,9 +92,7 @@ export function useHeaderWrapper() { }} /> { navigation.navigate("NewConversation"); @@ -58,12 +101,7 @@ export function useHeaderWrapper() { ), titleComponent: ( - + { navigation.navigate("Profile", { @@ -72,33 +110,13 @@ export function useHeaderWrapper() { }} hitSlop={theme.spacing.sm} > -
+
- { - if (actionId === "all-chats") { - Alert.alert("Coming soon"); - } else if (actionId === "new-account") { - navigation.navigate("NewAccountNavigator"); - } else if (actionId === "app-settings") { - Alert.alert("Coming soon"); - } - - // Pressed on an account - else { - setCurrentAccount(actionId, false); - } - }} + { return { @@ -121,21 +139,9 @@ export function useHeaderWrapper() { }, ]} > - + {shortDisplayName(preferredName)} -
+
-
+ ), }, diff --git a/features/conversation/conversation-composer/conversation-composer-add-attachment-button.tsx b/features/conversation/conversation-composer/conversation-composer-add-attachment-button.tsx index ebc4dbb30..e6dc8ce18 100644 --- a/features/conversation/conversation-composer/conversation-composer-add-attachment-button.tsx +++ b/features/conversation/conversation-composer/conversation-composer-add-attachment-button.tsx @@ -1,5 +1,5 @@ import { Center } from "@/design-system/Center"; -import { Menu } from "@/design-system/Menu/Menu"; +import { DropdownMenu } from "@/design-system/dropdown-menu/dropdown-menu"; import { useConversationComposerStore } from "@/features/conversation/conversation-composer/conversation-composer.store-context"; import { getCurrentAccount } from "@data/store/accountsStore"; import { Icon } from "@design-system/Icon/Icon"; @@ -96,24 +96,27 @@ export function AddAttachmentButton() { handleAttachmentSelected(asset); }, [handleAttachmentSelected]); + const onDropdownMenuPress = useCallback( + (actionId: string) => { + switch (actionId) { + case "camera": + openCamera(); + break; + case "mediaLibrary": + pickMedia(); + break; + } + }, + [openCamera, pickMedia] + ); + return ( - { - switch (actionId) { - case "camera": - openCamera(); - break; - case "mediaLibrary": - pickMedia(); - break; - default: - break; - } - }} + onPress={onDropdownMenuPress} actions={[ { id: "mediaLibrary", @@ -147,6 +150,6 @@ export function AddAttachmentButton() { size={20} // Value from figma />
- + ); }