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 { useDispatch } from 'react-redux'
import { Stack } from 'tamagui'
import { toggleButtonSelection } from '../../redux/Sidebars/slice'
type IconButtonWithDotProps = {
iconEl: any
@ -7,6 +9,7 @@ type IconButtonWithDotProps = {
isDotOn: boolean
selected?: boolean
disabled?: boolean
id: string
}
const IconButtonWithDot = ({
@ -15,10 +18,14 @@ const IconButtonWithDot = ({
isDotOn,
selected,
disabled,
id
}: IconButtonWithDotProps) => {
const dispatch = useDispatch()
const onClickHandler = (id) => { if (!disabled) dispatch(toggleButtonSelection(id)) }
return (
<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 && (
<Stack
style={{