mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2import {SvgProps} from 'react-native-svg'
3
4import {atoms as a, useTheme, web} from '#/alf'
5import {PressableWithHover} from '../../../PressableWithHover'
6
7export function ControlButton({
8 active,
9 activeLabel,
10 inactiveLabel,
11 activeIcon: ActiveIcon,
12 inactiveIcon: InactiveIcon,
13 onPress,
14}: {
15 active: boolean
16 activeLabel: string
17 inactiveLabel: string
18 activeIcon: React.ComponentType<Pick<SvgProps, 'fill' | 'width'>>
19 inactiveIcon: React.ComponentType<Pick<SvgProps, 'fill' | 'width'>>
20 onPress: () => void
21}) {
22 const t = useTheme()
23 return (
24 <PressableWithHover
25 accessibilityRole="button"
26 accessibilityHint={active ? activeLabel : inactiveLabel}
27 onPress={onPress}
28 style={[
29 a.p_xs,
30 a.rounded_full,
31 web({transition: 'background-color 0.1s'}),
32 ]}
33 hoverStyle={{backgroundColor: 'rgba(255, 255, 255, 0.2)'}}>
34 {active ? (
35 <ActiveIcon fill={t.palette.white} width={20} />
36 ) : (
37 <InactiveIcon fill={t.palette.white} width={20} />
38 )}
39 </PressableWithHover>
40 )
41}