mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-15 17:19:40 +02:00
Projects included: - maerchenzauber (NestJS backend + Expo mobile + SvelteKit web + Astro landing) - manacore (Expo mobile + SvelteKit web + Astro landing) - manadeck (NestJS backend + Expo mobile + SvelteKit web) - memoro (Expo mobile + SvelteKit web + Astro landing) This commit preserves the current state before monorepo restructuring. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
77 lines
1.7 KiB
TypeScript
77 lines
1.7 KiB
TypeScript
import React, { type FC, type ReactNode } from 'react';
|
|
// TODO: Migrate to @expo/ui ContextMenu
|
|
import { MenuView } from '~/components/ui/MenuViewPlaceholder';
|
|
import type { MenuActionConfig } from '~/config/menuActions';
|
|
import { buildMenuActions } from '~/utils/menuBuilder';
|
|
|
|
export interface NativeMenuProps {
|
|
/**
|
|
* Die Menu Actions die angezeigt werden sollen
|
|
*/
|
|
actions: MenuActionConfig[];
|
|
|
|
/**
|
|
* Callback wenn eine Action ausgewählt wird
|
|
*/
|
|
onAction: (actionId: string) => void;
|
|
|
|
/**
|
|
* Die Komponente die das Menu triggert
|
|
*/
|
|
children: ReactNode;
|
|
|
|
/**
|
|
* Ob das Menu ein Context Menu ist (Long Press) oder Dropdown (Tap)
|
|
* @default false (Dropdown)
|
|
*/
|
|
isContextMenu?: boolean;
|
|
|
|
/**
|
|
* Optional: Titel des Menus (nur iOS)
|
|
*/
|
|
title?: string;
|
|
|
|
/**
|
|
* Optional: Callbacks für Menu Events
|
|
*/
|
|
onOpenMenu?: () => void;
|
|
onCloseMenu?: () => void;
|
|
|
|
/**
|
|
* Optional: Theme Variant (nur iOS)
|
|
*/
|
|
themeVariant?: 'light' | 'dark';
|
|
}
|
|
|
|
/**
|
|
* Wrapper-Komponente für @react-native-menu/menu
|
|
* Vereinfacht die Verwendung von nativen Menus im Projekt
|
|
*/
|
|
export const NativeMenu: FC<NativeMenuProps> = ({
|
|
actions,
|
|
onAction,
|
|
children,
|
|
isContextMenu = false,
|
|
title,
|
|
onOpenMenu,
|
|
onCloseMenu,
|
|
themeVariant,
|
|
}) => {
|
|
const menuActions = buildMenuActions(actions);
|
|
|
|
return (
|
|
<MenuView
|
|
title={title}
|
|
actions={menuActions}
|
|
onPressAction={({ nativeEvent }) => {
|
|
onAction(nativeEvent.event);
|
|
}}
|
|
onOpenMenu={onOpenMenu}
|
|
onCloseMenu={onCloseMenu}
|
|
shouldOpenOnLongPress={isContextMenu}
|
|
themeVariant={themeVariant}
|
|
>
|
|
{children}
|
|
</MenuView>
|
|
);
|
|
};
|