import React from 'react';
import { StyleSheet } from 'react-native';
import { observer } from 'mobx-react';
import PropTypes from 'prop-types';
import Background from '../component/background';
import MainContent from '../component/main-content';
import { Header, Title } from '../component/header';
import { CancelButton, PillButton, Button } from '../component/button';
import Card from '../component/card';
import LightningBoltIcon from '../asset/icon/lightning-bolt';
import { FormStretcher, FormText, FormSubText } from '../component/form';
import { color } from '../component/style';
import { BalanceLabel, BalanceLabelUnit } from '../component/label';
import { InputField, AmountInputField } from '../component/field';

const styles = StyleSheet.create({
  description: {
    paddingLeft: 40,
    paddingRight: 40,
    paddingBottom: 40,
  },
  subText: {
    paddingTop: 20,
    paddingBottom: 40,
    paddingLeft: 40,
    paddingRight: 40,
  },
  unit: {
    color: color.blackText,
  },
});

const PoolAddLiqView = ({ store, nav, pooladdliq }) => (
  <Background image="purple-gradient-bg">
    <Header shadow color={color.purple}>
      <Button disabled onPress={() => {}} />
      <Title title="Add Pool Liquidity">
        <LightningBoltIcon height={12} width={6.1} />
      </Title>
      <CancelButton onPress={() => nav.goHome()} />
    </Header>
    <MainContent>
      <Card>
        <FormText style={styles.description}>
          Enter amount to add to merchants liquidity. You will receive pool
          share propotional to this amount.
        </FormText>
        <BalanceLabel style={styles.balance}>
          <AmountInputField
            autoFocus={true}
            onChangeText={amount => pooladdliq.setAmount({ amount })}
            //onSubmitEditing={() => pooladdliq.checkType()}
          />
          <BalanceLabelUnit style={styles.unit}>
            {store.unitFiatLabel}
          </BalanceLabelUnit>
        </BalanceLabel>
        <FormStretcher>
          <InputField
            placeholder="Pool Payment Request"
            autoFocus={true}
            value={store.payment.address}
          />
          <FormSubText style={styles.subText}>
            Investments will be locked for a minimum lock time as shown on the
            pool contract. So make sure you are investing in the right merchant.
          </FormSubText>
        </FormStretcher>
        <PillButton onPress={() => pooladdliq.checkType()}>
          Verify Shares
        </PillButton>
      </Card>
    </MainContent>
  </Background>
);

PoolAddLiqView.propTypes = {
  store: PropTypes.object.isRequired,
  nav: PropTypes.object.isRequired,
  pooladdliq: PropTypes.object.isRequired,
};

export default observer(PoolAddLiqView);
