11import { useLayoutEffect , useState } from "react" ;
2- import { View } from "react-native" ;
32import { GestureDetector , usePanGesture } from "react-native-gesture-handler" ;
43import Animated , {
54 cancelAnimation ,
5+ Easing ,
6+ FadeOut ,
67 ReduceMotion ,
78 runOnJS ,
89 useAnimatedStyle ,
910 useSharedValue ,
1011 withTiming ,
12+ type EntryAnimationsValues ,
1113} from "react-native-reanimated" ;
1214import { useSafeAreaInsets } from "react-native-safe-area-context" ;
1315import { Toast } from "../../components/ui/Toast" ;
16+ import { MOBILE_MOTION } from "../../lib/designTokens" ;
1417import {
1518 dismissThreadUndoNotice ,
1619 readThreadUndoNotice ,
1720 useThreadUndoNotice ,
1821} from "./thread-undo-notice" ;
1922
2023const SWIPE_TIMING = { duration : 160 , reduceMotion : ReduceMotion . System } ;
24+ const ENTER_TIMING = {
25+ duration : MOBILE_MOTION . enter ,
26+ easing : Easing . out ( Easing . cubic ) ,
27+ reduceMotion : ReduceMotion . System ,
28+ } ;
29+ const NOTICE_EXITING = FadeOut . duration ( MOBILE_MOTION . exit ) . reduceMotion ( ReduceMotion . System ) ;
30+ const noticeEntering = ( values : EntryAnimationsValues ) => {
31+ "worklet" ;
32+ return {
33+ initialValues : { originY : values . targetOriginY + values . targetHeight + 12 } ,
34+ animations : { originY : withTiming ( values . targetOriginY , ENTER_TIMING ) } ,
35+ } ;
36+ } ;
2137
2238export function ThreadUndoNotice ( props : { readonly visible : boolean } ) {
2339 const notice = useThreadUndoNotice ( ) ;
@@ -74,18 +90,21 @@ function SwipeableUndoNotice(props: {
7490 transform : [ { translateX : translation . value } ] ,
7591 } ) ) ;
7692
93+ // Clip the entrance above navigation; the notice intentionally covers the anchored FAB.
7794 return (
78- < View
79- className = "absolute inset-x-3 z-[100]"
95+ < Animated . View
96+ className = "absolute inset-x-3 z-[100] overflow-hidden "
8097 style = { { bottom : insets . bottom + 12 } }
8198 pointerEvents = "box-none"
99+ exiting = { NOTICE_EXITING }
82100 onLayout = { ( event ) => {
83101 width . set ( event . nativeEvent . layout . width ) ;
84102 } }
85103 >
86104 < GestureDetector gesture = { gesture } >
87105 < Animated . View
88106 collapsable = { false }
107+ entering = { noticeEntering }
89108 accessible
90109 accessibilityRole = "alert"
91110 accessibilityLiveRegion = "assertive"
@@ -102,6 +121,6 @@ function SwipeableUndoNotice(props: {
102121 />
103122 </ Animated . View >
104123 </ GestureDetector >
105- </ View >
124+ </ Animated . View >
106125 ) ;
107126}
0 commit comments