Reveal chat timestamp on tap (#10262)
This commit is contained in:
@@ -235,7 +235,13 @@ export function Root({children}: {children: React.ReactNode}) {
|
||||
return <Context.Provider value={context}>{children}</Context.Provider>
|
||||
}
|
||||
|
||||
export function Trigger({children, label, contentLabel, style}: TriggerProps) {
|
||||
export function Trigger({
|
||||
children,
|
||||
label,
|
||||
contentLabel,
|
||||
style,
|
||||
onTap,
|
||||
}: TriggerProps) {
|
||||
const context = useContextMenuContext()
|
||||
const playHaptic = useHaptics()
|
||||
const insets = useSafeAreaInsets()
|
||||
@@ -294,6 +300,17 @@ export function Trigger({children, label, contentLabel, style}: TriggerProps) {
|
||||
}
|
||||
}, [context, insets])
|
||||
|
||||
const tapGesture = useMemo(() => {
|
||||
const gesture = Gesture.Tap()
|
||||
.numberOfTaps(1)
|
||||
.cancelsTouchesInView(false)
|
||||
.runOnJS(true)
|
||||
if (onTap) {
|
||||
gesture.onEnd(() => void onTap())
|
||||
}
|
||||
return gesture
|
||||
}, [onTap])
|
||||
|
||||
const doubleTapGesture = useMemo(() => {
|
||||
return Gesture.Tap()
|
||||
.numberOfTaps(2)
|
||||
@@ -346,8 +363,10 @@ export function Trigger({children, label, contentLabel, style}: TriggerProps) {
|
||||
})
|
||||
}, [open, hoverablesSV, onTouchUpMenuItem, hoveredItemSV, translationSV])
|
||||
|
||||
// Order matters here: doubleTapGesture must come before tapGesture.
|
||||
const composedGestures = Gesture.Exclusive(
|
||||
doubleTapGesture,
|
||||
tapGesture,
|
||||
pressAndHoldGesture,
|
||||
)
|
||||
|
||||
|
||||
@@ -84,6 +84,14 @@ export type TriggerProps = {
|
||||
hint?: string
|
||||
role?: AccessibilityRole
|
||||
style?: StyleProp<ViewStyle>
|
||||
/**
|
||||
* Callback for single taps. Composed with the double-tap and
|
||||
* press-and-hold gestures via `Gesture.Exclusive`, so a double tap
|
||||
* does not also fire this handler.
|
||||
*
|
||||
* @platform ios, android
|
||||
*/
|
||||
onTap?: () => void
|
||||
}
|
||||
export type TriggerChildProps =
|
||||
| {
|
||||
|
||||
Reference in New Issue
Block a user