Add handler on each sidebar button

This commit is contained in:
Hristo Nedelkov 2023-09-26 13:44:35 +03:00
parent 89ad2ecb73
commit 395f28219d
1 changed files with 36 additions and 29 deletions

View File

@ -1,5 +1,7 @@
import { IconButton } from '@status-im/components' import { IconButton } from '@status-im/components'
import { useDispatch } from 'react-redux'
import { Stack } from 'tamagui' import { Stack } from 'tamagui'
import { toggleButtonSelection } from '../../redux/Sidebars/slice'
type IconButtonWithDotProps = { type IconButtonWithDotProps = {
iconEl: any iconEl: any
@ -7,6 +9,7 @@ type IconButtonWithDotProps = {
isDotOn: boolean isDotOn: boolean
selected?: boolean selected?: boolean
disabled?: boolean disabled?: boolean
id: string
} }
const IconButtonWithDot = ({ const IconButtonWithDot = ({
@ -15,10 +18,14 @@ const IconButtonWithDot = ({
isDotOn, isDotOn,
selected, selected,
disabled, disabled,
id
}: IconButtonWithDotProps) => { }: IconButtonWithDotProps) => {
const dispatch = useDispatch()
const onClickHandler = (id) => { if (!disabled) dispatch(toggleButtonSelection(id)) }
return ( return (
<Stack style={{ position: 'relative', display: 'inline-block' }}> <Stack style={{ position: 'relative', display: 'inline-block' }}>
<IconButton icon={iconEl} variant={variant} selected={selected} disabled={disabled} /> <IconButton icon={iconEl} variant={variant} selected={selected} disabled={disabled} onPress={() => onClickHandler(id)} />
{isDotOn && ( {isDotOn && (
<Stack <Stack
style={{ style={{