import  React, { useState } from 'react';
import { Button, View, StyleSheet, Text, ScrollView, Image, FlatList, TouchableOpacity} from 'react-native';
import { Searchbar } from 'react-native-paper';
import styles from '../currency/style';
import Ionics from 'react-native-vector-icons/Ionicons';
import { SafeAreaView } from 'react-native-safe-area-context';
import { NavigationContainer } from '../sidebar/index';

const plus = require ('../../images/plus.png');
const greater = require('../../images/greater.png');
// const [searchQuery, setSearchQuery] = React.useState('');
// const onChangeSearch = query => setSearchQuery(query);

const CURRENCY = [
  {
    id:'0',
    title:'MYR',
    name:'Malaysian Ringgit',
    status:'DEFAULT',
  },
  {
    id:'1',
    title:'USD',
    name:'United States Dollar',
  },
  {
    id:'2',
    title:'KRW',
    name:'South Korean Won',
  },
  {
    id:'3',
    title:'SGD',
    name:'Singapore Dollar',
  },
  {
    id:'4',
    title:'AUD',
    name:'Australian Dollar',
  },
  {
    id:'5',
    title:'IDR',
    name:'Indonesian Rupiah',
  },
  {
    id:'6',
    title:'MXN',
    name:'Mexican Peso',
  },
  {
    id:'7',
    title:'QAR',
    name:'Qatari rial',
  },
  {
    id:'8',
    title:'THB',
    name:'Thai Baht',
  },
]

const renderItem = ({ item }) => (
  <View style={{ flex: 1, backgroundColor:'white'}}>
    <View style = {{flexDirection:'row', justifyContent:'flex-end', marginRight:10}}>
        <Text style ={{marginTop:10,fontSize:15, color:'dodgerblue'}}>{item.status}</Text>
    </View>
            <View style = {{flexDirection:'row'}}>
                <Text style = {[styles.textStyle,{marginTop:0, marginHorizontal:30, fontWeight:'500'}]}>{item.title}</Text>
                     <View style = {{flexDirection:'column', marginVertical:3}}>
                          <TouchableOpacity onPress={() => navigation.navigate("editcurrency")}><Image style={{width:15, height:20, marginHorizontal:250, marginTop:5}} source={greater} ></Image></TouchableOpacity>
                    </View>
            </View>
               <Text style={{marginHorizontal:30}}>{item.name}</Text>
               <View style={styles.dividerLine}></View>  
  </View>
  
);

{/* <Searchbar
      placeholder="Search"
      onChangeText={onChangeSearch}
      value={searchQuery}
    />*/}

    

    export default function CurrencyScreen({navigation}){
    return (
      <View style={{ flex: 1, backgroundColor:'white'}}> 
        <SafeAreaView>
          <FlatList
           data={CURRENCY}
           renderItem={renderItem}
           keyExtractor={item => item.id}
          />
          <TouchableOpacity style={{backgroundColor:'white', elevation:7, width:70, height:70,justifyContent:'center', alignItems:'center', position:'absolute', borderRadius:100, bottom:20, left:310, marginTop:210}} onPress={() => navigation.navigate("addcurrency")}>
             <Image style={{width:30, height:30}} source = {plus}></Image>
          </TouchableOpacity>
           </SafeAreaView>  
      </View>
    );
  };

