|
1 | | -# react-native-search-bar |
| 1 | +<h2 align="center">React Native Search Bar</h2> |
2 | 2 |
|
3 | | -<a href="https://www.npmjs.com/package/react-native-search-bar"><img src="https://badge.fury.io/js/react-native-search-bar.svg" alt="" height="18"></a> |
| 3 | +<p align="center">The high-quality |
| 4 | + <a href="https://developer.apple.com/documentation/uikit/uisearchbar">native iOS search bar</a> for <a href="https://facebook.github.io/react-native/">react native.</a> |
4 | 5 |
|
5 | | -The high-quality [iOS native search bar](https://developer.apple.com/documentation/uikit/uisearchbar) for [react native](https://facebook.github.io/react-native/). |
| 6 | +<p align="center"> |
| 7 | + <a href="https://www.npmjs.com/package/react-native-search-bar"> |
| 8 | + <img alt="npm version" src="https://img.shields.io/npm/v/react-native-search-bar.svg?style=flat-square"> |
| 9 | + </a> |
| 10 | + <a href="https://www.npmjs.com/package/react-native-react-native-search-bar"> |
| 11 | + <img alt="npm downloads" src="https://img.shields.io/npm/dm/react-native-search-bar.svg?style=flat-square"> |
| 12 | + </a> |
| 13 | + <a href="https://prettier.io"> |
| 14 | + <img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square"> |
| 15 | + </a> |
| 16 | +</p> |
6 | 17 |
|
7 | | -<img src="SearchBar.png"/> |
| 18 | +<p align="center"> |
| 19 | + <img src="./.github/SearchBar.png"/> |
| 20 | +</p> |
8 | 21 |
|
9 | | -:sunny: Battle-tested in [WeatherEh](https://itunes.apple.com/us/app/id1112813447) app. |
| 22 | +<br> |
10 | 23 |
|
11 | | -## Installation |
| 24 | +## Getting Started |
12 | 25 |
|
13 | | -In your react native project, run `npm install react-native-search-bar --save` or `yarn add react-native-search-bar` |
| 26 | +1. Installation |
14 | 27 |
|
15 | | -To link this library, please follow the first two steps in the [Linking Libraries (iOS)](http://facebook.github.io/react-native/docs/linking-libraries-ios.html) guide on React Native website. The `.xcodeproj` file is in `node_modules/react-native-search-bar/`. In the end, you should have `RNSearchBar.xcodeproj` in the `Libaries` group on Xcode and `libRNSearchBar.a` in the `Link Binary With Libraries` section inside the `Build Phases` tab of your project target. |
| 28 | + * Using npm: `npm install react-native-tableview --save` |
| 29 | + * Using yarn: `yarn add react-native-tableview` |
| 30 | + |
| 31 | +2. Link |
| 32 | + * Run `react-native link react-native-search-bar` |
| 33 | + * If linking fails, follow the |
| 34 | + [manual linking steps](http://facebook.github.io/react-native/docs/linking-libraries-ios.html#manual-linking) |
16 | 35 |
|
17 | 36 | ## Update |
18 | 37 |
|
19 | 38 | In your react native project, run |
20 | 39 |
|
21 | 40 | ```Bash |
22 | | -npm install react-native@latest --save # optional, just for the latest react-native |
| 41 | +# npm |
23 | 42 | npm install react-native-search-bar@latest --save |
| 43 | + |
| 44 | +# yarn |
| 45 | +yarn add react-native-search-bar@latest |
24 | 46 | ``` |
25 | 47 |
|
26 | 48 | ## Usage |
27 | 49 |
|
28 | 50 | ```javascript |
29 | | -var SearchBar = require('react-native-search-bar'); |
| 51 | +import SearchBar from 'react-native-search-bar' |
30 | 52 | ``` |
31 | 53 |
|
32 | 54 | ```JSX |
33 | 55 | <SearchBar |
34 | | - ref='searchBar' |
35 | | - placeholder='Search' |
36 | | - onChangeText={...} |
37 | | - onSearchButtonPress={...} |
38 | | - onCancelButtonPress={...} |
39 | | - /> |
| 56 | + ref='searchBar' |
| 57 | + placeholder='Search' |
| 58 | + onChangeText={...} |
| 59 | + onSearchButtonPress={...} |
| 60 | + onCancelButtonPress={...} |
| 61 | +/> |
40 | 62 | ``` |
41 | 63 |
|
42 | 64 | ### Managing the keyboard |
| 65 | + |
43 | 66 | * Show - `this.refs.searchBar.focus();` |
44 | 67 | * Hide |
45 | | - - `this.refs.searchBar.blur();` - uses the iOS `endEditing:true` method on the underlying `UISearchBar` view. |
46 | | - - `this.refs.searchBar.unFocus();` - calls `resignFirstResponder` on the `UITextField` used by the `UISearchBar`. |
47 | | -* Examples |
48 | | - * Show the keyboard when the view loads: |
| 68 | + * `this.refs.searchBar.blur();` - uses the iOS `endEditing:true` method on the |
| 69 | + underlying `UISearchBar` view. |
| 70 | + * `this.refs.searchBar.unFocus();` - calls `resignFirstResponder` on the |
| 71 | + `UITextField` used by the `UISearchBar`. |
| 72 | + |
| 73 | +### Examples |
| 74 | + |
| 75 | +* Show the keyboard when the view loads: |
| 76 | + |
49 | 77 | ```javascript |
50 | 78 | componentDidMount() { |
51 | 79 | this.refs.searchBar.focus(); |
52 | 80 | } |
53 | 81 | ``` |
54 | | - * Hide the keyboard when the user searches: |
| 82 | + |
| 83 | +* Hide the keyboard when the user searches: |
| 84 | + |
55 | 85 | ```javascript |
56 | 86 | ... |
57 | 87 | onSearchButtonPress={this.refs.searchBar.unFocus} |
58 | 88 | ... |
59 | 89 | ``` |
60 | 90 |
|
61 | | -For all supportted properties, please check out `propTypes` in either [SearchBar.coffee](SearchBar.coffee) or [SearchBar.js](SearchBar.js). |
| 91 | +For a full list of props check out |
| 92 | +[the typescript definitions file](./src/index.d.ts). |
62 | 93 |
|
63 | | -There is also an example project in the [SearchBarExample](SearchBarExample) directory. |
| 94 | +There is also an example project in the [example](./example) directory. |
64 | 95 |
|
65 | 96 | ## Contribution |
66 | 97 |
|
67 | | -For now, implemented are only some of the features of [UISearchBar](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISearchBar_Class/). |
68 | | -Feel free to send a pull request. To get started, you can read the ["Native UI Components (iOS)"](http://facebook.github.io/react-native/docs/native-components-ios.html) guide on React Native website. |
| 98 | +For now, only some of the features of |
| 99 | +[UISearchBar](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISearchBar_Class/) |
| 100 | +are implemented. |
| 101 | + |
| 102 | +Feel free to send a pull request to the |
| 103 | +[next](https://github.com/umhan35/react-native-search-bar/tree/next) branch. To |
| 104 | +get started, you can read the |
| 105 | +["Native UI Components (iOS)"](http://facebook.github.io/react-native/docs/native-components-ios.html) |
| 106 | +guide on the React Native website. |
69 | 107 |
|
70 | | -Except code contribution, you are welcome to answer question asked in [Issues](https://github.com/umhan35/react-native-search-bar/issues). |
| 108 | +Along with code contribution, you are welcomed to answer questions asked in the |
| 109 | +[Issues](https://github.com/umhan35/react-native-search-bar/issues). |
71 | 110 |
|
72 | 111 | ## License |
73 | 112 |
|
74 | 113 | MIT |
75 | | - |
76 | | - |
|
0 commit comments