Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# IntelliJ
#
.idea

# OSX
#
.DS_Store

# node.js
#
node_modules/
npm-debug.log
yarn-error.log
package-lock.log
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

103 changes: 103 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

112 changes: 60 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# react-native-select-two

## react-native-select-two
## Component like [Select2](https://select2.org/) on web for React Native

![Single select](https://raw.githubusercontent.com/xuho/demo-images/master/react-native-select2-single-select.gif)

## Add it to your project
- Using NPM
Expand All @@ -17,70 +16,79 @@
1. [react-native-modal](https://github.com/react-native-community/react-native-modal)
2. [react-native-vector-icons](https://github.com/oblador/react-native-vector-icons)

1. Insall package
- Using NPM
`npm install react-native-select-two`
- Using Yarn
`yarn add react-native-select-two`
2. Import package
`import Select2 from 'react-native-select-two';`

## Usage



```javascript
import React, { Component } from "react"
import { View, Text, StyleSheet } from "react-native"
import Select2 from "react-native-select-two"
import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import Select2 from 'react-native-select-two';

const mockData = [
{ id: 1, name: "React Native Developer", checked: true }, // set default checked for render option item
{ id: 2, name: "Android Developer" },
{ id: 3, name: "iOS Developer" }
]
{ id: 1, name: 'React Native Developer', checked: true }, // set default checked for render option item
{ id: 2, name: 'Android Developer' },
{ id: 3, name: 'iOS Developer' }
];

// create a component
class CreateNewAppointment extends Component {
render() {
return (
<View style={styles.container}>
<Select2
isSelectSingle
style={{ borderRadius: 5 }}
colorTheme="blue"
popupTitle="Select item"
title="Select item"
data={mockData}
onSelect={data => {
this.setState({ data })
}}
onRemoveItem={data => {
this.setState({ data })
}}
/>
</View>
)
}
render() {
return (
<View style={styles.container}>
<Select2
isSelectSingle
style={{ borderRadius: 5 }}
colorTheme={'blue'}
popupTitle='Select item'
title='Select item'
data={mockData}
onSelect={data => {
this.setState({ data });
}}
onRemoveItem={data => {
this.setState({ data });
}}
/>
</View>
);
}
}
```

### Multiple select
## Usage

### Single select
![Single select](https://raw.githubusercontent.com/xuho/demo-images/master/react-native-select2-single-select.gif)
### Multiple select
![Multiple select](https://raw.githubusercontent.com/xuho/demo-images/master/react-native-select2-multipe-select.gif)

## Properties

| Property name | Type | Default | Description |
| ------------------------- | -------------- | ------------------------------- | ------------------------------------------------------------------------------------------- |
| **style** | _Object_ | none | Custom style for component |
| **modalStyle** | _Object_ | none | Custom style for modal |
| **title** | _String_ | none | String display when you don't select any item |
| **data** | _Array_ | \*required | Datasource of list options: an array of objects (each object have `name` and `id` property) |
| **onSelect** | _Function_ | none | The callback function trigger after you press select button |
| **onRemoveItem** | _Function_ | none | The callback function trigger after you press tags to remove them |
| **popupTitle** | _String_ | none | Title of modal select item |
| **colorTheme** | _string/color_ | #16a45f | Color for componet |
| **isSelectSingle** | _Bool_ | false | Selelect only one option |
| **showSearchBox** | _Bool_ | true | Show or hide search field |
| **cancelButtonText** | _string_ | Hủy | Cancel button text title |
| **selectButtonText** | _String_ | Chọn | Select button text title |
| **searchPlaceHolderText** | _String_ | Nhập vào từ khóa | Placeholder text for search field |
| **listEmptyTitle** | _String_ | Không tìm thấy lựa chọn phù hợp | Title to show when there's no item to be render |
| **defaultFontName** | _String_ | none | Set custom font for all component |
| **selectedTitleStyle** | _Object_ | none | Set custom style for display selected title text |
| **buttonTextStyle** | _Object_ | none | Set custom button text style |
| **buttonStyle** | _Object_ | none | Set custom button style |


## Props

- **`style`** _(Object)_ - Custom style for component
- **`title`** _(String)_ String display when you don't select any item
- **`data`** _(Array)_ - Datasource of list options: an array of objects (each object have ```name``` property)
- **`onSelect`** _(Function)_ - The callback function trigger after you press select button
- **`onRemoveItem`** _(Function)_ - The callback function trigger after you press tags to remove them
- **`popupTitle`** _(String)_ - Title of modal select item
- **`colorTheme`** _(String)_ - Color theme
- **`isSelectSingle`** _(Bool)_ - Set ```false``` if you want select multiple
- **`showSearchBox`** _(Bool)_ - Set ```false``` if you want hide search box, default value is ```true```
- **`cancelButtonText`** _(String)_ - Cancel button text title
- **`selectButtonText`** _(String)_ - Select button text title
- **`defaultFontName`** _(String)_ - Set custom font for all components
- **`selectedTitlteStyle`** _(Object)_ - Set custom style for display selected title text
- **`buttonTextStyle`** _(Object)_ - Set custom button text style
- **`buttonStyle`** _(Object)_ - Set custom button style

**MIT Licensed**
Loading