import React, { FC, useContext } from 'react'; import { TouchableOpacity, View } from 'react-native'; import { SwitchProps } from './types'; import styles from './styles'; import { Colors } from '../Consts'; import { useComponentId } from '../Application'; import { ComponentContext, MiniAppContext } from '../Context'; const Switch: FC = ({ value = false, onChange, disabled = false, style, params, accessibilityLabel, ...props }) => { const context = useContext(MiniAppContext); const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03; const circleAlign = value ? 'flex-end' : 'flex-start'; const componentName = 'Switch'; const { componentId } = useComponentId(componentName, accessibilityLabel); const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false; let backgroundColor = value ? Colors.green_03 : Colors.black_07; if (disabled) { backgroundColor = value ? Colors.green_09 : Colors.black_05; } return ( onChange?.(!value)} style={[ style, styles.container, { backgroundColor, alignItems: circleAlign }, showBaseLineDebug && styles.debugBaseLine, ]} > ); }; export { Switch };