forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1import {forwardRef, type PropsWithChildren} from 'react'
2import {
3 Pressable,
4 type PressableProps,
5 type StyleProp,
6 type ViewStyle,
7} from 'react-native'
8import {type View} from 'react-native'
9
10import {addStyle} from '#/lib/styles'
11import {useInteractionState} from '#/components/hooks/useInteractionState'
12
13interface PressableWithHover extends PressableProps {
14 hoverStyle: StyleProp<ViewStyle>
15}
16
17export const PressableWithHover = forwardRef<
18 View,
19 PropsWithChildren<PressableWithHover>
20>(function PressableWithHoverImpl(
21 {children, style, hoverStyle, ...props},
22 ref,
23) {
24 const {
25 state: hovered,
26 onIn: onHoverIn,
27 onOut: onHoverOut,
28 } = useInteractionState()
29
30 return (
31 <Pressable
32 {...props}
33 style={
34 typeof style !== 'function' && hovered
35 ? addStyle(style, hoverStyle)
36 : style
37 }
38 onHoverIn={onHoverIn}
39 onHoverOut={onHoverOut}
40 ref={ref}>
41 {children}
42 </Pressable>
43 )
44})