├── .gitignore ├── LICENSE.md ├── README.md ├── RNTHorizontalPicker.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ ├── jeremyeaton.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ └── kvineetha.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── kvineetha.xcuserdatad │ └── xcschemes │ ├── RNTHorizontalPicker.xcscheme │ ├── UniversalLib.xcscheme │ └── xcschememanagement.plist ├── RNTHorizontalPicker ├── AKPickerView.h ├── AKPickerView.m ├── RNTHorizontalPicker.h ├── RNTHorizontalPicker.m ├── RNTHorizontalPickerManager.h └── RNTHorizontalPickerManager.m ├── Screenshot.png ├── index.ios.js ├── package-lock.json └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 vineetha2438 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-horizontal-picker 2 | 3 | Screenshot 4 | 5 | ## Add it to your project 6 | 7 | You can try linking the project automatically: 8 | 9 | `$ react-native link` 10 | 11 | or do it manually as described below: 12 | 13 | ### iOS 14 | 15 | - Run `npm install react-native-horizontal-picker --save` 16 | 17 | or: 18 | 19 | ##### Manually 20 | 21 | 1. Open your project in XCode, right click on `Libraries` and click `Add 22 | Files to "Your Project Name"` Look under `node_modules/react-native-horizontal-picker` and add `RNTHorizontalPicker.xcodeproj`. 23 | 2. Add `libRNTHorizontalPicker.a` to `Build Phases -> Link Binary With Libraries` 24 | 3. Click on `libRNTHorizontalPicker.xcodeproj` in `Libraries` and go the `Build 25 | Settings` tab. 26 | 27 | Then: 28 | 29 | 30 | - Whenever you want to use it within React code now you can: `import HorizontalPicker from 'react-native-horizontal-picker';` 31 | 32 | ## Example 33 | 34 | ```javascript 35 | { console.log('index of selected value', event.nativeEvent.newIndex); }} 40 | /> 41 | ``` 42 | 43 | ### To-do list 44 | 45 | - [ ] Add test cases 46 | - [ ] More UI customization support 47 | - [ ] Android support 48 | - [ ] Support for images 49 | 50 | ### Credit 51 | This component is based on akkyie's component [AKPickerView](https://github.com/Akkyie/AKPickerView.git). 52 | License: https://github.com/Akkyie/AKPickerView/blob/master/LICENSE 53 | 54 | ### License 55 | 56 | MIT. 57 | -------------------------------------------------------------------------------- /RNTHorizontalPicker.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXAggregateTarget section */ 10 | BAA0A5FF1E9A39950072AF1B /* UniversalLib */ = { 11 | isa = PBXAggregateTarget; 12 | buildConfigurationList = BAA0A6001E9A39950072AF1B /* Build configuration list for PBXAggregateTarget "UniversalLib" */; 13 | buildPhases = ( 14 | BAA0A6031E9A39C60072AF1B /* ShellScript */, 15 | ); 16 | dependencies = ( 17 | ); 18 | name = UniversalLib; 19 | productName = UniversalLib; 20 | }; 21 | /* End PBXAggregateTarget section */ 22 | 23 | /* Begin PBXBuildFile section */ 24 | BAA0A4F61E9A0E790072AF1B /* RNTHorizontalPickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BAA0A4F51E9A0E790072AF1B /* RNTHorizontalPickerManager.m */; }; 25 | BAA0A64E1E9A419C0072AF1B /* AKPickerView.m in Sources */ = {isa = PBXBuildFile; fileRef = BAA0A64D1E9A419C0072AF1B /* AKPickerView.m */; }; 26 | BAAF043A1E94F85300F3CB23 /* RNTHorizontalPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = BAAF04391E94F85300F3CB23 /* RNTHorizontalPicker.m */; }; 27 | BAAF043B1E94F85300F3CB23 /* RNTHorizontalPicker.h in Copy Files */ = {isa = PBXBuildFile; fileRef = BAAF04381E94F85300F3CB23 /* RNTHorizontalPicker.h */; }; 28 | /* End PBXBuildFile section */ 29 | 30 | /* Begin PBXContainerItemProxy section */ 31 | BAA0A5021E9A11D40072AF1B /* PBXContainerItemProxy */ = { 32 | isa = PBXContainerItemProxy; 33 | containerPortal = BAA0A4F71E9A11D40072AF1B /* React.xcodeproj */; 34 | proxyType = 2; 35 | remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; 36 | remoteInfo = React; 37 | }; 38 | BAA0A5041E9A11D40072AF1B /* PBXContainerItemProxy */ = { 39 | isa = PBXContainerItemProxy; 40 | containerPortal = BAA0A4F71E9A11D40072AF1B /* React.xcodeproj */; 41 | proxyType = 2; 42 | remoteGlobalIDString = 2D2A28131D9B038B00D4039D; 43 | remoteInfo = "React-tvOS"; 44 | }; 45 | BAA0A5061E9A11D40072AF1B /* PBXContainerItemProxy */ = { 46 | isa = PBXContainerItemProxy; 47 | containerPortal = BAA0A4F71E9A11D40072AF1B /* React.xcodeproj */; 48 | proxyType = 2; 49 | remoteGlobalIDString = 3D3C059A1DE3340900C268FA; 50 | remoteInfo = yoga; 51 | }; 52 | BAA0A5081E9A11D40072AF1B /* PBXContainerItemProxy */ = { 53 | isa = PBXContainerItemProxy; 54 | containerPortal = BAA0A4F71E9A11D40072AF1B /* React.xcodeproj */; 55 | proxyType = 2; 56 | remoteGlobalIDString = 3D3C06751DE3340C00C268FA; 57 | remoteInfo = "yoga-tvOS"; 58 | }; 59 | BAA0A50A1E9A11D40072AF1B /* PBXContainerItemProxy */ = { 60 | isa = PBXContainerItemProxy; 61 | containerPortal = BAA0A4F71E9A11D40072AF1B /* React.xcodeproj */; 62 | proxyType = 2; 63 | remoteGlobalIDString = 3D3CD9251DE5FBEC00167DC4; 64 | remoteInfo = cxxreact; 65 | }; 66 | BAA0A50C1E9A11D40072AF1B /* PBXContainerItemProxy */ = { 67 | isa = PBXContainerItemProxy; 68 | containerPortal = BAA0A4F71E9A11D40072AF1B /* React.xcodeproj */; 69 | proxyType = 2; 70 | remoteGlobalIDString = 3D3CD9321DE5FBEE00167DC4; 71 | remoteInfo = "cxxreact-tvOS"; 72 | }; 73 | BAA0A50E1E9A11D40072AF1B /* PBXContainerItemProxy */ = { 74 | isa = PBXContainerItemProxy; 75 | containerPortal = BAA0A4F71E9A11D40072AF1B /* React.xcodeproj */; 76 | proxyType = 2; 77 | remoteGlobalIDString = 3D3CD90B1DE5FBD600167DC4; 78 | remoteInfo = jschelpers; 79 | }; 80 | BAA0A5101E9A11D40072AF1B /* PBXContainerItemProxy */ = { 81 | isa = PBXContainerItemProxy; 82 | containerPortal = BAA0A4F71E9A11D40072AF1B /* React.xcodeproj */; 83 | proxyType = 2; 84 | remoteGlobalIDString = 3D3CD9181DE5FBD800167DC4; 85 | remoteInfo = "jschelpers-tvOS"; 86 | }; 87 | /* End PBXContainerItemProxy section */ 88 | 89 | /* Begin PBXCopyFilesBuildPhase section */ 90 | BAAF04331E94F85300F3CB23 /* Copy Files */ = { 91 | isa = PBXCopyFilesBuildPhase; 92 | buildActionMask = 2147483647; 93 | dstPath = "include/$(PRODUCT_NAME)"; 94 | dstSubfolderSpec = 16; 95 | files = ( 96 | BAAF043B1E94F85300F3CB23 /* RNTHorizontalPicker.h in Copy Files */, 97 | ); 98 | name = "Copy Files"; 99 | runOnlyForDeploymentPostprocessing = 0; 100 | }; 101 | /* End PBXCopyFilesBuildPhase section */ 102 | 103 | /* Begin PBXFileReference section */ 104 | 5A170288267473A06C8A101C /* Pods_RNTHorizontalPicker.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RNTHorizontalPicker.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 105 | BAA0A4F41E9A0E790072AF1B /* RNTHorizontalPickerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNTHorizontalPickerManager.h; sourceTree = ""; }; 106 | BAA0A4F51E9A0E790072AF1B /* RNTHorizontalPickerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNTHorizontalPickerManager.m; sourceTree = ""; }; 107 | BAA0A4F71E9A11D40072AF1B /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; }; 108 | BAA0A5FB1E9A356B0072AF1B /* AKPickerView.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AKPickerView.framework; path = "../../../Library/Developer/Xcode/DerivedData/RNTHorizontalPicker-cgczmimadwkfbdezmovctumonhop/Build/Products/Debug-iphonesimulator/AKPickerView/AKPickerView.framework"; sourceTree = ""; }; 109 | BAA0A64C1E9A419C0072AF1B /* AKPickerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AKPickerView.h; sourceTree = ""; }; 110 | BAA0A64D1E9A419C0072AF1B /* AKPickerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AKPickerView.m; sourceTree = ""; }; 111 | BAAF04351E94F85300F3CB23 /* libRNTHorizontalPicker.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNTHorizontalPicker.a; sourceTree = BUILT_PRODUCTS_DIR; }; 112 | BAAF04381E94F85300F3CB23 /* RNTHorizontalPicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNTHorizontalPicker.h; sourceTree = ""; }; 113 | BAAF04391E94F85300F3CB23 /* RNTHorizontalPicker.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNTHorizontalPicker.m; sourceTree = ""; }; 114 | /* End PBXFileReference section */ 115 | 116 | /* Begin PBXFrameworksBuildPhase section */ 117 | BAAF04321E94F85300F3CB23 /* Frameworks */ = { 118 | isa = PBXFrameworksBuildPhase; 119 | buildActionMask = 2147483647; 120 | files = ( 121 | ); 122 | runOnlyForDeploymentPostprocessing = 0; 123 | }; 124 | /* End PBXFrameworksBuildPhase section */ 125 | 126 | /* Begin PBXGroup section */ 127 | BAA0A4F81E9A11D40072AF1B /* Products */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | BAA0A5031E9A11D40072AF1B /* libReact.a */, 131 | BAA0A5051E9A11D40072AF1B /* libReact.a */, 132 | BAA0A5071E9A11D40072AF1B /* libyoga.a */, 133 | BAA0A5091E9A11D40072AF1B /* libyoga.a */, 134 | BAA0A50B1E9A11D40072AF1B /* libcxxreact.a */, 135 | BAA0A50D1E9A11D40072AF1B /* libcxxreact.a */, 136 | BAA0A50F1E9A11D40072AF1B /* libjschelpers.a */, 137 | BAA0A5111E9A11D40072AF1B /* libjschelpers.a */, 138 | ); 139 | name = Products; 140 | sourceTree = ""; 141 | }; 142 | BAAF042C1E94F85300F3CB23 = { 143 | isa = PBXGroup; 144 | children = ( 145 | BAAF04371E94F85300F3CB23 /* RNTHorizontalPicker */, 146 | BAAF04361E94F85300F3CB23 /* Products */, 147 | F48778AF8B696CD4238D895C /* Frameworks */, 148 | ); 149 | sourceTree = ""; 150 | }; 151 | BAAF04361E94F85300F3CB23 /* Products */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | BAAF04351E94F85300F3CB23 /* libRNTHorizontalPicker.a */, 155 | ); 156 | name = Products; 157 | sourceTree = ""; 158 | }; 159 | BAAF04371E94F85300F3CB23 /* RNTHorizontalPicker */ = { 160 | isa = PBXGroup; 161 | children = ( 162 | BAA0A64C1E9A419C0072AF1B /* AKPickerView.h */, 163 | BAA0A64D1E9A419C0072AF1B /* AKPickerView.m */, 164 | BAA0A4F41E9A0E790072AF1B /* RNTHorizontalPickerManager.h */, 165 | BAA0A4F51E9A0E790072AF1B /* RNTHorizontalPickerManager.m */, 166 | BAAF04381E94F85300F3CB23 /* RNTHorizontalPicker.h */, 167 | BAAF04391E94F85300F3CB23 /* RNTHorizontalPicker.m */, 168 | ); 169 | path = RNTHorizontalPicker; 170 | sourceTree = ""; 171 | }; 172 | F48778AF8B696CD4238D895C /* Frameworks */ = { 173 | isa = PBXGroup; 174 | children = ( 175 | BAA0A5FB1E9A356B0072AF1B /* AKPickerView.framework */, 176 | BAA0A4F71E9A11D40072AF1B /* React.xcodeproj */, 177 | 5A170288267473A06C8A101C /* Pods_RNTHorizontalPicker.framework */, 178 | ); 179 | name = Frameworks; 180 | sourceTree = ""; 181 | }; 182 | /* End PBXGroup section */ 183 | 184 | /* Begin PBXNativeTarget section */ 185 | BAAF04341E94F85300F3CB23 /* RNTHorizontalPicker */ = { 186 | isa = PBXNativeTarget; 187 | buildConfigurationList = BAAF043E1E94F85300F3CB23 /* Build configuration list for PBXNativeTarget "RNTHorizontalPicker" */; 188 | buildPhases = ( 189 | 142BAB838DC4034E30A569D3 /* [CP] Check Pods Manifest.lock */, 190 | BAAF04311E94F85300F3CB23 /* Sources */, 191 | BAAF04321E94F85300F3CB23 /* Frameworks */, 192 | BAAF04331E94F85300F3CB23 /* Copy Files */, 193 | 6B86F20C5C741AB322DD97C3 /* [CP] Copy Pods Resources */, 194 | ); 195 | buildRules = ( 196 | ); 197 | dependencies = ( 198 | ); 199 | name = RNTHorizontalPicker; 200 | productName = RNTHorizontalPicker; 201 | productReference = BAAF04351E94F85300F3CB23 /* libRNTHorizontalPicker.a */; 202 | productType = "com.apple.product-type.library.static"; 203 | }; 204 | /* End PBXNativeTarget section */ 205 | 206 | /* Begin PBXProject section */ 207 | BAAF042D1E94F85300F3CB23 /* Project object */ = { 208 | isa = PBXProject; 209 | attributes = { 210 | LastUpgradeCheck = 0820; 211 | ORGANIZATIONNAME = MDL; 212 | TargetAttributes = { 213 | BAA0A5FF1E9A39950072AF1B = { 214 | CreatedOnToolsVersion = 8.2.1; 215 | ProvisioningStyle = Automatic; 216 | }; 217 | BAAF04341E94F85300F3CB23 = { 218 | CreatedOnToolsVersion = 8.2.1; 219 | ProvisioningStyle = Automatic; 220 | }; 221 | }; 222 | }; 223 | buildConfigurationList = BAAF04301E94F85300F3CB23 /* Build configuration list for PBXProject "RNTHorizontalPicker" */; 224 | compatibilityVersion = "Xcode 3.2"; 225 | developmentRegion = English; 226 | hasScannedForEncodings = 0; 227 | knownRegions = ( 228 | en, 229 | ); 230 | mainGroup = BAAF042C1E94F85300F3CB23; 231 | productRefGroup = BAAF04361E94F85300F3CB23 /* Products */; 232 | projectDirPath = ""; 233 | projectReferences = ( 234 | { 235 | ProductGroup = BAA0A4F81E9A11D40072AF1B /* Products */; 236 | ProjectRef = BAA0A4F71E9A11D40072AF1B /* React.xcodeproj */; 237 | }, 238 | ); 239 | projectRoot = ""; 240 | targets = ( 241 | BAAF04341E94F85300F3CB23 /* RNTHorizontalPicker */, 242 | BAA0A5FF1E9A39950072AF1B /* UniversalLib */, 243 | ); 244 | }; 245 | /* End PBXProject section */ 246 | 247 | /* Begin PBXReferenceProxy section */ 248 | BAA0A5031E9A11D40072AF1B /* libReact.a */ = { 249 | isa = PBXReferenceProxy; 250 | fileType = archive.ar; 251 | path = libReact.a; 252 | remoteRef = BAA0A5021E9A11D40072AF1B /* PBXContainerItemProxy */; 253 | sourceTree = BUILT_PRODUCTS_DIR; 254 | }; 255 | BAA0A5051E9A11D40072AF1B /* libReact.a */ = { 256 | isa = PBXReferenceProxy; 257 | fileType = archive.ar; 258 | path = libReact.a; 259 | remoteRef = BAA0A5041E9A11D40072AF1B /* PBXContainerItemProxy */; 260 | sourceTree = BUILT_PRODUCTS_DIR; 261 | }; 262 | BAA0A5071E9A11D40072AF1B /* libyoga.a */ = { 263 | isa = PBXReferenceProxy; 264 | fileType = archive.ar; 265 | path = libyoga.a; 266 | remoteRef = BAA0A5061E9A11D40072AF1B /* PBXContainerItemProxy */; 267 | sourceTree = BUILT_PRODUCTS_DIR; 268 | }; 269 | BAA0A5091E9A11D40072AF1B /* libyoga.a */ = { 270 | isa = PBXReferenceProxy; 271 | fileType = archive.ar; 272 | path = libyoga.a; 273 | remoteRef = BAA0A5081E9A11D40072AF1B /* PBXContainerItemProxy */; 274 | sourceTree = BUILT_PRODUCTS_DIR; 275 | }; 276 | BAA0A50B1E9A11D40072AF1B /* libcxxreact.a */ = { 277 | isa = PBXReferenceProxy; 278 | fileType = archive.ar; 279 | path = libcxxreact.a; 280 | remoteRef = BAA0A50A1E9A11D40072AF1B /* PBXContainerItemProxy */; 281 | sourceTree = BUILT_PRODUCTS_DIR; 282 | }; 283 | BAA0A50D1E9A11D40072AF1B /* libcxxreact.a */ = { 284 | isa = PBXReferenceProxy; 285 | fileType = archive.ar; 286 | path = libcxxreact.a; 287 | remoteRef = BAA0A50C1E9A11D40072AF1B /* PBXContainerItemProxy */; 288 | sourceTree = BUILT_PRODUCTS_DIR; 289 | }; 290 | BAA0A50F1E9A11D40072AF1B /* libjschelpers.a */ = { 291 | isa = PBXReferenceProxy; 292 | fileType = archive.ar; 293 | path = libjschelpers.a; 294 | remoteRef = BAA0A50E1E9A11D40072AF1B /* PBXContainerItemProxy */; 295 | sourceTree = BUILT_PRODUCTS_DIR; 296 | }; 297 | BAA0A5111E9A11D40072AF1B /* libjschelpers.a */ = { 298 | isa = PBXReferenceProxy; 299 | fileType = archive.ar; 300 | path = libjschelpers.a; 301 | remoteRef = BAA0A5101E9A11D40072AF1B /* PBXContainerItemProxy */; 302 | sourceTree = BUILT_PRODUCTS_DIR; 303 | }; 304 | /* End PBXReferenceProxy section */ 305 | 306 | /* Begin PBXShellScriptBuildPhase section */ 307 | 142BAB838DC4034E30A569D3 /* [CP] Check Pods Manifest.lock */ = { 308 | isa = PBXShellScriptBuildPhase; 309 | buildActionMask = 2147483647; 310 | files = ( 311 | ); 312 | inputPaths = ( 313 | ); 314 | name = "[CP] Check Pods Manifest.lock"; 315 | outputPaths = ( 316 | ); 317 | runOnlyForDeploymentPostprocessing = 0; 318 | shellPath = /bin/sh; 319 | shellScript = ""; 320 | showEnvVarsInLog = 0; 321 | }; 322 | 6B86F20C5C741AB322DD97C3 /* [CP] Copy Pods Resources */ = { 323 | isa = PBXShellScriptBuildPhase; 324 | buildActionMask = 2147483647; 325 | files = ( 326 | ); 327 | inputPaths = ( 328 | ); 329 | name = "[CP] Copy Pods Resources"; 330 | outputPaths = ( 331 | ); 332 | runOnlyForDeploymentPostprocessing = 0; 333 | shellPath = /bin/sh; 334 | shellScript = ""; 335 | showEnvVarsInLog = 0; 336 | }; 337 | BAA0A6031E9A39C60072AF1B /* ShellScript */ = { 338 | isa = PBXShellScriptBuildPhase; 339 | buildActionMask = 2147483647; 340 | files = ( 341 | ); 342 | inputPaths = ( 343 | ); 344 | outputPaths = ( 345 | ); 346 | runOnlyForDeploymentPostprocessing = 0; 347 | shellPath = /bin/sh; 348 | shellScript = "# define output folder environment variable\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal\n\n# Step 1. Build Device and Simulator versions\nxcodebuild -target ImageFilters ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR=\"${BUILD_DIR}\" BUILD_ROOT=\"${BUILD_ROOT}\"\nxcodebuild -target ImageFilters -configuration ${CONFIGURATION} -sdk iphonesimulator -arch i386 BUILD_DIR=\"${BUILD_DIR}\" BUILD_ROOT=\"${BUILD_ROOT}\"\n\n# make sure the output directory exists\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\n\n# Step 2. Create universal binary file using lipo\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/lib${PROJECT_NAME}.a\" \"${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/lib${PROJECT_NAME}.a\"\n\n# Last touch. copy the header files. Just for convenience\ncp -R \"${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/include\" \"${UNIVERSAL_OUTPUTFOLDER}/\""; 349 | }; 350 | /* End PBXShellScriptBuildPhase section */ 351 | 352 | /* Begin PBXSourcesBuildPhase section */ 353 | BAAF04311E94F85300F3CB23 /* Sources */ = { 354 | isa = PBXSourcesBuildPhase; 355 | buildActionMask = 2147483647; 356 | files = ( 357 | BAA0A4F61E9A0E790072AF1B /* RNTHorizontalPickerManager.m in Sources */, 358 | BAA0A64E1E9A419C0072AF1B /* AKPickerView.m in Sources */, 359 | BAAF043A1E94F85300F3CB23 /* RNTHorizontalPicker.m in Sources */, 360 | ); 361 | runOnlyForDeploymentPostprocessing = 0; 362 | }; 363 | /* End PBXSourcesBuildPhase section */ 364 | 365 | /* Begin XCBuildConfiguration section */ 366 | BAA0A6011E9A39950072AF1B /* Debug */ = { 367 | isa = XCBuildConfiguration; 368 | buildSettings = { 369 | PRODUCT_NAME = "$(TARGET_NAME)"; 370 | }; 371 | name = Debug; 372 | }; 373 | BAA0A6021E9A39950072AF1B /* Release */ = { 374 | isa = XCBuildConfiguration; 375 | buildSettings = { 376 | PRODUCT_NAME = "$(TARGET_NAME)"; 377 | }; 378 | name = Release; 379 | }; 380 | BAAF043C1E94F85300F3CB23 /* Debug */ = { 381 | isa = XCBuildConfiguration; 382 | buildSettings = { 383 | ALWAYS_SEARCH_USER_PATHS = NO; 384 | CLANG_ANALYZER_NONNULL = YES; 385 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 386 | CLANG_CXX_LIBRARY = "libc++"; 387 | CLANG_ENABLE_MODULES = YES; 388 | CLANG_ENABLE_OBJC_ARC = YES; 389 | CLANG_WARN_BOOL_CONVERSION = YES; 390 | CLANG_WARN_CONSTANT_CONVERSION = YES; 391 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 392 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 393 | CLANG_WARN_EMPTY_BODY = YES; 394 | CLANG_WARN_ENUM_CONVERSION = YES; 395 | CLANG_WARN_INFINITE_RECURSION = YES; 396 | CLANG_WARN_INT_CONVERSION = YES; 397 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 398 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 399 | CLANG_WARN_UNREACHABLE_CODE = YES; 400 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 401 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 402 | COPY_PHASE_STRIP = NO; 403 | DEBUG_INFORMATION_FORMAT = dwarf; 404 | ENABLE_STRICT_OBJC_MSGSEND = YES; 405 | ENABLE_TESTABILITY = YES; 406 | GCC_C_LANGUAGE_STANDARD = gnu99; 407 | GCC_DYNAMIC_NO_PIC = NO; 408 | GCC_NO_COMMON_BLOCKS = YES; 409 | GCC_OPTIMIZATION_LEVEL = 0; 410 | GCC_PREPROCESSOR_DEFINITIONS = ( 411 | "DEBUG=1", 412 | "$(inherited)", 413 | ); 414 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 415 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 416 | GCC_WARN_UNDECLARED_SELECTOR = YES; 417 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 418 | GCC_WARN_UNUSED_FUNCTION = YES; 419 | GCC_WARN_UNUSED_VARIABLE = YES; 420 | HEADER_SEARCH_PATHS = "$(CONFIGURATION_BUILD_DIR)"; 421 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 422 | MTL_ENABLE_DEBUG_INFO = YES; 423 | ONLY_ACTIVE_ARCH = YES; 424 | SDKROOT = iphoneos; 425 | USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../node_modules/react-native/React"; 426 | }; 427 | name = Debug; 428 | }; 429 | BAAF043D1E94F85300F3CB23 /* Release */ = { 430 | isa = XCBuildConfiguration; 431 | buildSettings = { 432 | ALWAYS_SEARCH_USER_PATHS = NO; 433 | CLANG_ANALYZER_NONNULL = YES; 434 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 435 | CLANG_CXX_LIBRARY = "libc++"; 436 | CLANG_ENABLE_MODULES = YES; 437 | CLANG_ENABLE_OBJC_ARC = YES; 438 | CLANG_WARN_BOOL_CONVERSION = YES; 439 | CLANG_WARN_CONSTANT_CONVERSION = YES; 440 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 441 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 442 | CLANG_WARN_EMPTY_BODY = YES; 443 | CLANG_WARN_ENUM_CONVERSION = YES; 444 | CLANG_WARN_INFINITE_RECURSION = YES; 445 | CLANG_WARN_INT_CONVERSION = YES; 446 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 447 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 448 | CLANG_WARN_UNREACHABLE_CODE = YES; 449 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 450 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 451 | COPY_PHASE_STRIP = NO; 452 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 453 | ENABLE_NS_ASSERTIONS = NO; 454 | ENABLE_STRICT_OBJC_MSGSEND = YES; 455 | GCC_C_LANGUAGE_STANDARD = gnu99; 456 | GCC_NO_COMMON_BLOCKS = YES; 457 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 458 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 459 | GCC_WARN_UNDECLARED_SELECTOR = YES; 460 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 461 | GCC_WARN_UNUSED_FUNCTION = YES; 462 | GCC_WARN_UNUSED_VARIABLE = YES; 463 | HEADER_SEARCH_PATHS = "$(CONFIGURATION_BUILD_DIR)"; 464 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 465 | MTL_ENABLE_DEBUG_INFO = NO; 466 | SDKROOT = iphoneos; 467 | USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../node_modules/react-native/React"; 468 | VALIDATE_PRODUCT = YES; 469 | }; 470 | name = Release; 471 | }; 472 | BAAF043F1E94F85300F3CB23 /* Debug */ = { 473 | isa = XCBuildConfiguration; 474 | buildSettings = { 475 | OTHER_LDFLAGS = "-ObjC"; 476 | PRODUCT_NAME = "$(TARGET_NAME)"; 477 | SKIP_INSTALL = YES; 478 | }; 479 | name = Debug; 480 | }; 481 | BAAF04401E94F85300F3CB23 /* Release */ = { 482 | isa = XCBuildConfiguration; 483 | buildSettings = { 484 | OTHER_LDFLAGS = "-ObjC"; 485 | PRODUCT_NAME = "$(TARGET_NAME)"; 486 | SKIP_INSTALL = YES; 487 | }; 488 | name = Release; 489 | }; 490 | /* End XCBuildConfiguration section */ 491 | 492 | /* Begin XCConfigurationList section */ 493 | BAA0A6001E9A39950072AF1B /* Build configuration list for PBXAggregateTarget "UniversalLib" */ = { 494 | isa = XCConfigurationList; 495 | buildConfigurations = ( 496 | BAA0A6011E9A39950072AF1B /* Debug */, 497 | BAA0A6021E9A39950072AF1B /* Release */, 498 | ); 499 | defaultConfigurationIsVisible = 0; 500 | defaultConfigurationName = Release; 501 | }; 502 | BAAF04301E94F85300F3CB23 /* Build configuration list for PBXProject "RNTHorizontalPicker" */ = { 503 | isa = XCConfigurationList; 504 | buildConfigurations = ( 505 | BAAF043C1E94F85300F3CB23 /* Debug */, 506 | BAAF043D1E94F85300F3CB23 /* Release */, 507 | ); 508 | defaultConfigurationIsVisible = 0; 509 | defaultConfigurationName = Release; 510 | }; 511 | BAAF043E1E94F85300F3CB23 /* Build configuration list for PBXNativeTarget "RNTHorizontalPicker" */ = { 512 | isa = XCConfigurationList; 513 | buildConfigurations = ( 514 | BAAF043F1E94F85300F3CB23 /* Debug */, 515 | BAAF04401E94F85300F3CB23 /* Release */, 516 | ); 517 | defaultConfigurationIsVisible = 0; 518 | defaultConfigurationName = Release; 519 | }; 520 | /* End XCConfigurationList section */ 521 | }; 522 | rootObject = BAAF042D1E94F85300F3CB23 /* Project object */; 523 | } 524 | -------------------------------------------------------------------------------- /RNTHorizontalPicker.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /RNTHorizontalPicker.xcodeproj/project.xcworkspace/xcuserdata/jeremyeaton.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vineetha2438/react-native-horizontal-picker/38fe2a9201a69ee7d6511bb0790c40601377418d/RNTHorizontalPicker.xcodeproj/project.xcworkspace/xcuserdata/jeremyeaton.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /RNTHorizontalPicker.xcodeproj/project.xcworkspace/xcuserdata/kvineetha.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vineetha2438/react-native-horizontal-picker/38fe2a9201a69ee7d6511bb0790c40601377418d/RNTHorizontalPicker.xcodeproj/project.xcworkspace/xcuserdata/kvineetha.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /RNTHorizontalPicker.xcodeproj/xcuserdata/kvineetha.xcuserdatad/xcschemes/RNTHorizontalPicker.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /RNTHorizontalPicker.xcodeproj/xcuserdata/kvineetha.xcuserdatad/xcschemes/UniversalLib.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /RNTHorizontalPicker.xcodeproj/xcuserdata/kvineetha.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | RNTHorizontalPicker.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | UniversalLib.xcscheme 13 | 14 | orderHint 15 | 11 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | BAA0A5FF1E9A39950072AF1B 21 | 22 | primary 23 | 24 | 25 | BAAF04341E94F85300F3CB23 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /RNTHorizontalPicker/AKPickerView.h: -------------------------------------------------------------------------------- 1 | // 2 | // AKPickerView.h 3 | // AKPickerViewSample 4 | // 5 | // Created by Akio Yasui on 3/29/14. 6 | // Copyright (c) 2014 Akio Yasui. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSInteger, AKPickerViewStyle) { 12 | AKPickerViewStyle3D = 1, 13 | AKPickerViewStyleFlat 14 | }; 15 | 16 | @class AKPickerView; 17 | 18 | @protocol AKPickerViewDataSource 19 | @required 20 | - (NSUInteger)numberOfItemsInPickerView:(AKPickerView *)pickerView; 21 | @optional 22 | - (NSString *)pickerView:(AKPickerView *)pickerView titleForItem:(NSInteger)item; 23 | - (UIImage *)pickerView:(AKPickerView *)pickerView imageForItem:(NSInteger)item; 24 | @end 25 | 26 | @protocol AKPickerViewDelegate 27 | @optional 28 | - (void)pickerView:(AKPickerView *)pickerView didSelectItem:(NSInteger)item; 29 | - (CGSize)pickerView:(AKPickerView *)pickerView marginForItem:(NSInteger)item; 30 | - (void)pickerView:(AKPickerView *)pickerView configureLabel:(UILabel * const)label forItem:(NSInteger)item; 31 | @end 32 | 33 | @interface AKPickerView : UIView 34 | 35 | @property (nonatomic, weak) id dataSource; 36 | @property (nonatomic, weak) id delegate; 37 | @property (nonatomic, strong) UIFont *font; 38 | @property (nonatomic, strong) UIFont *highlightedFont; 39 | @property (nonatomic, strong) UIColor *textColor; 40 | @property (nonatomic, strong) UIColor *highlightedTextColor; 41 | @property (nonatomic, assign) CGFloat interitemSpacing; 42 | @property (nonatomic, assign) CGFloat fisheyeFactor; // 0...1; slight value recommended such as 0.0001 43 | @property (nonatomic, assign, getter=isMaskDisabled) BOOL maskDisabled; 44 | @property (nonatomic, assign) AKPickerViewStyle pickerViewStyle; 45 | @property (nonatomic, assign, readonly) NSUInteger selectedItem; 46 | @property (nonatomic, assign, readonly) CGPoint contentOffset; 47 | 48 | - (void)reloadData; 49 | - (void)scrollToItem:(NSUInteger)item animated:(BOOL)animated; 50 | - (void)selectItem:(NSUInteger)item animated:(BOOL)animated; 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /RNTHorizontalPicker/AKPickerView.m: -------------------------------------------------------------------------------- 1 | // 2 | // AKPickerView.m 3 | // AKPickerViewSample 4 | // 5 | // Created by Akio Yasui on 3/29/14. 6 | // Copyright (c) 2014 Akio Yasui. All rights reserved. 7 | // 8 | 9 | #import "AKPickerView.h" 10 | 11 | #import 12 | 13 | @class AKCollectionViewLayout; 14 | 15 | @protocol AKCollectionViewLayoutDelegate 16 | - (AKPickerViewStyle)pickerViewStyleForCollectionViewLayout:(AKCollectionViewLayout *)layout; 17 | @end 18 | 19 | @interface AKCollectionViewCell : UICollectionViewCell 20 | @property (nonatomic, strong) UILabel *label; 21 | @property (nonatomic, strong) UIImageView *imageView; 22 | @property (nonatomic, strong) UIFont *font; 23 | @property (nonatomic, strong) UIFont *highlightedFont; 24 | @end 25 | 26 | @interface AKCollectionViewLayout : UICollectionViewFlowLayout 27 | @property (nonatomic, assign) id delegate; 28 | @end 29 | 30 | @interface AKPickerViewDelegateIntercepter : NSObject 31 | @property (nonatomic, weak) AKPickerView *pickerView; 32 | @property (nonatomic, weak) id delegate; 33 | @end 34 | 35 | @interface AKPickerView () 36 | @property (nonatomic, strong) UICollectionView *collectionView; 37 | @property (nonatomic, assign) NSUInteger selectedItem; 38 | @property (nonatomic, strong) AKPickerViewDelegateIntercepter *intercepter; 39 | - (CGFloat)offsetForItem:(NSUInteger)item; 40 | - (void)didEndScrolling; 41 | - (CGSize)sizeForString:(NSString *)string; 42 | @end 43 | 44 | @implementation AKPickerView 45 | 46 | - (void)initialize 47 | { 48 | self.font = self.font ?: [UIFont fontWithName:@"HelveticaNeue-Light" size:20]; 49 | self.highlightedFont = self.highlightedFont ?: [UIFont fontWithName:@"HelveticaNeue" size:20]; 50 | self.textColor = self.textColor ?: [UIColor darkGrayColor]; 51 | self.highlightedTextColor = self.highlightedTextColor ?: [UIColor blackColor]; 52 | self.pickerViewStyle = self.pickerViewStyle ?: AKPickerViewStyle3D; 53 | self.maskDisabled = self.maskDisabled; 54 | 55 | [self.collectionView removeFromSuperview]; 56 | self.collectionView = [[UICollectionView alloc] initWithFrame:self.bounds 57 | collectionViewLayout:[self collectionViewLayout]]; 58 | self.collectionView.showsHorizontalScrollIndicator = NO; 59 | self.collectionView.backgroundColor = [UIColor clearColor]; 60 | self.collectionView.decelerationRate = UIScrollViewDecelerationRateFast; 61 | self.collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 62 | self.collectionView.dataSource = self; 63 | [self.collectionView registerClass:[AKCollectionViewCell class] 64 | forCellWithReuseIdentifier:NSStringFromClass([AKCollectionViewCell class])]; 65 | [self addSubview:self.collectionView]; 66 | 67 | self.intercepter = [AKPickerViewDelegateIntercepter new]; 68 | self.intercepter.pickerView = self; 69 | self.intercepter.delegate = self.delegate; 70 | self.collectionView.delegate = self.intercepter; 71 | } 72 | 73 | - (id)initWithFrame:(CGRect)frame 74 | { 75 | self = [super initWithFrame:frame]; 76 | if (self) { 77 | [self initialize]; 78 | } 79 | return self; 80 | } 81 | 82 | - (id)initWithCoder:(NSCoder *)aDecoder 83 | { 84 | self = [super initWithCoder:aDecoder]; 85 | if (self) { 86 | [self initialize]; 87 | } 88 | return self; 89 | } 90 | 91 | - (void)dealloc 92 | { 93 | self.collectionView.delegate = nil; 94 | } 95 | 96 | #pragma mark - 97 | 98 | - (void)layoutSubviews 99 | { 100 | [super layoutSubviews]; 101 | self.collectionView.collectionViewLayout = [self collectionViewLayout]; 102 | if ([self.dataSource numberOfItemsInPickerView:self]) { 103 | [self scrollToItem:self.selectedItem animated:NO]; 104 | } 105 | self.collectionView.layer.mask.frame = self.collectionView.bounds; 106 | } 107 | 108 | - (CGSize)intrinsicContentSize 109 | { 110 | return CGSizeMake(UIViewNoIntrinsicMetric, MAX(self.font.lineHeight, self.highlightedFont.lineHeight)); 111 | } 112 | 113 | - (CGPoint)contentOffset 114 | { 115 | return self.collectionView.contentOffset; 116 | } 117 | 118 | #pragma mark - 119 | 120 | - (void)setDelegate:(id)delegate 121 | { 122 | if (![_delegate isEqual:delegate]) { 123 | _delegate = delegate; 124 | self.intercepter.delegate = delegate; 125 | } 126 | } 127 | 128 | - (void)setFisheyeFactor:(CGFloat)fisheyeFactor 129 | { 130 | _fisheyeFactor = fisheyeFactor; 131 | 132 | CATransform3D transform = CATransform3DIdentity; 133 | transform.m34 = -MAX(MIN(self.fisheyeFactor, 1.0), 0.0); 134 | self.collectionView.layer.sublayerTransform = transform; 135 | } 136 | 137 | - (void)setMaskDisabled:(BOOL)maskDisabled 138 | { 139 | _maskDisabled = maskDisabled; 140 | 141 | self.collectionView.layer.mask = maskDisabled ? nil : ({ 142 | CAGradientLayer *maskLayer = [CAGradientLayer layer]; 143 | maskLayer.frame = self.collectionView.bounds; 144 | maskLayer.colors = @[(id)[[UIColor clearColor] CGColor], 145 | (id)[[UIColor blackColor] CGColor], 146 | (id)[[UIColor blackColor] CGColor], 147 | (id)[[UIColor clearColor] CGColor],]; 148 | maskLayer.locations = @[@0.0, @0.33, @0.66, @1.0]; 149 | maskLayer.startPoint = CGPointMake(0.0, 0.0); 150 | maskLayer.endPoint = CGPointMake(1.0, 0.0); 151 | maskLayer; 152 | }); 153 | } 154 | 155 | #pragma mark - 156 | 157 | - (AKCollectionViewLayout *)collectionViewLayout 158 | { 159 | AKCollectionViewLayout *layout = [AKCollectionViewLayout new]; 160 | layout.delegate = self; 161 | return layout; 162 | } 163 | 164 | - (CGSize)sizeForString:(NSString *)string 165 | { 166 | CGSize size; 167 | CGSize highlightedSize; 168 | #ifdef __IPHONE_7_0 169 | size = [string sizeWithAttributes:@{NSFontAttributeName: self.font}]; 170 | highlightedSize = [string sizeWithAttributes:@{NSFontAttributeName: self.highlightedFont}]; 171 | #else 172 | size = [string sizeWithFont:self.font]; 173 | highlightedSize = [string sizeWithFont:self.highlightedFont]; 174 | #endif 175 | return CGSizeMake(ceilf(MAX(size.width, highlightedSize.width)), ceilf(MAX(size.height, highlightedSize.height))); 176 | } 177 | 178 | #pragma mark - 179 | 180 | - (void)reloadData 181 | { 182 | [self invalidateIntrinsicContentSize]; 183 | [self.collectionView.collectionViewLayout invalidateLayout]; 184 | [self.collectionView reloadData]; 185 | if ([self.dataSource numberOfItemsInPickerView:self]) { 186 | [self selectItem:self.selectedItem animated:NO notifySelection:NO]; 187 | } 188 | } 189 | 190 | - (CGFloat)offsetForItem:(NSUInteger)item 191 | { 192 | NSAssert(item < [self.collectionView numberOfItemsInSection:0], 193 | @"item out of range; '%lu' passed, but the maximum is '%lu'", item, [self.collectionView numberOfItemsInSection:0]); 194 | 195 | CGFloat offset = 0.0; 196 | 197 | for (NSInteger i = 0; i < item; i++) { 198 | NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0]; 199 | CGSize cellSize = [self collectionView:self.collectionView layout:self.collectionView.collectionViewLayout sizeForItemAtIndexPath:indexPath]; 200 | offset += cellSize.width; 201 | } 202 | 203 | NSIndexPath *firstIndexPath = [NSIndexPath indexPathForItem:0 inSection:0]; 204 | CGSize firstSize = [self collectionView:self.collectionView layout:self.collectionView.collectionViewLayout sizeForItemAtIndexPath:firstIndexPath]; 205 | NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForItem:item inSection:0]; 206 | CGSize selectedSize = [self collectionView:self.collectionView layout:self.collectionView.collectionViewLayout sizeForItemAtIndexPath:selectedIndexPath]; 207 | offset -= (firstSize.width - selectedSize.width) / 2; 208 | 209 | return offset; 210 | } 211 | 212 | - (void)scrollToItem:(NSUInteger)item animated:(BOOL)animated 213 | { 214 | switch (self.pickerViewStyle) { 215 | case AKPickerViewStyleFlat: { 216 | [self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:item inSection:0] 217 | atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally 218 | animated:animated]; 219 | break; 220 | } 221 | case AKPickerViewStyle3D: { 222 | [self.collectionView setContentOffset:CGPointMake([self offsetForItem:item], self.collectionView.contentOffset.y) 223 | animated:animated]; 224 | break; 225 | } 226 | default: break; 227 | } 228 | } 229 | 230 | - (void)selectItem:(NSUInteger)item animated:(BOOL)animated 231 | { 232 | [self selectItem:item animated:animated notifySelection:YES]; 233 | } 234 | 235 | - (void)selectItem:(NSUInteger)item animated:(BOOL)animated notifySelection:(BOOL)notifySelection 236 | { 237 | [self.collectionView selectItemAtIndexPath:[NSIndexPath indexPathForItem:item inSection:0] 238 | animated:animated 239 | scrollPosition:UICollectionViewScrollPositionNone]; 240 | [self scrollToItem:item animated:animated]; 241 | 242 | self.selectedItem = item; 243 | 244 | if (notifySelection && 245 | [self.delegate respondsToSelector:@selector(pickerView:didSelectItem:)]) 246 | [self.delegate pickerView:self didSelectItem:item]; 247 | } 248 | 249 | - (void)didEndScrolling 250 | { 251 | switch (self.pickerViewStyle) { 252 | case AKPickerViewStyleFlat: { 253 | CGPoint center = [self convertPoint:self.collectionView.center toView:self.collectionView]; 254 | NSIndexPath *indexPath = [self.collectionView indexPathForItemAtPoint:center]; 255 | [self selectItem:indexPath.item animated:YES]; 256 | break; 257 | } 258 | case AKPickerViewStyle3D: { 259 | if ([self.dataSource numberOfItemsInPickerView:self]) { 260 | for (NSUInteger i = 0; i < [self collectionView:self.collectionView numberOfItemsInSection:0]; i++) { 261 | NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0]; 262 | AKCollectionViewCell *cell = (AKCollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath]; 263 | if ([self offsetForItem:i] + cell.bounds.size.width / 2 > self.collectionView.contentOffset.x) { 264 | [self selectItem:i animated:YES]; 265 | break; 266 | } 267 | } 268 | } 269 | break; 270 | } 271 | default: break; 272 | } 273 | } 274 | 275 | #pragma mark - 276 | 277 | - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView 278 | { 279 | return ([self.dataSource numberOfItemsInPickerView:self] > 0); 280 | } 281 | 282 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section 283 | { 284 | return [self.dataSource numberOfItemsInPickerView:self]; 285 | } 286 | 287 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 288 | { 289 | AKCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([AKCollectionViewCell class]) 290 | forIndexPath:indexPath]; 291 | 292 | if ([self.dataSource respondsToSelector:@selector(pickerView:titleForItem:)]) { 293 | NSString *title = [self.dataSource pickerView:self titleForItem:indexPath.item]; 294 | cell.label.text = title; 295 | cell.label.textColor = self.textColor; 296 | cell.label.highlightedTextColor = self.highlightedTextColor; 297 | cell.label.font = self.font; 298 | cell.font = self.font; 299 | cell.highlightedFont = self.highlightedFont; 300 | cell.label.bounds = (CGRect){CGPointZero, [self sizeForString:title]}; 301 | if ([self.delegate respondsToSelector:@selector(pickerView:marginForItem:)]) { 302 | CGSize margin = [self.delegate pickerView:self marginForItem:indexPath.item]; 303 | cell.label.frame = CGRectInset(cell.label.frame, -margin.width, -margin.height); 304 | } 305 | if ([self.delegate respondsToSelector:@selector(pickerView:configureLabel:forItem:)]) { 306 | [self.delegate pickerView:self configureLabel:cell.label forItem:indexPath.item]; 307 | } 308 | } else if ([self.dataSource respondsToSelector:@selector(pickerView:imageForItem:)]) { 309 | cell.imageView.image = [self.dataSource pickerView:self imageForItem:indexPath.item]; 310 | } 311 | cell.selected = (indexPath.item == self.selectedItem); 312 | 313 | return cell; 314 | } 315 | 316 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath 317 | { 318 | CGSize size = CGSizeMake(self.interitemSpacing, collectionView.bounds.size.height); 319 | if ([self.dataSource respondsToSelector:@selector(pickerView:titleForItem:)]) { 320 | NSString *title = [self.dataSource pickerView:self titleForItem:indexPath.item]; 321 | size.width += [self sizeForString:title].width; 322 | if ([self.delegate respondsToSelector:@selector(pickerView:marginForItem:)]) { 323 | CGSize margin = [self.delegate pickerView:self marginForItem:indexPath.item]; 324 | size.width += margin.width * 2; 325 | } 326 | } else if ([self.dataSource respondsToSelector:@selector(pickerView:imageForItem:)]) { 327 | UIImage *image = [self.dataSource pickerView:self imageForItem:indexPath.item]; 328 | size.width += image.size.width; 329 | } 330 | return size; 331 | } 332 | 333 | - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section 334 | { 335 | return 0.0; 336 | } 337 | 338 | - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section 339 | { 340 | return 0.0; 341 | } 342 | 343 | - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section 344 | { 345 | NSInteger number = [self collectionView:collectionView numberOfItemsInSection:section]; 346 | NSIndexPath *firstIndexPath = [NSIndexPath indexPathForItem:0 inSection:section]; 347 | CGSize firstSize = [self collectionView:collectionView layout:collectionViewLayout sizeForItemAtIndexPath:firstIndexPath]; 348 | NSIndexPath *lastIndexPath = [NSIndexPath indexPathForItem:number - 1 inSection:section]; 349 | CGSize lastSize = [self collectionView:collectionView layout:collectionViewLayout sizeForItemAtIndexPath:lastIndexPath]; 350 | return UIEdgeInsetsMake(0, (collectionView.bounds.size.width - firstSize.width) / 2, 351 | 0, (collectionView.bounds.size.width - lastSize.width) / 2); 352 | } 353 | 354 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 355 | { 356 | [self selectItem:indexPath.item animated:YES]; 357 | } 358 | 359 | #pragma mark - 360 | 361 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView 362 | { 363 | if ([self.delegate respondsToSelector:@selector(scrollViewDidEndDecelerating:)]) 364 | [self.delegate scrollViewDidEndDecelerating:scrollView]; 365 | 366 | if (!scrollView.isTracking) [self didEndScrolling]; 367 | } 368 | 369 | - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate 370 | { 371 | if ([self.delegate respondsToSelector:@selector(scrollViewDidEndDragging:willDecelerate:)]) 372 | [self.delegate scrollViewDidEndDragging:scrollView willDecelerate:decelerate]; 373 | 374 | if (!decelerate) [self didEndScrolling]; 375 | } 376 | 377 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView 378 | { 379 | if ([self.delegate respondsToSelector:@selector(scrollViewDidScroll:)]) 380 | [self.delegate scrollViewDidScroll:scrollView]; 381 | 382 | [CATransaction begin]; 383 | [CATransaction setValue:(id)kCFBooleanTrue 384 | forKey:kCATransactionDisableActions]; 385 | self.collectionView.layer.mask.frame = self.collectionView.bounds; 386 | [CATransaction commit]; 387 | } 388 | 389 | #pragma mark - 390 | 391 | - (AKPickerViewStyle)pickerViewStyleForCollectionViewLayout:(AKCollectionViewLayout *)layout 392 | { 393 | return self.pickerViewStyle; 394 | } 395 | 396 | @end 397 | 398 | @implementation AKCollectionViewCell 399 | 400 | - (void)initialize 401 | { 402 | self.layer.doubleSided = NO; 403 | self.label = [[UILabel alloc] initWithFrame:self.contentView.bounds]; 404 | self.label.backgroundColor = [UIColor clearColor]; 405 | self.label.textAlignment = NSTextAlignmentCenter; 406 | self.label.textColor = [UIColor grayColor]; 407 | self.label.numberOfLines = 1; 408 | self.label.lineBreakMode = NSLineBreakByTruncatingTail; 409 | self.label.highlightedTextColor = [UIColor blackColor]; 410 | self.label.font = [UIFont systemFontOfSize:[UIFont systemFontSize]]; 411 | self.label.autoresizingMask = (UIViewAutoresizingFlexibleTopMargin | 412 | UIViewAutoresizingFlexibleLeftMargin | 413 | UIViewAutoresizingFlexibleBottomMargin | 414 | UIViewAutoresizingFlexibleRightMargin); 415 | [self.contentView addSubview:self.label]; 416 | 417 | self.imageView = [[UIImageView alloc] initWithFrame:self.contentView.bounds]; 418 | self.imageView.backgroundColor = [UIColor clearColor]; 419 | self.imageView.contentMode = UIViewContentModeCenter; 420 | self.imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 421 | [self.contentView addSubview:self.imageView]; 422 | } 423 | 424 | - (id)initWithFrame:(CGRect)frame 425 | { 426 | self = [super initWithFrame:frame]; 427 | if (self) { 428 | [self initialize]; 429 | } 430 | return self; 431 | } 432 | 433 | - (id)initWithCoder:(NSCoder *)aDecoder 434 | { 435 | self = [super initWithCoder:aDecoder]; 436 | if (self) { 437 | [self initialize]; 438 | } 439 | return self; 440 | } 441 | 442 | - (void)setSelected:(BOOL)selected 443 | { 444 | [super setSelected:selected]; 445 | 446 | CATransition *transition = [CATransition animation]; 447 | [transition setType:kCATransitionFade]; 448 | [transition setDuration:0.15]; 449 | [self.label.layer addAnimation:transition forKey:nil]; 450 | 451 | self.label.font = self.selected ? self.highlightedFont : self.font; 452 | } 453 | 454 | @end 455 | 456 | @interface AKCollectionViewLayout () 457 | @property (nonatomic, assign) CGFloat width; 458 | @property (nonatomic, assign) CGFloat midX; 459 | @property (nonatomic, assign) CGFloat maxAngle; 460 | @end 461 | 462 | @implementation AKCollectionViewLayout 463 | 464 | - (id)init 465 | { 466 | self = [super init]; 467 | if (self) { 468 | self.sectionInset = UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0); 469 | self.scrollDirection = UICollectionViewScrollDirectionHorizontal; 470 | self.minimumLineSpacing = 0.0; 471 | } 472 | return self; 473 | } 474 | 475 | - (void)prepareLayout 476 | { 477 | CGRect visibleRect = (CGRect){self.collectionView.contentOffset, self.collectionView.bounds.size}; 478 | self.midX = CGRectGetMidX(visibleRect); 479 | self.width = CGRectGetWidth(visibleRect) / 2; 480 | self.maxAngle = M_PI_2; 481 | } 482 | 483 | - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds 484 | { 485 | return YES; 486 | } 487 | 488 | - (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath 489 | { 490 | UICollectionViewLayoutAttributes *attributes = [[super layoutAttributesForItemAtIndexPath:indexPath] copy]; 491 | switch ([self.delegate pickerViewStyleForCollectionViewLayout:self]) { 492 | case AKPickerViewStyleFlat: { 493 | return attributes; break; 494 | } 495 | case AKPickerViewStyle3D: { 496 | CGFloat distance = CGRectGetMidX(attributes.frame) - self.midX; 497 | CGFloat currentAngle = self.maxAngle * distance / self.width / M_PI_2; 498 | CATransform3D transform = CATransform3DIdentity; 499 | transform = CATransform3DTranslate(transform, -distance, 0, -self.width); 500 | transform = CATransform3DRotate(transform, currentAngle, 0, 1, 0); 501 | transform = CATransform3DTranslate(transform, 0, 0, self.width); 502 | attributes.transform3D = transform; 503 | attributes.alpha = (ABS(currentAngle) < self.maxAngle); 504 | return attributes; break; 505 | } 506 | default: return nil; break; 507 | } 508 | } 509 | 510 | - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect 511 | { 512 | switch ([self.delegate pickerViewStyleForCollectionViewLayout:self]) { 513 | case AKPickerViewStyleFlat: { 514 | return [super layoutAttributesForElementsInRect:rect]; 515 | break; 516 | } 517 | case AKPickerViewStyle3D: { 518 | NSMutableArray *attributes = [NSMutableArray array]; 519 | if ([self.collectionView numberOfSections]) { 520 | for (NSInteger i = 0; i < [self.collectionView numberOfItemsInSection:0]; i++) { 521 | NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0]; 522 | [attributes addObject:[self layoutAttributesForItemAtIndexPath:indexPath]]; 523 | } 524 | } 525 | return attributes; 526 | break; 527 | } 528 | default: return nil; break; 529 | } 530 | } 531 | 532 | @end 533 | 534 | @implementation AKPickerViewDelegateIntercepter 535 | 536 | - (id)forwardingTargetForSelector:(SEL)aSelector 537 | { 538 | if ([self.pickerView respondsToSelector:aSelector]) return self.pickerView; 539 | if ([self.delegate respondsToSelector:aSelector]) return self.delegate; 540 | return [super forwardingTargetForSelector:aSelector]; 541 | } 542 | 543 | - (BOOL)respondsToSelector:(SEL)aSelector 544 | { 545 | if ([self.pickerView respondsToSelector:aSelector]) return YES; 546 | if ([self.delegate respondsToSelector:aSelector]) return YES; 547 | return [super respondsToSelector:aSelector]; 548 | } 549 | 550 | @end 551 | -------------------------------------------------------------------------------- /RNTHorizontalPicker/RNTHorizontalPicker.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNTHorizontalPicker.h 3 | // RNTHorizontalPicker 4 | // 5 | // Created by K Vineetha on 4/5/17. 6 | // Copyright © 2017 MDL. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RNTHorizontalPicker : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /RNTHorizontalPicker/RNTHorizontalPicker.m: -------------------------------------------------------------------------------- 1 | // 2 | // RNTHorizontalPicker.m 3 | // RNTHorizontalPicker 4 | // 5 | // Created by K Vineetha on 4/5/17. 6 | // Copyright © 2017 MDL. All rights reserved. 7 | // 8 | 9 | #import "RNTHorizontalPicker.h" 10 | 11 | #import "AKPickerView.h" 12 | #import 13 | 14 | @interface RNTHorizontalPicker () 15 | @property (nonatomic, strong) AKPickerView *pickerView; 16 | @property (nonatomic, strong) NSMutableArray *titles; 17 | @property (nonatomic, copy) RCTBubblingEventBlock onChange; 18 | @property (nonatomic, assign) NSInteger selectedIndex; 19 | @end 20 | 21 | @implementation RNTHorizontalPicker 22 | 23 | - (id)initWithFrame:(CGRect)frame 24 | { 25 | self = [super initWithFrame:frame]; 26 | self.pickerView = [[AKPickerView alloc] initWithFrame:self.bounds]; 27 | self.pickerView.delegate = self; 28 | self.pickerView.dataSource = self; 29 | self.pickerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 30 | [self addSubview:self.pickerView]; 31 | 32 | self.pickerView.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:60]; 33 | self.pickerView.highlightedFont = [UIFont fontWithName:@"HelveticaNeue-Bold" size:70]; 34 | self.pickerView.interitemSpacing = 6.0; 35 | self.pickerView.fisheyeFactor = 0.001; 36 | self.pickerView.pickerViewStyle = AKPickerViewStyle3D; 37 | self.pickerView.maskDisabled = false; 38 | return self; 39 | } 40 | 41 | #pragma mark - AKPickerViewDataSource 42 | 43 | - (void)setTitles:(NSArray *)titles 44 | { 45 | _titles = [NSMutableArray arrayWithArray:titles]; 46 | [_pickerView reloadData]; 47 | } 48 | 49 | 50 | - (NSUInteger)numberOfItemsInPickerView:(AKPickerView *)pickerView 51 | { 52 | return [self.titles count]; 53 | } 54 | 55 | /* 56 | * AKPickerView now support images! 57 | * 58 | * Please comment '-pickerView:titleForItem:' entirely 59 | * and uncomment '-pickerView:imageForItem:' to see how it works. 60 | * 61 | */ 62 | 63 | - (NSString *)pickerView:(AKPickerView *)pickerView titleForItem:(NSInteger)item 64 | { 65 | return self.titles[item]; 66 | } 67 | 68 | /* 69 | - (UIImage *)pickerView:(AKPickerView *)pickerView imageForItem:(NSInteger)item 70 | { 71 | return [UIImage imageNamed:self.titles[item]]; 72 | } 73 | */ 74 | 75 | #pragma mark - AKPickerViewDelegate 76 | 77 | - (void)pickerView:(AKPickerView *)pickerView didSelectItem:(NSInteger)item 78 | { 79 | if (_onChange) { 80 | _onChange(@{ 81 | @"newIndex": @(item), 82 | }); 83 | } 84 | } 85 | 86 | - (void)setSelectedIndex:(NSInteger)selectedIndex 87 | { 88 | _selectedIndex = selectedIndex; 89 | [_pickerView reloadData]; 90 | [_pickerView selectItem:_selectedIndex animated:true]; 91 | } 92 | 93 | 94 | /* 95 | * Label Customization 96 | * 97 | * You can customize labels by their any properties (except font,) 98 | * and margin around text. 99 | * These methods are optional, and ignored when using images. 100 | * 101 | */ 102 | 103 | /* 104 | - (void)pickerView:(AKPickerView *)pickerView configureLabel:(UILabel *const)label forItem:(NSInteger)item 105 | { 106 | label.textColor = [UIColor lightGrayColor]; 107 | label.highlightedTextColor = [UIColor whiteColor]; 108 | label.backgroundColor = [UIColor colorWithHue:(float)item/(float)self.titles.count 109 | saturation:1.0 110 | brightness:1.0 111 | alpha:1.0]; 112 | } 113 | */ 114 | 115 | /* 116 | - (CGSize)pickerView:(AKPickerView *)pickerView marginForItem:(NSInteger)item 117 | { 118 | return CGSizeMake(40, 20); 119 | } 120 | */ 121 | 122 | #pragma mark - UIScrollViewDelegate 123 | 124 | /* 125 | * AKPickerViewDelegate inherits UIScrollViewDelegate. 126 | * You can use UIScrollViewDelegate methods 127 | * by simply setting pickerView's delegate. 128 | * 129 | */ 130 | 131 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView 132 | { 133 | // Too noisy... 134 | // NSLog(@"%f", scrollView.contentOffset.x); 135 | } 136 | 137 | @end 138 | -------------------------------------------------------------------------------- /RNTHorizontalPicker/RNTHorizontalPickerManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // RNTHorizontalPickerManager.h 3 | // RNTHorizontalPicker 4 | // 5 | // Created by K Vineetha on 4/5/17. 6 | // Copyright © 2017 MDL. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RNTHorizontalPickerManager : RCTViewManager 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /RNTHorizontalPicker/RNTHorizontalPickerManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // RNTHorizontalPickerManager.m 3 | // RNTHorizontalPicker 4 | // 5 | // Created by K Vineetha on 4/5/17. 6 | // Copyright © 2017 MDL. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "RNTHorizontalPickerManager.h" 12 | #import "RNTHorizontalPicker.h" 13 | #import 14 | 15 | @implementation RNTHorizontalPickerManager 16 | 17 | RCT_EXPORT_MODULE(); 18 | 19 | RCT_EXPORT_VIEW_PROPERTY(titles, NSArray) 20 | RCT_EXPORT_VIEW_PROPERTY(onChange, RCTBubblingEventBlock) 21 | RCT_EXPORT_VIEW_PROPERTY(selectedIndex, NSInteger) 22 | RCT_EXPORT_VIEW_PROPERTY(fontSize, NSInteger) 23 | 24 | 25 | - (UIView *)view 26 | { 27 | 28 | RNTHorizontalPicker *theView; 29 | theView = [[RNTHorizontalPicker alloc] initWithFrame: CGRectMake(0, 0, 100, 100)]; 30 | return theView; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vineetha2438/react-native-horizontal-picker/38fe2a9201a69ee7d6511bb0790c40601377418d/Screenshot.png -------------------------------------------------------------------------------- /index.ios.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { requireNativeComponent, Event } from 'react-native'; 3 | import _ from 'lodash'; 4 | import PropTypes from 'prop-types'; 5 | 6 | const RNTHorizontalPicker = requireNativeComponent('RNTHorizontalPicker', { 7 | propTypes: { 8 | titles: PropTypes.array, 9 | selectedIndex: PropTypes.number 10 | } 11 | }, { 12 | nativeOnly: { 13 | onChange: true 14 | } 15 | }); 16 | 17 | export default class HorizontalPicker extends Component { 18 | constructor (props) { 19 | super(props); 20 | } 21 | 22 | convertToString(array) { 23 | return _.map(array, (item) => { 24 | return item.toString(); 25 | }); 26 | } 27 | 28 | render() { 29 | const { 30 | onChange, 31 | selectedIndex, 32 | style, 33 | titles 34 | } = this.props; 35 | return ( 36 | 42 | ); 43 | } 44 | } 45 | 46 | HorizontalPicker.defaultProps = { 47 | selectedIndex: 0, 48 | style: { width: 150, height: 100 }, 49 | titles: [1, 2, 3, 4] 50 | }; 51 | 52 | HorizontalPicker.propTypes = { 53 | onChange: PropTypes.func.isRequired, 54 | selectedIndex: PropTypes.number, 55 | style: PropTypes.object, 56 | titles: PropTypes.array.isRequired 57 | }; 58 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-horizontal-picker", 3 | "version": "0.0.1", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "asap": { 8 | "version": "2.0.6", 9 | "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", 10 | "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" 11 | }, 12 | "core-js": { 13 | "version": "1.2.7", 14 | "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", 15 | "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=" 16 | }, 17 | "encoding": { 18 | "version": "0.1.12", 19 | "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", 20 | "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", 21 | "requires": { 22 | "iconv-lite": "0.4.19" 23 | } 24 | }, 25 | "fbjs": { 26 | "version": "0.8.16", 27 | "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.16.tgz", 28 | "integrity": "sha1-XmdDL1UNxBtXK/VYR7ispk5TN9s=", 29 | "requires": { 30 | "core-js": "1.2.7", 31 | "isomorphic-fetch": "2.2.1", 32 | "loose-envify": "1.3.1", 33 | "object-assign": "4.1.1", 34 | "promise": "7.3.1", 35 | "setimmediate": "1.0.5", 36 | "ua-parser-js": "0.7.17" 37 | } 38 | }, 39 | "iconv-lite": { 40 | "version": "0.4.19", 41 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", 42 | "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" 43 | }, 44 | "is-stream": { 45 | "version": "1.1.0", 46 | "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", 47 | "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" 48 | }, 49 | "isomorphic-fetch": { 50 | "version": "2.2.1", 51 | "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", 52 | "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", 53 | "requires": { 54 | "node-fetch": "1.7.3", 55 | "whatwg-fetch": "2.0.3" 56 | } 57 | }, 58 | "js-tokens": { 59 | "version": "3.0.2", 60 | "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", 61 | "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" 62 | }, 63 | "loose-envify": { 64 | "version": "1.3.1", 65 | "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz", 66 | "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", 67 | "requires": { 68 | "js-tokens": "3.0.2" 69 | } 70 | }, 71 | "node-fetch": { 72 | "version": "1.7.3", 73 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", 74 | "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", 75 | "requires": { 76 | "encoding": "0.1.12", 77 | "is-stream": "1.1.0" 78 | } 79 | }, 80 | "object-assign": { 81 | "version": "4.1.1", 82 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 83 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" 84 | }, 85 | "promise": { 86 | "version": "7.3.1", 87 | "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", 88 | "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", 89 | "requires": { 90 | "asap": "2.0.6" 91 | } 92 | }, 93 | "prop-types": { 94 | "version": "15.6.0", 95 | "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.6.0.tgz", 96 | "integrity": "sha1-zq8IMCL8RrSjX2nhPvda7Q1jmFY=", 97 | "requires": { 98 | "fbjs": "0.8.16", 99 | "loose-envify": "1.3.1", 100 | "object-assign": "4.1.1" 101 | } 102 | }, 103 | "setimmediate": { 104 | "version": "1.0.5", 105 | "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", 106 | "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" 107 | }, 108 | "ua-parser-js": { 109 | "version": "0.7.17", 110 | "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.17.tgz", 111 | "integrity": "sha512-uRdSdu1oA1rncCQL7sCj8vSyZkgtL7faaw9Tc9rZ3mGgraQ7+Pdx7w5mnOSF3gw9ZNG6oc+KXfkon3bKuROm0g==" 112 | }, 113 | "whatwg-fetch": { 114 | "version": "2.0.3", 115 | "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz", 116 | "integrity": "sha1-nITsLc9oGH/wC8ZOEnS0QhduHIQ=" 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-horizontal-picker", 3 | "version": "0.0.1", 4 | "description": "", 5 | "main": "index", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/vineetha2438/react-native-horizontal-picker.git" 12 | }, 13 | "author": "K Vineetha", 14 | "license": "MIT", 15 | "dependencies": { 16 | "lodash": "^4.17.4", 17 | "prop-types": "^15.6.0" 18 | } 19 | } 20 | --------------------------------------------------------------------------------