import React, { Component } from 'react';
import { View, TouchableOpacity, TextInput, KeyboardAvoidingView, Platform, ScrollView } from 'react-native';
import Image from 'react-native-fast-image'
import Text from '../../components/Text';
import Icon from '../../components/Icon'
import moment from 'moment'
import { t } from '../../utils/i18n';

export default class SaveViewMeter extends Component {
  constructor(props) {
    super(props);
    this.state = {
    };
  }

  render() {
    return (
        <KeyboardAvoidingView style={{flex:1}} keyboardVerticalOffset={Platform.OS == 'ios' ? 70 : 0} behavior={Platform.OS == 'ios' ? "padding" : ""} enabled>
          <ScrollView contentContainerStyle={{flex:1}}>
      <View style={{flex:1,padding:16}}>
          <View style={{justifyContent:'center',alignItems:'center'}}>
            <Image source={{uri:this.props.ImageUri}} resizeMode={'contain'} style={{borderRadius:5,height: 184,width:'100%'}}/>
          </View>
          <Text style={{color:'black',fontSize:14,textAlign:'center',marginVertical: 16,}}>{t('taken_on')} {moment().format('DD/MM/YYYY HH:mm')} {t('short_minute')}</Text>
          <TouchableOpacity style={{height: 40,width: '100%',backgroundColor:'#007AFF',justifyContent:'center',alignItems:'center',borderRadius:5,flexDirection:'row'}}
                        onPress={this.props.onTakeCamera}>
            <Icon nane={'ic_outline_camera'} size={22} color={'#FFFFFF'}/>
            <Text style={{color:'white'}}>{t('retake_meter_photo')}</Text>
          </TouchableOpacity>
          <Text style={{color:'#00420A',marginVertical: 16,fontSize:14}}>{t('enter_meter')}</Text>
          <TextInput
            style={{height: 48, backgroundColor: '#FFFFFF', borderRadius:24,paddingHorizontal:16}}
            onChangeText={(text) => this.props.TextChanged(text)}
            value={this.props.amount}
            keyboardType={'numeric'}
          />
          <View style={{flex:1}}/>
          <View style={{}}>
            <TouchableOpacity style={{height: 40,width: '100%',backgroundColor:this.props.canConfirm ? '#269A21' : 'silver' ,justifyContent:'center',alignItems:'center',borderRadius:5,flexDirection:'row'}}
            disabled={this.props.canConfirm ? false : true}
                          onPress={() => {this.props.Confirm()}}>
              <Icon nane={'ic_outline_camera'} size={22} color={'#FFFFFF'}/>
              <Text style={{color:'white'}}>{t('confirm_meter')}</Text>
            </TouchableOpacity>
          </View>
      </View>
      </ScrollView>
        </KeyboardAvoidingView>
    );
  }
}
