├── .github └── issue_template.md ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── assets └── filterablelist.gif ├── demo ├── .gitignore ├── app │ ├── App_Resources │ │ ├── Android │ │ │ ├── app.gradle │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── res │ │ │ │ ├── drawable-hdpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── drawable-ldpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── drawable-mdpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── drawable-nodpi │ │ │ │ └── splash_screen.xml │ │ │ │ ├── drawable-xhdpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── drawable-xxhdpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── drawable-xxxhdpi │ │ │ │ ├── background.png │ │ │ │ ├── icon.png │ │ │ │ └── logo.png │ │ │ │ ├── values-v21 │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ └── iOS │ │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── icon-29.png │ │ │ │ ├── icon-29@2x.png │ │ │ │ ├── icon-29@3x.png │ │ │ │ ├── icon-40.png │ │ │ │ ├── icon-40@2x.png │ │ │ │ ├── icon-40@3x.png │ │ │ │ ├── icon-50.png │ │ │ │ ├── icon-50@2x.png │ │ │ │ ├── icon-57.png │ │ │ │ ├── icon-57@2x.png │ │ │ │ ├── icon-60@2x.png │ │ │ │ ├── icon-60@3x.png │ │ │ │ ├── icon-72.png │ │ │ │ ├── icon-72@2x.png │ │ │ │ ├── icon-76.png │ │ │ │ ├── icon-76@2x.png │ │ │ │ └── icon-83.5@2x.png │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.launchimage │ │ │ │ ├── Contents.json │ │ │ │ ├── Default-568h@2x.png │ │ │ │ ├── Default-667h@2x.png │ │ │ │ ├── Default-736h@3x.png │ │ │ │ ├── Default-Landscape.png │ │ │ │ ├── Default-Landscape@2x.png │ │ │ │ ├── Default-Landscape@3x.png │ │ │ │ ├── Default-Portrait.png │ │ │ │ ├── Default-Portrait@2x.png │ │ │ │ ├── Default.png │ │ │ │ └── Default@2x.png │ │ │ ├── LaunchScreen.AspectFill.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchScreen-AspectFill.png │ │ │ │ └── LaunchScreen-AspectFill@2x.png │ │ │ └── LaunchScreen.Center.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchScreen-Center.png │ │ │ │ └── LaunchScreen-Center@2x.png │ │ │ ├── Info.plist │ │ │ ├── LaunchScreen.storyboard │ │ │ └── build.xcconfig │ ├── app.css │ ├── app.ts │ ├── main-page.ts │ ├── main-page.xml │ ├── main-view-model.ts │ └── package.json ├── nsconfig.json ├── package.json ├── references.d.ts ├── tsconfig.json ├── tsconfig.tns.json ├── tsfmt.json └── webpack.config.js ├── publish ├── pack.sh ├── package-lock.json ├── package.json └── publish.sh ├── schema └── tns.xsd ├── src ├── .npmignore ├── README.md ├── assets │ └── download.png ├── filterable-listpicker.ts ├── index.d.ts ├── nsconfig.json ├── package.json ├── platforms │ └── android │ │ └── nativescript_filterable_listpicker.aar ├── references.d.ts └── tsconfig.json └── tslint.json /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | ### Make sure to check the demo app(s) for sample usage 2 | 3 | ### Make sure to check the existing issues in this repository 4 | 5 | ### If the demo apps cannot help and there is no issue for your problem, tell us about it 6 | Please, ensure your title is less than 63 characters long and starts with a capital 7 | letter. 8 | 9 | ### Which platform(s) does your issue occur on? 10 | - iOS/Android/Both 11 | - iOS/Android versions 12 | - emulator or device. What type of device? 13 | 14 | ### Please, provide the following version numbers that your issue occurs with: 15 | 16 | - CLI: (run `tns --version` to fetch it) 17 | - Cross-platform modules: (check the 'version' attribute in the 18 | `node_modules/tns-core-modules/package.json` file in your project) 19 | - Runtime(s): (look for the `"tns-android"` and `"tns-ios"` properties in the `package.json` file of your project) 20 | - Plugin(s): (look for the version numbers in the `package.json` file of your 21 | project and paste your dependencies and devDependencies here) 22 | 23 | ### Please, tell us how to recreate the issue in as much detail as possible. 24 | Describe the steps to reproduce it. 25 | 26 | ### Is there any code involved? 27 | - provide a code example to recreate the problem 28 | - (EVEN BETTER) provide a .zip with application or refer to a repository with application where the problem is reproducible. 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | .idea 3 | .DS_Store 4 | *.js 5 | *.js.map 6 | *.log 7 | src/*.d.ts 8 | !src/index.d.ts 9 | !src/references.d.ts 10 | !src/scripts/*.js 11 | !seed-tests/*.js 12 | seed-tests/seed-copy/**/*.* 13 | seed-tests/seed-copy-new-git-repo/**/*.* 14 | !demo/karma.conf.js 15 | !demo/app/tests/*.js 16 | demo/*.d.ts 17 | !demo/references.d.ts 18 | demo/lib 19 | demo/platforms 20 | node_modules 21 | publish/src 22 | publish/package 23 | demo/report/report.html 24 | demo/report/stats.json 25 | package-lock.json 26 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | matrix: 2 | include: 3 | - stage: "Lint" 4 | language: node_js 5 | os: linux 6 | node_js: "6" 7 | script: cd src && npm run ci.tslint && cd ../demo && npm run ci.tslint 8 | - stage: "WebPack" 9 | os: osx 10 | env: 11 | - Platform="iOS" 12 | osx_image: xcode8.3 13 | language: node_js 14 | node_js: "6" 15 | jdk: oraclejdk8 16 | script: cd demo && npm run build.plugin && npm i && npm run build-ios-bundle 17 | - language: android 18 | os: linux 19 | env: 20 | - Platform="Android" 21 | jdk: oraclejdk8 22 | before_install: nvm install 6.10.3 23 | script: cd demo && npm run build.plugin && npm i && npm run build-android-bundle 24 | - stage: "Build and Test" 25 | env: 26 | - BuildAndroid="25" 27 | language: android 28 | os: linux 29 | jdk: oraclejdk8 30 | before_install: nvm install stable 31 | script: 32 | - cd src && npm i && npm run tsc && cd ../demo && tns build android 33 | - os: osx 34 | env: 35 | - BuildiOS="10.3" 36 | - Xcode="8.3" 37 | osx_image: xcode8.3 38 | language: node_js 39 | node_js: "6" 40 | jdk: oraclejdk8 41 | script: 42 | - cd src && npm i && npm run tsc && cd ../demo && tns build ios 43 | - os: linux 44 | language: android 45 | dist: precise 46 | sudo: required 47 | jdk: oraclejdk8 48 | before_script: 49 | - echo no | android create avd --force -n test -t android-21 -b armeabi-v7a 50 | - emulator -avd test -no-audio -no-window & 51 | - android-wait-for-emulator 52 | before_install: 53 | - nvm install 6 54 | script: cd src && npm run test.android 55 | - os: osx 56 | language: node_js 57 | node_js: "6" 58 | jdk: oraclejdk8 59 | osx_image: xcode8.3 60 | script: cd src && npm run test.ios 61 | 62 | android: 63 | components: 64 | - tools 65 | - platform-tools 66 | - build-tools-25.0.2 67 | - android-25 68 | - extra-android-m2repository 69 | - sys-img-armeabi-v7a-android-21 70 | 71 | install: 72 | - echo no | npm install -g nativescript 73 | - tns usage-reporting disable 74 | - tns error-reporting disable -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Twitter URL](https://img.shields.io/badge/twitter-davecoffin-blue.svg)](https://twitter.com/davecoffin) 2 | 3 | # nativescript-filterable-listpicker 4 | 5 | The native listpickers on iOS and Android are not great for huge lists that users may want to filter. This plugin is a modal that offers filtering capabilities. 6 | 7 | 8 | 9 | 10 | ## Installation 11 | 12 | ``` 13 | tns plugin add nativescript-filterable-listpicker 14 | ``` 15 | 16 | ## Usage 17 | In order to use the plugin, you must place it on your page within a namespace. Wherever you place it, thats where it will display when invoked, but it will be hidden until you invoke it. The best way to use this is to place it on top of your page content like this: 18 | 19 | ### NativeScript Core 20 | 21 | ```xml 22 | 23 | 24 | 25 | 26 | 27 | 117 | 118 | 119 | 120 | ``` 121 | 122 | Then in your code... 123 | ```ts 124 | @ViewChild('myfilter') myfilter: ElementRef; 125 | 126 | cancelFilterableList() { 127 | console.log('canceled'); 128 | } 129 | 130 | itemTapped(args) { 131 | alert(args.selectedItem) 132 | } 133 | 134 | showPicker() { 135 | this.myfilter.nativeElement.show(); 136 | } 137 | ``` 138 | 139 | Note: When calling show, as of 2.1.0 you can pass in a viewContainer that the plugin will use to find the necessary elements. This allows you to 140 | use the list picker in modals now! For example, you could pass in a Page element, or a GridLayout that contains the FilterableListpicker element like this: 141 | 142 | in android: 143 | ```ts 144 | @ViewChild('myContainer') myContainer: ElementRef; 145 | 146 | public function showPicker() { 147 | this.myfilter.nativeElement.show(this.myContainer.nativeElement); 148 | } 149 | ``` 150 | 151 | Note: You can change the items in the filterable list easily by just setting the source to an array in your observable, and changing then changing the array. Take a look at the demo project for an example. 152 | 153 | ### Source Array 154 | As of version 2.0, you can supply either an array of strings, or an array of objects. The object must contain a parameter called `title`, and thats what will display as the title. Check out the gif above to see what the picker looks like when supplying an object. The 3 parameters the picker will display 155 | if in your object are: 156 | 157 | | Property | Description| 158 | | --- | --- | 159 | | title | The title, this is what your list will be filtered on, and it will display in bold. | 160 | | image | OPTIONAL: This will display to the left of the title. | 161 | | description | OPTIONAL: This will display under the title smaller and in gray. | 162 | 163 | Here's some example code: 164 | ```ts 165 | public listitems = [ 166 | { 167 | "image": "https://lh3.googleusercontent.com/gN6iBKP1b2GTXZZoCxhyXiYIAh8QJ_8xzlhEK6csyDadA4GdkEdIEy9Bc8s5jozt1g=w300", 168 | "title": "Brown Bear", 169 | "description": "Brown bear brown bear, what do you see?" 170 | }, 171 | { 172 | "image": "http://icons.veryicon.com/png/Flag/Rounded%20World%20Flags/Indonesia%20Flag.png", 173 | "title": "Red Bird" 174 | }, 175 | { 176 | "title": "Purple Cat", 177 | "description": "Why are we teaching kids there are purple cats?" 178 | } 179 | ]; 180 | 181 | ``` 182 | 183 | You could, for example, massage the results of an API call and use the result array of objects to display in the picker. Other parameters can be present in the objects in the array (like IDs for example), the picker will use `title`, `image` and `description` if they are present. Although `title` must be present. 184 | 185 | Here's how it will look in the picker: 186 | 187 | 188 | 189 | ### Webpack 190 | 191 | Thanks to Mike Richards, this plugin is now compatible with webpack. Just follow the webpack instructions carefully, in particular the `bundle-config.js` and `require("bundle-entry-points");` parts. See more here. 192 | 193 | ## API 194 | 195 | The UI element accepts the following parameters: 196 | 197 | | Property | Default | Description | 198 | | --- | --- | --- | 199 | | source | REQUIRED | The array of strings or objects (see Source Array above) you want to display in the picker. | 200 | | hintText | Enter text to filter... | This is the text that shows up as the hint for the textfield used to filter the list. | 201 | | listWidth | 300 | The width of the modal element. | 202 | | listHeight | 300 | The height of the modal element. | 203 | | focusOnShow | false | true or false, indicating if the textfield should be in focus (and the keyboard open) when the listpicker is shown. | 204 | | dimmerColor | rgba(0,0,0,0.8) | The color of the dimmer behind the modal. You can set it to `transparent`, or any color supported by NativeScript (ex: `rgba(255,255,255,0.5)`, `red`, `#0088CC`) | 205 | | blur | none | iOS only. Pass `dark` or `light` for a dark or light blur effect. If this is passed, dimmerColor is ignored on iOS but respected on Android. | 206 | | itemTapped(args) | | This is the function called when an item in the list is tapped. The modal is automically dismissed, and you can access to item tapped with `args.selectedItem`. | 207 | | canceled | | This is just a function to call if the user cancels, probably rarely neccessary. | 208 | | showCancel | | Show cancel button or not. | 209 | | enableSearch | | Allow searching by showing the TextField at the top. | 210 | | autocomplete(fn: Function) | | Allow binding listener `textChangeEvent` to Textfield and use the plugin as `autocomplete` eg.: Google Place API. | 211 | 212 | ## CSS Styling 213 | 214 | ```css 215 | .flp-container .flp-list-container { 216 | border-radius: 10; 217 | } 218 | .flp-container .flp-list-container .flp-listview { 219 | background-color: white; 220 | } 221 | 222 | .flp-container .flp-list-container .flp-listview .flp-row { 223 | background-color: white; 224 | } 225 | /* .flp-container .flp-list-container .flp-listview .flp-row .flp-row-container { 226 | padding: 10; 227 | } */ 228 | .flp-container .flp-list-container .flp-listview .flp-row .flp-image { 229 | margin: 10 0 10 5; 230 | } 231 | .flp-container .flp-list-container .flp-listview .flp-row .flp-title-container { 232 | margin: 10 10 10 5; 233 | /* margin: 0 10 0 10; */ 234 | } 235 | .flp-container .flp-list-container .flp-listview .flp-row .flp-title-container .flp-title { 236 | font-weight: bold; 237 | font-size: 16; 238 | } 239 | .flp-container .flp-list-container .flp-listview .flp-row .flp-title-container .flp-description { 240 | color: gray; 241 | font-size: 13; 242 | } 243 | .flp-container .flp-list-container .flp-listview .flp-row .flp-title-container .flp-no-title { 244 | margin-left: 15; 245 | padding: 10 0; 246 | } 247 | .flp-container .flp-list-container .flp-listview .flp-row .flp-item-selected { 248 | color: lightblue; 249 | } 250 | 251 | .flp-container .flp-hint-field { 252 | padding: 10 15; 253 | height: 40; 254 | background-color: #E0E0E0; 255 | border-radius: 10 10 0 0; 256 | } 257 | 258 | .flp-container .flp-cancel-container { 259 | background-color: #E0E0E0; 260 | height: 40; 261 | border-radius: 0 0 10 10; 262 | } 263 | 264 | .flp-container .flp-cancel-container .flp-btn-cancel { 265 | font-weight: bold; 266 | height: 40; 267 | background-color: transparent; 268 | border-color: transparent; 269 | border-width: 1; 270 | font-size: 12; 271 | } 272 | ``` 273 | 274 | 275 | ## License 276 | 277 | Apache License Version 2.0, January 2004 278 | -------------------------------------------------------------------------------- /assets/filterablelist.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/assets/filterablelist.gif -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | # NativeScript 2 | hooks/ 3 | node_modules/ 4 | platforms/ 5 | 6 | # NativeScript Template 7 | *.js.map 8 | *.js 9 | !webpack.config.js 10 | 11 | # Logs 12 | logs 13 | *.log 14 | npm-debug.log* 15 | yarn-debug.log* 16 | yarn-error.log* 17 | 18 | # General 19 | .DS_Store 20 | .AppleDouble 21 | .LSOverride 22 | .idea 23 | .cloud 24 | .project 25 | tmp/ 26 | typings/ 27 | 28 | # Visual Studio Code 29 | .vscode/* 30 | !.vscode/settings.json 31 | !.vscode/tasks.json 32 | !.vscode/launch.json 33 | !.vscode/extensions.json 34 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/app.gradle: -------------------------------------------------------------------------------- 1 | // Add your native dependencies here: 2 | 3 | // Uncomment to add recyclerview-v7 dependency 4 | //dependencies { 5 | // compile 'com.android.support:recyclerview-v7:+' 6 | //} 7 | 8 | android { 9 | defaultConfig { 10 | generatedDensities = [] 11 | applicationId = "org.nativescript.filterablelistpicker" 12 | } 13 | aaptOptions { 14 | additionalParameters "--no-version-vectors" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 27 | 28 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-hdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-hdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-hdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-hdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-ldpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-ldpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-ldpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-ldpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-mdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-mdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-mdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-mdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-nodpi/splash_screen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-xhdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-xxhdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/background.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/icon.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/Android/src/main/res/drawable-xxxhdpi/logo.png -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/values-v21/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3d5afe 4 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 11 | 14 | 15 | 16 | 19 | 20 | 23 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #F5F5F5 4 | #757575 5 | #33B5E5 6 | #272734 7 | -------------------------------------------------------------------------------- /demo/app/App_Resources/Android/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 18 | 19 | 21 | 22 | 23 | 31 | 32 | 34 | 35 | 36 | 42 | 43 | 45 | 46 | -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "icon-29.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "icon-29@2x.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "icon-29@3x.png", 19 | "scale" : "3x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "icon-40@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "40x40", 29 | "idiom" : "iphone", 30 | "filename" : "icon-40@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "57x57", 35 | "idiom" : "iphone", 36 | "filename" : "icon-57.png", 37 | "scale" : "1x" 38 | }, 39 | { 40 | "size" : "57x57", 41 | "idiom" : "iphone", 42 | "filename" : "icon-57@2x.png", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "icon-60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "icon-60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "29x29", 59 | "idiom" : "ipad", 60 | "filename" : "icon-29.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "29x29", 65 | "idiom" : "ipad", 66 | "filename" : "icon-29@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "40x40", 71 | "idiom" : "ipad", 72 | "filename" : "icon-40.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "40x40", 77 | "idiom" : "ipad", 78 | "filename" : "icon-40@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "50x50", 83 | "idiom" : "ipad", 84 | "filename" : "icon-50.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "50x50", 89 | "idiom" : "ipad", 90 | "filename" : "icon-50@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "72x72", 95 | "idiom" : "ipad", 96 | "filename" : "icon-72.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "72x72", 101 | "idiom" : "ipad", 102 | "filename" : "icon-72@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "76x76", 107 | "idiom" : "ipad", 108 | "filename" : "icon-76.png", 109 | "scale" : "1x" 110 | }, 111 | { 112 | "size" : "76x76", 113 | "idiom" : "ipad", 114 | "filename" : "icon-76@2x.png", 115 | "scale" : "2x" 116 | }, 117 | { 118 | "size" : "83.5x83.5", 119 | "idiom" : "ipad", 120 | "filename" : "icon-83.5@2x.png", 121 | "scale" : "2x" 122 | } 123 | ], 124 | "info" : { 125 | "version" : 1, 126 | "author" : "xcode" 127 | } 128 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-50@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-57@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "extent" : "full-screen", 5 | "idiom" : "iphone", 6 | "subtype" : "736h", 7 | "filename" : "Default-736h@3x.png", 8 | "minimum-system-version" : "8.0", 9 | "orientation" : "portrait", 10 | "scale" : "3x" 11 | }, 12 | { 13 | "extent" : "full-screen", 14 | "idiom" : "iphone", 15 | "subtype" : "736h", 16 | "filename" : "Default-Landscape@3x.png", 17 | "minimum-system-version" : "8.0", 18 | "orientation" : "landscape", 19 | "scale" : "3x" 20 | }, 21 | { 22 | "extent" : "full-screen", 23 | "idiom" : "iphone", 24 | "subtype" : "667h", 25 | "filename" : "Default-667h@2x.png", 26 | "minimum-system-version" : "8.0", 27 | "orientation" : "portrait", 28 | "scale" : "2x" 29 | }, 30 | { 31 | "orientation" : "portrait", 32 | "idiom" : "iphone", 33 | "filename" : "Default@2x.png", 34 | "extent" : "full-screen", 35 | "minimum-system-version" : "7.0", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "extent" : "full-screen", 40 | "idiom" : "iphone", 41 | "subtype" : "retina4", 42 | "filename" : "Default-568h@2x.png", 43 | "minimum-system-version" : "7.0", 44 | "orientation" : "portrait", 45 | "scale" : "2x" 46 | }, 47 | { 48 | "orientation" : "portrait", 49 | "idiom" : "ipad", 50 | "filename" : "Default-Portrait.png", 51 | "extent" : "full-screen", 52 | "minimum-system-version" : "7.0", 53 | "scale" : "1x" 54 | }, 55 | { 56 | "orientation" : "landscape", 57 | "idiom" : "ipad", 58 | "filename" : "Default-Landscape.png", 59 | "extent" : "full-screen", 60 | "minimum-system-version" : "7.0", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "orientation" : "portrait", 65 | "idiom" : "ipad", 66 | "filename" : "Default-Portrait@2x.png", 67 | "extent" : "full-screen", 68 | "minimum-system-version" : "7.0", 69 | "scale" : "2x" 70 | }, 71 | { 72 | "orientation" : "landscape", 73 | "idiom" : "ipad", 74 | "filename" : "Default-Landscape@2x.png", 75 | "extent" : "full-screen", 76 | "minimum-system-version" : "7.0", 77 | "scale" : "2x" 78 | }, 79 | { 80 | "orientation" : "portrait", 81 | "idiom" : "iphone", 82 | "filename" : "Default.png", 83 | "extent" : "full-screen", 84 | "scale" : "1x" 85 | }, 86 | { 87 | "orientation" : "portrait", 88 | "idiom" : "iphone", 89 | "filename" : "Default@2x.png", 90 | "extent" : "full-screen", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "orientation" : "portrait", 95 | "idiom" : "iphone", 96 | "filename" : "Default-568h@2x.png", 97 | "extent" : "full-screen", 98 | "subtype" : "retina4", 99 | "scale" : "2x" 100 | }, 101 | { 102 | "orientation" : "portrait", 103 | "idiom" : "ipad", 104 | "extent" : "to-status-bar", 105 | "scale" : "1x" 106 | }, 107 | { 108 | "orientation" : "portrait", 109 | "idiom" : "ipad", 110 | "filename" : "Default-Portrait.png", 111 | "extent" : "full-screen", 112 | "scale" : "1x" 113 | }, 114 | { 115 | "orientation" : "landscape", 116 | "idiom" : "ipad", 117 | "extent" : "to-status-bar", 118 | "scale" : "1x" 119 | }, 120 | { 121 | "orientation" : "landscape", 122 | "idiom" : "ipad", 123 | "filename" : "Default-Landscape.png", 124 | "extent" : "full-screen", 125 | "scale" : "1x" 126 | }, 127 | { 128 | "orientation" : "portrait", 129 | "idiom" : "ipad", 130 | "extent" : "to-status-bar", 131 | "scale" : "2x" 132 | }, 133 | { 134 | "orientation" : "portrait", 135 | "idiom" : "ipad", 136 | "filename" : "Default-Portrait@2x.png", 137 | "extent" : "full-screen", 138 | "scale" : "2x" 139 | }, 140 | { 141 | "orientation" : "landscape", 142 | "idiom" : "ipad", 143 | "extent" : "to-status-bar", 144 | "scale" : "2x" 145 | }, 146 | { 147 | "orientation" : "landscape", 148 | "idiom" : "ipad", 149 | "filename" : "Default-Landscape@2x.png", 150 | "extent" : "full-screen", 151 | "scale" : "2x" 152 | } 153 | ], 154 | "info" : { 155 | "version" : 1, 156 | "author" : "xcode" 157 | } 158 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchScreen-AspectFill.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchScreen-AspectFill@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchScreen-Center.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchScreen-Center@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/demo/app/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiresFullScreen 28 | 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | NSAppTransportSecurity 47 | 48 | NSAllowsArbitraryLoads 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /demo/app/App_Resources/iOS/build.xcconfig: -------------------------------------------------------------------------------- 1 | // You can add custom settings here 2 | // for example you can uncomment the following line to force distribution code signing 3 | // CODE_SIGN_IDENTITY = iPhone Distribution 4 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 5 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 6 | -------------------------------------------------------------------------------- /demo/app/app.css: -------------------------------------------------------------------------------- 1 | @import '~nativescript-theme-core/css/core.light.css'; 2 | 3 | .flp-container { 4 | background-color: red; 5 | } 6 | 7 | .flp-container .flp-list-container { 8 | border-radius: 10; 9 | } 10 | .flp-container .flp-heading-title { 11 | font-size: 12; 12 | text-align: center; 13 | background-color: yellow; 14 | padding: 10; 15 | } 16 | .flp-container .flp-list-container .flp-listview { 17 | background-color: white; 18 | } 19 | 20 | .flp-container .flp-list-container .flp-listview .flp-row { 21 | background-color: white; 22 | } 23 | /* .flp-container .flp-list-container .flp-listview .flp-row .flp-row-container { 24 | padding: 10; 25 | } */ 26 | .flp-container .flp-list-container .flp-listview .flp-row .flp-image { 27 | margin: 10 0 10 5; 28 | } 29 | .flp-container .flp-list-container .flp-listview .flp-row .flp-title-container { 30 | margin: 10 10 10 5; 31 | /* margin: 0 10 0 10; */ 32 | } 33 | .flp-container .flp-list-container .flp-listview .flp-row .flp-title-container .flp-title { 34 | font-weight: bold; 35 | font-size: 16; 36 | } 37 | .flp-container .flp-list-container .flp-listview .flp-row .flp-title-container .flp-description { 38 | color: gray; 39 | font-size: 13; 40 | } 41 | .flp-container .flp-list-container .flp-listview .flp-row .flp-title-container .flp-no-title { 42 | margin-left: 15; 43 | padding: 10 0; 44 | } 45 | .flp-container .flp-list-container .flp-listview .flp-row .flp-item-selected { 46 | color: lightblue; 47 | } 48 | 49 | .flp-container .flp-hint-field { 50 | padding: 10 15; 51 | height: 40; 52 | background-color: #E0E0E0; 53 | border-radius: 10 10 0 0; 54 | } 55 | 56 | .flp-container .flp-cancel-container { 57 | background-color: #E0E0E0; 58 | height: 40; 59 | border-radius: 0 0 10 10; 60 | } 61 | 62 | .flp-container .flp-cancel-container .flp-btn-cancel { 63 | font-weight: bold; 64 | height: 40; 65 | background-color: transparent; 66 | border-color: transparent; 67 | border-width: 1; 68 | font-size: 12; 69 | } -------------------------------------------------------------------------------- /demo/app/app.ts: -------------------------------------------------------------------------------- 1 | import * as application from 'tns-core-modules/application'; 2 | application.run({ moduleName: "main-page" }); 3 | -------------------------------------------------------------------------------- /demo/app/main-page.ts: -------------------------------------------------------------------------------- 1 | import * as observable from 'tns-core-modules/data/observable'; 2 | import * as pages from 'tns-core-modules/ui/page'; 3 | import {HelloWorldModel} from './main-view-model'; 4 | 5 | // Event handler for Page 'loaded' event attached in main-page.xml 6 | export function pageLoaded(args: observable.EventData) { 7 | // Get the event sender 8 | let page = args.object; 9 | page.bindingContext = new HelloWorldModel(page); 10 | } 11 | -------------------------------------------------------------------------------- /demo/app/main-page.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 117 | 118 | 119 | 120 | ``` 121 | 122 | Then in your code... 123 | ```ts 124 | @ViewChild('myfilter') myfilter: ElementRef; 125 | 126 | cancelFilterableList() { 127 | console.log('canceled'); 128 | } 129 | 130 | itemTapped(args) { 131 | alert(args.selectedItem) 132 | } 133 | 134 | showPicker() { 135 | this.myfilter.nativeElement.show(); 136 | } 137 | ``` 138 | 139 | Note: When calling show, as of 2.1.0 you can pass in a viewContainer that the plugin will use to find the necessary elements. This allows you to 140 | use the list picker in modals now! For example, you could pass in a Page element, or a GridLayout that contains the FilterableListpicker element like this: 141 | 142 | in android: 143 | ```ts 144 | @ViewChild('myContainer') myContainer: ElementRef; 145 | 146 | public function showPicker() { 147 | this.myfilter.nativeElement.show(this.myContainer.nativeElement); 148 | } 149 | ``` 150 | 151 | Note: You can change the items in the filterable list easily by just setting the source to an array in your observable, and changing then changing the array. Take a look at the demo project for an example. 152 | 153 | ### Source Array 154 | As of version 2.0, you can supply either an array of strings, or an array of objects. The object must contain a parameter called `title`, and thats what will display as the title. Check out the gif above to see what the picker looks like when supplying an object. The 3 parameters the picker will display 155 | if in your object are: 156 | 157 | | Property | Description| 158 | | --- | --- | 159 | | title | The title, this is what your list will be filtered on, and it will display in bold. | 160 | | image | OPTIONAL: This will display to the left of the title. | 161 | | description | OPTIONAL: This will display under the title smaller and in gray. | 162 | 163 | Here's some example code: 164 | ```ts 165 | public listitems = [ 166 | { 167 | "image": "https://lh3.googleusercontent.com/gN6iBKP1b2GTXZZoCxhyXiYIAh8QJ_8xzlhEK6csyDadA4GdkEdIEy9Bc8s5jozt1g=w300", 168 | "title": "Brown Bear", 169 | "description": "Brown bear brown bear, what do you see?" 170 | }, 171 | { 172 | "image": "http://icons.veryicon.com/png/Flag/Rounded%20World%20Flags/Indonesia%20Flag.png", 173 | "title": "Red Bird" 174 | }, 175 | { 176 | "title": "Purple Cat", 177 | "description": "Why are we teaching kids there are purple cats?" 178 | } 179 | ]; 180 | 181 | ``` 182 | 183 | You could, for example, massage the results of an API call and use the result array of objects to display in the picker. Other parameters can be present in the objects in the array (like IDs for example), the picker will use `title`, `image` and `description` if they are present. Although `title` must be present. 184 | 185 | Here's how it will look in the picker: 186 | 187 | 188 | 189 | 190 | ### Webpack 191 | Thanks to Mike Richards, this plugin is now compatible with webpack. Just follow the webpack instructions carefully, in particular the `bundle-config.js` and `require("bundle-entry-points");` parts. See more here. 192 | 193 | 194 | ## API 195 | 196 | The UI element accepts the following parameters: 197 | 198 | | Property | Default | Description | 199 | | --- | --- | --- | 200 | | source | REQUIRED | The array of strings or objects (see Source Array above) you want to display in the picker. | 201 | | hintText | Enter text to filter... | This is the text that shows up as the hint for the textfield used to filter the list. | 202 | | listWidth | 300 | The width of the modal element. | 203 | | listHeight | 300 | The height of the modal element. | 204 | | focusOnShow | false | true or false, indicating if the textfield should be in focus (and the keyboard open) when the listpicker is shown. | 205 | | dimmerColor | rgba(0,0,0,0.8) | The color of the dimmer behind the modal. You can set it to `transparent`, or any color supported by NativeScript (ex: `rgba(255,255,255,0.5)`, `red`, `#0088CC`) | 206 | | blur | none | iOS only. Pass `dark` or `light` for a dark or light blur effect. If this is passed, dimmerColor is ignored on iOS but respected on Android. | 207 | | itemTapped(args) | | This is the function called when an item in the list is tapped. The modal is automically dismissed, and you can access to item tapped with `args.selectedItem`. | 208 | | canceled | | This is just a function to call if the user cancels, probably rarely neccessary. | 209 | | showCancel | | Show cancel button or not. | 210 | | enableSearch | | Allow searching by showing the TextField at the top. | 211 | | autocomplete(fn: Function) | | Allow binding listener `textChangeEvent` to Textfield and use the plugin as `autocomplete` eg.: Google Place API. | 212 | 213 | ## CSS Styling 214 | 215 | ```css 216 | .flp-container .flp-list-container { 217 | border-radius: 10; 218 | } 219 | .flp-container .flp-list-container .flp-listview { 220 | background-color: white; 221 | } 222 | 223 | .flp-container .flp-list-container .flp-listview .flp-row { 224 | background-color: white; 225 | } 226 | /* .flp-container .flp-list-container .flp-listview .flp-row .flp-row-container { 227 | padding: 10; 228 | } */ 229 | .flp-container .flp-list-container .flp-listview .flp-row .flp-image { 230 | margin: 10 0 10 5; 231 | } 232 | .flp-container .flp-list-container .flp-listview .flp-row .flp-title-container { 233 | margin: 10 10 10 5; 234 | /* margin: 0 10 0 10; */ 235 | } 236 | .flp-container .flp-list-container .flp-listview .flp-row .flp-title-container .flp-title { 237 | font-weight: bold; 238 | font-size: 16; 239 | } 240 | .flp-container .flp-list-container .flp-listview .flp-row .flp-title-container .flp-description { 241 | color: gray; 242 | font-size: 13; 243 | } 244 | .flp-container .flp-list-container .flp-listview .flp-row .flp-title-container .flp-no-title { 245 | margin-left: 15; 246 | padding: 10 0; 247 | } 248 | .flp-container .flp-list-container .flp-listview .flp-row .flp-item-selected { 249 | color: lightblue; 250 | } 251 | 252 | .flp-container .flp-hint-field { 253 | padding: 10 15; 254 | height: 40; 255 | background-color: #E0E0E0; 256 | border-radius: 10 10 0 0; 257 | } 258 | 259 | .flp-container .flp-cancel-container { 260 | background-color: #E0E0E0; 261 | height: 40; 262 | border-radius: 0 0 10 10; 263 | } 264 | 265 | .flp-container .flp-cancel-container .flp-btn-cancel { 266 | font-weight: bold; 267 | height: 40; 268 | background-color: transparent; 269 | border-color: transparent; 270 | border-width: 1; 271 | font-size: 12; 272 | } 273 | ``` 274 | 275 | 276 | ## License 277 | 278 | Apache License Version 2.0, January 2004 279 | -------------------------------------------------------------------------------- /src/assets/download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/src/assets/download.png -------------------------------------------------------------------------------- /src/filterable-listpicker.ts: -------------------------------------------------------------------------------- 1 | import { ObservableArray } from "tns-core-modules/data/observable-array"; 2 | 3 | import { 4 | View, 5 | Property, 6 | booleanConverter, 7 | PropertyChangeData 8 | } from "tns-core-modules/ui/core/view"; 9 | import { AnimationCurve } from "tns-core-modules/ui/enums"; 10 | import { GridLayout } from "tns-core-modules/ui/layouts/grid-layout"; 11 | import { TextField } from "tns-core-modules/ui/text-field"; 12 | import { isIOS } from "tns-core-modules/platform"; 13 | import * as enums from "tns-core-modules/ui/enums"; 14 | 15 | let builder = require("tns-core-modules/ui/builder"); 16 | 17 | let unfilteredSource: Array = []; 18 | let filtering: boolean = false; 19 | export const listWidthProperty = new Property({ 20 | name: "listWidth", 21 | defaultValue: "300" 22 | }); 23 | export const listHeightProperty = new Property({ 24 | name: "listHeight", 25 | defaultValue: "300" 26 | }); 27 | export const headingTitleProperty = new Property({ 28 | name: "headingTitle", 29 | defaultValue: undefined 30 | }); 31 | export const enableSearchProperty = new Property( 32 | { 33 | name: "enableSearch", 34 | defaultValue: true, 35 | valueConverter: booleanConverter 36 | } 37 | ); 38 | export const showCancelProperty = new Property({ 39 | name: "showCancel", 40 | defaultValue: true, 41 | valueConverter: booleanConverter 42 | }); 43 | export const dimmerColorProperty = new Property({ 44 | name: "dimmerColor", 45 | defaultValue: "rgba(0,0,0,0.8)" 46 | }); 47 | export const blurProperty = new Property({ 48 | name: "blur", 49 | defaultValue: "none" 50 | }); 51 | export const focusOnShowProperty = new Property({ 52 | name: "focusOnShow", 53 | defaultValue: false 54 | }); 55 | export const hideFilterProperty = new Property({ 56 | name: "hideFilter", 57 | defaultValue: false 58 | }); 59 | export const hintTextProperty = new Property({ 60 | name: "hintText", 61 | defaultValue: "Enter text to filter..." 62 | }); 63 | export const sourceProperty = new Property< 64 | FilterableListpicker, 65 | ObservableArray 66 | >({ 67 | name: "source", 68 | defaultValue: undefined, 69 | affectsLayout: true, 70 | valueChanged: (target, oldValue, newValue) => { 71 | if (!filtering) { 72 | while (unfilteredSource.length) unfilteredSource.pop(); 73 | newValue.forEach(element => { 74 | unfilteredSource.push(element); 75 | }); 76 | } 77 | } 78 | }); 79 | 80 | export class FilterableListpicker extends GridLayout { 81 | constructor() { 82 | super(); 83 | this._searchFilter = this._searchFilterFn.bind(this); 84 | } 85 | 86 | onLoaded() { 87 | super.onLoaded(); 88 | //let innerComponent = builder.load(__dirname + '/filterable-listpicker.xml') as View; 89 | let innerComponent = builder.Builder.parse(` 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | `); 115 | innerComponent.bindingContext = this; 116 | this.addChild(innerComponent); 117 | } 118 | public static canceledEvent = "canceled"; 119 | public static itemTappedEvent = "itemTapped"; 120 | public source: any; 121 | public dimmerColor: any; 122 | public hintText: any; 123 | public hideFilter: any; 124 | public enableSearch: boolean; 125 | public blur: any; 126 | private blurView: any = false; 127 | public focusOnShow: any; 128 | private _container: GridLayout; 129 | private _picker: GridLayout; 130 | private _textField: TextField; 131 | private _searchFilter: (data: any) => void; 132 | private _isAutocomplete: boolean = false; 133 | private _suggestions: any; 134 | 135 | visibility: any = enums.Visibility.collapse; 136 | 137 | loadedContainer(args) { 138 | this._container = args.object; 139 | } 140 | 141 | loadedInnerContainer(args) { 142 | this._picker = args.object; 143 | } 144 | 145 | autocomplete(fn: Function) { 146 | if(!this.isAutocomplete) 147 | return; 148 | if(typeof fn !== "function") 149 | throw("[FilterableListPicker]: autotcomplete params must be a Function type !"); 150 | 151 | /** 152 | * Populate sources with suggestions if is defined is usefull if we have a most use list 153 | * for the moment user can't search into suggestion .. writing into Textfield will active autocomplete 154 | * */ 155 | if(!this.source) 156 | this.source = []; 157 | 158 | // Copy suggestion list to bind it when Textfield is empty 159 | this._suggestions = this.source; 160 | 161 | // bind custome autocomplete function 162 | this._textField.on("textChange", (data: PropertyChangeData) => { 163 | if(!data.value && this._suggestions.length > 0) { 164 | this.set("source", this._suggestions) 165 | this.notifyPropertyChange("source", this._suggestions); 166 | console.log(this._suggestions); 167 | return; 168 | } 169 | fn(data); 170 | }) 171 | } 172 | 173 | loadedTextField(args) { 174 | this._textField = args.object; 175 | } 176 | 177 | public choose(args) { 178 | let item = this.source[args.index]; 179 | this.hide(); 180 | this.notify({ 181 | eventName: "itemTapped", 182 | object: this, 183 | selectedItem: item 184 | }); 185 | } 186 | 187 | public cancel() { 188 | this.notify({ 189 | eventName: "canceled", 190 | object: this 191 | }); 192 | this.hide(); 193 | } 194 | 195 | public hide() { 196 | if (this.enableSearch) { 197 | if (this._textField.dismissSoftInput) this._textField.dismissSoftInput(); 198 | this._textField.text = ""; 199 | } 200 | if (this.blurView) { 201 | UIView.animateWithDurationAnimationsCompletion( 202 | 0.3, 203 | () => { 204 | this.blurView.effect = null; 205 | }, 206 | () => { 207 | this.blurView.removeFromSuperview(); 208 | } 209 | ); 210 | } else { 211 | this._container 212 | .animate({ 213 | opacity: 0, 214 | duration: 200 215 | }) 216 | .then(_ => {}, err => {}); 217 | } 218 | 219 | if (this.enableSearch) { 220 | // cleanup event when closing 221 | this._textField.off("textChange", this._searchFilter); 222 | } 223 | 224 | return this._picker 225 | .animate({ 226 | scale: { x: 0.7, y: 0.7 }, 227 | opacity: 0, 228 | duration: 400, 229 | curve: AnimationCurve.cubicBezier(0.1, 0.1, 0.1, 1) 230 | }) 231 | .then( 232 | () => { 233 | this.visibility = enums.Visibility.collapse; 234 | this._container.visibility = "collapse"; 235 | }, 236 | err => {} 237 | ); 238 | } 239 | 240 | public show() { 241 | this.visibility = enums.Visibility.visible; 242 | this._container.visibility = "visible"; 243 | 244 | this.source = unfilteredSource.filter(i => true); 245 | if (isIOS && this.blur && this.blur != "none") { 246 | let iosView: UIView = this._container.ios; 247 | let effectView = UIVisualEffectView.alloc().init(); 248 | effectView.frame = CGRectMake( 249 | 0, 250 | 0, 251 | iosView.bounds.size.width, 252 | iosView.bounds.size.height 253 | ); 254 | effectView.autoresizingMask = 255 | UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; 256 | this.blurView = effectView; 257 | iosView.addSubview(effectView); 258 | iosView.sendSubviewToBack(effectView); 259 | UIView.animateWithDurationAnimationsCompletion( 260 | 0.3, 261 | () => { 262 | let theme = UIBlurEffectStyle.Dark; 263 | if (this.blur == "light") theme = UIBlurEffectStyle.Light; 264 | effectView.effect = UIBlurEffect.effectWithStyle(theme); 265 | }, 266 | () => { 267 | // the animation is complete. 268 | } 269 | ); 270 | } else { 271 | this._container.opacity = 0; 272 | this._container.backgroundColor = this.dimmerColor; 273 | this._container 274 | .animate({ 275 | opacity: 1, 276 | duration: 200 277 | }) 278 | .then(_ => {}, err => {}); 279 | } 280 | 281 | this._picker.scaleX = 0.7; 282 | this._picker.scaleY = 0.7; 283 | this._picker.opacity = 0; 284 | this._picker 285 | .animate({ 286 | scale: { x: 1, y: 1 }, 287 | opacity: 1, 288 | duration: 400, 289 | curve: AnimationCurve.cubicBezier(0.1, 0.1, 0.1, 1) 290 | }) 291 | .then(_ => {}, err => {}); 292 | 293 | if (this.enableSearch) { 294 | if (JSON.parse(this.focusOnShow)) this._textField.focus(); 295 | this._textField.on("textChange", this._searchFilter); 296 | } 297 | } 298 | 299 | get isAutocomplete(): boolean { 300 | return this._isAutocomplete; 301 | } 302 | 303 | set isAutocomplete(val: boolean) { 304 | if(val === false) { 305 | // remve listener for TextField 306 | console.log(val) 307 | this._textField.off("textChange"); 308 | } 309 | this._isAutocomplete = val; 310 | } 311 | 312 | private _searchFilterFn(data: any) { 313 | filtering = true; 314 | this.source = unfilteredSource.filter(item => { 315 | if (item.title) { 316 | return ( 317 | item.title.toLowerCase().indexOf(data.value.toLowerCase()) !== -1 318 | ); 319 | } else { 320 | return item.toLowerCase().indexOf(data.value.toLowerCase()) !== -1; 321 | } 322 | }); 323 | filtering = false; 324 | } 325 | } 326 | 327 | listWidthProperty.register(FilterableListpicker); 328 | listHeightProperty.register(FilterableListpicker); 329 | headingTitleProperty.register(FilterableListpicker); 330 | enableSearchProperty.register(FilterableListpicker); 331 | showCancelProperty.register(FilterableListpicker); 332 | dimmerColorProperty.register(FilterableListpicker); 333 | focusOnShowProperty.register(FilterableListpicker); 334 | hideFilterProperty.register(FilterableListpicker); 335 | blurProperty.register(FilterableListpicker); 336 | hintTextProperty.register(FilterableListpicker); 337 | sourceProperty.register(FilterableListpicker); 338 | 339 | export interface SourcesInterface { 340 | title: string; 341 | image?: any; 342 | description?: string; 343 | } 344 | 345 | export class SourcesDataItem implements SourcesInterface { 346 | title: string; 347 | image?: any; 348 | description?: string; 349 | 350 | constructor(title: string, image?: any, description?: string) 351 | { 352 | this.title = title; 353 | this.image = image; 354 | this.description = description; 355 | } 356 | } -------------------------------------------------------------------------------- /src/index.d.ts: -------------------------------------------------------------------------------- 1 | import { ObservableArray } from "tns-core-modules/data/observable-array"; 2 | import { Property } from "tns-core-modules/ui/core/view"; 3 | import { GridLayout } from "tns-core-modules/ui/layouts/grid-layout"; 4 | export declare const listWidthProperty: Property; 5 | export declare const listHeightProperty: Property; 6 | export declare const headingTitleProperty: Property; 7 | export declare const enableSearchProperty: Property; 8 | export declare const showCancelProperty: Property; 9 | export declare const dimmerColorProperty: Property; 10 | export declare const blurProperty: Property; 11 | export declare const focusOnShowProperty: Property; 12 | export declare const hideFilterProperty: Property; 13 | export declare const hintTextProperty: Property; 14 | export declare const sourceProperty: Property>; 15 | export declare class FilterableListpicker extends GridLayout { 16 | constructor(); 17 | onLoaded(): void; 18 | static canceledEvent: string; 19 | static itemTappedEvent: string; 20 | source: any; 21 | dimmerColor: any; 22 | hintText: any; 23 | hideFilter: any; 24 | enableSearch: boolean; 25 | blur: any; 26 | private blurView; 27 | focusOnShow: any; 28 | private _container; 29 | private _picker; 30 | private _textField; 31 | private _searchFilter; 32 | private _isAutocomplete; 33 | private _suggestions; 34 | visibility: any; 35 | loadedContainer(args: any): void; 36 | loadedInnerContainer(args: any): void; 37 | autocomplete(fn: Function): void; 38 | loadedTextField(args: any): void; 39 | choose(args: any): void; 40 | cancel(): void; 41 | hide(): Promise; 42 | show(): void; 43 | isAutocomplete: boolean; 44 | private _searchFilterFn; 45 | } 46 | -------------------------------------------------------------------------------- /src/nsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "useLegacyWorkflow": true 3 | } -------------------------------------------------------------------------------- /src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nativescript-filterable-listpicker", 3 | "version": "3.0.0", 4 | "description": "A modal list picker with filtering capabilities.", 5 | "main": "filterable-listpicker", 6 | "typings": "index.d.ts", 7 | "nativescript": { 8 | "tns-android": { 9 | "version": "6.3.0" 10 | }, 11 | "tns-ios": { 12 | "version": "6.3.0" 13 | }, 14 | "plugin": { 15 | "nan": "true", 16 | "pan": "true", 17 | "vue": "true", 18 | "core3": "true", 19 | "category": "Interface" 20 | } 21 | }, 22 | "scripts": { 23 | "tsc": "tsc", 24 | "build": "npm i && tsc", 25 | "postclone": "npm i && node scripts/postclone.js && cd ../demo && npm i && cd ../src", 26 | "test.android": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build android && tns test android --justlaunch", 27 | "test.ios": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build ios && tns test ios --justlaunch", 28 | "tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\"", 29 | "plugin.tscwatch": "npm run tsc -- -w", 30 | "demo.ios": "npm run tsc && cd ../demo && tns run ios --emulator", 31 | "debug.ios": "npm run tsc && cd ../demo && tns debug ios --emulator", 32 | "demo.android": "npm run tsc && cd ../demo && tns run android", 33 | "debug.android": "npm run tsc && cd ../demo && tns debug android", 34 | "demo.reset": "cd ../demo && npx rimraf -- hooks node_modules platforms package-lock.json", 35 | "plugin.prepare": "npm run tsc && cd ../demo && tns plugin remove @proplugins/nativescript-filterable-listpicker && tns plugin add ../src && npx rimraf -- package-lock.json", 36 | "clean": "cd ../demo && npx rimraf -- hooks node_modules platforms package-lock.json && cd ../src && npx rimraf -- node_modules", 37 | "ci.tslint": "npm i && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**'" 38 | }, 39 | "keywords": [ 40 | "NativeScript", 41 | "JavaScript", 42 | "Android", 43 | "iOS" 44 | ], 45 | "author": { 46 | "name": "Dave Coffin", 47 | "email": "dave@davecoffin.com" 48 | }, 49 | "contributors": [ 50 | { 51 | "name": "Nathanael Walker", 52 | "email": "walkerrunpdx@gmail.com", 53 | "url": "https://github.com/NathanWalker" 54 | }, 55 | { 56 | "name": "MultiShiv19", 57 | "email": "sp@shiv19.com", 58 | "url": "https://github.com/shiv19" 59 | }, 60 | { 61 | "name": "BADER ALDIN Kefah", 62 | "email": "kefah.bader@gmail.com", 63 | "url": "https://github.com/kefahB" 64 | } 65 | ], 66 | "repository": { 67 | "url": "https://git.master.technology/proplugins/nativescript-filterable-listpicker", 68 | "type": "git" 69 | }, 70 | "bugs": { 71 | "url": "https://git.master.technology/proplugins/nativescript-filterable-listpicker/issues" 72 | }, 73 | "license": "Apache-2.0", 74 | "homepage": "https://git.master.technology/proplugins/nativescript-filterable-listpicker", 75 | "readmeFilename": "README.md", 76 | "devDependencies": { 77 | "rimraf": "^2.5.0", 78 | "tns-core-modules": "^6.0.0", 79 | "tns-platform-declarations": "^6.0.0", 80 | "tslint": "^5.0.0", 81 | "typescript": "^3.7.4" 82 | }, 83 | "dependencies": {}, 84 | "bootstrapper": "nativescript-plugin-seed" 85 | } 86 | -------------------------------------------------------------------------------- /src/platforms/android/nativescript_filterable_listpicker.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davecoffin/nativescript-filterable-listpicker/34cbf49b13adf2ff831f98330aa4d45fc4d0d7ee/src/platforms/android/nativescript_filterable_listpicker.aar -------------------------------------------------------------------------------- /src/references.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "removeComments": true, 7 | "noLib": false, 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "skipLibCheck": true, 11 | "lib": [ 12 | "es2017", 13 | "dom", 14 | "es6" 15 | ], 16 | "sourceMap": true, 17 | "pretty": true, 18 | "allowUnreachableCode": false, 19 | "allowUnusedLabels": false, 20 | "noEmitHelpers": true, 21 | "noEmitOnError": false, 22 | "noImplicitAny": false, 23 | "noImplicitReturns": true, 24 | "noImplicitUseStrict": false, 25 | "noFallthroughCasesInSwitch": true 26 | }, 27 | "exclude": [ 28 | "node_modules" 29 | ], 30 | "compileOnSave": false 31 | } 32 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "class-name": true, 4 | "comment-format": [ 5 | true, 6 | "check-space" 7 | ], 8 | "indent": [ 9 | true, 10 | "spaces" 11 | ], 12 | "no-duplicate-variable": true, 13 | "no-eval": true, 14 | "no-internal-module": true, 15 | "no-trailing-whitespace": true, 16 | "no-var-keyword": true, 17 | "one-line": [ 18 | true, 19 | "check-open-brace", 20 | "check-whitespace" 21 | ], 22 | "quotemark": [ 23 | false, 24 | "double" 25 | ], 26 | "semicolon": [ 27 | true, 28 | "always" 29 | ], 30 | "triple-equals": [ 31 | true, 32 | "allow-null-check" 33 | ], 34 | "typedef-whitespace": [ 35 | true, 36 | { 37 | "call-signature": "nospace", 38 | "index-signature": "nospace", 39 | "parameter": "nospace", 40 | "property-declaration": "nospace", 41 | "variable-declaration": "nospace" 42 | } 43 | ], 44 | "variable-name": [ 45 | true, 46 | "ban-keywords" 47 | ], 48 | "whitespace": [ 49 | true, 50 | "check-branch", 51 | "check-decl", 52 | "check-operator", 53 | "check-separator", 54 | "check-type" 55 | ] 56 | } 57 | } --------------------------------------------------------------------------------