Update SwitchComponent.tsx

This commit is contained in:
Hristo Nedelkov 2023-11-20 18:49:05 +02:00
parent f3dc2f9ca8
commit 5a56737809

View File

@ -1,24 +1,31 @@
import { Switch } from "tamagui" import { Switch } from 'tamagui'
type SwitchComponentProps = {
timestamps: boolean
setTimestamps: (timestamps: boolean) => void
}
const SwitchComponent = () => { const SwitchComponent = ({ timestamps, setTimestamps }: SwitchComponentProps) => {
const handleCheckedChange = () => {
setTimestamps(!timestamps)
}
return ( return (
<Switch <Switch
size="$1" size="$1"
style={ { backgroundColor: 'grey'} } style={{ backgroundColor: timestamps ? '#4360df' : 'grey', border: 'none' }}
checked={false} checked={timestamps}
onCheckedChange={() =>(console.log(a))} onCheckedChange={handleCheckedChange}
> >
<Switch.Thumb <Switch.Thumb
style={{ style={{
right: 7, right: 7,
bottom: 3, bottom: 3,
backgroundColor: '#fff', backgroundColor: '#fff',
height: '16px', height: '18px',
width: '16px', width: '18px',
}} }}
/> />
</Switch> </Switch>
) )
} }
export default SwitchComponent export default SwitchComponent