diff options
author | Samuel Newman <mozzius@protonmail.com> | 2025-03-27 18:53:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-27 09:53:42 -0700 |
commit | 7d1ebf6a027085ddc10a7dad2075d5e52d314233 (patch) | |
tree | 7a76364ad0684aa78cb8b267dd039518e2830fd7 /src/components/ContextMenu/types.ts | |
parent | 1e688dee248dcbee318ed241bc19968b711bc546 (diff) | |
download | voidsky-7d1ebf6a027085ddc10a7dad2075d5e52d314233.tar.zst |
Allow selecting `ContextMenu` options via press-and-hold (#8020)
* save locations of menu items * enable panning to select items * rm unused type * fix haptic overfiring
Diffstat (limited to 'src/components/ContextMenu/types.ts')
-rw-r--r-- | src/components/ContextMenu/types.ts | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/components/ContextMenu/types.ts b/src/components/ContextMenu/types.ts index 0b3fedc55..2084ecf19 100644 --- a/src/components/ContextMenu/types.ts +++ b/src/components/ContextMenu/types.ts @@ -1,17 +1,29 @@ import React from 'react' -import {AccessibilityRole, StyleProp, ViewStyle} from 'react-native' +import { + AccessibilityRole, + GestureResponderEvent, + StyleProp, + ViewStyle, +} from 'react-native' import {SharedValue} from 'react-native-reanimated' import * as Dialog from '#/components/Dialog' -import {RadixPassThroughTriggerProps} from '#/components/Menu/types' +import { + ItemProps as MenuItemProps, + RadixPassThroughTriggerProps, +} from '#/components/Menu/types' export type { GroupProps, ItemIconProps, - ItemProps, ItemTextProps, } from '#/components/Menu/types' +// Same as Menu.ItemProps, but onPress is not guaranteed to get an event +export type ItemProps = Omit<MenuItemProps, 'onPress'> & { + onPress: (evt?: GestureResponderEvent) => void +} + export type Measurement = { x: number y: number @@ -28,6 +40,19 @@ export type ContextType = { translationSV: SharedValue<number> open: (evt: Measurement) => void close: () => void + registerHoverable: ( + id: string, + rect: Measurement, + onTouchUp: () => void, + ) => void + hoverablesSV: SharedValue<Record<string, {id: string; rect: Measurement}>> + hoveredMenuItem: string | null + setHoveredMenuItem: React.Dispatch<React.SetStateAction<string | null>> + onTouchUpMenuItem: (id: string) => void +} + +export type MenuContextType = { + align: 'left' | 'right' } export type ItemContextType = { |