Add handler on each sidebar button
This commit is contained in:
parent
89ad2ecb73
commit
395f28219d
|
@ -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={{
|
||||||
|
|
Loading…
Reference in New Issue