import type { MenuAction } from "@react-native-menu/menu";import { Pressable } from "react-native"; import { SymbolView } from "./AppSymbol";import { ControlPillMenu } from "./ControlPill"; const ATTACHMENT_MENU_ACTIONS: MenuAction[] = [ { id: "photos", title: "Photo Library", image: "photo" }, { id: "files", title: "Choose Files", image: "folder" },]; export function ComposerAttachmentButton(props: { readonly disabled?: boolean; readonly supportsFiles: boolean; readonly onPickMedia: () => Promise<void>; readonly onPickFiles: () => Promise<void>;}) { const button = ( <Pressable accessibilityLabel="Add attachment" accessibilityRole="button" accessibilityState={{ disabled: props.disabled }} className="size-[44px] shrink-0 items-center justify-center rounded-full active:opacity-70 disabled:opacity-50" disabled={props.disabled} onPress={props.supportsFiles ? undefined : () => void props.onPickMedia()} > <SymbolView name="plus" size={20} weight="regular" tintColorClassName="accent-icon" type="monochrome" /> </Pressable> ); if (props.disabled || !props.supportsFiles) { return button; } return ( <ControlPillMenu actions={ATTACHMENT_MENU_ACTIONS} onPressAction={({ nativeEvent }) => { if (nativeEvent.event === "photos") { void props.onPickMedia(); } else if (nativeEvent.event === "files") { void props.onPickFiles(); } }} > {button} </ControlPillMenu> );}
import type { MenuAction } from "@react-native-menu/menu";
import { Pressable } from "react-native";
import { SymbolView } from "./AppSymbol";
import { ControlPillMenu } from "./ControlPill";
const ATTACHMENT_MENU_ACTIONS: MenuAction[] = [
{ id: "photos", title: "Photo Library", image: "photo" },
{ id: "files", title: "Choose Files", image: "folder" },
];
export function ComposerAttachmentButton(props: {
readonly disabled?: boolean;
readonly supportsFiles: boolean;
readonly onPickMedia: () => Promise<void>;
readonly onPickFiles: () => Promise<void>;
}) {
const button = (
<Pressable
accessibilityLabel="Add attachment"
accessibilityRole="button"
accessibilityState={{ disabled: props.disabled }}
className="size-[44px] shrink-0 items-center justify-center rounded-full active:opacity-70 disabled:opacity-50"
disabled={props.disabled}
onPress={props.supportsFiles ? undefined : () => void props.onPickMedia()}
>
<SymbolView
name="plus"
size={20}
weight="regular"
tintColorClassName="accent-icon"
type="monochrome"
/>
</Pressable>
);
if (props.disabled || !props.supportsFiles) {
return button;
}
return (
<ControlPillMenu
actions={ATTACHMENT_MENU_ACTIONS}
onPressAction={({ nativeEvent }) => {
if (nativeEvent.event === "photos") {
void props.onPickMedia();
} else if (nativeEvent.event === "files") {
void props.onPickFiles();
}
}}
>
{button}
</ControlPillMenu>
);
}