import { View, Switch } from "@tarojs/components";
import './NewSwitch.scss'

export default function NewSwitch(props: {
    disable: boolean,
    checked: boolean,
    color: string,
    onChange: any,
    onClick?: any
}) {
    return <View className="switch_container">
        <Switch checked={props.checked}
            color={props.color}
            onChange={props.onChange}
        />
        {
            props.disable && <View className="switch_top" onClick={(e) => {
                if (process.env.TARO_ENV == 'weapp') {
                    e.stopPropagation()
                }
                if (props.onClick) {
                    props.onClick()
                }
            }} />
        }

    </View>
}