import React from 'react';
import { View, StyleSheet } from 'react-native';
import { observer } from 'mobx-react';
import PropTypes from 'prop-types';
import { CopyText } from '../component/text';
import { SplitBackground } from '../component/background';
import MainContent from '../component/main-content';
import { Header, Title } from '../component/header';
import { CopyButton, Button, ButtonText } from '../component/button';
import { CopiedNotification } from '../component/notification';
import CopyDarkIcon from '../../src/asset/icon/copy-dark';
import QRCode from '../component/qrcode';
import { color } from '../component/style';

import Icon from '../component/icon';

const styles = StyleSheet.create({
  qrWrapper: {
    justifyContent: 'center',
    alignItems: 'center',
  },
  smlIcon: {
    height: 24,
    width: 24,
  },
  content: {
    justifyContent: 'space-between',
    padding: 5,
    paddingLeft: 20,
    paddingRight: 20,
  },
  copyTxt: {
    textAlign: 'center',
    marginTop: 25,
    maxWidth: 450,
  },
  copyTxtX: {
    textAlign: 'center',
    marginTop: 35,
    marginBottom: 25,
    maxWidth: 450,
  },
  btnWrapper: {
    alignItems: 'center',
  },
  copyBtn: {
    backgroundColor: color.glas,
    marginBottom: 10,
  },
});

const DepositView = ({ store, nav, invoice }) => (
  <SplitBackground image="purple-gradient-bg" bottom={color.blackDark}>
    <Header separator>
      <Title title="Deposit Funds" />
    </Header>
    <MainContent style={styles.content}>
      <CopyText style={styles.copyTxt}>
        Scan the QR code to send from another wallet.
      </CopyText>
      <QRCode size={180}>{store.walletAddressUri}</QRCode>
      <View style={styles.btnWrapper}>
        <CopyText style={styles.copyTxtX}>
          or copy address and buy directly from an exchange below.
        </CopyText>
        <CopyButton
          onPress={() => invoice.toClipboard({ text: store.walletAddress })}
          icon={<CopyDarkIcon height={17.5} width={14} />}
          style={styles.copyBtn}
        >
          {store.walletAddress}
        </CopyButton>
        <CopyButton
          onPress={() =>
            nav.goURL(
              'https://localcryptos.com/Bitcoin/Buy?top_rated=1&online=1'
            )
          }
          icon={
            <Icon
              image={require('../asset/icon/localcryptos.png')}
              style={styles.smlIcon}
            />
          }
          style={styles.copyBtn}
        >
          LocalCryptos
        </CopyButton>
        <Button onPress={() => nav.goHome()}>
          <ButtonText style={styles.doneBtnText}>DONE</ButtonText>
        </Button>
      </View>
      <CopiedNotification
        display={store.displayCopied}
        color={color.notifyLight}
      />
    </MainContent>
  </SplitBackground>
);

DepositView.propTypes = {
  store: PropTypes.object.isRequired,
  nav: PropTypes.object.isRequired,
  invoice: PropTypes.object.isRequired,
};

export default observer(DepositView);
