11import { forwardRef , useCallback , useMemo , type FC } from 'react' ;
22import { Pressable , StyleSheet , type LayoutChangeEvent } from 'react-native' ;
33
4- import Animated , {
5- interpolate ,
6- useAnimatedStyle ,
7- withTiming ,
8- } from 'react-native-reanimated' ;
4+ import Animated from 'react-native-reanimated' ;
95import Svg , { Defs , RadialGradient , Rect , Stop } from 'react-native-svg' ;
106
117import { GestureDetector } from 'react-native-gesture-handler' ;
128import { useThemeColor } from '../../helpers/theme' ;
139import type { PressableRef } from '../../helpers/types' ;
1410import {
1511 PressableFeedbackAnimationProvider ,
16- usePressableFeedbackAnimation ,
1712 usePressableFeedbackHighlightAnimation ,
13+ usePressableFeedbackRippleAnimation ,
1814 usePressableFeedbackRootAnimation ,
1915} from './pressable-feedback.animation' ;
2016import { DISPLAY_NAME } from './pressable-feedback.constants' ;
@@ -116,48 +112,10 @@ const PressableFeedbackHighlight: FC<{
116112// --------------------------------------------------
117113
118114const PressableFeedbackRipple : FC < { } > = ( ) => {
119- const {
120- pressedCenterX,
121- pressedCenterY,
122- containerWidth,
123- containerHeight,
124- rippleProgress,
125- } = usePressableFeedbackAnimation ( ) ;
115+ const { rContainerStyle } = usePressableFeedbackRippleAnimation ( ) ;
126116
127117 const themeColorSurfaceSecondary = useThemeColor ( 'on-surface-hover' ) ;
128118
129- const rContainerStyle = useAnimatedStyle ( ( ) => {
130- const circleRadius =
131- Math . sqrt ( containerWidth . get ( ) ** 2 + containerHeight . get ( ) ** 2 ) * 1.25 ;
132-
133- const translateX = pressedCenterX . get ( ) - circleRadius ;
134- const translateY = pressedCenterY . get ( ) - circleRadius ;
135-
136- return {
137- width : circleRadius * 2 ,
138- height : circleRadius * 2 ,
139- borderRadius : circleRadius ,
140- opacity : withTiming (
141- interpolate ( rippleProgress . get ( ) , [ 0 , 1 , 2 ] , [ 0 , 1 , 0 ] ) ,
142- { duration : 40 }
143- ) ,
144- transform : [
145- {
146- translateX,
147- } ,
148- {
149- translateY,
150- } ,
151- {
152- scale : withTiming (
153- interpolate ( rippleProgress . get ( ) , [ 0 , 1 , 2 ] , [ 0 , 1 , 1 ] ) ,
154- { duration : 40 }
155- ) ,
156- } ,
157- ] ,
158- } ;
159- } ) ;
160-
161119 return (
162120 < Animated . View
163121 pointerEvents = "none"
@@ -169,18 +127,18 @@ const PressableFeedbackRipple: FC<{}> = () => {
169127 < RadialGradient id = "rippleGradient" cx = "50%" cy = "50%" r = "50%" >
170128 < Stop
171129 offset = "0%"
172- stopColor = { themeColorSurfaceSecondary }
173130 stopOpacity = "1"
131+ stopColor = { themeColorSurfaceSecondary }
174132 />
175133 < Stop
176- offset = "75%"
134+ offset = "80%"
135+ stopOpacity = "0.8"
177136 stopColor = { themeColorSurfaceSecondary }
178- stopOpacity = "0.75"
179137 />
180138 < Stop
181139 offset = "100%"
182- stopColor = { themeColorSurfaceSecondary }
183140 stopOpacity = "0"
141+ stopColor = { themeColorSurfaceSecondary }
184142 />
185143 </ RadialGradient >
186144 </ Defs >
0 commit comments