The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { MenuView } from "@react-native-menu/menu"; |
| 2 | import { useGT } from "gt-react-native"; |
| 3 | import type { ReactElement } from "react"; |
| 4 | import { Platform, View, type PressableProps, type StyleProp, type ViewStyle } from "react-native"; |
| 5 | |
| 6 | import type { useMediaActions } from "../state/mediaActions"; |
| 7 | import { SymbolView } from "./ui/AppSymbol"; |
| 8 | import { Menu } from "./ui/Menu"; |
| 9 | |
| 10 | export function MediaActionsMenu(props: { |
| 11 | readonly media: ReturnType<typeof useMediaActions>; |
| 12 | readonly inModal?: boolean; |
| 13 | readonly children?: ReactElement<PressableProps>; |
| 14 | readonly style?: StyleProp<ViewStyle>; |
| 15 | }) { |
| 16 | const gt = useGT(); |
| 17 | if (props.media.actions.length === 0) return props.children ?? null; |
| 18 | // Android's normal anchored menu lives in the app-root portal, behind native modals. |
| 19 | const nativeAndroidMenu = props.inModal && Platform.OS === "android"; |
| 20 | const MediaMenu = nativeAndroidMenu ? MenuView : Menu; |
| 21 | return ( |
| 22 | <MediaMenu |
| 23 | title={props.media.title} |
| 24 | style={props.style} |
| 25 | shouldOpenOnLongPress={props.children !== undefined} |
| 26 | actions={props.media.actions.map(({ id, title, disabled }) => ({ |
| 27 | id, |
| 28 | title, |
| 29 | attributes: { disabled: disabled ?? false }, |
| 30 | }))} |
| 31 | onPressAction={({ nativeEvent }) => { |
| 32 | props.media.actions.find(({ id }) => id === nativeEvent.event)?.run(); |
| 33 | }} |
| 34 | > |
| 35 | {props.children ?? ( |
| 36 | <View |
| 37 | accessible |
| 38 | accessibilityRole="button" |
| 39 | accessibilityLabel={gt("Media actions")} |
| 40 | className="min-h-11 min-w-11 items-center justify-center rounded-md bg-black/60" |
| 41 | > |
| 42 | <SymbolView name="ellipsis" size={20} tintColor="#ffffff" type="monochrome" /> |
| 43 | </View> |
| 44 | )} |
| 45 | </MediaMenu> |
| 46 | ); |
| 47 | } |