Socket
Book a DemoInstallSign in
Socket

react-native-picker-w-icon

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-picker-w-icon

React Native Picker with Icon

latest
Source
npmnpm
Version
1.0.8
Version published
Maintainers
1
Created
Source

react-native-picker-w-icon

Getting started

$ npm install react-native-picker-w-icon --save

Mostly automatic installation

$ react-native link react-native-picker-w-icon

Usage

import React, { useState } from "react";
import PickerWIcon from 'react-native-picker-w-icon';
import { View, Image, StyleSheet } from "react-native";
import { Icon } from "native-base";

const telCodes = [
  {
    "code": "+60",
    "icon": "https://cdn3.iconfinder.com/data/icons/o-shaped-flag-1/128/O_shaped_asian_flag-21-256.png",
  },
  {
    "code": "+62",
    "icon": "https://cdn3.iconfinder.com/data/icons/o-shaped-flag-1/128/O_shaped_asian_flag-27-128.png",
  },
  {
    "code": "+81",
    "icon": "https://cdn3.iconfinder.com/data/icons/o-shaped-flag-1/128/O_shaped_asian_flag-16-256.png",
  },
]

const PickerWIconApp = props => {

    const [value, setValue] = useState(undefined);

    return (
      <PickerWIcon
        options={telCodes}
        dropdownStyle={{ height: (50 + StyleSheet.hairlineWidth) * telCodes.length }}
        defaultValue={telCodes[0]}
        onSelect={(index, value) => setValue(value)}
        renderRow={
          <View>
            <Image
              source={{ uri: telCodes[0].icon }}
              style={{ width: 30, height: 30 }}
              resizeMode={'cover'}
            />
            <Text numberOfLines={1}>
              {telCodes[0].code}
            </Text>
            <Icon
              name="md-arrow-dropdown"
              style={{ color: 'transparent' }}
            />
          </View>
        }
        selected={
          <View style={styles.button}>
            <Image
              source={{ uri: value.icon }}
              style={styles.iconStyle}
            />
            <Text style={styles.buttonText} numberOfLines={1}>
              {value.code}
            </Text>
            <Icon
              name="md-caret-down"
              style={styles.pickerIcon}
            />
          </View>
        }
      />
    )
}

var styles = StyleSheet.create({
    button: {
      justifyContent: 'space-evenly',
      alignItems: 'center',
      flexDirection: 'row',
      height: 50
    },
    buttonText: {
      fontSize: 16,
      color: 'white'
    },
    pickerIcon: {
      color: 'grey',
      width: 23,
      height: 28
    },
    iconStyle: {
      width: 30,
      height: 30
    },
});

Props

PropTypeRequiredDefaultDescription
optionsArrayYesArray of objects to select
selectedcomponentYesThe selected component
renderRowcomponentYesThe component to show in the dropdown
disabledboolNofalseDisables interaction with the component
scrollEnabledboolNotrueScrollable
showItemSeparatorboolNofalseShow item separator between dropdown item
defaultValueobjectNooptions[0]Default selected value
animatedboolNotrueAnimation of showing the dropdown list
showsVerticalScrollIndicatorboolNofalseShow vertical scroll indicator of the list
stylestyleNoThe style applied to the option container
dropdownStylestyleNoThe style of the dropdown
dropdownTextStylestyleNoThe style of the drop down text

MIT Licensed

Keywords

react-native

FAQs

Package last updated on 15 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.