digitalfabrik/integreat-app

View on GitHub
native/src/components/base/SettingsSwitch.tsx

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import React, { ReactElement } from 'react'
import { Switch } from 'react-native'
import { useTheme } from 'styled-components/native'

type SettingsSwitchProps = {
  onPress: (value: boolean) => void
  value: boolean
}

const SettingsSwitch = ({ value, onPress }: SettingsSwitchProps): ReactElement => {
  const theme = useTheme()
  return (
    <Switch
      thumbColor={theme.colors.themeColor}
      trackColor={{
        true: theme.colors.themeColor,
        false: theme.colors.textSecondaryColor,
      }}
      value={value}
      onValueChange={onPress}
      role='switch'
    />
  )
}

export default SettingsSwitch