diff --git a/cashtab/src/components/Common/Switch.js b/cashtab/src/components/Common/Switch.js new file mode 100644 --- /dev/null +++ b/cashtab/src/components/Common/Switch.js @@ -0,0 +1,77 @@ +// Copyright (c) 2024 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +import React from 'react'; +import styled from 'styled-components'; +import PropTypes from 'prop-types'; + +const CheckBoxWrapper = styled.div` + position: relative; +`; +const CheckBoxLabel = styled.label` + position: absolute; + top: 0; + left: 0; + width: 42px; + height: 26px; + border-radius: 15px; + background: #bebebe; + cursor: pointer; + &::after { + content: ''; + display: block; + border-radius: 50%; + width: 18px; + height: 18px; + margin: 3px; + background: #ffffff; + box-shadow: 1px 3px 3px 1px rgba(0, 0, 0, 0.2); + transition: 0.4s; + } +`; +const CheckBox = styled.input` + opacity: 0; + z-index: 1; + border-radius: 15px; + width: 42px; + height: 26px; + &:checked + ${CheckBoxLabel} { + background: ${props => props.theme.eCashBlue}; + &::after { + content: ''; + display: block; + border-radius: 50%; + width: 18px; + height: 18px; + margin-left: 21px; + transition: 0.4s; + } + } +`; + +// TODO optimize transition time +// TODO width +// TODO mess with styles and colors +// TODO disabled label (accept image) +// TODO enabled label (accept image) +const CustomSwitch = ({ checked, handleToggle }) => { + return ( + + + + + ); +}; + +CustomSwitch.propTypes = { + checked: PropTypes.bool, + handleToggle: PropTypes.func, +}; + +export default CustomSwitch; diff --git a/cashtab/src/components/Send/SendXec.js b/cashtab/src/components/Send/SendXec.js --- a/cashtab/src/components/Send/SendXec.js +++ b/cashtab/src/components/Send/SendXec.js @@ -62,6 +62,7 @@ import { isMobile, getUserLocale } from 'helpers'; import { hasEnoughToken, fiatToSatoshis } from 'wallet'; import { toast } from 'react-toastify'; +import CustomSwitch from 'components/Common/Switch'; const { TextArea } = Input; const TextAreaLabel = styled.div` @@ -173,6 +174,7 @@ nonSlpUtxos, chaintipBlockheight, ); + const [toggled, setToggled] = useState(false); const [isOneToManyXECSend, setIsOneToManyXECSend] = useState(false); const [opReturnMsg, setOpReturnMsg] = useState(false); @@ -803,7 +805,12 @@ Webapp Tx Request )} - +
+ setToggled(!toggled)} + /> +
{' '} Send to