/**
 * React Native Full App (https://store.enappd.com/product/react-native-full-app)
 *
 * Copyright © 2019-present Enappd. All rights reserved.
 *
 * This source code is licensed as per the terms found in the
 * LICENSE.md file in the root directory of this source tree.
 */
import React, { Component } from 'react';
import { Picker, Icon } from 'native-base';

interface PickerComponentProps {
  jsonList: any;
  selected: any;
  onValueChange: (event: any) => void;
}

const PickerComponent = (props: PickerComponentProps) => {
  const { jsonList } = props;
  return (
    <Picker
      mode="dropdown"
      iosIcon={<Icon name="arrow-down" />}
      placeholder={props.selected}
      placeholderStyle={{ color: '#bfc6ea' }}
      placeholderIconColor="#007aff"
      style={{ width: undefined }}
      selectedValue={props.selected}
      onValueChange={($event) => props.onValueChange($event)}
    >
      {jsonList.map((item: any, i: number) => {
        return (
          <Picker.Item
            key={i}
            label={item.dial_code + ' ' + item.name}
            value={item.code}
          />
        );
      })}
    </Picker>
  );
};
export default PickerComponent;
