Add iOS 26 fluid zoom transition for Menu sheets

On iOS 26+, Menu bottom sheets now morph from their trigger button
using UIViewController.preferredTransition = .zoom. This creates a
fluid visual connection between the trigger and the presented sheet,
complementing the Liquid Glass design language.

The sourceViewTag prop is also available on the generic Dialog/BottomSheet
layer so any dialog can opt into the zoom transition.

https://claude.ai/code/session_011cNDhEb2cDgg5QbVuzEyH1
This commit is contained in:
Claude
2026-02-28 19:18:44 +00:00
committed by Samuel Newman
parent c42502fdcb
commit e143bcd030
6 changed files with 30 additions and 7 deletions
+7 -3
View File
@@ -1,5 +1,6 @@
import {cloneElement, Fragment, isValidElement, useMemo} from 'react'
import {cloneElement, Fragment, isValidElement, useMemo, useRef} from 'react'
import {
findNodeHandle,
Pressable,
type StyleProp,
type TextStyle,
@@ -46,9 +47,11 @@ export function Root({
control?: Dialog.DialogControlProps
}>) {
const defaultControl = Dialog.useDialogControl()
const triggerRef = useRef<View>(null)
const context = useMemo<ContextType>(
() => ({
control: control || defaultControl,
triggerRef,
}),
[control, defaultControl],
)
@@ -79,7 +82,7 @@ export function Trigger({
pressed,
},
props: {
ref: null,
ref: context.triggerRef,
onPress: context.control.open,
onFocus,
onBlur,
@@ -101,11 +104,12 @@ export function Outer({
}>) {
const context = useMenuContext()
const {_} = useLingui()
const sourceViewTag = findNodeHandle(context.triggerRef.current) ?? undefined
return (
<Dialog.Outer
control={context.control}
nativeOptions={{preventExpansion: true}}>
nativeOptions={{preventExpansion: true, sourceViewTag}}>
<Dialog.Handle />
{/* Re-wrap with context since Dialogs are portal-ed to root */}
<Context.Provider value={context}>
+3 -1
View File
@@ -1,4 +1,4 @@
import {forwardRef, useCallback, useId, useMemo, useState} from 'react'
import {forwardRef, useCallback, useId, useMemo, useRef, useState} from 'react'
import {
Pressable,
type StyleProp,
@@ -62,9 +62,11 @@ export function Root({
}>) {
const {_} = useLingui()
const defaultControl = useMenuControl()
const triggerRef = useRef<View>(null)
const context = useMemo<ContextType>(
() => ({
control: control || defaultControl,
triggerRef,
}),
[control, defaultControl],
)
+3 -1
View File
@@ -3,6 +3,7 @@ import {
type AccessibilityRole,
type GestureResponderEvent,
type PressableProps,
type View,
} from 'react-native'
import type React from 'react'
@@ -12,6 +13,7 @@ import {type Props as SVGIconProps} from '#/components/icons/common'
export type ContextType = {
control: Dialog.DialogOuterProps['control']
triggerRef: React.RefObject<View | null>
}
export type ItemContextType = {
@@ -61,7 +63,7 @@ export type TriggerChildProps =
* object is empty.
*/
props: {
ref: null
ref: React.RefObject<View | null>
onPress: () => void
onFocus: () => void
onBlur: () => void