@@ -4,7 +4,7 @@ import { GestureDetector } from 'react-native-gesture-handler';
44import Animated from 'react-native-reanimated' ;
55import { CloseIcon } from '../../helpers/components/close-icon' ;
66import { Text } from '../../helpers/components/text' ;
7- import { cn } from '../../helpers/theme' ;
7+ import { cn , useThemeColor } from '../../helpers/theme' ;
88import type { ViewRef } from '../../helpers/types' ;
99import { createContext } from '../../helpers/utils' ;
1010import * as ToastPrimitive from '../../primitives/toast' ;
@@ -13,6 +13,7 @@ import type {
1313 ToastShowOptions ,
1414} from '../../providers/toast' ;
1515import { Button } from '../button' ;
16+ import type { PressableFeedbackHighlightRootAnimation } from '../pressable-feedback' ;
1617import { useToastRootAnimation } from './toast.animation' ;
1718import { DISPLAY_NAME } from './toast.constants' ;
1819import { useToastDuration } from './toast.hooks' ;
@@ -106,10 +107,8 @@ const ToastRoot = forwardRef<ViewRef, ToastRootProps>((props, ref) => {
106107 </ AnimatedToastRoot >
107108 { /* Static toast instance */ }
108109 < AnimatedToastRoot
109- className = { cn (
110- tvStyles ,
111- 'absolute top-[200px] opacity-0 pointer-events-none'
112- ) }
110+ pointerEvents = "none"
111+ className = { cn ( tvStyles , 'absolute opacity-0' ) }
113112 style = { [ styleSheet . root , style ] }
114113 onLayout = { ( event ) => {
115114 const measuredHeight = event . nativeEvent . layout . height ;
@@ -172,6 +171,39 @@ const ToastAction = forwardRef<View, ToastActionProps>((props, ref) => {
172171
173172 const { variant : toastVariant } = useToast ( ) ;
174173
174+ const tvStyles = toastStyles . action ( {
175+ variant : toastVariant ,
176+ className,
177+ } ) ;
178+
179+ const themeColorDefaultHover = useThemeColor ( 'default-hover' ) ;
180+ const themeColorAccentHover = useThemeColor ( 'accent-hover' ) ;
181+ const themeColorSuccessHover = useThemeColor ( 'success-hover' ) ;
182+ const themeColorWarningHover = useThemeColor ( 'warning-hover' ) ;
183+ const themeColorDangerHover = useThemeColor ( 'danger-hover' ) ;
184+
185+ const highlightColorMap = useMemo ( ( ) => {
186+ switch ( toastVariant ) {
187+ case 'default' :
188+ return themeColorDefaultHover ;
189+ case 'accent' :
190+ return themeColorAccentHover ;
191+ case 'success' :
192+ return themeColorSuccessHover ;
193+ case 'warning' :
194+ return themeColorWarningHover ;
195+ case 'danger' :
196+ return themeColorDangerHover ;
197+ }
198+ } , [
199+ toastVariant ,
200+ themeColorDefaultHover ,
201+ themeColorAccentHover ,
202+ themeColorSuccessHover ,
203+ themeColorWarningHover ,
204+ themeColorDangerHover ,
205+ ] ) ;
206+
175207 const buttonVariant = useMemo ( ( ) => {
176208 if ( variant ) return variant ;
177209
@@ -185,17 +217,23 @@ const ToastAction = forwardRef<View, ToastActionProps>((props, ref) => {
185217 }
186218 } , [ toastVariant , variant ] ) ;
187219
188- const tvStyles = toastStyles . action ( {
189- variant : toastVariant ,
190- className,
191- } ) ;
220+ const animationConfig = useMemo < PressableFeedbackHighlightRootAnimation > (
221+ ( ) => ( {
222+ highlight : {
223+ backgroundColor : { value : highlightColorMap } ,
224+ opacity : { value : [ 0 , 1 ] } ,
225+ } ,
226+ } ) ,
227+ [ highlightColorMap ]
228+ ) ;
192229
193230 return (
194231 < Button
195232 ref = { ref }
196233 variant = { buttonVariant }
197234 size = { size }
198235 className = { tvStyles }
236+ animation = { animationConfig }
199237 { ...restProps }
200238 >
201239 { children }
0 commit comments