import React, {Component, useState} from 'react';
import {
  View,
  Text,
  StyleSheet,
  TextInput,
  TouchableOpacity,
} from 'react-native';
import HeaderBack from '../../components/Header/HeaderBack';

import PickerItem from '../../components/Picker/PickerItem';
import I18n from '../../helper/i18/i18n';
import AppText from '../../components/AppText';
import TextField from '../../components/Input/TextField';
import {getFontXD, HEIGHTXD, WIDTHXD} from '../../Config/Functions';
import R from '../../assets/R';

const dataType = [
  {
    value: '0',
    name: 'KG',
  },
  {
    value: '1',
    name: 'Pound',
  },
];

const ConvertUnit = (props) => {
  const [typeOne, setTypeOne] = useState();
  const [typeTwo, setTypeTwo] = useState();
  const [valueOne, setValueOne] = useState();
  const [valueTwo, setValueTwo] = useState();

  const onClick = () => {
    console.log('Heloo', typeOne, typeTwo, valueOne, valueTwo);
  };

  return (
    <View style={{flex: 1}}>
      <HeaderBack title={'ConvertUnit'} />
      <View style={{flex: 1, paddingTop: 20, paddingHorizontal: 20}}>
        <AppText style={styles.txtTitle} i18nKey={'ConversionUnit'} />
        <View style={styles.Item}>
          <View style={styles.wrap}>
            <PickerItem
              width={WIDTHXD(431)}
              data={dataType}
              onValueChange={(value, items) => {
                setTypeOne(items);
              }}
            />
            <TextInput
              onChangeText={(val) => setValueOne(val)}
              keyboardType={'number-pad'}
              style={styles.wrapInput}
            />
          </View>
          <Text style={styles.txtNote}>1KG = 2 Pount</Text>
        </View>

        <View style={styles.Item}>
          <View style={styles.wrap}>
            <PickerItem
              width={WIDTHXD(431)}
              data={dataType}
              onValueChange={(value, items) => {
                setTypeTwo(items);
              }}
            />
            <TextInput
              onChangeText={(val) => setValueTwo(val)}
              keyboardType={'number-pad'}
              style={styles.wrapInput}
            />
          </View>
          <Text style={styles.txtNote}>1 Pount = 0.5 KG</Text>
        </View>

        <View style={styles.footer}>
          <TouchableOpacity onPress={onClick} style={styles.btnContainer}>
            <AppText style={styles.txtBtn} i18nKey={'Caculate'} />
          </TouchableOpacity>
        </View>
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  txtTitle: {
    fontSize: getFontXD(42),
    color: R.colors.color777,
    marginBottom: 15,
  },
  note: {
    fontSize: getFontXD(36),
    fontStyle: 'italic',
    marginTop: 10,
  },
  row: {
    height: HEIGHTXD(109),
    width: '80%',
    justifyContent: 'space-between',
    marginVertical: 5,
    paddingHorizontal: 10,
  },
  footer: {
    alignItems: 'center',
    justifyContent: 'center',
    marginTop: 20,
  },
  btnContainer: {
    width: WIDTHXD(428),
    height: HEIGHTXD(120),
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: R.colors.main,
    borderRadius: 10,
  },
  txtBtn: {
    fontSize: getFontXD(48),
    color: R.colors.white,
    fontWeight: '600',
  },
  wrapInput: {
    width: WIDTHXD(431),
    backgroundColor: R.colors.white,
    height: HEIGHTXD(109),
    fontSize: getFontXD(42),
    borderRadius: 5,
    paddingHorizontal: 10,
    shadowColor: '#000',
    shadowOffset: {
      width: 0,
      height: 1,
    },
    shadowOpacity: 0.2,
    shadowRadius: 1.41,
    elevation: 2,
  },
  wrap: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-between',
  },
  Item: {
    marginBottom: 20,
  },
  txtNote: {
    fontSize: getFontXD(36),
    textAlign: 'right',
    marginTop: 10,
  },
});
export default ConvertUnit;
